Fixes #155 "External Storage disconnecting on world reload"

This commit is contained in:
Raoul Van den Berge
2016-07-05 17:05:21 +02:00
parent f1a03b226e
commit b3aa078f56
5 changed files with 17 additions and 8 deletions

View File

@@ -2,6 +2,7 @@
### 0.8.6
**Bugfixes**
- Fixed External Storage disconnecting on world reload
- Huge performance improvements to large networks
### 0.8.5

View File

@@ -245,6 +245,7 @@ public final class RefinedStorageUtils {
}
public static void updateBlock(World world, BlockPos pos) {
System.out.println("Updating block @ " + pos);
world.notifyBlockUpdate(pos, world.getBlockState(pos), world.getBlockState(pos), 1 | 2);
}

View File

@@ -98,8 +98,6 @@ public class BlockController extends BlockBase {
if (tag != null && tag.hasKey(TileController.NBT_ENERGY)) {
controller.getEnergy().receiveEnergy(tag.getInteger(TileController.NBT_ENERGY), false);
}
controller.rebuildNodes();
}
super.onBlockPlacedBy(world, pos, state, player, stack);
@@ -108,7 +106,7 @@ public class BlockController extends BlockBase {
@Override
public void breakBlock(World world, BlockPos pos, IBlockState state) {
if (!world.isRemote) {
((TileController) world.getTileEntity(pos)).onBreak();
((TileController) world.getTileEntity(pos)).disconnectAll();
}
super.breakBlock(world, pos, state);

View File

@@ -195,7 +195,11 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR
if (couldRun != canRun()) {
couldRun = canRun();
worldObj.notifyNeighborsOfStateChange(pos, RefinedStorageBlocks.CONTROLLER);
if (!couldRun && !nodes.isEmpty()) {
disconnectAll();
} else if (couldRun) {
rebuildNodes();
}
}
if (getEnergyScaledForDisplay() != lastEnergyDisplay) {
@@ -214,10 +218,12 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR
super.update();
}
public void onBreak() {
public void disconnectAll() {
for (INetworkNode node : nodes) {
node.onDisconnected();
}
nodes.clear();
}
@Override
@@ -376,6 +382,7 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR
@Override
public void rebuildNodes() {
System.out.println("Rebuilding Nodes");
List<INetworkNode> newNodes = new ArrayList<INetworkNode>();
Set<BlockPos> newNodesPos = new HashSet<BlockPos>();

View File

@@ -61,13 +61,15 @@ public class TileExternalStorage extends TileNode implements IStorageProvider, I
@Override
public void update() {
super.update();
if (getFacingTile() instanceof IDrawerGroup && lastDrawerCount != ((IDrawerGroup) getFacingTile()).getDrawerCount()) {
if (ticks == 0) {
updateStorage();
} else if (getFacingTile() instanceof IDrawerGroup && lastDrawerCount != ((IDrawerGroup) getFacingTile()).getDrawerCount()) {
lastDrawerCount = ((IDrawerGroup) getFacingTile()).getDrawerCount();
updateStorage();
}
super.update();
}
@Override