Nicer logging of EE3 stuff, some initial work on mod addons, more tickhandler stuff

This commit is contained in:
pahimar 2012-06-21 16:21:49 -04:00
parent 824958ac21
commit 00d00be781
9 changed files with 123 additions and 17 deletions

View file

@ -20,9 +20,4 @@ public class SoundHandler extends SoundHandlerAdaptor {
for (int i = 0; i < soundFiles.length; i++) for (int i = 0; i < soundFiles.length; i++)
soundManager.getSoundsPool().addSound(soundFiles[i], this.getClass().getResource("/" + soundFiles[i])); soundManager.getSoundsPool().addSound(soundFiles[i], this.getClass().getResource("/" + soundFiles[i]));
} }
@Override
public String onPlaySoundAtEntity(Entity entity, String soundName, float volume, float pitch) {
return soundName;
}
} }

View file

@ -2,7 +2,7 @@ package ee3.addons;
import net.minecraft.src.Item; import net.minecraft.src.Item;
import net.minecraft.src.ModLoader; import net.minecraft.src.ModLoader;
import ee3.lib.Reference; import ee3.lib.Helper;
/** /**
* TODO Class Description * TODO Class Description
@ -13,10 +13,12 @@ public class BuildCraftAddon extends EEAddon {
public static void init() { public static void init() {
try { try {
ModLoader.getLogger().fine(Reference.LOGGER_PREFIX + "Loaded BuildCraft Addon"); ModLoader.getLogger().finer(Helper.getLogMessage("BuildCraft detected; attempting to initialize BuildCraft addon"));
ModLoader.getLogger().finer(Helper.getLogMessage("BuildCraft addon initialized"));
} }
catch (Exception e) { catch (Exception e) {
ModLoader.getLogger().warning(Reference.LOGGER_PREFIX + "Could not load BuildCraft Addon"); ModLoader.getLogger().fine(Helper.getLogMessage("Failed to initialize BuildCraft Addon"));
e.printStackTrace(System.err); e.printStackTrace(System.err);
} }
} }

View file

@ -1,6 +1,6 @@
package ee3.addons; package ee3.addons;
import ee3.lib.Reference; import ee3.lib.Helper;
import net.minecraft.src.Block; import net.minecraft.src.Block;
import net.minecraft.src.Item; import net.minecraft.src.Item;
import net.minecraft.src.ModLoader; import net.minecraft.src.ModLoader;
@ -12,12 +12,16 @@ import net.minecraft.src.ModLoader;
*/ */
public class ForestryAddon extends EEAddon { public class ForestryAddon extends EEAddon {
private static final String FORESTRY_ITEM_CLASS = "forestry.core.config.ForestryItem";
private static final String FORESTRY_BLOCK_CLASS = "forestry.api.core.ForestryBlock";
private static final int APATITE = 0; private static final int APATITE = 0;
private static final int COPPER = 1; private static final int COPPER = 1;
private static final int TIN = 2; private static final int TIN = 2;
public static Item beeComb = null; public static Item beeComb = null;
public static Item honeyDrop = null; public static Item honeyDrop = null;
public static Item apatite = null;
public static Item ingotCopper = null; public static Item ingotCopper = null;
public static Item ingotTin = null; public static Item ingotTin = null;
public static Item ingotBronze = null; public static Item ingotBronze = null;
@ -26,10 +30,21 @@ public class ForestryAddon extends EEAddon {
public static void init() { public static void init() {
try { try {
ModLoader.getLogger().fine(Reference.LOGGER_PREFIX + "Loaded Forestry Addon"); ModLoader.getLogger().finer(Helper.getLogMessage("Forestry detected; attempting to initialize Forestry addon"));
beeComb = getModItem("beeComb", FORESTRY_ITEM_CLASS);
honeyDrop = getModItem("honeyDrop", FORESTRY_ITEM_CLASS);
apatite = getModItem("apatite", FORESTRY_ITEM_CLASS);
ingotCopper = getModItem("ingotCopper", FORESTRY_ITEM_CLASS);
ingotTin = getModItem("ingotTin", FORESTRY_ITEM_CLASS);
ingotBronze = getModItem("ingotBronze", FORESTRY_ITEM_CLASS);
resources = getModBlock("resources", FORESTRY_BLOCK_CLASS);
ModLoader.getLogger().finer(Helper.getLogMessage("Forestry addon initialized"));
} }
catch (Exception e) { catch (Exception e) {
ModLoader.getLogger().warning(Reference.LOGGER_PREFIX + "Could not load Forestry Addon"); ModLoader.getLogger().fine(Helper.getLogMessage("Failed to initialize Forestry Addon"));
e.printStackTrace(System.err); e.printStackTrace(System.err);
} }
} }

View file

@ -1,5 +1,8 @@
package ee3.addons; package ee3.addons;
import net.minecraft.src.ModLoader;
import ee3.lib.Helper;
/** /**
* TODO Class Description * TODO Class Description
* @author pahimar * @author pahimar
@ -7,4 +10,15 @@ package ee3.addons;
*/ */
public class IndustrialCraftAddon { public class IndustrialCraftAddon {
public static void init() {
try {
ModLoader.getLogger().finer(Helper.getLogMessage("IndustrialCraft2 detected; attempting to initialize IndustrialCraft2 addon"));
ModLoader.getLogger().finer(Helper.getLogMessage("IndustrialCraft2 addon initialized"));
}
catch (Exception e) {
ModLoader.getLogger().fine(Helper.getLogMessage("Failed to initialize IndustrialCraft2 addon"));
e.printStackTrace(System.err);
}
}
} }

View file

@ -1,5 +1,8 @@
package ee3.addons; package ee3.addons;
import net.minecraft.src.ModLoader;
import ee3.lib.Helper;
/** /**
* TODO Class Description * TODO Class Description
* @author pahimar * @author pahimar
@ -7,4 +10,15 @@ package ee3.addons;
*/ */
public class RedPowerAddon { public class RedPowerAddon {
public static void init() {
try {
ModLoader.getLogger().finer(Helper.getLogMessage("RedPower2 detected; attempting to initialize RedPower2 addon"));
ModLoader.getLogger().finer(Helper.getLogMessage("RedPower2 addon initialized"));
}
catch (Exception e) {
ModLoader.getLogger().fine(Helper.getLogMessage("Failed to initialize RedPower2 addon"));
e.printStackTrace(System.err);
}
}
} }

View file

@ -2,24 +2,45 @@ package ee3.core;
import java.util.EnumSet; import java.util.EnumSet;
import net.minecraft.src.BaseMod;
import net.minecraft.src.ModLoader;
import cpw.mods.fml.common.ITickHandler; import cpw.mods.fml.common.ITickHandler;
import cpw.mods.fml.common.TickType; import cpw.mods.fml.common.TickType;
import ee3.addons.*;
import ee3.lib.Helper;
import ee3.lib.Reference; import ee3.lib.Reference;
public class TickHandler implements ITickHandler { public class TickHandler implements ITickHandler {
private static boolean addonsInitialized = false;
@Override @Override
public void tickStart(EnumSet<TickType> type, Object... tickData) { } public void tickStart(EnumSet<TickType> type, Object... tickData) {
for (TickType tickType : type) {
// WORLDLOAD ticks only happen once, so we'll use it to finish initialising things
if (tickType == TickType.WORLDLOAD) {
// Initialise
if (!addonsInitialized) {
addonsInitialized = true;
Helper.initAddons();
}
}
}
}
@Override @Override
public void tickEnd(EnumSet<TickType> type, Object... tickData) { public void tickEnd(EnumSet<TickType> type, Object... tickData) {
// TODO This is where all our tick related code goes :) for (TickType tickType : type) {
if (tickType == TickType.GAME) {
}
}
} }
@Override @Override
public EnumSet<TickType> ticks() { public EnumSet<TickType> ticks() {
return EnumSet.of(TickType.GAME); return EnumSet.of(TickType.GAME, TickType.WORLDLOAD);
} }
@Override @Override

View file

@ -1,10 +1,18 @@
package ee3.lib; package ee3.lib;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.logging.Level;
import ee3.addons.BuildCraftAddon;
import ee3.addons.ForestryAddon;
import ee3.addons.IndustrialCraftAddon;
import ee3.addons.RedPowerAddon;
import net.minecraft.src.BaseMod;
import net.minecraft.src.Block; import net.minecraft.src.Block;
import net.minecraft.src.Item; import net.minecraft.src.Item;
import net.minecraft.src.ItemStack; import net.minecraft.src.ItemStack;
import net.minecraft.src.ModLoader;
public class Helper { public class Helper {
@ -26,4 +34,40 @@ public class Helper {
return list.toArray(); return list.toArray();
} }
public static String getLogMessage(String logMessage) {
return Reference.LOGGER_PREFIX + logMessage;
}
public static void initAddons() {
ModLoader.getLogger().finer(getLogMessage("Checking for addons needing initializing"));
boolean addonsFound = false;
for (BaseMod mod : ModLoader.getLoadedMods()) {
if (mod.toString().contains("mod_BuildCraftEnergy")) {
BuildCraftAddon.init();
addonsFound = true;
}
else if (mod.toString().contains("mod_RedPowerCore")) {
RedPowerAddon.init();
addonsFound = true;
}
else if (mod.toString().contains("mod_RedPowerWorld")) {
RedPowerAddon.init();
addonsFound = true;
}
else if (mod.toString().contains("mod_Forestry")) {
ForestryAddon.init();
addonsFound = true;
}
else if (mod.toString().contains("mod_IC2")) {
IndustrialCraftAddon.init();
addonsFound = true;
}
}
if (addonsFound)
ModLoader.getLogger().finer(getLogMessage("Done initializing addons"));
else
ModLoader.getLogger().finer(getLogMessage("No addons for loaded mods found"));
}
} }

View file

@ -11,7 +11,7 @@ public class Reference {
public static final String MOD_NAME = "Equivalent Exchange 3"; public static final String MOD_NAME = "Equivalent Exchange 3";
public static final String CHANNEL_NAME = "EE3"; public static final String CHANNEL_NAME = "EE3";
public static final String LOGGER_PREFIX = "[" + CHANNEL_NAME + "]: "; public static final String LOGGER_PREFIX = "[" + MOD_NAME + "] ";
public static final String CONFIG_FILE = "EE3.cfg"; public static final String CONFIG_FILE = "EE3.cfg";
public static final String CONFIG_DIR = "config/ee3/"; public static final String CONFIG_DIR = "config/ee3/";
@ -21,4 +21,5 @@ public class Reference {
public static final String ARMOR_SHEET_LOCATION = "/ee3/art/armor/"; public static final String ARMOR_SHEET_LOCATION = "/ee3/art/armor/";
public static final String SOUND_RESOURCE_LOCATION = "ee3/sound/"; public static final String SOUND_RESOURCE_LOCATION = "ee3/sound/";
public static final String SOUND_PREFIX = "ee3.sound."; public static final String SOUND_PREFIX = "ee3.sound.";
} }

View file

@ -24,7 +24,7 @@ public class Version {
public static final int REQ_FORGE_MAJOR = 3; public static final int REQ_FORGE_MAJOR = 3;
public static final int REQ_FORGE_MINOR = 3; public static final int REQ_FORGE_MINOR = 3;
public static final int REQ_FORGE_REVISION = 7; public static final int REQ_FORGE_REVISION = 8;
private static final String REMOTE_VERSION_FILE = "http://dl.dropbox.com/u/25591134/EE2/version.txt"; private static final String REMOTE_VERSION_FILE = "http://dl.dropbox.com/u/25591134/EE2/version.txt";