mirror of
https://github.com/GTNewHorizons/Binnie.git
synced 2026-11-25 06:24:26 +00:00
Add Isolator JEI recipes
This commit is contained in:
1 parent
b6191ab4b0
commit
f082500fc0
14 files changed
+258
-50
No files matched your search
@@ -1,9 +1,8 @@
|
||||
package binnie.genetics.machine.isolator;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import binnie.core.genetics.Gene;
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.core.machines.MachineUtil;
|
||||
import binnie.core.machines.inventory.IChargedSlots;
|
||||
import binnie.core.machines.power.ComponentProcessSetCost;
|
||||
import binnie.core.machines.power.ErrorState;
|
||||
@@ -13,18 +12,20 @@ import binnie.genetics.item.ItemSequence;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.IAllele;
|
||||
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;
|
||||
|
||||
public class IsolatorLogic extends ComponentProcessSetCost implements IProcess {
|
||||
float enzymePerProcess;
|
||||
float ethanolPerProcess;
|
||||
public static final float ENZYME_PER_PROCESS = 0.5f;
|
||||
public static final int ETHANOL_PER_PROCESS = 10;
|
||||
public static final float TARGET_LOSS_CHANCE = 0.05f;
|
||||
|
||||
public IsolatorLogic(final Machine machine) {
|
||||
super(machine, 192000, 4800);
|
||||
this.enzymePerProcess = 0.5f;
|
||||
this.ethanolPerProcess = 10.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -43,7 +44,7 @@ public class IsolatorLogic extends ComponentProcessSetCost implements IProcess {
|
||||
|
||||
@Override
|
||||
public ErrorState canProgress() {
|
||||
if (!this.getUtil().liquidInTank(Isolator.TANK_ETHANOL, (int) this.ethanolPerProcess)) {
|
||||
if (!this.getUtil().liquidInTank(Isolator.TANK_ETHANOL, ETHANOL_PER_PROCESS)) {
|
||||
return new ErrorState.InsufficientLiquid(Genetics.proxy.localise("machine.machine.isolator.errors.insufficient.ethanol.desc"), Isolator.TANK_ETHANOL);
|
||||
}
|
||||
if (this.getUtil().getSlotCharge(Isolator.SLOT_ENZYME) == 0.0f) {
|
||||
@@ -56,38 +57,34 @@ public class IsolatorLogic extends ComponentProcessSetCost implements IProcess {
|
||||
protected void onFinishTask() {
|
||||
super.onFinishTask();
|
||||
final Random rand = this.getMachine().getWorld().rand;
|
||||
final ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(this.getUtil().getStack(Isolator.SLOT_TARGET));
|
||||
MachineUtil util = this.getUtil();
|
||||
final ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(util.getStack(Isolator.SLOT_TARGET));
|
||||
if (root == null) {
|
||||
return;
|
||||
}
|
||||
final IIndividual individual = root.getMember(this.getUtil().getStack(Isolator.SLOT_TARGET));
|
||||
final IIndividual individual = root.getMember(util.getStack(Isolator.SLOT_TARGET));
|
||||
if (individual == null) {
|
||||
return;
|
||||
}
|
||||
IAllele allele = null;
|
||||
IChromosomeType chromosome = null;
|
||||
Gene gene = null;
|
||||
if (this.getMachine().getWorld().rand.nextFloat() < 2.0f) {
|
||||
while (gene == null) {
|
||||
try {
|
||||
chromosome = root.getKaryotype()[rand.nextInt(root.getKaryotype().length)];
|
||||
allele = (rand.nextBoolean() ? individual.getGenome().getActiveAllele(chromosome) : individual.getGenome().getInactiveAllele(chromosome));
|
||||
gene = Gene.create(allele, chromosome, root);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IChromosomeType[] karyotype = root.getKaryotype();
|
||||
IChromosomeType chromosome = karyotype[rand.nextInt(karyotype.length)];
|
||||
IGenome genome = individual.getGenome();
|
||||
IAllele allele = rand.nextBoolean() ? genome.getActiveAllele(chromosome) : genome.getInactiveAllele(chromosome);
|
||||
Gene gene = Gene.create(allele, chromosome, root);
|
||||
|
||||
final ItemStack serum = ItemSequence.create(gene);
|
||||
this.getUtil().setStack(Isolator.SLOT_RESULUT, serum);
|
||||
this.getUtil().decreaseStack(Isolator.SLOT_SEQUENCER_VIAL, 1);
|
||||
if (rand.nextFloat() < 0.05f) {
|
||||
this.getUtil().decreaseStack(Isolator.SLOT_TARGET, 1);
|
||||
util.setStack(Isolator.SLOT_RESULUT, serum);
|
||||
util.decreaseStack(Isolator.SLOT_SEQUENCER_VIAL, 1);
|
||||
if (rand.nextFloat() < TARGET_LOSS_CHANCE) {
|
||||
util.decreaseStack(Isolator.SLOT_TARGET, 1);
|
||||
}
|
||||
this.getUtil().drainTank(Isolator.TANK_ETHANOL, (int) this.ethanolPerProcess);
|
||||
util.drainTank(Isolator.TANK_ETHANOL, ETHANOL_PER_PROCESS);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTickTask() {
|
||||
this.getMachine().getInterface(IChargedSlots.class).alterCharge(Isolator.SLOT_ENZYME, -this.enzymePerProcess * this.getProgressPerTick() / 100.0f);
|
||||
IChargedSlots chargedSlots = this.getMachine().getInterface(IChargedSlots.class);
|
||||
chargedSlots.alterCharge(Isolator.SLOT_ENZYME, -ENZYME_PER_PROCESS * this.getProgressPerTick() / 100.0f);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user