From dd9c85e43e7f2ea22c0a85dfbff7ffd470dc0b47 Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Fri, 20 Jun 2014 12:12:48 -0500 Subject: [PATCH] Prevent block updates while loading parts; Should fix http://openeye.openmods.info/crashes/baf3e72a51ad8a5b8680ec24a819bc86 --- fmp/CableBusPart.java | 2 +- parts/CableBusContainer.java | 13 ++++++++++++- tile/networking/TileCableBus.java | 5 +---- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/fmp/CableBusPart.java b/fmp/CableBusPart.java index dba342a24..2069c1d86 100644 --- a/fmp/CableBusPart.java +++ b/fmp/CableBusPart.java @@ -551,7 +551,7 @@ public class CableBusPart extends JCuboidPart implements JNormalOcclusion, IReds if ( tile() instanceof TIInventoryTile ) ((TIInventoryTile) tile()).rebuildSlotMap(); - if ( world() != null && world().blockExists( x(), y(), z() ) ) + if ( world() != null && world().blockExists( x(), y(), z() ) && ! CableBusContainer.isLoading() ) world().notifyBlocksOfNeighborChange( x(), y(), z(), Platform.air ); } diff --git a/parts/CableBusContainer.java b/parts/CableBusContainer.java index 2e4347710..df711b427 100644 --- a/parts/CableBusContainer.java +++ b/parts/CableBusContainer.java @@ -320,12 +320,21 @@ public class CableBusContainer implements AEMultiTile, ICableBusContainer return null; } + private static final ThreadLocal isLoading = new ThreadLocal(); + + public static boolean isLoading() { + Boolean is = isLoading.get(); + return is != null && is == true; + } + public void addToWorld() { if ( inWorld ) return; + inWorld = true; - + isLoading.set( true ); + TileEntity te = getTile(); hasRedstone = te.getWorldObj().isBlockIndirectlyGettingPowered( te.xCoord, te.yCoord, te.zCoord ); @@ -372,6 +381,8 @@ public class CableBusContainer implements AEMultiTile, ICableBusContainer } partChanged(); + + isLoading.set(false); } public void removeFromWorld() diff --git a/tile/networking/TileCableBus.java b/tile/networking/TileCableBus.java index 11acff27a..98e0b51fa 100644 --- a/tile/networking/TileCableBus.java +++ b/tile/networking/TileCableBus.java @@ -126,10 +126,7 @@ public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomColl if ( cb.isEmpty() ) { if ( worldObj.getTileEntity( xCoord, yCoord, zCoord ) == this ) - { worldObj.func_147480_a( xCoord, yCoord, zCoord, true ); - // worldObj.destroyBlock( xCoord, yCoord, zCoord, true ); - } } else cb.addToWorld(); @@ -295,7 +292,7 @@ public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomColl @Override public void notifyNeighbors() { - if ( worldObj != null && worldObj.blockExists( xCoord, yCoord, zCoord ) ) + if ( worldObj != null && worldObj.blockExists( xCoord, yCoord, zCoord ) && ! CableBusContainer.isLoading() ) worldObj.notifyBlocksOfNeighborChange( xCoord, yCoord, zCoord, Platform.air ); }