Fixed crafting task stalling when there's not enough space in the inventory. Fixes #2051
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
- Fixed CraftingTweaks buttons resetting sometimes in the Crafting Grid (raoulvdberge)
|
||||
- Fixed Refined Storage jars not being signed (raoulvdberge)
|
||||
- Fixed client stalling when trying to search with # for tooltips (raoulvdberge)
|
||||
- Fixed crafting task stalling when there's not enough space in the inventory (raoulvdberge)
|
||||
- Removed getMissingItems() and getMissingFluids() functions from the OpenComputers integration, that info is now accessible through schedule(Fluid)Task(). If you just want to check if there are missing items/fluids but don't want to start an actual task, use the "canSchedule" parameter (raoulvdberge)
|
||||
- Updated Russian translation (kellixon)
|
||||
- Added fluid functions for the fluid autocrafting to the OpenComputers integration (raoulvdberge)
|
||||
|
@@ -719,7 +719,10 @@ public class CraftingTask implements ICraftingTask {
|
||||
}
|
||||
|
||||
if (p.getState() == ProcessingState.READY && hasAll) {
|
||||
boolean abort = false;
|
||||
boolean insertedAll = true;
|
||||
|
||||
List<ItemStack> put = new ArrayList<>();
|
||||
List<FluidStack> putFluids = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < p.getItemsToPut().size(); ++i) {
|
||||
ItemStack need = p.getItemsToPut().get(i);
|
||||
@@ -731,22 +734,16 @@ public class CraftingTask implements ICraftingTask {
|
||||
|
||||
ItemStack remainder = ItemHandlerHelper.insertItem(p.getPattern().getContainer().getConnectedInventory(), result, false);
|
||||
if (!remainder.isEmpty()) {
|
||||
LOGGER.warn("In a simulation, " + p.getPattern().getContainer().getConnectedInventory() + " reported that we could insert " + result + " but we got " + remainder + " as a remainder");
|
||||
|
||||
this.internalStorage.insert(remainder, remainder.getCount(), Action.PERFORM);
|
||||
|
||||
p.getItemsToPut().set(i, remainder);
|
||||
|
||||
abort = true;
|
||||
|
||||
break;
|
||||
insertedAll = false;
|
||||
} else {
|
||||
put.add(need);
|
||||
}
|
||||
}
|
||||
|
||||
if (abort) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (int i = 0; i < p.getFluidsToPut().size(); ++i) {
|
||||
FluidStack need = p.getFluidsToPut().get(i);
|
||||
|
||||
@@ -757,25 +754,24 @@ public class CraftingTask implements ICraftingTask {
|
||||
|
||||
int filled = p.getPattern().getContainer().getConnectedFluidInventory().fill(result, true);
|
||||
if (filled != result.amount) {
|
||||
LOGGER.warn("In a simulation, " + p.getPattern().getContainer().getConnectedFluidInventory() + " reported that we could fill " + result + " but we only filled " + filled);
|
||||
|
||||
this.internalFluidStorage.insert(result, result.amount - filled, Action.PERFORM);
|
||||
|
||||
p.getFluidsToPut().set(i, StackUtils.copy(result, result.amount - filled));
|
||||
|
||||
abort = true;
|
||||
|
||||
break;
|
||||
insertedAll = false;
|
||||
} else {
|
||||
putFluids.add(need);
|
||||
}
|
||||
}
|
||||
|
||||
if (abort) {
|
||||
continue;
|
||||
put.forEach(p::markItemAsPut);
|
||||
putFluids.forEach(p::markFluidAsPut);
|
||||
|
||||
if (insertedAll) {
|
||||
p.setState(ProcessingState.EXTRACTED_ALL);
|
||||
|
||||
p.getPattern().getContainer().onUsedForProcessing();
|
||||
}
|
||||
|
||||
p.setState(ProcessingState.EXTRACTED_ALL);
|
||||
|
||||
p.getPattern().getContainer().onUsedForProcessing();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1024,10 +1020,10 @@ public class CraftingTask implements ICraftingTask {
|
||||
}
|
||||
|
||||
if (processing.getState() == ProcessingState.EXTRACTED_ALL) {
|
||||
for (ItemStack put : processing.getItemsToPut()) {
|
||||
for (ItemStack put : processing.getItemsPut()) {
|
||||
elements.add(new CraftingMonitorElementItemRender(put, 0, 0, put.getCount(), 0, 0));
|
||||
}
|
||||
} else if (processing.getState() == ProcessingState.READY || processing.getState() == ProcessingState.MACHINE_DOES_NOT_ACCEPT || processing.getState() == ProcessingState.MACHINE_NONE || processing.getState() == ProcessingState.LOCKED) {
|
||||
} else {
|
||||
for (ItemStack receive : processing.getItemsToReceive().getStacks()) {
|
||||
ICraftingMonitorElement element = new CraftingMonitorElementItemRender(receive, 0, 0, 0, receive.getCount(), 0);
|
||||
|
||||
@@ -1060,10 +1056,10 @@ public class CraftingTask implements ICraftingTask {
|
||||
}
|
||||
|
||||
if (processing.getState() == ProcessingState.EXTRACTED_ALL) {
|
||||
for (FluidStack put : processing.getFluidsToPut()) {
|
||||
for (FluidStack put : processing.getFluidsPut()) {
|
||||
elements.add(new CraftingMonitorElementFluidRender(put, 0, 0, put.amount, 0, 0));
|
||||
}
|
||||
} else if (processing.getState() == ProcessingState.READY || processing.getState() == ProcessingState.MACHINE_DOES_NOT_ACCEPT || processing.getState() == ProcessingState.MACHINE_NONE) {
|
||||
} else {
|
||||
for (FluidStack receive : processing.getFluidsToReceive().getStacks()) {
|
||||
ICraftingMonitorElement element = new CraftingMonitorElementFluidRender(receive, 0, 0, 0, receive.amount, 0);
|
||||
|
||||
@@ -1071,6 +1067,8 @@ public class CraftingTask implements ICraftingTask {
|
||||
element = new CraftingMonitorElementError(element, "gui.refinedstorage:crafting_monitor.machine_does_not_accept_fluid");
|
||||
} else if (processing.getState() == ProcessingState.MACHINE_NONE) {
|
||||
element = new CraftingMonitorElementError(element, "gui.refinedstorage:crafting_monitor.machine_none");
|
||||
} else if (processing.getState() == ProcessingState.LOCKED) {
|
||||
element = new CraftingMonitorElementError(element, "gui.refinedstorage:crafting_monitor.crafter_is_locked");
|
||||
}
|
||||
|
||||
elements.add(element);
|
||||
|
@@ -20,6 +20,8 @@ class Processing {
|
||||
private static final String NBT_FLUIDS_TO_RECEIVE = "FluidsToReceive";
|
||||
private static final String NBT_ITEMS_TO_PUT = "ItemsToPut";
|
||||
private static final String NBT_FLUIDS_TO_PUT = "FluidsToPut";
|
||||
private static final String NBT_ITEMS_PUT = "ItemsPut";
|
||||
private static final String NBT_FLUIDS_PUT = "FluidsPut";
|
||||
private static final String NBT_STATE = "State";
|
||||
private static final String NBT_ROOT = "Root";
|
||||
|
||||
@@ -28,6 +30,8 @@ class Processing {
|
||||
private IStackList<FluidStack> fluidsToReceive;
|
||||
private ArrayList<ItemStack> itemsToPut;
|
||||
private ArrayList<FluidStack> fluidsToPut;
|
||||
private ArrayList<ItemStack> itemsPut = new ArrayList<>();
|
||||
private ArrayList<FluidStack> fluidsPut = new ArrayList<>();
|
||||
private ProcessingState state = ProcessingState.READY;
|
||||
private boolean root;
|
||||
|
||||
@@ -59,6 +63,17 @@ class Processing {
|
||||
itemsToPut.add(stack);
|
||||
}
|
||||
|
||||
NBTTagList itemsPutList = tag.getTagList(NBT_ITEMS_PUT, Constants.NBT.TAG_COMPOUND);
|
||||
for (int i = 0; i < itemsPutList.tagCount(); ++i) {
|
||||
ItemStack stack = StackUtils.deserializeStackFromNbt(itemsPutList.getCompoundTagAt(i));
|
||||
|
||||
if (stack.isEmpty()) {
|
||||
throw new CraftingTaskReadException("Stack is empty!");
|
||||
}
|
||||
|
||||
itemsPut.add(stack);
|
||||
}
|
||||
|
||||
this.fluidsToPut = new ArrayList<>();
|
||||
|
||||
NBTTagList fluidsToPutList = tag.getTagList(NBT_FLUIDS_TO_PUT, Constants.NBT.TAG_COMPOUND);
|
||||
@@ -72,6 +87,17 @@ class Processing {
|
||||
fluidsToPut.add(stack);
|
||||
}
|
||||
|
||||
NBTTagList fluidsPutList = tag.getTagList(NBT_FLUIDS_PUT, Constants.NBT.TAG_COMPOUND);
|
||||
for (int i = 0; i < fluidsPutList.tagCount(); ++i) {
|
||||
FluidStack stack = FluidStack.loadFluidStackFromNBT(fluidsPutList.getCompoundTagAt(i));
|
||||
|
||||
if (stack == null) {
|
||||
throw new CraftingTaskReadException("Stack is empty!");
|
||||
}
|
||||
|
||||
fluidsPut.add(stack);
|
||||
}
|
||||
|
||||
this.state = ProcessingState.values()[tag.getInteger(NBT_STATE)];
|
||||
}
|
||||
|
||||
@@ -95,10 +121,28 @@ class Processing {
|
||||
return fluidsToPut;
|
||||
}
|
||||
|
||||
public ArrayList<ItemStack> getItemsPut() {
|
||||
return itemsPut;
|
||||
}
|
||||
|
||||
public ArrayList<FluidStack> getFluidsPut() {
|
||||
return fluidsPut;
|
||||
}
|
||||
|
||||
public void setState(ProcessingState state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public void markItemAsPut(ItemStack stack) {
|
||||
itemsToPut.remove(stack);
|
||||
itemsPut.add(stack);
|
||||
}
|
||||
|
||||
public void markFluidAsPut(FluidStack stack) {
|
||||
fluidsToPut.remove(stack);
|
||||
fluidsPut.add(stack);
|
||||
}
|
||||
|
||||
public ProcessingState getState() {
|
||||
return state;
|
||||
}
|
||||
@@ -119,16 +163,26 @@ class Processing {
|
||||
for (ItemStack stack : this.itemsToPut) {
|
||||
itemsToPutList.appendTag(StackUtils.serializeStackToNbt(stack));
|
||||
}
|
||||
|
||||
tag.setTag(NBT_ITEMS_TO_PUT, itemsToPutList);
|
||||
|
||||
NBTTagList itemsPutList = new NBTTagList();
|
||||
for (ItemStack stack : this.itemsPut) {
|
||||
itemsPutList.appendTag(StackUtils.serializeStackToNbt(stack));
|
||||
}
|
||||
tag.setTag(NBT_ITEMS_PUT, itemsPutList);
|
||||
|
||||
NBTTagList fluidsToPutList = new NBTTagList();
|
||||
for (FluidStack stack : this.fluidsToPut) {
|
||||
fluidsToPutList.appendTag(stack.writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
|
||||
tag.setTag(NBT_FLUIDS_TO_PUT, fluidsToPutList);
|
||||
|
||||
NBTTagList fluidsPutList = new NBTTagList();
|
||||
for (FluidStack stack : this.fluidsPut) {
|
||||
fluidsPutList.appendTag(stack.writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
tag.setTag(NBT_FLUIDS_PUT, fluidsPutList);
|
||||
|
||||
tag.setInteger(NBT_STATE, state.ordinal());
|
||||
|
||||
return tag;
|
||||
|
Reference in New Issue
Block a user