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