package top.leisuretimedock.dglabgame.core.capability;

import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.entity.Entity;
import top.leisuretimedock.dglabgame.core.event.CommonEventHandler;
import top.r3944realms.lib39.util.nbt.NBTReader;
import top.r3944realms.lib39.util.nbt.NBTWriter;

public final class EntityDGLabData extends AbstractDGLabData {
    private final Entity entity;
    public static final String ACCEPT_USER_AGREEMENT = "AcceptUserAgreement";
    public EntityDGLabData(Entity entity) {
        super(CommonEventHandler.Game.DG_LAB_SYNC);
        this.entity = entity;
    }
    @Override
    public CompoundTag serializeNBT() {
        return NBTWriter.builder()
                .booleanValue(ACCEPT_USER_AGREEMENT, hasAcceptUseAgreements())
                .build();
    }

    @Override
    public void deserializeNBT(CompoundTag compoundTag) {
        NBTReader.of(compoundTag)
                .booleanValue(ACCEPT_USER_AGREEMENT, this::setAcceptUseAgreements);
    }

    public Entity getEntity() {
        return entity;
    }

    @Override
    public int entityId() {
        return entity.getId();
    }

    @Override
    public void update() {
    }
}
