more cleanup

This commit is contained in:
Rseifert 2013-02-20 13:48:46 -05:00
parent 69abbd43f3
commit b31c339be9
4 changed files with 108 additions and 174 deletions

View file

@ -107,17 +107,17 @@ public class FluidMech extends DummyModContainer
public static FluidMech instance;
public static Logger FMLog = Logger.getLogger(NAME);
@PreInit
public void preInit(FMLPreInitializationEvent event)
{
FMLog.setParent(FMLLog.getLogger());
FMLog.info("Initializing...");
MinecraftForge.EVENT_BUS.register(new LiquidHandler());
FMLog.setParent(FMLLog.getLogger());
FMLog.info("Initializing...");
MinecraftForge.EVENT_BUS.register(new LiquidHandler());
instance = this;
CONFIGURATION.load();
// Blocks
blockPipe = new BlockPipe(this.CONFIGURATION.getBlock("Pipes", BLOCK_ID_PREFIX).getInt());
blockMachine = new BlockPumpMachine(this.CONFIGURATION.getBlock("Machines", BLOCK_ID_PREFIX + 1).getInt());
@ -148,14 +148,13 @@ public class FluidMech extends DummyModContainer
GameRegistry.registerBlock(blockMachine, ItemLiquidMachine.class, "lmMachines");
GameRegistry.registerBlock(blockTank, ItemTank.class, "lmTank");
GameRegistry.registerBlock(blockSink, "lmSink");
}
@Init
public void Init(FMLInitializationEvent event)
{
FMLog.info("Loading...");
FMLog.info("Loading...");
proxy.Init();
// TileEntities
GameRegistry.registerTileEntity(TileEntityPipe.class, "lmPipeTile");
@ -166,14 +165,13 @@ public class FluidMech extends DummyModContainer
GameRegistry.registerTileEntity(TileEntityGenerator.class, "lmGen");
GameRegistry.registerTileEntity(TileEntitySink.class, "lmSink");
FMLog.info("Fluid Mechanics Loaded: " + TranslationHelper.loadLanguages(LANGUAGE_PATH, LANGUAGES_SUPPORTED) + " Languages.");
}
@PostInit
public void PostInit(FMLPostInitializationEvent event)
{
FMLog.info("Finalizing...");
FMLog.info("Finalizing...");
proxy.postInit();
TabFluidMech.setItemStack(new ItemStack(blockPipe, 1, 4));
// generator
@ -293,7 +291,7 @@ public class FluidMech extends DummyModContainer
'@', "plateSteel",
'X', new ItemStack(blockPipe, 1, ColorCode.NONE.ordinal()),
'B', new ItemStack(itemParts, 1, Parts.Valve.ordinal()),
'C',"basicCircuit",
'C', "basicCircuit",
'M', "motor" }));
// release valve
@ -320,9 +318,9 @@ public class FluidMech extends DummyModContainer
OreDictionary.registerOre("bronzeTube", new ItemStack(itemParts, 1, Parts.Bronze.ordinal()));
OreDictionary.registerOre("unfinishedTank", new ItemStack(itemParts, 1, Parts.Tank.ordinal()));
// add Default Liquids to current list, done last to let other mods use
// there liquid data first if used
// there liquid data first if used
LiquidStack waste = LiquidDictionary.getOrCreateLiquid("Waste", new LiquidStack(FluidMech.blockWasteLiquid, 1));
LiquidHandler.addDefaultLiquids();
LiquidHandler.addDefaultLiquids();
FMLog.info("Done Loading");
}
}

View file

