package top.leisuretimedock.dglabgame.core.event;

import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.common.capabilities.RegisterCapabilitiesEvent;
import net.minecraftforge.data.event.GatherDataEvent;
import net.minecraftforge.event.AttachCapabilitiesEvent;
import net.minecraftforge.event.RegisterCommandsEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import top.leisuretimedock.dglabgame.DGLabGame;
import top.leisuretimedock.dglabgame.core.capability.DGLabDataProvider;
import top.leisuretimedock.dglabgame.core.capability.DGLabDataSyncManager;
import top.leisuretimedock.dglabgame.core.command.DGLabCommands;
import top.leisuretimedock.dglabgame.core.register.DLGCapabilities;
import top.leisuretimedock.dglabgame.datagen.DLGDataGenEvent;
import top.r3944realms.lib39.api.event.SyncManagerRegisterEvent;

public class CommonEventHandler {
    @net.minecraftforge.fml.common.Mod.EventBusSubscriber(modid = DGLabGame.MOD_ID, bus = net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus.MOD)
    public static class Mod extends CommonEventHandler {
        @SubscribeEvent
        public static void gatherData(GatherDataEvent event) {
            DLGDataGenEvent.gatherData(event);
        }
        @SubscribeEvent
        public static void registerCapability(RegisterCapabilitiesEvent event) {
            DLGCapabilities.registerCapability(event);
        }

    }
    @net.minecraftforge.fml.common.Mod.EventBusSubscriber(modid = DGLabGame.MOD_ID, bus = net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus.FORGE)
    public static class Game extends CommonEventHandler {
        public static DGLabDataSyncManager dgLabDataSyncManager;
        public static ResourceLocation DG_LAB_SYNC = DGLabGame.rl("dg_lab_sync");

        @SubscribeEvent
        public static void onRegisterSyncManager(SyncManagerRegisterEvent event) {
            dgLabDataSyncManager = new DGLabDataSyncManager();
            event.registerSyncManager(
                    DG_LAB_SYNC, dgLabDataSyncManager, DGLabDataProvider.DG_LAB_DATA_CAPABILITY
            );
        }
        @SubscribeEvent
        public static void attachCapability(AttachCapabilitiesEvent<?> event) {
            DLGCapabilities.attachCapability(event);
        }

        @SubscribeEvent
        public static void onRegisterCommands(RegisterCommandsEvent event) {
            DGLabCommands.register(event.getDispatcher());
        }
    }
}
