diff --git a/src/main/java/hellfirepvp/modularmachinery/common/util/ItemUtils.java b/src/main/java/hellfirepvp/modularmachinery/common/util/ItemUtils.java index 3a80b884..28dbb02b 100644 --- a/src/main/java/hellfirepvp/modularmachinery/common/util/ItemUtils.java +++ b/src/main/java/hellfirepvp/modularmachinery/common/util/ItemUtils.java @@ -273,7 +273,8 @@ public static int insertAll(@Nonnull ItemStack stack, IItemHandlerModifiable han int inserted = 0; for (int i = 0; i < handler.getSlots(); i++) { - int maxStackSize = handler.getSlotLimit(i); + // 避免不可堆叠物品被叠加 + int maxStackSize = Math.min(handler.getSlotLimit(i), stack.getMaxStackSize()); ItemStack in = handler.getStackInSlot(i); int count = in.getCount(); if (count >= maxStackSize) { @@ -285,7 +286,8 @@ public static int insertAll(@Nonnull ItemStack stack, IItemHandlerModifiable han handler.setStackInSlot(i, copyStackWithSize(stack, toInsert)); inserted += toInsert; } else { - if (stackEqualsNonNBT(stack, in) && matchTags(stack, in)) { + // 不允许对不可堆叠物品进行合并 + if (stack.isStackable() && stackEqualsNonNBT(stack, in) && matchTags(stack, in)) { int toInsert = Math.min(maxInsert - inserted, maxStackSize - count); handler.setStackInSlot(i, copyStackWithSize(stack, toInsert + count)); inserted += toInsert;