Search in sources :

Example 16 with IAlleleSpecies

use of forestry.api.genetics.IAlleleSpecies in project Binnie by ForestryMC.

the class ExtraTreeMutation method getVanilla.

public static IAlleleSpecies getVanilla(final String uid) {
    String forestryUid = "forestry.tree" + uid;
    final IAllele allele = AlleleManager.alleleRegistry.getAllele(forestryUid);
    Preconditions.checkArgument(allele != null);
    Preconditions.checkArgument(allele instanceof IAlleleSpecies, "No Forestry species with uid: %s", forestryUid);
    return (IAlleleSpecies) allele;
}
Also used : IAllele(forestry.api.genetics.IAllele) IAlleleSpecies(forestry.api.genetics.IAlleleSpecies)

Example 17 with IAlleleSpecies

use of forestry.api.genetics.IAlleleSpecies in project Binnie by ForestryMC.

the class BreedingSystem method calculateMutations.

@Override
public void calculateMutations(ISpeciesRoot speciesRoot) {
    this.allMutations = new ArrayList<>();
    List<? extends IMutation> speciesMutations = speciesRoot.getMutations(false);
    if (!speciesMutations.isEmpty()) {
        final Set<IMutation> mutations = new LinkedHashSet<>(speciesMutations);
        for (final IMutation mutation : mutations) {
            this.allMutations.add(mutation);
            final Set<IAlleleSpecies> participatingSpecies = new LinkedHashSet<>();
            participatingSpecies.add(mutation.getAllele0());
            participatingSpecies.add(mutation.getAllele1());
            for (final IAlleleSpecies species : participatingSpecies) {
                this.allFurtherMutations.put(species, mutation);
                if (this.allActiveSpecies.contains(species)) {
                    this.furtherMutations.put(species, mutation);
                }
            }
            IAllele[] template = mutation.getTemplate();
            IAlleleSpecies speciesAllele = (IAlleleSpecies) template[0];
            this.allResultantMutations.put(speciesAllele, mutation);
            this.resultantMutations.put(speciesAllele, mutation);
        }
    }
}
Also used : LinkedHashSet(java.util.LinkedHashSet) IAllele(forestry.api.genetics.IAllele) IMutation(forestry.api.genetics.IMutation) IAlleleSpecies(forestry.api.genetics.IAlleleSpecies)

Example 18 with IAlleleSpecies

use of forestry.api.genetics.IAlleleSpecies in project Binnie by ForestryMC.

the class BreedingSystem method calculateAlleles.

@Override
public void calculateAlleles(ISpeciesRoot speciesRoot) {
    this.allSpecies = new ArrayList<>();
    this.allActiveSpecies = new ArrayList<>();
    this.resultantMutations.clear();
    this.furtherMutations.clear();
    this.allResultantMutations.clear();
    this.allFurtherMutations.clear();
    Collection<IAllele> allAlleles = AlleleManager.alleleRegistry.getRegisteredAlleles().values();
    for (IAllele allele : allAlleles) {
        String uid = allele.getUID();
        IAllele[] template = speciesRoot.getTemplate(uid);
        if (template != null) {
            IAlleleSpecies species = (IAlleleSpecies) allele;
            this.allSpecies.add(species);
            if (isBlacklisted(allele) || uid.contains("speciesBotAlfheim")) {
                continue;
            }
            this.allActiveSpecies.add((IAlleleSpecies) allele);
        }
    }
}
Also used : IAllele(forestry.api.genetics.IAllele) IAlleleSpecies(forestry.api.genetics.IAlleleSpecies)

Example 19 with IAlleleSpecies

use of forestry.api.genetics.IAlleleSpecies in project Binnie by ForestryMC.

the class PageFruit method onValueChanged.

