Search in sources :

Example 21 with ITree

use of forestry.api.arboriculture.ITree in project ForestryMC by ForestryMC.

the class TileLeaves method matureCaterpillar.

/* IBUTTERFLYNURSERY */
private void matureCaterpillar() {
    if (caterpillar == null) {
        return;
    }
    maturationTime++;
    ITree tree = getTree();
    boolean wasDestroyed = isDestroyed(tree, damage);
    damage += caterpillar.getGenome().getMetabolism();
    IButterflyGenome caterpillarGenome = caterpillar.getGenome();
    int caterpillarMatureTime = Math.round((float) caterpillarGenome.getLifespan() / (caterpillarGenome.getFertility() * 2));
    if (maturationTime >= caterpillarMatureTime) {
        ButterflyManager.butterflyRoot.plantCocoon(world, pos.down(), getCaterpillar(), getOwnerHandler().getOwner(), 0, false);
        setCaterpillar(null);
    } else if (!wasDestroyed && isDestroyed(tree, damage)) {
        sendNetworkUpdate();
    }
}
Also used : IButterflyGenome(forestry.api.lepidopterology.IButterflyGenome) ITree(forestry.api.arboriculture.ITree)

Example 22 with ITree

use of forestry.api.arboriculture.ITree in project ForestryMC by ForestryMC.

the class TileLeaves method getFoliageColour.

@SideOnly(Side.CLIENT)
public int getFoliageColour(EntityPlayer player) {
    final boolean showPollinated = isPollinatedState && GeneticsUtil.hasNaturalistEye(player);
    final int baseColor = getLeafSpriteProvider().getColor(showPollinated);
    ITree tree = getTree();
    if (isDestroyed(tree, damage)) {
        return ColourUtil.addRGBComponents(baseColor, 92, 61, 0);
    } else if (caterpillar != null) {
        return ColourUtil.multiplyRGBComponents(baseColor, 1.5f);
    } else {
        return baseColor;
    }
}
Also used : ITree(forestry.api.arboriculture.ITree) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 23 with ITree

use of forestry.api.arboriculture.ITree in project ForestryMC by ForestryMC.

the class TileSapling method tryGrow.

public void tryGrow(Random random, boolean bonemealed) {
    ITree tree = getTree();
    if (tree == null) {
        return;
    }
    int maturity = getRequiredMaturity(world, tree);
    if (timesTicked < maturity) {
        if (bonemealed) {
            timesTicked = maturity;
        }
        return;
    }
    WorldGenerator generator = tree.getTreeGenerator(world, getPos(), bonemealed);
    final boolean generated;
    if (generator instanceof WorldGenBase) {
        generated = ((WorldGenBase) generator).generate(world, random, getPos(), false);
    } else {
        generated = generator.generate(world, random, getPos());
    }
    if (generated) {
        IBreedingTracker breedingTracker = TreeManager.treeRoot.getBreedingTracker(world, getOwnerHandler().getOwner());
        breedingTracker.registerBirth(tree);
    }
}
Also used : WorldGenerator(net.minecraft.world.gen.feature.WorldGenerator) IBreedingTracker(forestry.api.genetics.IBreedingTracker) ITree(forestry.api.arboriculture.ITree) WorldGenBase(forestry.core.worldgen.WorldGenBase)

Example 24 with ITree

use of forestry.api.arboriculture.ITree in project ForestryMC by ForestryMC.

the class TileSapling method canAcceptBoneMeal.

public boolean canAcceptBoneMeal(Random rand) {
    ITree tree = getTree();
    if (tree == null) {
        return false;
    }
    int maturity = getRequiredMaturity(world, tree);
    if (timesTicked < maturity) {
        return true;
    }
    WorldGenerator generator = tree.getTreeGenerator(world, getPos(), true);
    if (generator instanceof WorldGenArboriculture) {
        WorldGenArboriculture arboricultureGenerator = (WorldGenArboriculture) generator;
        arboricultureGenerator.preGenerate(world, rand, getPos());
        return arboricultureGenerator.getValidGrowthPos(world, getPos()) != null;
    } else {
        return true;
    }
}
Also used : WorldGenerator(net.minecraft.world.gen.feature.WorldGenerator) WorldGenArboriculture(forestry.arboriculture.worldgen.WorldGenArboriculture) ITree(forestry.api.arboriculture.ITree)

Example 25 with ITree

use of forestry.api.arboriculture.ITree in project ForestryMC by ForestryMC.

the class ItemGermlingGE method getFermentationModifier.

@Override
public float getFermentationModifier(ItemStack itemstack) {
    itemstack = GeneticsUtil.convertToGeneticEquivalent(itemstack);
    ITree tree = TreeManager.treeRoot.getMember(itemstack);
    if (tree == null) {
        return 1.0f;
    }
    return tree.getGenome().getSappiness() * 10;
}
Also used : ITree(forestry.api.arboriculture.ITree)

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