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 CraftingTweaks buttons resetting sometimes in the Crafting Grid (raoulvdberge)
|
||||||
- Fixed Refined Storage jars not being signed (raoulvdberge)
|
- Fixed Refined Storage jars not being signed (raoulvdberge)
|
||||||
- Fixed client stalling when trying to search with # for tooltips (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)
|
- 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)
|
- Updated Russian translation (kellixon)
|
||||||
- Added fluid functions for the fluid autocrafting to the OpenComputers integration (raoulvdberge)
|
- 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) {
|
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) {
|
for (int i = 0; i < p.getItemsToPut().size(); ++i) {
|
||||||
ItemStack need = p.getItemsToPut().get(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);
|
ItemStack remainder = ItemHandlerHelper.insertItem(p.getPattern().getContainer().getConnectedInventory(), result, false);
|
||||||
if (!remainder.isEmpty()) {
|
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);
|
this.internalStorage.insert(remainder, remainder.getCount(), Action.PERFORM);
|
||||||
|
|
||||||
p.getItemsToPut().set(i, remainder);
|
p.getItemsToPut().set(i, remainder);
|
||||||
|
|
||||||
abort = true;
|
insertedAll = false;
|
||||||
|
} else {
|
||||||
break;
|
put.add(need);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (abort) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < p.getFluidsToPut().size(); ++i) {
|
for (int i = 0; i < p.getFluidsToPut().size(); ++i) {
|
||||||
FluidStack need = p.getFluidsToPut().get(i);
|
FluidStack need = p.getFluidsToPut().get(i);
|
||||||
|
|
||||||
@@ -757,27 +754,26 @@ public class CraftingTask implements ICraftingTask {
|
|||||||
|
|
||||||
int filled = p.getPattern().getContainer().getConnectedFluidInventory().fill(result, true);
|
int filled = p.getPattern().getContainer().getConnectedFluidInventory().fill(result, true);
|
||||||
if (filled != result.amount) {
|
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);
|
this.internalFluidStorage.insert(result, result.amount - filled, Action.PERFORM);
|
||||||
|
|
||||||
p.getFluidsToPut().set(i, StackUtils.copy(result, result.amount - filled));
|
p.getFluidsToPut().set(i, StackUtils.copy(result, result.amount - filled));
|
||||||
|
|
||||||
abort = true;
|
insertedAll = false;
|
||||||
|
} else {
|
||||||
break;
|
putFluids.add(need);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (abort) {
|
put.forEach(p::markItemAsPut);
|
||||||
continue;
|
putFluids.forEach(p::markFluidAsPut);
|
||||||
}
|
|
||||||
|
|
||||||
|
if (insertedAll) {
|
||||||
p.setState(ProcessingState.EXTRACTED_ALL);
|
p.setState(ProcessingState.EXTRACTED_ALL);
|
||||||
|
|
||||||
p.getPattern().getContainer().onUsedForProcessing();
|
p.getPattern().getContainer().onUsedForProcessing();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (originalState != p.getState()) {
|
if (originalState != p.getState()) {
|
||||||
network.getCraftingManager().onTaskChanged();
|
network.getCraftingManager().onTaskChanged();
|
||||||
@@ -1024,10 +1020,10 @@ public class CraftingTask implements ICraftingTask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (processing.getState() == ProcessingState.EXTRACTED_ALL) {
|
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));
|
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()) {
|
for (ItemStack receive : processing.getItemsToReceive().getStacks()) {
|
||||||
ICraftingMonitorElement element = new CraftingMonitorElementItemRender(receive, 0, 0, 0, receive.getCount(), 0);
|
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) {
|
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));
|
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()) {
|
for (FluidStack receive : processing.getFluidsToReceive().getStacks()) {
|
||||||
ICraftingMonitorElement element = new CraftingMonitorElementFluidRender(receive, 0, 0, 0, receive.amount, 0);
|
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");
|
element = new CraftingMonitorElementError(element, "gui.refinedstorage:crafting_monitor.machine_does_not_accept_fluid");
|
||||||
} else if (processing.getState() == ProcessingState.MACHINE_NONE) {
|
} else if (processing.getState() == ProcessingState.MACHINE_NONE) {
|
||||||
element = new CraftingMonitorElementError(element, "gui.refinedstorage:crafting_monitor.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);
|
elements.add(element);
|
||||||
|
@@ -20,6 +20,8 @@ class Processing {
|
|||||||
private static final String NBT_FLUIDS_TO_RECEIVE = "FluidsToReceive";
|
private static final String NBT_FLUIDS_TO_RECEIVE = "FluidsToReceive";
|
||||||
private static final String NBT_ITEMS_TO_PUT = "ItemsToPut";
|
private static final String NBT_ITEMS_TO_PUT = "ItemsToPut";
|
||||||
private static final String NBT_FLUIDS_TO_PUT = "FluidsToPut";
|
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_STATE = "State";
|
||||||
private static final String NBT_ROOT = "Root";
|
private static final String NBT_ROOT = "Root";
|
||||||
|
|
||||||
@@ -28,6 +30,8 @@ class Processing {
|
|||||||
private IStackList<FluidStack> fluidsToReceive;
|
private IStackList<FluidStack> fluidsToReceive;
|
||||||
private ArrayList<ItemStack> itemsToPut;
|
private ArrayList<ItemStack> itemsToPut;
|
||||||
private ArrayList<FluidStack> fluidsToPut;
|
private ArrayList<FluidStack> fluidsToPut;
|
||||||
|
private ArrayList<ItemStack> itemsPut = new ArrayList<>();
|
||||||
|
private ArrayList<FluidStack> fluidsPut = new ArrayList<>();
|
||||||
private ProcessingState state = ProcessingState.READY;
|
private ProcessingState state = ProcessingState.READY;
|
||||||
private boolean root;
|
private boolean root;
|
||||||
|
|
||||||
@@ -59,6 +63,17 @@ class Processing {
|
|||||||
itemsToPut.add(stack);
|
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<>();
|
this.fluidsToPut = new ArrayList<>();
|
||||||
|
|
||||||
NBTTagList fluidsToPutList = tag.getTagList(NBT_FLUIDS_TO_PUT, Constants.NBT.TAG_COMPOUND);
|
NBTTagList fluidsToPutList = tag.getTagList(NBT_FLUIDS_TO_PUT, Constants.NBT.TAG_COMPOUND);
|
||||||
@@ -72,6 +87,17 @@ class Processing {
|
|||||||
fluidsToPut.add(stack);
|
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)];
|
this.state = ProcessingState.values()[tag.getInteger(NBT_STATE)];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,10 +121,28 @@ class Processing {
|
|||||||
return fluidsToPut;
|
return fluidsToPut;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ArrayList<ItemStack> getItemsPut() {
|
||||||
|
return itemsPut;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<FluidStack> getFluidsPut() {
|
||||||
|
return fluidsPut;
|
||||||
|
}
|
||||||
|
|
||||||
public void setState(ProcessingState state) {
|
public void setState(ProcessingState state) {
|
||||||
this.state = 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() {
|
public ProcessingState getState() {
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
@@ -119,16 +163,26 @@ class Processing {
|
|||||||
for (ItemStack stack : this.itemsToPut) {
|
for (ItemStack stack : this.itemsToPut) {
|
||||||
itemsToPutList.appendTag(StackUtils.serializeStackToNbt(stack));
|
itemsToPutList.appendTag(StackUtils.serializeStackToNbt(stack));
|
||||||
}
|
}
|
||||||
|
|
||||||
tag.setTag(NBT_ITEMS_TO_PUT, itemsToPutList);
|
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();
|
NBTTagList fluidsToPutList = new NBTTagList();
|
||||||
for (FluidStack stack : this.fluidsToPut) {
|
for (FluidStack stack : this.fluidsToPut) {
|
||||||
fluidsToPutList.appendTag(stack.writeToNBT(new NBTTagCompound()));
|
fluidsToPutList.appendTag(stack.writeToNBT(new NBTTagCompound()));
|
||||||
}
|
}
|
||||||
|
|
||||||
tag.setTag(NBT_FLUIDS_TO_PUT, fluidsToPutList);
|
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());
|
tag.setInteger(NBT_STATE, state.ordinal());
|
||||||
|
|
||||||
return tag;
|
return tag;
|
||||||
|
Reference in New Issue
Block a user