No Wrapper for net.minecraft.network.protocol.game.ClientboundLevelChunkPacketData
Brokkonaut opened this issue ยท 7 comments
Describe the bug
1.18 has changed the "MAP_CHUNK" packet, it does now contain a field of type net.minecraft.network.protocol.game.ClientboundLevelChunkPacketData and a field of type net.minecraft.network.protocol.game.ClientboundLightUpdatePacketData. Both currently have no wrappers.
Use container.getStructures().read(0)
for this, see
Use
container.getStructures().read(0)
for this
How do I get the tile entity datas (I need the nbt and the coords) from there?
While I'm reading the code it looks like it isn't that trivial with ProtocolLib currently. Let me look into this to give you a better answer :)
Something like this works for me:
List<InternalStructure> chunkData = event.getPacket().getStructures().read(0).getLists(InternalStructure.CONVERTER).read(0);
You can then loop over the chunk data list and read/write to the object normally, something like this:
for (InternalStructure struct : chunkData) {
int packedXZ = struct.getIntegers().read(0); // calculated with ((blockX & 15) << 4) | (blockZ & 15)
int relativeY = struct.getIntegers().read(1);
NbtBase nbt = strct.getNbtModifier().read(0);
// do stuff with it
}
Hope this helps!
Thank you for your help :) InternalStructure.CONVERTER is not public, so I had to use reflection to get it. But at least it is working now.
Hey (again),
I think we should extend the api we provide to read from / write to internal structures in v5 as Mojang is becoming more and more a friend of "fake" enums. This is something I can look into in the next days, side to side with the improvements to the reflection code which is powering all these things. Currently I am more looking forward to find all issues with the new injection system and fix them...
@Brokkonaut How do you do this? I'm new to Java.