From b452afaa13acd1d027b5068dc8a87727b36a2c7c Mon Sep 17 00:00:00 2001 From: makamys Date: Tue, 3 Jan 2023 06:31:16 +0100 Subject: [PATCH] Reimplement dev ModDiscovererMixin in more lightweight way Fixes compat with forge_mod_discoverer_skip_known_libraries in CoreTweaks --- .../mixins/mixin/dev/ModDiscovererMixin.java | 29 ++++--------------- 1 file changed, 6 insertions(+), 23 deletions(-) diff --git a/src/main/java/com/falsepattern/gasstation/mixins/mixin/dev/ModDiscovererMixin.java b/src/main/java/com/falsepattern/gasstation/mixins/mixin/dev/ModDiscovererMixin.java index 66ca0ab..4d83e1a 100644 --- a/src/main/java/com/falsepattern/gasstation/mixins/mixin/dev/ModDiscovererMixin.java +++ b/src/main/java/com/falsepattern/gasstation/mixins/mixin/dev/ModDiscovererMixin.java @@ -4,18 +4,12 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.LocalCapture; +import org.spongepowered.asm.mixin.injection.ModifyVariable; -import cpw.mods.fml.common.FMLLog; -import cpw.mods.fml.common.ModClassLoader; -import cpw.mods.fml.common.discovery.ContainerType; import cpw.mods.fml.common.discovery.ModCandidate; import cpw.mods.fml.common.discovery.ModDiscoverer; -import java.io.File; +import java.util.Arrays; import java.util.List; @Mixin(value = ModDiscoverer.class, @@ -28,21 +22,10 @@ public List getCandidates() { return candidates; } - @Inject(method = "findClasspathMods", - at = @At(value = "INVOKE", - target = "Lcpw/mods/fml/common/FMLLog;finer(Ljava/lang/String;[Ljava/lang/Object;)V"), - locals = LocalCapture.CAPTURE_FAILHARD, + @ModifyVariable(method = "findClasspathMods", + at = @At("STORE"), require = 1) - private void smartCheck(ModClassLoader modClassLoader, CallbackInfo ci, List knownLibraries, File[] minecraftSources, int i) { - FMLLog.fine("Found a minecraft related file at %s, examining for mod candidates", minecraftSources[i].getAbsolutePath()); - candidates.add(new ModCandidate(minecraftSources[i], minecraftSources[i], ContainerType.JAR, i == 0, true)); - } - - @Redirect(method = "findClasspathMods", - at = @At(value = "INVOKE", - target = "Lcpw/mods/fml/common/FMLLog;finer(Ljava/lang/String;[Ljava/lang/Object;)V"), - require = 1) - private void noLog(String format, Object[] data) { - + private List noKnownLibraries(List original) { + return Arrays.asList(); } }