diff --git a/src/dark/core/DarkMain.java b/src/dark/core/DarkMain.java index 01063436..9beeaa70 100644 --- a/src/dark/core/DarkMain.java +++ b/src/dark/core/DarkMain.java @@ -57,38 +57,35 @@ public class DarkMain extends ModPrefab public static ModMetadata meta; /** Main config file */ - public static final Configuration CONFIGURATION = new Configuration(new File(Loader.instance().getConfigDir(), "Dark/General.cfg")); + public static final Configuration CONFIGURATION = new Configuration(new File(Loader.instance().getConfigDir(), "Dark/TheDarkMachine.cfg")); private static final String[] LANGUAGES_SUPPORTED = new String[] { "en_US" }; /** Can over pressure of devices do area damage */ public static boolean overPressureDamage; - /** Main mod output to console */ - public static final Logger LOGGER = Logger.getLogger("DarkCore"); public static BlockMulti blockMulti; - public static DarkMain instance; + private static DarkMain instance; public static CoreRecipeLoader recipeLoader; - public DarkMain() + public static DarkMain getInstance() { - super("dark"); + if(instance == null) + { + instance = new DarkMain(); + } + return instance; } - @EventHandler @Override public void preInit(FMLPreInitializationEvent event) { - super.preInit(event); - LOGGER.setParent(FMLLog.getLogger()); - LOGGER.info("Initializing..."); - recipeLoader = new CoreRecipeLoader(); instance = this; + super.preInit(event); MinecraftForge.EVENT_BUS.register(this); MinecraftForge.EVENT_BUS.register(new FluidRestrictionHandler()); proxy.preInit(); - } @EventHandler @@ -133,10 +130,14 @@ public class DarkMain extends ModPrefab @Override public void loadConfig() { + if (recipeLoader == null) + { + recipeLoader = new CoreRecipeLoader(); + } /* CONFIGS */ CONFIGURATION.load(); /* BLOCKS */ - DarkMain.blockMulti = new BlockMulti(DarkMain.CONFIGURATION.getBlock("RestrictedPipes", BLOCK_ID_PREFIX++).getInt()); + DarkMain.blockMulti = new BlockMulti(DarkMain.CONFIGURATION.getBlock("MultiBlock", BLOCK_ID_PREFIX++).getInt()); if (CONFIGURATION.get("general", "LoadOre", true).getBoolean(true)) { recipeLoader.blockOre = new BlockOre(BLOCK_ID_PREFIX++, CONFIGURATION); @@ -181,5 +182,11 @@ public class DarkMain extends ModPrefab { SaveManager.save(true); } + @Override + public String getDomain() + { + // TODO Auto-generated method stub + return "dark"; + } } diff --git a/src/dark/core/ModPrefab.java b/src/dark/core/ModPrefab.java index ae7ba3bd..067aaeb2 100644 --- a/src/dark/core/ModPrefab.java +++ b/src/dark/core/ModPrefab.java @@ -2,15 +2,17 @@ package dark.core; import org.modstats.Modstats; +import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.Mod.EventHandler; 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.relauncher.Side; public abstract class ModPrefab { - public String DOMAIN = "dark"; + public String DOMAIN = this.getDomain(); public String PREFIX = DOMAIN + ":"; public String DIRECTORY_NO_SLASH = "assets/" + DOMAIN + "/"; @@ -28,10 +30,7 @@ public abstract class ModPrefab public static int BLOCK_ID_PREFIX = 3100; public static int ITEM_ID_PREFIX = 13200; - public ModPrefab(String domain) - { - DOMAIN = domain; - } + public abstract String getDomain(); @EventHandler public void preInit(FMLPreInitializationEvent event) @@ -53,6 +52,12 @@ public abstract class ModPrefab } + public static void printSidedData(String data) + { + System.out.print(FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT ? "[C]" : "[S]"); + System.out.println(" " + data); + } + public abstract void loadConfig(); public abstract void loadModMeta(); diff --git a/src/dark/core/RecipeLoader.java b/src/dark/core/RecipeLoader.java index c0fa9370..cef32041 100644 --- a/src/dark/core/RecipeLoader.java +++ b/src/dark/core/RecipeLoader.java @@ -1,13 +1,13 @@ package dark.core; -import cpw.mods.fml.common.registry.GameRegistry; -import dark.core.helpers.Pair; -import dark.core.helpers.Triple; import net.minecraft.block.Block; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.oredict.OreDictionary; import net.minecraftforge.oredict.ShapedOreRecipe; +import cpw.mods.fml.common.registry.GameRegistry; +import dark.core.helpers.Pair; +import dark.core.helpers.Triple; public abstract class RecipeLoader { @@ -51,6 +51,15 @@ public abstract class RecipeLoader } } + public ItemStack setStackSize(ItemStack stack, int amount) + { + if (stack != null) + { + return new ItemStack(stack.itemID, amount, stack.getItemDamage()); + } + return stack; + } + public static class RecipeGrid { Object A, B, C, D, E, F, G, H, I; @@ -58,10 +67,15 @@ public abstract class RecipeLoader int width = 3; int hight = 3; - public RecipeGrid(int width, int hight) + public RecipeGrid(Object stack) { - this.width = Math.max(Math.min(width, 3), 1); - this.hight = Math.max(Math.min(hight, 3), 1);; + out = stack; + } + + public RecipeGrid(Object stack, int w, int h) + { + this(stack); + this.setSize(w, h); } /** 3x3 Crafting grid. Each Triple is a row. Input for the triples should be any of { Item, @@ -70,8 +84,9 @@ public abstract class RecipeLoader * @param one - top row * @param two - middle row * @param three - bottom row */ - public RecipeGrid(Triple one, Triple two, Triple three) + public RecipeGrid(Object stack, Triple one, Triple two, Triple three) { + this(stack); this.setRowOne(one.getA(), one.getB(), one.getC()); this.setRowTwo(two.getA(), two.getB(), two.getC()); this.setRowThree(three.getA(), three.getB(), three.getC()); @@ -82,19 +97,34 @@ public abstract class RecipeLoader * * @param one - top row * @param two - middle row */ - public RecipeGrid(Pair one, Pair two) + public RecipeGrid(Object stack, Pair one, Pair two) { + this(stack); this.setRowOne(one.getKey(), one.getValue()); this.setRowTwo(two.getKey(), two.getValue()); this.hight = 2; this.width = 2; } + /** Sets the grid size */ + public RecipeGrid setSize(int w, int h) + { + this.width = Math.max(Math.min(w, 3), 1); + this.hight = Math.max(Math.min(h, 3), 1); + return this; + } + + /** Sets the grid recipe output */ + public RecipeGrid setOutput(Object stack) + { + out = stack; + return this; + } + public RecipeGrid setRowOne(Object... objects) { if (objects != null) { - this.A = objects[0]; if (objects.length > 1) { @@ -112,7 +142,6 @@ public abstract class RecipeLoader { if (objects != null) { - this.D = objects[0]; if (objects.length > 1) { @@ -130,7 +159,6 @@ public abstract class RecipeLoader { if (objects != null) { - this.G = objects[0]; if (objects.length > 1) { @@ -144,27 +172,13 @@ public abstract class RecipeLoader return this; } - public void norm() + public String getOreName(ItemStack stack) { - Object[] list = new Object[] { A, B, C, D, E, F, G, H, I }; - for (int i = 0; i < list.length; i++) + if (stack != null) { - if (list[i] == null || (!(list[i] instanceof Item) && !(list[i] instanceof Block) && !(list[i] instanceof ItemStack) && !(list[i] instanceof String))) - { - list[i] = ""; - } - else - { - if (list[i] instanceof ItemStack) - { - String name = OreDictionary.getOreName(OreDictionary.getOreID((ItemStack) list[i])); - if (name != null) - { - list[i] = name; - } - } - } + return OreDictionary.getOreName(OreDictionary.getOreID(stack)); } + return null; } public void RegisterRecipe() @@ -180,43 +194,96 @@ public abstract class RecipeLoader { ShapedOreRecipe re = null; Object[] recipe = null; + String AA = "A"; + String BB = "B"; + String CC = "C"; + String DD = "D"; + String EE = "E"; + String FF = "F"; + String GG = "G"; + String HH = "H"; + String II = "I"; + if (A == null) + { + AA = " "; + A = ""; + } + if (B == null) + { + BB = " "; + B = ""; + } + if (C == null) + { + CC = " "; + C = ""; + } + if (D == null) + { + DD = " "; + D = ""; + } + if (E == null) + { + EE = " "; + E = ""; + } + if (F == null) + { + FF = " "; + F = ""; + } + if (G == null) + { + GG = " "; + G = ""; + } + if (H == null) + { + HH = " "; + H = ""; + } + if (I == null) + { + II = " "; + I = ""; + } - this.norm(); if (width == 3 && hight == 3) { - recipe = new Object[] { "ABC", "DEF", "GHI", 'A', A, 'B', B, 'C', C, 'D', D, 'E', E, 'F', F, 'G', G, 'H', H, 'I', I }; + recipe = new Object[] { AA + BB + CC, DD + EE + FF, GG + HH + II, 'A', A, 'B', B, 'C', C, 'D', D, 'E', E, 'F', F, 'G', G, 'H', H, 'I', I }; } else if (width == 2 && hight == 3) { - recipe = new Object[] { "AB", "DE", "GH", 'A', A, 'B', B, 'D', D, 'E', E, 'G', G, 'H', H }; + recipe = new Object[] { AA + BB, DD + EE, GG + HH, 'A', A, 'B', B, 'D', D, 'E', E, 'G', G, 'H', H }; } else if (width == 3 && hight == 2) { - recipe = new Object[] { "ABC", "DEF", 'A', A, 'B', B, 'C', C, 'D', D, 'E', E, 'F', F }; + recipe = new Object[] { AA + BB + CC, DD + EE + FF, 'A', A, 'B', B, 'C', C, 'D', D, 'E', E, 'F', F }; } else if (width == 1 && hight == 3) { - recipe = new Object[] { "A", "D", "G", 'A', A, 'D', D, 'G', G }; + recipe = new Object[] { AA, DD, GG, 'A', A, 'D', D, 'G', G }; } else if (width == 3 && hight == 1) { - recipe = new Object[] { "ABC", 'A', A, 'B', B, 'C', C }; + recipe = new Object[] { AA + BB + CC, 'A', A, 'B', B, 'C', C }; } else if (width == 2 && hight == 2) { - recipe = new Object[] { "AB", "DE", 'A', A, 'B', B, 'D', D, 'E', E }; + recipe = new Object[] { AA + BB, DD + EE, 'A', A, 'B', B, 'D', D, 'E', E }; } else if (width == 1 && hight == 2) { - recipe = new Object[] { "A", "D", 'A', A, 'D', D, }; + recipe = new Object[] { AA, DD, 'A', A, 'D', D, }; } else if (width == 2 && hight == 1) { - recipe = new Object[] { "AB", 'A', A, 'B', B, }; + recipe = new Object[] { AA + BB, 'A', A, 'B', B, }; } else if (width == 1 && hight == 1) { - recipe = new Object[] { "A", 'A', A }; + recipe = new Object[] { AA, 'A', A }; } if (recipe != null) { diff --git a/src/dark/core/blocks/BlockMachine.java b/src/dark/core/blocks/BlockMachine.java index f67a073a..ab8376b5 100644 --- a/src/dark/core/blocks/BlockMachine.java +++ b/src/dark/core/blocks/BlockMachine.java @@ -17,7 +17,7 @@ import dark.core.DarkMain; /** Basic TileEntity Container class designed to be used by generic machines. It is suggested that * each mod using this create there own basic block extending this to reduce need to input config * file each time - * + * * @author Rseifert */ public abstract class BlockMachine extends BlockAdvanced implements ITileEntityProvider { @@ -37,7 +37,7 @@ public abstract class BlockMachine extends BlockAdvanced implements ITileEntityP @Override public void registerIcons(IconRegister iconReg) { - this.blockIcon = iconReg.registerIcon(DarkMain.instance.PREFIX + "machine"); + this.blockIcon = iconReg.registerIcon(DarkMain.getInstance().PREFIX + "machine"); } @Override diff --git a/src/dark/core/blocks/BlockOre.java b/src/dark/core/blocks/BlockOre.java index d59e13f2..313dbca8 100644 --- a/src/dark/core/blocks/BlockOre.java +++ b/src/dark/core/blocks/BlockOre.java @@ -21,7 +21,7 @@ public class BlockOre extends Block { super(config.getBlock("Ore", par1).getInt(), Material.rock); this.setCreativeTab(CreativeTabs.tabBlock); - this.setUnlocalizedName(DarkMain.instance.PREFIX + "Ore"); + this.setUnlocalizedName(DarkMain.getInstance().PREFIX + "Ore"); } public static void regiserOreNames() @@ -54,7 +54,7 @@ public class BlockOre extends Block { if (EnumMeterials.values()[i].doWorldGen) { - this.icons[i] = par1IconRegister.registerIcon(DarkMain.instance.PREFIX + EnumMeterials.values()[i].name + "Ore"); + this.icons[i] = par1IconRegister.registerIcon(DarkMain.getInstance().PREFIX + EnumMeterials.values()[i].name + "Ore"); } } } diff --git a/src/dark/core/items/EnumMeterials.java b/src/dark/core/items/EnumMeterials.java index c077f818..888ca82a 100644 --- a/src/dark/core/items/EnumMeterials.java +++ b/src/dark/core/items/EnumMeterials.java @@ -75,7 +75,7 @@ public enum EnumMeterials if (this.doWorldGen) { ItemStack stack = new ItemStack(DarkMain.recipeLoader.blockOre, 1, this.ordinal()); - return (OreGenReplaceStone) new OreGenReplaceStone(this.name, this.name + "Ore", stack, this.maxY, this.ammount, this.branch).enable(DarkMain.instance.CONFIGURATION); + return (OreGenReplaceStone) new OreGenReplaceStone(this.name, this.name + "Ore", stack, this.maxY, this.ammount, this.branch).enable(DarkMain.getInstance().CONFIGURATION); } return null; } diff --git a/src/dark/core/items/ItemBasic.java b/src/dark/core/items/ItemBasic.java index 13d6b870..7a7ab13f 100644 --- a/src/dark/core/items/ItemBasic.java +++ b/src/dark/core/items/ItemBasic.java @@ -12,7 +12,7 @@ public class ItemBasic extends Item public ItemBasic(int itemID, String name, Configuration config) { super(config.getItem(name, itemID).getInt()); - this.setUnlocalizedName(DarkMain.instance.PREFIX + name); + this.setUnlocalizedName(DarkMain.getInstance().PREFIX + name); } } diff --git a/src/dark/core/items/ItemBattery.java b/src/dark/core/items/ItemBattery.java index 69b03e54..853d9aa9 100644 --- a/src/dark/core/items/ItemBattery.java +++ b/src/dark/core/items/ItemBattery.java @@ -13,7 +13,7 @@ public class ItemBattery extends ItemElectric public ItemBattery(String name, int id) { super(DarkMain.CONFIGURATION.getItem(name, id).getInt(id)); - this.setUnlocalizedName(DarkMain.instance.PREFIX + name); + this.setUnlocalizedName(DarkMain.getInstance().PREFIX + name); this.setCreativeTab(CreativeTabs.tabRedstone); } diff --git a/src/dark/core/items/ItemOre.java b/src/dark/core/items/ItemOre.java index a4e2579b..756adc8e 100644 --- a/src/dark/core/items/ItemOre.java +++ b/src/dark/core/items/ItemOre.java @@ -23,7 +23,7 @@ public class ItemOre extends ItemBlock @Override public String getUnlocalizedName(ItemStack par1ItemStack) { - return "tile." + DarkMain.instance.PREFIX + EnumMeterials.values()[par1ItemStack.getItemDamage()].name + "Ore"; + return "tile." + DarkMain.getInstance().PREFIX + EnumMeterials.values()[par1ItemStack.getItemDamage()].name + "Ore"; } } diff --git a/src/dark/core/items/ItemOreDirv.java b/src/dark/core/items/ItemOreDirv.java index 15891e1b..f0213a6a 100644 --- a/src/dark/core/items/ItemOreDirv.java +++ b/src/dark/core/items/ItemOreDirv.java @@ -12,7 +12,7 @@ import cpw.mods.fml.relauncher.SideOnly; import dark.core.DarkMain; /** A series of items that are derived from a basic ore block - * + * * @author DarkGuardsman */ public class ItemOreDirv extends ItemBasic { @@ -34,7 +34,7 @@ public class ItemOreDirv extends ItemBasic if (itemStack != null) { int meta = itemStack.getItemDamage(); - return "item." + DarkMain.instance.PREFIX + EnumOreParts.getFullName(meta); + return "item." + DarkMain.getInstance().PREFIX + EnumOreParts.getFullName(meta); } else { @@ -58,7 +58,7 @@ public class ItemOreDirv extends ItemBasic int meta = EnumOreParts.values()[j].meta; for (int i = 0; i < EnumMeterials.values().length; i++) { - ICONS[i + meta] = iconRegister.registerIcon(DarkMain.instance.PREFIX + EnumMeterials.values()[i].name + suf); + ICONS[i + meta] = iconRegister.registerIcon(DarkMain.getInstance().PREFIX + EnumMeterials.values()[i].name + suf); } } } diff --git a/src/dark/core/tile/network/NetworkTileEntities.java b/src/dark/core/tile/network/NetworkTileEntities.java index abff6bcb..5efcb1b5 100644 --- a/src/dark/core/tile/network/NetworkTileEntities.java +++ b/src/dark/core/tile/network/NetworkTileEntities.java @@ -27,13 +27,13 @@ public abstract class NetworkTileEntities /** Creates a new instance of this network to be used to merge or split networks while still * maintaining each class that extends the base network class - * + * * @return - new network instance using the current networks properties */ public abstract NetworkTileEntities newInstance(); /** Adds a TileEntity to the network. extends this to catch non-network parts and add them to * other tile lists - * + * * @param tileEntity - tileEntity instance * @param member - add to network member list * @return */ @@ -129,16 +129,14 @@ public abstract class NetworkTileEntities /** Combines two networks together into one. Calls to preMerge and doMerge instead of doing the * merge process itself - * + * * @param network - * @param part */ - public void merge(NetworkTileEntities network, INetworkPart part) + * @param mergePoint */ + public void merge(NetworkTileEntities network, INetworkPart mergePoint) { if (network != null && network != this && network.getClass().equals(this.getClass())) { - this.refresh(); - network.refresh(); - if (this.preMergeProcessing(network, part)) + if (this.preMergeProcessing(network, mergePoint)) { this.mergeDo(network); } @@ -147,17 +145,17 @@ public abstract class NetworkTileEntities /** Processing that needs too be done before the network merges. Use this to do final network * merge calculations and to cause network merge failure - * + * * @param network the network that is to merge with this one * @param part the part at which started the network merge. Use this to cause damage if two * networks merge with real world style failures - * + * * @return false if the merge needs to be canceled. - * + * * Cases in which the network should fail to merge are were the two networks merge with error. * Or, in the case of pipes the two networks merge and the merge point was destroyed by * combination of liquids. - * + * * Ex Lava and water */ public boolean preMergeProcessing(NetworkTileEntities network, INetworkPart part) { @@ -171,7 +169,7 @@ public abstract class NetworkTileEntities newNetwork.getNetworkMemebers().addAll(this.getNetworkMemebers()); newNetwork.getNetworkMemebers().addAll(network.getNetworkMemebers()); - newNetwork.cleanUpMembers(); + newNetwork.refresh(); } /** Called when a peace of the network is remove from the network. Will split the network if it @@ -249,7 +247,7 @@ public abstract class NetworkTileEntities } /** invalidates/remove a tile from the networks that surround and connect to it - * + * * @param tileEntity - tile */ public static void invalidate(TileEntity tileEntity) {