public boolean canUseBonemeal(World world, Random rand) { BlockPos binding = getBinding(); Block block = getBlockAtBinding(); return block instanceof IGrowable ? ((IGrowable) block).canUseBonemeal(world, rand, binding, world.getBlockState(binding)) : false; }
@Override public boolean canBeFertilized(IBlockState state, World world, BlockPos pos) { if (!(state.getBlock() instanceof IGrowable)) { return false; } IGrowable growable = (IGrowable) state.getBlock(); return growable.canGrow(world, pos, state, world.isRemote) && growable.canUseBonemeal(world, world.rand, pos, state); }
private boolean growBlock(World world, BlockPos pos, IBlockState state) { if (state.getBlock() instanceof IGrowable) { IGrowable growable = (IGrowable) state.getBlock(); if (growable.canGrow(world, pos, state, world.isRemote)) { if (ServerHelper.isServerWorld(world)) { if (growable.canUseBonemeal(world, world.rand, pos, state)) { growable.grow(world, world.rand, pos, state); world.playEvent(2005, pos, 0); } } return true; } } return false; }
if (igrowable.canUseBonemeal(worldIn, worldIn.rand, target, iblockstate))
private boolean useBoneMeal(World world, BlockPos pos) { boolean result = false; for (BlockPos currentPos : BlockPos.getAllInBoxMutable(pos.add(-15, 0, -15), pos.add(15, 0, 15))) { IBlockState state = world.getBlockState(currentPos); Block crop = state.getBlock(); if (crop instanceof IGrowable) { IGrowable growable = (IGrowable) crop; if (growable.canUseBonemeal(world, world.rand, currentPos, state)) { if (!result) { result = true; } growable.grow(world, world.rand, currentPos.toImmutable(), state); } } } return result; }
private boolean applyBonemeal(World worldIn, BlockPos target, EntityPlayer player, ItemStack sigilStack) { IBlockState iblockstate = worldIn.getBlockState(target); BonemealEvent event = new BonemealEvent(player, worldIn, target, iblockstate, EnumHand.MAIN_HAND, sigilStack); if (MinecraftForge.EVENT_BUS.post(event)) return false; else if (event.getResult() == Result.ALLOW) return true; if (iblockstate.getBlock() instanceof IGrowable) { IGrowable igrowable = (IGrowable) iblockstate.getBlock(); if (igrowable.canGrow(worldIn, target, iblockstate, worldIn.isRemote)) { if (!worldIn.isRemote) { if (igrowable.canUseBonemeal(worldIn, worldIn.rand, target, iblockstate)) igrowable.grow(worldIn, worldIn.rand, target, iblockstate); } return true; } } return false; } }
@Override public void newDay(World world, BlockPos pos, IBlockState state) { Calendar calendar = HFTrackers.getCalendar(world); Weather weather = calendar.getTodaysWeather(); if (!weather.isSnow()) { if (calendar.getDate().getSeason() != Season.WINTER && world.rand.nextInt(3) < 2) { if (state.getBlock() == Blocks.SNOW_LAYER) { world.setBlockToAir(pos); //Destroy the snow layer //Attempt to grow some plants in spring, as we will have destroyed them in the winter if (world.rand.nextInt(32) == 0) { IBlockState down = world.getBlockState(pos.down()); if (down.getBlock() instanceof IGrowable) { IGrowable growable = ((IGrowable)down.getBlock()); if (growable.canGrow(world, pos.down(), down, false)) { if (growable.canUseBonemeal(world, world.rand, pos.down(), down)) { growable.grow(world, world.rand, pos.down(), down); } } } } } else world.setBlockState(pos, Blocks.WATER.getDefaultState()); } } else if (weather == Weather.BLIZZARD && state.getBlock() == Blocks.SNOW_LAYER) { int meta = state.getValue(LAYERS); if (meta < 5) { world.setBlockState(pos, state.withProperty(LAYERS, meta + 1), 2); } } }