Search in sources :

Example 1 with IContainer

use of com.codetaylor.mc.athenaeum.tile.IContainer in project artisan-worktables by codetaylor.

the class BlockBase method breakBlock.

@Override
public void breakBlock(World world, BlockPos pos, IBlockState state) {
    if (!world.isRemote) {
        List<TileEntityBase> joinedTables = Util.getJoinedTables(new ArrayList<>(), world, pos, null);
        for (TileEntityBase table : joinedTables) {
            table.onJoinedBlockBreak(pos);
        }
    }
    TileEntity tileEntity = world.getTileEntity(pos);
    if (tileEntity instanceof IContainer) {
        List<ItemStack> drops = ((IContainer) tileEntity).getBlockBreakDrops();
        if (!(tileEntity instanceof TileEntityBase) || !((TileEntityBase) tileEntity).isCreative()) {
            for (ItemStack drop : drops) {
                InventoryHelper.spawnItemStack(world, pos.getX(), pos.getY(), pos.getZ(), drop);
            }
        }
    }
    super.breakBlock(world, pos, state);
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityBase(com.codetaylor.mc.artisanworktables.modules.worktables.tile.spi.TileEntityBase) IContainer(com.codetaylor.mc.athenaeum.tile.IContainer) ItemStack(net.minecraft.item.ItemStack)

Aggregations

TileEntityBase (com.codetaylor.mc.artisanworktables.modules.worktables.tile.spi.TileEntityBase)1 IContainer (com.codetaylor.mc.athenaeum.tile.IContainer)1 ItemStack (net.minecraft.item.ItemStack)1 TileEntity (net.minecraft.tileentity.TileEntity)1