@Override public boolean placeBlockAt( ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata) { GunBoxType type = GunBoxType.getBox(stack.getItemDamage()); if (type == null) return false; boolean place = super.placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, metadata); if (place) { TileEntityGunBox entity = (TileEntityGunBox) world.getBlockTileEntity(x, y, z); entity.setShortName(type.shortName); } return place; }
@Override public ArrayList<ItemStack> getBlockDropped( World world, int x, int y, int z, int metadata, int fortune) { ArrayList<ItemStack> ret = new ArrayList<ItemStack>(); TileEntityGunBox te = (TileEntityGunBox) world.getBlockTileEntity(x, y, z); if (te != null && te.getType() != null) { ret.add(new ItemStack(blockID, 1, te.getType().gunBoxID)); } return ret; }
public void breakBlock(World world, int x, int y, int z, int par5, int par6) { TileEntityGunBox te = (TileEntityGunBox) world.getBlockTileEntity(x, y, z); if (te != null && te.getType() != null) world.spawnEntityInWorld( new EntityItem( world, x + 0.5F, y + 0.5F, z + 0.5F, new ItemStack(blockID, 1, te.getType().gunBoxID))); super.breakBlock(world, x, y, z, par5, par6); }
@SideOnly(value = Side.CLIENT) @Override public Icon getBlockTexture(IBlockAccess iba, int x, int y, int z, int side) { TileEntityGunBox TE = (TileEntityGunBox) iba.getBlockTileEntity(x, y, z); GunBoxType type = TE.getType(); if (type == null) return null; if (side == 1) { return type.top; } if (side == 0) { return type.bottom; } return type.side; }