ProtocolLib

3M Downloads

com.comphenix.protocol.reflect.FieldAccessException: No field with type net.minecraft.server.v1_16_R1.EnumDifficulty exists in class PacketPlayOutRespawn.

MrKorvic opened this issue ยท 3 comments

commented

Describe the bug
Similar to the DimensionManager issue, When attempting to play the respawn packet to a player, ProtocolLib fails to find the v1_16_R1 EnumDifficulty field.

To Reproduce
Steps to reproduce the behavior:

  1. Get ProtocolManager
  2. Create a PacketContainer with PacketType.Play.Server.RESPAWN
  3. Write data to the packet's dimensions using packet#getDifficulties#write. This can even be done using the player's current world difficulty and a fieldIndex of 0.
  4. Observe FieldAccessException in the console.

Expected behavior
Should set the packet's difficulty to the one provided.

Screenshots
https://i.imgur.com/VdDhJiV.png
https://i.imgur.com/kuAr0hL.png

Version Info
https://pastebin.com/TzaM4XgK

commented

1.16 has no difficultly field (ref). That's not a fault of ProtocolLib.

However for the respawn packet it's still necessary to set the World Name. This is also a ResourceKey similar to #893. As a workaround we used a combination of reflection and use a specific StructureModifier for the ResourceKey class.

Nevertheless an official way would be much better.

commented

1.16 has no difficultly field (ref). That's not a fault of ProtocolLib.

However for the respawn packet it's still necessary to set the World Name. This is also a ResourceKey similar to #893. As a workaround we used a combination of reflection and use a specific StructureModifier for the ResourceKey class.

Nevertheless an official way would be much better.

So for 1.16+ I can just ignore the difficulty field altogether, you think?

commented

1.16 has no difficultly field (ref). That's not a fault of ProtocolLib.
However for the respawn packet it's still necessary to set the World Name. This is also a ResourceKey similar to #893. As a workaround we used a combination of reflection and use a specific StructureModifier for the ResourceKey class.
Nevertheless an official way would be much better.

So for 1.16+ I can just ignore the difficulty field altogether, you think?

he's directly telling you that there is no difficulty field. theres nothing to ignore. so no.. but yes.