public void generateTree(Random random, World world, BlockPos pos) { int height = random.nextInt(this.treeHeightRange) + this.minTreeHeight; boolean flag = true; if(seekHeight) { pos = findGround(world, pos); if(pos.getY() < 0) { return; } } int yPos = pos.getY(); if(yPos >= 1 && yPos + height + 1 <= 256) { IBlockState state = world.getBlockState(pos.down()); Block soil = state.getBlock(); boolean isSoil = (soil != Blocks.AIR && soil.canSustainPlant(state, world, pos.down(), EnumFacing.UP, TinkerWorld.slimeSapling)); if(isSoil) { soil.onPlantGrow(state, world, pos.down(), pos); placeCanopy(world, random, pos, height); placeTrunk(world, pos, height); } } }
@Override public boolean canBlockStay(@Nonnull World worldIn, BlockPos pos, IBlockState state) { if (pos.getY() >= 0 && pos.getY() < 256) { IBlockState iblockstate = worldIn.getBlockState(pos.down()); return iblockstate.getBlock() == Blocks.MYCELIUM || (iblockstate.getBlock() == Blocks.DIRT && iblockstate.getValue(BlockDirt.VARIANT) == BlockDirt.DirtType.PODZOL || iblockstate.getBlock().canSustainPlant(iblockstate, worldIn, pos.down(), net.minecraft.util.EnumFacing.UP, this)); } else { return false; } }
if(down.getBlock().canSustainPlant(down, world, pos.down(), EnumFacing.UP, seed)) {
private static boolean canHarvestCrops(IBlockState plantBlockState, World world, BlockPos pos) { if(!(plantBlockState.getBlock() instanceof BlockCrops)) return false; final BlockCrops crops = (BlockCrops) plantBlockState.getBlock(); IBlockState soilBlockState = world.getBlockState(pos.down()); if(!soilBlockState.getBlock().canSustainPlant(soilBlockState, world, pos.down(), EnumFacing.UP, crops)) return false; return crops.isMaxAge(plantBlockState); }
protected boolean canPlant(@Nonnull IFarmer farm, @Nonnull World world, @Nonnull BlockPos bc, @Nonnull IPlantable plantable) { IBlockState target = getPlant(farm, plantable); BlockPos groundPos = bc.down(); IBlockState groundBS = world.getBlockState(groundPos); Block ground = groundBS.getBlock(); if (target != null && target.getBlock().canPlaceBlockAt(world, bc) && ground.canSustainPlant(groundBS, world, groundPos, EnumFacing.UP, plantable)) { return true; } return false; }
@Override public boolean canStay(IBlockAccess world, BlockPos pos) { BlockPos blockPos = pos.down(); IBlockState blockState = world.getBlockState(blockPos); Block block = blockState.getBlock(); return block.canSustainPlant(blockState, world, blockPos, EnumFacing.UP, this); }
/** Returns true if this seed can be planted at this block position * @param world the world * @param pos the position to be planted * @param soil the state of the block clicked on * @param crop the crop itself * @param original the original position clicked**/ public boolean canPlantSeedAt(World world, BlockPos pos, IBlockState soil, C crop, BlockPos original) { return soil != Blocks.AIR && soil.getBlock().canSustainPlant(soil, world, pos, EnumFacing.UP, crop) && world.isAirBlock(pos.up()); }
@Override @ModDependentMethod(modId = LPConstants.mcmpModID) public boolean canSustainPlant(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing direction, IPlantable plantable) { Block block = mcmpBlockAccess.getBlock(); return block != null ? block.canSustainPlant(state, world, pos, direction, plantable) : super.canSustainPlant(state, world, pos, direction, plantable); }
protected boolean canPlant(@Nonnull IFarmer farm, @Nonnull World world, @Nonnull BlockPos bc) { Block target = getPlantedBlock(); BlockPos groundPos = bc.down(); IBlockState bs = world.getBlockState(groundPos); Block ground = bs.getBlock(); IPlantable plantable = (IPlantable) getPlantedBlock(); if (target.canPlaceBlockAt(world, bc) && (ground.canSustainPlant(bs, world, groundPos, EnumFacing.UP, plantable) || ignoreSustainCheck) && (!isCheckGroundForFarmland() || isGroundTilled(farm, bc))) { return true; } return false; }
@Override public boolean canPlaceBlockAt(World world, BlockPos pos) { IBlockState state = world.getBlockState(pos.down()); Block block = state.getBlock(); if (block.canSustainPlant(state, world, pos.down(), EnumFacing.UP, this)) return true; if (block == this) return true; else if (block != Blocks.GRASS && block != Blocks.DIRT) return false; return false; }
@Override public boolean canBlockStay(World world, BlockPos pos, IBlockState state) { IBlockState soil = world.getBlockState(pos.down()); return (soil.getBlock().canSustainPlant(soil, world, pos.down(), net.minecraft.util.EnumFacing.UP, this)); } }
@Override public boolean canBlockStay(World world, BlockPos pos, IBlockState state){ BlockPos offset = pos.down(); IBlockState offsetState = world.getBlockState(offset); Block offsetBlock = offsetState.getBlock(); return state.getValue(TYPE) == TheWildPlants.RICE ? offsetState.getMaterial() == Material.WATER : offsetBlock.canSustainPlant(offsetState, world, offset, EnumFacing.UP, this); }
@Override public boolean canPlaceBlockAt(World worldIn, BlockPos pos) { IBlockState soil = worldIn.getBlockState(pos.down()); return super.canPlaceBlockAt(worldIn, pos) && soil.getBlock().canSustainPlant(soil, worldIn, pos.down(), net.minecraft.util.EnumFacing.UP, this); }
@SuppressWarnings("unchecked") private boolean canStay(World world, BlockPos pos) { CropData data = CropHelper.getCropDataAt(world, pos); if (data != null) { Crop crop = data.getCrop(); if (crop.getGrowthHandler() != null) { IBlockState down = world.getBlockState(pos.down()); return down.getBlock() == this || down.getBlock().canSustainPlant(down, world, pos, EnumFacing.UP, crop); } } return false; }
public boolean canBlockStay(World world, BlockPos pos, IBlockState state) { if (state.getBlock() == this) { IBlockState soil = world.getBlockState(pos.down()); return soil.getBlock().canSustainPlant(soil, world, pos.down(), net.minecraft.util.EnumFacing.UP, this); } return canSustainBush(world.getBlockState(pos.down())); }
@Override public boolean canBlockStay(World world, BlockPos pos, IBlockState state) { if (state.getBlock() == this) { IBlockState soil = world.getBlockState(pos.down()); return soil.getBlock().canSustainPlant(soil, world, pos.down(), EnumFacing.UP, this); } return canSustainFlower(world.getBlockState(pos.down())); }
public boolean canBlockStay(World worldIn, BlockPos pos, IBlockState state) { if (state.getBlock() == this) //Forge: This function is called during world gen and placement, before this block is set, so if we are not 'here' then assume it's the pre-check. { IBlockState soil = worldIn.getBlockState(pos.down()); return soil.getBlock().canSustainPlant(soil, worldIn, pos.down(), net.minecraft.util.EnumFacing.UP, this); } return this.canSustain(worldIn.getBlockState(pos.down()).getBlock()); }
@Override public boolean canBlockStay(World worldIn, BlockPos pos, IBlockState state) { if (pos.getY() >= 0 && pos.getY() < 256) { IBlockState iblockstate = worldIn.getBlockState(pos.down()); return iblockstate.getBlock() == Blocks.MYCELIUM || (iblockstate.getBlock() == Blocks.DIRT && iblockstate.getValue(BlockDirt.VARIANT) == BlockDirt.DirtType.PODZOL || worldIn.getLight(pos) < 13 && iblockstate.getBlock().canSustainPlant(iblockstate, worldIn, pos.down(), net.minecraft.util.EnumFacing.UP, this)); } else { return false; } }
@Override public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { ItemStack stack = player.getHeldItem(hand); IBlockState state = world.getBlockState(pos); if (facing == EnumFacing.UP && player.canPlayerEdit(pos.offset(facing), facing, stack) && state.getBlock().canSustainPlant(state, world, pos, EnumFacing.UP, this) && world.isAirBlock(pos.up())) { world.setBlockState(pos.up(), this.sapling.getDefaultState()); stack.shrink(1); return EnumActionResult.SUCCESS; } else { return EnumActionResult.FAIL; } }
@Override public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { ItemStack stack = player.getHeldItem(hand); IBlockState state = worldIn.getBlockState(pos); if (facing == EnumFacing.UP && player.canPlayerEdit(pos.offset(facing), facing, stack) && state.getBlock().canSustainPlant(state, worldIn, pos, EnumFacing.UP, this) && worldIn.isAirBlock(pos.up())) { worldIn.setBlockState(pos.up(), ModBlocks.PLANTED_FLOWER.getDefaultState().withProperty(BlockPlantedGiantFlower.TYPE, BlockPlantedGiantFlower.EnumFlowerType.values()[stack.getItemDamage()]), 11); stack.shrink(1); return EnumActionResult.SUCCESS; } else { return EnumActionResult.FAIL; } }