mirror of
https://github.com/GTNewHorizons/Binnie.git
synced 2026-11-14 09:14:50 +00:00
Compare commits
23
Commits
master
...
2.6.10-pre
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b93d4760af | ||
|
|
73d7766b3d | ||
|
|
a52f1b0926 | ||
|
|
52e99c9b67 | ||
|
|
3154726eb8 | ||
|
|
4beab15846 | ||
|
|
7e331c0bd8 | ||
|
|
31a4e593b3 | ||
|
|
2e159f1983 | ||
|
|
7029d05c65 | ||
|
|
dde6c79f9e | ||
|
|
577a198cb6 | ||
|
|
d6f724dd23 | ||
|
|
938e33bfab | ||
|
|
6478c25ea7 | ||
|
|
2ce1328e3b | ||
|
|
03614866a4 | ||
|
|
60605d06c1 | ||
|
|
7c8d913724 | ||
|
|
718f0661df | ||
|
|
a936e2fa64 | ||
|
|
fb8edb5738 | ||
|
|
5f5dcda1a0 |
No files matched your search
@@ -9,4 +9,11 @@ public interface IProcess extends IErrorStateSource {
|
||||
boolean isInProgress();
|
||||
|
||||
ProcessInfo getInfo();
|
||||
|
||||
/***
|
||||
* Returns true if the current target got worked on at least once.
|
||||
*/
|
||||
default boolean workedOnTarget() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,10 @@ import forestry.api.genetics.IIndividual;
|
||||
|
||||
public class SplicerComponentLogic extends ComponentProcessSetCost implements IProcess {
|
||||
|
||||
// Needed to keep stack. If user takes out target slot and it gets automatically refilled, this happens in the same
|
||||
// tick
|
||||
private ItemStack workedOnStack = null;
|
||||
|
||||
public int nOfGenes;
|
||||
|
||||
public SplicerComponentLogic(Machine machine) {
|
||||
@@ -50,6 +54,11 @@ public class SplicerComponentLogic extends ComponentProcessSetCost implements IP
|
||||
public void onInventoryUpdate() {
|
||||
super.onInventoryUpdate();
|
||||
nOfGenes = getGenesToUse();
|
||||
ItemStack newTarget = getUtil().getStack(Splicer.SLOT_TARGET);
|
||||
|
||||
if (newTarget == null || !ItemStack.areItemStacksEqual(workedOnStack, newTarget)) {
|
||||
workedOnStack = null;
|
||||
}
|
||||
}
|
||||
|
||||
protected int getGenesToUse() {
|
||||
@@ -190,5 +199,31 @@ public class SplicerComponentLogic extends ComponentProcessSetCost implements IP
|
||||
Splicer.setGene(gene, target, 1);
|
||||
}
|
||||
getUtil().damageItem(Splicer.SLOT_SERUM_VIAL, 1);
|
||||
workedOnStack = getUtil().getStack(Splicer.SLOT_TARGET).copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean workedOnTarget() {
|
||||
return ItemStack.areItemStacksEqual(workedOnStack, getUtil().getStack(Splicer.SLOT_TARGET));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
super.readFromNBT(nbt);
|
||||
NBTTagCompound tagWorkedOnStack = (NBTTagCompound) nbt.getTag("workedOnStack");
|
||||
if (tagWorkedOnStack != null) {
|
||||
workedOnStack = ItemStack.loadItemStackFromNBT(tagWorkedOnStack);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
super.writeToNBT(nbt);
|
||||
if (workedOnStack != null) {
|
||||
NBTTagCompound tagWorkedOnStack = new NBTTagCompound();
|
||||
workedOnStack.writeToNBT(tagWorkedOnStack);
|
||||
// Need to save, in case inventory is full it might need to get moved out way later.
|
||||
nbt.setTag("workedOnStack", tagWorkedOnStack);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package binnie.genetics.machine.splicer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import binnie.core.craftgui.minecraft.IMachineInformation;
|
||||
import binnie.core.machines.IMachine;
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.core.machines.inventory.ComponentInventorySlots;
|
||||
import binnie.core.machines.inventory.ComponentInventoryTransfer;
|
||||
@@ -79,8 +80,20 @@ public class SplicerPackage extends AdvGeneticMachine.PackageAdvGeneticBase impl
|
||||
|
||||
@Override
|
||||
public boolean fufilled(ItemStack stack) {
|
||||
return stack != null && transfer.getMachine().getMachineUtil().getStack(Splicer.SLOT_SERUM_VIAL) != null
|
||||
&& transfer.getMachine().getInterface(SplicerComponentLogic.class).isValidSerum() != null;
|
||||
if (stack == null) {
|
||||
return false;
|
||||
}
|
||||
IMachine machine = transfer.getMachine();
|
||||
boolean hasSerum = machine.getMachineUtil().getStack(Splicer.SLOT_SERUM_VIAL) != null;
|
||||
|
||||
if (hasSerum) {
|
||||
// Move item if it can't be processed anymore with current serum.
|
||||
boolean validSerum = machine.getInterface(SplicerComponentLogic.class).isValidSerum() == null;
|
||||
return !validSerum;
|
||||
} else {
|
||||
// Move item if there is no serum and item got processed already
|
||||
return machine.getMachineUtil().getProcess().workedOnTarget();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user