diff --git a/CHANGELOG.md b/CHANGELOG.md index ae47a39..4239b7d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# 1.2.0 + +- Backport to 1.20.1 + # 1.1.2 - Fix YACL bindings incorrectly using the current value as the default diff --git a/build.gradle.kts b/build.gradle.kts index 1fa7a1c..e37e316 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -48,7 +48,7 @@ loom { tasks { withType { - options.release = 21 + options.release = minecraftVersion.javaVersion() } withType { @@ -84,8 +84,8 @@ tasks { java { withSourcesJar() - sourceCompatibility = JavaVersion.VERSION_21 - targetCompatibility = JavaVersion.VERSION_21 + sourceCompatibility = JavaVersion.toVersion(minecraftVersion.javaVersion()) + targetCompatibility = JavaVersion.toVersion(minecraftVersion.javaVersion()) } val buildAndCollect = tasks.register("buildAndCollect") { diff --git a/gradle.properties b/gradle.properties index 6be1461..341b7ae 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,15 +1,13 @@ org.gradle.jvmargs=-Xmx4G -fabric_versions=1.21.1 +fabric_versions=1.20.1, 1.21.1 neoforge_versions=1.21.1 -mod_version=1.1.2 +mod_version=1.2.0 mod_group=com.bawnorton mod_id=configurable mod_name=Configurable mod_description=Config library that allows decentralised settings in a mod modrinth_project_id=lGffrQ3O -curseforge_project_id=1092048 - -yacl_version=3.5.0+1.21 \ No newline at end of file +curseforge_project_id=1092048 \ No newline at end of file diff --git a/src/main/java/com/bawnorton/configurable/ap/ConfigurableProcessor.java b/src/main/java/com/bawnorton/configurable/ap/ConfigurableProcessor.java index 38c5297..a72336c 100644 --- a/src/main/java/com/bawnorton/configurable/ap/ConfigurableProcessor.java +++ b/src/main/java/com/bawnorton/configurable/ap/ConfigurableProcessor.java @@ -25,6 +25,7 @@ import javax.lang.model.element.TypeElement; import javax.lang.model.util.Elements; import javax.lang.model.util.Types; +import javax.tools.Diagnostic; import javax.tools.FileObject; import javax.tools.StandardLocation; import org.jetbrains.annotations.NotNull; @@ -38,7 +39,11 @@ import java.util.Set; @SupportedAnnotationTypes("com.bawnorton.configurable.Configurable") -@SupportedSourceVersion(SourceVersion.RELEASE_21) +//? if >=1.21 { +/*@SupportedSourceVersion(SourceVersion.RELEASE_21) +*///?} else { +@SupportedSourceVersion(SourceVersion.RELEASE_17) +//?} public final class ConfigurableProcessor extends AbstractProcessor { private final Gson gson = new GsonBuilder() .setFieldNamingStrategy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES) @@ -88,19 +93,19 @@ public boolean process(Set annotations, RoundEnvironment sourceSet = null; } } catch (IOException e) { - messager.printError("Cannot determine source set"); + messager.printMessage(Diagnostic.Kind.ERROR, "Cannot determine source set"); throw new RuntimeException(e); } SourceProvider sourceProvider = SourceProviders.getSourceProvider(filer, buildPath); if(sourceProvider == null) { - messager.printError("Cannot determine source provider"); + messager.printMessage(Diagnostic.Kind.ERROR,"Cannot determine source provider"); throw new RuntimeException(); } String configName = sourceProvider.getName(); ConfigurableSettings settings = generateSettings(sourceSet, configName, buildPath); - messager.printNote("Found config name: \"%s\" for source set \"%s\"".formatted(settings.name(), settings.sourceSet())); + messager.printMessage(Diagnostic.Kind.NOTE, "Found config name: \"%s\" for source set \"%s\"".formatted(settings.name(), settings.sourceSet())); ConfigLoaderGenerator loaderGenerator = new ConfigLoaderGenerator(filer, types, messager, settings); ConfigGenerator configGenerator = new ConfigGenerator(filer, types, messager, settings); @@ -115,7 +120,7 @@ public boolean process(Set annotations, RoundEnvironment screenFactoryGenerator.generateYaclScreenFactory(roots, configGenerator::getExternalReference); } } catch (IOException e) { - messager.printError("Could not generate config classes"); + messager.printMessage(Diagnostic.Kind.ERROR,"Could not generate config classes"); throw new RuntimeException(e); } @@ -166,7 +171,7 @@ private void generateSettingsFile(ConfigurableSettings settings, Path buildPath) out.write(gson.toJson(settings).getBytes()); } } catch (IOException e) { - messager.printError("Could not write settings file"); + messager.printMessage(Diagnostic.Kind.ERROR,"Could not write settings file"); throw new RuntimeException(e); } } diff --git a/src/main/java/com/bawnorton/configurable/ap/generator/ConfigGenerator.java b/src/main/java/com/bawnorton/configurable/ap/generator/ConfigGenerator.java index 938fcc9..e79e74d 100644 --- a/src/main/java/com/bawnorton/configurable/ap/generator/ConfigGenerator.java +++ b/src/main/java/com/bawnorton/configurable/ap/generator/ConfigGenerator.java @@ -7,6 +7,7 @@ import javax.annotation.processing.Messager; import javax.lang.model.element.Element; import javax.lang.model.util.Types; +import javax.tools.Diagnostic; import javax.tools.JavaFileObject; import java.io.IOException; import java.io.PrintWriter; @@ -147,7 +148,7 @@ private void addClampedConstraint(ConfigurableHolder holder, Element element, St double min = holder.min(); double max = holder.max(); if (min > max) { - messager.printError("min must be smaller than or equal to the max", element); + messager.printMessage(Diagnostic.Kind.ERROR, "min must be smaller than or equal to the max", element); } constraintSet.append(".addClamped(%s, %s)".formatted(min, max)); } diff --git a/src/main/java/com/bawnorton/configurable/ap/generator/ConfigLoaderGenerator.java b/src/main/java/com/bawnorton/configurable/ap/generator/ConfigLoaderGenerator.java index 79446ae..2ef7686 100644 --- a/src/main/java/com/bawnorton/configurable/ap/generator/ConfigLoaderGenerator.java +++ b/src/main/java/com/bawnorton/configurable/ap/generator/ConfigLoaderGenerator.java @@ -96,9 +96,9 @@ private void parseNested(List stack, JsonObject nestedJson, Config confi for(String key : keys) { JsonElement element = nestedJson.get(key); if(element.isJsonObject()) { - stack.addLast(key); + stack.add(key); parseNested(stack, element.getAsJsonObject(), config); - stack.removeLast(); + stack.remove(stack.size() - 1); } else if (element.isJsonNull()) { parseReference(key, null, stack, config); } else if (element.isJsonPrimitive()) { diff --git a/src/main/java/com/bawnorton/configurable/ap/generator/ConfigScreenFactoryGenerator.java b/src/main/java/com/bawnorton/configurable/ap/generator/ConfigScreenFactoryGenerator.java index 30786a0..353b762 100644 --- a/src/main/java/com/bawnorton/configurable/ap/generator/ConfigScreenFactoryGenerator.java +++ b/src/main/java/com/bawnorton/configurable/ap/generator/ConfigScreenFactoryGenerator.java @@ -16,6 +16,7 @@ import javax.lang.model.type.DeclaredType; import javax.lang.model.util.Elements; import javax.lang.model.util.Types; +import javax.tools.Diagnostic; import javax.tools.JavaFileObject; import org.jetbrains.annotations.NotNull; import java.io.IOException; @@ -257,7 +258,7 @@ private YaclRoot createYaclImpl(List roots, Function new YaclOptionController.CyclingList( @@ -265,7 +266,7 @@ private YaclRoot createYaclImpl(List roots, Function { - messager.printError("Could not automatically create controller for type: %s".formatted(entry.getFullyQualifiedTypeName(types)), entry.element()); + messager.printMessage(Diagnostic.Kind.ERROR, "Could not automatically create controller for type: %s".formatted(entry.getFullyQualifiedTypeName(types)), entry.element()); throw new RuntimeException(); } }; diff --git a/src/main/java/com/bawnorton/configurable/ap/tree/ConfigurableTree.java b/src/main/java/com/bawnorton/configurable/ap/tree/ConfigurableTree.java index 032de77..d740b8f 100644 --- a/src/main/java/com/bawnorton/configurable/ap/tree/ConfigurableTree.java +++ b/src/main/java/com/bawnorton/configurable/ap/tree/ConfigurableTree.java @@ -6,6 +6,7 @@ import javax.lang.model.element.Element; import javax.lang.model.element.Modifier; import javax.lang.model.type.TypeKind; +import javax.tools.Diagnostic; import java.util.ArrayList; import java.util.Comparator; import java.util.HashSet; @@ -98,25 +99,25 @@ private ConfigurableElement createConfigurableElement(Element element) { getAnnotationMirror(element, Configurable.class.getCanonicalName()) ); if (annotation == null) { - messager.printError("Element \"%s\" does not have Configurable annotation".formatted(element.getSimpleName()), element); + messager.printMessage(Diagnostic.Kind.ERROR, "Element \"%s\" does not have Configurable annotation".formatted(element.getSimpleName()), element); throw new RuntimeException(); } Set modifiers = element.getModifiers(); if(element.getKind().isField()) { if(modifiers.contains(Modifier.FINAL)) { - messager.printError("Configurable field \"%s\" cannot be final".formatted(element.getSimpleName()), element); + messager.printMessage(Diagnostic.Kind.ERROR, "Configurable field \"%s\" cannot be final".formatted(element.getSimpleName()), element); throw new RuntimeException(); } else if (!modifiers.contains(Modifier.STATIC)) { - messager.printError("Configurable field \"%s\" must be static".formatted(element.getSimpleName()), element); + messager.printMessage(Diagnostic.Kind.ERROR, "Configurable field \"%s\" must be static".formatted(element.getSimpleName()), element); throw new RuntimeException(); } else if(annotation.yacl().collapsed()) { - messager.printError("Configurable field \"%s\" cannot be collapsed, only classes allowed".formatted(element.getSimpleName()), element); + messager.printMessage(Diagnostic.Kind.ERROR, "Configurable field \"%s\" cannot be collapsed, only classes allowed".formatted(element.getSimpleName()), element); throw new RuntimeException(); } } else if (element.getKind().isClass()) { if(modifiers.contains(Modifier.PRIVATE)) { - messager.printError("Configurable class \"%s\" cannot be private".formatted(element.getSimpleName()), element); + messager.printMessage(Diagnostic.Kind.ERROR, "Configurable class \"%s\" cannot be private".formatted(element.getSimpleName()), element); throw new RuntimeException(); } } @@ -129,7 +130,7 @@ private ConfigurableElement createConfigurableElement(Element element) { .toList(); if (element.getKind().isClass() && children.isEmpty()) { - messager.printError("Configurable class \"%s\" must have at least one Configurable field or class".formatted(element.getSimpleName()), element); + messager.printMessage(Diagnostic.Kind.ERROR, "Configurable class \"%s\" must have at least one Configurable field or class".formatted(element.getSimpleName()), element); throw new RuntimeException(); } @@ -144,7 +145,7 @@ private ConfigurableElement createConfigurableElement(Element element) { .equals("org.spongepowered.asm.mixin.Mixin")) .findFirst() .ifPresent(mirror -> { - messager.printError("Configurable element \"%s\" must be outside a mixin class".formatted(element.getSimpleName()), element); + messager.printMessage(Diagnostic.Kind.ERROR, "Configurable element \"%s\" must be outside a mixin class".formatted(element.getSimpleName()), element); throw new RuntimeException(); }); } diff --git a/src/main/java/com/bawnorton/configurable/ap/yacl/YaclDescriptionImage.java b/src/main/java/com/bawnorton/configurable/ap/yacl/YaclDescriptionImage.java index ac3819e..529924e 100644 --- a/src/main/java/com/bawnorton/configurable/ap/yacl/YaclDescriptionImage.java +++ b/src/main/java/com/bawnorton/configurable/ap/yacl/YaclDescriptionImage.java @@ -30,20 +30,25 @@ protected String getSpec(int depth) { if(customOwner != null && customMethod != null) { return "customImage(%s)".formatted(getCustomImageSpec()); } + //? if >=1.21 { + /*String id = "Identifier.of(\"%s\")".formatted(image.value()); + *///?} else { + String id = "new Identifier(\"%s\")".formatted(image.value()); + //?} return switch (image.type()) { case RESOURCE -> { if(!image.path().isEmpty()) { - yield "image(Path.of(\"%s\"), Identifier.of(\"%s\"))".formatted( + yield "image(Path.of(\"%s\"), %s)".formatted( image.path(), - image.value() + id ); } int textureWidth = image.textureWidth() == 0 ? image.width() : image.textureWidth(); int textureHeight = image.textureHeight() == 0 ? image.height() : image.textureHeight(); - yield "image(Identifier.of(\"%s\"), %sF, %sF, %s, %s, %s, %s)".formatted( - image.value(), + yield "image(%s, %sF, %sF, %s, %s, %s, %s)".formatted( + id, image.u(), image.v(), image.width(), @@ -54,13 +59,13 @@ protected String getSpec(int depth) { } case WEBP -> { if(!image.path().isEmpty()) { - yield "webpImage(Path.of(\"%s\"), Identifier.of(\"%s\"))".formatted( + yield "webpImage(Path.of(\"%s\"), %s)".formatted( image.path(), - image.value() + id ); } - yield "webpImage(Identifier.of(\"%s\"))".formatted(image.value()); + yield "webpImage(%s)".formatted(id); } }; } diff --git a/src/main/java/com/bawnorton/configurable/client/mixin/ModMenuMixin.java b/src/main/java/com/bawnorton/configurable/client/mixin/ModMenuMixin.java index 269c877..46a0390 100644 --- a/src/main/java/com/bawnorton/configurable/client/mixin/ModMenuMixin.java +++ b/src/main/java/com/bawnorton/configurable/client/mixin/ModMenuMixin.java @@ -20,9 +20,16 @@ @Mixin(value = ModMenu.class, remap = false) public abstract class ModMenuMixin { - @Shadow @Final private static Map> configScreenFactories; + //? if >=1.21 { + /*@Shadow @Final private static Map> configScreenFactories; @Shadow @Final private static List apiImplementations; + *///?} else { + @Shadow private static Map> configScreenFactories; + + @Shadow private static List>> delayedScreenFactoryProviders; + //?} + @Inject( method = "onInitializeClient", @@ -49,7 +56,11 @@ public ConfigScreenFactory getModConfigScreenFactory() { ModMenuApi api = apiGetter.apply(wrapper); configScreenFactories.put(name, api.getModConfigScreenFactory()); - apiImplementations.add(api); + //? if >=1.21 { + /*apiImplementations.add(api); + *///?} else { + delayedScreenFactoryProviders.add(api.getProvidedConfigScreenFactories()); + //?} })); } } diff --git a/src/main/java/com/bawnorton/configurable/ref/gson/ItemTypeAdapter.java b/src/main/java/com/bawnorton/configurable/ref/gson/ItemTypeAdapter.java index 9463cce..5c024cd 100644 --- a/src/main/java/com/bawnorton/configurable/ref/gson/ItemTypeAdapter.java +++ b/src/main/java/com/bawnorton/configurable/ref/gson/ItemTypeAdapter.java @@ -19,7 +19,12 @@ public class ItemTypeAdapter implements JsonSerializer, JsonDeserializer=0.15.0", "minecraft": "${minecraft_dependency}", - "java": ">=21", "fabric-api": "*" }, "custom": { diff --git a/stonecutter.gradle.kts b/stonecutter.gradle.kts index 584861a..17a8686 100644 --- a/stonecutter.gradle.kts +++ b/stonecutter.gradle.kts @@ -1,7 +1,7 @@ plugins { id("dev.kikugie.stonecutter") } -stonecutter active "1.21.1-fabric-yarn" /* [SC] DO NOT EDIT */ +stonecutter active "1.20.1-fabric-yarn" /* [SC] DO NOT EDIT */ stonecutter registerChiseled tasks.register("chiseledBuildAndCollect", stonecutter.chiseled) { group = "project" diff --git a/versions/1.20.1-fabric-mojmap/gradle.properties b/versions/1.20.1-fabric-mojmap/gradle.properties new file mode 100644 index 0000000..ef4df20 --- /dev/null +++ b/versions/1.20.1-fabric-mojmap/gradle.properties @@ -0,0 +1,10 @@ +loom.platform=fabric +mappings=mojmap + +yarn_build=10 +fabric_loader=0.16.2 +minecraft_dependency=>=1.20.1 +supported_versions=1.20.1 + +modmenu=7.2.2 +yacl_version=3.5.0+1.20.1 \ No newline at end of file diff --git a/versions/1.20.1-fabric-yarn/gradle.properties b/versions/1.20.1-fabric-yarn/gradle.properties new file mode 100644 index 0000000..4548d7a --- /dev/null +++ b/versions/1.20.1-fabric-yarn/gradle.properties @@ -0,0 +1,10 @@ +loom.platform=fabric +mappings=yarn + +yarn_build=10 +fabric_loader=0.16.2 +minecraft_dependency=>=1.20.1 +supported_versions=1.20.1 + +modmenu=7.2.2 +yacl_version=3.5.0+1.20.1 \ No newline at end of file diff --git a/versions/1.21.1-fabric-mojmap/gradle.properties b/versions/1.21.1-fabric-mojmap/gradle.properties index ab2387e..7f2223f 100644 --- a/versions/1.21.1-fabric-mojmap/gradle.properties +++ b/versions/1.21.1-fabric-mojmap/gradle.properties @@ -6,4 +6,5 @@ fabric_loader=0.16.2 minecraft_dependency=>=1.21 supported_versions=1.21, 1.21.1 -modmenu=11.0.2 \ No newline at end of file +modmenu=11.0.2 +yacl_version=3.5.0+1.21 \ No newline at end of file diff --git a/versions/1.21.1-fabric-yarn/gradle.properties b/versions/1.21.1-fabric-yarn/gradle.properties index 6ce9ab1..9a4a4f7 100644 --- a/versions/1.21.1-fabric-yarn/gradle.properties +++ b/versions/1.21.1-fabric-yarn/gradle.properties @@ -6,4 +6,5 @@ fabric_loader=0.16.2 minecraft_dependency=>=1.21 supported_versions=1.21, 1.21.1 -modmenu=11.0.2 \ No newline at end of file +modmenu=11.0.2 +yacl_version=3.5.0+1.21 \ No newline at end of file diff --git a/versions/1.21.1-neoforge-mojmap/gradle.properties b/versions/1.21.1-neoforge-mojmap/gradle.properties index 0812b47..e3f5b40 100644 --- a/versions/1.21.1-neoforge-mojmap/gradle.properties +++ b/versions/1.21.1-neoforge-mojmap/gradle.properties @@ -4,4 +4,6 @@ mappings=mojmap yarn_build=3 neoforge_loader=21.1.31 minecraft_dependency=>=1.21 -supported_versions=1.21, 1.21.1 \ No newline at end of file +supported_versions=1.21, 1.21.1 + +yacl_version=3.5.0+1.21 \ No newline at end of file diff --git a/versions/1.21.1-neoforge-yarn/gradle.properties b/versions/1.21.1-neoforge-yarn/gradle.properties index d520214..eb14a7d 100644 --- a/versions/1.21.1-neoforge-yarn/gradle.properties +++ b/versions/1.21.1-neoforge-yarn/gradle.properties @@ -4,4 +4,6 @@ mappings=yarn yarn_build=3 neoforge_loader=21.1.31 minecraft_dependency=>=1.21 -supported_versions=1.21, 1.21.1 \ No newline at end of file +supported_versions=1.21, 1.21.1 + +yacl_version=3.5.0+1.21 \ No newline at end of file