TurnBasedMinecraftMod/src/main/java/com/seodisparate/TurnBasedMinecraft/common/TurnBasedMinecraftMod.java

108 lines
4.2 KiB
Java
Raw Normal View History

package com.seodisparate.TurnBasedMinecraft.common;
import org.apache.logging.log4j.Logger;
import com.seodisparate.TurnBasedMinecraft.common.networking.PacketBattleDecision;
import com.seodisparate.TurnBasedMinecraft.common.networking.PacketBattleInfo;
2018-09-06 08:08:36 +00:00
import com.seodisparate.TurnBasedMinecraft.common.networking.PacketBattleMessage;
import com.seodisparate.TurnBasedMinecraft.common.networking.PacketBattleRequestInfo;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
2018-09-12 06:39:55 +00:00
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.event.FMLServerStoppingEvent;
2018-09-12 07:00:55 +00:00
import net.minecraftforge.fml.common.network.NetworkRegistry;
import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper;
import net.minecraftforge.fml.relauncher.Side;
2018-08-28 02:51:26 +00:00
@Mod(modid = TurnBasedMinecraftMod.MODID, name = TurnBasedMinecraftMod.NAME, version = TurnBasedMinecraftMod.VERSION)
public class TurnBasedMinecraftMod
{
2018-08-28 02:51:26 +00:00
public static final String MODID = "com.seodisparate.turnbasedminecraft";
public static final String NAME = "Turn Based Minecraft Mod";
2018-09-21 07:11:59 +00:00
public static final String VERSION = "0.3";
public static final String CONFIG_FILENAME = "TBM_Config.xml";
public static final String CONFIG_DIRECTORY = "config/TurnBasedMinecraft/";
public static final String CONFIG_FILE_PATH = CONFIG_DIRECTORY + CONFIG_FILENAME;
public static final String CONFIG_INTERNAL_PATH = "/assets/TurnBasedMinecraft/" + CONFIG_FILENAME;
public static final String MUSIC_ROOT = CONFIG_DIRECTORY + "Music/";
public static final String MUSIC_SILLY = MUSIC_ROOT + "silly/";
public static final String MUSIC_BATTLE = MUSIC_ROOT + "battle/";
2018-09-10 05:59:56 +00:00
2018-09-12 07:00:55 +00:00
public static final SimpleNetworkWrapper NWINSTANCE = NetworkRegistry.INSTANCE.newSimpleChannel("seodisparate.tbmc");
protected static Logger logger;
private static int packetHandlerID = 0;
2018-09-12 06:39:55 +00:00
@SidedProxy(modId=MODID, serverSide="com.seodisparate.TurnBasedMinecraft.common.CommonProxy", clientSide="com.seodisparate.TurnBasedMinecraft.client.ClientProxy")
public static CommonProxy proxy;
@EventHandler
public void preInit(FMLPreInitializationEvent event)
{
logger = event.getModLog();
proxy.setLogger(logger);
}
@EventHandler
public void init(FMLInitializationEvent event)
{
proxy.initialize();
// register packets
2018-09-12 07:00:55 +00:00
NWINSTANCE.registerMessage(
PacketBattleInfo.HandlerBattleInfo.class,
PacketBattleInfo.class,
packetHandlerID++,
Side.CLIENT);
2018-09-12 07:00:55 +00:00
NWINSTANCE.registerMessage(
PacketBattleRequestInfo.HandlerBattleRequestInfo.class,
PacketBattleRequestInfo.class,
packetHandlerID++,
Side.SERVER);
2018-09-12 07:00:55 +00:00
NWINSTANCE.registerMessage(
PacketBattleDecision.HandleBattleDecision.class,
PacketBattleDecision.class,
packetHandlerID++,
Side.SERVER);
2018-09-12 07:00:55 +00:00
NWINSTANCE.registerMessage(
2018-09-06 08:08:36 +00:00
PacketBattleMessage.HandlerBattleMessage.class,
PacketBattleMessage.class,
packetHandlerID++,
Side.CLIENT);
// register event handler(s)
MinecraftForge.EVENT_BUS.register(new AttackEventHandler());
}
@EventHandler
public void postInit(FMLPostInitializationEvent event)
{
proxy.postInit();
}
@EventHandler
public void serverStarting(FMLServerStartingEvent event)
{
logger.debug("About to initialize BattleManager");
if(proxy.initializeBattleManager())
{
logger.debug("Initialized BattleManager");
}
}
@EventHandler
public void serverStopping(FMLServerStoppingEvent event)
{
logger.debug("About to cleanup BattleManager");
if(proxy.cleanupBattleManager())
{
logger.debug("Cleaned up BattleManager");
}
}
}