From 3c8bfedc9c9044818ba1a420cc631ab6a64679a4 Mon Sep 17 00:00:00 2001 From: Su5eD Date: Mon, 16 Dec 2024 17:37:28 +0100 Subject: [PATCH 1/5] Fix java libraries showing up as mods Start work on beta 5 Update dependencies --- build.gradle.kts | 29 ++++++++++--------- gradle.properties | 6 ++-- gradle/wrapper/gradle-wrapper.properties | 2 +- .../connector/locator/ConnectorLocator.java | 3 ++ 4 files changed, 23 insertions(+), 17 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 8f4bc987..5cb8658c 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,16 +1,17 @@ import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar import me.modmuss50.mpp.ReleaseType import net.neoforged.moddevgradle.dsl.RunModel +import net.neoforged.moddevgradle.internal.RunGameTask import java.time.LocalDateTime plugins { java `maven-publish` - id("net.neoforged.moddev") version "2.0.1-beta" + id("net.neoforged.moddev") version "2.0.52-beta" id("io.github.goooler.shadow") version "8.1.8" apply false id("me.modmuss50.mod-publish-plugin") version "0.5.+" id("net.neoforged.gradleutils") version "3.0.0" - id("org.sinytra.adapter.userdev") version "1.2-SNAPSHOT" + id("org.sinytra.adapter.userdev") version "1.2.1-SNAPSHOT" } val versionConnector: String by project @@ -62,13 +63,9 @@ configurations { } "modCompileOnly" { - extendsFrom(configurations.compileOnly.get()) - } - - "modImplementation" { extendsFrom(shade) } - + additionalRuntimeClasspath { extendsFrom(shade) } @@ -95,23 +92,26 @@ neoForge { systemProperty("connector.logging.markers", "MIXINPATCH,MERGER") systemProperty("mixin.debug.export", "true") gameDirectory.set(layout.projectDirectory.dir("run")) - - mods { - maybeCreate("connector").apply { - sourceSet(mod) - } - } } create("client") { client() config(this) } + create("server") { server() config(this) } } + + addModdingDependenciesTo(mod) + + mods { + maybeCreate("connector").apply { + sourceSet(mod) + } + } } repositories { @@ -218,6 +218,9 @@ tasks { assemble { dependsOn(fullJar) } + withType { + dependsOn(jar) + } } publishMods { diff --git a/gradle.properties b/gradle.properties index 120387a4..5ddb43f0 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,13 +7,13 @@ org.gradle.caching=true #org.gradle.configuration-cache=true # Versions -versionConnector=2.0.0-beta.4 +versionConnector=2.0.0-beta.5 versionAdapter=1.13.20+1.21.1-20240811.191740 -versionAdapterDefinition=1.13.21+1.21.1 +versionAdapterDefinition=1.13.22+1.21.1 versionAdapterRuntime=1.0.0+1.21.1 versionMc=1.21.1 -versionNeoForge=21.1.57 +versionNeoForge=21.1.90 versionParchmentMc=1.21 versionParchment=2024.07.28 versionForgeAutoRenamingTool=1.0.12 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 2617362f..4eaec467 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/main/java/org/sinytra/connector/locator/ConnectorLocator.java b/src/main/java/org/sinytra/connector/locator/ConnectorLocator.java index 37cb8280..1b55a3e1 100644 --- a/src/main/java/org/sinytra/connector/locator/ConnectorLocator.java +++ b/src/main/java/org/sinytra/connector/locator/ConnectorLocator.java @@ -147,6 +147,9 @@ private List locateFabricMods(List discoveredMods) { private static IModFile createConnectorModFile(SplitPackageMerger.FilteredModPath modPath) { JarContents jarContents = new JarContentsBuilder().paths(modPath.paths()).pathFilter(modPath.filter()).build(); + if (modPath.metadata().generated()) { + return IModFile.create(SecureJar.from(jarContents), JarModsDotTomlModFileReader::manifestParser, IModFile.Type.LIBRARY, ModFileDiscoveryAttributes.DEFAULT); + } ModJarMetadata modJarMetadata = new ModJarMetadata(jarContents); SecureJar secureJar = SecureJar.from(jarContents, modJarMetadata); IModFile modFile = IModFile.create(secureJar, f -> FabricModMetadataParser.createForgeMetadata(f, modPath.metadata().modMetadata(), modPath.metadata().visibleMixinConfigs(), modPath.metadata().generated())); From f0ec6ce96884013920b3997fb4e8b0563388f193 Mon Sep 17 00:00:00 2001 From: Su5eD Date: Thu, 19 Dec 2024 16:54:10 +0100 Subject: [PATCH 2/5] Add fancy mixin safeguard stability checker --- gradle.properties | 2 +- .../connector/locator/ConnectorLocator.java | 5 ++ .../locator/MixinTransformSafeguard.java | 46 +++++++++++++++++++ .../transformer/jar/JarTransformInstance.java | 12 +++-- .../transformer/jar/JarTransformer.java | 23 ++++++---- .../connector/util/ConnectorConfig.java | 15 +++--- 6 files changed, 83 insertions(+), 20 deletions(-) create mode 100644 src/main/java/org/sinytra/connector/locator/MixinTransformSafeguard.java diff --git a/gradle.properties b/gradle.properties index 5ddb43f0..be4a9d01 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,7 +9,7 @@ org.gradle.caching=true # Versions versionConnector=2.0.0-beta.5 versionAdapter=1.13.20+1.21.1-20240811.191740 -versionAdapterDefinition=1.13.22+1.21.1 +versionAdapterDefinition=1.13.23+1.21.1 versionAdapterRuntime=1.0.0+1.21.1 versionMc=1.21.1 diff --git a/src/main/java/org/sinytra/connector/locator/ConnectorLocator.java b/src/main/java/org/sinytra/connector/locator/ConnectorLocator.java index 1b55a3e1..93038a55 100644 --- a/src/main/java/org/sinytra/connector/locator/ConnectorLocator.java +++ b/src/main/java/org/sinytra/connector/locator/ConnectorLocator.java @@ -132,6 +132,11 @@ private List locateFabricMods(List discoveredMods) { // Run jar transformations (or get existing outputs from cache) List transformed = JarTransformer.transform(candidates, renameLibs, loadedModFiles); + List failing = transformed.stream().filter(j -> j.auditTrail() != null && j.auditTrail().hasFailingMixins()).toList(); + if (!failing.isEmpty()) { + MixinTransformSafeguard.trigger(failing); + } + // Skip last step to save time if an error occured during transformation if (ConnectorEarlyLoader.hasEncounteredException()) { StartupNotificationManager.addModMessage("JAR TRANSFORMATION ERROR"); diff --git a/src/main/java/org/sinytra/connector/locator/MixinTransformSafeguard.java b/src/main/java/org/sinytra/connector/locator/MixinTransformSafeguard.java new file mode 100644 index 00000000..bc2f8c6f --- /dev/null +++ b/src/main/java/org/sinytra/connector/locator/MixinTransformSafeguard.java @@ -0,0 +1,46 @@ +package org.sinytra.connector.locator; + +import com.mojang.logging.LogUtils; +import net.neoforged.fml.ModLoadingException; +import net.neoforged.fml.ModLoadingIssue; +import net.neoforged.fml.loading.progress.StartupNotificationManager; +import org.sinytra.adapter.patch.api.PatchAuditTrail; +import org.sinytra.connector.transformer.jar.JarTransformer; +import org.sinytra.connector.util.ConnectorConfig; +import org.slf4j.Logger; + +import java.util.List; + +public final class MixinTransformSafeguard { + private static final Logger LOGGER = LogUtils.getLogger(); + + public static boolean isEnabled() { + return ConnectorConfig.INSTANCE.get().enableMixinSafeguard(); + } + + public static void trigger(List failing) throws ModLoadingException { + if (!isEnabled()) { + LOGGER.warn("Ignoring {} found incompatibilities as mixin safeguard is disabled", failing.size()); + return; + } + + StartupNotificationManager.addModMessage("INCOMPATIBLE FABRIC MOD FOUND"); + StringBuilder builder = new StringBuilder(); + + String msg = "Found §e" + failing.size() + " incompatible Fabric " + (failing.size() > 1 ? "mods" : "mod") + "§r. Details are provided below.\n\n" + + "With the current configuration, Connector §ccannot guarantee§r a stable environment. Should you still want to proceed, please restart the game.\n\n" + + "§7This one-time safety check can be disabled in Connector's config file under \"enableMixinSafeguard\".§r"; + builder.append(msg).append("\n\n"); + + failing.forEach(p -> { + builder.append("Mod file §e").append(p.input().getFileName().toString()).append("§r has failing mixins:\n"); + for (PatchAuditTrail.Candidate failed : p.auditTrail().getFailingMixins()) { + String[] parts = failed.classNode().name.split("/"); + builder.append("- §c").append(parts[parts.length - 1]).append("§7#§3").append(failed.methodNode().name).append("§r\n"); + } + builder.append("\n"); + }); + + throw new ModLoadingException(ModLoadingIssue.error(builder.toString())); + } +} diff --git a/src/main/java/org/sinytra/connector/transformer/jar/JarTransformInstance.java b/src/main/java/org/sinytra/connector/transformer/jar/JarTransformInstance.java index 1d02b383..043f6a36 100644 --- a/src/main/java/org/sinytra/connector/transformer/jar/JarTransformInstance.java +++ b/src/main/java/org/sinytra/connector/transformer/jar/JarTransformInstance.java @@ -18,6 +18,7 @@ import net.neoforged.fml.loading.LibraryFinder; import net.neoforged.fml.loading.MavenCoordinate; import net.neoforged.neoforgespi.locating.IModFile; +import org.jetbrains.annotations.Nullable; import org.sinytra.adapter.patch.LVTOffsets; import org.sinytra.adapter.patch.api.Patch; import org.sinytra.adapter.patch.api.PatchAuditTrail; @@ -111,12 +112,13 @@ public BytecodeFixerUpperFrontend getBfu() { return bfu; } - public void transformJar(File input, Path output, JarTransformer.FabricModFileMetadata metadata) throws IOException { + @Nullable + public PatchAuditTrail transformJar(File input, Path output, JarTransformer.FabricModFileMetadata metadata) throws IOException { Stopwatch stopwatch = Stopwatch.createStarted(); if (metadata.generated()) { processGeneratedJar(input, output, stopwatch); - return; + return null; } String jarMapping = metadata.manifestAttributes().getValue(FABRIC_MAPPING_NAMESPACE); @@ -130,10 +132,11 @@ public void transformJar(File input, Path output, JarTransformer.FabricModFileMe IMappingFile intermediaryToSrg = resolver.getCurrentMap(JarTransformer.SOURCE_NAMESPACE); AccessorRedirectTransformer accessorRedirectTransformer = new AccessorRedirectTransformer(srgToIntermediary); + PatchAuditTrail jarTrail = PatchAuditTrail.create(); List extraPatches = Stream.concat(this.adapterPatches.stream(), AccessorRedirectTransformer.PATCHES.stream()).toList(); ConnectorRefmapHolder refmapHolder = new ConnectorRefmapHolder(refmap.merged(), refmap.files()); int fabricLVTCompatibility = FabricMixinBootstrap.MixinConfigDecorator.getMixinCompat(metadata.modMetadata()); - PatchEnvironment environment = PatchEnvironment.create(refmapHolder, this.cleanClassLookup, this.bfu.unwrap(), fabricLVTCompatibility, this.auditTrail); + PatchEnvironment environment = PatchEnvironment.create(refmapHolder, this.cleanClassLookup, this.bfu.unwrap(), fabricLVTCompatibility, jarTrail); MixinPatchTransformer patchTransformer = new MixinPatchTransformer(this.lvtOffsetsData, environment, extraPatches); RefmapRemapper refmapRemapper = new RefmapRemapper(refmap.files()); Renamer.Builder builder = Renamer.builder() @@ -168,6 +171,9 @@ public void transformJar(File input, Path output, JarTransformer.FabricModFileMe stopwatch.stop(); LOGGER.debug(JarTransformer.TRANSFORM_MARKER, "Jar {} transformed in {} ms", input.getName(), stopwatch.elapsed(TimeUnit.MILLISECONDS)); + + this.auditTrail.merge(jarTrail); + return jarTrail; } private static void processGeneratedJar(File input, Path output, Stopwatch stopwatch) throws IOException { diff --git a/src/main/java/org/sinytra/connector/transformer/jar/JarTransformer.java b/src/main/java/org/sinytra/connector/transformer/jar/JarTransformer.java index 380aa793..b6c8f443 100644 --- a/src/main/java/org/sinytra/connector/transformer/jar/JarTransformer.java +++ b/src/main/java/org/sinytra/connector/transformer/jar/JarTransformer.java @@ -17,6 +17,8 @@ import net.neoforged.fml.loading.progress.ProgressMeter; import net.neoforged.fml.loading.progress.StartupNotificationManager; import net.neoforged.neoforgespi.locating.IModFile; +import org.jetbrains.annotations.Nullable; +import org.sinytra.adapter.patch.api.PatchAuditTrail; import org.sinytra.connector.ConnectorEarlyLoader; import org.sinytra.connector.locator.ConnectorFabricModMetadata; import org.sinytra.connector.locator.DependencyResolver; @@ -133,12 +135,12 @@ private static List transformJars(List>> futures = paths.stream() + List>>> futures = paths.stream() .map(jar -> { - Future future = executorService.submit(() -> { - FabricModPath path = jar.transform(transformInstance); + Future> future = executorService.submit(() -> { + Pair pair = jar.transform(transformInstance); progress.increment(); - return path; + return pair; }); return Pair.of(jar.input(), future); }) @@ -150,7 +152,8 @@ private static List transformJars(List results = futures.stream() .map(pair -> { try { - return new TransformedFabricModPath(pair.getFirst().toPath(), pair.getSecond().get()); + Pair result = pair.getSecond().get(); + return new TransformedFabricModPath(pair.getFirst().toPath(), result.getFirst(), result.getSecond()); } catch (Throwable t) { throw new ModLoadingException(ConnectorEarlyLoader.createGenericLoadingIssue(t, "Error transforming file " + pair.getFirst().getName())); } @@ -260,20 +263,20 @@ private JarTransformer() {} public record FabricModPath(Path path, FabricModFileMetadata metadata) {} - public record TransformedFabricModPath(Path input, FabricModPath output) {} + public record TransformedFabricModPath(Path input, FabricModPath output, @Nullable PatchAuditTrail auditTrail) {} public record FabricModFileMetadata(ConnectorFabricModMetadata modMetadata, Collection visibleMixinConfigs, Collection mixinConfigs, Set refmaps, Set mixinPackages, Attributes manifestAttributes, boolean containsAT, boolean generated) {} public record TransformableJar(File input, FabricModPath modPath, ConnectorUtil.CacheFile cacheFile) { - public FabricModPath transform(JarTransformInstance transformInstance) throws IOException { + public Pair transform(JarTransformInstance transformInstance) throws IOException { Files.deleteIfExists(this.modPath.path); - transformInstance.transformJar(this.input, this.modPath.path, this.modPath.metadata()); + PatchAuditTrail audit = transformInstance.transformJar(this.input, this.modPath.path, this.modPath.metadata()); this.cacheFile.save(); - return this.modPath; + return Pair.of(this.modPath, audit); } public TransformedFabricModPath toTransformedPath() { - return new TransformedFabricModPath(this.input.toPath(), this.modPath); + return new TransformedFabricModPath(this.input.toPath(), this.modPath, null); } } } diff --git a/src/main/java/org/sinytra/connector/util/ConnectorConfig.java b/src/main/java/org/sinytra/connector/util/ConnectorConfig.java index 00b99dc3..46275c34 100644 --- a/src/main/java/org/sinytra/connector/util/ConnectorConfig.java +++ b/src/main/java/org/sinytra/connector/util/ConnectorConfig.java @@ -27,7 +27,7 @@ import java.util.function.Function; import java.util.function.Supplier; -public record ConnectorConfig(int version, List hiddenMods, Multimap globalModAliases) { +public record ConnectorConfig(int version, List hiddenMods, Multimap globalModAliases, boolean enableMixinSafeguard) { public static final Codec CODEC = RecordCodecBuilder.create(instance -> instance.group( Codec.INT .comapFlatMap(i -> i == 1 ? DataResult.success(i) : DataResult.error(() -> "Unsupported \"version\", must be 1"), Function.identity()) @@ -39,7 +39,7 @@ public record ConnectorConfig(int version, List hiddenMods, Multimap Optional.of(c.hiddenMods())), Codec.unboundedMap( Codec.STRING, - Codec.either(Codec.STRING.listOf(), Codec.STRING).xmap(either -> either.map(list -> list, List::of), list -> list.size() == 1 ? Either.right(list.get(0)) : Either.left(list)) + Codec.either(Codec.STRING.listOf(), Codec.STRING).xmap(either -> either.map(list -> list, List::of), list -> list.size() == 1 ? Either.right(list.getFirst()) : Either.left(list)) ) .xmap(map -> { Multimap aliases = HashMultimap.create(); @@ -51,14 +51,17 @@ public record ConnectorConfig(int version, List hiddenMods, Multimap Optional.of(c.enableMixinSafeguard())) ).apply(instance, ConnectorConfig::new)); - ConnectorConfig(Optional version, Optional> hiddenMods, Multimap globalModAliases) { - this(version.orElse(1), hiddenMods.orElseGet(List::of), globalModAliases); + ConnectorConfig(Optional version, Optional> hiddenMods, Multimap globalModAliases, Optional enableMixinSafeguard) { + this(version.orElse(1), hiddenMods.orElseGet(List::of), globalModAliases, enableMixinSafeguard.orElse(true)); } - private static final ConnectorConfig DEFAULT = new ConnectorConfig(1, List.of(), ConnectorUtil.DEFAULT_GLOBAL_MOD_ALIASES); + private static final ConnectorConfig DEFAULT = new ConnectorConfig(1, List.of(), ConnectorUtil.DEFAULT_GLOBAL_MOD_ALIASES, true); private static final Logger LOGGER = LogUtils.getLogger(); public static final Supplier INSTANCE = Suppliers.memoize(() -> { Path path = FMLPaths.CONFIGDIR.get().resolve("connector.json"); From 8fb49ad076285c0c736d6e052325bf82e7cbe83a Mon Sep 17 00:00:00 2001 From: Su5eD Date: Sat, 21 Dec 2024 15:17:20 +0100 Subject: [PATCH 3/5] Move brigadier module to GAME layer Fixes #1439 --- .../sinytra/connector/service/ConnectorLoaderService.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/sinytra/connector/service/ConnectorLoaderService.java b/src/main/java/org/sinytra/connector/service/ConnectorLoaderService.java index 9a33c662..638d532c 100644 --- a/src/main/java/org/sinytra/connector/service/ConnectorLoaderService.java +++ b/src/main/java/org/sinytra/connector/service/ConnectorLoaderService.java @@ -12,7 +12,6 @@ import net.neoforged.fml.loading.LoadingModList; import net.neoforged.neoforgespi.earlywindow.ImmediateWindowProvider; import org.sinytra.connector.ConnectorEarlyLoader; -import org.sinytra.connector.locator.ConnectorLocator; import org.sinytra.connector.service.hacks.ConnectorForkJoinThreadFactory; import org.sinytra.connector.service.hacks.FabricASMFixer; import org.sinytra.connector.service.hacks.LenientRuntimeEnumExtender; @@ -38,6 +37,7 @@ public class ConnectorLoaderService implements ITransformationService { private static final String NAME = "connector_loader"; private static final String AUTHLIB_MODULE = "authlib"; + private static final String BRIGADIER_MODULE = "brigadier"; private static final Logger LOGGER = LogUtils.getLogger(); private static final VarHandle PLUGINS = uncheck(() -> ConnectorUtil.TRUSTED_LOOKUP.findVarHandle(LaunchPluginHandler.class, "plugins", Map.class)); @@ -122,7 +122,8 @@ public List completeScan(IModuleLayerManager layerManager) { } return List.of(new Resource(IModuleLayerManager.Layer.GAME, List.of( FabricASMFixer.provideGeneratedClassesJar(), - ModuleLayerMigrator.moveModule(AUTHLIB_MODULE) + ModuleLayerMigrator.moveModule(AUTHLIB_MODULE), + ModuleLayerMigrator.moveModule(BRIGADIER_MODULE) ))); } From fb36f5afb19e3e5b08b55b8fd8c4416b435b418c Mon Sep 17 00:00:00 2001 From: Su5eD Date: Tue, 24 Dec 2024 14:44:29 +0100 Subject: [PATCH 4/5] Fabric ASM and ambigous method fix Fixed #1547 --- .../sinytra/connector/ConnectorCoremods.java | 1 + .../OptimizedRenamingTransformer.java | 51 +++++++------------ 2 files changed, 20 insertions(+), 32 deletions(-) diff --git a/src/main/java/org/sinytra/connector/ConnectorCoremods.java b/src/main/java/org/sinytra/connector/ConnectorCoremods.java index 8921605d..62259498 100644 --- a/src/main/java/org/sinytra/connector/ConnectorCoremods.java +++ b/src/main/java/org/sinytra/connector/ConnectorCoremods.java @@ -173,6 +173,7 @@ private static List> getFabricASMTransformers() { TargetType.METHOD, Set.of( ITransformer.Target.targetMethod("com.chocohead.mm.Plugin$1", "generate", "()Ljava/util/function/Consumer;"), + ITransformer.Target.targetMethod("com.chocohead.mm.Plugin$1", "generate", "(Ljava/lang/String;Ljava/util/Collection;)V"), ITransformer.Target.targetMethod("me.shedaniel.mm.Plugin$1", "generate", "(Ljava/lang/String;Ljava/util/Collection;)V") ), input -> { diff --git a/src/main/java/org/sinytra/connector/transformer/OptimizedRenamingTransformer.java b/src/main/java/org/sinytra/connector/transformer/OptimizedRenamingTransformer.java index da358e0a..4babf160 100644 --- a/src/main/java/org/sinytra/connector/transformer/OptimizedRenamingTransformer.java +++ b/src/main/java/org/sinytra/connector/transformer/OptimizedRenamingTransformer.java @@ -7,24 +7,10 @@ import net.minecraftforge.fart.internal.RenamingTransformer; import net.minecraftforge.srgutils.IMappingFile; import org.jetbrains.annotations.Nullable; -import org.objectweb.asm.AnnotationVisitor; -import org.objectweb.asm.ClassReader; -import org.objectweb.asm.ClassVisitor; -import org.objectweb.asm.ClassWriter; -import org.objectweb.asm.Handle; -import org.objectweb.asm.Opcodes; -import org.objectweb.asm.Type; +import org.objectweb.asm.*; import org.objectweb.asm.commons.ClassRemapper; import org.objectweb.asm.commons.Remapper; -import org.objectweb.asm.tree.AbstractInsnNode; -import org.objectweb.asm.tree.AnnotationNode; -import org.objectweb.asm.tree.ClassNode; -import org.objectweb.asm.tree.FieldNode; -import org.objectweb.asm.tree.InvokeDynamicInsnNode; -import org.objectweb.asm.tree.LdcInsnNode; -import org.objectweb.asm.tree.MethodInsnNode; -import org.objectweb.asm.tree.MethodNode; -import org.objectweb.asm.tree.VarInsnNode; +import org.objectweb.asm.tree.*; import org.sinytra.adapter.patch.analysis.MethodCallAnalyzer; import org.sinytra.adapter.patch.analysis.selector.AnnotationHandle; import org.sinytra.adapter.patch.analysis.selector.AnnotationValueHandle; @@ -33,12 +19,7 @@ import org.spongepowered.asm.mixin.gen.AccessorInfo; import java.io.IOException; -import java.util.Collection; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.Set; +import java.util.*; import java.util.concurrent.ConcurrentHashMap; import java.util.function.Consumer; import java.util.regex.Matcher; @@ -107,7 +88,8 @@ protected void postProcess(ClassNode node) { } private void avoidAmbigousMappingRecursion(ClassNode classNode, MethodNode method) { - if (isAmbigousOverridenMethod(classNode, method)) { + int parentMethods = countAmbigousOverridenMethods(classNode, method); + if (parentMethods > 1) { for (AbstractInsnNode insn : method.instructions) { if (insn instanceof MethodInsnNode minsn && minsn.getOpcode() == Opcodes.INVOKEVIRTUAL && minsn.owner.equals(classNode.name) && minsn.name.equals(method.name) && minsn.desc.equals(method.desc)) { List insns = MethodCallAnalyzer.findMethodCallParamInsns(method, minsn); @@ -117,16 +99,25 @@ private void avoidAmbigousMappingRecursion(ClassNode classNode, MethodNode metho } } } + // Look for ambigous methods in our own class + if (parentMethods > 0) { + int i = 1; + for (MethodNode m : classNode.methods) { + if (m != method && m.name.equals(method.name) && m.desc.equals(method.desc)) { + m.name += "$connector_disabled$" + i; + } + } + } } - private boolean isAmbigousOverridenMethod(ClassNode classNode, MethodNode method) { - return classNode.superName != null && this.remapper.getClass(classNode.name) - .map(c -> c.getMethods().stream() + private int countAmbigousOverridenMethods(ClassNode classNode, MethodNode method) { + return classNode.superName != null ? this.remapper.getClass(classNode.name) + .map(c -> (int) c.getMethods().stream() .flatMap(Optional::stream) .filter(m -> !m.getName().equals(m.getMapped()) && m.getMapped().equals(method.name) && method.desc.equals(this.remapper.mapMethodDesc(m.getDescriptor())) && (m.getAccess() & (ACC_PRIVATE | ACC_STATIC)) == 0) - .count() > 1) - .orElse(false); + .count()) + .orElse(0) : 0; } private void processMixinAnnotation(AnnotationNode annotation, PostProcessRemapper postProcessRemapper) { @@ -282,10 +273,6 @@ public MixinAwareEnhancedRemapper(ClassProvider classProvider, IMappingFile map, this.flatMappings = flatMappings; } - public ClassProvider getUpstreamProvider() { - return ((IntermediaryClassProvider) this.classProvider).upstream; - } - @Override public String map(final String key) { String fastMapped = this.flatMappings.map(key); From d309b3ad141bdd873848c93ae63b1cf9713c86ac Mon Sep 17 00:00:00 2001 From: Su5eD Date: Tue, 24 Dec 2024 23:48:30 +0100 Subject: [PATCH 5/5] Bump FFLoader version Exposes custom Neo mod metadata values in Fabric Loader CC @LambdAurora --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index be4a9d01..5a05db1f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -17,7 +17,7 @@ versionNeoForge=21.1.90 versionParchmentMc=1.21 versionParchment=2024.07.28 versionForgeAutoRenamingTool=1.0.12 -versionForgifiedFabricLoader=2.5.33+0.16.0+1.21.1 +versionForgifiedFabricLoader=2.5.34+0.16.0+1.21.1 versionAccessWidener=2.1.0 versionForgifiedFabricApi=0.104.0+2.0.13+1.21.1