ProtocolLib

3M Downloads

Can't serialize unregistered packet

papr0tka opened this issue · 1 comments

commented

Make sure you're doing the following

  • You're using the latest build for your server version
  • This isn't an issue caused by another plugin
  • You've checked for duplicate issues
  • You didn't use /reload

Describe the question
So after use ProtocolContainer to create an packet and send it to player, server kick with message Internal Exception: io.netty.handler.codec.EncoderException: java.io.IOException: Can't serialize unregistered packet

API method(s) used
construcor, getBlockPositionModifier, write, getStringArrays, sendServerPacket

Expected behavior
open sign editor

Code

        PacketContainer sign = new PacketContainer(PacketType.Play.Client.UPDATE_SIGN);
        sign.getBlockPositionModifier().write(0, new BlockPosition(0, 0, 0));
        String[] lines = new String[4];
        lines[0] = Main.hexTranslate("&6To działa");
        lines[1] = "Naprawdę";
        lines[2] = "3";
        lines[3] = "4";
        sign.getStringArrays().write(0, lines);

        Main.getProtocolManager().sendServerPacket(player, sign);

Additional context
empty

commented

Client packet types are packets sent by the client to the server (inbound). You want to send an outbound packet, use PacketType.Play.Server.UPDATE_SIGN for versions before 1.9.4 or PacketType.Play.Server.TILE_ENTITY_DATA for 1.9.4 and later