@SubscribeEvent public void onBonemealClick(BonemealEvent event) { World world = event.world; if (event.block.equals(mod_Rediscovered.CherrySapling)) { if (!world.isRemote) { double chance = 0.45D; if (world.rand.nextFloat() < chance) { //grow tree event.setResult(Result.ALLOW); ((BlockCherrySapling)mod_Rediscovered.CherrySapling).generateTree(event.world, event.pos, event.world.getBlockState(event.pos), event.world.rand); } } } }
@ForgeSubscribe public void fertellise (BonemealEvent event) { World world = event.world; EntityPlayer player = event.entityPlayer; int x = event.X; int y = event.Y; int z = event.Z; int id = event.ID; ItemStack item = player.getHeldItem(); int meta = world.getBlockMetadata(x, y, z); if (id == BlockListMF.sapling.blockID) { if (!world.isRemote) { if ((double)world.rand.nextFloat() < ((BlockSaplingMF)BlockListMF.sapling).getBonemealChance(meta)) { ((BlockSaplingMF)BlockListMF.sapling).markOrGrowMarked(world, x, y, z, world.rand); } } event.setResult(Result.ALLOW); } }
@ForgeSubscribe public void handleBonemeal(BonemealEvent event) { if (!Proxies.common.isSimulating(event.world)) return; TileEntity tile = event.world.getBlockTileEntity(event.X, event.Y, event.Z); if (tile instanceof TileSapling) { if (((TileSapling) tile).tryGrow(true)) { event.setResult(Result.ALLOW); } } else if(tile instanceof IFruitBearer) { IFruitBearer bearer = (IFruitBearer)tile; if(bearer.getRipeness() <= 1.0f) { bearer.addRipeness(1.0f); event.setResult(Result.ALLOW); } } }
@SubscribeEvent public void onBonemeal(BonemealEvent event){ if (event.entityPlayer.worldObj.isRemote) return; if (!ClaimsList.For(event.entity.worldObj).actionIsTrusted(event.entityPlayer, PermissionsMutex.USE_BONEMEAL, event.pos.getX(), event.pos.getY(), event.pos.getZ())) event.setCanceled(true); else GriefGuardian._dal.logAction( (EntityPlayerMP)event.entityPlayer, Actions.ITEM_USE, (int)Math.floor(event.entity.posX), (int)Math.floor(event.entity.posY), (int)Math.floor(event.entity.posZ), event.entityPlayer.getCurrentEquippedItem(), ""); }
@SubscribeEvent public void onBonemealClick(BonemealEvent event) { World world = event.world; if (event.block.equals(mod_Rediscovered.CherrySapling)) { event.setResult(Result.ALLOW); if (!world.isRemote) { double chance = 0.45D; if (world.rand.nextFloat() < chance) { //grow tree ((BlockCherrySapling)mod_Rediscovered.CherrySapling).func_149878_d(event.world, event.x, event.y, event.z, event.world.rand); } } } }
@ForgeSubscribe public void onUseBonemeal(BonemealEvent event) { if (event.ID == ModBlocks.blockOrangeTreeSapling.blockID) { if (!event.world.isRemote) { ((OrangeTreeSapling) ModBlocks.blockOrangeTreeSapling).generateTree(event.world, event.X, event.Y, event.Z, event.world.rand, event.world.getBlockMetadata(event.X, event.Y, event.Z)); event.setResult(Result.ALLOW); } } if (event.ID == ModBlocks.blockOrangeTreeOrange.blockID) { if (!event.world.isRemote) { ((OrangeTreeOrange) ModBlocks.blockOrangeTreeOrange).fertilize(event.world, event.X, event.Y, event.Z); event.setResult(Result.ALLOW); } } }
@SubscribeEvent public void bonemealUsed(BonemealEvent event) { int plantMetadata = event.world.getBlockMetadata(event.x, event.y, event.z); if (event.world.getBlock(event.x, event.y, event.z) == ModBlocks.riceBlock) { if (plantMetadata != 7) { event.world.setBlockMetadataWithNotify(event.x, event.y, event.z, plantMetadata + 1, 2); event.setResult(Result.ALLOW); } } if (event.world.getBlock(event.x, event.y, event.z) == ModBlocks.strawberryBlock) { if (plantMetadata != 7) { event.world.setBlockMetadataWithNotify(event.x, event.y, event.z, plantMetadata + 1, 2); event.setResult(Result.ALLOW); } } if (event.world.getBlock(event.x, event.y, event.z) == ModBlocks.grapeBlock) { if (plantMetadata != 7) { event.world.setBlockMetadataWithNotify(event.x, event.y, event.z, plantMetadata + 1, 2); event.setResult(Result.ALLOW); } } }
@ForgeSubscribe public boolean onUseBonemeal(BonemealEvent event){ if(event.world.isRemote) return true; if(event.ID == ModBlocks.dreamSaplings.blockID) { ((BlockDreamSaplings)(ModBlocks.dreamSaplings)).growTree(event.world, event.X, event.Y, event.Z, new Random()); event.setResult(Result.ALLOW); } /* if(id == ModBlocks.dreamPlants.blockID) { if(event.world.getBlockMetadata(event.X, event.Y, event.Z) < 5) { ((BlockDreamPlants)(ModBlocks.dreamPlants)).fertilize(event.world, event.X, event.Y, event.Z); event.setResult(Result.ALLOW); } } */ 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); } } }
@ForgeSubscribe public void onBonmealEvent(BonemealEvent event){ int meta = event.world.getBlockMetadata(event.X, event.Y, event.Z); if(!event.world.isRemote){ if(event.getResult() == Result.DEFAULT && event.ID == Blocks.blockSaplings.blockID){ if(meta == 0){ if ((double)event.world.rand.nextFloat() > 0.15D){ ((BlockSaplings)Blocks.blockSaplings).growTree(event.world, event.X, event.Y, event.Z, event.world.rand); } event.setResult(Result.ALLOW); } } } }
@SubscribeEvent public void onBonemeal(BonemealEvent evt) { World world = evt.getWorld(); DimensionData data = getDimensionData(world); if (data != null) { if (preventPlantGrowth(world, data, evt.getPos())) { evt.setResult(Event.Result.ALLOW); if (world.isRemote) { evt.getEntityPlayer().sendStatusMessage(new TextComponentString(TextFormatting.RED + "The bonemeal did not work!"), false); } } } }
public static int onApplyBonemeal(EntityPlayer player, World world, BlockPos pos, IBlockState state, ItemStack stack) { BonemealEvent event = new BonemealEvent(player, world, pos, state); if (MinecraftForge.EVENT_BUS.post(event)) return -1; if (event.getResult() == Result.ALLOW) { if (!world.isRemote) stack.stackSize--; return 1; } return 0; }
private void useBonemeal(BonemealEvent event) { if(!this.hasMinLvl(bonemeal)) return; this.calculateGain(event.entityPlayer, bonemeal); if(this.success == 0) { event.setCanceled(true); } }
@SubscribeEvent public void onBonemealUsedEvent(BonemealEvent event) { Chunk chunk = event.world.getChunkFromBlockCoords(event.x, event.z); if (IBiotaAPI.API.addNutrientsToBioSystem(event.world, chunk, Settings.BONEMEAL_PHOSPHORUS, Settings.BONEMEAL_POTASSIUM, Settings.BONEMEAL_NITROGEN)) event.setResult(Event.Result.ALLOW); else event.setCanceled(true); }
@SubscribeEvent public void onUseBonemeal(BonemealEvent event) { if (event.block==IlluminatedBlocks.illuminatedSapling) { if (boneRand.nextInt(Config.boneMealChance)==0) { if (!event.world.isRemote) { this.growTree(event.world, event.x, event.y, event.z); } } event.setResult(Event.Result.ALLOW); } }
public void onUseBonemeal(BonemealEvent event) { if (event.block == ModBlocks.nuggetDirt) { event.setResult(Event.Result.DENY); } }
@ForgeSubscribe public void bonemealUsed(BonemealEvent event) { if(event.world.getBlockId(event.X, event.Y, event.Z) == ModBlocks.nileSapling.blockID) { ((BlockNileSapling)ModBlocks.nileSapling).growTree(event.world, event.X, event.Y, event.Z, event.world.rand); } }
@Override public boolean useOnBlock(World world, EntityPlayer player, IPlayerSession session, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int boost, int cost) { for (int j = -(1 + boost); j < (2 + boost); j++) for (int k = -(1 + boost); k < (2 + boost); k++) { if (session.hasEnoughMana(cost())) { Block blk = world.getBlock(x + j, y, z + k); if (blk != null && !world.isAirBlock(x + j, y, z + k)) { BonemealEvent event = new BonemealEvent(player, world, blk, x + j, y, z + k); if (MinecraftForge.EVENT_BUS.post(event)) return false; if (blk instanceof IGrowable) { IGrowable grow = (IGrowable) blk; if (grow.func_149851_a(world, x + j, y, z + k, world.isRemote)) { world.spawnParticle("happyVillager", x + j + 0.5, y + 0.5, z + k + 0.5, world.rand.nextDouble() + 2, world.rand.nextDouble() + 2, world.rand.nextDouble() + 2); if (!world.isRemote) { if (grow.func_149852_a(world, world.rand, x + j, y, z + k)) { session.adjustMana(-cost(), false); //blk.updateTick(world, x + j, y, z + k, world.rand); grow.func_149853_b(world, world.rand, x + j, y, z + k); } } } } } } else break; } return false; }
@SubscribeEvent public void onAttemptBonemeal(BonemealEvent event) { if (!event.world.isRemote && event.block.getBlock() == Blocks.vine && event.pos.getY() > 0) { int i = event.pos.getY(); while(event.world.getBlockState(event.pos.down(++i)) == Blocks.vine) {} i++; while(event.world.isAirBlock(event.pos.down(++i)) && event.world.rand.nextInt(3) != 0) { event.world.setBlockState(event.pos.down(i), event.block); } } }
public static boolean applyBonemeal(ItemStack itemstack, World world, int x, int y, int z, EntityPlayer player) { Block block = world.getBlock(x, y, z); BonemealEvent event = new BonemealEvent(player, world, block, x, y, z); if (MinecraftForge.EVENT_BUS.post(event)) { return false; } if (event.getResult() == Result.ALLOW) { if (!world.isRemote) { itemstack.stackSize--; } return true; } if (block instanceof IGrowable) { IGrowable igrowable = (IGrowable) block; if (igrowable.func_149851_a(world, x, y, z, world.isRemote)) { if (!world.isRemote) { if (igrowable.func_149852_a(world, world.rand, x, y, z)) { igrowable.func_149853_b(world, world.rand, x, y, z); } } return true; } } return false; }
@SubscribeEvent public void applyBonemeal (BonemealEvent event) { if (event.block instanceof IPlantProxy) { IPlantProxy proxy = (IPlantProxy) event.block; if (proxy.applyBonemeal(event.world, event.x, event.y, event.z)) event.setResult(Event.Result.ALLOW); } }
@ForgeSubscribe public void onBonemealClick(BonemealEvent event) { if (event.ID == mod_Rediscovered.CherrySapling.blockID) { event.setResult(Result.ALLOW); //if(itemRand.nextInt(2) == 0) //{ //grow tree ((BlockCherrySapling)mod_Rediscovered.CherrySapling).markOrGrowMarked(event.world, event.X, event.Y, event.Z, event.world.rand); //} } }
@SubscribeEvent public void onUseBonemeal(BonemealEvent event) { if(event.getBlock().getBlock().equals(BlockLoader.grapeVine)){ if(!event.getWorld().isRemote) ((GrapeVines)event.getBlock().getBlock()).updateTick(event.getWorld(), event.getPos(), event.getWorld().getBlockState(event.getPos()), event.getWorld().rand); event.setResult(Event.Result.ALLOW); } }
@Override public void updateTick(World w, int x, int y, int z, Random r) { final int meta = w.getBlockMetadata(x, y, z); if (meta == 1) return; if (!(w.getWorldChunkManager() instanceof NyxChunkManager)) { w.setBlock(x, y, z, Blocks.dirt, 1, 0x3); return; } final Block bl = w.getBlock(x, y + 1, z); if (bl instanceof IGrowable) { ((IGrowable) bl).func_149853_b(w, r, x, y + 1, z); } else { MinecraftForge.EVENT_BUS.post(new BonemealEvent(null, w, bl, x, y + 1, z)); } boolean foundThermal = false; for (int xit = -1; xit <= 1; ++xit) { for (int yit = -1; yit <= 1; ++yit) { for (int zit = -1; zit <= 1; ++zit) if (w.getBlock(x + xit, y + yit, z + zit).getMaterial() == Material.fire) { foundThermal = true; } } } if (!foundThermal) { w.setBlockMetadataWithNotify(x, y, z, 1, 0x3); } }
@SubscribeEvent public void bonemealUsed(BonemealEvent event) { if(event.getWorld().getBlockState(event.getPos()) == setBlocks.crop) { ((BlockFlax)setBlocks.crop).grow(event.getWorld(), event.getPos(), event.getBlock()); } }
@ForgeSubscribe public void handleBonemeal(BonemealEvent event) { if (!Proxies.common.isSimulating(event.world)) return; int blockid = event.world.getBlockId(event.X, event.Y, event.Z); if(blockid != ForestryBlock.mushroom.blockID) return; ((BlockMushroom)ForestryBlock.mushroom).growTree(event.world, event.X, event.Y, event.Z, event.world.rand); event.setResult(Result.ALLOW); }
@SubscribeEvent public void applyBonemeal (BonemealEvent event) { if (event.block == blocks.largePotPlantProxy) { BlockLargePotPlantProxy proxyBlock = blocks.largePotPlantProxy; if (proxyBlock.applyBonemeal(event.world, event.x, event.y, event.z)) event.setResult(Result.ALLOW); // Stop further processing and consume bonemeal } }
public static boolean applyBonemeal(World world, int x, int y, int z, EntityPlayer player) { Block block = world.getBlock(x, y, z); BonemealEvent event = new BonemealEvent(player, world, block, x, y, z); if (MinecraftForge.EVENT_BUS.post(event)) { return false; } if (event.getResult() == Result.ALLOW) { return true; } if (block instanceof IGrowable) { IGrowable igrowable = (IGrowable) block; if (igrowable.func_149851_a(world, x, y, z, world.isRemote)) { if (!world.isRemote) { if (igrowable.func_149852_a(world, world.rand, x, y, z)) { igrowable.func_149853_b(world, world.rand, x, y, z); } } return true; } } return false; }
@SubscribeEvent public void onFertilization(BonemealEvent event){ if(event.world.isRemote) return; // why would we want to handle this on the client-side? if(event.block == Blocks.netherrack || event.block == Blocks.end_stone || event.block.canSustainPlant(event.world, event.x, event.y, event.z, ForgeDirection.UP, Blocks.red_flower)) { // can bonemeal Biomes O' Plenty grass, etc. boolean onGrass = event.block instanceof BlockGrass; if(onGrass && Config.includePlantsOnBonemeal || !onGrass && Config.allowDirtBonemealing) { // we'll try to spawn plants in a 5x5 area which is centered on the block that has been bonemealed for(int x = event.x - 2; x < event.x + 3; x++) { for(int z = event.z - 2; z < event.z + 3; z++) { if(event.world.isAirBlock(x, event.y + 1, z)) { if(event.world.rand.nextInt(8) == 1) { // increase .nextInt(x) to lower the chances of spawning a plant BlockPneumaticPlantBase trySpawn = BlockPlants.allPlants.get(event.world.rand.nextInt(BlockPlants.allPlants.size() - 1)); // select a random plant if(trySpawn.canPlantGrowOnThisBlock(event.world.getBlock(x, event.y, z), event.world, x, event.y, z)) { // make sure that the plant we selected can grow on the soil event.world.setBlock(x, event.y + (trySpawn.isPlantHanging() ? -1 : 1), z, trySpawn); } } } } /* * vanilla mechanics will spawn flowers etc. when bonemeal is used on grass, * so we cannot set Result.ALLOW in this case because it would stop event-propagation */ if(!onGrass) event.setResult(Result.ALLOW); } } } }
@Override public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { if (!player.canPlayerEdit(pos, side, stack)) { return EnumActionResult.FAIL; } else { IBlockState state; int i; int x; state = world.getBlockState(pos); BonemealEvent event = new BonemealEvent(player, world, pos, state); if (MinecraftForge.EVENT_BUS.post(event)) { return EnumActionResult.FAIL; } if (state == Blocks.GRASS.getDefaultState()) { if (!world.isRemote) { --stack.stackSize; label133: for (i = 0; i < 128; ++i) { x = pos.getX(); int y = pos.getY() + 1; int z = pos.getZ(); for (int j = 0; j < i / 16; ++j) { x += itemRand.nextInt(15) - 5; y += (itemRand.nextInt(15) - 5) * itemRand.nextInt(15) / 10; z += itemRand.nextInt(15) - 5; BlockPos positionGrass2 = new BlockPos(x, y - 1, z); if (world.getBlockState(positionGrass2).getBlock() != Blocks.GRASS || world.isBlockNormalCube(pos, true)) { continue label133; } } BlockPos positionGrass = new BlockPos(x, y, z); if (world.getBlockState(positionGrass) == Blocks.AIR.getDefaultState()) { if (itemRand.nextInt(3) != 0) { if (Blocks.TALLGRASS.canBlockStay(world, positionGrass, Blocks.TALLGRASS.getDefaultState() )) { WarsMod.generateBlock(world, x, y, z, Blocks.TALLGRASS); } } } return EnumActionResult.SUCCESS; } } } } return EnumActionResult.PASS; }
@SubscribeEvent public void onBoneMealUse(BonemealEvent event) { onEvent(event.entityPlayer, event); }
@Override public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int xPos, int yPos, int zPos, int p_77648_7_, float p_77648_8_, float p_77648_9_, float p_77648_10_) { Block block = world.getBlock(xPos, yPos, zPos); BonemealEvent event = new BonemealEvent(player, world, block, xPos, yPos, zPos); if (MinecraftForge.EVENT_BUS.post(event)) { return false; } if (event.getResult() == Result.ALLOW) { if (!world.isRemote) { stack.stackSize--; } return true; } if (block instanceof IGrowable) { IGrowable igrowable = (IGrowable) block; if (igrowable.func_149851_a(world, xPos, yPos, zPos, world.isRemote)) { if (!world.isRemote) { if (igrowable.func_149852_a(world, world.rand, xPos, yPos, zPos)) { igrowable.func_149853_b(world, world.rand, xPos, yPos, zPos); } --stack.stackSize; world.playAuxSFX(2005, xPos, yPos, zPos, 0); } return true; } } return false; }
@SubscribeEvent public void boneMeal(BonemealEvent event) { if (!event.world.isRemote && event.entityPlayer != null) DiscoveryManager.unlockItem(QADiscoveries.Item.MANIPULATION.get().getKey(), event.entityPlayer, false); }
public static boolean applyBonemeal(ItemStack p_150919_0_, World p_150919_1_, int p_150919_2_, int p_150919_3_, int p_150919_4_, EntityPlayer player) { Block block = p_150919_1_.getBlock(p_150919_2_, p_150919_3_, p_150919_4_); BonemealEvent event = new BonemealEvent(player, p_150919_1_, block, p_150919_2_, p_150919_3_, p_150919_4_); if (MinecraftForge.EVENT_BUS.post(event)) { return false; } if (event.getResult() == Result.ALLOW) { if (!p_150919_1_.isRemote) { p_150919_0_.stackSize--; } return true; } if (block instanceof IGrowable) { IGrowable igrowable = (IGrowable)block; if (igrowable.func_149851_a(p_150919_1_, p_150919_2_, p_150919_3_, p_150919_4_, p_150919_1_.isRemote)) { if (!p_150919_1_.isRemote) { if (igrowable.func_149852_a(p_150919_1_, p_150919_1_.rand, p_150919_2_, p_150919_3_, p_150919_4_)) { igrowable.func_149853_b(p_150919_1_, p_150919_1_.rand, p_150919_2_, p_150919_3_, p_150919_4_); } --p_150919_0_.stackSize; } return true; } } return false; }