Localization and refactoring (#77)

* Some refactoring for bee production

* Code cleanup

* Code cleanup

* Added some localization

* Fix wrong dropped class

* Added some localization

* Added some localization

* Added some localization

* Fix wrong import
This commit is contained in:
Alexander Kornilov authored and mezz committed 2017-05-23 23:58:13 -07:00
1 parent 68bbe7710c
commit 1ea7b62e5f
157 files changed
+3240 -5045

No files matched your search

@@ -0,0 +1,56 @@
package binnie.genetics.machine.acclimatiser;
import binnie.core.genetics.Gene;
import binnie.core.genetics.Tolerance;
import binnie.genetics.machine.inoculator.Inoculator;
import forestry.api.genetics.AlleleManager;
import forestry.api.genetics.IAlleleTolerance;
import forestry.api.genetics.IChromosomeType;
import forestry.api.genetics.IGenome;
import forestry.api.genetics.IIndividual;
import forestry.api.genetics.ISpeciesRoot;
import net.minecraft.item.ItemStack;
import java.util.Random;
class ToleranceSystem {
public String uid;
public IChromosomeType chromosomeOrdinal;
public ToleranceType type;
ToleranceSystem(String uid, IChromosomeType chromosomeOrdinal, ToleranceType type) {
this.uid = uid;
this.chromosomeOrdinal = chromosomeOrdinal;
this.type = type;
}
public boolean canAlter(ItemStack stack, ItemStack acclim) {
IIndividual member = AlleleManager.alleleRegistry.getIndividual(stack);
IGenome genome = member.getGenome();
IAlleleTolerance tolAllele = (IAlleleTolerance) genome.getActiveAllele(chromosomeOrdinal);
Tolerance tol = Tolerance.get(tolAllele.getValue());
float effect = type.getEffect(acclim);
return (effect > 0.0f && tol.getBounds()[1] < 5) || (effect < 0.0f && tol.getBounds()[0] > -5);
}
public ItemStack alter(ItemStack stack, ItemStack acc) {
Random rand = new Random();
float effect = type.getEffect(acc);
if (rand.nextFloat() > Math.abs(effect)) {
return stack;
}
IIndividual member = AlleleManager.alleleRegistry.getIndividual(stack);
IGenome genome = member.getGenome();
IAlleleTolerance tolAllele = (IAlleleTolerance) genome.getActiveAllele(chromosomeOrdinal);
Tolerance tol = Tolerance.get(tolAllele.getValue());
Tolerance newTol = Acclimatiser.alterTolerance(tol, effect);
if (rand.nextFloat() > 1.0f / (-newTol.getBounds()[0] + newTol.getBounds()[1])) {
return stack;
}
ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(stack);
Inoculator.setGene(new Gene(newTol.getAllele(), chromosomeOrdinal, root), stack, rand.nextInt(2));
return stack;
}
}