use of forestry.api.lepidopterology.IButterflyMutation in project ForestryMC by ForestryMC.
the class Butterfly method mutateSpecies.
@Nullable
private static IChromosome[] mutateSpecies(World world, IButterflyNursery nursery, IGenome genomeOne, IGenome genomeTwo) {
IChromosome[] parent1 = genomeOne.getChromosomes();
IChromosome[] parent2 = genomeTwo.getChromosomes();
IGenome genome0;
IGenome genome1;
IAllele allele0;
IAllele allele1;
if (rand.nextBoolean()) {
allele0 = parent1[EnumButterflyChromosome.SPECIES.ordinal()].getPrimaryAllele();
allele1 = parent2[EnumButterflyChromosome.SPECIES.ordinal()].getSecondaryAllele();
genome0 = genomeOne;
genome1 = genomeTwo;
} else {
allele0 = parent2[EnumButterflyChromosome.SPECIES.ordinal()].getPrimaryAllele();
allele1 = parent1[EnumButterflyChromosome.SPECIES.ordinal()].getSecondaryAllele();
genome0 = genomeTwo;
genome1 = genomeOne;
}
for (IButterflyMutation mutation : ButterflyManager.butterflyRoot.getMutations(true)) {
float chance = mutation.getChance(world, nursery, allele0, allele1, genome0, genome1);
if (chance > rand.nextFloat() * 100) {
return ButterflyManager.butterflyRoot.templateAsChromosomes(mutation.getTemplate());
}
}
return null;
}
Aggregations