@Override public boolean onBlockActivated( World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { int meta = world.getBlockMetadata(x, y, z); if (meta == dataHangerFruit) { ItemStack item = new ItemStack(ModItems.food, 1, ItemErebusFood.FoodType.DARK_FRUIT.ordinal()); world.playSoundAtEntity(player, "random.pop", 0.5F, 2.0F); if (!player.inventory.addItemStackToInventory(item)) Utils.dropStack(world, (int) (x + 0.5D), (int) (y + 0.5D), (int) (z + 0.5D), item); world.setBlock(x, y, z, this, dataHanger4, 2); return true; } if (meta == dataHangerSeed) { ItemStack item = new ItemStack(ModItems.materials, 1, DATA.darkFruitSeeds.ordinal()); world.playSoundAtEntity(player, "random.pop", 0.5F, 2.0F); if (!player.inventory.addItemStackToInventory(item)) Utils.dropStack(world, (int) (x + 0.5D), (int) (y + 0.5D), (int) (z + 0.5D), item); world.setBlock(x, y, z, this, dataHanger4, 2); return true; } return true; }
@Override public void onBlockHarvested(World world, int x, int y, int z, int id, EntityPlayer player) { int meta = world.getBlockMetadata(x, y, z); ItemStack item = null; if (meta == dataHangerFruit) { item = new ItemStack(ModItems.food, 2, ItemErebusFood.FoodType.DARK_FRUIT.ordinal()); Utils.dropStack(world, (int) (x + 0.5D), (int) (y + 0.5D), (int) (z + 0.5D), item); } if (meta == dataHangerSeed) { item = new ItemStack(ModItems.materials, 2, DATA.darkFruitSeeds.ordinal()); Utils.dropStack(world, (int) (x + 0.5D), (int) (y + 0.5D), (int) (z + 0.5D), item); } }
@Override public void onNeighborBlockChange(World world, int x, int y, int z, Block neighbour) { int meta = world.getBlockMetadata(x, y, z); ItemStack item = null; if (world.isAirBlock(x, y + 1, z)) { if (meta == dataHangerFruit) { item = new ItemStack(ModItems.food, 1, ItemErebusFood.FoodType.DARK_FRUIT.ordinal()); Utils.dropStack(world, (int) (x + 0.5D), (int) (y + 0.5D), (int) (z + 0.5D), item); } if (meta == dataHangerSeed) { item = new ItemStack(ModItems.materials, 1, DATA.darkFruitSeeds.ordinal()); Utils.dropStack(world, (int) (x + 0.5D), (int) (y + 0.5D), (int) (z + 0.5D), item); } world.setBlockToAir(x, y, z); } canBlockStay(world, x, y, z); }