package top.leisuretimedock.dglabgame.core.register;

import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Player;
import net.minecraftforge.common.capabilities.RegisterCapabilitiesEvent;
import net.minecraftforge.event.AttachCapabilitiesEvent;
import org.jetbrains.annotations.NotNull;
import top.leisuretimedock.dglabgame.DGLabGame;
import top.leisuretimedock.dglabgame.core.capability.AbstractDGLabData;
import top.leisuretimedock.dglabgame.core.capability.DGLabDataProvider;

public class DLGCapabilities {
    public static final String DG_LAB_DATA = "dg_lab_data";

    public static void registerCapability(@NotNull RegisterCapabilitiesEvent event) {
        event.register(AbstractDGLabData.class);
    }

    public static void attachCapability(@NotNull AttachCapabilitiesEvent<?> event) {
        // 虽然是Entity 但是只有Player才有意义
        if (event.getObject() instanceof Player entity) {
            event.addCapability(DGLabGame.rl(DG_LAB_DATA), new DGLabDataProvider(entity));
        }
    }
}
