From 0e3fec76ceccef153d059c2d8ec8a98de53760b4 Mon Sep 17 00:00:00 2001 From: Flanks255 <32142731+Flanks255@users.noreply.github.com> Date: Mon, 4 Mar 2024 13:17:03 -0600 Subject: [PATCH] Small filter tweak before 1.20.4 --- .../mod/tile/FilterSettings.java | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/FilterSettings.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/FilterSettings.java index 68580d557..0caac315d 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/FilterSettings.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/FilterSettings.java @@ -35,13 +35,21 @@ public class FilterSettings { } public FilterSettings(int slots, boolean defaultWhitelist, boolean defaultRespectNBT, boolean defaultRespectMod) { - this.filterInventory = new ItemStackHandlerAA(slots); + this.filterInventory = new ItemStackHandlerAA(slots) { + @Override + protected void onContentsChanged(int slot) { + super.onContentsChanged(slot); + FilterSettings.this.onContentsChanged(); + } + }; this.isWhitelist = defaultWhitelist; this.respectNBT = defaultRespectNBT; this.respectMod = defaultRespectMod; } + public void onContentsChanged() {} + public static boolean check(ItemStack stack, ItemStackHandlerAA filter, boolean whitelist, boolean nbt, boolean mod) { if (!stack.isEmpty()) { for (int i = 0; i < filter.getSlots(); i++) { @@ -77,11 +85,7 @@ public class FilterSettings { return false; } - boolean nbtFine = !nbt || ItemStack.isSameItemSameTags(first, second); - if (nbtFine) { - return true; - } - return false; + return !nbt || ItemStack.isSameItemSameTags(first, second); } public void writeToNBT(CompoundTag tag, String name) { @@ -89,7 +93,7 @@ public class FilterSettings { compound.putBoolean("Whitelist", this.isWhitelist); compound.putBoolean("NBT", this.respectNBT); compound.putBoolean("Mod", this.respectMod); - TileEntityInventoryBase.saveSlots(this.filterInventory, compound); + compound.put("Items", filterInventory.serializeNBT()); tag.put(name, compound); } @@ -98,7 +102,7 @@ public class FilterSettings { this.isWhitelist = compound.getBoolean("Whitelist"); this.respectNBT = compound.getBoolean("NBT"); this.respectMod = compound.getBoolean("Mod"); - TileEntityInventoryBase.loadSlots(this.filterInventory, compound); + this.filterInventory.deserializeNBT(compound.getCompound("Items")); } public boolean needsUpdateSend() {