aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--changelog.md81
-rw-r--r--src/main/java/dev/isxander/yacl3/config/v3/JsonFileCodecConfig.java2
-rw-r--r--src/main/java/dev/isxander/yacl3/gui/AbstractWidget.java8
-rw-r--r--src/main/java/dev/isxander/yacl3/platform/YACLPlatform.java16
-rw-r--r--src/main/kotlin/dev/isxander/yacl3/dsl/API.kt3
-rw-r--r--src/testmod/java/dev/isxander/yacl3/test/CodecConfig.java7
-rw-r--r--stonecutter.gradle.kts2
-rw-r--r--versions/1.21-fabric/gradle.properties4
8 files changed, 101 insertions, 22 deletions
diff --git a/changelog.md b/changelog.md
index dbab4c7..ab6c6d1 100644
--- a/changelog.md
+++ b/changelog.md
@@ -1,13 +1,88 @@
-# YetAnotherConfigLib 3.4.4
+# YetAnotherConfigLib 3.5.0
This build supports the following versions:
- Fabric 1.20.1
- Fabric 1.20.4
- Fabric 1.20.6 (also supports 1.20.5)
+- Fabric 1.21
- NeoForge 1.20.6 (also supports 1.20.5)
- NeoForge 1.20.4
- MinecraftForge 1.20.1
-## Bug Fixes
+## *Experimental* Codec Config
-- Fix Kotlin DSL not being included
+This update brings a new experimental config API that utilises Mojang's Codec for (de)serialization.
+
+```java
+public class CodecConfig extends JsonFileCodecConfig/*or*/CodecConfig {
+ public static final CodecConfig INSTANCE = new CodecConfig();
+
+ public final ConfigEntry<Integer> myInt =
+ register("my_int", 0, Codec.INT);
+
+ public final ReadonlyConfigEntry<InnerCodecConfig> myInnerConfig =
+ register("my_inner_config", InnerCodecConfig.INSTANCE);
+
+ public CodecConfig() {
+ super(path);
+ }
+
+ void test() {
+ loadFromFile(); // load like this
+ saveToFile(); // save like this
+
+ // or if you just extend CodecConfig instead of JsonFileConfig:
+ JsonElement element = null;
+ this.decode(element, JsonOps.INSTANCE); // load
+ DataResult<JsonElement> encoded = this.encodeStart(JsonOps.INSTANCE); // save
+ }
+}
+```
+or in Kotlin...
+```kotlin
+object CodecConfig : JsonFileCodecConfig(path) {
+ val myInt by register<Int>(0, Codec.INT)
+
+ val myInnerConfig by register(InnerCodecConfig)
+
+ fun test() {
+ loadFromFile()
+ saveToFile()
+
+ // blah blah blah
+ }
+}
+```
+
+## Rewritten Kotlin DSL
+
+Completely rewrote the Kotlin DSL!
+
+```kotlin
+YetAnotherConfigLib("namespace") {
+ val category by categories.registering {
+ val option by rootOptions.registering<Int> {
+ controller = slider(range = 5..10)
+ binding(::thisProp, default)
+
+ val otherOption by categories["category"]["group"].futureRef<Boolean>()
+ otherOption.onReady { it.setAvailable(false) }
+ }
+
+ // translation key is generated automagically
+ val label by rootOptions.registeringLabel
+
+ val group by groups.registering {
+ val otherOption = options.register<Boolean>("otherOption") {
+ controller = tickBox()
+ }
+ }
+ }
+}
+```
+
+## Changes
+
+- Fix dropdown controllers erroneously showing their dropdown - Crendgrim
+- Make cancel/reset and undo buttons public for accessing
+- Add compatibility for 1.21
diff --git a/src/main/java/dev/isxander/yacl3/config/v3/JsonFileCodecConfig.java b/src/main/java/dev/isxander/yacl3/config/v3/JsonFileCodecConfig.java
index 49a0dac..fed8ba8 100644
--- a/src/main/java/dev/isxander/yacl3/config/v3/JsonFileCodecConfig.java
+++ b/src/main/java/dev/isxander/yacl3/config/v3/JsonFileCodecConfig.java
@@ -12,7 +12,7 @@ import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
@ApiStatus.Experimental
-public abstract class JsonFileCodecConfig extends CodecConfig {
+public abstract class JsonFileCodecConfig<T extends JsonFileCodecConfig<T>> extends CodecConfig<T> {
private final Path configPath;
private final Gson gson;
diff --git a/src/main/java/dev/isxander/yacl3/gui/AbstractWidget.java b/src/main/java/dev/isxander/yacl3/gui/AbstractWidget.java
index 8def3b3..48f2cc3 100644
--- a/src/main/java/dev/isxander/yacl3/gui/AbstractWidget.java
+++ b/src/main/java/dev/isxander/yacl3/gui/AbstractWidget.java
@@ -95,17 +95,17 @@ public abstract class AbstractWidget implements GuiEventListener, Renderable, Na
VertexConsumer vertex = graphics.bufferSource().getBuffer(RenderType.gui());
Matrix4f matrix4f = graphics.pose().last().pose();
- /*? if >1.20.6 {*//*
+ /*? if >1.20.6 {*/
vertex.addVertex(matrix4f, x1, y1, 0).setColor(startColor);
vertex.addVertex(matrix4f, x1, y2, 0).setColor(startColor);
vertex.addVertex(matrix4f, x2, y2, 0).setColor(endColor);
vertex.addVertex(matrix4f, x2, y1, 0).setColor(endColor);
- *//*?} else {*/
- vertex.vertex(matrix4f, x1, y1, 0).color(startColor).endVertex();
+ /*?} else {*/
+ /*vertex.vertex(matrix4f, x1, y1, 0).color(startColor).endVertex();
vertex.vertex(matrix4f, x1, y2, 0).color(startColor).endVertex();
vertex.vertex(matrix4f, x2, y2, 0).color(endColor).endVertex();
vertex.vertex(matrix4f, x2, y1, 0).color(endColor).endVertex();
- /*?}*/
+ *//*?}*/
}
diff --git a/src/main/java/dev/isxander/yacl3/platform/YACLPlatform.java b/src/main/java/dev/isxander/yacl3/platform/YACLPlatform.java
index 514c964..490a5fa 100644
--- a/src/main/java/dev/isxander/yacl3/platform/YACLPlatform.java
+++ b/src/main/java/dev/isxander/yacl3/platform/YACLPlatform.java
@@ -15,11 +15,11 @@ import java.nio.file.Path;
public final class YACLPlatform {
public static ResourceLocation parseRl(String rl) {
- /*? if >1.20.6 {*//*
+ /*? if >1.20.6 {*/
return ResourceLocation.parse(rl);
- *//*?} else {*/
- return new ResourceLocation(rl);
- /*?}*/
+ /*?} else {*/
+ /*return new ResourceLocation(rl);
+ *//*?}*/
}
public static ResourceLocation rl(String path) {
@@ -31,11 +31,11 @@ public final class YACLPlatform {
}
public static ResourceLocation rl(String namespace, String path) {
- /*? if >1.20.6 {*//*
+ /*? if >1.20.6 {*/
return ResourceLocation.fromNamespaceAndPath(namespace, path);
- *//*?} else {*/
- return new ResourceLocation(namespace, path);
- /*?}*/
+ /*?} else {*/
+ /*return new ResourceLocation(namespace, path);
+ *//*?}*/
}
public static Env getEnvironment() {
diff --git a/src/main/kotlin/dev/isxander/yacl3/dsl/API.kt b/src/main/kotlin/dev/isxander/yacl3/dsl/API.kt
index cd2c483..e3e3099 100644
--- a/src/main/kotlin/dev/isxander/yacl3/dsl/API.kt
+++ b/src/main/kotlin/dev/isxander/yacl3/dsl/API.kt
@@ -23,6 +23,9 @@ typealias FutureOption<T> = CompletableFuture<Option<T>>
fun <T> CompletableFuture<OptionRegistrar>.futureRef(id: String): FutureOption<T> =
thenCompose { it.futureRef(id) }
+fun <T> CompletableFuture<OptionRegistrar>.futureRef(): RegisterableDelegateProvider<FutureOption<T>> =
+ RegisterableDelegateProvider({ this.futureRef(it) }, null)
+
fun YetAnotherConfigLib(id: String, block: RootDsl.() -> Unit) =
RootDslImpl(id).apply(block).build()
diff --git a/src/testmod/java/dev/isxander/yacl3/test/CodecConfig.java b/src/testmod/java/dev/isxander/yacl3/test/CodecConfig.java
index 08137e6..1a65eb2 100644
--- a/src/testmod/java/dev/isxander/yacl3/test/CodecConfig.java
+++ b/src/testmod/java/dev/isxander/yacl3/test/CodecConfig.java
@@ -6,12 +6,13 @@ import com.mojang.serialization.DataResult;
import com.mojang.serialization.JsonOps;
import dev.isxander.yacl3.config.v3.ConfigEntry;
import dev.isxander.yacl3.config.v3.JsonFileCodecConfig;
+import dev.isxander.yacl3.config.v3.ReadonlyConfigEntry;
import dev.isxander.yacl3.platform.YACLPlatform;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.ComponentSerialization;
import net.minecraft.resources.ResourceLocation;
-public class CodecConfig extends JsonFileCodecConfig {
+public class CodecConfig extends JsonFileCodecConfig<CodecConfig> {
public static final CodecConfig INSTANCE = new CodecConfig();
public final ConfigEntry<Integer> myInt =
@@ -26,8 +27,8 @@ public class CodecConfig extends JsonFileCodecConfig {
public final ConfigEntry<Component> myText =
register("my_text", Component.literal("Hello"), ComponentSerialization.CODEC);
- public final ConfigEntry<InnerCodecConfig> myInnerConfig =
- register("my_inner_config", InnerCodecConfig.INSTANCE, InnerCodecConfig.INSTANCE);
+ public final ReadonlyConfigEntry<InnerCodecConfig> myInnerConfig =
+ register("my_inner_config", InnerCodecConfig.INSTANCE);
public static class InnerCodecConfig extends dev.isxander.yacl3.config.v3.CodecConfig<InnerCodecConfig> {
public static final InnerCodecConfig INSTANCE = new InnerCodecConfig();
diff --git a/stonecutter.gradle.kts b/stonecutter.gradle.kts
index 8aa3e0c..79cc121 100644
--- a/stonecutter.gradle.kts
+++ b/stonecutter.gradle.kts
@@ -7,7 +7,7 @@ plugins {
id("me.modmuss50.mod-publish-plugin") version "0.5.+" apply false
id("org.ajoberstar.grgit") version "5.0.+" apply false
}
-stonecutter active "1.20.6-fabric" /* [SC] DO NOT EDIT */
+stonecutter active "1.21-fabric" /* [SC] DO NOT EDIT */
stonecutter.configureEach {
val platform = project.property("loom.platform")
diff --git a/versions/1.21-fabric/gradle.properties b/versions/1.21-fabric/gradle.properties
index 678600f..aac37cb 100644
--- a/versions/1.21-fabric/gradle.properties
+++ b/versions/1.21-fabric/gradle.properties
@@ -1,8 +1,8 @@
loom.platform=fabric
-mcVersion=1.21-pre1
+mcVersion=1.21-rc1
java.version=21
deps.quiltMappings=
-deps.fabricApi=0.99.2+1.21
+deps.fabricApi=0.100.1+1.21
fmj.mcDep=~1.21-