Skip to content

Commit

Permalink
small refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Ellpeck committed Nov 27, 2024
1 parent 2c8ab9e commit 805393b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,17 @@ public ItemStack getTravelingIngredient(ItemStack stack, ItemEquality... equalit
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;
}
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -216,19 +216,8 @@ public void cancelCrafting() {
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)
Expand Down

0 comments on commit 805393b

Please sign in to comment.