From bb62acf45f905e1a50b329b82605198ac896134e Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Tue, 27 Oct 2020 22:51:07 +0100 Subject: [PATCH] made the crafting terminal ghost transfer also consider craftables Closes #50 --- .../terminal/CraftingTerminalTileEntity.java | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/main/java/de/ellpeck/prettypipes/terminal/CraftingTerminalTileEntity.java b/src/main/java/de/ellpeck/prettypipes/terminal/CraftingTerminalTileEntity.java index f2f19ea..b203c91 100644 --- a/src/main/java/de/ellpeck/prettypipes/terminal/CraftingTerminalTileEntity.java +++ b/src/main/java/de/ellpeck/prettypipes/terminal/CraftingTerminalTileEntity.java @@ -75,13 +75,20 @@ public class CraftingTerminalTileEntity extends ItemTerminalTileEntity { if (items.size() > 1) { int highestAmount = 0; for (ItemStack stack : items) { - EquatableItemStack equatable = new EquatableItemStack(stack); - NetworkItem network = this.networkItems.get(equatable); - if (network == null) - continue; - int amount = network.getLocations().stream() - .mapToInt(l -> l.getItemAmount(this.world, stack, ItemEqualityType.NBT)) - .sum(); + int amount = 0; + // check existing items + NetworkItem network = this.networkItems.get(new EquatableItemStack(stack)); + if (network != null) { + amount = network.getLocations().stream() + .mapToInt(l -> l.getItemAmount(this.world, stack, ItemEqualityType.NBT)) + .sum(); + } + // check craftables + if (amount <= 0 && highestAmount <= 0) { + PipeTileEntity pipe = this.getConnectedPipe(); + if (pipe != null) + amount = PipeNetwork.get(this.world).getCraftableAmount(pipe.getPos(), null, stack, ItemEqualityType.NBT); + } if (amount > highestAmount) { highestAmount = amount; toSet = stack;