ProtocolLib

3M Downloads

Using getDimensions doesn't seem to write ResourceKey field

msparkles opened this issue ยท 1 comments

commented

Describe the bug
When using getDimensions().write(0, value), ProtocolLib doesn't write to the ResourceKey field.

To Reproduce
Steps to reproduce the behavior:

  1. Call getDimensions().write(0, <value>) *e.g. 0
  2. Print the packet's fields and see ResourceKey be null/World Names be empty

Expected behavior
ResourceKey to be filled, not null
World Names to be not empty

Version Info
https://pastebin.com/XAAWZPjb

Additional context
A normal PacketPlayServerLogin's fields

[
   861,
   1163285567470036550,
   false,
   CREATIVE,
   SURVIVAL,
   [
      ResourceKey[
         minecraft:dimension / minecraft:overworld
      ]
   ],
   net.minecraft.server.v1_16_R3.IRegistryCustom$Dimension@3da44252,
   net.minecraft.server.v1_16_R3.DimensionManager@6626ae40,
   ResourceKey[
      minecraft:dimension / minecraft:overworld
   ],
   20,
   10,
   false,
   true,
   false,
   false
]

A packet printed after setting the EID, game mode, debug info, and dimension.

[
   862,
   0,
   false,
   CREATIVE,
   NOT_SET,
   [
      
   ],
   net.minecraft.server.v1_16_R3.IRegistryCustom$Dimension@6878c42b,
   net.minecraft.server.v1_16_R3.DimensionManager@6626ae40,
   null,
   0,
   0,
   false,
   false,
   false,
   false
]
commented

Tried to write it using

public void setResourceKey(World value) {
    handle.getWorldKeys().write(0, value);
}

No more NPE, but the client crashes upon sending the packet.