2018-09-12 05:43:59 +00:00
|
|
|
package com.seodisparate.TurnBasedMinecraft.common;
|
2018-08-28 02:26:34 +00:00
|
|
|
|
2018-08-29 06:09:44 +00:00
|
|
|
import java.time.Duration;
|
|
|
|
|
2018-08-28 06:13:14 +00:00
|
|
|
import org.apache.logging.log4j.Logger;
|
|
|
|
|
2018-08-29 06:09:44 +00:00
|
|
|
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;
|
2018-08-29 06:09:44 +00:00
|
|
|
import com.seodisparate.TurnBasedMinecraft.common.networking.PacketBattleRequestInfo;
|
2018-08-28 06:13:14 +00:00
|
|
|
|
|
|
|
import net.minecraft.entity.Entity;
|
2018-09-12 05:43:59 +00:00
|
|
|
import net.minecraftforge.common.MinecraftForge;
|
2018-08-28 02:26:34 +00:00
|
|
|
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;
|
2018-08-28 02:26:34 +00:00
|
|
|
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
2018-09-03 06:19:33 +00:00
|
|
|
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
|
2018-08-28 02:26:34 +00:00
|
|
|
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
2018-09-12 07:00:55 +00:00
|
|
|
import net.minecraftforge.fml.common.network.NetworkRegistry;
|
|
|
|
import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper;
|
2018-08-29 06:09:44 +00:00
|
|
|
import net.minecraftforge.fml.relauncher.Side;
|
2018-08-28 02:26:34 +00:00
|
|
|
|
2018-08-28 02:51:26 +00:00
|
|
|
@Mod(modid = TurnBasedMinecraftMod.MODID, name = TurnBasedMinecraftMod.NAME, version = TurnBasedMinecraftMod.VERSION)
|
2018-08-28 02:26:34 +00:00
|
|
|
public class TurnBasedMinecraftMod
|
|
|
|
{
|
2018-08-28 02:51:26 +00:00
|
|
|
public static final String MODID = "com.seodisparate.turnbasedminecraft";
|
2018-08-28 02:26:34 +00:00
|
|
|
public static final String NAME = "Turn Based Minecraft Mod";
|
2018-09-13 04:07:49 +00:00
|
|
|
public static final String VERSION = "0.1";
|
2018-08-29 06:09:44 +00:00
|
|
|
public static final Duration BattleDecisionTime = Duration.ofSeconds(15);
|
2018-09-03 06:19:33 +00:00
|
|
|
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;
|
2018-09-07 07:41:22 +00:00
|
|
|
public static final String CONFIG_INTERNAL_PATH = "/assets/TurnBasedMinecraft/" + CONFIG_FILENAME;
|
2018-09-10 05:59:56 +00:00
|
|
|
|
2018-09-07 07:41:22 +00:00
|
|
|
private static int CONFIG_FILE_VERSION = 0;
|
2018-09-12 07:00:55 +00:00
|
|
|
|
|
|
|
public static final SimpleNetworkWrapper NWINSTANCE = NetworkRegistry.INSTANCE.newSimpleChannel("seodisparate.tbmc");
|
2018-08-28 02:26:34 +00:00
|
|
|
|
2018-09-12 05:43:59 +00:00
|
|
|
protected static Logger logger;
|
|
|
|
protected static BattleManager battleManager;
|
2018-08-29 06:09:44 +00:00
|
|
|
private static int packetHandlerID = 0;
|
2018-09-12 05:43:59 +00:00
|
|
|
protected static Entity attackingEntity;
|
|
|
|
protected static int attackingDamage = 0;
|
|
|
|
protected static Config config;
|
2018-08-29 06:09:44 +00:00
|
|
|
|
2018-09-10 05:59:56 +00:00
|
|
|
public static Battle currentBattle = null;
|
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 commonProxy;
|
2018-08-28 02:26:34 +00:00
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
public void preInit(FMLPreInitializationEvent event)
|
|
|
|
{
|
|
|
|
logger = event.getModLog();
|
2018-09-07 07:41:22 +00:00
|
|
|
logger.debug("PREINIT");
|
2018-08-28 02:26:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
public void init(FMLInitializationEvent event)
|
|
|
|
{
|
2018-08-29 06:09:44 +00:00
|
|
|
currentBattle = null;
|
2018-09-12 05:43:59 +00:00
|
|
|
battleManager = null;
|
|
|
|
config = new Config(logger);
|
2018-08-29 06:09:44 +00:00
|
|
|
|
|
|
|
// register packets
|
2018-09-12 07:00:55 +00:00
|
|
|
NWINSTANCE.registerMessage(
|
2018-08-29 06:09:44 +00:00
|
|
|
PacketBattleInfo.HandlerBattleInfo.class,
|
|
|
|
PacketBattleInfo.class,
|
|
|
|
packetHandlerID++,
|
|
|
|
Side.CLIENT);
|
2018-09-12 07:00:55 +00:00
|
|
|
NWINSTANCE.registerMessage(
|
2018-08-29 06:09:44 +00:00
|
|
|
PacketBattleRequestInfo.HandlerBattleRequestInfo.class,
|
|
|
|
PacketBattleRequestInfo.class,
|
|
|
|
packetHandlerID++,
|
|
|
|
Side.SERVER);
|
2018-09-12 07:00:55 +00:00
|
|
|
NWINSTANCE.registerMessage(
|
2018-08-29 06:09:44 +00:00
|
|
|
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);
|
2018-09-07 07:41:22 +00:00
|
|
|
logger.debug("INIT");
|
2018-09-12 05:43:59 +00:00
|
|
|
|
|
|
|
// register event handler(s)
|
|
|
|
MinecraftForge.EVENT_BUS.register(new AttackEventHandler());
|
2018-08-28 06:13:14 +00:00
|
|
|
}
|
2018-08-29 06:09:44 +00:00
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
public void postInit(FMLPostInitializationEvent event)
|
|
|
|
{
|
2018-09-07 07:41:22 +00:00
|
|
|
logger.debug("POSTINIT");
|
2018-08-29 06:09:44 +00:00
|
|
|
}
|
2018-08-30 07:15:20 +00:00
|
|
|
|
|
|
|
public static BattleManager getBattleManager()
|
|
|
|
{
|
|
|
|
return battleManager;
|
|
|
|
}
|
2018-09-07 07:41:22 +00:00
|
|
|
|
|
|
|
public static void setConfigVersion(int version)
|
|
|
|
{
|
|
|
|
CONFIG_FILE_VERSION = version;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static int getConfigVersion()
|
|
|
|
{
|
|
|
|
return CONFIG_FILE_VERSION;
|
|
|
|
}
|
2018-08-28 02:26:34 +00:00
|
|
|
}
|