#Encoding Packet Error

6 messages · Page 1 of 1 (latest)

cosmic thicket
#

im getting the above error and i dont really know why. i rewrote the networking for 1.20.5+ and in singleplayer it works perfectly fine, but when used on a server, the user gets kicked from server with the message "Failed to Encode Packet..." the following code are my CustomPayloads

public record PlaySoundPayload(BlockPos blockPos, String urlName) implements CustomPayload {
        public static final CustomPayload.Id<PlaySoundPayload> ID = CustomPayload.id("vinurl:play_sound");
        public static final PacketCodec<RegistryByteBuf, PlaySoundPayload> CODEC = PacketCodec.tuple(BlockPos.PACKET_CODEC, PlaySoundPayload::blockPos, PacketCodecs.STRING, PlaySoundPayload::urlName, PlaySoundPayload::new);

        @Override
        public Id<PlaySoundPayload> getId() {
            return ID;
        }
    }

    public record SetURLPayload(String urlName) implements CustomPayload {
        public static final CustomPayload.Id<SetURLPayload> ID = CustomPayload.id("vinurl:record_set_url");
        public static final PacketCodec<RegistryByteBuf, SetURLPayload> CODEC = PacketCodecs.STRING.xmap(SetURLPayload::new, SetURLPayload::urlName).cast();

        @Override
        public Id<SetURLPayload> getId() {
            return ID;
        }
    }


    public record RecordGUIPayload(String urlName) implements CustomPayload {
        public static final CustomPayload.Id<RecordGUIPayload> ID = CustomPayload.id("vinurl:record_gui");
        public static final PacketCodec<RegistryByteBuf, RecordGUIPayload> CODEC = PacketCodecs.STRING.xmap(RecordGUIPayload::new, RecordGUIPayload::urlName).cast();


        @Override
        public Id<RecordGUIPayload> getId() {
            return ID;
        }
    }
upbeat jasper
#

Did you register the packet codec?

cosmic thicket
#

I indeed did

#

Or do i need to register it in main source instead of only in Client?