Fix crafting task issues

This commit is contained in:
Raoul Van den Berge
2016-05-21 13:37:27 +02:00
parent d1cd0c176c
commit 5ababd6946
2 changed files with 6 additions and 18 deletions

View File

@@ -85,7 +85,7 @@ public class TileController extends TileBase implements IEnergyReceiver, ISynchr
private List<ClientSideMachine> clientSideMachines = new ArrayList<ClientSideMachine>(); private List<ClientSideMachine> clientSideMachines = new ArrayList<ClientSideMachine>();
private List<CraftingPattern> patterns = new ArrayList<CraftingPattern>(); private List<CraftingPattern> patterns = new ArrayList<CraftingPattern>();
private List<ICraftingTask> craftingTasks = new ArrayList<ICraftingTask>(); private Stack<ICraftingTask> craftingTasks = new Stack<ICraftingTask>();
private List<ICraftingTask> craftingTasksToAdd = new ArrayList<ICraftingTask>(); private List<ICraftingTask> craftingTasksToAdd = new ArrayList<ICraftingTask>();
private List<ICraftingTask> craftingTasksToCancel = new ArrayList<ICraftingTask>(); private List<ICraftingTask> craftingTasksToCancel = new ArrayList<ICraftingTask>();
@@ -143,15 +143,12 @@ public class TileController extends TileBase implements IEnergyReceiver, ISynchr
craftingTasks.addAll(craftingTasksToAdd); craftingTasks.addAll(craftingTasksToAdd);
craftingTasksToAdd.clear(); craftingTasksToAdd.clear();
Iterator<ICraftingTask> craftingTaskIterator = craftingTasks.iterator(); if (!craftingTasks.empty()) {
ICraftingTask top = craftingTasks.peek();
if (ticks % top.getPattern().getCrafter(worldObj).getSpeed() == 0 && top.update(this)) {
top.onDone(this);
while (craftingTaskIterator.hasNext()) { craftingTasks.pop();
ICraftingTask task = craftingTaskIterator.next();
if (ticks % task.getPattern().getCrafter(worldObj).getSpeed() == 0 && task.update(this)) {
task.onDone(this);
craftingTaskIterator.remove();
} }
} }
} else { } else {

View File

@@ -67,15 +67,6 @@ public class BasicCraftingTask implements ICraftingTask {
itemsTook.add(took); itemsTook.add(took);
satisfied[i] = true; satisfied[i] = true;
// This is needed because if we request 2 chests for example
// it will schedule 2 child tasks for wood the child tasks will then give 8 wood
// but the first chest task will take all the 8 wood for completion
// and then you end up with the second task not having anything anymore
// and is stuck because the child task is already created.
if (childTasks[i]) {
break;
}
} else if (!childTasks[i]) { } else if (!childTasks[i]) {
CraftingPattern pattern = controller.getPattern(input); CraftingPattern pattern = controller.getPattern(input);