Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

createPacket not working on 1.20.4 (and again on 1.20.5/6) ! #2669

Closed
1 task done
Jeppa opened this issue Dec 8, 2023 · 28 comments
Closed
1 task done

createPacket not working on 1.20.4 (and again on 1.20.5/6) ! #2669

Jeppa opened this issue Dec 8, 2023 · 28 comments

Comments

@Jeppa
Copy link

Jeppa commented Dec 8, 2023

  • 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

@Jeppa Jeppa changed the title createPacket now working on 1.20.3 ? createPacket now working on 1.20.4 ? Dec 8, 2023
@Jeppa Jeppa changed the title createPacket now working on 1.20.4 ? createPacket not working on 1.20.4 ? Dec 8, 2023
@Ghost-chu
Copy link

I can also reproduce this issue on Spigot-1.20.4 (3966-Spigot-ce0f71e-cb2ea54) on latest dev build.

@dmulloy2
Copy link
Owner

dmulloy2 commented Dec 9, 2023

Was able to reproduce this. Looking into it further

@dmulloy2
Copy link
Owner

dmulloy2 commented Dec 9, 2023

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

@dmulloy2 dmulloy2 pinned this issue Dec 9, 2023
@Ghost-chu
Copy link

Looks works for me.

@Jeppa
Copy link
Author

Jeppa commented Dec 11, 2023

Seems to be fixed, thanks! ;)

@Jeppa Jeppa closed this as completed Dec 11, 2023
@Jeppa
Copy link
Author

Jeppa commented Dec 15, 2023

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)...

@Jeppa Jeppa reopened this Dec 15, 2023
@Jeppa Jeppa changed the title createPacket not working on 1.20.4 ? createPacket not working on 1.20.4 (again) ! Dec 16, 2023
@Jeppa
Copy link
Author

Jeppa commented Dec 16, 2023

OK, Build 677 works again ;)

@TheCalypso
Copy link

New problem mention in #2856

@Jeppa
Copy link
Author

Jeppa commented May 1, 2024

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...

@Jeppa Jeppa reopened this May 1, 2024
@Jeppa Jeppa changed the title createPacket not working on 1.20.4 (again) ! createPacket not working on 1.20.4 (and again on 1.20.5/6) ! May 2, 2024
@ghost
Copy link

ghost commented May 3, 2024

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

@Jeppa
Copy link
Author

Jeppa commented May 3, 2024

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.

@seraph-prisons
Copy link

seraph-prisons commented May 5, 2024

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:?]

@Jeppa
Copy link
Author

Jeppa commented May 6, 2024

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...

@Ghost-chu
Copy link

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) ~[?:?]

dump-2024-05-07_17.55.58.txt

  PacketContainer fakeItemPacket = manager.getProtocolManager().createPacket(PacketType.Play.Server.SPAWN_ENTITY);

@LoneDev6
Copy link

LoneDev6 commented May 7, 2024

Same issue

@seraph-prisons
Copy link

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) ~[?:?]

dump-2024-05-07_17.55.58.txt

  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.

@LoneDev6
Copy link

LoneDev6 commented May 9, 2024

More info here: #2917

@Ghost-chu
Copy link

Still exists on Paper-77 (1.20.6) with ProtocolLib v5.2.1-SNAPSHOT-689

@seraph-prisons
Copy link

Are there any temporary work arounds for now?

@EuSouVoce
Copy link
Contributor

Are there any temporary work arounds for now?

@seraph-prisons
Fork, change code, compile, just remember to disable tests, otherwise it'll not compile

@Jeppa
Copy link
Author

Jeppa commented May 15, 2024

@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...)

@Raidware
Copy link

Is this fixed?

@Jeppa
Copy link
Author

Jeppa commented May 18, 2024

Is this fixed?

No, it's not !

@dmulloy2 : any progress?

@Jeppa
Copy link
Author

Jeppa commented Jun 3, 2024

@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);

@MusclePr
Copy link

MusclePr commented Jun 5, 2024

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:        }

@MusclePr
Copy link

MusclePr commented Jun 5, 2024

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!

@dmulloy2
Copy link
Owner

dmulloy2 commented Jun 5, 2024

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

@Jeppa
Copy link
Author

Jeppa commented Jun 5, 2024

Looks good again ;)
The packets I'm using seem to be ok now.

Thanks!

@Jeppa Jeppa closed this as completed Jun 5, 2024
@dmulloy2 dmulloy2 unpinned this issue Jun 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants