Skip to content

Commit 566fb6c

Browse files
committed
Changelog and minor changes
1 parent 305718e commit 566fb6c

File tree

8 files changed

+101
-22
lines changed

8 files changed

+101
-22
lines changed

changelog.md

Lines changed: 78 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,88 @@
1-
# YetAnotherConfigLib 3.4.4
1+
# YetAnotherConfigLib 3.5.0
22

33
This build supports the following versions:
44
- Fabric 1.20.1
55
- Fabric 1.20.4
66
- Fabric 1.20.6 (also supports 1.20.5)
7+
- Fabric 1.21
78
- NeoForge 1.20.6 (also supports 1.20.5)
89
- NeoForge 1.20.4
910
- MinecraftForge 1.20.1
1011

11-
## Bug Fixes
12+
## *Experimental* Codec Config
1213

13-
- Fix Kotlin DSL not being included
14+
This update brings a new experimental config API that utilises Mojang's Codec for (de)serialization.
15+
16+
```java
17+
public class CodecConfig extends JsonFileCodecConfig/*or*/CodecConfig {
18+
public static final CodecConfig INSTANCE = new CodecConfig();
19+
20+
public final ConfigEntry<Integer> myInt =
21+
register("my_int", 0, Codec.INT);
22+
23+
public final ReadonlyConfigEntry<InnerCodecConfig> myInnerConfig =
24+
register("my_inner_config", InnerCodecConfig.INSTANCE);
25+
26+
public CodecConfig() {
27+
super(path);
28+
}
29+
30+
void test() {
31+
loadFromFile(); // load like this
32+
saveToFile(); // save like this
33+
34+
// or if you just extend CodecConfig instead of JsonFileConfig:
35+
JsonElement element = null;
36+
this.decode(element, JsonOps.INSTANCE); // load
37+
DataResult<JsonElement> encoded = this.encodeStart(JsonOps.INSTANCE); // save
38+
}
39+
}
40+
```
41+
or in Kotlin...
42+
```kotlin
43+
object CodecConfig : JsonFileCodecConfig(path) {
44+
val myInt by register<Int>(0, Codec.INT)
45+
46+
val myInnerConfig by register(InnerCodecConfig)
47+
48+
fun test() {
49+
loadFromFile()
50+
saveToFile()
51+
52+
// blah blah blah
53+
}
54+
}
55+
```
56+
57+
## Rewritten Kotlin DSL
58+
59+
Completely rewrote the Kotlin DSL!
60+
61+
```kotlin
62+
YetAnotherConfigLib("namespace") {
63+
val category by categories.registering {
64+
val option by rootOptions.registering<Int> {
65+
controller = slider(range = 5..10)
66+
binding(::thisProp, default)
67+
68+
val otherOption by categories["category"]["group"].futureRef<Boolean>()
69+
otherOption.onReady { it.setAvailable(false) }
70+
}
71+
72+
// translation key is generated automagically
73+
val label by rootOptions.registeringLabel
74+
75+
val group by groups.registering {
76+
val otherOption = options.register<Boolean>("otherOption") {
77+
controller = tickBox()
78+
}
79+
}
80+
}
81+
}
82+
```
83+
84+
## Changes
85+
86+
- Fix dropdown controllers erroneously showing their dropdown - Crendgrim
87+
- Make cancel/reset and undo buttons public for accessing
88+
- Add compatibility for 1.21

src/main/java/dev/isxander/yacl3/config/v3/JsonFileCodecConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import java.nio.file.StandardOpenOption;
1313

