mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-06 00:49:09 +01:00
Amend filter terminology to allow-deny
This commit is contained in:
parent
26758cb41b
commit
58788d9a5b
3 changed files with 25 additions and 24 deletions
|
@ -30,18 +30,18 @@ public class FilterSettingsGui {
|
|||
|
||||
private final FilterSettings theSettings;
|
||||
|
||||
public Button whitelistButton;
|
||||
public Button allowButton;
|
||||
public Button modButton;
|
||||
|
||||
public FilterSettingsGui(FilterSettings settings, int x, int y, Consumer<AbstractButton> buttonConsumer, Consumer<Integer> clickConsumer, int idOffset) {
|
||||
this.theSettings = settings;
|
||||
|
||||
this.whitelistButton = Button.builder(Component.literal("WH"), $ -> {
|
||||
theSettings.isWhitelist = !theSettings.isWhitelist;
|
||||
this.allowButton = Button.builder(Component.literal("A"), $ -> {
|
||||
theSettings.isAllowFilter = !theSettings.isAllowFilter;
|
||||
clickConsumer.accept(idOffset);
|
||||
})
|
||||
.bounds(x, y, 16, 12).build();
|
||||
buttonConsumer.accept(this.whitelistButton);
|
||||
buttonConsumer.accept(this.allowButton);
|
||||
y += 14;
|
||||
this.modButton = Button.builder(Component.literal("MO"), $ -> {
|
||||
theSettings.respectMod = !theSettings.respectMod;
|
||||
|
@ -62,9 +62,10 @@ public class FilterSettingsGui {
|
|||
}*/
|
||||
|
||||
public void tick() {
|
||||
this.whitelistButton.setMessage(Component.literal("WH").withStyle(this.theSettings.isWhitelist
|
||||
? ChatFormatting.DARK_GREEN
|
||||
: ChatFormatting.RED));
|
||||
if (this.theSettings.isAllowFilter)
|
||||
this.allowButton.setMessage(Component.literal("A").withStyle(ChatFormatting.DARK_GREEN));
|
||||
else
|
||||
this.allowButton.setMessage(Component.literal("D").withStyle(ChatFormatting.RED));
|
||||
this.modButton.setMessage(Component.literal("MO").withStyle(this.theSettings.respectMod
|
||||
? ChatFormatting.DARK_GREEN
|
||||
: ChatFormatting.RED));
|
||||
|
@ -73,11 +74,11 @@ public class FilterSettingsGui {
|
|||
public void drawHover(GuiGraphics guiGraphics, int mouseX, int mouseY) {
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
List<Component> list = new ArrayList<>();
|
||||
if (this.whitelistButton.isMouseOver(mouseX, mouseY)) {
|
||||
list.add((this.theSettings.isWhitelist
|
||||
? Component.translatable("info." + ActuallyAdditions.MODID + ".gui.whitelist")
|
||||
: Component.translatable("info." + ActuallyAdditions.MODID + ".gui.blacklist")).withStyle(ChatFormatting.BOLD));
|
||||
list.add(Component.translatable("info." + ActuallyAdditions.MODID + ".gui.whitelistInfo"));
|
||||
if (this.allowButton.isMouseOver(mouseX, mouseY)) {
|
||||
list.add((this.theSettings.isAllowFilter
|
||||
? Component.translatable("info." + ActuallyAdditions.MODID + ".gui.allow")
|
||||
: Component.translatable("info." + ActuallyAdditions.MODID + ".gui.deny")).withStyle(ChatFormatting.BOLD));
|
||||
list.add(Component.translatable("info." + ActuallyAdditions.MODID + ".gui.filterInfo"));
|
||||
} else if (this.modButton.isMouseOver(mouseX, mouseY)) {
|
||||
list.add((this.theSettings.respectMod
|
||||
? Component.translatable("info." + ActuallyAdditions.MODID + ".gui.respectMod")
|
||||
|
|
|
@ -21,7 +21,7 @@ import net.minecraft.world.item.ItemStack;
|
|||
|
||||
public class FilterSettings {
|
||||
public final ItemStackHandlerAA filterInventory;
|
||||
public boolean isWhitelist;
|
||||
public boolean isAllowFilter;
|
||||
public boolean respectMod;
|
||||
private boolean lastWhitelist;
|
||||
private boolean lastRespectMod;
|
||||
|
@ -40,7 +40,7 @@ public class FilterSettings {
|
|||
}
|
||||
};
|
||||
|
||||
this.isWhitelist = defaultWhitelist;
|
||||
this.isAllowFilter = defaultWhitelist;
|
||||
this.respectMod = defaultRespectMod;
|
||||
}
|
||||
|
||||
|
@ -82,7 +82,7 @@ public class FilterSettings {
|
|||
|
||||
public void writeToNBT(CompoundTag tag, String name) {
|
||||
CompoundTag compound = new CompoundTag();
|
||||
compound.putBoolean("Whitelist", this.isWhitelist);
|
||||
compound.putBoolean("Whitelist", this.isAllowFilter);
|
||||
compound.putBoolean("Mod", this.respectMod);
|
||||
compound.put("Items", filterInventory.serializeNBT());
|
||||
tag.put(name, compound);
|
||||
|
@ -90,30 +90,30 @@ public class FilterSettings {
|
|||
|
||||
public void readFromNBT(CompoundTag tag, String name) {
|
||||
CompoundTag compound = tag.getCompound(name);
|
||||
this.isWhitelist = compound.getBoolean("Whitelist");
|
||||
this.isAllowFilter = compound.getBoolean("Whitelist");
|
||||
this.respectMod = compound.getBoolean("Mod");
|
||||
this.filterInventory.deserializeNBT(compound.getCompound("Items"));
|
||||
}
|
||||
|
||||
public boolean needsUpdateSend() {
|
||||
return this.lastWhitelist != this.isWhitelist || this.lastRespectMod != this.respectMod;
|
||||
return this.lastWhitelist != this.isAllowFilter || this.lastRespectMod != this.respectMod;
|
||||
}
|
||||
|
||||
public void updateLasts() {
|
||||
this.lastWhitelist = this.isWhitelist;
|
||||
this.lastWhitelist = this.isAllowFilter;
|
||||
this.lastRespectMod = this.respectMod;
|
||||
}
|
||||
|
||||
public void onButtonPressed(int id) {
|
||||
if (id == Buttons.WHITELIST.ordinal()) {
|
||||
this.isWhitelist = !this.isWhitelist;
|
||||
this.isAllowFilter = !this.isAllowFilter;
|
||||
} else if (id == Buttons.MOD.ordinal()) {
|
||||
this.respectMod = !this.respectMod;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean check(ItemStack stack) {
|
||||
return !this.needsCheck() || check(stack, this.filterInventory, this.isWhitelist, this.respectMod);
|
||||
return !this.needsCheck() || check(stack, this.filterInventory, this.isAllowFilter, this.respectMod);
|
||||
}
|
||||
|
||||
public boolean needsCheck() {
|
||||
|
@ -122,6 +122,6 @@ public class FilterSettings {
|
|||
return true;
|
||||
}
|
||||
}
|
||||
return this.isWhitelist;
|
||||
return this.isAllowFilter;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -456,9 +456,9 @@
|
|||
"info.actuallyadditions.gui.all": "All",
|
||||
"info.actuallyadditions.gui.put": "Put",
|
||||
"info.actuallyadditions.gui.pull": "Pull",
|
||||
"info.actuallyadditions.gui.whitelist": "Whitelist",
|
||||
"info.actuallyadditions.gui.blacklist": "Blacklist",
|
||||
"info.actuallyadditions.gui.whitelistInfo": "To let all items through, an empty blacklist can be used, to let no items through, an empty whitelist can be used. To configure certain items, place them or configured Item Filters in the slots.",
|
||||
"info.actuallyadditions.gui.allow": "Allow",
|
||||
"info.actuallyadditions.gui.deny": "Deny",
|
||||
"info.actuallyadditions.gui.filterInfo": "To let all items through, an empty deny filter can be used, to let no items through, an empty allow filter can be used. To configure certain items, place them or configured Item Filters in the slots.",
|
||||
"info.actuallyadditions.gui.respectMeta": "Respecting Metadata",
|
||||
"info.actuallyadditions.gui.ignoreMeta": "Ignoring Metadata",
|
||||
"info.actuallyadditions.gui.respectNBT": "Respecting NBT",
|
||||
|
|
Loading…
Reference in a new issue