mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-26 08:48:34 +01:00
Small filter tweak
This commit is contained in:
parent
63fbbb334e
commit
00418d267f
1 changed files with 12 additions and 8 deletions
|
@ -35,13 +35,21 @@ public class FilterSettings {
|
||||||
}
|
}
|
||||||
|
|
||||||
public FilterSettings(int slots, boolean defaultWhitelist, boolean defaultRespectNBT, boolean defaultRespectMod) {
|
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.isWhitelist = defaultWhitelist;
|
||||||
this.respectNBT = defaultRespectNBT;
|
this.respectNBT = defaultRespectNBT;
|
||||||
this.respectMod = defaultRespectMod;
|
this.respectMod = defaultRespectMod;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onContentsChanged() {}
|
||||||
|
|
||||||
public static boolean check(ItemStack stack, ItemStackHandlerAA filter, boolean whitelist, boolean nbt, boolean mod) {
|
public static boolean check(ItemStack stack, ItemStackHandlerAA filter, boolean whitelist, boolean nbt, boolean mod) {
|
||||||
if (!stack.isEmpty()) {
|
if (!stack.isEmpty()) {
|
||||||
for (int i = 0; i < filter.getSlots(); i++) {
|
for (int i = 0; i < filter.getSlots(); i++) {
|
||||||
|
@ -77,11 +85,7 @@ public class FilterSettings {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean nbtFine = !nbt || ItemStack.isSameItemSameTags(first, second);
|
return !nbt || ItemStack.isSameItemSameTags(first, second);
|
||||||
if (nbtFine) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeToNBT(CompoundTag tag, String name) {
|
public void writeToNBT(CompoundTag tag, String name) {
|
||||||
|
@ -89,7 +93,7 @@ public class FilterSettings {
|
||||||
compound.putBoolean("Whitelist", this.isWhitelist);
|
compound.putBoolean("Whitelist", this.isWhitelist);
|
||||||
compound.putBoolean("NBT", this.respectNBT);
|
compound.putBoolean("NBT", this.respectNBT);
|
||||||
compound.putBoolean("Mod", this.respectMod);
|
compound.putBoolean("Mod", this.respectMod);
|
||||||
TileEntityInventoryBase.saveSlots(this.filterInventory, compound);
|
compound.put("Items", filterInventory.serializeNBT());
|
||||||
tag.put(name, compound);
|
tag.put(name, compound);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,7 +102,7 @@ public class FilterSettings {
|
||||||
this.isWhitelist = compound.getBoolean("Whitelist");
|
this.isWhitelist = compound.getBoolean("Whitelist");
|
||||||
this.respectNBT = compound.getBoolean("NBT");
|
this.respectNBT = compound.getBoolean("NBT");
|
||||||
this.respectMod = compound.getBoolean("Mod");
|
this.respectMod = compound.getBoolean("Mod");
|
||||||
TileEntityInventoryBase.loadSlots(this.filterInventory, compound);
|
this.filterInventory.deserializeNBT(compound.getCompound("Items"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean needsUpdateSend() {
|
public boolean needsUpdateSend() {
|
||||||
|
|
Loading…
Reference in a new issue