MinimallyCorrect / ModPatcher

Allows easy patching of mods/plugins/arbitrary minecraft classes using config files
MIT License
8 stars 6 forks source link

cannot find pa: net.minecraft.network.NetHandlerPlayServer found in pa.class #19

Closed Sir-Will closed 4 years ago

Sir-Will commented 6 years ago

Trying to use getServerHandler() in patches throws the error below. I got this issue in 1.10 and 1.12 and with multiple mods.

(Using the embedded version in TickProfiler)

[17:50:44] [Server thread/ERROR]: [JavaPatcher]: Error patching handleMessage in vazkii.quark.base.network.message.MessageRestock with insertCodeBefore
java.lang.RuntimeException: cannot find pa: net.minecraft.network.NetHandlerPlayServer found in pa.class
    at javassist.CtClassType.getClassFile3(CtClassType.java:208) ~[CtClassType.class:?]
    at javassist.CtClassType.makeFieldCache(CtClassType.java:900) ~[CtClassType.class:?]
    at javassist.CtClassType.getMembers(CtClassType.java:891) ~[CtClassType.class:?]
    at javassist.CtClassType.getDeclaredField2(CtClassType.java:1025) ~[CtClassType.class:?]
    at javassist.CtClassType.getField2(CtClassType.java:979) ~[CtClassType.class:?]
    at javassist.CtClassType.getField(CtClassType.java:960) ~[CtClassType.class:?]
    at javassist.CtClass.getField(CtClass.java:835) ~[CtClass.class:?]
    at javassist.compiler.MemberResolver.lookupField(MemberResolver.java:310) ~[javassist-3.22.0-CR1.jar:?]
    at javassist.compiler.MemberResolver.lookupFieldByJvmName(MemberResolver.java:299) ~[javassist-3.22.0-CR1.jar:?]
    at javassist.compiler.TypeChecker.fieldAccess(TypeChecker.java:876) ~[javassist-3.22.0-CR1.jar:?]
    at javassist.compiler.TypeChecker.atFieldRead(TypeChecker.java:803) ~[javassist-3.22.0-CR1.jar:?]
    at javassist.compiler.TypeChecker.atExpr(TypeChecker.java:578) ~[javassist-3.22.0-CR1.jar:?]
    at javassist.compiler.ast.Expr.accept(Expr.java:68) ~[javassist-3.22.0-CR1.jar:?]
    at javassist.compiler.TypeChecker.atCastExpr(TypeChecker.java:547) ~[javassist-3.22.0-CR1.jar:?]
    at javassist.compiler.JvstTypeChecker.atCastExpr(JvstTypeChecker.java:104) ~[javassist-3.22.0-CR1.jar:?]
    at javassist.compiler.ast.CastExpr.accept(CastExpr.java:55) ~[javassist-3.22.0-CR1.jar:?]
    at javassist.compiler.CodeGen.doTypeCheck(CodeGen.java:242) ~[javassist-3.22.0-CR1.jar:?]
    at javassist.compiler.CodeGen.atDeclarator(CodeGen.java:743) ~[javassist-3.22.0-CR1.jar:?]
    at javassist.compiler.ast.Declarator.accept(Declarator.java:100) ~[javassist-3.22.0-CR1.jar:?]
    at javassist.compiler.CodeGen.atStmnt(CodeGen.java:351) ~[javassist-3.22.0-CR1.jar:?]
    at javassist.compiler.ast.Stmnt.accept(Stmnt.java:50) ~[javassist-3.22.0-CR1.jar:?]
    at javassist.compiler.CodeGen.atStmnt(CodeGen.java:351) ~[javassist-3.22.0-CR1.jar:?]
    at javassist.compiler.ast.Stmnt.accept(Stmnt.java:50) ~[javassist-3.22.0-CR1.jar:?]
    at javassist.compiler.Javac.compileStmnt(Javac.java:567) ~[javassist-3.22.0-CR1.jar:?]
    at javassist.CtBehavior.insertBefore(CtBehavior.java:754) ~[CtBehavior.class:?]
    at javassist.CtBehavior.insertBefore(CtBehavior.java:734) ~[CtBehavior.class:?]
    at me.nallar.javapatcher.patcher.Patches.insertCodeBefore(Patches.java:932) ~[Patches.class:1.8+Jenkins-b61.git-8893876c05313e7818055c79e31cf8e828c877a2]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_144]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_144]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_144]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_144]
    at me.nallar.javapatcher.patcher.Patcher$PatchMethodDescriptor.run(Patcher.java:418) [Patcher$PatchMethodDescriptor.class:1.8+Jenkins-b61.git-8893876c05313e7818055c79e31cf8e828c877a2]
    at me.nallar.javapatcher.patcher.Patcher$PatchMethodDescriptor.run(Patcher.java:388) [Patcher$PatchMethodDescriptor.class:1.8+Jenkins-b61.git-8893876c05313e7818055c79e31cf8e828c877a2]
    at me.nallar.javapatcher.patcher.Patcher$ClassPatchDescriptor.runPatches(Patcher.java:514) [Patcher$ClassPatchDescriptor.class:1.8+Jenkins-b61.git-8893876c05313e7818055c79e31cf8e828c877a2]
    at me.nallar.javapatcher.patcher.Patcher.patch(Patcher.java:211) [Patcher.class:1.8+Jenkins-b61.git-8893876c05313e7818055c79e31cf8e828c877a2]
    at org.minimallycorrect.modpatcher.api.ModPatcherTransformer$ClassTransformer.transform(ModPatcherTransformer.java:154) [ModPatcher-1.12-SNAPSHOT.jar:1.12-SNAPSHOT+Jenkins-b5.git-24e3b38023c281ee5d327595ecaea7f37f198dfc]
    at net.minecraft.launchwrapper.LaunchClassLoader.runTransformers(LaunchClassLoader.java:279) [launchwrapper-1.12.jar:?]
    at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:176) [launchwrapper-1.12.jar:?]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424) [?:1.8.0_144]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357) [?:1.8.0_144]
    at vazkii.quark.base.network.MessageRegister.init(MessageRegister.java:38) [MessageRegister.class:?]
    at vazkii.quark.base.proxy.CommonProxy.preInit(CommonProxy.java:31) [CommonProxy.class:?]
    at vazkii.quark.base.Quark.preInit(Quark.java:35) [Quark.class:?]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_144]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_144]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_144]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_144]
    at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:600) [FMLModContainer.class:?]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_144]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_144]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_144]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_144]
    at com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:91) [minecraft_server.1.12.2.jar:?]
    at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150) [minecraft_server.1.12.2.jar:?]
    at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76) [minecraft_server.1.12.2.jar:?]
    at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399) [minecraft_server.1.12.2.jar:?]
    at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71) [minecraft_server.1.12.2.jar:?]
    at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116) [minecraft_server.1.12.2.jar:?]
    at com.google.common.eventbus.EventBus.post(EventBus.java:217) [minecraft_server.1.12.2.jar:?]
    at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:278) [LoadController.class:?]
    at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:256) [LoadController.class:?]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_144]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_144]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_144]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_144]
    at com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:91) [minecraft_server.1.12.2.jar:?]
    at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150) [minecraft_server.1.12.2.jar:?]
    at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76) [minecraft_server.1.12.2.jar:?]
    at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399) [minecraft_server.1.12.2.jar:?]
    at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71) [minecraft_server.1.12.2.jar:?]
    at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116) [minecraft_server.1.12.2.jar:?]
    at com.google.common.eventbus.EventBus.post(EventBus.java:217) [minecraft_server.1.12.2.jar:?]
    at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:148) [LoadController.class:?]
    at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:602) [Loader.class:?]
    at net.minecraftforge.fml.server.FMLServerHandler.beginServerLoading(FMLServerHandler.java:98) [FMLServerHandler.class:?]
    at net.minecraftforge.fml.common.FMLCommonHandler.onServerStart(FMLCommonHandler.java:332) [FMLCommonHandler.class:?]
    at net.minecraft.server.dedicated.DedicatedServer.func_71197_b(DedicatedServer.java:125) [nz.class:?]
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:484) [MinecraftServer.class:?]
    at java.lang.Thread.run(Thread.java:748) [?:1.8.0_144]
Sir-Will commented 5 years ago

@nallar any chance you can take a look at this?

LunNova commented 5 years ago

What's the patch XML?

Sir-Will commented 5 years ago

https://github.com/TehNut/HWYLA/blob/1.12/src/main/java/mcp/mobius/waila/network/MessageRequestTile.java#L62

<mods>
    <Hwyla>
        <class id="mcp.mobius.waila.network.MessageRequestTile$Handler">
            <insertCodeBefore code="{
                System.out.println($2.getServerHandler());
            }">onMessage</insertCodeBefore>
        </class>
    </Hwyla>
</mods>
LunNova commented 4 years ago

Sorry about the huge delay here. Deprecating the old XML patch format now, too much trouble with it

We will retain support for custom patches in a folder in the next release, but they'll be custom mixin classes instead. #21

Sir-Will commented 4 years ago

When is that next release planned? Are there examples of patches in mixin class format?

LunNova commented 4 years ago

When it's done. Don't have a good estimate :c

Yes, at the moment there are examples in a few places. The most complicated ones are probably in the current (broken, WIP) version of TickThreading. There are also a few simple ones as test files in the Mixin repo.