mirror of
https://github.com/GTNewHorizons/Binnie.git
synced 2026-10-25 20:22:30 +00:00
Isolator crash fix revision (#56)
Co-authored-by: Maya <10861407+serenibyss@users.noreply.github.com>
This commit is contained in:
1 parent
8d0fa2ebb5
commit
5f1b5daa24
1 file changed
+14
-19
@@ -1,12 +1,11 @@
|
||||
package binnie.genetics.machine.isolator;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import binnie.core.genetics.Gene;
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.core.machines.inventory.IChargedSlots;
|
||||
@@ -18,14 +17,13 @@ import binnie.extrabees.config.EBConfigMachines;
|
||||
import binnie.genetics.item.ItemSequence;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.IChromosome;
|
||||
import forestry.api.genetics.IChromosomeType;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
|
||||
public class IsolatorComponentLogic extends ComponentProcessSetCost implements IProcess {
|
||||
|
||||
private static final Logger LOG = LogManager.getLogger("Genetics");
|
||||
|
||||
protected float enzymePerProcess = 0.5f;
|
||||
protected float ethanolPerProcess = 10.0f;
|
||||
|
||||
@@ -84,22 +82,19 @@ public class IsolatorComponentLogic extends ComponentProcessSetCost implements I
|
||||
}
|
||||
|
||||
final IChromosomeType[] karyo = root.getKaryotype();
|
||||
final IChromosomeType chromosome = karyo[rand.nextInt(karyo.length)];
|
||||
final IAllele allele;
|
||||
try {
|
||||
allele = rand.nextBoolean() ? individual.getGenome().getActiveAllele(chromosome)
|
||||
: individual.getGenome().getInactiveAllele(chromosome);
|
||||
} catch (NullPointerException npe) {
|
||||
// just return and eat the power without eating the rest of it
|
||||
LOG.warn(
|
||||
"NPE occurred on unknown gene: name: " + chromosome.getName()
|
||||
+ " | ordinal: "
|
||||
+ chromosome.ordinal()
|
||||
+ " | is null? "
|
||||
+ (individual.getGenome().getChromosomes()[chromosome.ordinal()] == null ? "true"
|
||||
: "false"));
|
||||
|
||||
final IChromosome[] chromosomes = individual.getGenome().getChromosomes();
|
||||
if (Arrays.stream(chromosomes).allMatch(Objects::isNull)) {
|
||||
return;
|
||||
}
|
||||
|
||||
IChromosomeType chromosome;
|
||||
do {
|
||||
chromosome = karyo[rand.nextInt(karyo.length)];
|
||||
} while (chromosomes[chromosome.ordinal()] == null);
|
||||
|
||||
final IAllele allele = rand.nextBoolean() ? individual.getGenome().getActiveAllele(chromosome)
|
||||
: individual.getGenome().getInactiveAllele(chromosome);
|
||||
final Gene gene = new Gene(allele, chromosome, root);
|
||||
|
||||
ItemStack serum = ItemSequence.create(gene);
|
||||
|
||||
Reference in new issue
Block a user