1414
@ApiStatus.Experimental
15-
public abstract class JsonFileCodecConfig extends CodecConfig {
15+
public abstract class JsonFileCodecConfig<T extends JsonFileCodecConfig<T>> extends CodecConfig<T> {
1616
private final Path configPath;
1717
private final Gson gson;
1818

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,17 +95,17 @@ protected void fillSidewaysGradient(GuiGraphics graphics, int x1, int y1, int x2
9595
VertexConsumer vertex = graphics.bufferSource().getBuffer(RenderType.gui());
9696
Matrix4f matrix4f = graphics.pose().last().pose();
9797

98-
/*? if >1.20.6 {*//*
98+
/*? if >1.20.6 {*/
9999
vertex.addVertex(matrix4f, x1, y1, 0).setColor(startColor);
100100
vertex.addVertex(matrix4f, x1, y2, 0).setColor(startColor);
101101
vertex.addVertex(matrix4f, x2, y2, 0).setColor(endColor);
102102
vertex.addVertex(matrix4f, x2, y1, 0).setColor(endColor);
103-
*//*?} else {*/
104-
vertex.vertex(matrix4f, x1, y1, 0).color(startColor).endVertex();
103+
/*?} else {*/
104+
/*vertex.vertex(matrix4f, x1, y1, 0).color(startColor).endVertex();
105105
vertex.vertex(matrix4f, x1, y2, 0).color(startColor).endVertex();
106106
vertex.vertex(matrix4f, x2, y2, 0).color(endColor).endVertex();
107107
vertex.vertex(matrix4f, x2, y1, 0).color(endColor).endVertex();
108-
/*?}*/
108+
*//*?}*/
109109
}
110110

111111

src/main/java/dev/isxander/yacl3/platform/YACLPlatform.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515

1616
public final class YACLPlatform {
1717
public static ResourceLocation parseRl(String rl) {
18-
/*? if >1.20.6 {*//*
18+
/*? if >1.20.6 {*/
1919
return ResourceLocation.parse(rl);
20-
*//*?} else {*/
21-
return new ResourceLocation(rl);
22-
/*?}*/
20+
/*?} else {*/
21+
/*return new ResourceLocation(rl);
22+
*//*?}*/
2323
}
2424

2525
public static ResourceLocation rl(String path) {
@@ -31,11 +31,11 @@ public static ResourceLocation mcRl(String path) {
3131
}
3232

3333
public static ResourceLocation rl(String namespace, String path) {
34-
/*? if >1.20.6 {*//*
34+
/*? if >1.20.6 {*/
3535
return ResourceLocation.fromNamespaceAndPath(namespace, path);
36-
*//*?} else {*/
37-
return new ResourceLocation(namespace, path);
38-
/*?}*/
36+
/*?} else {*/
37+
/*return new ResourceLocation(namespace, path);
38+
*//*?}*/
3939
}
4040

4141
public static Env getEnvironment() {

src/main/kotlin/dev/isxander/yacl3/dsl/API.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ typealias FutureOption<T> = CompletableFuture<Option<T>>
2323
fun <T> CompletableFuture<OptionRegistrar>.futureRef(id: String): FutureOption<T> =
2424
thenCompose { it.futureRef(id) }
2525

26+
fun <T> CompletableFuture<OptionRegistrar>.futureRef(): RegisterableDelegateProvider<FutureOption<T>> =
27+
RegisterableDelegateProvider({ this.futureRef(it) }, null)
28+
2629
fun YetAnotherConfigLib(id: String, block: RootDsl.() -> Unit) =
2730
RootDslImpl(id).apply(block).build()
2831

src/testmod/java/dev/isxander/yacl3/test/CodecConfig.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@
66
import com.mojang.serialization.JsonOps;
77
import dev.isxander.yacl3.config.v3.ConfigEntry;
88
import dev.isxander.yacl3.config.v3.JsonFileCodecConfig;
9+
import dev.isxander.yacl3.config.v3.ReadonlyConfigEntry;
910
import dev.isxander.yacl3.platform.YACLPlatform;
1011
import net.minecraft.network.chat.Component;
1112
import net.minecraft.network.chat.ComponentSerialization;
1213
import net.minecraft.resources.ResourceLocation;
1314

14-
public class CodecConfig extends JsonFileCodecConfig {
15+
public class CodecConfig extends JsonFileCodecConfig<CodecConfig> {
1516
public static final CodecConfig INSTANCE = new CodecConfig();
1617

1718
public final ConfigEntry<Integer> myInt =
@@ -26,8 +27,8 @@ public class CodecConfig extends JsonFileCodecConfig {
2627
public final ConfigEntry<Component> myText =
2728
register("my_text", Component.literal("Hello"), ComponentSerialization.CODEC);
2829

29-
public final ConfigEntry<InnerCodecConfig> myInnerConfig =
30-
register("my_inner_config", InnerCodecConfig.INSTANCE, InnerCodecConfig.INSTANCE);
30+
public final ReadonlyConfigEntry<InnerCodecConfig> myInnerConfig =
31+
register("my_inner_config", InnerCodecConfig.INSTANCE);
3132

3233
public static class InnerCodecConfig extends dev.isxander.yacl3.config.v3.CodecConfig<InnerCodecConfig> {
3334
public static final InnerCodecConfig INSTANCE = new InnerCodecConfig();

stonecutter.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ plugins {
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.20.6-fabric" /* [SC] DO NOT EDIT */
10+
stonecutter active "1.21-fabric" /* [SC] DO NOT EDIT */
1111

1212
stonecutter.configureEach {
1313
val platform = project.property("loom.platform")
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
loom.platform=fabric
2-
mcVersion=1.21-pre1
2+
mcVersion=1.21-rc1
33

44
java.version=21
55

66
deps.quiltMappings=
7-
deps.fabricApi=0.99.2+1.21
7+
deps.fabricApi=0.100.1+1.21
88
fmj.mcDep=~1.21-

0 commit comments

Comments
 (0)