@@ -39,6 +39,7 @@ public class CraftingManager implements ICraftingManager {
|
||||
private List<ICraftingTask> craftingTasksToAdd = new ArrayList<>();
|
||||
private List<ICraftingTask> craftingTasksToCancel = new ArrayList<>();
|
||||
private List<NBTTagCompound> craftingTasksToRead = new ArrayList<>();
|
||||
private List<ICraftingStep> runningSteps = new ArrayList<>();
|
||||
|
||||
private int ticks;
|
||||
|
||||
@@ -190,6 +191,12 @@ public class CraftingManager implements ICraftingManager {
|
||||
}
|
||||
}
|
||||
|
||||
runningSteps = craftingTasks.stream()
|
||||
.map(ICraftingTask::getSteps)
|
||||
.flatMap(List::stream)
|
||||
.filter(ICraftingStep::hasStartedProcessing)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (craftingTasksChanged) {
|
||||
network.getNetwork().markCraftingMonitorForUpdate();
|
||||
}
|
||||
@@ -255,11 +262,9 @@ public class CraftingManager implements ICraftingManager {
|
||||
public void track(ItemStack stack, int size) {
|
||||
ItemStack inserted = ItemHandlerHelper.copyStackWithSize(stack, size);
|
||||
|
||||
for (ICraftingTask task : craftingTasks) {
|
||||
for (ICraftingStep processable : task.getSteps().stream().filter(ICraftingStep::hasStartedProcessing).collect(Collectors.toList())) {
|
||||
if (processable.onReceiveOutput(inserted)) {
|
||||
return;
|
||||
}
|
||||
for (ICraftingStep step : runningSteps) {
|
||||
if (step.onReceiveOutput(inserted)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -103,7 +103,7 @@ public abstract class CraftingStep implements ICraftingStep {
|
||||
|
||||
@Override
|
||||
public List<ICraftingStep> getPreliminarySteps() {
|
||||
return preliminarySteps;
|
||||
return preliminarySteps != null ? preliminarySteps : Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -90,6 +90,9 @@ public class CraftingStepCraft extends CraftingStep {
|
||||
toInsertItems.add(byproduct.copy());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Couldn't extract items
|
||||
startedProcessing = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -356,6 +356,21 @@ public class CraftingTask implements ICraftingTask {
|
||||
return false;
|
||||
}
|
||||
|
||||
// We need to copy the size cause we'll re-add unadded stacks to the queue
|
||||
// Do inserting on the next tick, reliefs CPU time during insertion
|
||||
// See TileController#runningSteps
|
||||
int times = toInsertItems.size();
|
||||
for (int i = 0; i < times; i++) {
|
||||
ItemStack insert = toInsertItems.poll();
|
||||
if (insert != null) {
|
||||
ItemStack remainder = network.insertItemTracked(insert, insert.getCount());
|
||||
|
||||
if (remainder != null) {
|
||||
toInsertItems.add(remainder);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Collect all leaf steps
|
||||
List<ICraftingStep> leafSteps = new LinkedList<>();
|
||||
Queue<ICraftingStep> steps = new LinkedList<>();
|
||||
@@ -391,18 +406,7 @@ public class CraftingTask implements ICraftingTask {
|
||||
}
|
||||
}
|
||||
|
||||
// We need to copy the size cause we'll re-add unadded stacks to the queue
|
||||
int times = toInsertItems.size();
|
||||
for (int i = 0; i < times; i++) {
|
||||
ItemStack insert = toInsertItems.poll();
|
||||
if (insert != null) {
|
||||
ItemStack remainder = network.insertItemTracked(insert, insert.getCount());
|
||||
|
||||
if (remainder != null) {
|
||||
toInsertItems.add(remainder);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (getSteps().stream().filter(ICraftingStep::hasStartedProcessing).count() == 0) {
|
||||
// When there is no started processes, restart the task.
|
||||
|
@@ -152,11 +152,8 @@ public class ProxyCommon {
|
||||
registerTile(TileFluidStorage.class, "fluid_storage");
|
||||
registerTile(TileDiskManipulator.class, "disk_manipulator");
|
||||
registerTile(TileSecurityManager.class, "security_manager");
|
||||
|
||||
if (READER_WRITER_ENABLED) {
|
||||
registerTile(TileReader.class, "reader");
|
||||
registerTile(TileWriter.class, "writer");
|
||||
}
|
||||
registerTile(TileReader.class, "reader");
|
||||
registerTile(TileWriter.class, "writer");
|
||||
|
||||
registerBlock(RSBlocks.CONTROLLER);
|
||||
registerBlock(RSBlocks.GRID);
|
||||
|
Reference in New Issue
Block a user