Mixin issues
aser11012 opened this issue ยท 2 comments
I want to use Mixin to change the source code,here is my code:
// Using Example Fabric mod and Only changed the code here.
@Mixin(OpenToLanScreen.class)
public class ExampleMixin {
@Redirect(method = "init",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/server/integrated/IntegratedServer;openToLan(Lnet/minecraft/world/GameMode;ZI)Z"))
private boolean init(IntegratedServer integratedServer, GameMode gameMode, boolean cheatsAllowed, int port) {
return integratedServer.openToLan(gameMode, cheatsAllowed, 12345);
}
}
But there's always something error with running it.
Here is the detailed error:
[19:38:06] [main/INFO] (Minecraft) [STDERR]: org.spongepowered.asm.mixin.injection.throwables.InjectionError: Critical injection failure: Redirector init(Lnet/minecraft/server/integrated/IntegratedServer;Lnet/minecraft/world/GameMode;ZI)Z in og.mixins.json:ExampleMixin failed injection check, (0/1) succeeded. Scanned 1 target(s). No refMap loaded.
[19:38:06] [main/INFO] (Minecraft) [STDERR]: at org.spongepowered.asm.mixin.injection.struct.InjectionInfo.postInject(InjectionInfo.java:400)
[19:38:06] [main/INFO] (Minecraft) [STDERR]: at org.spongepowered.asm.mixin.transformer.MixinTargetContext.applyInjections(MixinTargetContext.java:1280)
[19:38:06] [main/INFO] (Minecraft) [STDERR]: at org.spongepowered.asm.mixin.transformer.MixinApplicatorStandard.applyInjections(MixinApplicatorStandard.java:1042)
[19:38:06] [main/INFO] (Minecraft) [STDERR]: at org.spongepowered.asm.mixin.transformer.MixinApplicatorStandard.applyMixin(MixinApplicatorStandard.java:395)
[19:38:06] [main/INFO] (Minecraft) [STDERR]: at org.spongepowered.asm.mixin.transformer.MixinApplicatorStandard.apply(MixinApplicatorStandard.java:320)
[19:38:06] [main/INFO] (Minecraft) [STDERR]: at org.spongepowered.asm.mixin.transformer.TargetClassContext.applyMixins(TargetClassContext.java:345)
[19:38:06] [main/INFO] (Minecraft) [STDERR]: at org.spongepowered.asm.mixin.transformer.MixinProcessor.applyMixins(MixinProcessor.java:570)
[19:38:06] [main/INFO] (Minecraft) [STDERR]: at org.spongepowered.asm.mixin.transformer.MixinProcessor.applyMixins(MixinProcessor.java:351)
[19:38:06] [main/INFO] (Minecraft) [STDERR]: at org.spongepowered.asm.mixin.transformer.MixinTransformer.transformClass(MixinTransformer.java:191)
[19:38:06] [main/INFO] (Minecraft) [STDERR]: at org.spongepowered.asm.mixin.transformer.MixinTransformer.transformClassBytes(MixinTransformer.java:178)
[19:38:06] [main/INFO] (Minecraft) [STDERR]: at org.spongepowered.asm.mixin.transformer.FabricMixinTransformerProxy.transformClassBytes(FabricMixinTransformerProxy.java:23)
[19:38:06] [main/INFO] (Minecraft) [STDERR]: at net.fabricmc.loader.launch.knot.KnotClassDelegate.loadClassData(KnotClassDelegate.java:174)
[19:38:06] [main/INFO] (Minecraft) [STDERR]: at net.fabricmc.loader.launch.knot.KnotClassLoader.loadClass(KnotClassLoader.java:143)
[19:38:06] [main/INFO] (Minecraft) [STDERR]: at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
[19:38:06] [main/INFO] (Minecraft) [STDERR]: at net.minecraft.client.MinecraftClient.openPauseMenu(MinecraftClient.java:1173)
[19:38:06] [main/INFO] (Minecraft) [STDERR]: at net.minecraft.client.render.GameRenderer.render(GameRenderer.java:413)
[19:38:06] [main/INFO] (Minecraft) [STDERR]: at net.minecraft.client.MinecraftClient.render(MinecraftClient.java:929)
[19:38:06] [main/INFO] (Minecraft) [STDERR]: at net.minecraft.client.MinecraftClient.run(MinecraftClient.java:547)
[19:38:06] [main/INFO] (Minecraft) [STDERR]: at net.minecraft.client.main.Main.main(Main.java:178)
[19:38:06] [main/INFO] (Minecraft) [STDERR]: at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[19:38:06] [main/INFO] (Minecraft) [STDERR]: at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[19:38:06] [main/INFO] (Minecraft) [STDERR]: at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[19:38:06] [main/INFO] (Minecraft) [STDERR]: at java.lang.reflect.Method.invoke(Method.java:498)
[19:38:06] [main/INFO] (Minecraft) [STDERR]: at net.fabricmc.loader.game.MinecraftGameProvider.launch(MinecraftGameProvider.java:192)
[19:38:06] [main/INFO] (Minecraft) [STDERR]: at net.fabricmc.loader.launch.knot.Knot.init(Knot.java:140)
[19:38:06] [main/INFO] (Minecraft) [STDERR]: at net.fabricmc.loader.launch.knot.KnotClient.main(KnotClient.java:26)
[19:38:06] [main/INFO] (Minecraft) [STDERR]: at net.fabricmc.devlaunchinjector.Main.main(Main.java:86)
[19:38:06] [main/FATAL] (Minecraft) Unreported exception thrown!
org.spongepowered.asm.mixin.transformer.throwables.MixinTransformerError: An unexpected critical error was encountered
at org.spongepowered.asm.mixin.transformer.MixinProcessor.applyMixins(MixinProcessor.java:364) ~[sponge-mixin-0.8+build.18.jar:0.8+build.18+unknown-b18.git-unknown]
at org.spongepowered.asm.mixin.transformer.MixinTransformer.transformClass(MixinTransformer.java:191) ~[sponge-mixin-0.8+build.18.jar:0.8+build.18+unknown-b18.git-unknown]
at org.spongepowered.asm.mixin.transformer.MixinTransformer.transformClassBytes(MixinTransformer.java:178) ~[sponge-mixin-0.8+build.18.jar:0.8+build.18+unknown-b18.git-unknown]
at org.spongepowered.asm.mixin.transformer.FabricMixinTransformerProxy.transformClassBytes(FabricMixinTransformerProxy.java:23) ~[[email protected]_15_2.1.15.2+build.15-v2.jar:0.8+build.18+unknown-b18.git-unknown]
at net.fabricmc.loader.launch.knot.KnotClassDelegate.loadClassData(KnotClassDelegate.java:174) ~[[email protected]_15_2.1.15.2+build.15-v2.jar:?]
at net.fabricmc.loader.launch.knot.KnotClassLoader.loadClass(KnotClassLoader.java:143) ~[[email protected]_15_2.1.15.2+build.15-v2.jar:?]
at java.lang.ClassLoader.loadClass(ClassLoader.java:351) ~[?:1.8.0_241]
at net.minecraft.client.MinecraftClient.openPauseMenu(MinecraftClient.java:1173) ~[minecraft-1.15.2-mapped-net.fabricmc.yarn-1.15.2+build.15-v2.jar:?]
at net.minecraft.client.render.GameRenderer.render(GameRenderer.java:413) ~[minecraft-1.15.2-mapped-net.fabricmc.yarn-1.15.2+build.15-v2.jar:?]
at net.minecraft.client.MinecraftClient.render(MinecraftClient.java:929) ~[minecraft-1.15.2-mapped-net.fabricmc.yarn-1.15.2+build.15-v2.jar:?]
at net.minecraft.client.MinecraftClient.run(MinecraftClient.java:547) [minecraft-1.15.2-mapped-net.fabricmc.yarn-1.15.2+build.15-v2.jar:?]
at net.minecraft.client.main.Main.main(Main.java:178) [minecraft-1.15.2-mapped-net.fabricmc.yarn-1.15.2+build.15-v2.jar:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_241]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_241]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_241]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_241]
at net.fabricmc.loader.game.MinecraftGameProvider.launch(MinecraftGameProvider.java:192) [[email protected]_15_2.1.15.2+build.15-v2.jar:?]
at net.fabricmc.loader.launch.knot.Knot.init(Knot.java:140) [[email protected]_15_2.1.15.2+build.15-v2.jar:?]
at net.fabricmc.loader.launch.knot.KnotClient.main(KnotClient.java:26) [[email protected]_15_2.1.15.2+build.15-v2.jar:?]
at net.fabricmc.devlaunchinjector.Main.main(Main.java:86) [dev-launch-injector-0.2.0+build.6.jar:?]
Caused by: org.spongepowered.asm.mixin.injection.throwables.InjectionError: Critical injection failure: Redirector init(Lnet/minecraft/server/integrated/IntegratedServer;Lnet/minecraft/world/GameMode;ZI)Z in og.mixins.json:ExampleMixin failed injection check, (0/1) succeeded. Scanned 1 target(s). No refMap loaded.
at org.spongepowered.asm.mixin.injection.struct.InjectionInfo.postInject(InjectionInfo.java:400) ~[sponge-mixin-0.8+build.18.jar:0.8+build.18+unknown-b18.git-unknown]
at org.spongepowered.asm.mixin.transformer.MixinTargetContext.applyInjections(MixinTargetContext.java:1280) ~[sponge-mixin-0.8+build.18.jar:0.8+build.18+unknown-b18.git-unknown]
at org.spongepowered.asm.mixin.transformer.MixinApplicatorStandard.applyInjections(MixinApplicatorStandard.java:1042) ~[sponge-mixin-0.8+build.18.jar:0.8+build.18+unknown-b18.git-unknown]
at org.spongepowered.asm.mixin.transformer.MixinApplicatorStandard.applyMixin(MixinApplicatorStandard.java:395) ~[sponge-mixin-0.8+build.18.jar:0.8+build.18+unknown-b18.git-unknown]
at org.spongepowered.asm.mixin.transformer.MixinApplicatorStandard.apply(MixinApplicatorStandard.java:320) ~[sponge-mixin-0.8+build.18.jar:0.8+build.18+unknown-b18.git-unknown]
at org.spongepowered.asm.mixin.transformer.TargetClassContext.applyMixins(TargetClassContext.java:345) ~[sponge-mixin-0.8+build.18.jar:0.8+build.18+unknown-b18.git-unknown]
at org.spongepowered.asm.mixin.transformer.MixinProcessor.applyMixins(MixinProcessor.java:570) ~[sponge-mixin-0.8+build.18.jar:0.8+build.18+unknown-b18.git-unknown]
at org.spongepowered.asm.mixin.transformer.MixinProcessor.applyMixins(MixinProcessor.java:351) ~[sponge-mixin-0.8+build.18.jar:0.8+build.18+unknown-b18.git-unknown]
... 19 more
[19:38:06] [Server thread/INFO] (Minecraft) Stopping server<==[19:38:06] [Server thread/INFO] (Minecraft) Saving players
And oddly enough, using injection here doesn't make error.
Can you look at it for me?
Sorry for my bad English.
The method you are redirecting does not exist in init
method of that screen. If you are looking for the call in constructor, do <init>*
.
Also this is fabric api issues, not a support service. Closing.