package fr.koka99cab.ibelievechickenfly.chickenboat;

import fr.koka99cab.ibelievechickenfly.IBelieveChickenFlyMod;
import net.minecraft.network.RegistryFriendlyByteBuf;
import net.minecraft.network.codec.StreamCodec;
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;

public record ChickenBoatControlPayload(boolean up) implements CustomPacketPayload {
	public static final CustomPacketPayload.Type<ChickenBoatControlPayload> ID =
		new CustomPacketPayload.Type<>(IBelieveChickenFlyMod.id("boat_control"));
	public static final StreamCodec<RegistryFriendlyByteBuf, ChickenBoatControlPayload> CODEC =
		CustomPacketPayload.codec(ChickenBoatControlPayload::write, ChickenBoatControlPayload::new);

	public ChickenBoatControlPayload(RegistryFriendlyByteBuf buffer) {
		this(buffer.readBoolean());
	}

	private void write(RegistryFriendlyByteBuf buffer) {
		buffer.writeBoolean(this.up);
	}

	@Override
	public Type<? extends CustomPacketPayload> type() {
		return ID;
	}
}
