Better legacy tag check
This commit is contained in:
@@ -50,16 +50,19 @@ public abstract class BlockNode extends BlockBase {
|
||||
public void breakBlock(World world, BlockPos pos, IBlockState state) {
|
||||
super.breakBlock(world, pos, state);
|
||||
|
||||
INetworkNodeManager manager = API.instance().getNetworkNodeManager(world.provider.getDimension());
|
||||
// Sanity check
|
||||
if (world.getBlockState(pos).getBlock() == this) {
|
||||
INetworkNodeManager manager = API.instance().getNetworkNodeManager(world.provider.getDimension());
|
||||
|
||||
INetworkNode node = manager.getNode(pos);
|
||||
INetworkNode node = manager.getNode(pos);
|
||||
|
||||
manager.removeNode(pos, true);
|
||||
manager.removeNode(pos, true);
|
||||
|
||||
API.instance().markNetworkNodesDirty(world);
|
||||
API.instance().markNetworkNodesDirty(world);
|
||||
|
||||
if (node.getNetwork() != null) {
|
||||
node.getNetwork().getNodeGraph().rebuild();
|
||||
if (node.getNetwork() != null) {
|
||||
node.getNetwork().getNodeGraph().rebuild();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -82,10 +82,19 @@ public abstract class TileNode<N extends NetworkNode> extends TileBase implement
|
||||
public void read(NBTTagCompound tag) {
|
||||
super.read(tag);
|
||||
|
||||
// If we have more than this stored:
|
||||
// x, y, z, id, Direction
|
||||
// Then this is a legacy tag!
|
||||
if (tag.getSize() > 5) {
|
||||
// Ugly code for checking if this is a legacy tile. Sue me.
|
||||
boolean hasMeta = tag.hasKey("x") && tag.hasKey("y") && tag.hasKey("z") && tag.hasKey("id");
|
||||
boolean hasForgeData = tag.hasKey("ForgeData");
|
||||
boolean hasForgeCaps = tag.hasKey("ForgeCaps");
|
||||
|
||||
// + 1 because of "Direction".
|
||||
if (tag.getSize() == 4 + 1 && hasMeta) {
|
||||
// NO OP
|
||||
} else if (tag.getSize() == 5 + 1 && hasMeta && (hasForgeData || hasForgeCaps)) {
|
||||
// NO OP
|
||||
} else if (tag.getSize() == 6 + 1 && hasMeta && hasForgeData && hasForgeCaps) {
|
||||
// NO OP
|
||||
} else {
|
||||
legacyTagToRead = tag;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user