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-09-10 05:59:56 +00:00
|
|
|
import com.seodisparate.TurnBasedMinecraft.client.BattleGui;
|
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;
|
|
|
|
import com.seodisparate.TurnBasedMinecraft.common.networking.PacketHandler;
|
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 06:13:14 +00:00
|
|
|
import net.minecraftforge.event.entity.living.LivingAttackEvent;
|
2018-08-28 02:26:34 +00:00
|
|
|
import net.minecraftforge.fml.common.Mod;
|
|
|
|
import net.minecraftforge.fml.common.Mod.EventHandler;
|
|
|
|
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-07 07:41:22 +00:00
|
|
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
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";
|
|
|
|
public static final String VERSION = "1.0";
|
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-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;
|
|
|
|
public static BattleGui currentBattleGui = null;
|
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
|
|
|
|
PacketHandler.INSTANCE.registerMessage(
|
|
|
|
PacketBattleInfo.HandlerBattleInfo.class,
|
|
|
|
PacketBattleInfo.class,
|
|
|
|
packetHandlerID++,
|
|
|
|
Side.CLIENT);
|
|
|
|
PacketHandler.INSTANCE.registerMessage(
|
|
|
|
PacketBattleRequestInfo.HandlerBattleRequestInfo.class,
|
|
|
|
PacketBattleRequestInfo.class,
|
|
|
|
packetHandlerID++,
|
|
|
|
Side.SERVER);
|
|
|
|
PacketHandler.INSTANCE.registerMessage(
|
|
|
|
PacketBattleDecision.HandleBattleDecision.class,
|
|
|
|
PacketBattleDecision.class,
|
|
|
|
packetHandlerID++,
|
|
|
|
Side.SERVER);
|
2018-09-06 08:08:36 +00:00
|
|
|
PacketHandler.INSTANCE.registerMessage(
|
|
|
|
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
|
|
|
}
|