Fixes
This commit is contained in:
@@ -38,6 +38,11 @@ public interface INetworkNode {
|
||||
*/
|
||||
void onDisconnected();
|
||||
|
||||
/**
|
||||
* @return Whether the block is removed from the world
|
||||
*/
|
||||
boolean isRemoved();
|
||||
|
||||
/**
|
||||
* Called when the connection state of this node changes.
|
||||
* This is also called when redstone mode is updated, as opposed to {@link INetworkNode#onConnected(INetworkMaster)} and {@link INetworkNode#onDisconnected()}.
|
||||
|
||||
@@ -11,7 +11,6 @@ import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import refinedstorage.api.network.INetworkMaster;
|
||||
import refinedstorage.tile.TileNode;
|
||||
|
||||
public abstract class BlockNode extends BlockBase {
|
||||
@@ -59,16 +58,10 @@ public abstract class BlockNode extends BlockBase {
|
||||
|
||||
@Override
|
||||
public void breakBlock(World world, BlockPos pos, IBlockState state) {
|
||||
INetworkMaster network = null;
|
||||
|
||||
if (!world.isRemote) {
|
||||
network = ((TileNode) world.getTileEntity(pos)).getNetwork();
|
||||
(((TileNode) world.getTileEntity(pos)).getNetwork()).rebuildNodes();
|
||||
}
|
||||
|
||||
super.breakBlock(world, pos, state);
|
||||
|
||||
if (network != null) {
|
||||
network.rebuildNodes();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,15 +103,19 @@ public class TileDiskDrive extends TileNode implements IStorageProvider, IStorag
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnectionChange(INetworkMaster network, boolean state) {
|
||||
super.onConnectionChange(network, state);
|
||||
public void onDisconnected() {
|
||||
super.onDisconnected();
|
||||
|
||||
// @TODO
|
||||
for (Storage storage : this.storages) {
|
||||
if (storage != null) {
|
||||
storage.writeToNBT();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnectionChange(INetworkMaster network, boolean state) {
|
||||
super.onConnectionChange(network, state);
|
||||
|
||||
network.getStorage().rebuild();
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import net.minecraft.util.math.BlockPos;
|
||||
import refinedstorage.RefinedStorageUtils;
|
||||
import refinedstorage.api.network.INetworkMaster;
|
||||
import refinedstorage.api.network.INetworkNode;
|
||||
import refinedstorage.block.BlockNode;
|
||||
import refinedstorage.tile.config.IRedstoneModeConfig;
|
||||
import refinedstorage.tile.config.RedstoneMode;
|
||||
|
||||
@@ -72,6 +73,11 @@ public abstract class TileNode extends TileBase implements INetworkNode, ISynchr
|
||||
this.network = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRemoved() {
|
||||
return !(worldObj.getBlockState(pos).getBlock() instanceof BlockNode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnectionChange(INetworkMaster network, boolean state) {
|
||||
// NO OP
|
||||
|
||||
@@ -77,6 +77,19 @@ public class TileStorage extends TileNode implements IStorageProvider, IStorageG
|
||||
|
||||
if (storage == null && storageTag != null) {
|
||||
storage = new Storage();
|
||||
|
||||
if (network != null) {
|
||||
network.getStorage().rebuild();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisconnected() {
|
||||
super.onDisconnected();
|
||||
|
||||
if (storage != null) {
|
||||
storage.writeToNBT();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,11 +97,6 @@ public class TileStorage extends TileNode implements IStorageProvider, IStorageG
|
||||
public void onConnectionChange(INetworkMaster network, boolean state) {
|
||||
super.onConnectionChange(network, state);
|
||||
|
||||
// @TODO
|
||||
if (storage != null) {
|
||||
storage.writeToNBT();
|
||||
}
|
||||
|
||||
network.getStorage().rebuild();
|
||||
}
|
||||
|
||||
|
||||
@@ -404,6 +404,10 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR
|
||||
|
||||
INetworkNode node = (INetworkNode) tile;
|
||||
|
||||
if (node.isRemoved()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
newNodes.add(node);
|
||||
newNodesPos.add(node.getPosition());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user