diff --git a/src/main/java/net/brokenmoon/afloydwiremod/api/AbstractWireTile.java b/src/main/java/net/brokenmoon/afloydwiremod/api/AbstractWireTile.java index 476aa66..c5b8f44 100644 --- a/src/main/java/net/brokenmoon/afloydwiremod/api/AbstractWireTile.java +++ b/src/main/java/net/brokenmoon/afloydwiremod/api/AbstractWireTile.java @@ -54,4 +54,10 @@ public abstract class AbstractWireTile extends BlockContainer { //Singleplayer ((IEntityPlayer)player).displayGuiSettings(chip); } + @Override + public void onBlockRemoval(World world, int x, int y, int z) { + AbstractWireTileEntity tile = (AbstractWireTileEntity) world.getBlockTileEntity(x, y, z); + tile.prepForDelete(); + super.onBlockRemoval(world, x, y, z); + } } diff --git a/src/main/java/net/brokenmoon/afloydwiremod/api/AbstractWireTileEntity.java b/src/main/java/net/brokenmoon/afloydwiremod/api/AbstractWireTileEntity.java index 47fdf32..93b0620 100644 --- a/src/main/java/net/brokenmoon/afloydwiremod/api/AbstractWireTileEntity.java +++ b/src/main/java/net/brokenmoon/afloydwiremod/api/AbstractWireTileEntity.java @@ -102,4 +102,21 @@ public abstract class AbstractWireTileEntity extends TileEntity { } } } + + public void prepForDelete() { + if(outputs != null) { + for (int i = 0; i < outputs.length; ++i) { + if (outputs[i].wire != null && outputs[i].wire.thisslot > -1) { + WireConnection wire = outputs[i].wire; + AbstractWireTileEntity otherChip = (AbstractWireTileEntity)this.worldObj.getBlockTileEntity(wire.x, wire.y, wire.z); + if(otherChip != null && otherChip.inputs != null) { + outputs[i].floatvalue = 0; + outputs[i].stringvalue = ""; + this.updateIO(); + otherChip.update(); + } + } + } + } + } }