Add Splicer JEI recipes, improve Inoculator JEI recipes

This commit is contained in:
mezz committed 2017-01-19 19:34:31 -08:00
1 parent a990ce3dc9
commit 3530a0e9df
11 files changed
+174 -38

No files matched your search

@@ -1,7 +1,7 @@
package binnie.genetics.machine.splicer;
import binnie.core.machines.Machine;
import binnie.core.machines.power.ComponentProcessSetCost;
import binnie.core.machines.power.ComponentProcess;
import binnie.core.machines.power.ErrorState;
import binnie.core.machines.power.IProcess;
import binnie.genetics.Genetics;
@@ -14,38 +14,58 @@ import forestry.api.genetics.IIndividual;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
public class SplicerLogic extends ComponentProcessSetCost implements IProcess {
int nOfGenes;
import javax.annotation.Nullable;
@Override
public int getProcessLength() {
float n = this.getNumberOfGenes();
public class SplicerLogic extends ComponentProcess implements IProcess {
public static int PROCESS_ENERGY = 12000000;
public static int PROCESS_LENGTH = 1200;
public static int getProcessLength(int numberOfGenes) {
float n = numberOfGenes;
if (n > 1.0f) {
n = 1.0f + (n - 1.0f) * 0.5f;
}
// Fix for / by 0
int temp = (int) (super.getProcessLength() * n);
int temp = (int) (PROCESS_LENGTH * n);
return temp != 0 ? temp : 1;
}
public static int getProcessEnergy(int numberOfGenes) {
float n = numberOfGenes;
if (n > 1.0f) {
n = 1.0f + (n - 1.0f) * 0.5f;
}
return (int) (PROCESS_ENERGY * n);
}
private int nOfGenes;
public SplicerLogic(final Machine machine) {
super(machine);
this.nOfGenes = 0;
}
@Override
public int getProcessLength() {
int n = this.getNumberOfGenes();
return getProcessLength(n);
}
@Override
public int getProcessEnergy() {
float n = this.getNumberOfGenes();
if (n > 1.0f) {
n = 1.0f + (n - 1.0f) * 0.5f;
}
return (int) (super.getProcessEnergy() * n);
int n = this.getNumberOfGenes();
return getProcessEnergy(n);
}
@Override
public void onInventoryUpdate() {
super.onInventoryUpdate();
this.nOfGenes = this.getGenesToUse();
}
protected int getGenesToUse() {
final ItemStack serum = this.getUtil().getStack(0);
final ItemStack target = this.getUtil().getStack(9);
this.nOfGenes = getGenesToUse(serum, target);
}
public static int getGenesToUse(@Nullable ItemStack serum, @Nullable ItemStack target) {
if (serum == null || target == null) {
return 1;
}
@@ -82,11 +102,6 @@ public class SplicerLogic extends ComponentProcessSetCost implements IProcess {
return "Splicing in " + n + ((f > 1) ? ("/" + f) : "") + " gene" + ((n > 1) ? "s" : "");
}
public SplicerLogic(final Machine machine) {
super(machine, 12000000, 1200);
this.nOfGenes = 0;
}
@Override
public ErrorState canWork() {
if (this.getUtil().isSlotEmpty(Splicer.SLOT_TARGET)) {
@@ -147,9 +162,8 @@ public class SplicerLogic extends ComponentProcessSetCost implements IProcess {
ind.writeToNBT(nbttagcompound);
target.setTagCompound(nbttagcompound);
}
final IGene[] arr$;
final IGene[] genes = arr$ = ((IItemSerum) serum.getItem()).getGenes(serum);
for (final IGene gene : arr$) {
final IGene[] genes = ((IItemSerum) serum.getItem()).getGenes(serum);
for (final IGene gene : genes) {
Splicer.setGene(gene, target, 0);
Splicer.setGene(gene, target, 1);
}