From 805393ba6e0c5970414b52a23c04c730894bc861 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Thu, 28 Nov 2024 00:05:16 +0100 Subject: [PATCH] small refactor --- .../pipe/modules/craft/CraftingModuleItem.java | 11 +++++++++++ .../terminal/ItemTerminalBlockEntity.java | 15 ++------------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/main/java/de/ellpeck/prettypipes/pipe/modules/craft/CraftingModuleItem.java b/src/main/java/de/ellpeck/prettypipes/pipe/modules/craft/CraftingModuleItem.java index ac1daed..9697c0f 100644 --- a/src/main/java/de/ellpeck/prettypipes/pipe/modules/craft/CraftingModuleItem.java +++ b/src/main/java/de/ellpeck/prettypipes/pipe/modules/craft/CraftingModuleItem.java @@ -328,6 +328,17 @@ public class CraftingModuleItem extends ModuleItem { return ItemStack.EMPTY; } + public boolean markCanceledOrResolve(PipeNetwork network) { + if (this.inProgress) { + this.canceled = true; + return false; + } else { + for (var lock : this.ingredientsToRequest) + network.resolveNetworkLock(lock); + return true; + } + } + } } diff --git a/src/main/java/de/ellpeck/prettypipes/terminal/ItemTerminalBlockEntity.java b/src/main/java/de/ellpeck/prettypipes/terminal/ItemTerminalBlockEntity.java index 6c20dd0..cb9bba4 100644 --- a/src/main/java/de/ellpeck/prettypipes/terminal/ItemTerminalBlockEntity.java +++ b/src/main/java/de/ellpeck/prettypipes/terminal/ItemTerminalBlockEntity.java @@ -216,19 +216,8 @@ public class ItemTerminalBlockEntity extends BlockEntity implements IPipeConnect return; for (var craftable : network.getAllCraftables(pipe.getBlockPos())) { var otherPipe = network.getPipe(craftable.getLeft()); - if (otherPipe != null) { - otherPipe.activeCrafts.removeIf(c -> { - var data = c.getRight(); - if (data.inProgress) { - data.canceled = true; - return false; - } else { - for (var lock : data.ingredientsToRequest) - network.resolveNetworkLock(lock); - return true; - } - }); - } + if (otherPipe != null) + otherPipe.activeCrafts.removeIf(c -> c.getRight().markCanceledOrResolve(network)); } var lookingPlayers = this.getLookingPlayers(); if (lookingPlayers.length > 0)