@Override public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, BlockPos pos) { ITreeRoot treeRoot = TreeManager.treeRoot; ITree tree = treeRoot.getMember(germling); return tree != null && treeRoot.plantSapling(world, tree, player.getGameProfile(), pos); }
@Override public boolean prepareBlock(@Nonnull IFarmer farm, @Nonnull BlockPos bc, @Nonnull IBlockState state) { if (isValid()) { ItemStack sapling = farm.getSeedTypeInSuppliesFor(bc); if (sapling.getItem() == ForestryItemStacks.FORESTRY_SAPLING.getItem()) { ITree tree = getRoot().getMember(sapling); if (tree != null && tree.canStay(farm.getWorld(), bc)) { if (Prep.isValid(farm.takeSeedFromSupplies(bc))) { getRoot().plantSapling(farm.getWorld(), tree, farm.getFakePlayer().getGameProfile(), bc); return true; } } } } return false; }
private static ActionResult<ItemStack> onItemRightClickSapling(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, BlockPos pos, ITree tree) { // x, y, z are the coordinates of the block "hit", can thus either be the soil or tall grass, etc. IBlockState hitBlock = worldIn.getBlockState(pos); if (!hitBlock.getBlock().isReplaceable(worldIn, pos)) { if (!worldIn.isAirBlock(pos.up())) { return new ActionResult<>(EnumActionResult.FAIL, itemStackIn); } pos = pos.up(); } if (tree.canStay(worldIn, pos)) { if (TreeManager.treeRoot.plantSapling(worldIn, tree, playerIn.getGameProfile(), pos)) { if (!playerIn.capabilities.isCreativeMode) { itemStackIn.shrink(1); } return new ActionResult<>(EnumActionResult.SUCCESS, itemStackIn); } } return new ActionResult<>(EnumActionResult.FAIL, itemStackIn); }