@@ -137,6 +137,8 @@ public abstract class TileMultiblockMachineController extends TileEntityRestrict
137137
138138 protected Object animationFactory = null ;
139139
140+ protected boolean loaded = false ;
141+
140142 public TileMultiblockMachineController () {
141143 this .inventory = buildInventory ();
142144 this .inventory .setStackLimit (1 , BLUEPRINT_SLOT );
@@ -537,6 +539,11 @@ protected void onStructureFormed() {
537539 }
538540
539541 public void notifyStructureFormedState (boolean formed ) {
542+ //noinspection ConstantValue
543+ if (world == null || getPos () == null ) {
544+ // Where is the controller?
545+ return ;
546+ }
540547 IBlockState state = world .getBlockState (getPos ());
541548 if (controllerRotation == null || !(state .getBlock () instanceof BlockController )) {
542549 // Where is the controller?
@@ -1025,24 +1032,30 @@ public void incrementRecipeSearchRetryCount() {
10251032 @ Override
10261033 public void validate () {
10271034 super .validate ();
1028- if (FMLCommonHandler .instance ().getSide ().isClient ()) {
1029- ClientProxy .clientScheduler .addRunnable (() -> {
1030- BlockModelHider .hideOrShowBlocks (this );
1031- notifyStructureFormedState (isStructureFormed ());
1032- }, 0 );
1033- }
10341035 }
10351036
10361037 @ Override
10371038 public void invalidate () {
10381039 super .invalidate ();
1040+ loaded = false ;
10391041 foundComponents .forEach ((te , component ) -> MachineComponentManager .INSTANCE .removeOwner (te , this ));
10401042
10411043 if (getWorld ().isRemote ) {
10421044 BlockModelHider .hideOrShowBlocks (this );
10431045 }
10441046 }
10451047
1048+ @ Override
1049+ public void onLoad () {
1050+ if (FMLCommonHandler .instance ().getSide ().isClient ()) {
1051+ ClientProxy .clientScheduler .addRunnable (() -> {
1052+ BlockModelHider .hideOrShowBlocks (this );
1053+ notifyStructureFormedState (isStructureFormed ());
1054+ }, 0 );
1055+ loaded = true ;
1056+ }
1057+ }
1058+
10461059 @ Override
10471060 public void readCustomNBT (NBTTagCompound compound ) {
10481061 super .readCustomNBT (compound );
@@ -1060,16 +1073,14 @@ public void readCustomNBT(NBTTagCompound compound) {
10601073
10611074 readMachineNBT (compound );
10621075
1063- if (!isInvalid ()) {
1064- if (FMLCommonHandler .instance ().getSide ().isClient ()) {
1065- ClientProxy .clientScheduler .addRunnable (() -> {
1066- BlockModelHider .hideOrShowBlocks (this );
1067- notifyStructureFormedState (isStructureFormed ());
1068- if (!isStructureFormed ()) {
1069- animationFactory = null ;
1070- }
1071- }, 0 );
1072- }
1076+ if (loaded && FMLCommonHandler .instance ().getSide ().isClient ()) {
1077+ ClientProxy .clientScheduler .addRunnable (() -> {
1078+ BlockModelHider .hideOrShowBlocks (this );
1079+ notifyStructureFormedState (isStructureFormed ());
1080+ if (!isStructureFormed ()) {
1081+ animationFactory = null ;
1082+ }
1083+ }, 0 );
10731084 }
10741085 }
10751086
0 commit comments