@ -6,37 +6,36 @@ import net.minecraftforge.event.ForgeSubscribe;
import net.minecraftforge.event.world.WorldEvent;
import cpw.mods.fml.common.FMLLog;
public class HydraulicLoader
{
public static final HydraulicLoader INSTANCE = new HydraulicLoader();
public static final HydraulicLoader INSTANCE = new HydraulicLoader();
public static boolean isInitialized = false;
public static boolean isInitialized = false;
public void initiate()
{
if (!isInitialized)
{
Hydraulic.instance = new Hydraulic();
MinecraftForge.EVENT_BUS.register(this);
public void initiate()
{
if (!isInitialized)
{
Hydraulic.instance = new Hydraulic();
MinecraftForge.EVENT_BUS.register(this);
FMLLog.finest("Hydraulics v" + UniversalElectricity.VERSION + " loaded without error!");
FMLLog.finest("Hydraulics v" + Hydraulics.VERSION + " loaded without error!");
isInitialized = true;
}
}
isInitialized = true;
}
}
@ForgeSubscribe
public void onWorldUnLoad(WorldEvent.Unload event)
{
Hydraulic.instance = new Hydraulic();
Hydraulic.instance.cleanUpNetworks();
}
@ForgeSubscribe
public void onWorldUnLoad(WorldEvent.Unload event)
{
Hydraulic.instance = new Hydraulic();
Hydraulic.instance.cleanUpNetworks();
}
@ForgeSubscribe
public void onWorldLoad(WorldEvent.Load event)
{
Hydraulic.instance = new Hydraulic();
Hydraulic.instance.cleanUpNetworks();
}
@ForgeSubscribe
public void onWorldLoad(WorldEvent.Load event)
{
Hydraulic.instance = new Hydraulic();
Hydraulic.instance.cleanUpNetworks();
}
}

View file

@ -0,0 +1,72 @@
package hydraulic.core;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.Material;
import net.minecraftforge.common.Configuration;
import net.minecraftforge.common.ForgeVersion;
import cpw.mods.fml.common.FMLLog;
import cpw.mods.fml.common.Loader;
public class Hydraulics
{
/**
* The version of the Universal Electricity API.
*/
public static final int MAJOR_VERSION = 0;
public static final int MINOR_VERSION = 0;
public static final int REVISION_VERSION = 1;
public static final String VERSION = MAJOR_VERSION + "." + MINOR_VERSION + "." + REVISION_VERSION;
/**
* The Universal Electricity configuration file.
*/
public static final Configuration CONFIGURATION = new Configuration(new File(Loader.instance().getConfigDir(), "hydraulics/hydraulics.cfg"));
/**
* A list of all mods Universal Electricity has loaded.
*/
public static final List<Object> mods = new ArrayList<Object>();
/**
* You must register your mod with Universal Electricity. Call this in your mod's
* pre-initialization stage.
*/
public static void register(Object mod, int major, int minor, int revision, boolean strict)
{
if (MAJOR_VERSION != major)
{
throw new RuntimeException("A Hydraulics mod " + mod.getClass().getSimpleName() + " is way too old! Make sure it is update to v" + major + "." + minor + "." + revision);
}
if (MINOR_VERSION < minor)
{
throw new RuntimeException("A Hydraulics mod " + mod.getClass().getSimpleName() + " is too old! Make sure it is update to v" + major + "." + minor + "." + revision);
}
if (REVISION_VERSION < revision)
{
if (strict)
{
throw new RuntimeException("A Hydraulics mod " + mod.getClass().getSimpleName() + " is too old! Require v" + major + "." + minor + "." + revision);
}
else
{
FMLLog.warning("The version of Hydraulics detected is not the recommended version by the mod " + mod.getClass().getSimpleName() + ". Odd things might happen. Recommended to try v" + major + "." + minor + "." + revision);
}
}
mods.add(mod);
FMLLog.fine(mod.getClass().getSimpleName() + " has been registered to Hydraulics.");
HydraulicLoader.INSTANCE.initiate();
}
}

View file

