use of binnie.botany.api.genetics.IColorMix in project Binnie by ForestryMC.
the class Flower method mutateSpecies.
private IChromosome[] mutateSpecies(World world, BlockPos pos, IFlowerGenome genomeFirst, IFlowerGenome genomeSecond) {
IChromosome[] parentFirst = genomeFirst.getChromosomes();
IChromosome[] parentSecond = genomeSecond.getChromosomes();
IAlleleFlowerSpecies alleleFirst;
IAlleleFlowerSpecies alleleSecond;
IFlowerGenome genome0;
IFlowerGenome genome2;
if (world.rand.nextBoolean()) {
alleleFirst = (IAlleleFlowerSpecies) parentFirst[EnumTreeChromosome.SPECIES.ordinal()].getPrimaryAllele();
alleleSecond = (IAlleleFlowerSpecies) parentSecond[EnumTreeChromosome.SPECIES.ordinal()].getSecondaryAllele();
genome0 = genomeFirst;
genome2 = genomeSecond;
} else {
alleleFirst = (IAlleleFlowerSpecies) parentSecond[EnumTreeChromosome.SPECIES.ordinal()].getPrimaryAllele();
alleleSecond = (IAlleleFlowerSpecies) parentFirst[EnumTreeChromosome.SPECIES.ordinal()].getSecondaryAllele();
genome0 = genomeSecond;
genome2 = genomeFirst;
}
IFlowerColor colorFirst = genome0.getPrimaryColor();
IFlowerColor colorSecond = genome2.getPrimaryColor();
if (colorFirst != colorSecond) {
for (IColorMix mutation : BotanyCore.getFlowerRoot().getColorMixes(true)) {
if (mutation.isMutation(colorFirst, colorSecond) && world.rand.nextFloat() * 100.0f < mutation.getChance()) {
parentFirst[EnumFlowerChromosome.PRIMARY.ordinal()] = new Chromosome(mutation.getResult().getAllele());
}
}
}
colorFirst = genome0.getSecondaryColor();
colorSecond = genome2.getSecondaryColor();
if (colorFirst != colorSecond) {
for (IColorMix mutation : BotanyCore.getFlowerRoot().getColorMixes(true)) {
if (mutation.isMutation(colorFirst, colorSecond) && world.rand.nextFloat() * 100.0f < mutation.getChance()) {
parentFirst[EnumFlowerChromosome.SECONDARY.ordinal()] = new Chromosome(mutation.getResult().getAllele());
}
}
}
colorFirst = genome0.getStemColor();
colorSecond = genome2.getStemColor();
if (colorFirst != colorSecond) {
for (IColorMix mutation : BotanyCore.getFlowerRoot().getColorMixes(true)) {
if (mutation.isMutation(colorFirst, colorSecond) && world.rand.nextFloat() * 100.0f < mutation.getChance()) {
parentFirst[EnumFlowerChromosome.STEM.ordinal()] = new Chromosome(mutation.getResult().getAllele());
}
}
}
IChromosome[] template = null;
for (IFlowerMutation mutation2 : BotanyCore.getFlowerRoot().getMutations(true)) {
float chance = mutation2.getChance(world, pos, alleleFirst, alleleSecond, genome0, genome2);
if (chance > 0.0f && world.rand.nextFloat() * 100.0f < chance && template == null) {
template = BotanyCore.getFlowerRoot().templateAsChromosomes(mutation2.getTemplate());
}
}
if (template != null) {
parentFirst = template;
}
return parentFirst;
}
use of binnie.botany.api.genetics.IColorMix in project Binnie by ForestryMC.
the class PageColorMix method onValueChanged.
@Override
public void onValueChanged(IFlowerColor colour) {
List<IColorMix> mixes = new ArrayList<>();
for (IColorMix mix : BotanyCore.getFlowerRoot().getColorMixes(false)) {
if (mix.getColorFirst() == colour || mix.getColorSecond() == colour) {
mixes.add(mix);
}
}
list.setOptions(mixes);
}
use of binnie.botany.api.genetics.IColorMix in project Binnie by ForestryMC.
the class PageColorMixResultant method onValueChanged.
@Override
public void onValueChanged(IFlowerColor colour) {
List<IColorMix> mixes = new ArrayList<>();
for (IColorMix mix : BotanyCore.getFlowerRoot().getColorMixes(false)) {
if (mix.getResult() == colour) {
mixes.add(mix);
}
}
pageSpeciesFurtherList.setOptions(mixes);
}
Aggregations