From 4f240f01d86ff60e94746cbed0ef9c1fd3623072 Mon Sep 17 00:00:00 2001 From: VoidLeech Date: Sun, 15 Dec 2024 23:53:29 +0100 Subject: [PATCH] fix: enchantments getting trimmed from non-filter items --- .../logistics/filter/FilterItemStack.java | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/logistics/filter/FilterItemStack.java b/src/main/java/com/simibubi/create/content/logistics/filter/FilterItemStack.java index 8f3c38f87b..196825a7c9 100644 --- a/src/main/java/com/simibubi/create/content/logistics/filter/FilterItemStack.java +++ b/src/main/java/com/simibubi/create/content/logistics/filter/FilterItemStack.java @@ -23,14 +23,15 @@ public class FilterItemStack { public static FilterItemStack of(ItemStack filter) { if (filter.hasTag()) { - CompoundTag stackTag = filter.getTag(); - stackTag.remove("Enchantments"); - stackTag.remove("AttributeModifiers"); - if (AllItems.FILTER.isIn(filter)) + if (AllItems.FILTER.isIn(filter)){ + trimFilterTag(filter); return new ListFilterItemStack(filter); - if (AllItems.ATTRIBUTE_FILTER.isIn(filter)) + } + if (AllItems.ATTRIBUTE_FILTER.isIn(filter)){ + trimFilterTag(filter); return new AttributeFilterItemStack(filter); + } } return new FilterItemStack(filter); @@ -39,11 +40,17 @@ public static FilterItemStack of(ItemStack filter) { public static FilterItemStack of(CompoundTag tag) { return of(ItemStack.of(tag)); } - + public static FilterItemStack empty() { return of(ItemStack.EMPTY); } + private static void trimFilterTag(ItemStack filter){ + CompoundTag stackTag = filter.getTag(); + stackTag.remove("Enchantments"); + stackTag.remove("AttributeModifiers"); + } + public boolean isEmpty() { return filterItemStack.isEmpty(); } @@ -51,16 +58,16 @@ public boolean isEmpty() { public CompoundTag serializeNBT() { return filterItemStack.serializeNBT(); } - + public ItemStack item() { return filterItemStack; } - + public FluidStack fluid(Level level) { resolveFluid(level); return filterFluidStack; } - + public boolean isFilterItem() { return filterItemStack.getItem() instanceof FilterItem; } @@ -98,7 +105,7 @@ public boolean test(Level world, FluidStack stack, boolean matchNBT) { } // - + private void resolveFluid(Level world) { if (!fluidExtracted) { fluidExtracted = true;