use of blusunrize.immersiveengineering.common.util.inventory.IIEInventory in project ImmersiveEngineering by BluSunrize.
the class BlockIETileProvider method breakBlock.
@Override
public void breakBlock(World world, BlockPos pos, IBlockState state) {
TileEntity tile = world.getTileEntity(pos);
if (tile != null && (!(tile instanceof ITileDrop) || !((ITileDrop) tile).preventInventoryDrop())) {
if (tile instanceof IIEInventory && ((IIEInventory) tile).getDroppedItems() != null) {
for (ItemStack s : ((IIEInventory) tile).getDroppedItems()) if (s != null)
spawnAsEntity(world, pos, s);
} else if (tile.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null)) {
IItemHandler h = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
if (h instanceof IEInventoryHandler)
for (int i = 0; i < h.getSlots(); i++) if (h.getStackInSlot(i) != null) {
spawnAsEntity(world, pos, h.getStackInSlot(i));
((IEInventoryHandler) h).setStackInSlot(i, null);
}
}
}
if (tile instanceof IHasDummyBlocks) {
((IHasDummyBlocks) tile).breakDummies(pos, state);
}
if (tile instanceof IImmersiveConnectable)
if (!world.isRemote || !Minecraft.getMinecraft().isSingleplayer())
ImmersiveNetHandler.INSTANCE.clearAllConnectionsFor(Utils.toCC(tile), world, !world.isRemote && world.getGameRules().getBoolean("doTileDrops"));
super.breakBlock(world, pos, state);
world.removeTileEntity(pos);
}
Aggregations