package xyz.tbvns.rogue_block.Packets.registeredPackets;

import net.minecraft.network.RegistryByteBuf;
import net.minecraft.network.codec.PacketCodec;
import net.minecraft.network.codec.PacketCodecs;
import net.minecraft.network.packet.CustomPayload;
import net.minecraft.util.Identifier;
import xyz.tbvns.rogue_block.Rogue_block;

//TODO: replace that with @Data and @AllArgsConstructor
public record BytesPacket(byte[] bytes) implements CustomPayload {
    public static final Id ID = new Id<BytesPacket>(Identifier.of(Rogue_block.MOD_ID, "upgrade_packet"));
    public static final PacketCodec<RegistryByteBuf, BytesPacket> CODEC = PacketCodec.tuple(PacketCodecs.BYTE_ARRAY, BytesPacket::getBytes, BytesPacket::new);

    public byte[] getBytes() {
        return bytes;
    }

    @Override
    public Id<? extends CustomPayload> getId() {
        return new Id<BytesPacket>(Identifier.of(Rogue_block.MOD_ID, "upgrade_packet"));
    }
}
