Search in sources :

Example 16 with ITree

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);
}
Also used : ITree(forestry.api.arboriculture.ITree) TileSapling(forestry.arboriculture.tiles.TileSapling)

Example 17 with ITree

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);
    }
}
Also used : ITree(forestry.api.arboriculture.ITree) ItemStack(net.minecraft.item.ItemStack) ITreeGenome(forestry.api.arboriculture.ITreeGenome) IFruitProvider(forestry.api.arboriculture.IFruitProvider)

Example 18 with ITree

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());
}
Also used : ITree(forestry.api.arboriculture.ITree) TileSapling(forestry.arboriculture.tiles.TileSapling)

Example 19 with ITree

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;
}
Also used : Item(net.minecraft.item.Item) ItemRegistryArboriculture(forestry.arboriculture.items.ItemRegistryArboriculture) EnumGermlingType(forestry.api.arboriculture.EnumGermlingType) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ITree(forestry.api.arboriculture.ITree) ItemStack(net.minecraft.item.ItemStack)

Example 20 with ITree

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;
}
Also used : ITree(forestry.api.arboriculture.ITree) ItemStack(net.minecraft.item.ItemStack)

Aggregations

ITree (forestry.api.arboriculture.ITree)33 ItemStack (net.minecraft.item.ItemStack)9 ITreeGenome (forestry.api.arboriculture.ITreeGenome)8 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)5 IAlleleTreeSpecies (forestry.api.arboriculture.IAlleleTreeSpecies)4 IFruitProvider (forestry.api.arboriculture.IFruitProvider)4 IAllele (forestry.api.genetics.IAllele)4 EnumGermlingType (forestry.api.arboriculture.EnumGermlingType)3 IAlleleFruit (forestry.api.arboriculture.IAlleleFruit)3 TileSapling (forestry.arboriculture.tiles.TileSapling)3 GuiAlyzer (forestry.core.gui.GuiAlyzer)3 TextLayoutHelper (forestry.core.gui.TextLayoutHelper)3 TileLeaves (forestry.arboriculture.tiles.TileLeaves)2 ArrayList (java.util.ArrayList)2 Nullable (javax.annotation.Nullable)2 IBlockState (net.minecraft.block.state.IBlockState)2 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)2 BlockPos (net.minecraft.util.math.BlockPos)2 Biome (net.minecraft.world.biome.Biome)2 WorldGenerator (net.minecraft.world.gen.feature.WorldGenerator)2