diff --git a/src/main/java/owmii/powah/lib/logistics/inventory/ItemStackHandler.java b/src/main/java/owmii/powah/lib/logistics/inventory/ItemStackHandler.java index 2158fa4..f0df002 100644 --- a/src/main/java/owmii/powah/lib/logistics/inventory/ItemStackHandler.java +++ b/src/main/java/owmii/powah/lib/logistics/inventory/ItemStackHandler.java @@ -78,7 +78,8 @@ public ItemStack insertItem(int slot, @NotNull ItemStack stack, boolean simulate if (!simulate) { if (existing.isEmpty()) { - this.stacks.set(slot, reachedLimit ? ItemStackHandlerHelper.copyStackWithSize(stack, limit) : stack); + // We must always copy the stack because onContentsChanged might change it, messing with our later use. + this.stacks.set(slot, reachedLimit ? ItemStackHandlerHelper.copyStackWithSize(stack, limit) : stack.copy()); } else { existing.grow(reachedLimit ? limit : stack.getCount()); }