package nmd.primal.sorcery;

import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.Mod.Instance;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
import net.minecraftforge.fml.common.network.NetworkRegistry;
import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper;
import nmd.primal.sorcery.common.CommonProxy;
import nmd.primal.sorcery.common.init.ModInfo;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.util.Locale;

@Mod(   modid = ModInfo.MOD_ID,
        name = ModInfo.MOD_ID,
        version = ModInfo.MOD_VERSION,
        acceptedMinecraftVersions = ModInfo.MC_VERSIONS,
        dependencies = ModInfo.DEPENDENCIES,
        updateJSON = ModInfo.UPDATE_JSON
)

public class PrimalSorcery
{
    @Instance(ModInfo.MOD_ID)
    public static PrimalSorcery INSTANCE;

    @SidedProxy(clientSide = ModInfo.CLIENT_PROXY, serverSide = ModInfo.COMMON_PROXY)
    private static CommonProxy PROXY;

    private static SimpleNetworkWrapper NETWORK = NetworkRegistry.INSTANCE.newSimpleChannel(ModInfo.MOD_ID);
    private static Logger LOGGER = LogManager.getLogger(ModInfo.MOD_ID);

    @EventHandler
    public void preInit(FMLPreInitializationEvent event)
    {
        Locale.setDefault(Locale.ENGLISH);
        LOGGER.info("Pre-Init");
        PROXY.preInit();

        // pre init stuff
    }

    @EventHandler
    public void init(FMLInitializationEvent event)
    {
        LOGGER.info("Init");
        PROXY.init();

        // init stuff
    }

    @EventHandler
    public void postInit(FMLPostInitializationEvent event)
    {
        LOGGER.info("Post-Init");
        PROXY.postInit();

        // post init stuff
    }

    @EventHandler
    public void serverStarting(FMLServerStartingEvent event)
    {
        // custom commands
    }

    // ***************************************************************************** //
    //  helper methods
    // ***************************************************************************** //
    public static SimpleNetworkWrapper getNetwork() {
        return NETWORK;
    }

    public static CommonProxy getProxy() {
        return PROXY;
    }

    public static Logger getLogger() {
        return LOGGER;
    }
}
