diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/package-info.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/package-info.java new file mode 100644 index 00000000..01e664aa --- /dev/null +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/package-info.java @@ -0,0 +1,24 @@ +/* + * Copyright © 2021-2025 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +@SuppressWarnings("unused") +package io.github.axolotlclient.AxolotlClientConfig.impl; diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/ButtonListWidget.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/ButtonListWidget.java index 4dbab511..0210b56f 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/ButtonListWidget.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/ButtonListWidget.java @@ -144,6 +144,11 @@ protected int getScrollbarPositionX() { return super.getScrollbarPositionX() + 38; } + @Override + public boolean mouseScrolled(double mouseX, double mouseY, double scrollY) { + return getHoveredEntry() != null && getHoveredEntry().mouseScrolled(mouseX, mouseY, scrollY) || super.mouseScrolled(mouseX, mouseY, scrollY); + } + protected static class Entry extends ElementListWidget.Entry { diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/widgets/EnumWidget.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/widgets/EnumWidget.java index c1f64596..322a5197 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/widgets/EnumWidget.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/widgets/EnumWidget.java @@ -23,7 +23,11 @@ package io.github.axolotlclient.AxolotlClientConfig.impl.ui.rounded.widgets; import io.github.axolotlclient.AxolotlClientConfig.impl.options.EnumOption; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.screen.Screen; import net.minecraft.text.TranslatableText; +import org.apache.commons.lang3.ArrayUtils; +import org.lwjgl.glfw.GLFW; public class EnumWidget> extends RoundedButtonWidget { private final EnumOption option; @@ -35,17 +39,65 @@ public EnumWidget(int x, int y, int width, int height, EnumOption option) { } @Override - public void onPress() { - T[] values = option.getClazz().getEnumConstants(); - int i = 0; - while (!values[i].equals(option.get())) { - i += 1; + public boolean mouseClicked(double mouseX, double mouseY, int button) { + if (this.active && this.visible) { + if (this.isValidClickButton(button)) { + boolean bl = this.isMouseOver(mouseX, mouseY); + if (bl) { + this.playDownSound(MinecraftClient.getInstance().getSoundManager()); + this.cycle(button == 0 ? 1 : -1, true); + return true; + } + } } - i += 1; - if (i >= values.length) { - i = 0; + return false; + } + + @Override + public boolean keyPressed(int keyCode, int scanCode, int modifiers) { + if (!this.active || !this.visible) { + return false; + } else if (keyCode == GLFW.GLFW_KEY_ENTER || keyCode == GLFW.GLFW_KEY_SPACE || keyCode == GLFW.GLFW_KEY_KP_ENTER || keyCode == GLFW.GLFW_KEY_RIGHT) { + if (this.cycle(1, false)) { + this.playDownSound(MinecraftClient.getInstance().getSoundManager()); + return true; + } + } else if(keyCode == GLFW.GLFW_KEY_LEFT) { + if (this.cycle(-1, false)) { + this.playDownSound(MinecraftClient.getInstance().getSoundManager()); + return true; + } } - option.set(values[i]); + return false; + } + + @Override + protected boolean isValidClickButton(int button) { + return button == 0 || button == 1; + } + + private boolean cycle(int step, boolean wrap) { + if (Screen.hasShiftDown()) { + step *= -1; + } + T[] values = option.getClazz().getEnumConstants(); + int i = ArrayUtils.indexOf(values, option.get()); + if (!wrap && (i == 0 || i == values.length-1)) { + return false; + } + option.set(values[Math.floorMod(i + step, values.length)]); setMessage(new TranslatableText(String.valueOf(option.get()))); + return true; + } + + @Override + public boolean mouseScrolled(double mouseX, double mouseY, double scrollY) { + if (scrollY > 0.0) { + this.cycle(-1, true); + } else if (scrollY < 0.0) { + this.cycle(1, true); + } + + return true; } } diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/widgets/RoundedButtonWidget.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/widgets/RoundedButtonWidget.java index 04891418..5f9b3a38 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/widgets/RoundedButtonWidget.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/widgets/RoundedButtonWidget.java @@ -89,7 +89,7 @@ protected Color getWidgetColor() { } public boolean isHovered() { - return hovered; + return hovered || isFocused(); } @Override diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/widgets/StringArrayButtonWidget.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/widgets/StringArrayButtonWidget.java index 7d67e872..ffee995f 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/widgets/StringArrayButtonWidget.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/widgets/StringArrayButtonWidget.java @@ -23,9 +23,13 @@ package io.github.axolotlclient.AxolotlClientConfig.impl.ui.rounded.widgets; import io.github.axolotlclient.AxolotlClientConfig.impl.options.StringArrayOption; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.resource.language.I18n; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.text.TranslatableText; +import org.apache.commons.lang3.ArrayUtils; +import org.lwjgl.glfw.GLFW; public class StringArrayButtonWidget extends RoundedButtonWidget { @@ -46,17 +50,65 @@ public void renderButton(MatrixStack graphics, int mouseX, int mouseY, float del } @Override - public void onPress() { + public boolean mouseClicked(double mouseX, double mouseY, int button) { + if (this.active && this.visible) { + if (this.isValidClickButton(button)) { + boolean bl = this.isMouseOver(mouseX, mouseY); + if (bl) { + this.playDownSound(MinecraftClient.getInstance().getSoundManager()); + this.cycle(button == 0 ? 1 : -1, true); + return true; + } + } + } + return false; + } + + @Override + public boolean keyPressed(int keyCode, int scanCode, int modifiers) { + if (!this.active || !this.visible) { + return false; + } else if (keyCode == GLFW.GLFW_KEY_ENTER || keyCode == GLFW.GLFW_KEY_SPACE || keyCode == GLFW.GLFW_KEY_KP_ENTER || keyCode == GLFW.GLFW_KEY_RIGHT) { + if (this.cycle(1, false)) { + this.playDownSound(MinecraftClient.getInstance().getSoundManager()); + return true; + } + } else if (keyCode == GLFW.GLFW_KEY_LEFT) { + if (this.cycle(-1, false)) { + this.playDownSound(MinecraftClient.getInstance().getSoundManager()); + return true; + } + } + return false; + } + + @Override + protected boolean isValidClickButton(int button) { + return button == 0 || button == 1; + } + + private boolean cycle(int step, boolean wrap) { + if (Screen.hasShiftDown()) { + step *= -1; + } String[] values = option.getValues(); - int i = 0; - while (!values[i].equals(option.get())) { - i += 1; + int i = ArrayUtils.indexOf(values, option.get()); + if (!wrap && (i == 0 || i == values.length-1)) { + return false; } - i += 1; - if (i >= values.length) { - i = 0; + option.set(values[Math.floorMod(i + step, values.length)]); + setMessage(new TranslatableText(String.valueOf(option.get()))); + return true; + } + + @Override + public boolean mouseScrolled(double mouseX, double mouseY, double scrollY) { + if (scrollY > 0.0) { + this.cycle(-1, true); + } else if (scrollY < 0.0) { + this.cycle(1, true); } - option.set(values[i]); - setMessage(new TranslatableText(option.get())); + + return true; } } diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/widgets/TextOnlyButtonWidget.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/widgets/TextOnlyButtonWidget.java index 41cfde77..b19494fe 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/widgets/TextOnlyButtonWidget.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/widgets/TextOnlyButtonWidget.java @@ -1,3 +1,25 @@ +/* + * Copyright © 2021-2024 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + package io.github.axolotlclient.AxolotlClientConfig.impl.ui.rounded.widgets; import io.github.axolotlclient.AxolotlClientConfig.impl.ui.rounded.NVGHolder; diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/vanilla/ButtonListWidget.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/vanilla/ButtonListWidget.java index a57b584c..8d51a399 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/vanilla/ButtonListWidget.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/vanilla/ButtonListWidget.java @@ -152,9 +152,12 @@ protected void renderList(MatrixStack matrices, int mouseX, int mouseY, float de DrawUtil.popScissor(); } - protected static class Entry extends ElementListWidget.Entry { - + @Override + public boolean mouseScrolled(double mouseX, double mouseY, double scrollY) { + return getHoveredEntry() != null && getHoveredEntry().mouseScrolled(mouseX, mouseY, scrollY) || super.mouseScrolled(mouseX, mouseY, scrollY); + } + protected static class Entry extends ElementListWidget.Entry { private final List children = new ArrayList<>(); public Entry(Collection widgets) { diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/vanilla/widgets/EnumWidget.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/vanilla/widgets/EnumWidget.java index bfaa8045..62949981 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/vanilla/widgets/EnumWidget.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/vanilla/widgets/EnumWidget.java @@ -23,7 +23,11 @@ package io.github.axolotlclient.AxolotlClientConfig.impl.ui.vanilla.widgets; import io.github.axolotlclient.AxolotlClientConfig.impl.options.EnumOption; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.screen.Screen; import net.minecraft.text.TranslatableText; +import org.apache.commons.lang3.ArrayUtils; +import org.lwjgl.glfw.GLFW; public class EnumWidget> extends VanillaButtonWidget { private final EnumOption option; @@ -35,17 +39,65 @@ public EnumWidget(int x, int y, int width, int height, EnumOption option) { } @Override - public void onClick(double mouseX, double mouseY) { - T[] values = option.getClazz().getEnumConstants(); - int i = 0; - while (!values[i].equals(option.get())) { - i += 1; + public boolean mouseClicked(double mouseX, double mouseY, int button) { + if (this.active && this.visible) { + if (this.isValidClickButton(button)) { + boolean bl = this.isMouseOver(mouseX, mouseY); + if (bl) { + this.playDownSound(MinecraftClient.getInstance().getSoundManager()); + this.cycle(button == 0 ? 1 : -1, true); + return true; + } + } } - i += 1; - if (i >= values.length) { - i = 0; + return false; + } + + @Override + public boolean keyPressed(int keyCode, int scanCode, int modifiers) { + if (!this.active || !this.visible) { + return false; + } else if (keyCode == GLFW.GLFW_KEY_ENTER || keyCode == GLFW.GLFW_KEY_SPACE || keyCode == GLFW.GLFW_KEY_KP_ENTER || keyCode == GLFW.GLFW_KEY_RIGHT) { + if (this.cycle(1, false)) { + this.playDownSound(MinecraftClient.getInstance().getSoundManager()); + return true; + } + } else if(keyCode == GLFW.GLFW_KEY_LEFT) { + if (this.cycle(-1, false)) { + this.playDownSound(MinecraftClient.getInstance().getSoundManager()); + return true; + } } - option.set(values[i]); + return false; + } + + @Override + protected boolean isValidClickButton(int button) { + return button == 0 || button == 1; + } + + private boolean cycle(int step, boolean wrap) { + if (Screen.hasShiftDown()) { + step *= -1; + } + T[] values = option.getClazz().getEnumConstants(); + int i = ArrayUtils.indexOf(values, option.get()); + if (!wrap && (i == 0 || i == values.length-1)) { + return false; + } + option.set(values[Math.floorMod(i + step, values.length)]); setMessage(new TranslatableText(String.valueOf(option.get()))); + return true; + } + + @Override + public boolean mouseScrolled(double mouseX, double mouseY, double scrollY) { + if (scrollY > 0.0) { + this.cycle(-1, true); + } else if (scrollY < 0.0) { + this.cycle(1, true); + } + + return true; } } diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/vanilla/widgets/PlainTextButtonWidget.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/vanilla/widgets/PlainTextButtonWidget.java index b3808d7e..411038dd 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/vanilla/widgets/PlainTextButtonWidget.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/vanilla/widgets/PlainTextButtonWidget.java @@ -1,3 +1,25 @@ +/* + * Copyright © 2021-2024 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + package io.github.axolotlclient.AxolotlClientConfig.impl.ui.vanilla.widgets; import net.minecraft.client.font.TextRenderer; diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/vanilla/widgets/StringArrayWidget.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/vanilla/widgets/StringArrayWidget.java index 40296432..4d0b2c3c 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/vanilla/widgets/StringArrayWidget.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/vanilla/widgets/StringArrayWidget.java @@ -23,8 +23,12 @@ package io.github.axolotlclient.AxolotlClientConfig.impl.ui.vanilla.widgets; import io.github.axolotlclient.AxolotlClientConfig.impl.options.StringArrayOption; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.text.TranslatableText; +import org.apache.commons.lang3.ArrayUtils; +import org.lwjgl.glfw.GLFW; public class StringArrayWidget extends VanillaButtonWidget { @@ -45,17 +49,65 @@ public void renderButton(MatrixStack graphics, int mouseX, int mouseY, float del } @Override - public void onClick(double mouseX, double mouseY) { + public boolean mouseClicked(double mouseX, double mouseY, int button) { + if (this.active && this.visible) { + if (this.isValidClickButton(button)) { + boolean bl = this.isMouseOver(mouseX, mouseY); + if (bl) { + this.playDownSound(MinecraftClient.getInstance().getSoundManager()); + this.cycle(button == 0 ? 1 : -1, true); + return true; + } + } + } + return false; + } + + @Override + public boolean keyPressed(int keyCode, int scanCode, int modifiers) { + if (!this.active || !this.visible) { + return false; + } else if (keyCode == GLFW.GLFW_KEY_ENTER || keyCode == GLFW.GLFW_KEY_SPACE || keyCode == GLFW.GLFW_KEY_KP_ENTER || keyCode == GLFW.GLFW_KEY_RIGHT) { + if (this.cycle(1, false)) { + this.playDownSound(MinecraftClient.getInstance().getSoundManager()); + return true; + } + } else if (keyCode == GLFW.GLFW_KEY_LEFT) { + if (this.cycle(-1, false)) { + this.playDownSound(MinecraftClient.getInstance().getSoundManager()); + return true; + } + } + return false; + } + + @Override + protected boolean isValidClickButton(int button) { + return button == 0 || button == 1; + } + + private boolean cycle(int step, boolean wrap) { + if (Screen.hasShiftDown()) { + step *= -1; + } String[] values = option.getValues(); - int i = 0; - while (!values[i].equals(option.get())) { - i += 1; + int i = ArrayUtils.indexOf(values, option.get()); + if (!wrap && (i == 0 || i == values.length-1)) { + return false; } - i += 1; - if (i >= values.length) { - i = 0; + option.set(values[Math.floorMod(i + step, values.length)]); + setMessage(new TranslatableText(String.valueOf(option.get()))); + return true; + } + + @Override + public boolean mouseScrolled(double mouseX, double mouseY, double scrollY) { + if (scrollY > 0.0) { + this.cycle(-1, true); + } else if (scrollY < 0.0) { + this.cycle(1, true); } - option.set(values[i]); - setMessage(new TranslatableText(option.get())); + + return true; } } diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/vanilla/widgets/VanillaButtonWidget.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/vanilla/widgets/VanillaButtonWidget.java index 98c2d201..60ad5a52 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/vanilla/widgets/VanillaButtonWidget.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/vanilla/widgets/VanillaButtonWidget.java @@ -38,7 +38,7 @@ public VanillaButtonWidget(int x, int y, int width, int height, Text message, Pr } public boolean isHovered() { - return hovered; + return hovered || isFocused(); } public int getX() { diff --git a/1.16_combat-6/src/test/java/io/github/axolotlclient/AxolotlClientConfig/example/Example.java b/1.16_combat-6/src/test/java/io/github/axolotlclient/AxolotlClientConfig/example/Example.java index e4cc9642..675172a8 100644 --- a/1.16_combat-6/src/test/java/io/github/axolotlclient/AxolotlClientConfig/example/Example.java +++ b/1.16_combat-6/src/test/java/io/github/axolotlclient/AxolotlClientConfig/example/Example.java @@ -91,6 +91,9 @@ public void onInitializeClient() { example.add(new StringOption("string option", "default value")); example.add(new BooleanOption("option", false)); example.add(new BooleanOption("other option", true)); + example.add(new GraphicsOption("graphics", 40, 40)); + example.add(new EnumOption<>("enum", TestEnum.class, TestEnum.TEST_ENUM1)); + example.add(new StringArrayOption("another string array", "value 1", "value 2", "value 3")); KeyBinding binding = new KeyBinding("test", -1, "test"); KeyBindingHelper.registerKeyBinding(binding); @@ -122,5 +125,9 @@ public void onInitializeClient() { manager.getRoot(), parent); } - + public enum TestEnum { + TEST_ENUM1, + TEST_ENUM2, + TEST_ENUM3, + } } diff --git a/1.20/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/package-info.java b/1.20/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/package-info.java new file mode 100644 index 00000000..01e664aa --- /dev/null +++ b/1.20/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/package-info.java @@ -0,0 +1,24 @@ +/* + * Copyright © 2021-2025 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +@SuppressWarnings("unused") +package io.github.axolotlclient.AxolotlClientConfig.impl; diff --git a/1.20/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/ButtonListWidget.java b/1.20/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/ButtonListWidget.java index a54e3de0..5b1f1c43 100644 --- a/1.20/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/ButtonListWidget.java +++ b/1.20/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/ButtonListWidget.java @@ -144,6 +144,16 @@ protected int getScrollbarPositionX() { return super.getScrollbarPositionX() + 38; } + @Override + protected boolean method_53812(int i) { + return true; + } + + @Override + public boolean mouseScrolled(double mouseX, double mouseY, double scrollY) { + return getHoveredEntry() != null && getHoveredEntry().mouseScrolled(mouseX, mouseY, scrollY) || super.mouseScrolled(mouseX, mouseY, scrollY); + } + protected static class Entry extends ElementListWidget.Entry { diff --git a/1.20/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/NVGUtil.java b/1.20/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/NVGUtil.java index 77ff0fed..da89b772 100644 --- a/1.20/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/NVGUtil.java +++ b/1.20/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/NVGUtil.java @@ -1,3 +1,25 @@ +/* + * Copyright © 2021-2024 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + package io.github.axolotlclient.AxolotlClientConfig.impl.ui.rounded; import java.util.function.Consumer; diff --git a/1.20/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/widgets/EnumWidget.java b/1.20/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/widgets/EnumWidget.java index 51dfebbe..1ef72d8d 100644 --- a/1.20/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/widgets/EnumWidget.java +++ b/1.20/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/widgets/EnumWidget.java @@ -23,7 +23,12 @@ package io.github.axolotlclient.AxolotlClientConfig.impl.ui.rounded.widgets; import io.github.axolotlclient.AxolotlClientConfig.impl.options.EnumOption; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.CommonInputs; +import net.minecraft.client.gui.screen.Screen; import net.minecraft.text.Text; +import org.apache.commons.lang3.ArrayUtils; +import org.lwjgl.glfw.GLFW; public class EnumWidget> extends RoundedButtonWidget { private final EnumOption option; @@ -35,17 +40,65 @@ public EnumWidget(int x, int y, int width, int height, EnumOption option) { } @Override - public void onPress() { - T[] values = option.getClazz().getEnumConstants(); - int i = 0; - while (!values[i].equals(option.get())) { - i += 1; + public boolean mouseClicked(double mouseX, double mouseY, int button) { + if (this.active && this.visible) { + if (this.isValidClickButton(button)) { + boolean bl = this.isMouseOver(mouseX, mouseY); + if (bl) { + this.playDownSound(MinecraftClient.getInstance().getSoundManager()); + this.cycle(button == 0 ? 1 : -1, true); + return true; + } + } } - i += 1; - if (i >= values.length) { - i = 0; + return false; + } + + @Override + public boolean keyPressed(int keyCode, int scanCode, int modifiers) { + if (!this.active || !this.visible) { + return false; + } else if (CommonInputs.isToggle(keyCode) || keyCode == GLFW.GLFW_KEY_RIGHT) { + if (this.cycle(1, false)) { + this.playDownSound(MinecraftClient.getInstance().getSoundManager()); + return true; + } + } else if(keyCode == GLFW.GLFW_KEY_LEFT) { + if (this.cycle(-1, false)) { + this.playDownSound(MinecraftClient.getInstance().getSoundManager()); + return true; + } } - option.set(values[i]); + return false; + } + + @Override + protected boolean isValidClickButton(int button) { + return button == 0 || button == 1; + } + + private boolean cycle(int step, boolean wrap) { + if (Screen.hasShiftDown()) { + step *= -1; + } + T[] values = option.getClazz().getEnumConstants(); + int i = ArrayUtils.indexOf(values, option.get()); + if (!wrap && (i == 0 || i == values.length-1)) { + return false; + } + option.set(values[Math.floorMod(i + step, values.length)]); setMessage(Text.translatable(String.valueOf(option.get()))); + return true; + } + + @Override + public boolean mouseScrolled(double mouseX, double mouseY, double scrollY) { + if (scrollY > 0.0) { + this.cycle(-1, true); + } else if (scrollY < 0.0) { + this.cycle(1, true); + } + + return true; } } diff --git a/1.20/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/widgets/StringArrayButtonWidget.java b/1.20/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/widgets/StringArrayButtonWidget.java index 177ed372..384b836d 100644 --- a/1.20/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/widgets/StringArrayButtonWidget.java +++ b/1.20/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/widgets/StringArrayButtonWidget.java @@ -23,9 +23,14 @@ package io.github.axolotlclient.AxolotlClientConfig.impl.ui.rounded.widgets; import io.github.axolotlclient.AxolotlClientConfig.impl.options.StringArrayOption; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.CommonInputs; import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.resource.language.I18n; import net.minecraft.text.Text; +import org.apache.commons.lang3.ArrayUtils; +import org.lwjgl.glfw.GLFW; public class StringArrayButtonWidget extends RoundedButtonWidget { @@ -46,17 +51,65 @@ protected void drawWidget(GuiGraphics graphics, int mouseX, int mouseY, float de } @Override - public void onPress() { + public boolean mouseClicked(double mouseX, double mouseY, int button) { + if (this.active && this.visible) { + if (this.isValidClickButton(button)) { + boolean bl = this.isMouseOver(mouseX, mouseY); + if (bl) { + this.playDownSound(MinecraftClient.getInstance().getSoundManager()); + this.cycle(button == 0 ? 1 : -1, true); + return true; + } + } + } + return false; + } + + @Override + public boolean keyPressed(int keyCode, int scanCode, int modifiers) { + if (!this.active || !this.visible) { + return false; + } else if (CommonInputs.isToggle(keyCode) || keyCode == GLFW.GLFW_KEY_RIGHT) { + if (this.cycle(1, false)) { + this.playDownSound(MinecraftClient.getInstance().getSoundManager()); + return true; + } + } else if(keyCode == GLFW.GLFW_KEY_LEFT) { + if (this.cycle(-1, false)) { + this.playDownSound(MinecraftClient.getInstance().getSoundManager()); + return true; + } + } + return false; + } + + @Override + protected boolean isValidClickButton(int button) { + return button == 0 || button == 1; + } + + private boolean cycle(int step, boolean wrap) { + if (Screen.hasShiftDown()) { + step *= -1; + } String[] values = option.getValues(); - int i = 0; - while (!values[i].equals(option.get())) { - i += 1; + int i = ArrayUtils.indexOf(values, option.get()); + if (!wrap && (i == 0 || i == values.length-1)) { + return false; } - i += 1; - if (i >= values.length) { - i = 0; + option.set(values[Math.floorMod(i + step, values.length)]); + setMessage(Text.translatable(String.valueOf(option.get()))); + return true; + } + + @Override + public boolean mouseScrolled(double mouseX, double mouseY, double scrollY) { + if (scrollY > 0.0) { + this.cycle(-1, true); + } else if (scrollY < 0.0) { + this.cycle(1, true); } - option.set(values[i]); - setMessage(Text.translatable(option.get())); + + return true; } } diff --git a/1.20/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/widgets/TextOnlyButtonWidget.java b/1.20/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/widgets/TextOnlyButtonWidget.java index 11857264..2d37d365 100644 --- a/1.20/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/widgets/TextOnlyButtonWidget.java +++ b/1.20/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/widgets/TextOnlyButtonWidget.java @@ -1,3 +1,25 @@ +/* + * Copyright © 2021-2024 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + package io.github.axolotlclient.AxolotlClientConfig.impl.ui.rounded.widgets; import io.github.axolotlclient.AxolotlClientConfig.impl.ui.rounded.NVGHolder; diff --git a/1.20/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/vanilla/EntryListWidget.java b/1.20/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/vanilla/EntryListWidget.java index 2210f6b5..c189d04a 100644 --- a/1.20/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/vanilla/EntryListWidget.java +++ b/1.20/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/vanilla/EntryListWidget.java @@ -145,6 +145,11 @@ protected int getScrollbarPositionX() { return super.getScrollbarPositionX() + 38; } + @Override + public boolean mouseScrolled(double mouseX, double mouseY, double scrollY) { + return getHoveredEntry() != null && getHoveredEntry().mouseScrolled(mouseX, mouseY, scrollY) || super.mouseScrolled(mouseX, mouseY, scrollY); + } + protected static class Entry extends ElementListWidget.Entry { diff --git a/1.20/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/vanilla/widgets/EnumWidget.java b/1.20/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/vanilla/widgets/EnumWidget.java index 34fde476..cfc23bd8 100644 --- a/1.20/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/vanilla/widgets/EnumWidget.java +++ b/1.20/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/vanilla/widgets/EnumWidget.java @@ -23,8 +23,13 @@ package io.github.axolotlclient.AxolotlClientConfig.impl.ui.vanilla.widgets; import io.github.axolotlclient.AxolotlClientConfig.impl.options.EnumOption; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.CommonInputs; +import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.widget.ButtonWidget; import net.minecraft.text.Text; +import org.apache.commons.lang3.ArrayUtils; +import org.lwjgl.glfw.GLFW; public class EnumWidget> extends ButtonWidget { private final EnumOption option; @@ -36,17 +41,65 @@ public EnumWidget(int x, int y, int width, int height, EnumOption option) { } @Override - public void onClick(double mouseX, double mouseY) { - T[] values = option.getClazz().getEnumConstants(); - int i = 0; - while (!values[i].equals(option.get())) { - i += 1; + public boolean mouseClicked(double mouseX, double mouseY, int button) { + if (this.active && this.visible) { + if (this.isValidClickButton(button)) { + boolean bl = this.isMouseOver(mouseX, mouseY); + if (bl) { + this.playDownSound(MinecraftClient.getInstance().getSoundManager()); + this.cycle(button == 0 ? 1 : -1, true); + return true; + } + } } - i += 1; - if (i >= values.length) { - i = 0; + return false; + } + + @Override + public boolean keyPressed(int keyCode, int scanCode, int modifiers) { + if (!this.active || !this.visible) { + return false; + } else if (CommonInputs.isToggle(keyCode) || keyCode == GLFW.GLFW_KEY_RIGHT) { + if (this.cycle(1, false)) { + this.playDownSound(MinecraftClient.getInstance().getSoundManager()); + return true; + } + } else if(keyCode == GLFW.GLFW_KEY_LEFT) { + if (this.cycle(-1, false)) { + this.playDownSound(MinecraftClient.getInstance().getSoundManager()); + return true; + } } - option.set(values[i]); + return false; + } + + @Override + protected boolean isValidClickButton(int button) { + return button == 0 || button == 1; + } + + private boolean cycle(int step, boolean wrap) { + if (Screen.hasShiftDown()) { + step *= -1; + } + T[] values = option.getClazz().getEnumConstants(); + int i = ArrayUtils.indexOf(values, option.get()); + if (!wrap && (i == 0 || i == values.length-1)) { + return false; + } + option.set(values[Math.floorMod(i + step, values.length)]); setMessage(Text.translatable(String.valueOf(option.get()))); + return true; + } + + @Override + public boolean mouseScrolled(double mouseX, double mouseY, double scrollY) { + if (scrollY > 0.0) { + this.cycle(-1, true); + } else if (scrollY < 0.0) { + this.cycle(1, true); + } + + return true; } } diff --git a/1.20/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/vanilla/widgets/StringArrayWidget.java b/1.20/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/vanilla/widgets/StringArrayWidget.java index 7c03761d..96ca1525 100644 --- a/1.20/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/vanilla/widgets/StringArrayWidget.java +++ b/1.20/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/vanilla/widgets/StringArrayWidget.java @@ -23,9 +23,14 @@ package io.github.axolotlclient.AxolotlClientConfig.impl.ui.vanilla.widgets; import io.github.axolotlclient.AxolotlClientConfig.impl.options.StringArrayOption; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.CommonInputs; import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.widget.ButtonWidget; import net.minecraft.text.Text; +import org.apache.commons.lang3.ArrayUtils; +import org.lwjgl.glfw.GLFW; public class StringArrayWidget extends ButtonWidget { @@ -46,17 +51,65 @@ protected void drawWidget(GuiGraphics graphics, int mouseX, int mouseY, float de } @Override - public void onClick(double mouseX, double mouseY) { + public boolean mouseClicked(double mouseX, double mouseY, int button) { + if (this.active && this.visible) { + if (this.isValidClickButton(button)) { + boolean bl = this.isMouseOver(mouseX, mouseY); + if (bl) { + this.playDownSound(MinecraftClient.getInstance().getSoundManager()); + this.cycle(button == 0 ? 1 : -1, true); + return true; + } + } + } + return false; + } + + @Override + public boolean keyPressed(int keyCode, int scanCode, int modifiers) { + if (!this.active || !this.visible) { + return false; + } else if (CommonInputs.isToggle(keyCode) || keyCode == GLFW.GLFW_KEY_RIGHT) { + if (this.cycle(1, false)) { + this.playDownSound(MinecraftClient.getInstance().getSoundManager()); + return true; + } + } else if(keyCode == GLFW.GLFW_KEY_LEFT) { + if (this.cycle(-1, false)) { + this.playDownSound(MinecraftClient.getInstance().getSoundManager()); + return true; + } + } + return false; + } + + @Override + protected boolean isValidClickButton(int button) { + return button == 0 || button == 1; + } + + private boolean cycle(int step, boolean wrap) { + if (Screen.hasShiftDown()) { + step *= -1; + } String[] values = option.getValues(); - int i = 0; - while (!values[i].equals(option.get())) { - i += 1; + int i = ArrayUtils.indexOf(values, option.get()); + if (!wrap && (i == 0 || i == values.length-1)) { + return false; } - i += 1; - if (i >= values.length) { - i = 0; + option.set(values[Math.floorMod(i + step, values.length)]); + setMessage(Text.translatable(String.valueOf(option.get()))); + return true; + } + + @Override + public boolean mouseScrolled(double mouseX, double mouseY, double scrollY) { + if (scrollY > 0.0) { + this.cycle(-1, true); + } else if (scrollY < 0.0) { + this.cycle(1, true); } - option.set(values[i]); - setMessage(Text.translatable(option.get())); + + return true; } } diff --git a/1.20/src/test/java/io/github/axolotlclient/AxolotlClientConfig/example/Example.java b/1.20/src/test/java/io/github/axolotlclient/AxolotlClientConfig/example/Example.java index 9dfff5fd..b897b8b9 100644 --- a/1.20/src/test/java/io/github/axolotlclient/AxolotlClientConfig/example/Example.java +++ b/1.20/src/test/java/io/github/axolotlclient/AxolotlClientConfig/example/Example.java @@ -93,7 +93,8 @@ public void onInitializeClient() { example.add(new BooleanOption("option", false)); example.add(new BooleanOption("other option", true)); example.add(new GraphicsOption("graphics", 40, 40)); - example.add(new EnumOption<>("enum", ExampleEnum.class)); + example.add(new EnumOption<>("enum", TestEnum.class, TestEnum.TEST_ENUM1)); + example.add(new StringArrayOption("another string array", "value 1", "value 2", "value 3")); AxolotlClientConfig.getInstance().register(new JsonConfigManager(FabricLoader.getInstance().getConfigDir().resolve(modid + ".json"), example)); @@ -118,12 +119,11 @@ public void onInitializeClient() { }); } - private enum ExampleEnum { - EXAMPLE1, - EXAMPLE2, - EXAMPLE3 + public enum TestEnum { + TEST_ENUM1, + TEST_ENUM2, + TEST_ENUM3, } - public Function getConfigScreenFactory(String name) { ConfigManager manager = AxolotlClientConfig.getInstance().getConfigManager(name); return parent -> (Screen) ConfigUI.getInstance().getScreen(this.getClass().getClassLoader(), diff --git a/1.20/src/test/java/io/github/axolotlclient/AxolotlClientConfig/example/mixin/TitleScreenMixin.java b/1.20/src/test/java/io/github/axolotlclient/AxolotlClientConfig/example/mixin/TitleScreenMixin.java index 513592a0..37d0bb2d 100644 --- a/1.20/src/test/java/io/github/axolotlclient/AxolotlClientConfig/example/mixin/TitleScreenMixin.java +++ b/1.20/src/test/java/io/github/axolotlclient/AxolotlClientConfig/example/mixin/TitleScreenMixin.java @@ -1,3 +1,25 @@ +/* + * Copyright © 2021-2024 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + package io.github.axolotlclient.AxolotlClientConfig.example.mixin; import io.github.axolotlclient.AxolotlClientConfig.example.Example; diff --git a/1.21.4/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/mixin/NativeImageInvoker.java b/1.21.4/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/mixin/NativeImageInvoker.java index 2e267392..eecc7e4f 100644 --- a/1.21.4/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/mixin/NativeImageInvoker.java +++ b/1.21.4/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/mixin/NativeImageInvoker.java @@ -1,3 +1,25 @@ +/* + * Copyright © 2021-2024 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + package io.github.axolotlclient.AxolotlClientConfig.impl.mixin; import java.io.IOException; diff --git a/1.21.4/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/package-info.java b/1.21.4/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/package-info.java new file mode 100644 index 00000000..01e664aa --- /dev/null +++ b/1.21.4/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/package-info.java @@ -0,0 +1,24 @@ +/* + * Copyright © 2021-2025 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +@SuppressWarnings("unused") +package io.github.axolotlclient.AxolotlClientConfig.impl; diff --git a/1.21.4/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/ButtonListWidget.java b/1.21.4/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/ButtonListWidget.java index 7a353e60..fd9ab3fe 100644 --- a/1.21.4/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/ButtonListWidget.java +++ b/1.21.4/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/ButtonListWidget.java @@ -171,6 +171,11 @@ protected void renderListItems(GuiGraphics guiGraphics, int mouseX, int mouseY, popScissor(NVGHolder.getContext()); } + @Override + protected boolean isValidClickButton(int button) { + return true; + } + protected static class Entry extends ContainerObjectSelectionList.Entry { diff --git a/1.21.4/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/NVGUtil.java b/1.21.4/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/NVGUtil.java index 18875145..47538387 100644 --- a/1.21.4/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/NVGUtil.java +++ b/1.21.4/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/NVGUtil.java @@ -1,3 +1,25 @@ +/* + * Copyright © 2021-2024 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + package io.github.axolotlclient.AxolotlClientConfig.impl.ui.rounded; import java.util.function.Consumer; diff --git a/1.21.4/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/widgets/EnumWidget.java b/1.21.4/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/widgets/EnumWidget.java index 6a8fc2ad..d06442e5 100644 --- a/1.21.4/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/widgets/EnumWidget.java +++ b/1.21.4/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/widgets/EnumWidget.java @@ -22,10 +22,12 @@ package io.github.axolotlclient.AxolotlClientConfig.impl.ui.rounded.widgets; +import com.mojang.blaze3d.platform.InputConstants; import io.github.axolotlclient.AxolotlClientConfig.impl.options.EnumOption; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.navigation.CommonInputs; import net.minecraft.client.gui.screens.Screen; import net.minecraft.network.chat.Component; -import net.minecraft.util.Mth; import org.apache.commons.lang3.ArrayUtils; public class EnumWidget> extends RoundedButtonWidget { @@ -38,24 +40,63 @@ public EnumWidget(int x, int y, int width, int height, EnumOption option) { } @Override - public void onPress() { - cycle(Screen.hasShiftDown() ? -1 : 1); + public boolean mouseClicked(double mouseX, double mouseY, int button) { + if (this.active && this.visible) { + if (this.isValidClickButton(button)) { + boolean bl = this.isMouseOver(mouseX, mouseY); + if (bl) { + this.playDownSound(Minecraft.getInstance().getSoundManager()); + this.cycle(button == 0 ? 1 : -1, true); + return true; + } + } + } + return false; + } + + @Override + public boolean keyPressed(int keyCode, int scanCode, int modifiers) { + if (!this.active || !this.visible) { + return false; + } else if (CommonInputs.selected(keyCode) || keyCode == InputConstants.KEY_RIGHT) { + if (this.cycle(1, false)) { + this.playDownSound(Minecraft.getInstance().getSoundManager()); + return true; + } + } else if(keyCode == InputConstants.KEY_LEFT) { + if (this.cycle(-1, false)) { + this.playDownSound(Minecraft.getInstance().getSoundManager()); + return true; + } + } + return false; } - private void cycle(int delta) { + @Override + protected boolean isValidClickButton(int button) { + return button == 0 || button == 1; + } + + private boolean cycle(int step, boolean wrap) { + if (Screen.hasShiftDown()) { + step *= -1; + } T[] values = option.getClazz().getEnumConstants(); int i = ArrayUtils.indexOf(values, option.get()); - i = Mth.positiveModulo(i + delta, values.length); - option.set(values[i]); + if (!wrap && (i == 0 || i == values.length-1)) { + return false; + } + option.set(values[Math.floorMod(i + step, values.length)]); setMessage(Component.translatable(String.valueOf(option.get()))); + return true; } @Override public boolean mouseScrolled(double mouseX, double mouseY, double scrollX, double scrollY) { if (scrollY > 0.0) { - this.cycle(-1); + this.cycle(-1, true); } else if (scrollY < 0.0) { - this.cycle(1); + this.cycle(1, true); } return true; diff --git a/1.21.4/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/widgets/StringArrayButtonWidget.java b/1.21.4/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/widgets/StringArrayButtonWidget.java index e30dfe96..484de53c 100644 --- a/1.21.4/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/widgets/StringArrayButtonWidget.java +++ b/1.21.4/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/widgets/StringArrayButtonWidget.java @@ -22,12 +22,14 @@ package io.github.axolotlclient.AxolotlClientConfig.impl.ui.rounded.widgets; +import com.mojang.blaze3d.platform.InputConstants; import io.github.axolotlclient.AxolotlClientConfig.impl.options.StringArrayOption; +import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.gui.navigation.CommonInputs; import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.resources.language.I18n; import net.minecraft.network.chat.Component; -import net.minecraft.util.Mth; import org.apache.commons.lang3.ArrayUtils; public class StringArrayButtonWidget extends RoundedButtonWidget { @@ -49,24 +51,63 @@ protected void renderWidget(GuiGraphics graphics, int mouseX, int mouseY, float } @Override - public void onPress() { - cycle(Screen.hasShiftDown() ? -1 : 1); + public boolean mouseClicked(double mouseX, double mouseY, int button) { + if (this.active && this.visible) { + if (this.isValidClickButton(button)) { + boolean bl = this.isMouseOver(mouseX, mouseY); + if (bl) { + this.playDownSound(Minecraft.getInstance().getSoundManager()); + this.cycle(button == 0 ? 1 : -1, true); + return true; + } + } + } + return false; + } + + @Override + public boolean keyPressed(int keyCode, int scanCode, int modifiers) { + if (!this.active || !this.visible) { + return false; + } else if (CommonInputs.selected(keyCode) || keyCode == InputConstants.KEY_RIGHT) { + if (this.cycle(1, false)) { + this.playDownSound(Minecraft.getInstance().getSoundManager()); + return true; + } + } else if (keyCode == InputConstants.KEY_LEFT) { + if (this.cycle(-1, false)) { + this.playDownSound(Minecraft.getInstance().getSoundManager()); + return true; + } + } + return false; } - private void cycle(int delta) { + @Override + protected boolean isValidClickButton(int button) { + return button == 0 || button == 1; + } + + private boolean cycle(int step, boolean wrap) { + if (Screen.hasShiftDown()) { + step *= -1; + } String[] values = option.getValues(); int i = ArrayUtils.indexOf(values, option.get()); - i = Mth.positiveModulo(i + delta, values.length); - option.set(values[i]); - setMessage(Component.translatable(option.get())); + if (!wrap && (i == 0 || i == values.length-1)) { + return false; + } + option.set(values[Math.floorMod(i + step, values.length)]); + setMessage(Component.translatable(String.valueOf(option.get()))); + return true; } @Override public boolean mouseScrolled(double mouseX, double mouseY, double scrollX, double scrollY) { if (scrollY > 0.0) { - this.cycle(-1); + this.cycle(-1, true); } else if (scrollY < 0.0) { - this.cycle(1); + this.cycle(1, true); } return true; diff --git a/1.21.4/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/widgets/TextOnlyButtonWidget.java b/1.21.4/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/widgets/TextOnlyButtonWidget.java index b04daa1f..1f4c0777 100644 --- a/1.21.4/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/widgets/TextOnlyButtonWidget.java +++ b/1.21.4/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/widgets/TextOnlyButtonWidget.java @@ -1,3 +1,25 @@ +/* + * Copyright © 2021-2024 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + package io.github.axolotlclient.AxolotlClientConfig.impl.ui.rounded.widgets; import io.github.axolotlclient.AxolotlClientConfig.impl.ui.rounded.NVGHolder; diff --git a/1.21.4/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/vanilla/widgets/EnumWidget.java b/1.21.4/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/vanilla/widgets/EnumWidget.java index 99c27b36..0b932436 100644 --- a/1.21.4/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/vanilla/widgets/EnumWidget.java +++ b/1.21.4/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/vanilla/widgets/EnumWidget.java @@ -22,11 +22,13 @@ package io.github.axolotlclient.AxolotlClientConfig.impl.ui.vanilla.widgets; +import com.mojang.blaze3d.platform.InputConstants; import io.github.axolotlclient.AxolotlClientConfig.impl.options.EnumOption; +import net.minecraft.client.Minecraft; import net.minecraft.client.gui.components.Button; +import net.minecraft.client.gui.navigation.CommonInputs; import net.minecraft.client.gui.screens.Screen; import net.minecraft.network.chat.Component; -import net.minecraft.util.Mth; import org.apache.commons.lang3.ArrayUtils; public class EnumWidget> extends Button { @@ -39,24 +41,63 @@ public EnumWidget(int x, int y, int width, int height, EnumOption option) { } @Override - public void onPress() { - cycle(Screen.hasShiftDown() ? -1 : 1); + public boolean mouseClicked(double mouseX, double mouseY, int button) { + if (this.active && this.visible) { + if (this.isValidClickButton(button)) { + boolean bl = this.isMouseOver(mouseX, mouseY); + if (bl) { + this.playDownSound(Minecraft.getInstance().getSoundManager()); + this.cycle(button == 0 ? 1 : -1, true); + return true; + } + } + } + return false; + } + + @Override + public boolean keyPressed(int keyCode, int scanCode, int modifiers) { + if (!this.active || !this.visible) { + return false; + } else if (CommonInputs.selected(keyCode) || keyCode == InputConstants.KEY_RIGHT) { + if (this.cycle(1, false)) { + this.playDownSound(Minecraft.getInstance().getSoundManager()); + return true; + } + } else if(keyCode == InputConstants.KEY_LEFT) { + if (this.cycle(-1, false)) { + this.playDownSound(Minecraft.getInstance().getSoundManager()); + return true; + } + } + return false; } - private void cycle(int delta) { + @Override + protected boolean isValidClickButton(int button) { + return button == 0 || button == 1; + } + + private boolean cycle(int step, boolean wrap) { + if (Screen.hasShiftDown()) { + step *= -1; + } T[] values = option.getClazz().getEnumConstants(); int i = ArrayUtils.indexOf(values, option.get()); - i = Mth.positiveModulo(i + delta, values.length); - option.set(values[i]); + if (!wrap && (i == 0 || i == values.length-1)) { + return false; + } + option.set(values[Math.floorMod(i + step, values.length)]); setMessage(Component.translatable(String.valueOf(option.get()))); + return true; } @Override public boolean mouseScrolled(double mouseX, double mouseY, double scrollX, double scrollY) { if (scrollY > 0.0) { - this.cycle(-1); + this.cycle(-1, true); } else if (scrollY < 0.0) { - this.cycle(1); + this.cycle(1, true); } return true; diff --git a/1.21.4/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/vanilla/widgets/StringArrayWidget.java b/1.21.4/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/vanilla/widgets/StringArrayWidget.java index 80e70f22..00757503 100644 --- a/1.21.4/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/vanilla/widgets/StringArrayWidget.java +++ b/1.21.4/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/vanilla/widgets/StringArrayWidget.java @@ -22,12 +22,14 @@ package io.github.axolotlclient.AxolotlClientConfig.impl.ui.vanilla.widgets; +import com.mojang.blaze3d.platform.InputConstants; import io.github.axolotlclient.AxolotlClientConfig.impl.options.StringArrayOption; +import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.Button; +import net.minecraft.client.gui.navigation.CommonInputs; import net.minecraft.client.gui.screens.Screen; import net.minecraft.network.chat.Component; -import net.minecraft.util.Mth; import org.apache.commons.lang3.ArrayUtils; public class StringArrayWidget extends Button { @@ -49,24 +51,63 @@ protected void renderWidget(GuiGraphics graphics, int mouseX, int mouseY, float } @Override - public void onPress() { - cycle(Screen.hasShiftDown() ? -1 : 1); + public boolean mouseClicked(double mouseX, double mouseY, int button) { + if (this.active && this.visible) { + if (this.isValidClickButton(button)) { + boolean bl = this.isMouseOver(mouseX, mouseY); + if (bl) { + this.playDownSound(Minecraft.getInstance().getSoundManager()); + this.cycle(button == 0 ? 1 : -1, true); + return true; + } + } + } + return false; + } + + @Override + public boolean keyPressed(int keyCode, int scanCode, int modifiers) { + if (!this.active || !this.visible) { + return false; + } else if (CommonInputs.selected(keyCode) || keyCode == InputConstants.KEY_RIGHT) { + if (this.cycle(1, false)) { + this.playDownSound(Minecraft.getInstance().getSoundManager()); + return true; + } + } else if (keyCode == InputConstants.KEY_LEFT) { + if (this.cycle(-1, false)) { + this.playDownSound(Minecraft.getInstance().getSoundManager()); + return true; + } + } + return false; } - private void cycle(int delta) { + @Override + protected boolean isValidClickButton(int button) { + return button == 0 || button == 1; + } + + private boolean cycle(int step, boolean wrap) { + if (Screen.hasShiftDown()) { + step *= -1; + } String[] values = option.getValues(); int i = ArrayUtils.indexOf(values, option.get()); - i = Mth.positiveModulo(i + delta, values.length); - option.set(values[i]); - setMessage(Component.translatable(option.get())); + if (!wrap && (i == 0 || i == values.length - 1)) { + return false; + } + option.set(values[Math.floorMod(i + step, values.length)]); + setMessage(Component.translatable(String.valueOf(option.get()))); + return true; } @Override public boolean mouseScrolled(double mouseX, double mouseY, double scrollX, double scrollY) { if (scrollY > 0.0) { - this.cycle(-1); + this.cycle(-1, true); } else if (scrollY < 0.0) { - this.cycle(1); + this.cycle(1, true); } return true; diff --git a/1.21.4/src/test/java/io/github/axolotlclient/AxolotlClientConfig/example/Example.java b/1.21.4/src/test/java/io/github/axolotlclient/AxolotlClientConfig/example/Example.java index 9cf702da..60d6a68c 100644 --- a/1.21.4/src/test/java/io/github/axolotlclient/AxolotlClientConfig/example/Example.java +++ b/1.21.4/src/test/java/io/github/axolotlclient/AxolotlClientConfig/example/Example.java @@ -93,7 +93,8 @@ public void onInitializeClient() { example.add(new BooleanOption("option", false)); example.add(new BooleanOption("other option", true)); example.add(new GraphicsOption("graphics", 40, 40)); - example.add(new EnumOption<>("enum", ExampleEnum.class)); + example.add(new EnumOption<>("enum", TestEnum.class, TestEnum.TEST_ENUM1)); + example.add(new StringArrayOption("another string array", "value 1", "value 2", "value 3")); AxolotlClientConfig.getInstance().register(new JsonConfigManager(FabricLoader.getInstance().getConfigDir().resolve(modid + ".json"), example)); @@ -118,10 +119,10 @@ public void onInitializeClient() { }); } - private enum ExampleEnum { - EXAMPLE1, - EXAMPLE2, - EXAMPLE3 + public enum TestEnum { + TEST_ENUM1, + TEST_ENUM2, + TEST_ENUM3, } public Function getConfigScreenFactory(String name) { diff --git a/1.21.4/src/test/java/io/github/axolotlclient/AxolotlClientConfig/example/mixin/TitleScreenMixin.java b/1.21.4/src/test/java/io/github/axolotlclient/AxolotlClientConfig/example/mixin/TitleScreenMixin.java index b8e2ba9e..67d574d4 100644 --- a/1.21.4/src/test/java/io/github/axolotlclient/AxolotlClientConfig/example/mixin/TitleScreenMixin.java +++ b/1.21.4/src/test/java/io/github/axolotlclient/AxolotlClientConfig/example/mixin/TitleScreenMixin.java @@ -1,3 +1,25 @@ +/* + * Copyright © 2021-2024 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + package io.github.axolotlclient.AxolotlClientConfig.example.mixin; import io.github.axolotlclient.AxolotlClientConfig.example.Example; diff --git a/1.21/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/package-info.java b/1.21/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/package-info.java new file mode 100644 index 00000000..01e664aa --- /dev/null +++ b/1.21/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/package-info.java @@ -0,0 +1,24 @@ +/* + * Copyright © 2021-2025 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +@SuppressWarnings("unused") +package io.github.axolotlclient.AxolotlClientConfig.impl; diff --git a/1.21/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/ButtonListWidget.java b/1.21/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/ButtonListWidget.java index a54e3de0..9b7e5959 100644 --- a/1.21/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/ButtonListWidget.java +++ b/1.21/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/ButtonListWidget.java @@ -144,6 +144,11 @@ protected int getScrollbarPositionX() { return super.getScrollbarPositionX() + 38; } + @Override + public boolean mouseScrolled(double mouseX, double mouseY, double scrollX, double scrollY) { + return getHoveredEntry() != null && getHoveredEntry().mouseScrolled(mouseX, mouseY, scrollX, scrollY) || super.mouseScrolled(mouseX, mouseY, scrollX, scrollY); + } + protected static class Entry extends ElementListWidget.Entry { diff --git a/1.21/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/NVGUtil.java b/1.21/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/NVGUtil.java index 77ff0fed..da89b772 100644 --- a/1.21/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/NVGUtil.java +++ b/1.21/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/NVGUtil.java @@ -1,3 +1,25 @@ +/* + * Copyright © 2021-2024 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + package io.github.axolotlclient.AxolotlClientConfig.impl.ui.rounded; import java.util.function.Consumer; diff --git a/1.21/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/widgets/EnumWidget.java b/1.21/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/widgets/EnumWidget.java index 51dfebbe..abfda835 100644 --- a/1.21/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/widgets/EnumWidget.java +++ b/1.21/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/widgets/EnumWidget.java @@ -23,7 +23,12 @@ package io.github.axolotlclient.AxolotlClientConfig.impl.ui.rounded.widgets; import io.github.axolotlclient.AxolotlClientConfig.impl.options.EnumOption; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.CommonInputs; +import net.minecraft.client.gui.screen.Screen; import net.minecraft.text.Text; +import org.apache.commons.lang3.ArrayUtils; +import org.lwjgl.glfw.GLFW; public class EnumWidget> extends RoundedButtonWidget { private final EnumOption option; @@ -35,17 +40,65 @@ public EnumWidget(int x, int y, int width, int height, EnumOption option) { } @Override - public void onPress() { - T[] values = option.getClazz().getEnumConstants(); - int i = 0; - while (!values[i].equals(option.get())) { - i += 1; + public boolean mouseClicked(double mouseX, double mouseY, int button) { + if (this.active && this.visible) { + if (this.isValidClickButton(button)) { + boolean bl = this.isMouseOver(mouseX, mouseY); + if (bl) { + this.playDownSound(MinecraftClient.getInstance().getSoundManager()); + this.cycle(button == 0 ? 1 : -1, true); + return true; + } + } } - i += 1; - if (i >= values.length) { - i = 0; + return false; + } + + @Override + public boolean keyPressed(int keyCode, int scanCode, int modifiers) { + if (!this.active || !this.visible) { + return false; + } else if (CommonInputs.isToggle(keyCode) || keyCode == GLFW.GLFW_KEY_RIGHT) { + if (this.cycle(1, false)) { + this.playDownSound(MinecraftClient.getInstance().getSoundManager()); + return true; + } + } else if(keyCode == GLFW.GLFW_KEY_LEFT) { + if (this.cycle(-1, false)) { + this.playDownSound(MinecraftClient.getInstance().getSoundManager()); + return true; + } } - option.set(values[i]); + return false; + } + + @Override + protected boolean isValidClickButton(int button) { + return button == 0 || button == 1; + } + + private boolean cycle(int step, boolean wrap) { + if (Screen.hasShiftDown()) { + step *= -1; + } + T[] values = option.getClazz().getEnumConstants(); + int i = ArrayUtils.indexOf(values, option.get()); + if (!wrap && (i == 0 || i == values.length-1)) { + return false; + } + option.set(values[Math.floorMod(i + step, values.length)]); setMessage(Text.translatable(String.valueOf(option.get()))); + return true; + } + + @Override + public boolean mouseScrolled(double mouseX, double mouseY, double scrollX, double scrollY) { + if (scrollY > 0.0) { + this.cycle(-1, true); + } else if (scrollY < 0.0) { + this.cycle(1, true); + } + + return true; } } diff --git a/1.21/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/widgets/StringArrayButtonWidget.java b/1.21/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/widgets/StringArrayButtonWidget.java index 177ed372..2acd8fba 100644 --- a/1.21/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/widgets/StringArrayButtonWidget.java +++ b/1.21/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/widgets/StringArrayButtonWidget.java @@ -23,9 +23,14 @@ package io.github.axolotlclient.AxolotlClientConfig.impl.ui.rounded.widgets; import io.github.axolotlclient.AxolotlClientConfig.impl.options.StringArrayOption; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.CommonInputs; import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.resource.language.I18n; import net.minecraft.text.Text; +import org.apache.commons.lang3.ArrayUtils; +import org.lwjgl.glfw.GLFW; public class StringArrayButtonWidget extends RoundedButtonWidget { @@ -46,17 +51,65 @@ protected void drawWidget(GuiGraphics graphics, int mouseX, int mouseY, float de } @Override - public void onPress() { + public boolean mouseClicked(double mouseX, double mouseY, int button) { + if (this.active && this.visible) { + if (this.isValidClickButton(button)) { + boolean bl = this.isMouseOver(mouseX, mouseY); + if (bl) { + this.playDownSound(MinecraftClient.getInstance().getSoundManager()); + this.cycle(button == 0 ? 1 : -1, true); + return true; + } + } + } + return false; + } + + @Override + public boolean keyPressed(int keyCode, int scanCode, int modifiers) { + if (!this.active || !this.visible) { + return false; + } else if (CommonInputs.isToggle(keyCode) || keyCode == GLFW.GLFW_KEY_RIGHT) { + if (this.cycle(1, false)) { + this.playDownSound(MinecraftClient.getInstance().getSoundManager()); + return true; + } + } else if(keyCode == GLFW.GLFW_KEY_LEFT) { + if (this.cycle(-1, false)) { + this.playDownSound(MinecraftClient.getInstance().getSoundManager()); + return true; + } + } + return false; + } + + @Override + protected boolean isValidClickButton(int button) { + return button == 0 || button == 1; + } + + private boolean cycle(int step, boolean wrap) { + if (Screen.hasShiftDown()) { + step *= -1; + } String[] values = option.getValues(); - int i = 0; - while (!values[i].equals(option.get())) { - i += 1; + int i = ArrayUtils.indexOf(values, option.get()); + if (!wrap && (i == 0 || i == values.length-1)) { + return false; } - i += 1; - if (i >= values.length) { - i = 0; + option.set(values[Math.floorMod(i + step, values.length)]); + setMessage(Text.translatable(String.valueOf(option.get()))); + return true; + } + + @Override + public boolean mouseScrolled(double mouseX, double mouseY, double scrollX, double scrollY) { + if (scrollY > 0.0) { + this.cycle(-1, true); + } else if (scrollY < 0.0) { + this.cycle(1, true); } - option.set(values[i]); - setMessage(Text.translatable(option.get())); + + return true; } } diff --git a/1.21/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/widgets/TextOnlyButtonWidget.java b/1.21/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/widgets/TextOnlyButtonWidget.java index 11857264..2d37d365 100644 --- a/1.21/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/widgets/TextOnlyButtonWidget.java +++ b/1.21/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/widgets/TextOnlyButtonWidget.java @@ -1,3 +1,25 @@ +/* + * Copyright © 2021-2024 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + package io.github.axolotlclient.AxolotlClientConfig.impl.ui.rounded.widgets; import io.github.axolotlclient.AxolotlClientConfig.impl.ui.rounded.NVGHolder; diff --git a/1.21/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/vanilla/EntryListWidget.java b/1.21/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/vanilla/EntryListWidget.java index 935fe7ad..5758a3f2 100644 --- a/1.21/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/vanilla/EntryListWidget.java +++ b/1.21/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/vanilla/EntryListWidget.java @@ -145,6 +145,16 @@ protected int getScrollbarPositionX() { return super.getScrollbarPositionX()-2; } + @Override + protected boolean isZero(int index) { + return true; + } + + @Override + public boolean mouseScrolled(double mouseX, double mouseY, double scrollX, double scrollY) { + return getHoveredEntry() != null && getHoveredEntry().mouseScrolled(mouseX, mouseY, scrollX, scrollY) || super.mouseScrolled(mouseX, mouseY, scrollX, scrollY); + } + protected static class Entry extends ElementListWidget.Entry { diff --git a/1.21/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/vanilla/widgets/EnumWidget.java b/1.21/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/vanilla/widgets/EnumWidget.java index c007c910..454bea96 100644 --- a/1.21/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/vanilla/widgets/EnumWidget.java +++ b/1.21/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/vanilla/widgets/EnumWidget.java @@ -23,8 +23,13 @@ package io.github.axolotlclient.AxolotlClientConfig.impl.ui.vanilla.widgets; import io.github.axolotlclient.AxolotlClientConfig.impl.options.EnumOption; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.CommonInputs; +import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.widget.button.ButtonWidget; import net.minecraft.text.Text; +import org.apache.commons.lang3.ArrayUtils; +import org.lwjgl.glfw.GLFW; public class EnumWidget> extends ButtonWidget { private final EnumOption option; @@ -36,17 +41,65 @@ public EnumWidget(int x, int y, int width, int height, EnumOption option) { } @Override - public void onClick(double mouseX, double mouseY) { - T[] values = option.getClazz().getEnumConstants(); - int i = 0; - while (!values[i].equals(option.get())) { - i += 1; + public boolean mouseClicked(double mouseX, double mouseY, int button) { + if (this.active && this.visible) { + if (this.isValidClickButton(button)) { + boolean bl = this.isMouseOver(mouseX, mouseY); + if (bl) { + this.playDownSound(MinecraftClient.getInstance().getSoundManager()); + this.cycle(button == 0 ? 1 : -1, true); + return true; + } + } } - i += 1; - if (i >= values.length) { - i = 0; + return false; + } + + @Override + public boolean keyPressed(int keyCode, int scanCode, int modifiers) { + if (!this.active || !this.visible) { + return false; + } else if (CommonInputs.isToggle(keyCode) || keyCode == GLFW.GLFW_KEY_RIGHT) { + if (this.cycle(1, false)) { + this.playDownSound(MinecraftClient.getInstance().getSoundManager()); + return true; + } + } else if(keyCode == GLFW.GLFW_KEY_LEFT) { + if (this.cycle(-1, false)) { + this.playDownSound(MinecraftClient.getInstance().getSoundManager()); + return true; + } } - option.set(values[i]); + return false; + } + + @Override + protected boolean isValidClickButton(int button) { + return button == 0 || button == 1; + } + + private boolean cycle(int step, boolean wrap) { + if (Screen.hasShiftDown()) { + step *= -1; + } + T[] values = option.getClazz().getEnumConstants(); + int i = ArrayUtils.indexOf(values, option.get()); + if (!wrap && (i == 0 || i == values.length-1)) { + return false; + } + option.set(values[Math.floorMod(i + step, values.length)]); setMessage(Text.translatable(String.valueOf(option.get()))); + return true; + } + + @Override + public boolean mouseScrolled(double mouseX, double mouseY, double scrollX, double scrollY) { + if (scrollY > 0.0) { + this.cycle(-1, true); + } else if (scrollY < 0.0) { + this.cycle(1, true); + } + + return true; } } diff --git a/1.21/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/vanilla/widgets/StringArrayWidget.java b/1.21/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/vanilla/widgets/StringArrayWidget.java index 50b5714d..9a207790 100644 --- a/1.21/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/vanilla/widgets/StringArrayWidget.java +++ b/1.21/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/vanilla/widgets/StringArrayWidget.java @@ -23,9 +23,14 @@ package io.github.axolotlclient.AxolotlClientConfig.impl.ui.vanilla.widgets; import io.github.axolotlclient.AxolotlClientConfig.impl.options.StringArrayOption; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.CommonInputs; import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.widget.button.ButtonWidget; import net.minecraft.text.Text; +import org.apache.commons.lang3.ArrayUtils; +import org.lwjgl.glfw.GLFW; public class StringArrayWidget extends ButtonWidget { @@ -46,17 +51,65 @@ protected void drawWidget(GuiGraphics graphics, int mouseX, int mouseY, float de } @Override - public void onClick(double mouseX, double mouseY) { + public boolean mouseClicked(double mouseX, double mouseY, int button) { + if (this.active && this.visible) { + if (this.isValidClickButton(button)) { + boolean bl = this.isMouseOver(mouseX, mouseY); + if (bl) { + this.playDownSound(MinecraftClient.getInstance().getSoundManager()); + this.cycle(button == 0 ? 1 : -1, true); + return true; + } + } + } + return false; + } + + @Override + public boolean keyPressed(int keyCode, int scanCode, int modifiers) { + if (!this.active || !this.visible) { + return false; + } else if (CommonInputs.isToggle(keyCode) || keyCode == GLFW.GLFW_KEY_RIGHT) { + if (this.cycle(1, false)) { + this.playDownSound(MinecraftClient.getInstance().getSoundManager()); + return true; + } + } else if (keyCode == GLFW.GLFW_KEY_LEFT) { + if (this.cycle(-1, false)) { + this.playDownSound(MinecraftClient.getInstance().getSoundManager()); + return true; + } + } + return false; + } + + @Override + protected boolean isValidClickButton(int button) { + return button == 0 || button == 1; + } + + private boolean cycle(int step, boolean wrap) { + if (Screen.hasShiftDown()) { + step *= -1; + } String[] values = option.getValues(); - int i = 0; - while (!values[i].equals(option.get())) { - i += 1; + int i = ArrayUtils.indexOf(values, option.get()); + if (!wrap && (i == 0 || i == values.length-1)) { + return false; } - i += 1; - if (i >= values.length) { - i = 0; + option.set(values[Math.floorMod(i + step, values.length)]); + setMessage(Text.translatable(String.valueOf(option.get()))); + return true; + } + + @Override + public boolean mouseScrolled(double mouseX, double mouseY, double scrollX, double scrollY) { + if (scrollY > 0.0) { + this.cycle(-1, false); + } else if (scrollY < 0.0) { + this.cycle(1, false); } - option.set(values[i]); - setMessage(Text.translatable(option.get())); + + return true; } } diff --git a/1.21/src/test/java/io/github/axolotlclient/AxolotlClientConfig/example/Example.java b/1.21/src/test/java/io/github/axolotlclient/AxolotlClientConfig/example/Example.java index 9dfff5fd..08dbdba8 100644 --- a/1.21/src/test/java/io/github/axolotlclient/AxolotlClientConfig/example/Example.java +++ b/1.21/src/test/java/io/github/axolotlclient/AxolotlClientConfig/example/Example.java @@ -93,7 +93,8 @@ public void onInitializeClient() { example.add(new BooleanOption("option", false)); example.add(new BooleanOption("other option", true)); example.add(new GraphicsOption("graphics", 40, 40)); - example.add(new EnumOption<>("enum", ExampleEnum.class)); + example.add(new EnumOption<>("enum", TestEnum.class, TestEnum.TEST_ENUM1)); + example.add(new StringArrayOption("another string array", "value 1", "value 2", "value 3")); AxolotlClientConfig.getInstance().register(new JsonConfigManager(FabricLoader.getInstance().getConfigDir().resolve(modid + ".json"), example)); @@ -118,10 +119,10 @@ public void onInitializeClient() { }); } - private enum ExampleEnum { - EXAMPLE1, - EXAMPLE2, - EXAMPLE3 + public enum TestEnum { + TEST_ENUM1, + TEST_ENUM2, + TEST_ENUM3, } public Function getConfigScreenFactory(String name) { diff --git a/1.21/src/test/java/io/github/axolotlclient/AxolotlClientConfig/example/mixin/TitleScreenMixin.java b/1.21/src/test/java/io/github/axolotlclient/AxolotlClientConfig/example/mixin/TitleScreenMixin.java index 99422f1e..61899dde 100644 --- a/1.21/src/test/java/io/github/axolotlclient/AxolotlClientConfig/example/mixin/TitleScreenMixin.java +++ b/1.21/src/test/java/io/github/axolotlclient/AxolotlClientConfig/example/mixin/TitleScreenMixin.java @@ -1,3 +1,25 @@ +/* + * Copyright © 2021-2024 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + package io.github.axolotlclient.AxolotlClientConfig.example.mixin; import io.github.axolotlclient.AxolotlClientConfig.example.Example; diff --git a/1.8.9/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/package-info.java b/1.8.9/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/package-info.java new file mode 100644 index 00000000..01e664aa --- /dev/null +++ b/1.8.9/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/package-info.java @@ -0,0 +1,24 @@ +/* + * Copyright © 2021-2025 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +@SuppressWarnings("unused") +package io.github.axolotlclient.AxolotlClientConfig.impl; diff --git a/1.8.9/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/Screen.java b/1.8.9/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/Screen.java index 5e97d009..6c7ce4c4 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/Screen.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/Screen.java @@ -68,8 +68,10 @@ public List children() { public void handleMouse() { super.handleMouse(); int scroll = Mouse.getDWheel(); + int x = Mouse.getEventX() * this.width / this.minecraft.width; + int y = this.height - Mouse.getEventY() * this.height / this.minecraft.height - 1; if (scroll != 0) { - children.forEach(e -> e.mouseScrolled(minecraft.mouse.dx, minecraft.mouse.dy, 0, scroll)); + children.forEach(e -> e.mouseScrolled(x, y, 0, scroll)); } } diff --git a/1.8.9/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/ButtonListWidget.java b/1.8.9/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/ButtonListWidget.java index 52af8d64..fb3772c3 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/ButtonListWidget.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/ButtonListWidget.java @@ -143,6 +143,11 @@ protected int getScrollbarPositionX() { return super.getScrollbarPositionX() + 38; } + @Override + public boolean mouseScrolled(double mouseX, double mouseY, double scrollX, double scrollY) { + return getHoveredEntry() != null && getHoveredEntry().mouseScrolled(mouseX, mouseY, scrollX, scrollY) || super.mouseScrolled(mouseX, mouseY, scrollX, scrollY); + } + protected static class Entry extends ElementListWidget.Entry { diff --git a/1.8.9/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/EntryListWidget.java b/1.8.9/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/EntryListWidget.java index 3fe60ae3..c094779b 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/EntryListWidget.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/EntryListWidget.java @@ -132,7 +132,7 @@ protected void replaceEntries(Collection newEntries) { } protected E getEntry(int index) { - return (E) this.children().get(index); + return this.children().get(index); } protected int addEntry(E entry) { @@ -169,9 +169,9 @@ protected final E getEntryAtPosition(double x, double y) { int l = j + i; int m = MathHelper.floor(y - (double) this.top) - this.headerHeight + (int) this.getScrollAmount() - 4; int n = m / this.itemHeight; - return (E) (x < (double) this.getScrollbarPositionX() && x >= (double) k && x <= (double) l && n >= 0 && m >= 0 && n < this.getEntryCount() + return x < (double) this.getScrollbarPositionX() && x >= (double) k && x <= (double) l && n >= 0 && m >= 0 && n < this.getEntryCount() ? this.children().get(n) - : null); + : null; } public void updateSize(int width, int height, int top, int bottom) { @@ -211,7 +211,7 @@ public void render(int mouseX, int mouseY, float delta) { int j = i + 6; Tessellator tessellator = Tessellator.getInstance(); BufferBuilder bufferBuilder = tessellator.getBuilder(); - this.hoveredEntry = this.isMouseOver((double) mouseX, (double) mouseY) ? this.getEntryAtPosition((double) mouseX, (double) mouseY) : null; + this.hoveredEntry = this.isMouseOver(mouseX, mouseY) ? this.getEntryAtPosition(mouseX, mouseY) : null; if (this.renderBackground) { this.client.getTextureManager().bind(GuiElement.BACKGROUND_LOCATION); GlStateManager.color4f(1.0f, 1.0f, 1.0f, 1.0f); @@ -289,7 +289,7 @@ public void render(int mouseX, int mouseY, float delta) { } protected void centerScrollOn(E entry) { - this.setScrollAmount((double) (this.children().indexOf(entry) * this.itemHeight + this.itemHeight / 2 - (this.bottom - this.top) / 2)); + this.setScrollAmount(this.children().indexOf(entry) * this.itemHeight + this.itemHeight / 2 - (this.bottom - this.top) / 2); } protected void ensureVisible(E entry) { @@ -314,7 +314,7 @@ public double getScrollAmount() { } public void setScrollAmount(double amount) { - this.scrollAmount = MathHelper.clamp(amount, 0.0, (double) this.getMaxScroll()); + this.scrollAmount = MathHelper.clamp(amount, 0.0, this.getMaxScroll()); } public int getMaxScroll() { @@ -433,7 +433,7 @@ protected boolean moveSelection(MoveDirection direction, Predicate predicate) break; } - E entry = (E) this.children().get(k); + E entry = this.children().get(k); if (predicate.test(entry)) { this.setSelected(entry); this.ensureVisible(entry); @@ -522,7 +522,7 @@ protected E remove(int index) { protected boolean removeEntry(E entry) { boolean bl = this.children.remove(entry); if (bl && entry == this.getSelectedOrNull()) { - this.setSelected((E) null); + this.setSelected(null); } return bl; @@ -537,9 +537,9 @@ void setEntryParentList(Entry entry) { entry.parentList = this; } - protected static enum MoveDirection { + protected enum MoveDirection { UP, - DOWN; + DOWN } public abstract static class Entry> implements Element { @@ -557,10 +557,10 @@ public boolean isMouseOver(double mouseX, double mouseY) { } class Entries extends AbstractList { - private final List entries = Lists.newArrayList(); + private final List entries = Lists.newArrayList(); public E get(int i) { - return (E) this.entries.get(i); + return this.entries.get(i); } public int size() { @@ -568,7 +568,7 @@ public int size() { } public E set(int i, E entry) { - E entry2 = (E) this.entries.set(i, entry); + E entry2 = this.entries.set(i, entry); EntryListWidget.this.setEntryParentList(entry); return entry2; } @@ -579,7 +579,7 @@ public void add(int i, E entry) { } public E remove(int i) { - return (E) this.entries.remove(i); + return this.entries.remove(i); } } } diff --git a/1.8.9/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/widgets/EnumWidget.java b/1.8.9/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/widgets/EnumWidget.java index b0443aaf..a62d4904 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/widgets/EnumWidget.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/widgets/EnumWidget.java @@ -23,7 +23,11 @@ package io.github.axolotlclient.AxolotlClientConfig.impl.ui.rounded.widgets; import io.github.axolotlclient.AxolotlClientConfig.impl.options.EnumOption; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.resource.language.I18n; +import org.apache.commons.lang3.ArrayUtils; +import org.lwjgl.input.Keyboard; public class EnumWidget> extends RoundedButtonWidget { private final EnumOption option; @@ -35,17 +39,65 @@ public EnumWidget(int x, int y, int width, int height, EnumOption option) { } @Override - public void onPress() { - T[] values = option.getClazz().getEnumConstants(); - int i = 0; - while (!values[i].equals(option.get())) { - i += 1; + public boolean mouseClicked(double mouseX, double mouseY, int button) { + if (this.active && this.visible) { + if (this.isValidClickButton(button)) { + boolean bl = this.isMouseOver(mouseX, mouseY); + if (bl) { + this.playDownSound(Minecraft.getInstance().getSoundManager()); + this.cycle(button == 0 ? 1 : -1, true); + return true; + } + } } - i += 1; - if (i >= values.length) { - i = 0; + return false; + } + + @Override + public boolean keyPressed(int keyCode, int scanCode, int modifiers) { + if (!this.active || !this.visible) { + return false; + } else if (keyCode == Keyboard.KEY_RETURN || keyCode == Keyboard.KEY_SPACE || keyCode == Keyboard.KEY_NUMPADENTER || keyCode == Keyboard.KEY_RIGHT) { + if (this.cycle(1, false)) { + this.playDownSound(Minecraft.getInstance().getSoundManager()); + return true; + } + } else if (keyCode == Keyboard.KEY_LEFT) { + if (this.cycle(-1, false)) { + this.playDownSound(Minecraft.getInstance().getSoundManager()); + return true; + } } - option.set(values[i]); + return false; + } + + @Override + protected boolean isValidClickButton(int button) { + return button == 0 || button == 1; + } + + private boolean cycle(int step, boolean wrap) { + if (Screen.isShiftDown()) { + step *= -1; + } + T[] values = option.getClazz().getEnumConstants(); + int i = ArrayUtils.indexOf(values, option.get()); + if (!wrap && (i == 0 || i == values.length-1)) { + return false; + } + option.set(values[Math.floorMod(i + step, values.length)]); setMessage(I18n.translate(String.valueOf(option.get()))); + return true; + } + + @Override + public boolean mouseScrolled(double mouseX, double mouseY, double scrollX, double scrollY) { + if (scrollY > 0.0) { + this.cycle(-1, true); + } else if (scrollY < 0.0) { + this.cycle(1, true); + } + + return true; } } diff --git a/1.8.9/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/widgets/StringArrayButtonWidget.java b/1.8.9/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/widgets/StringArrayButtonWidget.java index b0e9ea98..2350abd6 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/widgets/StringArrayButtonWidget.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/widgets/StringArrayButtonWidget.java @@ -23,7 +23,11 @@ package io.github.axolotlclient.AxolotlClientConfig.impl.ui.rounded.widgets; import io.github.axolotlclient.AxolotlClientConfig.impl.options.StringArrayOption; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.resource.language.I18n; +import org.apache.commons.lang3.ArrayUtils; +import org.lwjgl.input.Keyboard; public class StringArrayButtonWidget extends RoundedButtonWidget { @@ -44,17 +48,65 @@ public void drawWidget(int mouseX, int mouseY, float delta) { } @Override - public void onPress() { + public boolean mouseClicked(double mouseX, double mouseY, int button) { + if (this.active && this.visible) { + if (this.isValidClickButton(button)) { + boolean bl = this.isMouseOver(mouseX, mouseY); + if (bl) { + this.playDownSound(Minecraft.getInstance().getSoundManager()); + this.cycle(button == 0 ? 1 : -1, true); + return true; + } + } + } + return false; + } + + @Override + public boolean keyPressed(int keyCode, int scanCode, int modifiers) { + if (!this.active || !this.visible) { + return false; + } else if (keyCode == Keyboard.KEY_RETURN || keyCode == Keyboard.KEY_SPACE || keyCode == Keyboard.KEY_NUMPADENTER || keyCode == Keyboard.KEY_RIGHT) { + if (this.cycle(1, false)) { + this.playDownSound(Minecraft.getInstance().getSoundManager()); + return true; + } + } else if (keyCode == Keyboard.KEY_LEFT) { + if (this.cycle(-1, false)) { + this.playDownSound(Minecraft.getInstance().getSoundManager()); + return true; + } + } + return false; + } + + @Override + protected boolean isValidClickButton(int button) { + return button == 0 || button == 1; + } + + private boolean cycle(int step, boolean wrap) { + if (Screen.isShiftDown()) { + step *= -1; + } String[] values = option.getValues(); - int i = 0; - while (!values[i].equals(option.get())) { - i += 1; + int i = ArrayUtils.indexOf(values, option.get()); + if (!wrap && (i == 0 || i == values.length-1)) { + return false; } - i += 1; - if (i >= values.length) { - i = 0; + option.set(values[Math.floorMod(i + step, values.length)]); + setMessage(I18n.translate(String.valueOf(option.get()))); + return true; + } + + @Override + public boolean mouseScrolled(double mouseX, double mouseY, double scrollX, double scrollY) { + if (scrollY > 0.0) { + this.cycle(-1, true); + } else if (scrollY < 0.0) { + this.cycle(1, true); } - option.set(values[i]); - setMessage(I18n.translate(option.get())); + + return true; } } diff --git a/1.8.9/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/widgets/TextOnlyButtonWidget.java b/1.8.9/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/widgets/TextOnlyButtonWidget.java index d6938dd5..1831d967 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/widgets/TextOnlyButtonWidget.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/rounded/widgets/TextOnlyButtonWidget.java @@ -1,3 +1,25 @@ +/* + * Copyright © 2021-2024 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + package io.github.axolotlclient.AxolotlClientConfig.impl.ui.rounded.widgets; import io.github.axolotlclient.AxolotlClientConfig.impl.ui.rounded.NVGHolder; diff --git a/1.8.9/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/vanilla/ButtonListWidget.java b/1.8.9/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/vanilla/ButtonListWidget.java index 91aa9340..fdf34d6d 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/vanilla/ButtonListWidget.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/vanilla/ButtonListWidget.java @@ -151,6 +151,11 @@ protected void renderList(int mouseX, int mouseY, float delta) { DrawUtil.popScissor(); } + @Override + public boolean mouseScrolled(double mouseX, double mouseY, double scrollX, double scrollY) { + return getHoveredEntry() != null && getHoveredEntry().mouseScrolled(mouseX, mouseY, scrollX, scrollY) || super.mouseScrolled(mouseX, mouseY, scrollX, scrollY); + } + protected static class Entry extends ElementListWidget.Entry { diff --git a/1.8.9/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/vanilla/widgets/EnumWidget.java b/1.8.9/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/vanilla/widgets/EnumWidget.java index b5f9fcb9..4853f1b7 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/vanilla/widgets/EnumWidget.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/vanilla/widgets/EnumWidget.java @@ -23,7 +23,11 @@ package io.github.axolotlclient.AxolotlClientConfig.impl.ui.vanilla.widgets; import io.github.axolotlclient.AxolotlClientConfig.impl.options.EnumOption; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.resource.language.I18n; +import org.apache.commons.lang3.ArrayUtils; +import org.lwjgl.input.Keyboard; public class EnumWidget> extends VanillaButtonWidget { private final EnumOption option; @@ -35,17 +39,65 @@ public EnumWidget(int x, int y, int width, int height, EnumOption option) { } @Override - public void onClick(double mouseX, double mouseY) { - T[] values = option.getClazz().getEnumConstants(); - int i = 0; - while (!values[i].equals(option.get())) { - i += 1; + public boolean mouseClicked(double mouseX, double mouseY, int button) { + if (this.active && this.visible) { + if (this.isValidClickButton(button)) { + boolean bl = this.isMouseOver(mouseX, mouseY); + if (bl) { + this.playDownSound(Minecraft.getInstance().getSoundManager()); + this.cycle(button == 0 ? 1 : -1, true); + return true; + } + } } - i += 1; - if (i >= values.length) { - i = 0; + return false; + } + + @Override + public boolean keyPressed(int keyCode, int scanCode, int modifiers) { + if (!this.active || !this.visible) { + return false; + } else if (keyCode == Keyboard.KEY_RETURN || keyCode == Keyboard.KEY_SPACE || keyCode == Keyboard.KEY_NUMPADENTER || keyCode == Keyboard.KEY_RIGHT) { + if (this.cycle(1, false)) { + this.playDownSound(Minecraft.getInstance().getSoundManager()); + return true; + } + } else if (keyCode == Keyboard.KEY_LEFT) { + if (this.cycle(-1, false)) { + this.playDownSound(Minecraft.getInstance().getSoundManager()); + return true; + } } - option.set(values[i]); + return false; + } + + @Override + protected boolean isValidClickButton(int button) { + return button == 0 || button == 1; + } + + private boolean cycle(int step, boolean wrap) { + if (Screen.isShiftDown()) { + step *= -1; + } + T[] values = option.getClazz().getEnumConstants(); + int i = ArrayUtils.indexOf(values, option.get()); + if (!wrap && (i == 0 || i == values.length-1)) { + return false; + } + option.set(values[Math.floorMod(i + step, values.length)]); setMessage(I18n.translate(String.valueOf(option.get()))); + return true; + } + + @Override + public boolean mouseScrolled(double mouseX, double mouseY, double scrollX, double scrollY) { + if (scrollY > 0.0) { + this.cycle(-1, true); + } else if (scrollY < 0.0) { + this.cycle(1, true); + } + + return true; } } diff --git a/1.8.9/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/vanilla/widgets/PlainTextButtonWidget.java b/1.8.9/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/vanilla/widgets/PlainTextButtonWidget.java index e0c97c35..48ce5a47 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/vanilla/widgets/PlainTextButtonWidget.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/vanilla/widgets/PlainTextButtonWidget.java @@ -1,3 +1,25 @@ +/* + * Copyright © 2021-2024 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + package io.github.axolotlclient.AxolotlClientConfig.impl.ui.vanilla.widgets; diff --git a/1.8.9/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/vanilla/widgets/StringArrayWidget.java b/1.8.9/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/vanilla/widgets/StringArrayWidget.java index 63270cb9..7bf49f39 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/vanilla/widgets/StringArrayWidget.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/ui/vanilla/widgets/StringArrayWidget.java @@ -23,7 +23,11 @@ package io.github.axolotlclient.AxolotlClientConfig.impl.ui.vanilla.widgets; import io.github.axolotlclient.AxolotlClientConfig.impl.options.StringArrayOption; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.resource.language.I18n; +import org.apache.commons.lang3.ArrayUtils; +import org.lwjgl.input.Keyboard; public class StringArrayWidget extends VanillaButtonWidget { @@ -44,17 +48,65 @@ public void drawWidget(int mouseX, int mouseY, float delta) { } @Override - public void onClick(double mouseX, double mouseY) { + public boolean mouseClicked(double mouseX, double mouseY, int button) { + if (this.active && this.visible) { + if (this.isValidClickButton(button)) { + boolean bl = this.isMouseOver(mouseX, mouseY); + if (bl) { + this.playDownSound(Minecraft.getInstance().getSoundManager()); + this.cycle(button == 0 ? 1 : -1, true); + return true; + } + } + } + return false; + } + + @Override + public boolean keyPressed(int keyCode, int scanCode, int modifiers) { + if (!this.active || !this.visible) { + return false; + } else if (keyCode == Keyboard.KEY_RETURN || keyCode == Keyboard.KEY_SPACE || keyCode == Keyboard.KEY_NUMPADENTER || keyCode == Keyboard.KEY_RIGHT) { + if (this.cycle(1, false)) { + this.playDownSound(Minecraft.getInstance().getSoundManager()); + return true; + } + } else if (keyCode == Keyboard.KEY_LEFT) { + if (this.cycle(-1, false)) { + this.playDownSound(Minecraft.getInstance().getSoundManager()); + return true; + } + } + return false; + } + + @Override + protected boolean isValidClickButton(int button) { + return button == 0 || button == 1; + } + + private boolean cycle(int step, boolean wrap) { + if (Screen.isShiftDown()) { + step *= -1; + } String[] values = option.getValues(); - int i = 0; - while (!values[i].equals(option.get())) { - i += 1; + int i = ArrayUtils.indexOf(values, option.get()); + if (!wrap && (i == 0 || i == values.length-1)) { + return false; } - i += 1; - if (i >= values.length) { - i = 0; + option.set(values[Math.floorMod(i + step, values.length)]); + setMessage(I18n.translate(String.valueOf(option.get()))); + return true; + } + + @Override + public boolean mouseScrolled(double mouseX, double mouseY, double scrollX, double scrollY) { + if (scrollY > 0.0) { + this.cycle(-1, true); + } else if (scrollY < 0.0) { + this.cycle(1, true); } - option.set(values[i]); - setMessage(I18n.translate(option.get())); + + return true; } } diff --git a/1.8.9/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/util/DrawUtil.java b/1.8.9/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/util/DrawUtil.java index 19de28dd..453a1078 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/util/DrawUtil.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/AxolotlClientConfig/impl/util/DrawUtil.java @@ -184,21 +184,22 @@ public static void drawScrollingText(TextRenderer renderer, String text, int cen } } - public static void drawScrollingText(DrawingUtil drawingUtil, NVGFont font, String text, int i, int j, int k, int l, int m, Color color) { + public static void drawScrollingText(DrawingUtil drawingUtil, NVGFont font, String text, int center, int left, int top, int right, int bottom, Color color) { float textWidth = font.getWidth(text); - int y = (k + m - 9) / 2 + 1; - int width = l - j; + int y = (top + bottom - 9) / 2 + 1; + int width = right - left; if (textWidth > width) { float r = textWidth - width; double d = (double) Minecraft.getTime() / 1000.0; double e = Math.max((double) r * 0.5, 3.0); double f = Math.sin((Math.PI / 2) * Math.cos((Math.PI * 2) * d / e)) / 2.0 + 0.5; double g = MathHelper.clampedLerp(f, 0.0, r); - drawingUtil.pushScissor(NVGHolder.getContext(), j, k, l, m); - drawingUtil.drawString(NVGHolder.getContext(), font, text, j - (int) g, y, color); + drawingUtil.pushScissor(NVGHolder.getContext(), left, top, right-left, bottom-top); + drawingUtil.drawString(NVGHolder.getContext(), font, text, left - (int) g, y, color); drawingUtil.popScissor(NVGHolder.getContext()); } else { - float centerX = MathHelper.clamp(i, j + textWidth / 2, l - textWidth / 2); + float min = left + textWidth / 2; + float centerX = (float) center < min ? min : Math.min((float) center, right - textWidth / 2); drawingUtil.drawCenteredString(NVGHolder.getContext(), font, text, centerX, y, color); } } diff --git a/1.8.9/src/test/java/io/github/axolotlclient/AxolotlClientConfig/example/Example.java b/1.8.9/src/test/java/io/github/axolotlclient/AxolotlClientConfig/example/Example.java index 3da8cadb..47d66f35 100644 --- a/1.8.9/src/test/java/io/github/axolotlclient/AxolotlClientConfig/example/Example.java +++ b/1.8.9/src/test/java/io/github/axolotlclient/AxolotlClientConfig/example/Example.java @@ -89,6 +89,7 @@ public void initClient() { example.add(new BooleanOption("other option", true)); example.add(new GraphicsOption("graphics", 40, 40)); example.add(new EnumOption<>("enum", TestEnum.class, TestEnum.TEST_ENUM1)); + example.add(new StringArrayOption("another string array", "value 1", "value 2", "value 3")); KeyBinding binding = new KeyBinding("test", 0, "test"); KeyBindingEvents.REGISTER_KEYBINDS.register((registry) -> registry.register(binding)); @@ -122,6 +123,7 @@ public void initClient() { public enum TestEnum { TEST_ENUM1, - TEST_ENUM2 + TEST_ENUM2, + TEST_ENUM3, } } diff --git a/common/src/main/java/io/github/axolotlclient/AxolotlClientConfig/api/util/AlphabeticalComparator.java b/common/src/main/java/io/github/axolotlclient/AxolotlClientConfig/api/util/AlphabeticalComparator.java index b6cebb98..0415bb8d 100644 --- a/common/src/main/java/io/github/axolotlclient/AxolotlClientConfig/api/util/AlphabeticalComparator.java +++ b/common/src/main/java/io/github/axolotlclient/AxolotlClientConfig/api/util/AlphabeticalComparator.java @@ -1,3 +1,25 @@ +/* + * Copyright © 2021-2024 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + package io.github.axolotlclient.AxolotlClientConfig.api.util; import java.util.Arrays; diff --git a/gradle.properties b/gradle.properties index f5c911ec..0c689061 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,7 +3,7 @@ org.gradle.jvmargs=-Xmx1G org.gradle.parallel=true # Mod Properties -version=3.0.2 +version=3.0.3 maven_group=io.github.axolotlclient archives_base_name=AxolotlClientConfig