Search in sources :

Example 1 with IMutation

use of forestry.api.genetics.IMutation in project ForestryMC by ForestryMC.

the class GeneticsUtil method getGeneticAdvancement.

private static int getGeneticAdvancement(IAlleleSpecies species, Set<IAlleleSpecies> exclude, IChromosomeType speciesChromosome) {
    int highest = 0;
    exclude.add(species);
    for (IMutation mutation : species.getRoot().getPaths(species, speciesChromosome)) {
        highest = getHighestAdvancement(mutation.getAllele0(), highest, exclude, speciesChromosome);
        highest = getHighestAdvancement(mutation.getAllele1(), highest, exclude, speciesChromosome);
    }
    return 1 + highest;
}
Also used : IMutation(forestry.api.genetics.IMutation)

Example 2 with IMutation

use of forestry.api.genetics.IMutation in project ForestryMC by ForestryMC.

the class AlleleSpecies method getResearchBounty.

@Override
public NonNullList<ItemStack> getResearchBounty(World world, GameProfile researcher, IIndividual individual, int bountyLevel) {
    if (world.rand.nextFloat() < bountyLevel / 16.0f) {
        List<? extends IMutation> allMutations = getRoot().getCombinations(this);
        if (!allMutations.isEmpty()) {
            List<IMutation> unresearchedMutations = new ArrayList<>();
            IBreedingTracker tracker = individual.getGenome().getSpeciesRoot().getBreedingTracker(world, researcher);
            for (IMutation mutation : allMutations) {
                if (!tracker.isResearched(mutation)) {
                    unresearchedMutations.add(mutation);
                }
            }
            IMutation chosenMutation;
            if (!unresearchedMutations.isEmpty()) {
                chosenMutation = unresearchedMutations.get(world.rand.nextInt(unresearchedMutations.size()));
            } else {
                chosenMutation = allMutations.get(world.rand.nextInt(allMutations.size()));
            }
            ItemStack researchNote = AlleleManager.alleleRegistry.getMutationNoteStack(researcher, chosenMutation);
            NonNullList<ItemStack> bounty = NonNullList.create();
            bounty.add(researchNote);
            return bounty;
        }
    }
    return NonNullList.create();
}
Also used : IMutation(forestry.api.genetics.IMutation) IBreedingTracker(forestry.api.genetics.IBreedingTracker) ArrayList(java.util.ArrayList) ItemStack(net.minecraft.item.ItemStack)

Example 3 with IMutation

use of forestry.api.genetics.IMutation in project ForestryMC by ForestryMC.

the class GuiNaturalistInventory method displaySpeciesInformation.

private void displaySpeciesInformation(boolean analyzed, IAlleleSpecies species, ItemStack iconStack, int x) {
    if (!analyzed) {
        textLayout.drawLine(Translator.translateToLocal("for.gui.unknown"), x);
        return;
    }
    textLayout.drawLine(species.getAlleleName(), x);
    GuiUtil.drawItemStack(this, iconStack, guiLeft + x + 69, guiTop + textLayout.getLineY() - 2);
    textLayout.newLine();
    // Viable Combinations
    int columnWidth = 16;
    int column = 10;
    for (IMutation combination : speciesRoot.getCombinations(species)) {
        if (combination.isSecret()) {
            continue;
        }
        if (breedingTracker.isDiscovered(combination)) {
            drawMutationIcon(combination, species, column);
        } else {
            drawUnknownIcon(combination, column);
        }
        column += columnWidth;
        if (column > 75) {
            column = 10;
            textLayout.newLine(18);
        }
    }
    textLayout.newLine();
    textLayout.newLine();
}
Also used : IMutation(forestry.api.genetics.IMutation)

Example 4 with IMutation

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

the class ControlMutationBox method setSpecies.

public void setSpecies(@Nullable final IAlleleSpecies species) {
    if (species != this.species) {
        this.species = species;
        this.movePercentage(-100.0f);
        final IBreedingSystem system = ((WindowAbstractDatabase) this.getTopParent()).getBreedingSystem();
        final List<IMutation> discovered = system.getDiscoveredMutations(Window.get(this).getWorld(), Window.get(this).getUsername());
        if (species != null) {
            if (this.type == Type.Resultant) {
                this.setOptions(system.getResultantMutations(species));
            } else {
                final List<IMutation> mutations = system.getFurtherMutations(species);
                int i = 0;
                while (i < mutations.size()) {
                    final IMutation mutation = mutations.get(i);
                    if (!discovered.contains(mutation) && !((IAlleleSpecies) mutation.getTemplate()[0]).isCounted()) {
                        mutations.remove(i);
                    } else {
                        ++i;
                    }
                }
                this.setOptions(mutations);
            }
        }
    }
}
Also used : IMutation(forestry.api.genetics.IMutation) IAlleleSpecies(forestry.api.genetics.IAlleleSpecies) IBreedingSystem(binnie.core.api.genetics.IBreedingSystem)

Example 5 with IMutation

use of forestry.api.genetics.IMutation 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)

Aggregations

IMutation (forestry.api.genetics.IMutation)10 IAllele (forestry.api.genetics.IAllele)3 IAlleleSpecies (forestry.api.genetics.IAlleleSpecies)3 ArrayList (java.util.ArrayList)3 IBreedingTracker (forestry.api.genetics.IBreedingTracker)2 IChromosome (forestry.api.genetics.IChromosome)2 Nullable (javax.annotation.Nullable)2 IBreedingSystem (binnie.core.api.genetics.IBreedingSystem)1 GameProfile (com.mojang.authlib.GameProfile)1 IAlleleBeeSpecies (forestry.api.apiculture.IAlleleBeeSpecies)1 IApiaristTracker (forestry.api.apiculture.IApiaristTracker)1 IBeeGenome (forestry.api.apiculture.IBeeGenome)1 IBeeMutation (forestry.api.apiculture.IBeeMutation)1 IAlleleTreeSpecies (forestry.api.arboriculture.IAlleleTreeSpecies)1 IArboristTracker (forestry.api.arboriculture.IArboristTracker)1 ITreeGenome (forestry.api.arboriculture.ITreeGenome)1 ITreeMutation (forestry.api.arboriculture.ITreeMutation)1 IGenome (forestry.api.genetics.IGenome)1 ISpeciesRoot (forestry.api.genetics.ISpeciesRoot)1 LinkedHashSet (java.util.LinkedHashSet)1