SpongePowered / Mixin

Mixin is a trait/mixin and bytecode weaving framework for Java using ASM
MIT License
1.43k stars 193 forks source link

"could not find any targets matching" #401

Closed akaJuliaan closed 4 years ago

akaJuliaan commented 4 years ago

Error in MinecraftLog:

Mixin apply failed mixins.jtools.json:MixinMinecraft -> net.minecraft.client.Minecraft: org.spongepowered.asm.mixin.injection.throwables.InvalidInjectionException @Inject annotation on handler$getSession$zze000 could not find any targets matching 'getSession' in the target class net.minecraft.client.Minecraft. Using refmap mixins.jtools.refmap.json org.spongepowered.asm.mixin.injection.throwables.InvalidInjectionException: @Inject annotation on handler$getSession$zze000 could not find any targets matching 'getSession' in the target class net.minecraft.client.Minecraft. Using refmap mixins.jtools.refmap.json at org.spongepowered.asm.mixin.injection.struct.InjectionInfo.findMethods(InjectionInfo.java:421) at org.spongepowered.asm.mixin.injection.struct.InjectionInfo.readAnnotation(InjectionInfo.java:172) at org.spongepowered.asm.mixin.injection.struct.InjectionInfo.<init>(InjectionInfo.java:159) at org.spongepowered.asm.mixin.injection.struct.InjectionInfo.<init>(InjectionInfo.java:151) at org.spongepowered.asm.mixin.injection.struct.CallbackInjectionInfo.<init>(CallbackInjectionInfo.java:44) at org.spongepowered.asm.mixin.injection.struct.InjectionInfo.parse(InjectionInfo.java:472) at org.spongepowered.asm.mixin.transformer.MixinTargetContext.prepareInjections(MixinTargetContext.java:1180) at org.spongepowered.asm.mixin.transformer.MixinApplicatorStandard.prepareInjections(MixinApplicatorStandard.java:900) at org.spongepowered.asm.mixin.transformer.MixinApplicatorStandard.applyMixin(MixinApplicatorStandard.java:304) at org.spongepowered.asm.mixin.transformer.MixinApplicatorStandard.apply(MixinApplicatorStandard.java:267) at org.spongepowered.asm.mixin.transformer.TargetClassContext.applyMixins(TargetClassContext.java:353) at org.spongepowered.asm.mixin.transformer.MixinTransformer.apply(MixinTransformer.java:724) at org.spongepowered.asm.mixin.transformer.MixinTransformer.applyMixins(MixinTransformer.java:703) at org.spongepowered.asm.mixin.transformer.MixinTransformer.transformClassBytes(MixinTransformer.java:509) at org.spongepowered.asm.mixin.transformer.Proxy.transform(Proxy.java:72) at net.minecraft.launchwrapper.LaunchClassLoader.runTransformers(LaunchClassLoader.java:279) at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:176) at java.lang.ClassLoader.loadClass(ClassLoader.java:418) at java.lang.ClassLoader.loadClass(ClassLoader.java:351) at net.minecraft.client.main.Main.main(SourceFile:41) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) at net.minecraft.launchwrapper.Launch.main(Launch.java:28)

SRC:

` @Inject(method = {"getSession()Lnet/minecraft/client/util/Session;"}, at = {@At("HEAD")}, cancellable = true, remap = false) private void getSession(CallbackInfoReturnable cir) {

        if(JTools.clientSession == null) {
            JTools.clientSession = session;
            return;
        }

        session = JTools.clientSession;
        JTools.CLIENT_INSTANCE.bot.changeNick(session.getUsername());
        cir.setReturnValue(JTools.clientSession);

    }`

In Eclipse all work fine

Chocohead commented 4 years ago

