aboutsummaryrefslogtreecommitdiff
path: root/src/Java/miscutil/MiscUtils.java
blob: 7681e6a581595214a13a938fa719bd2196f09360 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
package miscutil;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import miscutil.core.commands.CommandMath;
import miscutil.core.common.CommonProxy;
import miscutil.core.common.compat.COMPAT_HANDLER;
import miscutil.core.creative.AddToCreativeTab;
import miscutil.core.handler.events.PickaxeBlockBreakEventHandler;
import miscutil.core.lib.CORE;
import miscutil.core.lib.LoadedMods;
import miscutil.core.util.PlayerCache;
import miscutil.core.util.Utils;
import miscutil.core.util.debug.DEBUG_ScreenOverlay;
import miscutil.core.util.uptime.Uptime;
import miscutil.gregtech.common.GregtechRecipeAdder;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.living.LivingDeathEvent;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLServerStartingEvent;
import cpw.mods.fml.common.event.FMLServerStoppingEvent;
import cpw.mods.fml.common.eventhandler.EventPriority;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.PlayerEvent;

@Mod(modid=CORE.MODID, name="Misc. Utils", version=CORE.VERSION, dependencies="required-after:gregtech;")
public class MiscUtils
implements ActionListener
{ 
	
	@Mod.Instance(CORE.MODID)
	public static MiscUtils instance;
	public static Uptime Uptime = new Uptime();

	@SidedProxy(clientSide="miscutil.core.proxy.ClientProxy", serverSide="miscutil.core.proxy.ServerProxy")
	public static CommonProxy proxy;


	//Pre-Init
	@Mod.EventHandler
	public void preInit(FMLPreInitializationEvent event)
	{
		LoadedMods.checkLoaded();
		Utils.LOG_INFO("Doing some house cleaning.");
		
		if (LoadedMods.Gregtech){
			try {
				CORE.sRecipeAdder = CORE.RA = new GregtechRecipeAdder();
			} catch (NullPointerException e){
				
			}
		}
		
		AddToCreativeTab.initialiseTabs();
		proxy.registerTileEntities();
		proxy.registerRenderThings();
		proxy.preInit(event);
		Uptime.preInit(); //Integration of Uptime.
		//FMLInterModComms.sendMessage("Waila", "register", "miscutil.core.waila.WailaCompat.load");
	}

	//Init
	@Mod.EventHandler
	public void init(FMLInitializationEvent event)
	{
		proxy.init(event);
		MinecraftForge.EVENT_BUS.register(this);
		MinecraftForge.EVENT_BUS.register(new PickaxeBlockBreakEventHandler());
		if (CORE.DEBUG){
			MinecraftForge.EVENT_BUS.register(new DEBUG_ScreenOverlay());	
		}
		FMLCommonHandler.instance().bus().register(this);
		proxy.registerNetworkStuff();
		Uptime.init(); //Integration of Uptime.
	}

	//Post-Init
	@Mod.EventHandler
	public void postInit(FMLPostInitializationEvent event) {
		Utils.LOG_INFO("Cleaning up, doing postInit.");
		COMPAT_HANDLER.ServerStartedEvent();
		PlayerCache.initCache();
		proxy.postInit(event);
		
	}

	@EventHandler
	public void serverStarting(FMLServerStartingEvent event)
	{
		event.registerServerCommand(new CommandMath());
		Uptime.serverStarting(); //Integration of Uptime.

	}

	@Mod.EventHandler
	public void serverStopping(FMLServerStoppingEvent event)
	{
		Uptime.serverStopping(); //Integration of Uptime.

	}

	@Override
	public void actionPerformed(ActionEvent arg0) {
		Uptime.actionPerformed(arg0); //Integration of Uptime.

	}
	
	@SubscribeEvent(priority=EventPriority.NORMAL, receiveCanceled=true)
	public void onPlayerLogin(PlayerEvent.PlayerLoggedInEvent event)
	{
		Uptime.onPlayerLogin(event);
	}

	@SubscribeEvent(priority=EventPriority.NORMAL, receiveCanceled=true)
	public void onPlayerLogout(PlayerEvent.PlayerLoggedOutEvent event)
	{
		Uptime.onPlayerLogout(event);
	}
	
	@SubscribeEvent(priority=EventPriority.NORMAL, receiveCanceled=true)
	public void onPlayerDeath(LivingDeathEvent lde)
	{
		Uptime.onPlayerDeath(lde);
	}

	@SubscribeEvent(priority=EventPriority.NORMAL, receiveCanceled=true)
	public void onPlayerRespawn(PlayerEvent.PlayerRespawnEvent event)
	{
		Uptime.onPlayerRespawn(event);
	}

}