diff --git a/src/main/java/de/ellpeck/prettypipes/compat/jei/CraftingModuleTransferHandler.java b/src/main/java/de/ellpeck/prettypipes/compat/jei/CraftingModuleTransferHandler.java index 7cde3cf..4ee3cca 100644 --- a/src/main/java/de/ellpeck/prettypipes/compat/jei/CraftingModuleTransferHandler.java +++ b/src/main/java/de/ellpeck/prettypipes/compat/jei/CraftingModuleTransferHandler.java @@ -42,14 +42,11 @@ public class CraftingModuleTransferHandler implements IUniversalRecipeTransferHa continue; var remain = allIngredients.getFirst().copy(); var toAdd = entry.getRole() == RecipeIngredientRole.INPUT ? inputs : outputs; - for (var stack : toAdd) { - if (ItemEquality.compareItems(stack, remain)) { - var fits = Math.min(stack.getMaxStackSize() - stack.getCount(), remain.getCount()); - stack.grow(fits); - remain.shrink(fits); - if (remain.isEmpty()) - break; - } + var lastAdded = toAdd.isEmpty() ? ItemStack.EMPTY : toAdd.getLast(); + if (ItemEquality.compareItems(lastAdded, remain)) { + var fits = Math.min(lastAdded.getMaxStackSize() - lastAdded.getCount(), remain.getCount()); + lastAdded.grow(fits); + remain.shrink(fits); } if (!remain.isEmpty()) toAdd.add(remain); diff --git a/src/main/java/de/ellpeck/prettypipes/packets/PacketCraftingModuleTransfer.java b/src/main/java/de/ellpeck/prettypipes/packets/PacketCraftingModuleTransfer.java index c76fc2f..d3a958e 100644 --- a/src/main/java/de/ellpeck/prettypipes/packets/PacketCraftingModuleTransfer.java +++ b/src/main/java/de/ellpeck/prettypipes/packets/PacketCraftingModuleTransfer.java @@ -40,9 +40,7 @@ public record PacketCraftingModuleTransfer(List inputs, List contents) { for (var i = 0; i < container.getSlots(); i++) - container.setStackInSlot(i, ItemStack.EMPTY); - for (var stack : contents) - ItemHandlerHelper.insertItem(container, stack, false); + container.setStackInSlot(i, i < contents.size() ? contents.get(i) : ItemStack.EMPTY); } } diff --git a/src/main/java/de/ellpeck/prettypipes/packets/PacketGhostSlot.java b/src/main/java/de/ellpeck/prettypipes/packets/PacketGhostSlot.java index ef6b381..a9e51ba 100644 --- a/src/main/java/de/ellpeck/prettypipes/packets/PacketGhostSlot.java +++ b/src/main/java/de/ellpeck/prettypipes/packets/PacketGhostSlot.java @@ -44,6 +44,7 @@ public record PacketGhostSlot(BlockPos pos, List stacks) implements Custo tile.setGhostItems(message.stacks); } + // TODO the crafting module should probably also use a system like this to allow recipes that have multiple options & to also pick the items we have most of (like the terminal does in setGhostItems) public record Entry(Optional> stacks, Optional> tag) { public static final StreamCodec CODEC = StreamCodec.composite(