Skip to content
This repository was archived by the owner on Nov 28, 2025. It is now read-only.

Commit ebc9992

Browse files
committed
Improve AutoBoop filter configuration
1 parent 07b45e0 commit ebc9992

File tree

25 files changed

+1282
-16
lines changed

25 files changed

+1282
-16
lines changed

1.16_combat-6/src/main/java/io/github/axolotlclient/AxolotlClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,6 @@ public void onInitializeClient() {
160160
}
161161

162162
public static Path resolveConfigFile(String file) {
163-
return FabricLoader.getInstance().getConfigDir().resolve("axolotlclient").resolve(file);
163+
return AxolotlClientCommon.resolveConfigFile(file);
164164
}
165165
}

1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/autoboop/AutoBoop.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,12 @@
2222

2323
package io.github.axolotlclient.modules.hypixel.autoboop;
2424

25+
import java.util.List;
26+
2527
import io.github.axolotlclient.modules.hypixel.AbstractHypixelMod;
2628
import io.github.axolotlclient.util.Util;
2729
import lombok.Getter;
30+
import net.minecraft.client.MinecraftClient;
2831

2932
// Based on https://github.com/VeryHolyCheeeese/AutoBoop/blob/main/src/main/java/autoboop/AutoBoop.java
3033
public class AutoBoop extends AutoBoopCommon implements AbstractHypixelMod {
@@ -36,4 +39,9 @@ public class AutoBoop extends AutoBoopCommon implements AbstractHypixelMod {
3639
protected void sendChatMessage(String message) {
3740
Util.sendChatMessage(message);
3841
}
42+
43+
@Override
44+
protected void openFiltersScreen(List<String> filters) {
45+
MinecraftClient.getInstance().openScreen(new FilterListConfigurationScreen(filters, MinecraftClient.getInstance().currentScreen));
46+
}
3947
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/*
2+
* Copyright © 2025 moehreag <moehreag@gmail.com> & Contributors
3+
*
4+
* This file is part of AxolotlClient.
5+
*
6+
* This program is free software; you can redistribute it and/or
7+
* modify it under the terms of the GNU Lesser General Public
8+
* License as published by the Free Software Foundation; either
9+
* version 3 of the License, or (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14+
* Lesser General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Lesser General Public License
17+
* along with this program; if not, write to the Free Software Foundation,
18+
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19+
*
20+
* For more information, see the LICENSE file.
21+
*/
22+
23+
package io.github.axolotlclient.modules.hypixel.autoboop;
24+
25+
import java.util.List;
26+
27+
import io.github.axolotlclient.AxolotlClientCommon;
28+
import net.minecraft.client.gui.screen.Screen;
29+
import net.minecraft.client.gui.screen.ScreenTexts;
30+
import net.minecraft.client.gui.widget.ButtonWidget;
31+
import net.minecraft.client.util.math.MatrixStack;
32+
import net.minecraft.text.TranslatableText;
33+
34+
public class FilterListConfigurationScreen extends Screen {
35+
final List<String> filters;
36+
private FiltersList filtersList;
37+
private final Screen parent;
38+
39+
public FilterListConfigurationScreen(List<String> filters, Screen parent) {
40+
super(new TranslatableText("autoboop.filters.configure"));
41+
this.filters = filters;
42+
this.parent = parent;
43+
}
44+
45+
@Override
46+
public void render(MatrixStack graphics, int mouseX, int mouseY, float delta) {
47+
renderBackground(graphics);
48+
super.render(graphics, mouseX, mouseY, delta);
49+
drawCenteredText(graphics, textRenderer, getTitle(), width / 2, 33 / 2 - textRenderer.fontHeight / 2, -1);
50+
}
51+
52+
@Override
53+
protected void init() {
54+
this.filtersList = addChild(new FiltersList(this));
55+
ButtonWidget resetButton = new ButtonWidget(width / 2 - 150 - 4, height - 33 / 2 - 10, 150, 20,
56+
new TranslatableText("autoboop.filters.clear"), button -> {
57+
filters.clear();
58+
filtersList.reload();
59+
AxolotlClientCommon.getInstance().saveConfig();
60+
});
61+
addButton(resetButton);
62+
addButton(new ButtonWidget(width / 2 + 4, height - 33 / 2 - 10, 150, 20,
63+
ScreenTexts.DONE, button -> this.onClose()));
64+
}
65+
66+
@Override
67+
public void onClose() {
68+
this.client.openScreen(this.parent);
69+
filtersList.apply();
70+
AxolotlClientCommon.getInstance().saveConfig();
71+
}
72+
}
Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
/*
2+
* Copyright © 2025 moehreag <moehreag@gmail.com> & Contributors
3+
*
4+
* This file is part of AxolotlClient.
5+
*
6+
* This program is free software; you can redistribute it and/or
7+
* modify it under the terms of the GNU Lesser General Public
8+
* License as published by the Free Software Foundation; either
9+
* version 3 of the License, or (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14+
* Lesser General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Lesser General Public License
17+
* along with this program; if not, write to the Free Software Foundation,
18+
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19+
*
20+
* For more information, see the LICENSE file.
21+
*/
22+
23+
package io.github.axolotlclient.modules.hypixel.autoboop;
24+
25+
import java.util.List;
26+
27+
import com.google.common.collect.ImmutableList;
28+
import net.fabricmc.api.EnvType;
29+
import net.fabricmc.api.Environment;
30+
import net.minecraft.client.MinecraftClient;
31+
import net.minecraft.client.gui.Element;
32+
import net.minecraft.client.gui.widget.ButtonWidget;
33+
import net.minecraft.client.gui.widget.ElementListWidget;
34+
import net.minecraft.client.gui.widget.TextFieldWidget;
35+
import net.minecraft.client.util.math.MatrixStack;
36+
import net.minecraft.text.Text;
37+
import net.minecraft.text.TranslatableText;
38+
39+
@Environment(EnvType.CLIENT)
40+
public class FiltersList extends ElementListWidget<FiltersList.Entry> {
41+
final FilterListConfigurationScreen screen;
42+
43+
public FiltersList(FilterListConfigurationScreen screen) {
44+
super(MinecraftClient.getInstance(), screen.width, screen.height, 33, screen.height - 33, 24);
45+
this.screen = screen;
46+
47+
reload();
48+
}
49+
50+
public void reload() {
51+
clearEntries();
52+
for (String entry : screen.filters) {
53+
this.addEntry(new FilterEntry(entry));
54+
}
55+
56+
addEntry(new SpacerEntry());
57+
addEntry(new NewEntry());
58+
}
59+
60+
@Override
61+
public int getRowWidth() {
62+
return 340;
63+
}
64+
65+
public void apply() {
66+
screen.filters.clear();
67+
screen.filters.addAll(children().stream().filter(e -> e instanceof FilterEntry)
68+
.map(e -> (FilterEntry) e)
69+
.map(e -> e.editBox.getText()).toList());
70+
}
71+
72+
@Environment(EnvType.CLIENT)
73+
public abstract static class Entry extends ElementListWidget.Entry<Entry> {
74+
75+
}
76+
77+
public static class SpacerEntry extends Entry {
78+
@Override
79+
public void render(MatrixStack guiGraphics, int index, int top, int left, int width, int height, int mouseX, int mouseY, boolean hovering, float partialTick) {
80+
81+
}
82+
83+
@Override
84+
public List<? extends Element> children() {
85+
return List.of();
86+
}
87+
}
88+
89+
@Environment(EnvType.CLIENT)
90+
public class FilterEntry extends Entry {
91+
private static final Text REMOVE_BUTTON_TITLE = new TranslatableText("autoboop.filters.remove");
92+
private final TextFieldWidget editBox;
93+
private final ButtonWidget removeButton;
94+
95+
FilterEntry(String filter) {
96+
this.editBox = new TextFieldWidget(client.textRenderer, 0, 0, 200, 20, new TranslatableText("autoboop.filters.edit"));
97+
editBox.setText(filter);
98+
editBox.setMaxLength(16);
99+
this.removeButton = new ButtonWidget(0, 0, 50, 20, REMOVE_BUTTON_TITLE, b -> {
100+
removeEntry(this);
101+
apply();
102+
setScrollAmount(getScrollAmount());
103+
});
104+
}
105+
106+
@Override
107+
public void render(MatrixStack guiGraphics, int index, int top, int left, int width, int height, int mouseX, int mouseY, boolean hovering, float partialTick) {
108+
int i = getScrollbarPositionX() - removeButton.getWidth() - 10;
109+
int j = top - 2;
110+
this.removeButton.x = i;
111+
this.removeButton.y = j;
112+
this.removeButton.render(guiGraphics, mouseX, mouseY, partialTick);
113+
114+
this.editBox.x = left;
115+
this.editBox.y = j;
116+
this.editBox.setWidth(i - left - 4);
117+
this.editBox.render(guiGraphics, mouseX, mouseY, partialTick);
118+
}
119+
120+
@Override
121+
public List<? extends Element> children() {
122+
return ImmutableList.of(this.editBox, removeButton);
123+
}
124+
}
125+
126+
public class NewEntry extends Entry {
127+
128+
private final ButtonWidget addButton;
129+
130+
public NewEntry() {
131+
this.addButton = new ButtonWidget(0, 0, 150, 20, new TranslatableText("autoboop.filters.add"), button -> {
132+
int i = FiltersList.this.children().indexOf(this);
133+
FiltersList.this.children().add(Math.max(i - 1, 0), new FilterEntry(""));
134+
apply();
135+
setScrollAmount(Math.max(0, getMaxPosition() - (bottom - top - 4)));
136+
});
137+
}
138+
139+
@Override
140+
public void render(MatrixStack guiGraphics, int index, int top, int left, int width, int height, int mouseX, int mouseY, boolean hovering, float partialTick) {
141+
int i = getScrollbarPositionX() - width / 2 - 10 - addButton.getWidth() / 2;
142+
int j = top - 2;
143+
this.addButton.x = i;
144+
this.addButton.y = j;
145+
this.addButton.render(guiGraphics, mouseX, mouseY, partialTick);
146+
}
147+
148+
@Override
149+
public List<? extends Element> children() {
150+
return List.of(addButton);
151+
}
152+
}
153+
}

1.20/src/main/java/io/github/axolotlclient/AxolotlClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,6 @@ public void onInitializeClient() {
162162
}
163163

164164
public static Path resolveConfigFile(String file) {
165-
return FabricLoader.getInstance().getConfigDir().resolve("axolotlclient").resolve(file);
165+
return AxolotlClientCommon.resolveConfigFile(file);
166166
}
167167
}

1.20/src/main/java/io/github/axolotlclient/modules/hypixel/autoboop/AutoBoop.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,12 @@
2222

2323
package io.github.axolotlclient.modules.hypixel.autoboop;
2424

25+
import java.util.List;
26+
2527
import io.github.axolotlclient.modules.hypixel.AbstractHypixelMod;
2628
import io.github.axolotlclient.util.Util;
2729
import lombok.Getter;
30+
import net.minecraft.client.MinecraftClient;
2831

2932
// Based on https://github.com/VeryHolyCheeeese/AutoBoop/blob/main/src/main/java/autoboop/AutoBoop.java
3033
public class AutoBoop extends AutoBoopCommon implements AbstractHypixelMod {
@@ -36,4 +39,9 @@ public class AutoBoop extends AutoBoopCommon implements AbstractHypixelMod {
3639
protected void sendChatMessage(String message) {
3740
Util.sendChatMessage(message);
3841
}
42+
43+
@Override
44+
protected void openFiltersScreen(List<String> filters) {
45+
MinecraftClient.getInstance().setScreen(new FilterListConfigurationScreen(filters, MinecraftClient.getInstance().currentScreen));
46+
}
3947
}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/*
2+
* Copyright © 2025 moehreag <moehreag@gmail.com> & Contributors
3+
*
4+
* This file is part of AxolotlClient.
5+
*
6+
* This program is free software; you can redistribute it and/or
7+
* modify it under the terms of the GNU Lesser General Public
8+
* License as published by the Free Software Foundation; either
9+
* version 3 of the License, or (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14+
* Lesser General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Lesser General Public License
17+
* along with this program; if not, write to the Free Software Foundation,
18+
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19+
*
20+
* For more information, see the LICENSE file.
21+
*/
22+
23+
package io.github.axolotlclient.modules.hypixel.autoboop;
24+
25+
import java.util.List;
26+
27+
import io.github.axolotlclient.AxolotlClientCommon;
28+
import net.minecraft.client.gui.GuiGraphics;
29+
import net.minecraft.client.gui.screen.Screen;
30+
import net.minecraft.client.gui.widget.ButtonWidget;
31+
import net.minecraft.text.CommonTexts;
32+
import net.minecraft.text.Text;
33+
34+
public class FilterListConfigurationScreen extends Screen {
35+
final List<String> filters;
36+
private FiltersList filtersList;
37+
private final Screen parent;
38+
39+
public FilterListConfigurationScreen(List<String> filters, Screen parent) {
40+
super(Text.translatable("autoboop.filters.configure"));
41+
this.filters = filters;
42+
this.parent = parent;
43+
}
44+
45+
@Override
46+
public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) {
47+
renderBackground(graphics);
48+
super.render(graphics, mouseX, mouseY, delta);
49+
graphics.drawCenteredShadowedText(textRenderer, getTitle(), width / 2, 33 / 2 - textRenderer.fontHeight / 2, -1);
50+
}
51+
52+
@Override
53+
protected void init() {
54+
this.filtersList = addDrawableChild(new FiltersList(this));
55+
ButtonWidget resetButton = ButtonWidget.builder(Text.translatable("autoboop.filters.clear"), button -> {
56+
filters.clear();
57+
filtersList.reload();
58+
AxolotlClientCommon.getInstance().saveConfig();
59+
}).positionAndSize(width / 2 - 150 - 4, height - 33 / 2 - 10, 150, 20).build();
60+
addDrawableChild(resetButton);
61+
addDrawableChild(ButtonWidget.builder(CommonTexts.DONE, button -> this.closeScreen())
62+
.positionAndSize(width / 2 + 4, height - 33 / 2 - 10, 150, 20).build());
63+
}
64+
65+
@Override
66+
public void closeScreen() {
67+
this.client.setScreen(this.parent);
68+
filtersList.apply();
69+
AxolotlClientCommon.getInstance().saveConfig();
70+
}
71+
}

0 commit comments

Comments
 (0)