Fix crafting task update being called multiple times.
This commit is contained in:
@@ -48,6 +48,8 @@ public class CraftingTask implements ICraftingTask {
|
|||||||
IStackList<ItemStack> results = API.instance().createItemStackList();
|
IStackList<ItemStack> results = API.instance().createItemStackList();
|
||||||
IStackList<ItemStack> storage = network.getItemStorageCache().getList().copy();
|
IStackList<ItemStack> storage = network.getItemStorageCache().getList().copy();
|
||||||
|
|
||||||
|
this.toCraft.add(requested, quantity);
|
||||||
|
|
||||||
while (qty > 0) {
|
while (qty > 0) {
|
||||||
this.steps.add(calculateInternal(storage, results, pattern));
|
this.steps.add(calculateInternal(storage, results, pattern));
|
||||||
|
|
||||||
@@ -154,7 +156,7 @@ public class CraftingTask implements ICraftingTask {
|
|||||||
if (!step.isCompleted()) {
|
if (!step.isCompleted()) {
|
||||||
allCompleted = false;
|
allCompleted = false;
|
||||||
|
|
||||||
if (step.canExecute() && step.execute() && ticks % getTickInterval(step.getPattern().getContainer().getSpeedUpgradeCount()) == 0) { // TODO: speed upgrades handling
|
if (ticks % getTickInterval(step.getPattern().getContainer().getSpeedUpgradeCount()) == 0 && step.canExecute() && step.execute()) {
|
||||||
step.setCompleted();
|
step.setCompleted();
|
||||||
|
|
||||||
network.getCraftingManager().sendCraftingMonitorUpdate();
|
network.getCraftingManager().sendCraftingMonitorUpdate();
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ public class StackListItem implements IStackList<ItemStack> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void add(@Nonnull ItemStack stack, int size) {
|
public void add(@Nonnull ItemStack stack, int size) {
|
||||||
if (stack.isEmpty() || size <= 0) {
|
if (stack == null || stack.isEmpty() || size <= 0) {
|
||||||
return;
|
throw new IllegalArgumentException("Cannot accept empty stack");
|
||||||
}
|
}
|
||||||
|
|
||||||
for (ItemStack otherStack : stacks.get(stack.getItem())) {
|
for (ItemStack otherStack : stacks.get(stack.getItem())) {
|
||||||
|
|||||||
Reference in New Issue
Block a user