use of forestry.api.arboriculture.ITree in project ForestryMC by ForestryMC.
the class BlockSapling method canBlockStay.
/* PLANTING */
public static boolean canBlockStay(IBlockAccess world, BlockPos pos) {
TileSapling tile = TileUtil.getTile(world, pos, TileSapling.class);
if (tile == null) {
return false;
}
ITree tree = tile.getTree();
return tree != null && tree.canStay(world, pos);
}
use of forestry.api.arboriculture.ITree in project ForestryMC by ForestryMC.
the class BlockDefaultLeaves method getLeafDrop.
@Override
protected void getLeafDrop(NonNullList<ItemStack> drops, World world, @Nullable GameProfile playerProfile, BlockPos pos, float saplingModifier, int fortune) {
ITree tree = getTree(world, pos);
if (tree == null) {
return;
}
// Add saplings
List<ITree> saplings = tree.getSaplings(world, playerProfile, pos, saplingModifier);
for (ITree sapling : saplings) {
if (sapling != null) {
drops.add(TreeManager.treeRoot.getMemberStack(sapling, EnumGermlingType.SAPLING));
}
}
// Add fruits
ITreeGenome genome = tree.getGenome();
IFruitProvider fruitProvider = genome.getFruitProvider();
if (fruitProvider.isFruitLeaf(genome, world, pos)) {
NonNullList<ItemStack> produceStacks = tree.produceStacks(world, pos, Integer.MAX_VALUE);
drops.addAll(produceStacks);
}
}
use of forestry.api.arboriculture.ITree in project ForestryMC by ForestryMC.
the class TreeGrowthHelper method isSapling.
private static boolean isSapling(ITreeGenome genome, World world, BlockPos pos) {
if (!world.isBlockLoaded(pos)) {
return false;
}
if (world.isAirBlock(pos)) {
return false;
}
TileSapling sapling = TileUtil.getTile(world, pos, TileSapling.class);
if (sapling == null) {
return false;
}
ITree tree = sapling.getTree();
return tree != null && tree.getGenome().getPrimary().getUID().equals(genome.getPrimary().getUID());
}
use of forestry.api.arboriculture.ITree in project ForestryMC by ForestryMC.
the class TreeRoot method getMemberStack.
@Override
public ItemStack getMemberStack(IIndividual tree, ISpeciesType type) {
Preconditions.checkArgument(tree instanceof ITree, "individual is not a tree");
Preconditions.checkArgument(type instanceof EnumGermlingType, "type is not an EnumGermlingType");
ItemRegistryArboriculture items = ModuleArboriculture.getItems();
Item germlingItem;
switch((EnumGermlingType) type) {
case SAPLING:
germlingItem = items.sapling;
break;
case POLLEN:
germlingItem = items.pollenFertile;
break;
default:
throw new RuntimeException("Cannot instantiate a tree of type " + type);
}
NBTTagCompound nbttagcompound = new NBTTagCompound();
tree.writeToNBT(nbttagcompound);
ItemStack treeStack = new ItemStack(germlingItem);
treeStack.setTagCompound(nbttagcompound);
return treeStack;
}
use of forestry.api.arboriculture.ITree in project ForestryMC by ForestryMC.
the class TileLeaves method pickFruit.
/* IFRUITBEARER */
@Override
public NonNullList<ItemStack> pickFruit(ItemStack tool) {
ITree tree = getTree();
if (tree == null || !hasFruit()) {
return NonNullList.create();
}
NonNullList<ItemStack> produceStacks = tree.produceStacks(world, getPos(), getRipeningTime());
ripeningTime = 0;
sendNetworkUpdateRipening();
return produceStacks;
}
Aggregations