public static boolean applyBonemeal( ItemStack stack, World worldIn, int x, int y, int z, EntityPlayer player) { Block block = worldIn.getBlock(x, y, z); BonemealEvent event = new BonemealEvent(player, worldIn, block, x, y, z); if (MinecraftForge.EVENT_BUS.post(event)) { return false; } if (event.getResult() == Result.ALLOW) { if (!worldIn.isRemote) { stack.stackSize--; } return true; } if (block instanceof IGrowable) { IGrowable igrowable = (IGrowable) block; if (igrowable.canFertilize(worldIn, x, y, z, worldIn.isRemote)) { if (!worldIn.isRemote) { if (igrowable.shouldFertilize(worldIn, worldIn.rand, x, y, z)) { igrowable.fertilize(worldIn, worldIn.rand, x, y, z); } --stack.stackSize; } return true; } } return false; }
@ForgeSubscribe public void onBoneMeal(final BonemealEvent event) { final Block block = Block.blocksList[event.ID]; if (block instanceof BlockCrop) { if (((BlockCrop) block).fertilize(event.world, event.X, event.Y, event.Z)) { event.setResult(Result.ALLOW); } else { event.setCanceled(true); } } }
@SubscribeEvent public void onUseBonemeal(BonemealEvent event) { if (event.block.equals(ChocoCraftBlocks.gysahlStemBlock)) { if (((BlockGysahlStem) ChocoCraftBlocks.gysahlStemBlock) .onBonemealUse(event.world, event.x, event.y, event.z)) { event.setResult(Event.Result.ALLOW); } } }
// Bonemeal events @SubscribeEvent public void bonemealUsed(BonemealEvent event) { if (event.block == AbyssalCraft.DLTSapling) { if (!event.world.isRemote) { ((DLTSapling) AbyssalCraft.DLTSapling) .growTree(event.world, event.x, event.y, event.z, event.world.rand); } event.setResult(Result.ALLOW); } if (event.block == AbyssalCraft.dreadsapling) { if (!event.world.isRemote) { ((Dreadsapling) AbyssalCraft.dreadsapling) .growTree(event.world, event.x, event.y, event.z, event.world.rand); } event.setResult(Result.ALLOW); } }
@SubscribeEvent public void bonemealEvent(BonemealEvent event) { if (!event.world.isRemote) { if (event.block == BlockRegistry.CANOLA.getBlockInstance()) { World world = event.world; int x = event.x; int y = event.y; int z = event.z; event.setResult(Event.Result.DENY); } } }
@ForgeSubscribe public void onUseBonemeal(BonemealEvent event) { if (event.ID == BOPBlocks.firSapling.blockID) { event.setResult(Result.ALLOW); if (!event.world.isRemote) { if ((double) event.world.rand.nextFloat() < 0.45D) { ((BlockFirSapling) BOPBlocks.firSapling) .growTree(event.world, event.X, event.Y, event.Z, event.world.rand); } } } if (event.ID == BOPBlocks.redwoodSapling.blockID) { event.setResult(Result.ALLOW); if (!event.world.isRemote) { if ((double) event.world.rand.nextFloat() < 0.45D) { ((BlockRedwoodSapling) BOPBlocks.redwoodSapling) .growTree(event.world, event.X, event.Y, event.Z, event.world.rand); } } } if (event.ID == BOPBlocks.palmSapling.blockID) { event.setResult(Result.ALLOW); if (!event.world.isRemote) { if ((double) event.world.rand.nextFloat() < 0.45D) { ((BlockPalmSapling) BOPBlocks.palmSapling) .growTree(event.world, event.X, event.Y, event.Z, event.world.rand); } } } if (event.ID == BOPBlocks.redSapling.blockID) { event.setResult(Result.ALLOW); if (!event.world.isRemote) { if ((double) event.world.rand.nextFloat() < 0.45D) { ((BlockRedSapling) BOPBlocks.redSapling) .growTree(event.world, event.X, event.Y, event.Z, event.world.rand); } } } if (event.ID == BOPBlocks.orangeSapling.blockID) { event.setResult(Result.ALLOW); if (!event.world.isRemote) { if ((double) event.world.rand.nextFloat() < 0.45D) { ((BlockOrangeSapling) BOPBlocks.orangeSapling) .growTree(event.world, event.X, event.Y, event.Z, event.world.rand); } } } if (event.ID == BOPBlocks.yellowSapling.blockID) { event.setResult(Result.ALLOW); if (!event.world.isRemote) { if ((double) event.world.rand.nextFloat() < 0.45D) { ((BlockYellowSapling) BOPBlocks.yellowSapling) .growTree(event.world, event.X, event.Y, event.Z, event.world.rand); } } } if (event.ID == BOPBlocks.brownSapling.blockID) { event.setResult(Result.ALLOW); if (!event.world.isRemote) { if ((double) event.world.rand.nextFloat() < 0.45D) { ((BlockBrownSapling) BOPBlocks.brownSapling) .growTree(event.world, event.X, event.Y, event.Z, event.world.rand); } } } if (event.ID == BOPBlocks.willowSapling.blockID) { event.setResult(Result.ALLOW); if (!event.world.isRemote) { if ((double) event.world.rand.nextFloat() < 0.45D) { ((BlockWillowSapling) BOPBlocks.willowSapling) .growTree(event.world, event.X, event.Y, event.Z, event.world.rand); } } } if (event.ID == BOPBlocks.appleSapling.blockID) { event.setResult(Result.ALLOW); if (!event.world.isRemote) { if ((double) event.world.rand.nextFloat() < 0.45D) { ((BlockAppleSapling) BOPBlocks.appleSapling) .growTree(event.world, event.X, event.Y, event.Z, event.world.rand); } } } if (event.ID == BOPBlocks.originSapling.blockID) { if (!event.world.isRemote) { if ((double) event.world.rand.nextFloat() < 0.45D) { ((BlockOriginSapling) BOPBlocks.originSapling) .growTree(event.world, event.X, event.Y, event.Z, event.world.rand); } } } if (event.ID == BOPBlocks.pinkSapling.blockID) { event.setResult(Result.ALLOW); if (!event.world.isRemote) { if ((double) event.world.rand.nextFloat() < 0.45D) { ((BlockPinkSapling) BOPBlocks.pinkSapling) .growTree(event.world, event.X, event.Y, event.Z, event.world.rand); } } } if (event.ID == BOPBlocks.whiteSapling.blockID) { event.setResult(Result.ALLOW); if (!event.world.isRemote) { if ((double) event.world.rand.nextFloat() < 0.45D) { ((BlockWhiteSapling) BOPBlocks.whiteSapling) .growTree(event.world, event.X, event.Y, event.Z, event.world.rand); } } } if (event.ID == BOPBlocks.darkSapling.blockID) { event.setResult(Result.ALLOW); if (!event.world.isRemote) { if ((double) event.world.rand.nextFloat() < 0.45D) { ((BlockDarkSapling) BOPBlocks.darkSapling) .growTree(event.world, event.X, event.Y, event.Z, event.world.rand); } } } if (event.ID == BOPBlocks.magicSapling.blockID) { event.setResult(Result.ALLOW); if (!event.world.isRemote) { if ((double) event.world.rand.nextFloat() < 0.45D) { ((BlockMagicSapling) BOPBlocks.magicSapling) .growTree(event.world, event.X, event.Y, event.Z, event.world.rand); } } } if (event.ID == BOPBlocks.mangroveSapling.blockID) { event.setResult(Result.ALLOW); if (!event.world.isRemote) { if ((double) event.world.rand.nextFloat() < 0.45D) { ((BlockMangroveSapling) BOPBlocks.mangroveSapling) .growTree(event.world, event.X, event.Y, event.Z, event.world.rand); } } } if (event.ID == BOPBlocks.acaciaSapling.blockID) { event.setResult(Result.ALLOW); if (!event.world.isRemote) { if ((double) event.world.rand.nextFloat() < 0.45D) { ((BlockAcaciaSapling) BOPBlocks.acaciaSapling) .growTree(event.world, event.X, event.Y, event.Z, event.world.rand); } } } if (event.ID == BOPBlocks.holyGrass.blockID) { int var13 = event.X; int var14 = event.Y + 1; int var15 = event.Z; for (int i1 = 0; i1 < 128; ++i1) { for (int i2 = 0; i2 < i1 / 16; ++i2) { var13 += event.world.rand.nextInt(3) - 1; var14 += (event.world.rand.nextInt(3) - 1) * event.world.rand.nextInt(3) / 2; var15 += event.world.rand.nextInt(3) - 1; } if (event.world.getBlockId(var13, var14, var15) == 0) { if (BOPBlocks.holyTallGrass.canBlockStay(event.world, var13, var14, var15)) { event.setResult(Result.ALLOW); if (!event.world.isRemote) { event.world.setBlock(var13, var14, var15, BOPBlocks.holyTallGrass.blockID, 0, 0x02); } } } } } }