@Override /** * This returns a complete list of items dropped from this block. * * @param world The current world * @param pos Block position in world * @param state Current state * @param fortune Breakers fortune level * @return A ArrayList containing all items this block drops */ public List<ItemStack> getDrops( IBlockAccess world, BlockPos pos, IBlockState state, int fortune) { List<ItemStack> ret = new java.util.ArrayList<ItemStack>(); Random rand = world instanceof World ? ((World) world).rand : RANDOM; int count = quantityDropped(state, fortune, rand); for (int i = 0; i < count; i++) { TileEntityBerries tile = (TileEntityBerries) world.getTileEntity(pos); ItemStack stack = BerryManager.getBerryItem(BerryManager.berryNames.get(tile.getBerryId())); if (stack != null) { ret.add(stack); } } return ret; }
@Override /** * Get the actual Block state of this Block at the given position. This applies properties not * visible in the metadata, such as fence connections. */ public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) { TileEntityBerries tile = (TileEntityBerries) worldIn.getTileEntity(pos); String name = tile == null ? "cheri" : BerryManager.berryNames.get(tile.getBerryId()); if (name == null) name = "cheri"; return state.withProperty(BerryManager.type, name); }
@Override /** * Called when a user uses the creative pick block button on this block * * @param target The full target the player is looking at * @return A ItemStack to add to the player's inventory, Null if nothing should be added. */ public ItemStack getPickBlock( MovingObjectPosition target, World world, BlockPos pos, EntityPlayer player) { TileEntityBerries tile = (TileEntityBerries) world.getTileEntity(pos); if (tile == null) return BerryManager.getBerryItem(1); return BerryManager.getBerryItem(tile.getBerryId()); }
@Override public void grow(World worldIn, BlockPos pos, IBlockState state) { TileEntityBerries tile = (TileEntityBerries) worldIn.getTileEntity(pos); tile.growCrop(); }