unlock crafter when cancelling task, implements #2170 (#2558)

This commit is contained in:
Darkere
2020-06-07 12:20:53 +02:00
committed by GitHub
parent 6830a1858d
commit ddd29e1419
3 changed files with 15 additions and 0 deletions

View File

@@ -114,6 +114,11 @@ public interface ICraftingPatternContainer {
return false; return false;
} }
/**
* Unlock the container so it may be used by processing pattern
*/
void unlock();
/** /**
* Called when this container is used by a processing pattern to insert items or fluids in the connected inventory. * Called when this container is used by a processing pattern to insert items or fluids in the connected inventory.
*/ */

View File

@@ -969,6 +969,11 @@ public class CraftingTask implements ICraftingTask {
@Override @Override
public void onCancelled() { public void onCancelled() {
crafts.values().forEach(c -> {
if (c instanceof Processing) {
network.getCraftingManager().getAllContainer(c.getPattern()).forEach(ICraftingPatternContainer::unlock);
}
});
for (ItemStack remainder : internalStorage.getStacks()) { for (ItemStack remainder : internalStorage.getStacks()) {
network.insertItem(remainder, remainder.getCount(), Action.PERFORM); network.insertItem(remainder, remainder.getCount(), Action.PERFORM);
} }

View File

@@ -429,6 +429,11 @@ public class CrafterNetworkNode extends NetworkNode implements ICraftingPatternC
} }
} }
@Override
public void unlock() {
locked = false;
}
@Override @Override
public void onUsedForProcessing() { public void onUsedForProcessing() {
Optional<ICraftingPatternContainer> root = getRootContainerNotSelf(); Optional<ICraftingPatternContainer> root = getRootContainerNotSelf();