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