use of binnie.core.genetics.Tolerance in project Binnie by ForestryMC.
the class ControlToleranceBar method setValues.
public void setValues(T value, forestry.api.genetics.EnumTolerance enumTol) {
tolerated.clear();
Tolerance tol = Tolerance.get(enumTol);
for (T full : fullSet) {
if (full.ordinal() > value.ordinal() + tol.getBounds()[1]) {
continue;
}
if (full.ordinal() < value.ordinal() + tol.getBounds()[0]) {
continue;
}
tolerated.add(full);
}
}
use of binnie.core.genetics.Tolerance in project Binnie by ForestryMC.
the class ToleranceSystem method canAlter.
public boolean canAlter(final ItemStack stack, final ItemStack acclim) {
final IIndividual member = AlleleManager.alleleRegistry.getIndividual(stack);
final IGenome genome = member.getGenome();
final IAlleleTolerance tolAllele = (IAlleleTolerance) genome.getActiveAllele(this.chromosomeType);
final Tolerance tol = Tolerance.get(tolAllele.getValue());
final float effect = this.type.getEffect(acclim);
return (effect > 0.0f && tol.getBounds()[1] < 5) || (effect < 0.0f && tol.getBounds()[0] > -5);
}
use of binnie.core.genetics.Tolerance in project Binnie by ForestryMC.
the class ToleranceSystem method alter.
public ItemStack alter(final ItemStack stack, final ItemStack acc) {
final Random rand = new Random();
final float effect = this.type.getEffect(acc);
if (rand.nextFloat() > Math.abs(effect)) {
return stack;
}
final IIndividual member = AlleleManager.alleleRegistry.getIndividual(stack);
final IGenome genome = member.getGenome();
final IAlleleTolerance tolAllele = (IAlleleTolerance) genome.getActiveAllele(this.chromosomeType);
final Tolerance tol = Tolerance.get(tolAllele.getValue());
final Tolerance newTol = Acclimatiser.alterTolerance(tol, effect);
if (rand.nextFloat() > 1.0f / (-newTol.getBounds()[0] + newTol.getBounds()[1])) {
return stack;
}
final ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(stack);
boolean setPrimary = rand.nextBoolean();
boolean setSecondary = !setPrimary;
Gene gene = new Gene(newTol.getAllele(), this.chromosomeType, root);
Splicer.setGene(gene, stack, setPrimary, setSecondary);
return stack;
}
Aggregations