Skip to content

Commit

Permalink
Update to 1.21.4, bump deps, bump Kotlin
Browse files Browse the repository at this point in the history
  • Loading branch information
isXander committed Dec 4, 2024
1 parent 8aa2379 commit 294798b
Show file tree
Hide file tree
Showing 19 changed files with 142 additions and 49 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ build
.gradle
!.gitkeep
/.architectury-transformer
/.kotlin/
6 changes: 3 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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")
Expand Down
21 changes: 13 additions & 8 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
# 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
- MinecraftForge 1.20.1

## 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
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 2 additions & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pluginManagement {
}

plugins {
id("dev.kikugie.stonecutter") version "0.4.5"
id("dev.kikugie.stonecutter") version "0.4.6"
}

extensions.configure<StonecutterSettings> {
Expand All @@ -27,6 +27,7 @@ extensions.configure<StonecutterSettings> {
}
}

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"))
Expand Down
83 changes: 65 additions & 18 deletions src/main/java/dev/isxander/yacl3/gui/ElementListWidgetExt.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -17,21 +18,26 @@
public class ElementListWidgetExt<E extends ElementListWidgetExt.Entry<E>> extends ContainerObjectSelectionList<E> 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
Expand All @@ -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)
Expand All @@ -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;

Expand All @@ -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;
}

Expand All @@ -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;
Expand All @@ -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;
}

Expand All @@ -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;
Expand All @@ -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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/dev/isxander/yacl3/gui/OptionListWidget.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
//?}
}
1 change: 1 addition & 0 deletions src/main/resources/yacl.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"defaultRequire": 1
},
"client": [
"AbstractSelectionListAccessor",
"AbstractSelectionListMixin",
"MinecraftMixin",
"OptionInstanceAccessor",
Expand Down
4 changes: 2 additions & 2 deletions stonecutter.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion versions/1.20.1-forge/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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,)
Expand Down
2 changes: 1 addition & 1 deletion versions/1.20.4-neoforge/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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,)
Expand Down
2 changes: 1 addition & 1 deletion versions/1.20.6-neoforge/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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,)
Expand Down
2 changes: 1 addition & 1 deletion versions/1.21-neoforge/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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,)
Expand Down
4 changes: 2 additions & 2 deletions versions/1.21.2-fabric/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading

0 comments on commit 294798b

Please sign in to comment.