If you turn the refmap remapping off for an injection into a method that will be obfuscated (which Minecraft#getSession is such a method) it will do this. There is no need for remap = false.

akaJuliaan commented 4 years ago

When I turn it off, ih got this Error on compiling: `> Task :compileJava Potential refmap conflict. Duplicate refmap name mixins.jtools.refmap.json specified for sourceSet main, already defined for sourceSet main Note: SpongePowered MIXIN Annotation Processor Version=0.7.10 Note: ObfuscationServiceMCP supports type: "searge" Note: ObfuscationServiceMCP supports type: "notch" Note: Loading searge mappings from C:\Users\Julian.gradle\caches\minecraft\de\oceanlabs\mcp\mcp_stable\22\srgs\mcp-srg.srg Note: Loading notch mappings from C:\Users\Julian.gradle\caches\minecraft\de\oceanlabs\mcp\mcp_stable\22\srgs\mcp-notch.srg C:\Users\Julian\Documents\JTools-SRC\build\sources\main\java\me\julian\jtools\injection\mixins\MixinMinecraft.java:87: warning: Cannot find target method for @Inject in net.minecraft.client.Minecraft @Inject(method = {"getSession()Lnet/minecraft/client/util/Session;"}, at = {@At("HEAD")}, cancellable = true) ^ C:\Users\Julian\Documents\JTools-SRC\build\sources\main\java\me\julian\jtools\injection\mixins\MixinMinecraft.java:87: error: No obfuscation mapping for @Inject target getSession @Inject(method = {"getSession()Lnet/minecraft/client/util/Session;"}, at = {@At("HEAD")}, cancellable = true) ^ Note: Writing refmap to C:\Users\Julian\Documents\JTools-SRC\build\tmp\compileJava\compileJava-refmap.json C:\Users\Julian\Documents\JTools-SRC\build\sources\main\java\me\julian\jtools\injection\mixins\MixinGuiButton.java:63: warning: @Overwrite is missing javadoc comment public void drawButton(Minecraft mc, int mouseX, int mouseY) { ^ C:\Users\Julian\Documents\JTools-SRC\build\sources\main\java\me\julian\jtools\injection\mixins\MixinGuiConnecting.java:73: warning: @Overwrite is missing an @reason tag private void connect(final String ip, final int port) { ^ C:\Users\Julian\Documents\JTools-SRC\build\sources\main\java\me\julian\jtools\injection\mixins\MixinGuiConnecting.java:117: warning: @Overwrite is missing an @reason tag public void drawScreen(int mouseX, int mouseY, float partialTicks) { ^ C:\Users\Julian\Documents\JTools-SRC\build\sources\main\java\me\julian\jtools\injection\mixins\MixinGuiSlot.java:86: warning: @Overwrite is missing javadoc comment public void drawScreen(int mouseXIn, int mouseYIn, float p_1481283) { ^ C:\Users\Julian\Documents\JTools-SRC\build\sources\main\java\me\julian\jtools\injection\mixins\MixinGuiSlot.java:168: warning: @Overwrite is missing javadoc comment protected int getScrollBarX() { ^ Note: Writing refmap to C:\Users\Julian\Documents\JTools-SRC\build\tmp\compileJava\compileJava-refmap.json Note: Writing searge output SRGs to C:\Users\Julian\Documents\JTools-SRC\build\tmp\compileJava\mcp-srg.srg Note: Writing notch output SRGs to C:\Users\Julian\Documents\JTools-SRC\build\tmp\compileJava\mcp-notch.srg Note: Writing refmap to C:\Users\Julian\Documents\JTools-SRC\build\tmp\compileJava\compileJava-refmap.json Note: Writing refmap to C:\Users\Julian\Documents\JTools-SRC\build\tmp\compileJava\compileJava-refmap.json Note: Writing searge output SRGs to C:\Users\Julian\Documents\JTools-SRC\build\tmp\compileJava\mcp-srg.srg Note: Writing notch output SRGs to C:\Users\Julian\Documents\JTools-SRC\build\tmp\compileJava\mcp-notch.srg 1 error 6 warnings

FAILURE: Build failed with an exception.

BUILD FAILED in 27s 7 actionable tasks: 5 executed, 2 up-to-date`

akaJuliaan commented 4 years ago

I fixed it myself