diff --git a/.gitignore b/.gitignore index fa11b06..bf897d6 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ build .gradle !.gitkeep /.architectury-transformer +/.kotlin/ diff --git a/build.gradle.kts b/build.gradle.kts index 63ff8c1..260c0d1 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -20,7 +20,7 @@ val isForgeLike = isNeoforge || isForge val mcVersion = findProperty("mcVersion").toString() group = "dev.isxander" -val versionWithoutMC = "3.6.1" +val versionWithoutMC = "3.6.2" version = "$versionWithoutMC+${stonecutter.current.project}" val snapshotVer = "${grgit.branch.current().name.replace('/', '.')}-SNAPSHOT" @@ -130,12 +130,12 @@ dependencies { if (isNeoforge) { "neoForge"("net.neoforged:neoforge:${findProperty("deps.neoforge")}") - modImplementation("thedarkcolour:kotlinforforge-neoforge:${findProperty("deps.kotlinForForge")}") + modRuntimeOnly("thedarkcolour:kotlinforforge-neoforge:${findProperty("deps.kotlinForForge")}") } if (isForge) { "forge"("net.minecraftforge:forge:${findProperty("deps.forge")}") - modImplementation("thedarkcolour:kotlinforforge:${findProperty("deps.kotlinForForge")}") + modRuntimeOnly("thedarkcolour:kotlinforforge:${findProperty("deps.kotlinForForge")}") // enable when it's needed // val mixinExtras = findProperty("deps.mixinExtras") diff --git a/changelog.md b/changelog.md index 2ccec03..0d1f243 100644 --- a/changelog.md +++ b/changelog.md @@ -1,12 +1,16 @@ -# YetAnotherConfigLib 3.6.1 +# YetAnotherConfigLib 3.6.2 -This build supports the following versions: -- Fabric 1.21.2 -- NeoForge 1.21.2 +This version of YACL has many different version targets. +Ensure you download the correct version of YACL for your MC version. + +- Fabric 1.21.4 +- Fabric 1.21.2 (also supports 1.21.3) - Fabric 1.20.1 - Fabric 1.20.4 - Fabric 1.20.6 (also supports 1.20.5) - Fabric 1.21 +- NeoForge 1.21.4 +- NeoForge 1.21.2 (also supports 1.21.3) - NeoForge 1.21 - NeoForge 1.20.6 (also supports 1.20.5) - NeoForge 1.20.4 @@ -14,7 +18,8 @@ This build supports the following versions: ## Changes -- Add 1.21.2 build for NeoForge -- Fix not being able to type negative numbers into number field controllers () -- Fix default range of floating point field controllers being 0-MAX instead of MIN-MAX ([#213](https://github.com/isXander/YetAnotherConfigLib/pull/213)) -- Update translations +- Update to support 1.21.4 (many thanks to Riflusso for this port) +- Add `groupIf` to `ConfigCategory.Builder` (thanks Kevin) +- Pass down middle-mouse clicks to widgets in ElementListWidgetExt (thanks Protonull) +- Fix Greek translation (many thanks to Darkhax for this) +- Update Kotlin to 2.0.21 diff --git a/gradle.properties b/gradle.properties index eaa637b..4de9649 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,9 +9,9 @@ modId=yet_another_config_lib_v3 modName=YetAnotherConfigLib modDescription=YetAnotherConfigLib (yacl) is just that. A builder-based configuration library for Minecraft. -deps.fabricLoader=0.16.7 -deps.imageio=3.10.0 +deps.fabricLoader=0.16.9 +deps.imageio=3.12.0 deps.quiltParsers=0.2.1 -deps.mixinExtras=0.3.5 -deps.fabricLangKotlin=1.10.19+kotlin.1.9.23 -deps.kotlinForForge=4.10.0 +deps.mixinExtras=0.4.1 +deps.fabricLangKotlin=1.12.3+kotlin.2.0.21 +deps.kotlinForForge=5.6.0 diff --git a/settings.gradle.kts b/settings.gradle.kts index b38845f..58b0b04 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -14,7 +14,7 @@ pluginManagement { } plugins { - id("dev.kikugie.stonecutter") version "0.4.5" + id("dev.kikugie.stonecutter") version "0.4.6" } extensions.configure { @@ -27,6 +27,7 @@ extensions.configure { } } + mc("1.21.4", loaders = listOf("fabric", "neoforge")) mc("1.21.2", loaders = listOf("fabric", "neoforge")) mc("1.21", loaders = listOf("fabric", "neoforge")) mc("1.20.6", loaders = listOf("fabric", "neoforge")) diff --git a/src/main/java/dev/isxander/yacl3/gui/ElementListWidgetExt.java b/src/main/java/dev/isxander/yacl3/gui/ElementListWidgetExt.java index 5428f48..a7653ce 100644 --- a/src/main/java/dev/isxander/yacl3/gui/ElementListWidgetExt.java +++ b/src/main/java/dev/isxander/yacl3/gui/ElementListWidgetExt.java @@ -1,6 +1,7 @@ package dev.isxander.yacl3.gui; import com.mojang.blaze3d.platform.InputConstants; +import dev.isxander.yacl3.mixin.AbstractSelectionListAccessor; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.AbstractWidget; @@ -17,21 +18,26 @@ public class ElementListWidgetExt> extends ContainerObjectSelectionList implements LayoutElement { protected static final int SCROLLBAR_WIDTH = 6; - private double smoothScrollAmount = getScrollAmount(); + private double smoothScrollAmount = scrollAmount(); private boolean returnSmoothAmount = false; private final boolean doSmoothScrolling; private boolean usingScrollbar; public ElementListWidgetExt(Minecraft client, int x, int y, int width, int height, boolean smoothScrolling) { - /*? if >1.20.2 {*/ - super(client, width, x, y, height); - /*?} else {*/ + //? if >=1.21.4 { + super(client, width, x, y, height, 0); + ((AbstractSelectionListAccessor) this).setRenderHeader(false); + //?} elif >=1.20.3 { + /*super(client, width, x, y, height); + *///?} else { /*super(client, width, height, y, y + height, 22); this.x0 = x; this.x1 = x + width; - *//*?}*/ + *///?} this.doSmoothScrolling = smoothScrolling; - setRenderHeader(false, 0); + + //? if <1.21.4 + /*setRenderHeader(false, 0);*/ } @Override @@ -42,16 +48,35 @@ public boolean mouseScrolled(double mouseX, double mouseY, /*? if >1.20.2 {*/ do /*?}*/ // default implementation bases scroll step from total height of entries, this is constant - this.setScrollAmount(this.getScrollAmount() - scroll * 20); + this.setScrollAmount(this.scrollAmount() - scroll * 20); return true; } + //? if <1.21.4 { + /*protected int scrollBarX() { + return this.getScrollbarPosition(); + } @Override protected int getScrollbarPosition() { + *///?} else { + @Override + protected int scrollBarX() { + //?} // default implementation does not respect left/right return this.getX() + this.getWidth() - SCROLLBAR_WIDTH; } + //? if >=1.21.4 { + @Override + protected int scrollBarY() { + return Math.max(this.getY(), (int)scrollAmount() * (this.height - this.scrollerHeight()) / this.maxScrollAmount() + this.getY()); + } + //?} else { + /*protected int maxScrollAmount() { + return this.getMaxPosition(); + } + *///?} + @Override /*? if >1.20.2 {*/ public void renderWidget(GuiGraphics graphics, int mouseX, int mouseY, float delta) @@ -66,7 +91,7 @@ public void renderWidget(GuiGraphics graphics, int mouseX, int mouseY, float del smoothScrollAmount = Mth.lerp( delta * 0.5, smoothScrollAmount, - getScrollAmount() + scrollAmount() ); returnSmoothAmount = true; @@ -84,16 +109,16 @@ public void renderWidget(GuiGraphics graphics, int mouseX, int mouseY, float del returnSmoothAmount = false; } - /*? if >1.20.1 {*/ - @Override - /*?}*/ + /*? if >1.20.1 && <1.21.4 {*/ + /*@Override + *//*?}*/ protected boolean isValidMouseClick(int button) { return button == InputConstants.MOUSE_BUTTON_LEFT || button == InputConstants.MOUSE_BUTTON_RIGHT || button == InputConstants.MOUSE_BUTTON_MIDDLE; } @Override public boolean mouseClicked(double mouseX, double mouseY, int button) { - if (button == 0 && mouseX >= getScrollbarPosition() && mouseX < getScrollbarPosition() + SCROLLBAR_WIDTH) { + if (button == 0 && mouseX >= scrollBarX() && mouseX < scrollBarX() + SCROLLBAR_WIDTH) { usingScrollbar = true; } @@ -120,22 +145,36 @@ public void updateDimensions(ScreenRectangle rectangle) { * awful code to only use smooth scroll state when rendering, * not other code that needs target scroll amount */ + //? if <1.21.4 { + /*// backwards compatible method to reduce stonecutter comments + protected double scrollAmount() { + return this.getScrollAmount(); + } + @Override public double getScrollAmount() { + *///?} else { + @Override + public double scrollAmount() { + //?} if (returnSmoothAmount && doSmoothScrolling) return smoothScrollAmount; - return super.getScrollAmount(); + //? if >=1.21.4 { + return super.scrollAmount(); + //?} else { + /*return super.getScrollAmount(); + *///?} } protected void resetSmoothScrolling() { - this.smoothScrollAmount = super.getScrollAmount(); + this.smoothScrollAmount = /*? if >=1.21.4 {*/super.scrollAmount()/*?} else {*//*super.getScrollAmount()*//*?}*/; } @Nullable @Override protected E getEntryAtPosition(double x, double y) { - y += getScrollAmount(); + y += scrollAmount(); if (x < this.getX() || x > this.getX() + this.getWidth()) return null; @@ -159,8 +198,16 @@ protected E getEntryAtPosition(double x, double y) { code is responsible for having dynamic item heights */ + //? if <1.21.4 { + /*protected int contentHeight() { + return this.getMaxPosition(); + } @Override protected int getMaxPosition() { + *///?} else { + @Override + protected int contentHeight() { + //?} return children().stream().map(E::getItemHeight).reduce(0, Integer::sum) + headerHeight; } @@ -175,7 +222,7 @@ protected void centerScrollOn(E entry) { @Override /*? if >=1.21.2 {*/ public /*?} else {*/ /*protected *//*?}*/ int getRowTop(int index) { - int integer = getY() + 4 - (int) this.getScrollAmount() + headerHeight; + int integer = getY() + 4 - (int) this.scrollAmount() + headerHeight; for (int i = 0; i < children().size() && i < index; i++) integer += children().get(i).getItemHeight(); return integer; @@ -186,12 +233,12 @@ protected void ensureVisible(E entry) { int i = this.getRowTop(this.children().indexOf(entry)); int j = i - this.getY() - 4 - entry.getItemHeight(); if (j < 0) { - this.setScrollAmount(this.getScrollAmount() + j); + this.setScrollAmount(this.scrollAmount() + j); } int k = this.getY() + this.getHeight() - i - entry.getItemHeight() * 2; if (k < 0) { - this.setScrollAmount(this.getScrollAmount() - k); + this.setScrollAmount(this.scrollAmount() - k); } } diff --git a/src/main/java/dev/isxander/yacl3/gui/OptionDescriptionWidget.java b/src/main/java/dev/isxander/yacl3/gui/OptionDescriptionWidget.java index 4ca3ad3..0f9384e 100644 --- a/src/main/java/dev/isxander/yacl3/gui/OptionDescriptionWidget.java +++ b/src/main/java/dev/isxander/yacl3/gui/OptionDescriptionWidget.java @@ -175,7 +175,8 @@ public void tick() { } private Style getDescStyle(int mouseX, int mouseY) { - if (!clicked(mouseX, mouseY)) + boolean clicked = /*? if >=1.21.4 {*/ isMouseOver(mouseX, mouseY) /*?} else {*/ /*clicked(mouseX, mouseY) *//*?}*/; + if (!clicked) return null; int x = mouseX - getX(); diff --git a/src/main/java/dev/isxander/yacl3/gui/OptionListWidget.java b/src/main/java/dev/isxander/yacl3/gui/OptionListWidget.java index 51f53b3..c4c6685 100644 --- a/src/main/java/dev/isxander/yacl3/gui/OptionListWidget.java +++ b/src/main/java/dev/isxander/yacl3/gui/OptionListWidget.java @@ -227,9 +227,9 @@ public void addEntryBelow(Entry below, Entry entry) { } public void addEntryBelowWithoutScroll(Entry below, Entry entry) { - double d = (double)this.getMaxScroll() - this.getScrollAmount(); + double d = (double)this.contentHeight() - this.scrollAmount(); addEntryBelow(below, entry); - setScrollAmount(getMaxScroll() - d); + setScrollAmount(this.contentHeight() - d); } @Override diff --git a/src/main/java/dev/isxander/yacl3/mixin/AbstractSelectionListAccessor.java b/src/main/java/dev/isxander/yacl3/mixin/AbstractSelectionListAccessor.java new file mode 100644 index 0000000..18769ee --- /dev/null +++ b/src/main/java/dev/isxander/yacl3/mixin/AbstractSelectionListAccessor.java @@ -0,0 +1,13 @@ +package dev.isxander.yacl3.mixin; + +import net.minecraft.client.gui.components.AbstractSelectionList; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +@Mixin(AbstractSelectionList.class) +public interface AbstractSelectionListAccessor { + //? if >=1.21.4 { + @Accessor + void setRenderHeader(boolean render); + //?} +} diff --git a/src/main/resources/yacl.mixins.json b/src/main/resources/yacl.mixins.json index 2385a1b..544e9c4 100644 --- a/src/main/resources/yacl.mixins.json +++ b/src/main/resources/yacl.mixins.json @@ -6,6 +6,7 @@ "defaultRequire": 1 }, "client": [ + "AbstractSelectionListAccessor", "AbstractSelectionListMixin", "MinecraftMixin", "OptionInstanceAccessor", diff --git a/stonecutter.gradle.kts b/stonecutter.gradle.kts index 5d77d3c..729aead 100644 --- a/stonecutter.gradle.kts +++ b/stonecutter.gradle.kts @@ -2,12 +2,12 @@ plugins { id("dev.kikugie.stonecutter") id("dev.architectury.loom") version "1.7.+" apply false - kotlin("jvm") version "1.9.23" apply false + kotlin("jvm") version "2.0.21" apply false id("me.modmuss50.mod-publish-plugin") version "0.5.+" apply false id("org.ajoberstar.grgit") version "5.0.+" apply false } -stonecutter active "1.21.2-fabric" /* [SC] DO NOT EDIT */ +stonecutter active "1.21.4-fabric" /* [SC] DO NOT EDIT */ stonecutter.configureEach { val platform = project.property("loom.platform") diff --git a/versions/1.20.1-forge/gradle.properties b/versions/1.20.1-forge/gradle.properties index 3bdc7f0..ad8179f 100644 --- a/versions/1.20.1-forge/gradle.properties +++ b/versions/1.20.1-forge/gradle.properties @@ -4,7 +4,7 @@ mcVersion=1.20.1 java.version=17 deps.quiltMappings=23 -deps.forge=1.20.1-47.2.23 +deps.forge=1.20.1-47.3.12 modstoml.mcDep=[1.20,1.20.1] modstoml.loaderVersion=[46,) diff --git a/versions/1.20.4-neoforge/gradle.properties b/versions/1.20.4-neoforge/gradle.properties index 4419b8e..3d95d93 100644 --- a/versions/1.20.4-neoforge/gradle.properties +++ b/versions/1.20.4-neoforge/gradle.properties @@ -4,7 +4,7 @@ mcVersion=1.20.4 java.version=17 deps.quiltMappings=3 -deps.neoforge=20.4.130-beta +deps.neoforge=20.4.237 modstoml.mcDep=[1.20.4] modstoml.loaderVersion=[1,) diff --git a/versions/1.20.6-neoforge/gradle.properties b/versions/1.20.6-neoforge/gradle.properties index 4fee88d..2d1eec0 100644 --- a/versions/1.20.6-neoforge/gradle.properties +++ b/versions/1.20.6-neoforge/gradle.properties @@ -4,7 +4,7 @@ mcVersion=1.20.6 java.version=21 deps.quiltMappings= -deps.neoforge=20.6.87-beta +deps.neoforge=20.6.121 modstoml.mcDep=[1.20.5,1.20.6] modstoml.loaderVersion=[1,) diff --git a/versions/1.21-neoforge/gradle.properties b/versions/1.21-neoforge/gradle.properties index 82c5b09..2957989 100644 --- a/versions/1.21-neoforge/gradle.properties +++ b/versions/1.21-neoforge/gradle.properties @@ -4,7 +4,7 @@ mcVersion=1.21 java.version=21 deps.quiltMappings= -deps.neoforge=21.0.0-beta +deps.neoforge=21.0.167 modstoml.mcDep=[1.21,1.21.1] modstoml.loaderVersion=[1,) diff --git a/versions/1.21.2-fabric/gradle.properties b/versions/1.21.2-fabric/gradle.properties index 8b9c294..b7588f1 100644 --- a/versions/1.21.2-fabric/gradle.properties +++ b/versions/1.21.2-fabric/gradle.properties @@ -5,6 +5,6 @@ java.version=21 deps.quiltMappings= deps.fabricApi=0.106.0+1.21.2 -fmj.mcDep=~1.21.2- +fmj.mcDep=~1.21.2 <1.21.4 -pub.stableMC=1.21.2 +pub.stableMC=1.21.2,1.21.3 diff --git a/versions/1.21.2-neoforge/gradle.properties b/versions/1.21.2-neoforge/gradle.properties index 4b20d2a..cfd12e9 100644 --- a/versions/1.21.2-neoforge/gradle.properties +++ b/versions/1.21.2-neoforge/gradle.properties @@ -4,11 +4,11 @@ mcVersion=1.21.2 java.version=21 deps.quiltMappings= -deps.neoforge=21.2.0-beta +deps.neoforge=21.2.1-beta -modstoml.mcDep=[1.21.2,1.22) +modstoml.mcDep=[1.21.2,1.21.4] modstoml.loaderVersion=[1,) modstoml.forgeId=neoforge modstoml.forgeConstraint=[21,) -pub.stableMC=1.21.2 +pub.stableMC=1.21.2,1.21.3 diff --git a/versions/1.21.4-fabric/gradle.properties b/versions/1.21.4-fabric/gradle.properties new file mode 100644 index 0000000..45e9e78 --- /dev/null +++ b/versions/1.21.4-fabric/gradle.properties @@ -0,0 +1,10 @@ +loom.platform=fabric +mcVersion=1.21.4 + +java.version=21 + +deps.quiltMappings= +deps.fabricApi=0.110.5+1.21.4 +fmj.mcDep=~1.21.4 + +pub.stableMC=1.21.4 diff --git a/versions/1.21.4-neoforge/gradle.properties b/versions/1.21.4-neoforge/gradle.properties new file mode 100644 index 0000000..3fe325f --- /dev/null +++ b/versions/1.21.4-neoforge/gradle.properties @@ -0,0 +1,14 @@ +loom.platform=neoforge +mcVersion=1.21.4 + +java.version=21 + +deps.quiltMappings= +deps.neoforge=21.4.3-beta + +modstoml.mcDep=[1.21.4,1.22) +modstoml.loaderVersion=[1,) +modstoml.forgeId=neoforge +modstoml.forgeConstraint=[21,) + +pub.stableMC=1.21.4