@ -1,135 +0,0 @@
package hydraulic.core;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.Material;
import net.minecraftforge.common.Configuration;
import net.minecraftforge.common.ForgeVersion;
import cpw.mods.fml.common.FMLLog;
import cpw.mods.fml.common.Loader;
/**
* Instructions for using the Universal Electricity API.
*
* The less you include of the API, the more compatible your mod will be for future releases of
* Universal Electricity.
*
* REQUIRED PACKAGE: "universalelectricity.core" OPTIONAL PACKAGE: "universalelectricity.prefab"
*
* All classes should be removed if you are not going to use them.
*
* @author Calclavia
*
*/
public class UniversalElectricity
{
/**
* The version of the Universal Electricity API.
*/
public static final int MAJOR_VERSION = 1;
public static final int MINOR_VERSION = 2;
public static final int REVISION_VERSION = 6;
public static final String VERSION = MAJOR_VERSION + "." + MINOR_VERSION + "." + REVISION_VERSION;
/**
* The Universal Electricity configuration file.
*/
public static final Configuration CONFIGURATION = new Configuration(new File(Loader.instance().getConfigDir(), "UniversalElectricity/UniversalElectricity.cfg"));
/**
* Conversion ratios between Buildcraft and Industrialcraft energy.
*/
// The amount of UE Joules equivalent to IC2 EU
public static double IC2_RATIO = 40;
// The amount of UE Joules equivalent to BC Minecraft Joules
public static double BC3_RATIO = 100;
public static double TO_IC2_RATIO = 1 / IC2_RATIO;
public static double TO_BC_RATIO = 1 / BC3_RATIO;
/**
* Is Universal Electricity currently being voltage sensitive? If so, all machines should
* explode under high voltage and react to different amounts of voltage differently.
*/
public static boolean isVoltageSensitive = false;
/**
* Use this material for all your machine blocks. It can be breakable by hand.
*/
public static final Material machine = new Material(MapColor.ironColor);
/**
* A list of all mods Universal Electricity has loaded.
*/
public static final List<Object> mods = new ArrayList<Object>();
/**
* You must register your mod with Universal Electricity. Call this in your mod's
* pre-initialization stage.
*/
public static void register(Object mod, int major, int minor, int revision, boolean strict)
{
if (MAJOR_VERSION != major)
{
throw new RuntimeException("A Universal Electricity mod " + mod.getClass().getSimpleName() + " is way too old! Make sure it is update to v" + major + "." + minor + "." + revision);
}
if (MINOR_VERSION < minor)
{
throw new RuntimeException("A Universal Electricity mod " + mod.getClass().getSimpleName() + " is too old! Make sure it is update to v" + major + "." + minor + "." + revision);
}
if (REVISION_VERSION < revision)
{
if (strict)
{
throw new RuntimeException("A Universal Electricity mod " + mod.getClass().getSimpleName() + " is too old! Require v" + major + "." + minor + "." + revision);
}
else
{
FMLLog.warning("The version of Universal Electricity detected is not the recommended version by the mod " + mod.getClass().getSimpleName() + ". Odd things might happen. Recommended to try v" + major + "." + minor + "." + revision);
}
}
mods.add(mod);
FMLLog.fine(mod.getClass().getSimpleName() + " has been registered to Universal Electricity.");
HydraulicLoader.INSTANCE.initiate();
}
/**
* A function that allows you to lock your mod to a specific version of Forge.
*/
public static void forgeLock(int major, int minor, int revision, boolean strict)
{
if (ForgeVersion.getMajorVersion() != major)
{
throw new RuntimeException("Universal Electricity: Wrong Minecraft Forge version! Require " + major + "." + minor + "." + revision);
}
if (ForgeVersion.getMinorVersion() < minor)
{
throw new RuntimeException("Universal Electricity: Minecraft Forge minor version is too old! Require " + major + "." + minor + "." + revision);
}
if (ForgeVersion.getRevisionVersion() < revision)
{
if (strict)
{
throw new RuntimeException("Universal Electricity: Minecraft Forge revision version is too old! Require " + major + "." + minor + "." + revision);
}
else
{
System.out.println("Universal Electricity Warning: Minecraft Forge is not the specified version. Odd things might happen. Require " + major + "." + minor + "." + revision);
}
}
}
public static void forgeLock(int major, int minor, int revision)
{
forgeLock(major, minor, revision, false);
}
}