juliarn / npc-lib

Asynchronous, high-performance Minecraft NPC library for 1.8-1.21 servers.
MIT License
296 stars 50 forks source link

Packet instance error #101

Closed plytki closed 1 year ago

plytki commented 1 year ago

I'm using NPC-Lib v3 in my project on 1.19.3 and I get these errors.

[17:22:28 ERROR]: [CryptoMine] Subscriber dev.plytki.cryptomine.world.npc.NPCPool$$Lambda$7250/0x00000008020ddad8 was unable to handle DefaultPost:
java.lang.NullPointerException: Unable to create packet instance for class class net.minecraft.network.protocol.game.PacketPlayOutEntityHeadRotation
        at java.util.Objects.requireNonNull(Objects.java:233) ~[?:?]
        at com.comphenix.protocol.injector.StructureCache.lambda$newPacket$2(StructureCache.java:97) ~[ProtocolLib.jar:?]
        at com.comphenix.protocol.injector.StructureCache.newPacket(StructureCache.java:101) ~[ProtocolLib.jar:?]
        at com.comphenix.protocol.injector.StructureCache.newPacket(StructureCache.java:111) ~[ProtocolLib.jar:?]
        at com.comphenix.protocol.events.PacketContainer.<init>(PacketContainer.java:117) ~[ProtocolLib.jar:?]
        at com.github.juliarn.npclib.bukkit.protocol.ProtocolLibPacketAdapter.lambda$createRotationPacket$8(ProtocolLibPacketAdapter.java:363) ~[cryptomine-2.0-SNAPSHOT.jar:?]
        at dev.plytki.cryptomine.world.npc.NPCPool.handleNpcShow(NPCPool.java:102) ~[cryptomine-2.0-SNAPSHOT.jar:?]
        at net.kyori.event.EventBusImpl.post(EventBusImpl.java:63) ~[cryptomine-2.0-SNAPSHOT.jar:?]
        at com.github.juliarn.npclib.common.util.EventDispatcher.dispatch(EventDispatcher.java:45) ~[cryptomine-2.0-SNAPSHOT.jar:?]
        at com.github.juliarn.npclib.common.npc.CommonNpc.lambda$forceTrackPlayer$0(CommonNpc.java:200) ~[cryptomine-2.0-SNAPSHOT.jar:?]
        at org.bukkit.craftbukkit.v1_19_R2.scheduler.CraftTask.run(CraftTask.java:101) ~[slimeworldmanager-1.19.3.jar:git-SlimeWorldManager-61]
        at org.bukkit.craftbukkit.v1_19_R2.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:57) ~[slimeworldmanager-1.19.3.jar:git-SlimeWorldManager-61]
        at com.destroystokyo.paper.ServerSchedulerReportingWrapper.run(ServerSchedulerReportingWrapper.java:22) ~[slimeworldmanager-1.19.3.jar:?]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[?:?]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[?:?]
        at java.lang.Thread.run(Thread.java:833) ~[?:?]
vytskalt commented 1 year ago

I also get these errors. Seems like it only happens when I join when the server hasn't fully started yet.

derklaro commented 1 year ago

I can reproduce the issue (with the non-fully started server, thanks for pointing that out), but it seems that the issue is triggered by ProtcolLib which is most likely triggered by some underlying stuff in the server code that is not predictable... I will take a look and see what I can do to fix this

plytki commented 1 year ago

Ok, so I found out that NPC sometimes do not spawn. It is random. Sometime when I start the server Npc are spawning, but sometimes they are not and that's why I'm getting this packet instance error. I'm always making sure to wait 5 sec after the server has fully started and I'm joining the world.

derklaro commented 1 year ago

I've implemented a fix for your issue in protocollib, please try out if the issue still happens with the latest build. If that's the case feel free to comment here again :)

Closing for now