@Override
public void onValueChanged(final ItemStack species) {
    this.deleteAllChildren();
    final WindowAbstractDatabase database = Window.get(this);
    new ControlText(this, new Area(0, 0, this.getSize().xPos(), 24), I18N.localise("extratrees.gui.database.tab.fruit." + (this.treesThatBearFruit ? "natural" : "potential")), TextJustification.MIDDLE_CENTER);
    ITreeBreedingSystem breedingSystem = (ITreeBreedingSystem) database.getBreedingSystem();
    final Collection<IAlleleSpecies> trees;
    if (this.treesThatBearFruit) {
        trees = breedingSystem.getTreesThatBearFruit(species, database.isMaster(), database.getWorld(), database.getUsername());
    } else {
        trees = breedingSystem.getTreesThatCanBearFruit(species, database.isMaster(), database.getWorld(), database.getUsername());
    }
    new ControlSpeciesBox(this, 4, 24, this.getSize().xPos() - 8, this.getSize().yPos() - 4 - 24).setOptions(trees);
}
Also used : ITreeBreedingSystem(binnie.genetics.api.ITreeBreedingSystem) Area(binnie.core.gui.geometry.Area) ControlText(binnie.core.gui.controls.ControlText) IAlleleSpecies(forestry.api.genetics.IAlleleSpecies) WindowAbstractDatabase(binnie.core.gui.database.WindowAbstractDatabase) ControlSpeciesBox(binnie.core.gui.database.ControlSpeciesBox)

Example 20 with IAlleleSpecies

use of forestry.api.genetics.IAlleleSpecies in project Binnie by ForestryMC.

the class PagePlanksTrees method onValueChanged.

@Override
public void onValueChanged(final ItemStack species) {
    this.deleteAllChildren();
    final WindowAbstractDatabase database = Window.get(this);
    new ControlText(this, new Area(0, 0, this.getSize().xPos(), 24), species.getDisplayName(), TextJustification.MIDDLE_CENTER);
    final Collection<IAlleleSpecies> trees = getTreesThatMakePlanks(species, database.isMaster(), database.getWorld(), database.getUsername());
    new ControlSpeciesBox(this, 4, 24, this.getSize().xPos() - 8, this.getSize().yPos() - 4 - 24).setOptions(trees);
}
Also used : Area(binnie.core.gui.geometry.Area) ControlText(binnie.core.gui.controls.ControlText) IAlleleSpecies(forestry.api.genetics.IAlleleSpecies) WindowAbstractDatabase(binnie.core.gui.database.WindowAbstractDatabase) ControlSpeciesBox(binnie.core.gui.database.ControlSpeciesBox)

Aggregations

IAlleleSpecies (forestry.api.genetics.IAlleleSpecies)37 ItemStack (net.minecraft.item.ItemStack)11 IAlleleTreeSpecies (forestry.api.arboriculture.IAlleleTreeSpecies)7 ITreeGenome (forestry.api.arboriculture.ITreeGenome)6 IAllele (forestry.api.genetics.IAllele)6 ArrayList (java.util.ArrayList)6 IBreedingSystem (binnie.core.api.genetics.IBreedingSystem)5 IIndividual (forestry.api.genetics.IIndividual)4 ISpeciesRoot (forestry.api.genetics.ISpeciesRoot)4 ControlText (binnie.core.gui.controls.ControlText)3 ControlSpeciesBox (binnie.core.gui.database.ControlSpeciesBox)3 WindowAbstractDatabase (binnie.core.gui.database.WindowAbstractDatabase)3 Area (binnie.core.gui.geometry.Area)3 IBreedingTracker (forestry.api.genetics.IBreedingTracker)3 IClassification (forestry.api.genetics.IClassification)3 IMutation (forestry.api.genetics.IMutation)3 Nullable (javax.annotation.Nullable)3 ITreeBreedingSystem (binnie.genetics.api.ITreeBreedingSystem)2 GameProfile (com.mojang.authlib.GameProfile)2 Alignment (binnie.core.api.gui.Alignment)1