Search in sources :

Example 11 with IAlleleTreeSpecies

use of forestry.api.arboriculture.IAlleleTreeSpecies 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 12 with IAlleleTreeSpecies

use of forestry.api.arboriculture.IAlleleTreeSpecies 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 13 with IAlleleTreeSpecies

use of forestry.api.arboriculture.IAlleleTreeSpecies 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 14 with IAlleleTreeSpecies

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

the class TreeDatabaseTab method createElements.

@Override
public void createElements(IGuiElementHelper elementHelper, ITree tree, ItemStack itemStack) {
    IAlleleTreeSpecies primarySpecies = tree.getGenome().getPrimary();
    boolean active = tab == EnumDatabaseTab.ACTIVE_SPECIES;
    IAlleleTreeSpecies species = active ? primarySpecies : tree.getGenome().getSecondary();
    int speciesColor = elementHelper.factory().getColorCoding(species.isDominant());
    elementHelper.addText(Translator.translateToLocal("for.gui.database.tab." + tab.name().toLowerCase() + ".name"), GuiElementAlignment.CENTER, 0xcfb53b);
    elementHelper.addAllele(Translator.translateToLocal("for.gui.species"), tree, EnumTreeChromosome.SPECIES, active);
    elementHelper.addAllele(Translator.translateToLocal("for.gui.saplings"), tree, EnumTreeChromosome.FERTILITY, active);
    elementHelper.addAllele(Translator.translateToLocal("for.gui.maturity"), tree, EnumTreeChromosome.MATURATION, active);
    elementHelper.addAllele(Translator.translateToLocal("for.gui.height"), tree, EnumTreeChromosome.HEIGHT, active);
    IAlleleInteger girth = (IAlleleInteger) (active ? tree.getGenome().getActiveAllele(EnumTreeChromosome.GIRTH) : tree.getGenome().getInactiveAllele(EnumTreeChromosome.GIRTH));
    elementHelper.addText(TextFormatting.UNDERLINE + Translator.translateToLocal("for.gui.girth"), GuiElementAlignment.CENTER);
    elementHelper.addText(String.format("%sx%s", girth.getValue(), girth.getValue()), GuiElementAlignment.CENTER, elementHelper.factory().getColorCoding(girth.isDominant()));
    elementHelper.addAllele(Translator.translateToLocal("for.gui.yield"), tree, EnumTreeChromosome.YIELD, active);
    elementHelper.addAllele(Translator.translateToLocal("for.gui.sappiness"), tree, EnumTreeChromosome.SAPPINESS, active);
    elementHelper.addAllele(Translator.translateToLocal("for.gui.effect"), tree, EnumTreeChromosome.EFFECT, active);
    elementHelper.addText(TextFormatting.UNDERLINE + Translator.translateToLocal("for.gui.native"), GuiElementAlignment.CENTER);
    elementHelper.addText(Translator.translateToLocal("for.gui." + tree.getGenome().getPrimary().getPlantType().toString().toLowerCase(Locale.ENGLISH)), GuiElementAlignment.CENTER, speciesColor);
    elementHelper.addText(TextFormatting.UNDERLINE + Translator.translateToLocal("for.gui.supports"), GuiElementAlignment.CENTER);
    List<IFruitFamily> families = new ArrayList<>(tree.getGenome().getPrimary().getSuitableFruit());
    for (IFruitFamily fruitFamily : families) {
        elementHelper.addText(fruitFamily.getName(), GuiElementAlignment.CENTER, speciesColor);
    }
    IAlleleFruit fruit = (IAlleleFruit) (active ? tree.getGenome().getActiveAllele(EnumTreeChromosome.FRUITS) : tree.getGenome().getInactiveAllele(EnumTreeChromosome.FRUITS));
    int colorCoding = elementHelper.factory().getColorCoding(tree.getGenome().getActiveAllele(EnumTreeChromosome.FRUITS).isDominant());
    elementHelper.addText(TextFormatting.UNDERLINE + Translator.translateToLocal("for.gui.fruits"), GuiElementAlignment.CENTER);
    String strike = "";
    if (!species.getSuitableFruit().contains(fruit.getProvider().getFamily()) && fruit != AlleleFruits.fruitNone) {
        strike = TextFormatting.STRIKETHROUGH.toString();
    }
    elementHelper.addText(strike + fruit.getProvider().getDescription(), GuiElementAlignment.CENTER, colorCoding);
    IFruitFamily family = fruit.getProvider().getFamily();
    if (family != null && !family.getUID().equals(EnumFruitFamily.NONE.getUID())) {
        elementHelper.addText(TextFormatting.UNDERLINE + Translator.translateToLocal("for.gui.family"), GuiElementAlignment.CENTER);
        elementHelper.addText(family.getName(), GuiElementAlignment.CENTER, colorCoding);
    }
}
Also used : IAlleleTreeSpecies(forestry.api.arboriculture.IAlleleTreeSpecies) IAlleleInteger(forestry.api.genetics.IAlleleInteger) IFruitFamily(forestry.api.genetics.IFruitFamily) ArrayList(java.util.ArrayList) IAlleleFruit(forestry.api.arboriculture.IAlleleFruit)

Example 15 with IAlleleTreeSpecies

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

the class ModelDefaultLeaves method bakeBlock.

@Override
protected void bakeBlock(BlockDefaultLeaves block, TreeDefinition 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, BlockAbstractLeaves.FOLIAGE_COLOR_INDEX);
    // Render overlay for fruit leaves.
    ResourceLocation fruitSpriteLocation = genome.getFruitProvider().getDecorativeSprite();
    if (fruitSpriteLocation != null) {
        TextureAtlasSprite fruitSprite = map.getAtlasSprite(fruitSpriteLocation.toString());
        baker.addBlockModel(null, fruitSprite, BlockAbstractLeaves.FRUIT_COLOR_INDEX);
    }
    // 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)

Aggregations

IAlleleTreeSpecies (forestry.api.arboriculture.IAlleleTreeSpecies)24 ITreeGenome (forestry.api.arboriculture.ITreeGenome)14 IAlleleSpecies (forestry.api.genetics.IAlleleSpecies)7 ItemStack (net.minecraft.item.ItemStack)7 IAllele (forestry.api.genetics.IAllele)6 ArrayList (java.util.ArrayList)6 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)6 ResourceLocation (net.minecraft.util.ResourceLocation)6 ILeafSpriteProvider (forestry.api.arboriculture.ILeafSpriteProvider)5 TextureMap (net.minecraft.client.renderer.texture.TextureMap)5 ITree (forestry.api.arboriculture.ITree)4 IBreedingSystem (binnie.core.api.genetics.IBreedingSystem)2 IChromosome (forestry.api.genetics.IChromosome)2 IFruitFamily (forestry.api.genetics.IFruitFamily)2 IBlockState (net.minecraft.block.state.IBlockState)2 Biome (net.minecraft.world.biome.Biome)2 ControlText (binnie.core.gui.controls.ControlText)1 Control (binnie.core.gui.controls.core.Control)1 ControlScrollableContent (binnie.core.gui.controls.scroll.ControlScrollableContent)1 Area (binnie.core.gui.geometry.Area)1