use of blusunrize.immersiveengineering.common.util.inventory.IEInventoryHandler in project Immersive-Tech by FerroO2000.
the class BlockITTileProvider 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()) && 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);
}
use of blusunrize.immersiveengineering.common.util.inventory.IEInventoryHandler in project ImmersiveEngineering by BluSunrize.
the class BlockIETileProvider method getDrops.
@Override
public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune) // public List<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune)
{
TileEntity tile = world.getTileEntity(pos);
DimensionBlockPos dpos = new DimensionBlockPos(pos, world instanceof World ? ((World) world).provider.getDimension() : 0);
if (tile == null && tempTile.containsKey(dpos))
tile = tempTile.get(dpos);
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.isEmpty())
drops.add(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).isEmpty()) {
drops.add(h.getStackInSlot(i));
((IEInventoryHandler) h).setStackInSlot(i, ItemStack.EMPTY);
}
}
}
if (tile instanceof ITileDrop) {
NonNullList<ItemStack> s = ((ITileDrop) tile).getTileDrops(harvesters.get(), state);
drops.addAll(s);
} else
super.getDrops(drops, world, pos, state, fortune);
tempTile.remove(dpos);
}
Aggregations