Skip to content

Commit 294798b

Browse files
committed
Update to 1.21.4, bump deps, bump Kotlin
1 parent 8aa2379 commit 294798b

19 files changed

+142
-49
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ build
44
.gradle
55
!.gitkeep
66
/.architectury-transformer
7+
/.kotlin/

build.gradle.kts

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ val isForgeLike = isNeoforge || isForge
2020
val mcVersion = findProperty("mcVersion").toString()
2121

2222
group = "dev.isxander"
23-
val versionWithoutMC = "3.6.1"
23+
val versionWithoutMC = "3.6.2"
2424
version = "$versionWithoutMC+${stonecutter.current.project}"
2525

2626
val snapshotVer = "${grgit.branch.current().name.replace('/', '.')}-SNAPSHOT"
@@ -130,12 +130,12 @@ dependencies {
130130
if (isNeoforge) {
131131
"neoForge"("net.neoforged:neoforge:${findProperty("deps.neoforge")}")
132132

133-
modImplementation("thedarkcolour:kotlinforforge-neoforge:${findProperty("deps.kotlinForForge")}")
133+
modRuntimeOnly("thedarkcolour:kotlinforforge-neoforge:${findProperty("deps.kotlinForForge")}")
134134
}
135135
if (isForge) {
136136
"forge"("net.minecraftforge:forge:${findProperty("deps.forge")}")
137137

138-
modImplementation("thedarkcolour:kotlinforforge:${findProperty("deps.kotlinForForge")}")
138+
modRuntimeOnly("thedarkcolour:kotlinforforge:${findProperty("deps.kotlinForForge")}")
139139

140140
// enable when it's needed
141141
// val mixinExtras = findProperty("deps.mixinExtras")

changelog.md

+13-8
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,25 @@
1-
# YetAnotherConfigLib 3.6.1
1+
# YetAnotherConfigLib 3.6.2
22

3-
This build supports the following versions:
4-
- Fabric 1.21.2
5-
- NeoForge 1.21.2
3+
This version of YACL has many different version targets.
4+
Ensure you download the correct version of YACL for your MC version.
5+
6+
- Fabric 1.21.4
7+
- Fabric 1.21.2 (also supports 1.21.3)
68
- Fabric 1.20.1
79
- Fabric 1.20.4
810
- Fabric 1.20.6 (also supports 1.20.5)
911
- Fabric 1.21
12+
- NeoForge 1.21.4
13+
- NeoForge 1.21.2 (also supports 1.21.3)
1014
- NeoForge 1.21
1115
- NeoForge 1.20.6 (also supports 1.20.5)
1216
- NeoForge 1.20.4
1317
- MinecraftForge 1.20.1
1418

1519
## Changes
1620

17-
- Add 1.21.2 build for NeoForge
18-
- Fix not being able to type negative numbers into number field controllers ()
19-
- Fix default range of floating point field controllers being 0-MAX instead of MIN-MAX ([#213](https://github.com/isXander/YetAnotherConfigLib/pull/213))
20-
- Update translations
21+
- Update to support 1.21.4 (many thanks to Riflusso for this port)
22+
- Add `groupIf` to `ConfigCategory.Builder` (thanks Kevin)
23+
- Pass down middle-mouse clicks to widgets in ElementListWidgetExt (thanks Protonull)
24+
- Fix Greek translation (many thanks to Darkhax for this)
25+
- Update Kotlin to 2.0.21

gradle.properties

+5-5
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ modId=yet_another_config_lib_v3
99
modName=YetAnotherConfigLib
1010
modDescription=YetAnotherConfigLib (yacl) is just that. A builder-based configuration library for Minecraft.
1111

12-
deps.fabricLoader=0.16.7
13-
deps.imageio=3.10.0
12+
deps.fabricLoader=0.16.9
13+
deps.imageio=3.12.0
1414
deps.quiltParsers=0.2.1
15-
deps.mixinExtras=0.3.5
16-
deps.fabricLangKotlin=1.10.19+kotlin.1.9.23
17-
deps.kotlinForForge=4.10.0
15+
deps.mixinExtras=0.4.1
16+
deps.fabricLangKotlin=1.12.3+kotlin.2.0.21
17+
deps.kotlinForForge=5.6.0

settings.gradle.kts

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pluginManagement {
1414
}
1515

1616
plugins {
17-
id("dev.kikugie.stonecutter") version "0.4.5"
17+
id("dev.kikugie.stonecutter") version "0.4.6"
1818
}
1919

2020
extensions.configure<StonecutterSettings> {
@@ -27,6 +27,7 @@ extensions.configure<StonecutterSettings> {
2727
}
2828
}
2929

30+
mc("1.21.4", loaders = listOf("fabric", "neoforge"))
3031
mc("1.21.2", loaders = listOf("fabric", "neoforge"))
3132
mc("1.21", loaders = listOf("fabric", "neoforge"))
3233
mc("1.20.6", loaders = listOf("fabric", "neoforge"))

src/main/java/dev/isxander/yacl3/gui/ElementListWidgetExt.java

+65-18
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package dev.isxander.yacl3.gui;
22

33
import com.mojang.blaze3d.platform.InputConstants;
4+
import dev.isxander.yacl3.mixin.AbstractSelectionListAccessor;
45
import net.minecraft.client.Minecraft;
56
import net.minecraft.client.gui.GuiGraphics;
67
import net.minecraft.client.gui.components.AbstractWidget;
@@ -17,21 +18,26 @@
1718
public class ElementListWidgetExt<E extends ElementListWidgetExt.Entry<E>> extends ContainerObjectSelectionList<E> implements LayoutElement {
1819
protected static final int SCROLLBAR_WIDTH = 6;
1920

20-
private double smoothScrollAmount = getScrollAmount();
21+
private double smoothScrollAmount = scrollAmount();
2122
private boolean returnSmoothAmount = false;
2223
private final boolean doSmoothScrolling;
2324
private boolean usingScrollbar;
2425

2526
public ElementListWidgetExt(Minecraft client, int x, int y, int width, int height, boolean smoothScrolling) {
26-
/*? if >1.20.2 {*/
27-
super(client, width, x, y, height);
28-
/*?} else {*/
27+
//? if >=1.21.4 {
28+
super(client, width, x, y, height, 0);
29+
((AbstractSelectionListAccessor) this).setRenderHeader(false);
30+
//?} elif >=1.20.3 {
31+
/*super(client, width, x, y, height);
32+
*///?} else {
2933
/*super(client, width, height, y, y + height, 22);
3034
this.x0 = x;
3135
this.x1 = x + width;
32-
*//*?}*/
36+
*///?}
3337
this.doSmoothScrolling = smoothScrolling;
34-
setRenderHeader(false, 0);
38+
39+
//? if <1.21.4
40+
/*setRenderHeader(false, 0);*/
3541
}
3642

3743
@Override
@@ -42,16 +48,35 @@ public boolean mouseScrolled(double mouseX, double mouseY, /*? if >1.20.2 {*/ do
4248
/*?}*/
4349

4450
// default implementation bases scroll step from total height of entries, this is constant
45-
this.setScrollAmount(this.getScrollAmount() - scroll * 20);
51+
this.setScrollAmount(this.scrollAmount() - scroll * 20);
4652
return true;
4753
}
4854

55+
//? if <1.21.4 {
56+
/*protected int scrollBarX() {
57+
return this.getScrollbarPosition();
58+
}
4959
@Override
5060
protected int getScrollbarPosition() {
61+
*///?} else {
62+
@Override
63+
protected int scrollBarX() {
64+
//?}
5165
// default implementation does not respect left/right
5266
return this.getX() + this.getWidth() - SCROLLBAR_WIDTH;
5367
}
5468

69+
//? if >=1.21.4 {
70+
@Override
71+
protected int scrollBarY() {
72+
return Math.max(this.getY(), (int)scrollAmount() * (this.height - this.scrollerHeight()) / this.maxScrollAmount() + this.getY());
73+
}
74+
//?} else {
75+
/*protected int maxScrollAmount() {
76+
return this.getMaxPosition();
77+
}
78+
*///?}
79+
5580
@Override
5681
/*? if >1.20.2 {*/
5782
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
6691
smoothScrollAmount = Mth.lerp(
6792
delta * 0.5,
6893
smoothScrollAmount,
69-
getScrollAmount()
94+
scrollAmount()
7095
);
7196
returnSmoothAmount = true;
7297

@@ -84,16 +109,16 @@ public void renderWidget(GuiGraphics graphics, int mouseX, int mouseY, float del
84109
returnSmoothAmount = false;
85110
}
86111

87-
/*? if >1.20.1 {*/
88-
@Override
89-
/*?}*/
112+
/*? if >1.20.1 && <1.21.4 {*/
113+
/*@Override
114+
*//*?}*/
90115
protected boolean isValidMouseClick(int button) {
91116
return button == InputConstants.MOUSE_BUTTON_LEFT || button == InputConstants.MOUSE_BUTTON_RIGHT || button == InputConstants.MOUSE_BUTTON_MIDDLE;
92117
}
93118

94119
@Override
95120
public boolean mouseClicked(double mouseX, double mouseY, int button) {
96-
if (button == 0 && mouseX >= getScrollbarPosition() && mouseX < getScrollbarPosition() + SCROLLBAR_WIDTH) {
121+
if (button == 0 && mouseX >= scrollBarX() && mouseX < scrollBarX() + SCROLLBAR_WIDTH) {
97122
usingScrollbar = true;
98123
}
99124

@@ -120,22 +145,36 @@ public void updateDimensions(ScreenRectangle rectangle) {
120145
* awful code to only use smooth scroll state when rendering,
121146
* not other code that needs target scroll amount
122147
*/
148+
//? if <1.21.4 {
149+
/*// backwards compatible method to reduce stonecutter comments
150+
protected double scrollAmount() {
151+
return this.getScrollAmount();
152+
}
153+
123154
@Override
124155
public double getScrollAmount() {
156+
*///?} else {
157+
@Override
158+
public double scrollAmount() {
159+
//?}
125160
if (returnSmoothAmount && doSmoothScrolling)
126161
return smoothScrollAmount;
127162

128-
return super.getScrollAmount();
163+
//? if >=1.21.4 {
164+
return super.scrollAmount();
165+
//?} else {
166+
/*return super.getScrollAmount();
167+
*///?}
129168
}
130169

131170
protected void resetSmoothScrolling() {
132-
this.smoothScrollAmount = super.getScrollAmount();
171+
this.smoothScrollAmount = /*? if >=1.21.4 {*/super.scrollAmount()/*?} else {*//*super.getScrollAmount()*//*?}*/;
133172
}
134173

135174
@Nullable
136175
@Override
137176
protected E getEntryAtPosition(double x, double y) {
138-
y += getScrollAmount();
177+
y += scrollAmount();
139178

140179
if (x < this.getX() || x > this.getX() + this.getWidth())
141180
return null;
@@ -159,8 +198,16 @@ protected E getEntryAtPosition(double x, double y) {
159198
code is responsible for having dynamic item heights
160199
*/
161200

201+
//? if <1.21.4 {
202+
/*protected int contentHeight() {
203+
return this.getMaxPosition();
204+
}
162205
@Override
163206
protected int getMaxPosition() {
207+
*///?} else {
208+
@Override
209+
protected int contentHeight() {
210+
//?}
164211
return children().stream().map(E::getItemHeight).reduce(0, Integer::sum) + headerHeight;
165212
}
166213

@@ -175,7 +222,7 @@ protected void centerScrollOn(E entry) {
175222
@Override
176223
/*? if >=1.21.2 {*/ public /*?} else {*/ /*protected *//*?}*/
177224
int getRowTop(int index) {
178-
int integer = getY() + 4 - (int) this.getScrollAmount() + headerHeight;
225+
int integer = getY() + 4 - (int) this.scrollAmount() + headerHeight;
179226
for (int i = 0; i < children().size() && i < index; i++)
180227
integer += children().get(i).getItemHeight();
181228
return integer;
@@ -186,12 +233,12 @@ protected void ensureVisible(E entry) {
186233
int i = this.getRowTop(this.children().indexOf(entry));
187234
int j = i - this.getY() - 4 - entry.getItemHeight();
188235
if (j < 0) {
189-
this.setScrollAmount(this.getScrollAmount() + j);
236+
this.setScrollAmount(this.scrollAmount() + j);
190237
}
191238

192239
int k = this.getY() + this.getHeight() - i - entry.getItemHeight() * 2;
193240
if (k < 0) {
194-
this.setScrollAmount(this.getScrollAmount() - k);
241+
this.setScrollAmount(this.scrollAmount() - k);
195242
}
196243
}
197244

src/main/java/dev/isxander/yacl3/gui/OptionDescriptionWidget.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,8 @@ public void tick() {
175175
}
176176

177177
private Style getDescStyle(int mouseX, int mouseY) {
178-
if (!clicked(mouseX, mouseY))
178+
boolean clicked = /*? if >=1.21.4 {*/ isMouseOver(mouseX, mouseY) /*?} else {*/ /*clicked(mouseX, mouseY) *//*?}*/;
179+
if (!clicked)
179180
return null;
180181

181182
int x = mouseX - getX();

src/main/java/dev/isxander/yacl3/gui/OptionListWidget.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,9 @@ public void addEntryBelow(Entry below, Entry entry) {
227227
}
228228

229229
public void addEntryBelowWithoutScroll(Entry below, Entry entry) {
230-
double d = (double)this.getMaxScroll() - this.getScrollAmount();
230+
double d = (double)this.contentHeight() - this.scrollAmount();
231231
addEntryBelow(below, entry);
232-
setScrollAmount(getMaxScroll() - d);
232+
setScrollAmount(this.contentHeight() - d);
233233
}
234234

235235
@Override
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package dev.isxander.yacl3.mixin;
2+
3+
import net.minecraft.client.gui.components.AbstractSelectionList;
4+
import org.spongepowered.asm.mixin.Mixin;
5+
import org.spongepowered.asm.mixin.gen.Accessor;
6+
7+
@Mixin(AbstractSelectionList.class)
8+
public interface AbstractSelectionListAccessor {
9+
//? if >=1.21.4 {
10+
@Accessor
11+
void setRenderHeader(boolean render);
12+
//?}
13+
}

src/main/resources/yacl.mixins.json

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"defaultRequire": 1
77
},
88
"client": [
9+
"AbstractSelectionListAccessor",
910
"AbstractSelectionListMixin",
1011
"MinecraftMixin",
1112
"OptionInstanceAccessor",

stonecutter.gradle.kts

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ plugins {
22
id("dev.kikugie.stonecutter")
33
id("dev.architectury.loom") version "1.7.+" apply false
44

5-
kotlin("jvm") version "1.9.23" apply false
5+
kotlin("jvm") version "2.0.21" apply false
66

77
id("me.modmuss50.mod-publish-plugin") version "0.5.+" apply false
88
id("org.ajoberstar.grgit") version "5.0.+" apply false
99
}
10-
stonecutter active "1.21.2-fabric" /* [SC] DO NOT EDIT */
10+
stonecutter active "1.21.4-fabric" /* [SC] DO NOT EDIT */
1111

1212
stonecutter.configureEach {
1313
val platform = project.property("loom.platform")

versions/1.20.1-forge/gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ mcVersion=1.20.1
44
java.version=17
55

66
deps.quiltMappings=23
7-
deps.forge=1.20.1-47.2.23
7+
deps.forge=1.20.1-47.3.12
88

99
modstoml.mcDep=[1.20,1.20.1]
1010
modstoml.loaderVersion=[46,)

versions/1.20.4-neoforge/gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ mcVersion=1.20.4
44
java.version=17
55

66
deps.quiltMappings=3
7-
deps.neoforge=20.4.130-beta
7+
deps.neoforge=20.4.237
88

99
modstoml.mcDep=[1.20.4]
1010
modstoml.loaderVersion=[1,)

versions/1.20.6-neoforge/gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ mcVersion=1.20.6
44
java.version=21
55

66
deps.quiltMappings=
7-
deps.neoforge=20.6.87-beta
7+
deps.neoforge=20.6.121
88

99
modstoml.mcDep=[1.20.5,1.20.6]
1010
modstoml.loaderVersion=[1,)

versions/1.21-neoforge/gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ mcVersion=1.21
44
java.version=21
55

66
deps.quiltMappings=
7-
deps.neoforge=21.0.0-beta
7+
deps.neoforge=21.0.167
88

99
modstoml.mcDep=[1.21,1.21.1]
1010
modstoml.loaderVersion=[1,)

versions/1.21.2-fabric/gradle.properties

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ java.version=21
55

66
deps.quiltMappings=
77
deps.fabricApi=0.106.0+1.21.2
8-
fmj.mcDep=~1.21.2-
8+
fmj.mcDep=~1.21.2 <1.21.4
99

10-
pub.stableMC=1.21.2
10+
pub.stableMC=1.21.2,1.21.3

0 commit comments

Comments
 (0)