diff --git a/src/main/java/de/ellpeck/prettypipes/Utility.java b/src/main/java/de/ellpeck/prettypipes/Utility.java index de44c34..ad11f85 100644 --- a/src/main/java/de/ellpeck/prettypipes/Utility.java +++ b/src/main/java/de/ellpeck/prettypipes/Utility.java @@ -167,6 +167,18 @@ public final class Utility { return null; } + public static void copyInto(ItemStackHandler handler, ItemStackHandler dest) { + dest.setSize(handler.getSlots()); + for (var i = 0; i < handler.getSlots(); i++) + dest.setStackInSlot(i, handler.getStackInSlot(i).copy()); + } + + public static ItemStackHandler copy(ItemStackHandler handler) { + var ret = new ItemStackHandler(); + copyInto(handler, ret); + return ret; + } + public interface IMergeItemStack { boolean mergeItemStack(ItemStack stack, int startIndex, int endIndex, boolean reverseDirection); diff --git a/src/main/java/de/ellpeck/prettypipes/misc/ItemFilter.java b/src/main/java/de/ellpeck/prettypipes/misc/ItemFilter.java index 12ff723..3323c7c 100644 --- a/src/main/java/de/ellpeck/prettypipes/misc/ItemFilter.java +++ b/src/main/java/de/ellpeck/prettypipes/misc/ItemFilter.java @@ -138,9 +138,7 @@ public class ItemFilter { public void load() { var content = this.stack.get(Data.TYPE); if (content != null) { - this.content.setSize(content.items.getSlots()); - for (var i = 0; i < this.content.getSlots(); i++) - this.content.setStackInSlot(i, content.items.getStackInSlot(i)); + Utility.copyInto(content.items, this.content); this.isWhitelist = content.whitelist; } } diff --git a/src/main/java/de/ellpeck/prettypipes/pipe/modules/craft/CraftingModuleContainer.java b/src/main/java/de/ellpeck/prettypipes/pipe/modules/craft/CraftingModuleContainer.java index 369585b..5083717 100644 --- a/src/main/java/de/ellpeck/prettypipes/pipe/modules/craft/CraftingModuleContainer.java +++ b/src/main/java/de/ellpeck/prettypipes/pipe/modules/craft/CraftingModuleContainer.java @@ -1,5 +1,6 @@ package de.ellpeck.prettypipes.pipe.modules.craft; +import de.ellpeck.prettypipes.Utility; import de.ellpeck.prettypipes.misc.FilterSlot; import de.ellpeck.prettypipes.pipe.containers.AbstractPipeContainer; import net.minecraft.core.BlockPos; @@ -20,7 +21,7 @@ public class CraftingModuleContainer extends AbstractPipeContainer