Prep for delete

main
astoria 2 years ago
parent 80cb07dd48
commit 363619148f

@ -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);
}
}

@ -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();
}
}
}
}
}
}

Loading…
Cancel
Save