diff options
author | isXander <xander@isxander.dev> | 2024-06-12 17:15:09 +0100 |
---|---|---|
committer | isXander <xander@isxander.dev> | 2024-06-12 17:15:09 +0100 |
commit | 566fb6c498d571281c94029f8dfbac5e5077600c (patch) | |
tree | 7b92ee139e0e6e2cdd8d8619c62f4f7d031aad42 /src | |
parent | 305718e163f91802a4bc1c1ed6540febb2ce204e (diff) | |
download | YetAnotherConfigLib-566fb6c498d571281c94029f8dfbac5e5077600c.tar.gz YetAnotherConfigLib-566fb6c498d571281c94029f8dfbac5e5077600c.tar.bz2 YetAnotherConfigLib-566fb6c498d571281c94029f8dfbac5e5077600c.zip |
Changelog and minor changes
Diffstat (limited to 'src')
5 files changed, 20 insertions, 16 deletions
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(); |