From 52623b715d395f65f96e09f4492285935b797b4b Mon Sep 17 00:00:00 2001 From: Linnea Gräf Date: Thu, 12 Sep 2024 13:34:11 +0200 Subject: Isolate CIT resewn compat --- build.gradle.kts | 22 +++- buildSrc/src/InnerJarsUnpacker.kt | 70 ++++++++++++ citresewn-defaults-1.2.0+1.21.jar | Bin 224043 -> 0 bytes .../citresewn/java/ConditionDirectAccessHelper.kt | 59 ++++++++++ .../compat/citresewn/MixinConditionComponents.java | 123 +++++++++++++++++++++ .../firmament/mixins/MixinConditionComponents.java | 123 --------------------- .../kotlin/events/subscription/SubscriptionList.kt | 3 + src/main/kotlin/util/ConditionNBTMixin.kt | 58 ---------- src/main/resources/fabric.mod.json | 7 +- .../kotlin/process/SubscribeAnnotationProcessor.kt | 2 +- 10 files changed, 279 insertions(+), 188 deletions(-) create mode 100644 buildSrc/src/InnerJarsUnpacker.kt delete mode 100644 citresewn-defaults-1.2.0+1.21.jar create mode 100644 src/compat/citresewn/java/ConditionDirectAccessHelper.kt create mode 100644 src/compat/citresewn/java/moe/nea/firmament/mixins/compat/citresewn/MixinConditionComponents.java delete mode 100644 src/main/java/moe/nea/firmament/mixins/MixinConditionComponents.java delete mode 100644 src/main/kotlin/util/ConditionNBTMixin.kt diff --git a/build.gradle.kts b/build.gradle.kts index cb31469..cdb97ff 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -94,6 +94,18 @@ kotlin { } } } +fun String.capitalizeN() = replaceFirstChar { it.uppercaseChar() } +fun innerJarsOf(name: String, dependency: Dependency): FileCollection { + val task = tasks.create("unpackInnerJarsFor${name.capitalizeN()}", InnerJarsUnpacker::class) { + this.inputJars.setFrom(files(configurations.detachedConfiguration(dependency))) + this.outputDir.set(layout.buildDirectory.dir("unpackedJars/$name").also { + it.get().asFile.mkdirs() + }) + } + println("Constructed innerJars task: ${project.files(task).toList()}") + return project.files(task) +} + val compatSourceSets: MutableSet = mutableSetOf() fun createIsolatedSourceSet(name: String, path: String = "compat/$name"): SourceSet { val ss = sourceSets.create(name) { @@ -103,7 +115,7 @@ fun createIsolatedSourceSet(name: String, path: String = "compat/$name"): Source compatSourceSets.add(ss) loom.createRemapConfigurations(ss) val mainSS = sourceSets.main.get() - val upperName = ss.name.replaceFirstChar { it.uppercaseChar() } + val upperName = ss.name.capitalizeN() configurations { (ss.implementationConfigurationName) { extendsFrom(getByName(mainSS.compileClasspathConfigurationName)) @@ -140,6 +152,7 @@ val SourceSet.modImplementationConfigurationName }!!.sourceConfiguration val configuredSourceSet = createIsolatedSourceSet("configured") val sodiumSourceSet = createIsolatedSourceSet("sodium") +val citResewnSourceSet = createIsolatedSourceSet("citresewn") val shadowMe by configurations.creating { exclude(group = "org.jetbrains.kotlin") @@ -163,8 +176,6 @@ val nonModImplentation by configurations.creating { configurations.implementation.get().extendsFrom(this) } -loom { -} dependencies { // Minecraft dependencies @@ -208,6 +219,10 @@ dependencies { (configuredSourceSet.modImplementationConfigurationName)(libs.configured) (sodiumSourceSet.modImplementationConfigurationName)(libs.sodium) + (citResewnSourceSet.modImplementationConfigurationName)( + innerJarsOf("citresewn", dependencies.create(libs.citresewn.get())).asFileTree) + (citResewnSourceSet.modImplementationConfigurationName)(libs.citresewn) + // Actual dependencies modCompileOnly(libs.rei.api) { exclude(module = "architectury") @@ -227,7 +242,6 @@ dependencies { // Dev environment preinstalled mods modLocalRuntime(libs.bundles.runtime.required) modLocalRuntime(libs.bundles.runtime.optional) - modImplementation(modLocalRuntime(project.files("citresewn-defaults-1.2.0+1.21.jar"))!!) modLocalRuntime(libs.jarvis.fabric) transInclude.resolvedConfiguration.resolvedArtifacts.forEach { diff --git a/buildSrc/src/InnerJarsUnpacker.kt b/buildSrc/src/InnerJarsUnpacker.kt new file mode 100644 index 0000000..de06467 --- /dev/null +++ b/buildSrc/src/InnerJarsUnpacker.kt @@ -0,0 +1,70 @@ +import com.google.gson.Gson +import com.google.gson.JsonArray +import com.google.gson.JsonObject +import com.google.gson.JsonPrimitive +import java.io.File +import java.util.zip.ZipInputStream +import org.gradle.api.DefaultTask +import org.gradle.api.file.ConfigurableFileCollection +import org.gradle.api.file.DirectoryProperty +import org.gradle.api.tasks.InputFile +import org.gradle.api.tasks.InputFiles +import org.gradle.api.tasks.OutputDirectory +import org.gradle.api.tasks.OutputFiles +import org.gradle.api.tasks.TaskAction +import kotlin.io.path.createDirectories +import kotlin.io.path.outputStream + +abstract class InnerJarsUnpacker : DefaultTask() { + @get:InputFiles + abstract val inputJars: ConfigurableFileCollection + + @get:OutputDirectory + abstract val outputDir: DirectoryProperty + + private fun getFabricModJson(inputFile: File): JsonObject { + inputFile.inputStream().use { + val zis = ZipInputStream(it) + while (true) { + val entry = zis.nextEntry ?: error("Failed to find fabric.mod.json") + if (entry.name == "fabric.mod.json") { + return Gson().fromJson(zis.reader(), JsonObject::class.java) + } + } + } + } + + @TaskAction + fun unpack() { + inputJars.forEach { inputFile -> + val fabricModObject = getFabricModJson(inputFile) + val jars = fabricModObject["jars"] as? JsonArray ?: error("No jars to unpack in $inputFile") + val jarPaths = jars.map { + ((it as? JsonObject)?.get("file") as? JsonPrimitive)?.asString + ?: error("Invalid Jar $it in $inputFile") + } + extractJars(inputFile, jarPaths) + } + } + + private fun extractJars(inputFile: File, jarPaths: List) { + val outputFile = outputDir.get().asFile.toPath() + val jarPathSet = jarPaths.toMutableSet() + inputFile.inputStream().use { + val zis = ZipInputStream(it) + while (true) { + val entry = zis.nextEntry ?: break + if (jarPathSet.remove(entry.name)) { + val resolvedPath = outputFile.resolve(entry.name) + resolvedPath.parent.createDirectories() + resolvedPath.outputStream().use { os -> + zis.copyTo(os) + } + } + } + } + if (jarPathSet.isNotEmpty()) { + error("Could not extract all jars: $jarPathSet") + } + } +} diff --git a/citresewn-defaults-1.2.0+1.21.jar b/citresewn-defaults-1.2.0+1.21.jar deleted file mode 100644 index c613fa9..0000000 Binary files a/citresewn-defaults-1.2.0+1.21.jar and /dev/null differ diff --git a/src/compat/citresewn/java/ConditionDirectAccessHelper.kt b/src/compat/citresewn/java/ConditionDirectAccessHelper.kt new file mode 100644 index 0000000..af97a40 --- /dev/null +++ b/src/compat/citresewn/java/ConditionDirectAccessHelper.kt @@ -0,0 +1,59 @@ +package moe.nea.firmament.compat.citresewn + +import java.lang.invoke.MethodHandles +import java.util.function.BiPredicate +import java.util.function.Function +import shcm.shsupercm.fabric.citresewn.defaults.cit.conditions.ConditionNBT + +object ConditionNBTMixin { + class Helper { + // TODO: make lambdametafactory work by way of modifying the actual modifiers + + val stringMatcherType = ConditionNBT::class.java.getDeclaredField("matchString").type + + val accessMatcher = run { + val matchStringF = ConditionNBT::class.java.getDeclaredField("matchString"); + matchStringF.isAccessible = true + val l = MethodHandles.privateLookupIn(ConditionNBT::class.java, MethodHandles.lookup()) +// val mt = MethodType.methodType(stringMatcherType, ConditionNBT::class.java) +// val callsite = LambdaMetafactory.metafactory( +// l, "apply", +// MethodType.methodType(Function::class.java), +// MethodType.methodType(java.lang.Object::class.java, java.lang.Object::class.java), +// l.unreflectGetter(matchStringF), +// mt +// ) + val getter = l.unreflectGetter(matchStringF) + Function { getter.invoke(it) as StringMatcher } + } + val directCaller = run { + val matchM = stringMatcherType.getDeclaredMethod("matches", String::class.java); + matchM.isAccessible = true + val l = MethodHandles.privateLookupIn(ConditionNBT::class.java, MethodHandles.lookup()) +// val mt = MethodType.methodType(java.lang.Boolean.TYPE, stringMatcherType, String::class.java) +// val callsite = LambdaMetafactory.metafactory( +// l, "test", +// MethodType.methodType(BiPredicate::class.java), +// mt, +// l.unreflect(matchM), +// mt +// ) + val func = l.unreflect(matchM) + BiPredicate { a, b -> func.invoke(a, b) as Boolean } + } + + fun test(condition: ConditionNBT, text: String): Boolean { + return directCaller.test(accessMatcher.apply(condition), text) as Boolean + } + } + + val helper = Helper() + + @JvmStatic + fun invokeDirectConditionNBTStringMatch( + nbt: ConditionNBT, + text: String, + ): Boolean { + return helper.test(nbt, text) + } +} diff --git a/src/compat/citresewn/java/moe/nea/firmament/mixins/compat/citresewn/MixinConditionComponents.java b/src/compat/citresewn/java/moe/nea/firmament/mixins/compat/citresewn/MixinConditionComponents.java new file mode 100644 index 0000000..0743d40 --- /dev/null +++ b/src/compat/citresewn/java/moe/nea/firmament/mixins/compat/citresewn/MixinConditionComponents.java @@ -0,0 +1,123 @@ +package moe.nea.firmament.mixins.compat.citresewn; + +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import com.llamalad7.mixinextras.sugar.Local; +import com.llamalad7.mixinextras.sugar.ref.LocalRef; +import com.mojang.serialization.Codec; +import com.mojang.serialization.DataResult; +import com.mojang.serialization.DynamicOps; +import moe.nea.firmament.compat.citresewn.ConditionNBTMixin; +import moe.nea.firmament.features.texturepack.CustomSkyBlockTextures; +import net.minecraft.component.ComponentType; +import net.minecraft.component.DataComponentTypes; +import net.minecraft.component.type.NbtComponent; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Pseudo; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import shcm.shsupercm.fabric.citresewn.CITResewn; +import shcm.shsupercm.fabric.citresewn.cit.CITContext; +import shcm.shsupercm.fabric.citresewn.defaults.cit.conditions.ConditionComponents; +import shcm.shsupercm.fabric.citresewn.defaults.cit.conditions.ConditionNBT; +import shcm.shsupercm.fabric.citresewn.pack.format.PropertyGroup; +import shcm.shsupercm.fabric.citresewn.pack.format.PropertyKey; +import shcm.shsupercm.fabric.citresewn.pack.format.PropertyValue; + +// People are complaining but this really is not my place to fix things + +@Mixin(ConditionComponents.class) +@Pseudo +public class MixinConditionComponents { + @Shadow + private ComponentType componentType; + + @Shadow(remap = false) + private ConditionNBT fallbackNBTCheck; + @Unique + private String[] pathCheck; + @Unique + private int loreInt = -1; + + @Inject(method = "load", at = @At("HEAD"), remap = false) + public void addExtraAttributeSupport(PropertyKey key, PropertyValue value, PropertyGroup properties, CallbackInfo ci, + @Local(argsOnly = true) LocalRef keyRef, + @Local(argsOnly = true) LocalRef valueRef) { + if (!CustomSkyBlockTextures.TConfig.INSTANCE.getEnableLegacyCIT()) return; + if (!"nbt".equals(key.path())) return; + if (!value.keyMetadata().startsWith("ExtraAttributes.")) return; + keyRef.set(new PropertyKey(key.namespace(), "component")); + valueRef.set(new PropertyValue( + "minecraft:custom_data" + value.keyMetadata().substring("ExtraAttributes".length()), + value.value(), + value.separator(), + value.position(), + value.propertiesIdentifier(), + value.packName() + )); + CITResewn.logWarnLoading(properties.messageWithDescriptorOf("NBT condition is not supported since 1.21. THIS IS A FIRMAMENT SPECIAL FEATURE ALLOWING YOU TO CONTINUE TO USE nbt.ExtraAttributes.* PROPERTIES FOR A LIMITED TIME! UPDATE YOUR .PROPERTIES FILES OR SWITCH TO FIRMAMENT CIT (https://github.com/FirmamentMC/CitToFirm)", + value.position())); + } + + @Inject(method = "load", + at = @At(value = "INVOKE", remap = false, target = "Lshcm/shsupercm/fabric/citresewn/defaults/cit/conditions/ConditionNBT;loadNbtCondition(Lshcm/shsupercm/fabric/citresewn/pack/format/PropertyValue;Lshcm/shsupercm/fabric/citresewn/pack/format/PropertyGroup;[Ljava/lang/String;Ljava/lang/String;)V"), + remap = false) + private void onLoadSavePath(PropertyKey key, PropertyValue value, PropertyGroup properties, CallbackInfo ci, + @Local String[] path) { + this.pathCheck = path; + this.loreInt = -1; + } + + @Unique + private boolean matchStringDirect(String directString, CITContext context) { + return ConditionNBTMixin.invokeDirectConditionNBTStringMatch(fallbackNBTCheck, directString); + } + + @WrapOperation(method = "test", at = @At(value = "INVOKE", target = "Lcom/mojang/serialization/Codec;encodeStart(Lcom/mojang/serialization/DynamicOps;Ljava/lang/Object;)Lcom/mojang/serialization/DataResult;"), remap = false) + DataResult fastPathUnsafeNbtComponent( + Codec instance, + DynamicOps dynamicOps, + Object o, + Operation original) { + if (o instanceof NbtComponent nbtComponent) { + return DataResult.success(nbtComponent.getNbt()); + } + return original.call(instance, dynamicOps, o); + } + + @Inject(method = "test", at = @At("HEAD"), cancellable = true, remap = false) + void fastPathDisplayName(CITContext context, CallbackInfoReturnable cir) { + if (this.componentType == DataComponentTypes.CUSTOM_NAME && pathCheck.length == 0) { + var displayName = context.stack.getComponents().get(DataComponentTypes.CUSTOM_NAME); + if (displayName != null) { + cir.setReturnValue(matchStringDirect((displayName.getString()), context)); + } + } + if (this.componentType == DataComponentTypes.LORE && pathCheck.length == 1) { + var lore = context.stack.getComponents().get(DataComponentTypes.LORE); + if (lore != null) { + var loreLines = lore.lines(); + if (pathCheck[0].equals("*")) { + for (var loreLine : loreLines) { + if (matchStringDirect((loreLine.getString()), context)) { + cir.setReturnValue(true); + return; + } + } + cir.setReturnValue(false); + } else { + if (loreInt < 0) + loreInt = Integer.parseInt(pathCheck[0]); + cir.setReturnValue(0 <= loreInt && loreInt < loreLines.size() && + matchStringDirect((loreLines.get(loreInt).getString()), context)); + } + } + } + } + + +} diff --git a/src/main/java/moe/nea/firmament/mixins/MixinConditionComponents.java b/src/main/java/moe/nea/firmament/mixins/MixinConditionComponents.java deleted file mode 100644 index 602c13d..0000000 --- a/src/main/java/moe/nea/firmament/mixins/MixinConditionComponents.java +++ /dev/null @@ -1,123 +0,0 @@ -package moe.nea.firmament.mixins; - -// People are complaining but this really is not my place to fix things - -import com.llamalad7.mixinextras.injector.wrapoperation.Operation; -import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; -import com.llamalad7.mixinextras.sugar.Local; -import com.llamalad7.mixinextras.sugar.ref.LocalRef; -import com.mojang.serialization.Codec; -import com.mojang.serialization.DataResult; -import com.mojang.serialization.DynamicOps; -import moe.nea.firmament.features.texturepack.CustomSkyBlockTextures; -import moe.nea.firmament.util.ConditionNBTMixin; -import net.minecraft.component.ComponentType; -import net.minecraft.component.DataComponentTypes; -import net.minecraft.component.type.NbtComponent; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Pseudo; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import shcm.shsupercm.fabric.citresewn.CITResewn; -import shcm.shsupercm.fabric.citresewn.cit.CITContext; -import shcm.shsupercm.fabric.citresewn.defaults.cit.conditions.ConditionComponents; -import shcm.shsupercm.fabric.citresewn.defaults.cit.conditions.ConditionNBT; -import shcm.shsupercm.fabric.citresewn.pack.format.PropertyGroup; -import shcm.shsupercm.fabric.citresewn.pack.format.PropertyKey; -import shcm.shsupercm.fabric.citresewn.pack.format.PropertyValue; - -@Mixin(ConditionComponents.class) -@Pseudo -public class MixinConditionComponents { - @Shadow - private ComponentType componentType; - - @Shadow(remap = false) - private ConditionNBT fallbackNBTCheck; - @Unique - private String[] pathCheck; - @Unique - private int loreInt = -1; - - @Inject(method = "load", at = @At("HEAD"), remap = false) - public void addExtraAttributeSupport(PropertyKey key, PropertyValue value, PropertyGroup properties, CallbackInfo ci, - @Local(argsOnly = true) LocalRef keyRef, - @Local(argsOnly = true) LocalRef valueRef) { - if (!CustomSkyBlockTextures.TConfig.INSTANCE.getEnableLegacyCIT()) return; - if (!"nbt".equals(key.path())) return; - if (!value.keyMetadata().startsWith("ExtraAttributes.")) return; - keyRef.set(new PropertyKey(key.namespace(), "component")); - valueRef.set(new PropertyValue( - "minecraft:custom_data" + value.keyMetadata().substring("ExtraAttributes".length()), - value.value(), - value.separator(), - value.position(), - value.propertiesIdentifier(), - value.packName() - )); - CITResewn.logWarnLoading(properties.messageWithDescriptorOf("NBT condition is not supported since 1.21. THIS IS A FIRMAMENT SPECIAL FEATURE ALLOWING YOU TO CONTINUE TO USE nbt.ExtraAttributes.* PROPERTIES FOR A LIMITED TIME! UPDATE YOUR .PROPERTIES FILES OR SWITCH TO FIRMAMENT CIT (https://github.com/FirmamentMC/CitToFirm)", - value.position())); - } - - @Inject(method = "load", - at = @At(value = "INVOKE", remap = false, target = "Lshcm/shsupercm/fabric/citresewn/defaults/cit/conditions/ConditionNBT;loadNbtCondition(Lshcm/shsupercm/fabric/citresewn/pack/format/PropertyValue;Lshcm/shsupercm/fabric/citresewn/pack/format/PropertyGroup;[Ljava/lang/String;Ljava/lang/String;)V"), - remap = false) - private void onLoadSavePath(PropertyKey key, PropertyValue value, PropertyGroup properties, CallbackInfo ci, - @Local String[] path) { - this.pathCheck = path; - this.loreInt = -1; - } - - @Unique - private boolean matchStringDirect(String directString, CITContext context) { - return ConditionNBTMixin.invokeDirectConditionNBTStringMatch(fallbackNBTCheck, directString); - } - - @WrapOperation(method = "test", at = @At(value = "INVOKE", target = "Lcom/mojang/serialization/Codec;encodeStart(Lcom/mojang/serialization/DynamicOps;Ljava/lang/Object;)Lcom/mojang/serialization/DataResult;"), remap = false) - DataResult fastPathUnsafeNbtComponent( - Codec instance, - DynamicOps dynamicOps, - Object o, - Operation original) { - if (o instanceof NbtComponent nbtComponent) { - return DataResult.success(nbtComponent.getNbt()); - } - return original.call(instance, dynamicOps, o); - } - - @Inject(method = "test", at = @At("HEAD"), cancellable = true, remap = false) - void fastPathDisplayName(CITContext context, CallbackInfoReturnable cir) { - if (this.componentType == DataComponentTypes.CUSTOM_NAME && pathCheck.length == 0) { - var displayName = context.stack.getComponents().get(DataComponentTypes.CUSTOM_NAME); - if (displayName != null) { - cir.setReturnValue(matchStringDirect((displayName.getString()), context)); - } - } - if (this.componentType == DataComponentTypes.LORE && pathCheck.length == 1) { - var lore = context.stack.getComponents().get(DataComponentTypes.LORE); - if (lore != null) { - var loreLines = lore.lines(); - if (pathCheck[0].equals("*")) { - for (var loreLine : loreLines) { - if (matchStringDirect((loreLine.getString()), context)) { - cir.setReturnValue(true); - return; - } - } - cir.setReturnValue(false); - } else { - if (loreInt < 0) - loreInt = Integer.parseInt(pathCheck[0]); - cir.setReturnValue(0 <= loreInt && loreInt < loreLines.size() && - matchStringDirect((loreLines.get(loreInt).getString()), context)); - } - } - } - } - - -} diff --git a/src/main/kotlin/events/subscription/SubscriptionList.kt b/src/main/kotlin/events/subscription/SubscriptionList.kt index e74a65a..817efc3 100644 --- a/src/main/kotlin/events/subscription/SubscriptionList.kt +++ b/src/main/kotlin/events/subscription/SubscriptionList.kt @@ -21,5 +21,8 @@ interface SubscriptionList { } .toList() } + init { + require(allLists.isNotEmpty()) + } } } diff --git a/src/main/kotlin/util/ConditionNBTMixin.kt b/src/main/kotlin/util/ConditionNBTMixin.kt deleted file mode 100644 index cbc1e66..0000000 --- a/src/main/kotlin/util/ConditionNBTMixin.kt +++ /dev/null @@ -1,58 +0,0 @@ -package moe.nea.firmament.util - -import java.lang.invoke.MethodHandles -import java.util.function.BiPredicate -import java.util.function.Function -import shcm.shsupercm.fabric.citresewn.defaults.cit.conditions.ConditionNBT - -object ConditionNBTMixin { - class Helper { - - val stringMatcherType = ConditionNBT::class.java.getDeclaredField("matchString").type - - val accessMatcher = run { - val matchStringF = ConditionNBT::class.java.getDeclaredField("matchString"); - matchStringF.isAccessible = true - val l = MethodHandles.privateLookupIn(ConditionNBT::class.java, MethodHandles.lookup()) -// val mt = MethodType.methodType(stringMatcherType, ConditionNBT::class.java) -// val callsite = LambdaMetafactory.metafactory( -// l, "apply", -// MethodType.methodType(Function::class.java), -// MethodType.methodType(java.lang.Object::class.java, java.lang.Object::class.java), -// l.unreflectGetter(matchStringF), -// mt -// ) - val getter = l.unreflectGetter(matchStringF) - Function { getter.invoke(it) as StringMatcher } - } - val directCaller = run { - val matchM = stringMatcherType.getDeclaredMethod("matches", String::class.java); - matchM.isAccessible = true - val l = MethodHandles.privateLookupIn(ConditionNBT::class.java, MethodHandles.lookup()) -// val mt = MethodType.methodType(java.lang.Boolean.TYPE, stringMatcherType, String::class.java) -// val callsite = LambdaMetafactory.metafactory( -// l, "test", -// MethodType.methodType(BiPredicate::class.java), -// mt, -// l.unreflect(matchM), -// mt -// ) - val func = l.unreflect(matchM) - BiPredicate { a, b -> func.invoke(a, b) as Boolean } - } - - fun test(condition: ConditionNBT, text: String): Boolean { - return directCaller.test(accessMatcher.apply(condition), text) as Boolean - } - } - - val helper = Helper() - - @JvmStatic - fun invokeDirectConditionNBTStringMatch( - nbt: ConditionNBT, - text: String, - ): Boolean { - return helper.test(nbt, text) - } -} diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index e027783..cb623dc 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -47,7 +47,9 @@ "fabric": "*", "fabric-language-kotlin": ">=${fabric_kotlin_version}", "minecraft": ">=${minecraft_version}", - "roughlyenoughitems": ">=${rei_version}" + "roughlyenoughitems": ">=${rei_version}", + "cloth-config": "*", + "architectury": "*" }, "custom": { "configured": { @@ -62,7 +64,8 @@ }, "mc-publish": { "dependencies": [ - "roughlyenoughitems{modrinth:rei}" + "roughlyenoughitems{modrinth:rei}", + "architectury{modrinth:architectury-api}" ] } } diff --git a/symbols/src/main/kotlin/process/SubscribeAnnotationProcessor.kt b/symbols/src/main/kotlin/process/SubscribeAnnotationProcessor.kt index e6fcd89..5c205cc 100644 --- a/symbols/src/main/kotlin/process/SubscribeAnnotationProcessor.kt +++ b/symbols/src/main/kotlin/process/SubscribeAnnotationProcessor.kt @@ -61,7 +61,7 @@ class SubscribeAnnotationProcessor( } subscriptionsFile.close() val metaInf = codeGenerator.createNewFileByPath( - Dependencies(false), + dependencies, "META-INF/services/moe.nea.firmament.events.subscription.SubscriptionList", extensionName = "") .bufferedWriter() metaInf.append("moe.nea.firmament.annotations.generated.") -- cgit