public boolean canGrow(World world, boolean isClient) { BlockPos binding = getBinding(); Block block = getBlockAtBinding(); return block instanceof IGrowable ? ((IGrowable) block).canGrow(world, binding, world.getBlockState(binding), isClient) : false; }
public void grow(World world, Random rand) { BlockPos binding = getBinding(); Block block = getBlockAtBinding(); if(block instanceof IGrowable) ((IGrowable) block).grow(world, rand, binding, world.getBlockState(binding)); }
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; }
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; }
@Override public void updateTick(World world, BlockPos pos, IBlockState state, Random rand) { if (world.isRemote) return; if (world.canBlockSeeSky(pos) && world.isDaytime()) { Triple<BlockPos, IBlockState, IGrowable> trip = firstBlock(world, pos); boolean once = false; if (trip != null) for (int i = 0; i < 3; i++) { IBlockState growState = i == 0 ? trip.getMiddle() : world.getBlockState(trip.getLeft()); if (growState.getBlock() == trip.getRight() && trip.getRight().canGrow(world, trip.getLeft(), growState, false)) { trip.getRight().grow(world, rand, trip.getLeft(), growState); once = true; } } if (once) world.playEvent(2005, trip.getMiddle().isOpaqueCube() ? trip.getLeft().up() : trip.getLeft(), 0); } }
@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 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; } }
if (igrowable.canGrow(worldIn, target, iblockstate, worldIn.isRemote)) if (igrowable.canUseBonemeal(worldIn, worldIn.rand, target, iblockstate)) igrowable.grow(worldIn, worldIn.rand, target, iblockstate);
private boolean isPlant(BlockPos pos) { IBlockState state = supertile.getWorld().getBlockState(pos); Block block = state.getBlock(); if(block == Blocks.GRASS || block == Blocks.LEAVES || block == Blocks.LEAVES2 || block instanceof BlockBush && !(block instanceof BlockCrops) && !(block instanceof BlockSapling)) return false; Material mat = state.getMaterial(); return mat != null && (mat == Material.PLANTS || mat == Material.CACTUS || mat == Material.GRASS || mat == Material.LEAVES || mat == Material.GOURD) && block instanceof IGrowable && ((IGrowable) block).canGrow(supertile.getWorld(), pos, supertile.getWorld().getBlockState(pos), supertile.getWorld().isRemote); }
@Override public void grow(World worldIn, Random rand, BlockPos pos, IBlockState state) { if(!worldIn.isRemote) { if(state.getValue(HALF) == BlockHalf.UPPER) { IBlockState downState = worldIn.getBlockState(pos.down()); if(downState.getBlock() instanceof IGrowable) { ((IGrowable)downState.getBlock()).grow(worldIn, rand, pos.down(), downState); } return; } int age = state.getValue(AGE); if (age <= 2) { IBlockState newState = state.withProperty(AGE, MathHelper.clamp(++age, 0, 2)); worldIn.setBlockState(pos, newState); worldIn.setBlockState(pos.up(), newState.withProperty(HALF, BlockHalf.UPPER)); } } }
@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); } } }
@Override public boolean canHarvest(@Nonnull IFarmer farm, @Nonnull BlockPos bc, @Nonnull IBlockState state) { Block block = state.getBlock(); if (!harvestExcludes.contains(block) && block instanceof IGrowable && !(block instanceof BlockStem)) { return !((IGrowable) block).canGrow(farm.getWorld(), bc, state, true); } return false; }
@Override public List<BlockPos> getPositionsToHarvest(World world, BlockPos pos, IBlockState state) { if (state.getBlock() instanceof IGrowable && !((IGrowable) state.getBlock()).canGrow(world, pos, state, world.isRemote)) { return Collections.singletonList(pos); } return Collections.emptyList(); }
@Override public List<BlockPos> getPositionsToHarvest(World world, BlockPos pos, IBlockState state) { List<BlockPos> ret = new ArrayList<>(); applyToCrop(world, pos, (p, s) -> { if (s.getBlock() instanceof IGrowable && !((IGrowable) s.getBlock()).canGrow(world, p, s, world.isRemote)) { ret.add(p); } return true; }); return ret; }
private boolean canFertilize(World world, BlockPos pos, IBlockState state) { return state.getBlock() instanceof IGrowable && ((IGrowable) state.getBlock()).canGrow(world, pos, state, world.isRemote); }
private boolean canBoneMeal(World world, BlockPos currentPos, IBlockState state) { return state.getBlock() instanceof IGrowable && ((IGrowable) state.getBlock()).canGrow(world, currentPos, state, world.isRemote); }
if (((IGrowable) block).canGrow(world, position, state, world.isRemote)) { blocksToFertilize.add(position); } else if (isFarmable(block, position)) {
if (block instanceof IPlantable || block instanceof IGrowable) { if (block instanceof IGrowable && ((IGrowable) block).canGrow(world, current, bState, world.isRemote) == false) { continue;//its at full growth, stahp