package com.tiedup.remake.client.state;

import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;

/**
 * Client-side cache of pet bed mode + facing per player.
 * Used by AnimationTickHandler to avoid overriding pet bed animations with bondage animations
 * and to lock body rotation to bed facing.
 */
@OnlyIn(Dist.CLIENT)
public class PetBedClientState {

    private record Entry(byte mode, float facingYRot) {}

    private static final Map<UUID, Entry> states = new ConcurrentHashMap<>();

    public static void set(UUID uuid, byte mode, float facingYRot) {
        states.put(uuid, new Entry(mode, facingYRot));
    }

    public static byte get(UUID uuid) {
        Entry e = states.get(uuid);
        return e != null ? e.mode : 0;
    }

    public static float getFacing(UUID uuid) {
        Entry e = states.get(uuid);
        return e != null ? e.facingYRot : 0f;
    }

    public static void clear(UUID uuid) {
        states.remove(uuid);
    }

    public static void clearAll() {
        states.clear();
    }
}
