Better method of removing nodes
@@ -11,6 +11,7 @@ import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
+import net.minecraft.world.Explosion;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
@@ -47,11 +48,24 @@ public abstract class BlockNode extends BlockBase {
}
@Override
- public void breakBlock(World world, BlockPos pos, IBlockState state) {
- super.breakBlock(world, pos, state);
+ public void onBlockDestroyedByPlayer(World world, BlockPos pos, IBlockState state) {
+ super.onBlockDestroyedByPlayer(world, pos, state);
- // Sanity check
- if (world.getBlockState(pos).getBlock() == this) {
+ if (!world.isRemote) {
+ removeNode(world, pos);
+ }
+ }
+
+ @Override
+ public void onBlockDestroyedByExplosion(World world, BlockPos pos, Explosion explosion) {
+ super.onBlockDestroyedByExplosion(world, pos, explosion);
+
+ if (!world.isRemote) {
+ removeNode(world, pos);
+ }
+ }
+
+ private void removeNode(World world, BlockPos pos) {
INetworkNodeManager manager = API.instance().getNetworkNodeManager(world.provider.getDimension());
INetworkNode node = manager.getNode(pos);
@@ -64,7 +78,6 @@ public abstract class BlockNode extends BlockBase {
node.getNetwork().getNodeGraph().rebuild();
}
}
- }
@Override
protected BlockStateContainer.Builder createBlockStateBuilder() {
