Search in sources :

Example 6 with ITreeGenome

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

the class BlockDecorativeLeaves method colorMultiplier.

@Override
@SideOnly(Side.CLIENT)
public int colorMultiplier(IBlockState state, @Nullable IBlockAccess worldIn, @Nullable BlockPos pos, int tintIndex) {
    TreeDefinition treeDefinition = state.getValue(getVariant());
    ITreeGenome genome = treeDefinition.getGenome();
    if (tintIndex == BlockAbstractLeaves.FRUIT_COLOR_INDEX) {
        IFruitProvider fruitProvider = genome.getFruitProvider();
        return fruitProvider.getDecorativeColor();
    }
    ILeafSpriteProvider spriteProvider = genome.getPrimary().getLeafSpriteProvider();
    return spriteProvider.getColor(false);
}
Also used : ILeafSpriteProvider(forestry.api.arboriculture.ILeafSpriteProvider) TreeDefinition(forestry.arboriculture.genetics.TreeDefinition) ITreeGenome(forestry.api.arboriculture.ITreeGenome) IFruitProvider(forestry.api.arboriculture.IFruitProvider) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 7 with ITreeGenome

use of forestry.api.arboriculture.ITreeGenome 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 8 with ITreeGenome

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

the class BlockDefaultLeaves method colorMultiplier.

@Override
@SideOnly(Side.CLIENT)
public int colorMultiplier(IBlockState state, @Nullable IBlockAccess worldIn, @Nullable BlockPos pos, int tintIndex) {
    TreeDefinition treeDefinition = getTreeDefinition(state);
    if (treeDefinition == null) {
        treeDefinition = TreeDefinition.Oak;
    }
    ITreeGenome genome = treeDefinition.getGenome();
    if (tintIndex == BlockAbstractLeaves.FRUIT_COLOR_INDEX) {
        IFruitProvider fruitProvider = genome.getFruitProvider();
        return fruitProvider.getDecorativeColor();
    }
    ILeafSpriteProvider spriteProvider = genome.getPrimary().getLeafSpriteProvider();
    return spriteProvider.getColor(false);
}
Also used : ILeafSpriteProvider(forestry.api.arboriculture.ILeafSpriteProvider) TreeDefinition(forestry.arboriculture.genetics.TreeDefinition) ITreeGenome(forestry.api.arboriculture.ITreeGenome) IFruitProvider(forestry.api.arboriculture.IFruitProvider) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 9 with ITreeGenome

use of forestry.api.arboriculture.ITreeGenome in project Binnie by ForestryMC.

the class TreeBreedingSystem method getChance.

@Override
public float getChance(final IMutation mutation, final EntityPlayer player, final IAlleleSpecies firstSpecies, final IAlleleSpecies secondSpecies) {
    ISpeciesRoot speciesRoot = this.getSpeciesRoot();
    final ITreeGenome genome0 = (ITreeGenome) speciesRoot.templateAsGenome(speciesRoot.getTemplate(firstSpecies));
    final ITreeGenome genome2 = (ITreeGenome) speciesRoot.templateAsGenome(speciesRoot.getTemplate(secondSpecies));
    return ((ITreeMutation) mutation).getChance(player.world, player.getPosition(), (IAlleleTreeSpecies) firstSpecies, (IAlleleTreeSpecies) secondSpecies, genome0, genome2);
}
Also used : ISpeciesRoot(forestry.api.genetics.ISpeciesRoot) ITreeMutation(forestry.api.arboriculture.ITreeMutation) ITreeGenome(forestry.api.arboriculture.ITreeGenome)

Example 10 with ITreeGenome

use of forestry.api.arboriculture.ITreeGenome in project Binnie by ForestryMC.

the class TreeBreedingSystem method getTreesThatHaveWood.

@Override
public Collection<IAlleleSpecies> getTreesThatHaveWood(final ItemStack wood, final boolean master, final World world, final GameProfile player) {
    final Collection<IAlleleSpecies> set = master ? this.getAllSpecies() : this.getDiscoveredSpecies(world, player);
    final List<IAlleleSpecies> found = new ArrayList<>();
    for (final IAlleleSpecies species : set) {
        IAlleleTreeSpecies tSpecies = (IAlleleTreeSpecies) species;
        ITreeGenome genome = TreeManager.treeRoot.templateAsGenome(TreeManager.treeRoot.getTemplate(tSpecies));
        IAlleleTreeSpecies treeSpecies = genome.getPrimary();
        final ItemStack woodStack = treeSpecies.getWoodProvider().getWoodStack();
        if (woodStack.isItemEqual(wood)) {
            found.add(species);
        }
    }
    return found;
}
Also used : IAlleleTreeSpecies(forestry.api.arboriculture.IAlleleTreeSpecies) IAlleleSpecies(forestry.api.genetics.IAlleleSpecies) ArrayList(java.util.ArrayList) ItemStack(net.minecraft.item.ItemStack) ITreeGenome(forestry.api.arboriculture.ITreeGenome)

Aggregations

ITreeGenome (forestry.api.arboriculture.ITreeGenome)28 IAlleleTreeSpecies (forestry.api.arboriculture.IAlleleTreeSpecies)14 IFruitProvider (forestry.api.arboriculture.IFruitProvider)11 ItemStack (net.minecraft.item.ItemStack)9 ITree (forestry.api.arboriculture.ITree)8 ILeafSpriteProvider (forestry.api.arboriculture.ILeafSpriteProvider)7 IAlleleSpecies (forestry.api.genetics.IAlleleSpecies)6 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)6 ArrayList (java.util.ArrayList)5 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)5 TextureMap (net.minecraft.client.renderer.texture.TextureMap)5 ResourceLocation (net.minecraft.util.ResourceLocation)5 ETTreeDefinition (binnie.extratrees.genetics.ETTreeDefinition)3 TreeDefinition (forestry.arboriculture.genetics.TreeDefinition)3 IBreedingSystem (binnie.core.api.genetics.IBreedingSystem)2 ITreeMutation (forestry.api.arboriculture.ITreeMutation)2 IAllele (forestry.api.genetics.IAllele)2 IChromosome (forestry.api.genetics.IChromosome)2 ControlText (binnie.core.gui.controls.ControlText)1 Control (binnie.core.gui.controls.core.Control)1