85 lines
3.0 KiB
Java
85 lines
3.0 KiB
Java
package lostcave.deathchests;
|
|
|
|
import lostcave.deathchests.block.BlockDeathChest;
|
|
import lostcave.deathchests.block.BlockDeathChest.TileDeathChest;
|
|
import lostcave.deathchests.item.ItemObituary;
|
|
import lostcave.deathchests.util.Config;
|
|
import lostcave.deathchests.util.DeathChestStorage;
|
|
import lostcave.deathchests.util.Debug;
|
|
import net.minecraft.client.Minecraft;
|
|
import net.minecraft.init.Blocks;
|
|
import net.minecraft.tileentity.TileEntity;
|
|
import net.minecraftforge.common.DimensionManager;
|
|
import net.minecraftforge.common.MinecraftForge;
|
|
|
|
import java.io.File;
|
|
|
|
import cpw.mods.fml.common.FMLCommonHandler;
|
|
import cpw.mods.fml.common.Loader;
|
|
import cpw.mods.fml.common.Mod;
|
|
import cpw.mods.fml.common.Mod.EventHandler;
|
|
import cpw.mods.fml.common.event.FMLConstructionEvent;
|
|
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.FMLServerAboutToStartEvent;
|
|
import cpw.mods.fml.common.event.FMLServerStoppedEvent;
|
|
import cpw.mods.fml.common.registry.GameRegistry;
|
|
|
|
@Mod(modid = DeathChests.MODID, version = DeathChests.VERSION)
|
|
public class DeathChests {
|
|
public static final String MODID = "deathchests";
|
|
public static final String VERSION = "0-SNAPSHOT";
|
|
|
|
private static File worldSaveLocation;
|
|
|
|
@EventHandler
|
|
public void init(FMLConstructionEvent event) {
|
|
Debug.out("Received FMLConstructionEvent");
|
|
Config.configDir = Loader.instance().getConfigDir();
|
|
Debug.out("Config file is: " + Config.configDir.toString() + System.getProperty("file.separator") + Config.config_file_name);
|
|
|
|
Config.loadConfig();
|
|
Debug.out("Loaded config.");
|
|
}
|
|
|
|
@EventHandler
|
|
public void init(FMLPreInitializationEvent event) {
|
|
Debug.out("Received FMLPreInitializationEvent");
|
|
}
|
|
|
|
@EventHandler
|
|
public void init(FMLInitializationEvent event) {
|
|
Debug.out("Received FMLInitializationEvent");
|
|
|
|
GameRegistry.registerBlock(BlockDeathChest.getInstance(), "death_chest");
|
|
if (Config.giveObituary) {
|
|
GameRegistry.registerItem(ItemObituary.getInstance(), "obituary");
|
|
}
|
|
Debug.out("Registered block and item.");
|
|
|
|
MinecraftForge.EVENT_BUS.register(new EventHook());
|
|
FMLCommonHandler.instance().bus().register(new EventHook());
|
|
Debug.out("Registered event hook.");
|
|
}
|
|
|
|
@EventHandler
|
|
public void init(FMLPostInitializationEvent event) {
|
|
Debug.out("Received FMLPostInitializationEvent");
|
|
TileEntity.addMapping(TileDeathChest.class, "death_chest");
|
|
}
|
|
|
|
@EventHandler
|
|
public void init(FMLServerAboutToStartEvent event) {
|
|
Debug.out("Received FMLServerAboutToStartEvent");
|
|
worldSaveLocation = DimensionManager.getCurrentSaveRootDirectory();
|
|
DeathChestStorage.load(worldSaveLocation);
|
|
}
|
|
|
|
@EventHandler
|
|
public void init(FMLServerStoppedEvent event) {
|
|
DeathChestStorage.save(worldSaveLocation);
|
|
}
|
|
|
|
}
|