ProtocolLib

3M Downloads

Unable to retrieve data objects from packets

CBlurban opened this issue ยท 1 comments

commented

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

commented

Sorry my bad, I didn't realize that the Dev Build and 4.8.0 were different versions