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;
}
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();
}
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();
}
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);
}
}
}
}
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);
}
}
}
Aggregations