diff options
author | isXander <xander@isxander.dev> | 2024-05-29 22:42:46 +0100 |
---|---|---|
committer | isXander <xander@isxander.dev> | 2024-05-29 22:42:46 +0100 |
commit | 646c7bac69dba476b3f9171568091eb23a86edaa (patch) | |
tree | 83727744315b956120fb573f9ecd883837b63099 | |
parent | 41253828df7c2066b5df29a32aa8e512f34ad85a (diff) | |
download | YetAnotherConfigLib-646c7bac69dba476b3f9171568091eb23a86edaa.tar.gz YetAnotherConfigLib-646c7bac69dba476b3f9171568091eb23a86edaa.tar.bz2 YetAnotherConfigLib-646c7bac69dba476b3f9171568091eb23a86edaa.zip |
1.21 compat
21 files changed, 75 insertions, 32 deletions
diff --git a/build.gradle.kts b/build.gradle.kts index 26ef177..13dcede 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -17,7 +17,7 @@ val isNeoforge = loader == "neoforge" val isForge = loader == "forge" val isForgeLike = isNeoforge || isForge -val mcVersion = stonecutter.current.version +val mcVersion = findProperty("mcVersion").toString() group = "dev.isxander" val versionWithoutMC = "3.4.4" @@ -111,7 +111,6 @@ repositories { forRepository { maven("https://thedarkcolour.github.io/KotlinForForge/") } filter { includeGroup("thedarkcolour") } } - maven("https://maven.neoforged.net/releases/") } @@ -119,7 +118,7 @@ dependencies { fun Dependency?.jij() = this?.let(::include) fun Dependency?.forgeRuntime() = this?.takeIf { isForgeLike }?.let { "forgeRuntimeLibrary"(it) } - minecraft("com.mojang:minecraft:${if (mcVersion.contains("beta")) "1.20.5-pre2" else mcVersion}") + minecraft("com.mojang:minecraft:$mcVersion") mappings(loom.layered { optionalProp("deps.quiltMappings") { diff --git a/gradle.properties b/gradle.properties index c2095c2..79fe14e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,7 +8,7 @@ modId=yet_another_config_lib_v3 modName=YetAnotherConfigLib modDescription=YetAnotherConfigLib (yacl) is just that. A builder-based configuration library for Minecraft. -deps.fabricLoader=0.15.9 +deps.fabricLoader=0.15.11 deps.imageio=3.10.0 deps.quiltParsers=0.2.1 deps.mixinExtras=0.3.5 diff --git a/settings.gradle.kts b/settings.gradle.kts index 6e84144..9027127 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -17,18 +17,19 @@ plugins { } extensions.configure<StonecutterSettings> { - kotlinController(true) - centralScript("build.gradle.kts") + kotlinController = true + centralScript = "build.gradle.kts" shared { fun mc(mcVersion: String, name: String = mcVersion, loaders: Iterable<String>) { for (loader in loaders) { - vers("$name-$loader", mcVersion) + versions("$name-$loader") } } + mc("1.20.6", loaders = listOf("fabric", "neoforge")) mc("1.20.4", loaders = listOf("fabric", "neoforge")) + mc("1.21", loaders = listOf("fabric")) mc("1.20.1", loaders = listOf("fabric", "forge")) - mc("1.20.6", loaders = listOf("fabric", "neoforge")) } create(rootProject) } diff --git a/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/SimpleOptionFactory.java b/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/SimpleOptionFactory.java index f7d807f..bbb878d 100644 --- a/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/SimpleOptionFactory.java +++ b/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/SimpleOptionFactory.java @@ -9,6 +9,7 @@ import dev.isxander.yacl3.config.v2.impl.FieldBackedBinding; import dev.isxander.yacl3.config.v2.impl.autogen.AutoGenUtils; import dev.isxander.yacl3.config.v2.impl.autogen.EmptyCustomImageFactory; import dev.isxander.yacl3.config.v2.impl.autogen.YACLAutoGenException; +import dev.isxander.yacl3.platform.YACLPlatform; import net.minecraft.client.Minecraft; import net.minecraft.locale.Language; import net.minecraft.network.chat.Component; @@ -90,7 +91,7 @@ public abstract class SimpleOptionFactory<A extends Annotation, T> implements Op builder.customImage(imageFactory.createImage(value, field, storage).thenApply(Optional::of)); } else if (!imageOverride.value().isEmpty()) { String path = imageOverride.value(); - ResourceLocation imageLocation = new ResourceLocation(field.parent().id().getNamespace(), path); + ResourceLocation imageLocation = YACLPlatform.rl(field.parent().id().getNamespace(), path); String extension = path.substring(path.lastIndexOf('.') + 1); switch (extension) { @@ -105,7 +106,7 @@ public abstract class SimpleOptionFactory<A extends Annotation, T> implements Op } else { String imagePath = "textures/yacl3/" + field.parent().id().getPath() + "/" + field.access().name() + ".webp"; imagePath = imagePath.toLowerCase().replaceAll("[^a-z0-9/._:-]", "_"); - ResourceLocation imageLocation = new ResourceLocation(field.parent().id().getNamespace(), imagePath); + ResourceLocation imageLocation = YACLPlatform.rl(field.parent().id().getNamespace(), imagePath); if (Minecraft.getInstance().getResourceManager().getResource(imageLocation).isPresent()) { builder.webpImage(imageLocation); } diff --git a/src/main/java/dev/isxander/yacl3/config/v2/impl/autogen/ListGroupImpl.java b/src/main/java/dev/isxander/yacl3/config/v2/impl/autogen/ListGroupImpl.java index f78d4ba..022d56e 100644 --- a/src/main/java/dev/isxander/yacl3/config/v2/impl/autogen/ListGroupImpl.java +++ b/src/main/java/dev/isxander/yacl3/config/v2/impl/autogen/ListGroupImpl.java @@ -8,6 +8,7 @@ import dev.isxander.yacl3.config.v2.api.autogen.ListGroup; import dev.isxander.yacl3.config.v2.api.autogen.OptionFactory; import dev.isxander.yacl3.config.v2.api.autogen.OptionAccess; import dev.isxander.yacl3.config.v2.impl.FieldBackedBinding; +import dev.isxander.yacl3.platform.YACLPlatform; import net.minecraft.client.Minecraft; import net.minecraft.locale.Language; import net.minecraft.network.chat.Component; @@ -56,7 +57,7 @@ public class ListGroupImpl<T> implements OptionFactory<ListGroup, List<T>> { String imagePath = "textures/yacl3/" + field.parent().id().getPath() + "/" + field.access().name() + ".webp"; imagePath = imagePath.toLowerCase().replaceAll("[^a-z0-9/._:-]", "_"); - ResourceLocation imageLocation = new ResourceLocation(field.parent().id().getNamespace(), imagePath); + ResourceLocation imageLocation = YACLPlatform.rl(field.parent().id().getNamespace(), imagePath); if (Minecraft.getInstance().getResourceManager().getResource(imageLocation).isPresent()) { builder.webpImage(imageLocation); } diff --git a/src/main/java/dev/isxander/yacl3/gui/AbstractWidget.java b/src/main/java/dev/isxander/yacl3/gui/AbstractWidget.java index 1f7c29b..e6ab3f1 100644 --- a/src/main/java/dev/isxander/yacl3/gui/AbstractWidget.java +++ b/src/main/java/dev/isxander/yacl3/gui/AbstractWidget.java @@ -94,10 +94,18 @@ public abstract class AbstractWidget implements GuiEventListener, Renderable, Na //Has a custom "z" value in case needed for later VertexConsumer vertex = graphics.bufferSource().getBuffer(RenderType.gui()); Matrix4f matrix4f = graphics.pose().last().pose(); + + /*? 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(); 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/gui/ElementListWidgetExt.java b/src/main/java/dev/isxander/yacl3/gui/ElementListWidgetExt.java index 85b86bb..be95caa 100644 --- a/src/main/java/dev/isxander/yacl3/gui/ElementListWidgetExt.java +++ b/src/main/java/dev/isxander/yacl3/gui/ElementListWidgetExt.java @@ -63,7 +63,11 @@ public class ElementListWidgetExt<E extends ElementListWidgetExt.Entry<E>> exten resetSmoothScrolling(); } - smoothScrollAmount = Mth.lerp(Minecraft.getInstance().getDeltaFrameTime() * 0.5, smoothScrollAmount, getScrollAmount()); + smoothScrollAmount = Mth.lerp( + delta * 0.5, + smoothScrollAmount, + getScrollAmount() + ); returnSmoothAmount = true; diff --git a/src/main/java/dev/isxander/yacl3/gui/YACLScreen.java b/src/main/java/dev/isxander/yacl3/gui/YACLScreen.java index 8152d18..4cf1cca 100644 --- a/src/main/java/dev/isxander/yacl3/gui/YACLScreen.java +++ b/src/main/java/dev/isxander/yacl3/gui/YACLScreen.java @@ -15,6 +15,7 @@ import dev.isxander.yacl3.gui.tab.ScrollableNavigationBar; import dev.isxander.yacl3.gui.tab.TabExt; import dev.isxander.yacl3.gui.utils.GuiUtils; import dev.isxander.yacl3.impl.utils.YACLConstants; +import dev.isxander.yacl3.platform.YACLPlatform; import net.minecraft.ChatFormatting; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Font; @@ -278,10 +279,6 @@ public class YACLScreen extends Screen { int drawY = y - 12; graphics.pose().pushPose(); - Tesselator tesselator = Tesselator.getInstance(); - BufferBuilder bufferBuilder = tesselator.getBuilder(); - RenderSystem.setShader(GameRenderer::getPositionColorShader); - bufferBuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR); TooltipRenderUtil.renderTooltipBackground( graphics, drawX, @@ -290,11 +287,6 @@ public class YACLScreen extends Screen { height, 400 ); - RenderSystem.enableDepthTest(); - RenderSystem.enableBlend(); - RenderSystem.defaultBlendFunc(); - BufferUploader.drawWithShader(bufferBuilder.end()); - RenderSystem.disableBlend(); graphics.pose().translate(0.0, 0.0, 400.0); text.renderLeftAligned(graphics, drawX, drawY, lineHeight, -1); @@ -305,7 +297,7 @@ public class YACLScreen extends Screen { public static class CategoryTab implements TabExt { /*? if >1.20.4 {*/ - private static final ResourceLocation DARKER_BG = new ResourceLocation("textures/gui/menu_list_background.png"); + private static final ResourceLocation DARKER_BG = YACLPlatform.mcRl("textures/gui/menu_list_background.png"); /*?}*/ private final YACLScreen screen; diff --git a/src/main/java/dev/isxander/yacl3/gui/utils/ItemRegistryHelper.java b/src/main/java/dev/isxander/yacl3/gui/utils/ItemRegistryHelper.java index 3c4f03a..bb6c664 100644 --- a/src/main/java/dev/isxander/yacl3/gui/utils/ItemRegistryHelper.java +++ b/src/main/java/dev/isxander/yacl3/gui/utils/ItemRegistryHelper.java @@ -1,6 +1,7 @@ package dev.isxander.yacl3.gui.utils; +import dev.isxander.yacl3.platform.YACLPlatform; import net.minecraft.ResourceLocationException; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.resources.ResourceLocation; @@ -26,7 +27,7 @@ public final class ItemRegistryHelper { */ public static boolean isRegisteredItem(String identifier) { try { - ResourceLocation itemIdentifier = new ResourceLocation(identifier.toLowerCase()); + ResourceLocation itemIdentifier = YACLPlatform.parseRl(identifier.toLowerCase()); return BuiltInRegistries.ITEM.containsKey(itemIdentifier); } catch (ResourceLocationException e) { return false; @@ -43,7 +44,7 @@ public final class ItemRegistryHelper { */ public static Item getItemFromName(String identifier, Item defaultItem) { try { - ResourceLocation itemIdentifier = new ResourceLocation(identifier.toLowerCase()); + ResourceLocation itemIdentifier = YACLPlatform.parseRl(identifier.toLowerCase()); if (BuiltInRegistries.ITEM.containsKey(itemIdentifier)) { return BuiltInRegistries.ITEM.get(itemIdentifier); } diff --git a/src/main/java/dev/isxander/yacl3/gui/utils/YACLRenderHelper.java b/src/main/java/dev/isxander/yacl3/gui/utils/YACLRenderHelper.java index b49557b..b8293fb 100644 --- a/src/main/java/dev/isxander/yacl3/gui/utils/YACLRenderHelper.java +++ b/src/main/java/dev/isxander/yacl3/gui/utils/YACLRenderHelper.java @@ -8,10 +8,10 @@ import net.minecraft.resources.ResourceLocation; public class YACLRenderHelper { /*? if >1.20.1 {*/ private static final net.minecraft.client.gui.components.WidgetSprites SPRITES = new net.minecraft.client.gui.components.WidgetSprites( - new ResourceLocation("widget/button"), // normal - new ResourceLocation("widget/button_disabled"), // disabled & !focused - new ResourceLocation("widget/button_highlighted"), // !disabled & focused - new ResourceLocation("widget/slider_highlighted") // disabled & focused + YACLPlatform.mcRl("widget/button"), // normal + YACLPlatform.mcRl("widget/button_disabled"), // disabled & !focused + YACLPlatform.mcRl("widget/button_highlighted"), // !disabled & focused + YACLPlatform.mcRl("widget/slider_highlighted") // disabled & focused ); /*?} else {*//* private static final ResourceLocation SLIDER_LOCATION = new ResourceLocation("textures/gui/slider.png"); diff --git a/src/main/java/dev/isxander/yacl3/platform/YACLPlatform.java b/src/main/java/dev/isxander/yacl3/platform/YACLPlatform.java index bfb0586..e330324 100644 --- a/src/main/java/dev/isxander/yacl3/platform/YACLPlatform.java +++ b/src/main/java/dev/isxander/yacl3/platform/YACLPlatform.java @@ -14,8 +14,28 @@ import net.minecraft.resources.ResourceLocation; import java.nio.file.Path; public final class YACLPlatform { + public static ResourceLocation parseRl(String rl) { + /*? if >1.20.6 {*//* + return ResourceLocation.parse(rl); + *//*?} else {*/ + return new ResourceLocation(rl); + /*?}*/ + } + public static ResourceLocation rl(String path) { - return new ResourceLocation("yet_another_config_lib_v3", path); + return rl("yet_another_config_lib_v3", path); + } + + public static ResourceLocation mcRl(String path) { + return rl("minecraft", path); + } + + public static ResourceLocation rl(String namespace, String path) { + /*? if >1.20.6 {*//* + return ResourceLocation.fromNamespaceAndPath(namespace, path); + *//*?} else {*/ + return new ResourceLocation(namespace, path); + /*?}*/ } public static Env getEnvironment() { diff --git a/src/testmod/java/dev/isxander/yacl3/test/AutogenConfigTest.java b/src/testmod/java/dev/isxander/yacl3/test/AutogenConfigTest.java index 9bb361e..186d192 100644 --- a/src/testmod/java/dev/isxander/yacl3/test/AutogenConfigTest.java +++ b/src/testmod/java/dev/isxander/yacl3/test/AutogenConfigTest.java @@ -24,7 +24,7 @@ import java.util.List; public class AutogenConfigTest { public static final ConfigClassHandler<AutogenConfigTest> INSTANCE = ConfigClassHandler.createBuilder(AutogenConfigTest.class) - .id(new ResourceLocation("yacl3-test", "config")) + .id(YACLPlatform.rl("yacl3-test", "config")) .serializer(config -> GsonConfigSerializerBuilder.create(config) .setPath(YACLPlatform.getConfigDir().resolve("yacl-test-v2.json5")) .setJson5(true) diff --git a/src/testmod/java/dev/isxander/yacl3/test/GuiTest.java b/src/testmod/java/dev/isxander/yacl3/test/GuiTest.java index cdc1285..07e0098 100644 --- a/src/testmod/java/dev/isxander/yacl3/test/GuiTest.java +++ b/src/testmod/java/dev/isxander/yacl3/test/GuiTest.java @@ -14,6 +14,7 @@ import dev.isxander.yacl3.gui.controllers.string.number.DoubleFieldController; import dev.isxander.yacl3.gui.controllers.string.number.FloatFieldController; import dev.isxander.yacl3.gui.controllers.string.number.IntegerFieldController; import dev.isxander.yacl3.gui.controllers.string.number.LongFieldController; +import dev.isxander.yacl3.platform.YACLPlatform; import net.minecraft.ChatFormatting; import net.minecraft.Util; import net.minecraft.client.GraphicsStatus; @@ -502,7 +503,7 @@ public class GuiTest { } private static ResourceLocation imageSample(String name) { - return new ResourceLocation("yacl_test", "textures/images/" + name); + return YACLPlatform.rl("yacl_test", "textures/images/" + name); } private static boolean myBooleanOption = true; diff --git a/src/testmod/kotlin/dev/isxander/yacl3/test/DslTest.kt b/src/testmod/kotlin/dev/isxander/yacl3/test/DslTest.kt index 2efd9a4..a3ed7cc 100644 --- a/src/testmod/kotlin/dev/isxander/yacl3/test/DslTest.kt +++ b/src/testmod/kotlin/dev/isxander/yacl3/test/DslTest.kt @@ -4,6 +4,7 @@ import dev.isxander.yacl3.api.OptionFlag import dev.isxander.yacl3.api.controller.BooleanControllerBuilder import dev.isxander.yacl3.api.controller.IntegerSliderControllerBuilder import dev.isxander.yacl3.dsl.* +import dev.isxander.yacl3.platform.YACLPlatform import net.minecraft.client.gui.screens.Screen import net.minecraft.network.chat.Component import net.minecraft.resources.ResourceLocation @@ -85,7 +86,7 @@ fun kotlinDslGui(parent: Screen?) = YetAnotherConfigLib("namespace") { addDefaultDescription(lines = 5) text { Component.translatable("somecustomkey") } - webpImage(ResourceLocation("namespace", "image.png")) + webpImage(YACLPlatform.rl("namespace", "image.png")) } // KProperties are cool! diff --git a/versions/1.20.1-fabric/gradle.properties b/versions/1.20.1-fabric/gradle.properties index abee145..4bd5fcc 100644 --- a/versions/1.20.1-fabric/gradle.properties +++ b/versions/1.20.1-fabric/gradle.properties @@ -1,4 +1,5 @@ loom.platform=fabric +mcVersion=1.20.1 java.version=17 diff --git a/versions/1.20.1-forge/gradle.properties b/versions/1.20.1-forge/gradle.properties index 64b9e33..3d24407 100644 --- a/versions/1.20.1-forge/gradle.properties +++ b/versions/1.20.1-forge/gradle.properties @@ -1,4 +1,5 @@ loom.platform=forge +mcVersion=1.20.1 java.version=17 diff --git a/versions/1.20.4-fabric/gradle.properties b/versions/1.20.4-fabric/gradle.properties index 542f0fa..ecf8015 100644 --- a/versions/1.20.4-fabric/gradle.properties +++ b/versions/1.20.4-fabric/gradle.properties @@ -1,4 +1,5 @@ loom.platform=fabric +mcVersion=1.20.4 java.version=17 diff --git a/versions/1.20.4-neoforge/gradle.properties b/versions/1.20.4-neoforge/gradle.properties index 6274b1a..2ed0130 100644 --- a/versions/1.20.4-neoforge/gradle.properties +++ b/versions/1.20.4-neoforge/gradle.properties @@ -1,4 +1,5 @@ loom.platform=neoforge +mcVersion=1.20.4 java.version=17 diff --git a/versions/1.20.6-fabric/gradle.properties b/versions/1.20.6-fabric/gradle.properties index 5a65f6d..0061628 100644 --- a/versions/1.20.6-fabric/gradle.properties +++ b/versions/1.20.6-fabric/gradle.properties @@ -1,4 +1,5 @@ loom.platform=fabric +mcVersion=1.20.6 java.version=21 diff --git a/versions/1.20.6-neoforge/gradle.properties b/versions/1.20.6-neoforge/gradle.properties index f354ca0..2e9f1df 100644 --- a/versions/1.20.6-neoforge/gradle.properties +++ b/versions/1.20.6-neoforge/gradle.properties @@ -1,4 +1,5 @@ loom.platform=neoforge +mcVersion=1.20.6 java.version=21 diff --git a/versions/1.21-fabric/gradle.properties b/versions/1.21-fabric/gradle.properties new file mode 100644 index 0000000..678600f --- /dev/null +++ b/versions/1.21-fabric/gradle.properties @@ -0,0 +1,8 @@ +loom.platform=fabric +mcVersion=1.21-pre1 + +java.version=21 + +deps.quiltMappings= +deps.fabricApi=0.99.2+1.21 +fmj.mcDep=~1.21- |