diff --git a/CHANGELOG.md b/CHANGELOG.md index f1a7d546c..7da13286a 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - Fixed network node scanning allowing multiple controllers in some cases (raoulvdberge) - Fixed OpenComputers integration not giving back a crafting task instance in the schedule task API (raoulvdberge) - Fixed OpenComputers integration causing log spam when getting processing patterns (raoulvdberge) +- Fixed OpenComputers voiding items with extract item API when there is no inventory space (raoulvdberge) - Fixed CraftingTweaks buttons resetting sometimes in the Crafting Grid (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) - Added fluid functions for the fluid autocrafting to the OpenComputers integration (raoulvdberge) diff --git a/src/main/java/com/raoulvdberge/refinedstorage/integration/oc/EnvironmentNetwork.java b/src/main/java/com/raoulvdberge/refinedstorage/integration/oc/EnvironmentNetwork.java index 248b2298a..5ccea8c18 100644 --- a/src/main/java/com/raoulvdberge/refinedstorage/integration/oc/EnvironmentNetwork.java +++ b/src/main/java/com/raoulvdberge/refinedstorage/integration/oc/EnvironmentNetwork.java @@ -309,18 +309,18 @@ public class EnvironmentNetwork extends AbstractManagedEnvironment { } // Simulate extracting the item and get the amount of items that can be extracted - ItemStack extractedSim = node.getNetwork().extractItem(stack, count, Action.SIMULATE); - if (extractedSim == null) { + ItemStack extracted = node.getNetwork().extractItem(stack, count, Action.SIMULATE); + if (extracted == null) { return new Object[]{null, "could not extract the specified item"}; } - int transferableAmount = extractedSim.getCount(); + int transferableAmount = extracted.getCount(); // Simulate inserting the item and see how many we were able to insert IItemHandler handler = targetEntity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing.getOpposite()); - ItemStack insertedSim = ItemHandlerHelper.insertItemStacked(handler, extractedSim, true); - if (!insertedSim.isEmpty() && insertedSim.getCount() > 0) { - transferableAmount -= insertedSim.getCount(); + ItemStack remainder = ItemHandlerHelper.insertItemStacked(handler, extracted, true); + if (!remainder.isEmpty()) { + transferableAmount -= remainder.getCount(); } // Abort early if we can not insert items @@ -329,9 +329,13 @@ public class EnvironmentNetwork extends AbstractManagedEnvironment { } // Actually do it and return how many items we've inserted - ItemStack extracted = node.getNetwork().extractItem(stack, count, Action.PERFORM); + extracted = node.getNetwork().extractItem(stack, transferableAmount, Action.PERFORM); if (extracted != null) { - ItemHandlerHelper.insertItemStacked(handler, extracted, false); + remainder = ItemHandlerHelper.insertItemStacked(handler, extracted, false); + + if (!remainder.isEmpty()) { + node.getNetwork().insertItem(remainder, remainder.getCount(), Action.PERFORM); + } } return new Object[]{transferableAmount};