Unable to retrieve data objects from packets
CBlurban opened this issue ยท 1 comments
Hi, I'm currently trying to read some packet data from a MAP_CHUNK packet however using the call to MapChunkPacketWrapper.getTileEntities() returns an error that the index 0 does not exist. I suspect that I'm simply not creating the packet object correctly as I'm pretty new to writing plugins in Java, however the packet object is returning the correct type.
My test code currently looks like this:
`{
@Override
public void onEnable() {
getServer().getPluginManager().registerEvents(new MyListener(), this);
ProtocolManager manager = ProtocolLibrary.getProtocolManager();
// Listen for chunk packets
manager.addPacketListener(new PacketAdapter(
this,
ListenerPriority.NORMAL,
PacketType.Play.Server.MAP_CHUNK
) {
@Override
public void onPacketSending(PacketEvent event) {
Player player = event.getPlayer();
PacketContainer packet = event.getPacket();
WrapperPlayServerMapChunk MapChunkPacketWrapper = new WrapperPlayServerMapChunk(packet);
List<NbtBase<?>> TileEntities = MapChunkPacketWrapper.getTileEntities();
}
});
}
@Override
public void onDisable() {
// Plugin shutdown logic
}
}`
I have tried some other packet types too such as TILE_ENTITY_DATA and reading from their lists returned the same error. I'm using ProtocolLib 4.8.0 and a Minecraft 1.19.4 Paper Server
Thanks, Cameron