Search in sources :

Example 11 with ITreeGenome

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

the class TreeBreedingSystem method calculateArrays.

@Override
public final void calculateArrays() {
    super.calculateArrays();
    for (final IAlleleSpecies species : this.allActiveSpecies) {
        final IAlleleTreeSpecies tSpecies = (IAlleleTreeSpecies) species;
        final ITreeGenome genome = (ITreeGenome) this.getSpeciesRoot().templateAsGenome(this.getSpeciesRoot().getTemplate(tSpecies));
        IAlleleTreeSpecies treeSpecies = genome.getPrimary();
        final ItemStack wood = treeSpecies.getWoodProvider().getWoodStack();
        if (!wood.isEmpty()) {
            this.allWoods.add(wood);
        }
        /*for (final ItemStack wood : tSpecies.getRoot().templateAsIndividual(getSpeciesRoot().getTemplate(tSpecies.getUID())).getProduceList()) {
				this.allWoods.add(wood);
			}*/
        this.allFruits.addAll(genome.getFruitProvider().getProducts().keySet());
    }
}
Also used : IAlleleTreeSpecies(forestry.api.arboriculture.IAlleleTreeSpecies) IAlleleSpecies(forestry.api.genetics.IAlleleSpecies) ItemStack(net.minecraft.item.ItemStack) ITreeGenome(forestry.api.arboriculture.ITreeGenome)

Example 12 with ITreeGenome

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

the class TreeBreedingSystem method getTreesThatBearFruit.

@Override
public Collection<IAlleleSpecies> getTreesThatBearFruit(final ItemStack fruit, 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) {
        final IAlleleTreeSpecies tSpecies = (IAlleleTreeSpecies) species;
        final ITreeGenome genome = (ITreeGenome) this.getSpeciesRoot().templateAsGenome(this.getSpeciesRoot().getTemplate(tSpecies));
        for (final ItemStack fruit2 : genome.getFruitProvider().getProducts().keySet()) {
            if (fruit2.isItemEqual(fruit)) {
                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)

Example 13 with ITreeGenome

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

the class TreeBreedingSystem method getTreesThatCanBearFruit.

@Override
public Collection<IAlleleSpecies> getTreesThatCanBearFruit(final ItemStack fruit, 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<>();
    final Set<IFruitFamily> providers = new HashSet<>();
    for (final IAlleleSpecies species : set) {
        final IAlleleTreeSpecies tSpecies = (IAlleleTreeSpecies) species;
        final ITreeGenome genome = (ITreeGenome) this.getSpeciesRoot().templateAsGenome(this.getSpeciesRoot().getTemplate(tSpecies));
        for (final ItemStack fruit2 : genome.getFruitProvider().getProducts().keySet()) {
            if (fruit2.isItemEqual(fruit)) {
                providers.add(genome.getFruitProvider().getFamily());
            }
        }
    }
    for (final IAlleleSpecies species : set) {
        final IAlleleTreeSpecies tSpecies = (IAlleleTreeSpecies) species;
        for (final IFruitFamily family : providers) {
            if (tSpecies.getSuitableFruit().contains(family)) {
                found.add(species);
                break;
            }
        }
    }
    return found;
}
Also used : IAlleleTreeSpecies(forestry.api.arboriculture.IAlleleTreeSpecies) IAlleleSpecies(forestry.api.genetics.IAlleleSpecies) ArrayList(java.util.ArrayList) IFruitFamily(forestry.api.genetics.IFruitFamily) ItemStack(net.minecraft.item.ItemStack) ITreeGenome(forestry.api.arboriculture.ITreeGenome) HashSet(java.util.HashSet)

Example 14 with ITreeGenome

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

the class ModelETDecorativeLeaves method bakeBlock.

@Override
protected void bakeBlock(BlockETDecorativeLeaves block, ETTreeDefinition treeDefinition, IModelBaker baker, boolean inventory) {
    TextureMap map = Minecraft.getMinecraft().getTextureMapBlocks();
    ITreeGenome genome = treeDefinition.getGenome();
    IAlleleTreeSpecies species = genome.getPrimary();
    ILeafSpriteProvider leafSpriteProvider = species.getLeafSpriteProvider();
    ResourceLocation leafSpriteLocation = leafSpriteProvider.getSprite(false, Proxies.render.fancyGraphicsEnabled());
    TextureAtlasSprite leafSprite = map.getAtlasSprite(leafSpriteLocation.toString());
    // Render the plain leaf block.
    baker.addBlockModel(null, leafSprite, 0);
    // Render overlay for fruit leaves.
    ResourceLocation fruitSpriteLocation = genome.getFruitProvider().getDecorativeSprite();
    if (fruitSpriteLocation != null) {
        TextureAtlasSprite fruitSprite = map.getAtlasSprite(fruitSpriteLocation.toString());
        baker.addBlockModel(null, fruitSprite, 1);
    }
    // Set the particle sprite
    baker.setParticleSprite(leafSprite);
}
Also used : IAlleleTreeSpecies(forestry.api.arboriculture.IAlleleTreeSpecies) TextureMap(net.minecraft.client.renderer.texture.TextureMap) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) ResourceLocation(net.minecraft.util.ResourceLocation) ILeafSpriteProvider(forestry.api.arboriculture.ILeafSpriteProvider) ITreeGenome(forestry.api.arboriculture.ITreeGenome)

Example 15 with ITreeGenome

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

the class TileLeaves method setTree.

@Override
public void setTree(ITree tree) {
    super.setTree(tree);
    ITreeGenome genome = tree.getGenome();
    species = genome.getPrimary();
    if (tree.canBearFruit()) {
        IFruitProvider fruitProvider = genome.getFruitProvider();
        isFruitLeaf = fruitProvider.isFruitLeaf(genome, world, getPos());
        if (isFruitLeaf) {
            // Hardcoded because vanilla oak trees don't show fruits.
            if (species == TreeDefinition.Oak.getGenome().getPrimary() && fruitProvider == AlleleFruits.fruitApple.getProvider()) {
                fruitSprite = null;
            } else {
                fruitSprite = fruitProvider.getSprite(genome, world, getPos(), getRipeningTime());
            }
            ripeningPeriod = (short) tree.getGenome().getFruitProvider().getRipeningPeriod();
        }
    } else {
        isFruitLeaf = false;
        fruitSprite = null;
    }
    markDirty();
}
Also used : ITreeGenome(forestry.api.arboriculture.ITreeGenome) IFruitProvider(forestry.api.arboriculture.IFruitProvider)

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