1.16.5 Get fields in ProtocolLib

Discussion in 'Spigot Plugin Development' started by LegitningLeo, Jun 12, 2021.

  1. Code (Java):
    @Override
        public void onEnable() {
            ProtocolManager manager = ProtocolLibrary.getProtocolManager();
            manager.addPacketListener(new PacketAdapter(getInstance(), ListenerPriority.NORMAL, PacketType.Play.Client.BLOCK_DIG) {
                @Override
                public void onPacketReceiving(PacketEvent event) {
                    Player player = event.getPlayer();
                    PacketContainer packet = event.getPacket();
                    System.out.println("GetField: " + packet.getBytes().getField(0));
                }
            });
        }

    I have this code and I just need to know the syntax for calling the a,b,c elements of protocollib on that last line. I think it is something along the lines of packet.getBytes().getField(0) but that does not work. Also if it helps at all here is the wiki for the BLOCK_DIG event I am using https://wiki.vg/Protocol#Player_Digging.