Retrofit the CraftingExtractor class so it can report all errors at once. Very ugly, need to clean this up.

This commit is contained in:
raoulvdberge
2018-06-06 21:35:08 +02:00
parent ec55c29bf3
commit c139710cd7
2 changed files with 26 additions and 3 deletions

View File

@@ -107,12 +107,35 @@ public class CraftingExtractor {
status.set(i, CraftingExtractorItemStatus.MACHINE_DOES_NOT_ACCEPT);
}
if (previousStatus != status.get(i)) {
CraftingExtractorItemStatus currentStatus = status.get(i);
if (previousStatus != currentStatus) {
network.getCraftingManager().onTaskChanged();
}
return;
// We only need to extract one.
// If we didn't extract successfully, try the others.
if (currentStatus == CraftingExtractorItemStatus.EXTRACTED) {
return;
}
}
}
}
public boolean isAllInsertable(@Nullable IItemHandler handler) {
// This method is called in the canExecute of CraftingStepProcess.
// If there is no handler, we still want to start executing so
// extractOneAndInsert can report the "no machine found" error.
if (handler == null) {
return true;
}
for (ItemStack item : items) {
if (!ItemHandlerHelper.insertItem(handler, item, true).isEmpty()) {
return false;
}
}
return true;
}
}

View File

@@ -26,7 +26,7 @@ public class CraftingStepProcess extends CraftingStep {
public boolean canExecute() {
extractor.updateStatus();
return extractor.isAllAvailable();
return extractor.isAllAvailable() && extractor.isAllInsertable(pattern.getContainer().getConnectedInventory());
}
public int onTrackedItemInserted(ItemStack stack, int size) {