Small filter tweak before 1.20.4

This commit is contained in:
Flanks255 2024-03-04 13:17:03 -06:00
parent 8236527fb7
commit 0e3fec76ce

View file

@ -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() {