From 730200ed8deadfb22e79e98843cf948a6b36fc66 Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Fri, 13 Jun 2014 14:39:36 -0500 Subject: [PATCH] Multi-block clean up should be cleaner now. --- me/cluster/IAEMultiBlock.java | 3 +- .../implementations/QuantumCalculator.java | 4 +- .../implementations/QuantumCluster.java | 13 ++--- .../SpatialPylonCalculator.java | 2 +- tile/qnb/TileQuantumBridge.java | 51 ++++++++++++++----- tile/spatial/TileSpatialPylon.java | 6 +-- 6 files changed, 51 insertions(+), 28 deletions(-) diff --git a/me/cluster/IAEMultiBlock.java b/me/cluster/IAEMultiBlock.java index 28bd256f..9384caea 100644 --- a/me/cluster/IAEMultiBlock.java +++ b/me/cluster/IAEMultiBlock.java @@ -3,10 +3,11 @@ package appeng.me.cluster; public interface IAEMultiBlock { - void disconnect(); + void disconnect(boolean b); IAECluster getCluster(); boolean isValid(); + } diff --git a/me/cluster/implementations/QuantumCalculator.java b/me/cluster/implementations/QuantumCalculator.java index 55068f93..7c730424 100644 --- a/me/cluster/implementations/QuantumCalculator.java +++ b/me/cluster/implementations/QuantumCalculator.java @@ -73,7 +73,7 @@ public class QuantumCalculator extends MBCalculator c.Ring[ringNum++] = te; } - te.updateStatus( c, flags ); + te.updateStatus( c, flags, true ); } } } @@ -89,7 +89,7 @@ public class QuantumCalculator extends MBCalculator @Override public void disconnect() { - tqb.disconnect(); + tqb.disconnect(true); } @Override diff --git a/me/cluster/implementations/QuantumCluster.java b/me/cluster/implementations/QuantumCluster.java index e9b9831a..8d3525e8 100644 --- a/me/cluster/implementations/QuantumCluster.java +++ b/me/cluster/implementations/QuantumCluster.java @@ -29,7 +29,7 @@ public class QuantumCluster implements ILocatable, IAECluster public WorldCoord min; public WorldCoord max; public boolean isDestroyed = false; - private boolean updateStatus = true; + public boolean updateStatus = true; boolean registered = false; private long thisSide; @@ -211,14 +211,11 @@ public class QuantumCluster implements ILocatable, IAECluster MinecraftForge.EVENT_BUS.post( new LocatableEventAnnounce( this, LocatableEvent.Unregister ) ); } - if ( updateStatus ) - { - center.updateStatus( null, (byte) -1 ); + center.updateStatus( null, (byte) -1, updateStatus ); - for (TileQuantumBridge r : Ring) - { - r.updateStatus( null, (byte) -1 ); - } + for (TileQuantumBridge r : Ring) + { + r.updateStatus( null, (byte) -1, updateStatus ); } center = null; diff --git a/me/cluster/implementations/SpatialPylonCalculator.java b/me/cluster/implementations/SpatialPylonCalculator.java index c9205cec..a7f8aeff 100644 --- a/me/cluster/implementations/SpatialPylonCalculator.java +++ b/me/cluster/implementations/SpatialPylonCalculator.java @@ -60,7 +60,7 @@ public class SpatialPylonCalculator extends MBCalculator @Override public void disconnect() { - tqb.disconnect(); + tqb.disconnect(true); } @Override diff --git a/tile/qnb/TileQuantumBridge.java b/tile/qnb/TileQuantumBridge.java index 201f9192..6e9e59cb 100644 --- a/tile/qnb/TileQuantumBridge.java +++ b/tile/qnb/TileQuantumBridge.java @@ -130,12 +130,20 @@ public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock } @Override - public void disconnect() + public void disconnect(boolean affectWorld) { if ( clust != null ) + { + if ( ! affectWorld ) + clust.updateStatus = false; + clust.destroy(); + } + clust = null; - gridProxy.setValidSides( EnumSet.noneOf( ForgeDirection.class ) ); + + if ( affectWorld ) + gridProxy.setValidSides( EnumSet.noneOf( ForgeDirection.class ) ); } @Override @@ -158,22 +166,39 @@ public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock gridProxy.setVisualRepresentation( ring ); } - public void updateStatus(QuantumCluster c, byte flags) + @Override + public void invalidate() + { + disconnect(false); + super.invalidate(); + } + + @Override + public void onChunkUnload() + { + disconnect(false); + super.onChunkUnload(); + } + + public void updateStatus(QuantumCluster c, byte flags, boolean affectWorld) { clust = c; - if ( xdex != flags ) + if ( affectWorld ) { - xdex = flags; - markForUpdate(); + if ( xdex != flags ) + { + xdex = flags; + markForUpdate(); + } + + if ( isCorner() || isCenter() ) + { + gridProxy.setValidSides( getConnections() ); + } + else + gridProxy.setValidSides( EnumSet.allOf( ForgeDirection.class ) ); } - - if ( isCorner() || isCenter() ) - { - gridProxy.setValidSides( getConnections() ); - } - else - gridProxy.setValidSides( EnumSet.allOf( ForgeDirection.class ) ); } public long getQEDest() diff --git a/tile/spatial/TileSpatialPylon.java b/tile/spatial/TileSpatialPylon.java index 62014749..6db11c32 100644 --- a/tile/spatial/TileSpatialPylon.java +++ b/tile/spatial/TileSpatialPylon.java @@ -127,15 +127,15 @@ public class TileSpatialPylon extends AENetworkTile implements IAEMultiBlock @Override public void invalidate() { + disconnect(false); super.invalidate(); - disconnect(); } @Override public void onChunkUnload() { + disconnect(false); super.onChunkUnload(); - disconnect(); } public void onNeighborBlockChange() @@ -207,7 +207,7 @@ public class TileSpatialPylon extends AENetworkTile implements IAEMultiBlock } @Override - public void disconnect() + public void disconnect(boolean b) { if ( clust != null ) {