createPacket not working on 1.20.4 (and again on 1.20.5/6) !
Jeppa opened this issue ยท 28 comments
- This issue is not solved in a development build
com.comphenix.protocol.ProtocolLibrary.getProtocolManager().createPacket(com.comphenix.protocol.PacketType.Play.Server.SPAWN_ENTITY)
throws the following error:
[Server thread/WARN]: java.lang.NullPointerException: Unable to create packet instance for class class net.minecraft.network.protocol.game.PacketPlayOutSpawnEntity
[Server thread/WARN]: at java.base/java.util.Objects.requireNonNull(Unknown Source)
[Server thread/WARN]: at com.comphenix.protocol.injector.StructureCache.lambda$newPacket$2(StructureCache.java:99)
[Server thread/WARN]: at com.comphenix.protocol.injector.StructureCache.newPacket(StructureCache.java:103)
[Server thread/WARN]: at com.comphenix.protocol.injector.StructureCache.newPacket(StructureCache.java:113)
[Server thread/WARN]: at com.comphenix.protocol.events.PacketContainer.(PacketContainer.java:117)
[Server thread/WARN]: at com.comphenix.protocol.injector.PacketFilterManager.createPacket(PacketFilterManager.java:389)
[Server thread/WARN]: at com.comphenix.protocol.injector.PacketFilterManager.createPacket(PacketFilterManager.java:384)
Version Info
Minecraft: Spigot 1.20.4 (8.12.2023)
ProtocolLib build #673
New problem mention in #2856
Having the same issue here, can load protocollib with obfuscated version of 1.20.6 as per issue #2900 but still getting the issue with:
java.lang.NullPointerException: Unable to create packet instance for class class net.minecraft.network.protocol.game.PacketPlayOutSpawnEntity
at java.base/java.util.Objects.requireNonNull(Objects.java:246) ~[?:?]
at ProtocolLib.jar/com.comphenix.protocol.injector.StructureCache.lambda$newPacket$2(StructureCache.java:99) ~[ProtocolLib.jar:?]
at ProtocolLib.jar/com.comphenix.protocol.injector.StructureCache.newPacket(StructureCache.java:103) ~[ProtocolLib.jar:?]
at ProtocolLib.jar/com.comphenix.protocol.injector.StructureCache.newPacket(StructureCache.java:113) ~[ProtocolLib.jar:?]
at ProtocolLib.jar/com.comphenix.protocol.events.PacketContainer.(PacketContainer.java:117) ~[ProtocolLib.jar:?]
at ProtocolLib.jar/com.comphenix.protocol.injector.PacketFilterManager.createPacket(PacketFilterManager.java:389) ~[ProtocolLib.jar:?]
at ProtocolLib.jar/com.comphenix.protocol.injector.PacketFilterManager.createPacket(PacketFilterManager.java:384) ~[ProtocolLib.jar:?]
Hi again,
new build 689 now works under Paper again, but still throws errors on packet creation:
e.g. I have two lines of code like this:
com.comphenix.protocol.events.PacketContainer addPlayerPacket = com.comphenix.protocol.ProtocolLibrary.getProtocolManager().createPacket(com.comphenix.protocol.PacketType.Play.Server.PLAYER_INFO);
addPlayerPacket.getPlayerInfoActions().write(0, EnumSet.of(com.comphenix.protocol.wrappers.EnumWrappers.PlayerInfoAction.ADD_PLAYER));
And Spigot still has this error:
java.lang.NullPointerException: Unable to create packet instance for class class net.minecraft.network.protocol.game.ClientboundPlayerInfoUpdatePacket - true - com.comphenix.protocol.wrappers.WrappedStreamCodec[handle=net.minecraft.network.codec.StreamCodec$9@286922fc]
at java.base/java.util.Objects.requireNonNull(Unknown Source)
at com.comphenix.protocol.injector.StructureCache.lambda$newPacket$4(StructureCache.java:130)
at com.comphenix.protocol.injector.StructureCache.newPacket(StructureCache.java:134)
at com.comphenix.protocol.injector.StructureCache.newPacket(StructureCache.java:144)
at com.comphenix.protocol.events.PacketContainer.<init>(PacketContainer.java:119)
at com.comphenix.protocol.injector.PacketFilterManager.createPacket(PacketFilterManager.java:389)
at com.comphenix.protocol.injector.PacketFilterManager.createPacket(PacketFilterManager.java:384)
With Paper the crash is at 2nd line like this ('EnumChatVisibility' has to be 'ChatVisibility' in unobfuscated Paper ):
java.lang.RuntimeException: Failed to find NMS class: world.entity.player.EnumChatVisibility
at ProtocolLib(B689).jar/com.comphenix.protocol.utility.MinecraftReflection.lambda$getMinecraftClass$2(MinecraftReflection.java:1386) ~[ProtocolLib(B689).jar:?]
at java.base/java.util.Optional.orElseThrow(Unknown Source) ~[?:?]
at ProtocolLib(B689).jar/com.comphenix.protocol.utility.MinecraftReflection.getMinecraftClass(MinecraftReflection.java:1386) ~[ProtocolLib(B689).jar:?]
at ProtocolLib(B689).jar/com.comphenix.protocol.wrappers.EnumWrappers.initialize(EnumWrappers.java:503) ~[ProtocolLib(B689).jar:?]
at ProtocolLib(B689).jar/com.comphenix.protocol.wrappers.EnumWrappers.getPlayerInfoActionClass(EnumWrappers.java:670) ~[ProtocolLib(B689).jar:?]
at ProtocolLib(B689).jar/com.comphenix.protocol.wrappers.EnumWrappers.getPlayerInfoActionConverter(EnumWrappers.java:769) ~[ProtocolLib(B689).jar:?]
at ProtocolLib(B689).jar/com.comphenix.protocol.events.AbstractStructure.getPlayerInfoActions(AbstractStructure.java:673) ~[ProtocolLib(B689).jar:?]
Strangely Paper does not crash at first line...
This seems to be broken again (build #686 and MC 1.20.5):
java.lang.NullPointerException: Unable to create packet instance for class class net.minecraft.network.protocol.game.ClientboundPlayerInfoUpdatePacket
rest is the same as before...
This seems to be broken again (build #686 and MC 1.20.5): java.lang.NullPointerException: Unable to create packet instance for class class net.minecraft.network.protocol.game.ClientboundPlayerInfoUpdatePacket
rest is the same as before...
How can you even use 1.20.5? it doesn't work at all
This seems to be broken again (build #686 and MC 1.20.5): java.lang.NullPointerException: Unable to create packet instance for class class net.minecraft.network.protocol.game.ClientboundPlayerInfoUpdatePacket
rest is the same as before...How can you even use 1.20.5? it doesn't work at all
Spigot 'works' ... paper does not.
Are there any temporary work arounds for now?
@seraph-prisons
Fork, change code, compile, just remember to disable tests, otherwise it'll not compile
@seraph-prisons Fork, change code, compile, just remember to disable tests, otherwise it'll not compile
So, you know what to change to fix this bug?
(I'm NOT talking about the EnumChatVisibility bug that is also mentioned here...)
I can reproduce this issue with Spigot 1.20.6:
java.lang.NullPointerException: Unable to create packet instance for class class net.minecraft.network.protocol.game.PacketPlayOutSpawnEntity - true - com.comphenix.protocol.wrappers.WrappedStreamCodec[handle=net.minecraft.network.codec.StreamCodec$9@eb185d3]
at java.base/java.util.Objects.requireNonNull(Objects.java:259) ~[?:?]
at com.comphenix.protocol.injector.StructureCache.lambda$newPacket$4(StructureCache.java:130) ~[?:?]
at com.comphenix.protocol.injector.StructureCache.newPacket(StructureCache.java:134) ~[?:?]
at com.comphenix.protocol.injector.StructureCache.newPacket(StructureCache.java:144) ~[?:?]
at com.comphenix.protocol.events.PacketContainer.<init>(PacketContainer.java:119) ~[?:?]
at com.comphenix.protocol.injector.PacketFilterManager.createPacket(PacketFilterManager.java:389) ~[?:?]
at com.comphenix.protocol.injector.PacketFilterManager.createPacket(PacketFilterManager.java:384) ~[?:?]
at com.ghostchu.quickshop.shop.display.virtual.packetfactory.v1_20_R4.createFakeItemSpawnPacket(v1_20_R4.java:56) ~[?:?]
PacketContainer fakeItemPacket = manager.getProtocolManager().createPacket(PacketType.Play.Server.SPAWN_ENTITY);
I can reproduce this issue with Spigot 1.20.6:
java.lang.NullPointerException: Unable to create packet instance for class class net.minecraft.network.protocol.game.PacketPlayOutSpawnEntity - true - com.comphenix.protocol.wrappers.WrappedStreamCodec[handle=net.minecraft.network.codec.StreamCodec$9@eb185d3] at java.base/java.util.Objects.requireNonNull(Objects.java:259) ~[?:?] at com.comphenix.protocol.injector.StructureCache.lambda$newPacket$4(StructureCache.java:130) ~[?:?] at com.comphenix.protocol.injector.StructureCache.newPacket(StructureCache.java:134) ~[?:?] at com.comphenix.protocol.injector.StructureCache.newPacket(StructureCache.java:144) ~[?:?] at com.comphenix.protocol.events.PacketContainer.<init>(PacketContainer.java:119) ~[?:?] at com.comphenix.protocol.injector.PacketFilterManager.createPacket(PacketFilterManager.java:389) ~[?:?] at com.comphenix.protocol.injector.PacketFilterManager.createPacket(PacketFilterManager.java:384) ~[?:?] at com.ghostchu.quickshop.shop.display.virtual.packetfactory.v1_20_R4.createFakeItemSpawnPacket(v1_20_R4.java:56) ~[?:?]
PacketContainer fakeItemPacket = manager.getProtocolManager().createPacket(PacketType.Play.Server.SPAWN_ENTITY);
Yeah, same here, tested with both obf and deobf version of paper from gradle build.
More info here: #2917
@dmulloy2 Build 699: still not fixed!
Spigot throws exact same exception when trying getProtocolManager().createPacket(PacketType.Play.Server.PLAYER_INFO);
Paper does not (with PLAYER_INFO), but throws same exception with getProtocolManager().createPacket(PacketType.Play.Server.SPAWN_ENTITY);
I can also reproduce this issue on Spigot-1.20.4 (3966-Spigot-ce0f71e-cb2ea54
) on latest dev build.
Give the latest build a try: https://ci.dmulloy2.net/job/ProtocolLib/lastBuild/
Shows as failing since not all the tests are passing yet. But it should fix the packet creation issue
Hi again,
It was OK with build #675.
Now, with build #676 there is the same error again, and now as well for other packets like:
com.comphenix.protocol.PacketType.Play.Server.PLAYER_INFO -> ClientboundPlayerInfoUpdatePacket
and
com.comphenix.protocol.PacketType.Play.Server.ENTITY_HEAD_ROTATION -> PacketPlayOutEntityHeadRotation
(maybe more...)
This seems to be a little random and not every error happes with every serverstart.
Sometimes it crashes with the 'ClientboundPlayerInfoUpdatePacket' (PLAYER_INFO), sometimes two packets later with 'PacketPlayOutSpawnEntity' (SPAWN_ENTITY)...
In my case...
- Paper version 1.20.6-137-master@bd5867a (2024-06-04T21:04:28Z)
- ProtocolLib v5.3.0-SNAPSHOT-699
Caused by: java.lang.NullPointerException: Unable to create packet instance for class class net.minecraft.network.protocol.game.ClientboundPlayerInfoUpdatePacket - true - com.comphenix.protocol.wrappers.WrappedStreamCodec[handle=net.minecraft.network.codec.StreamCodec$5@365fc150]
at java.base/java.util.Objects.requireNonNull(Unknown Source) ~[?:?]
at ProtocolLib.jar/com.comphenix.protocol.injector.StructureCache.lambda$newPacket$4(StructureCache.java:130) ~[ProtocolLib.jar:?]
at ProtocolLib.jar/com.comphenix.protocol.injector.StructureCache.newPacket(StructureCache.java:134) ~[ProtocolLib.jar:?]
at ProtocolLib.jar/com.comphenix.protocol.injector.StructureCache.newPacket(StructureCache.java:144) ~[ProtocolLib.jar:?]
at ProtocolLib.jar/com.comphenix.protocol.events.PacketContainer.<init>(PacketContainer.java:119) ~[ProtocolLib.jar:?]
at NickAfkPartyPack-1.0.5-PREVIEW1.jar/ml.noahc3.nickafkpartypack.Packets.WrapperPlayServerPlayerInfo.<init>(WrapperPlayServerPlayerInfo.java:15) ~[NickAfkPartyPack-1.0.5-PREVIEW1.jar:?]
in my code.
11: public class WrapperPlayServerPlayerInfo extends AbstractPacket {
12: public static final PacketType TYPE = PacketType.Play.Server.PLAYER_INFO;
13:
14: public WrapperPlayServerPlayerInfo() {
15: super(new PacketContainer(TYPE), TYPE); // <--- NPE on Paper 1.20.6
16: handle.getModifier().writeDefaults();
17: }
In my case...
- Paper version 1.20.6-137-master@bd5867a (2024-06-04T21:04:28Z)
- ProtocolLib v5.3.0-SNAPSHOT-699
Fixed in
- ProtocolLib v5.3.0-SNAPSHOT-702
Thank you!
You should be able to create all but MAP_CHUNK, SCOREBOARD_OBJECTIVE, and ENTITY_SOUND. Those 3 require some special handling that still needs to be worked out