* #19
Fix Sequencer don't reset progress after remove sequence item
Some rafactoring Sequencer class

* #19
Fixed imports
This commit is contained in:
Alexander Kornilov authored and mezz committed 2017-05-08 00:07:02 -07:00
1 parent 64259e06da
commit f6186d3cf3
3 files changed
+81 -46

No files matched your search

@@ -59,8 +59,8 @@ public class MachineUtil {
setStack(slot, null);
}
public ItemStack decreaseStack(int slotWood, int amount) {
return getInventory().decrStackSize(slotWood, amount);
public ItemStack decreaseStack(int slot, int amount) {
return getInventory().decrStackSize(slot, amount);
}
public void setStack(int slot, ItemStack stack) {
@@ -11,6 +11,7 @@ import java.util.List;
public class ComponentInventoryTransfer extends MachineComponent {
private List<Transfer> transfers = new ArrayList<>();
private ITransferRestockListener transferListener;
public ComponentInventoryTransfer(IMachine machine) {
super(machine);
@@ -43,6 +44,10 @@ public class ComponentInventoryTransfer extends MachineComponent {
transfers.add(new Storage(getMachine(), source, destination).setCondition(condition));
}
public void setTransferListener(ITransferRestockListener transferListener) {
this.transferListener = transferListener;
}
public abstract class Transfer {
protected Condition condition;
protected IMachine machine;
@@ -92,17 +97,22 @@ public class ComponentInventoryTransfer extends MachineComponent {
@Override
protected void doTransfer(IInventory inv) {
if (inv.getStackInSlot(destination) == null) {
for (int i : buffer) {
if (inv.getStackInSlot(i) == null) {
continue;
}
if (inv.getStackInSlot(destination) != null) {
return;
}
ItemStack newStack = inv.decrStackSize(i, limit);
if (newStack != null) {
inv.setInventorySlotContents(destination, newStack);
return;
for (int slot : buffer) {
if (inv.getStackInSlot(slot) == null) {
continue;
}
ItemStack newStack = inv.decrStackSize(slot, limit);
if (newStack != null) {
inv.setInventorySlotContents(destination, newStack);
if (transferListener != null) {
transferListener.onRestock(destination);
}
return;
}
}
}
@@ -141,4 +151,8 @@ public class ComponentInventoryTransfer extends MachineComponent {
public abstract boolean fufilled(ItemStack p0);
}
public interface ITransferRestockListener {
void onRestock(int target);
}
}