PageRenderTime 146ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/src/main/java/icbm/core/ICBMCore.java

https://bitbucket.org/darkguardsman/icbm
Java | 255 lines | 178 code | 51 blank | 26 comment | 9 complexity | c61adff86f7b3df21cc857fa289b58a4 MD5 | raw file
  1. package icbm.core;
  2. import icbm.Reference;
  3. import icbm.Settings;
  4. import icbm.TabICBM;
  5. import icbm.core.blocks.BlockCamouflage;
  6. import icbm.core.blocks.BlockConcrete;
  7. import icbm.core.blocks.BlockGlassButton;
  8. import icbm.core.blocks.BlockGlassPressurePlate;
  9. import icbm.core.blocks.BlockProximityDetector;
  10. import icbm.core.blocks.BlockReinforcedGlass;
  11. import icbm.core.blocks.BlockReinforcedRail;
  12. import icbm.core.blocks.BlockSpikes;
  13. import icbm.core.blocks.BlockSulfurOre;
  14. import icbm.core.blocks.OreGeneratorICBM;
  15. import icbm.core.blocks.TileProximityDetector;
  16. import icbm.core.compat.Waila;
  17. import icbm.core.entity.EntityFlyingBlock;
  18. import icbm.core.entity.EntityFragments;
  19. import icbm.core.items.ItemAntidote;
  20. import icbm.core.items.ItemComputer;
  21. import icbm.core.items.ItemPoisonPowder;
  22. import icbm.core.items.ItemSignalDisrupter;
  23. import icbm.core.items.ItemSulfurDust;
  24. import icbm.core.items.ItemTracker;
  25. import java.util.ArrayList;
  26. import java.util.logging.Logger;
  27. import net.minecraft.block.Block;
  28. import net.minecraft.item.Item;
  29. import net.minecraft.item.ItemStack;
  30. import net.minecraftforge.common.Configuration;
  31. import net.minecraftforge.common.MinecraftForge;
  32. import net.minecraftforge.oredict.OreDictionary;
  33. import net.minecraftforge.oredict.ShapedOreRecipe;
  34. import net.minecraftforge.oredict.ShapelessOreRecipe;
  35. import org.modstats.ModstatInfo;
  36. import org.modstats.Modstats;
  37. import resonant.core.ResonantEngine;
  38. import resonant.lib.config.ConfigHandler;
  39. import resonant.lib.content.ContentRegistry;
  40. import resonant.lib.modproxy.ProxyHandler;
  41. import resonant.lib.network.PacketHandler;
  42. import resonant.lib.network.PacketPlayerItem;
  43. import resonant.lib.network.PacketTile;
  44. import resonant.lib.prefab.item.ItemBlockMetadata;
  45. import resonant.lib.prefab.ore.OreGenBase;
  46. import resonant.lib.prefab.ore.OreGenerator;
  47. import resonant.lib.recipe.UniversalRecipe;
  48. import resonant.lib.utility.LanguageUtility;
  49. import cpw.mods.fml.common.Loader;
  50. import cpw.mods.fml.common.Mod;
  51. import cpw.mods.fml.common.Mod.EventHandler;
  52. import cpw.mods.fml.common.Mod.Instance;
  53. import cpw.mods.fml.common.Mod.Metadata;
  54. import cpw.mods.fml.common.ModMetadata;
  55. import cpw.mods.fml.common.SidedProxy;
  56. import cpw.mods.fml.common.event.FMLInitializationEvent;
  57. import cpw.mods.fml.common.event.FMLPostInitializationEvent;
  58. import cpw.mods.fml.common.event.FMLPreInitializationEvent;
  59. import cpw.mods.fml.common.network.NetworkMod;
  60. import cpw.mods.fml.common.network.NetworkRegistry;
  61. import cpw.mods.fml.common.registry.EntityRegistry;
  62. import cpw.mods.fml.common.registry.GameRegistry;
  63. /** Main class for ICBM core to run on. The core will need to be initialized by each ICBM module.
  64. *
  65. * @author Calclavia */
  66. @Mod(modid = Reference.NAME, name = Reference.NAME, version = Reference.VERSION, dependencies = "after:AtomicScience;required-after:ResonantEngine")
  67. @NetworkMod(channels = Reference.CHANNEL, clientSideRequired = true, serverSideRequired = false, packetHandler = PacketHandler.class)
  68. @ModstatInfo(prefix = "icbm", name = Reference.NAME, version = Reference.VERSION)
  69. public final class ICBMCore
  70. {
  71. @Instance(Reference.NAME)
  72. public static ICBMCore INSTANCE;
  73. @Metadata(Reference.NAME)
  74. public static ModMetadata metadata;
  75. @SidedProxy(clientSide = "icbm.core.ClientProxy", serverSide = "icbm.core.CommonProxy")
  76. public static CommonProxy proxy;
  77. // Blocks
  78. public static Block blockGlassPlate, blockGlassButton, blockProximityDetector, blockSpikes, blockCamo, blockConcrete, blockReinforcedGlass;
  79. // Items
  80. public static Item itemAntidote;
  81. public static Item itemSignalDisrupter;
  82. public static Item itemTracker;
  83. public static Item itemHackingComputer;
  84. public static Block blockSulfurOre, blockRadioactive, blockCombatRail, blockBox;
  85. public static Item itemSulfurDust, itemPoisonPowder;
  86. public static OreGenBase sulfurGenerator;
  87. public static final Logger LOGGER = Logger.getLogger(Reference.NAME);
  88. public static final PacketTile PACKET_TILE = new PacketTile(Reference.CHANNEL);
  89. public static final PacketPlayerItem PACKET_ITEM = new PacketPlayerItem(Reference.CHANNEL);
  90. public static final ContentRegistry contentRegistry = new ContentRegistry(Settings.CONFIGURATION, Settings.idManager, Reference.NAME).setPrefix(Reference.PREFIX).setTab(TabICBM.INSTANCE);
  91. private ProxyHandler modproxies = new ProxyHandler();
  92. @EventHandler
  93. public void preInit(FMLPreInitializationEvent event)
  94. {
  95. NetworkRegistry.instance().registerGuiHandler(this, proxy);
  96. Modstats.instance().getReporter().registerMod(INSTANCE);
  97. MinecraftForge.EVENT_BUS.register(INSTANCE);
  98. // MODULES TO LOAD INTO MOD PHASE
  99. modproxies.applyModule(Waila.class, true);
  100. LOGGER.fine("Loaded " + LanguageUtility.loadLanguages(icbm.Reference.LANGUAGE_PATH, icbm.Reference.LANGUAGES) + " languages.");
  101. Settings.CONFIGURATION.load();
  102. ResonantEngine.blockMulti.setTextureName(Reference.PREFIX + "machine");
  103. // Blocks
  104. blockSulfurOre = contentRegistry.createBlock(BlockSulfurOre.class);
  105. blockGlassPlate = contentRegistry.createBlock(BlockGlassPressurePlate.class);
  106. blockGlassButton = contentRegistry.createBlock(BlockGlassButton.class);
  107. blockProximityDetector = contentRegistry.createTile(BlockProximityDetector.class, TileProximityDetector.class);
  108. blockSpikes = contentRegistry.createBlock(BlockSpikes.class, ItemBlockMetadata.class);
  109. blockCamo = contentRegistry.createBlock(BlockCamouflage.class);
  110. blockConcrete = contentRegistry.createBlock(BlockConcrete.class, ItemBlockMetadata.class);
  111. blockReinforcedGlass = contentRegistry.createBlock(BlockReinforcedGlass.class, ItemBlockMetadata.class);
  112. blockCombatRail = contentRegistry.createBlock(BlockReinforcedRail.class);
  113. //blockBox = contentRegistry.newBlock(TileBox.class); TODO Enable, disabled as to allow to release a stable ICBM for 1.6
  114. // ITEMS
  115. itemPoisonPowder = contentRegistry.createItem(ItemPoisonPowder.class);
  116. itemSulfurDust = contentRegistry.createItem(ItemSulfurDust.class);
  117. itemAntidote = contentRegistry.createItem(ItemAntidote.class);
  118. itemSignalDisrupter = contentRegistry.createItem(ItemSignalDisrupter.class);
  119. itemTracker = contentRegistry.createItem(ItemTracker.class);
  120. itemHackingComputer = contentRegistry.createItem(ItemComputer.class);
  121. sulfurGenerator = new OreGeneratorICBM("Sulfur Ore", "oreSulfur", new ItemStack(blockSulfurOre), 0, 40, 20, 4).enable(Settings.CONFIGURATION);
  122. /** Check for existence of radioactive block. If it does not exist, then create it. */
  123. if (OreDictionary.getOres("blockRadioactive").size() > 0)
  124. {
  125. blockRadioactive = Block.blocksList[OreDictionary.getOres("blockRadioactive").get(0).itemID];
  126. LOGGER.fine("Detected radioative block from another mod, utilizing it.");
  127. }
  128. else
  129. {
  130. blockRadioactive = Block.mycelium;
  131. }
  132. /** Decrease Obsidian Resistance */
  133. Block.obsidian.setResistance(Settings.CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Reduce Obsidian Resistance", 45).getInt(45));
  134. LOGGER.fine("Changed obsidian explosive resistance to: " + Block.obsidian.getExplosionResistance(null));
  135. OreDictionary.registerOre("dustSulfur", new ItemStack(itemSulfurDust, 1, 0));
  136. OreDictionary.registerOre("dustSaltpeter", new ItemStack(itemSulfurDust, 1, 1));
  137. OreGenerator.addOre(sulfurGenerator);
  138. if (!Loader.isModLoaded("ICBM|Sentry") && !Loader.isModLoaded("ICBM|Explosion"))
  139. TabICBM.itemStack = new ItemStack(blockProximityDetector);
  140. proxy.preInit();
  141. modproxies.preInit();
  142. }
  143. @EventHandler
  144. public void init(FMLInitializationEvent event)
  145. {
  146. Settings.setModMetadata(Reference.NAME, Reference.NAME, metadata);
  147. EntityRegistry.registerGlobalEntityID(EntityFlyingBlock.class, "ICBMGravityBlock", EntityRegistry.findGlobalUniqueEntityId());
  148. EntityRegistry.registerGlobalEntityID(EntityFragments.class, "ICBMFragment", EntityRegistry.findGlobalUniqueEntityId());
  149. EntityRegistry.registerModEntity(EntityFlyingBlock.class, "ICBMGravityBlock", 0, this, 50, 15, true);
  150. EntityRegistry.registerModEntity(EntityFragments.class, "ICBMFragment", 1, this, 40, 8, true);
  151. proxy.init();
  152. modproxies.init();
  153. }
  154. @EventHandler
  155. public void postInit(FMLPostInitializationEvent event)
  156. {
  157. ConfigHandler.configure(Settings.CONFIGURATION, Settings.DOMAIN);
  158. /** LOAD. */
  159. ArrayList dustCharcoal = OreDictionary.getOres("dustCharcoal");
  160. ArrayList dustCoal = OreDictionary.getOres("dustCoal");
  161. // Sulfur
  162. GameRegistry.addSmelting(blockSulfurOre.blockID, new ItemStack(itemSulfurDust, 4), 0.8f);
  163. GameRegistry.addSmelting(Item.reed.itemID, new ItemStack(itemSulfurDust, 4, 1), 0f);
  164. GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(Item.gunpowder, 2), new Object[] { "dustSulfur", "dustSaltpeter", Item.coal }));
  165. GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(Item.gunpowder, 2), new Object[] { "dustSulfur", "dustSaltpeter", new ItemStack(Item.coal, 1, 1) }));
  166. if (dustCharcoal != null && dustCharcoal.size() > 0)
  167. GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(Item.gunpowder, 2), new Object[] { "dustSulfur", "dustSaltpeter", "dustCharcoal" }));
  168. if (dustCoal != null && dustCoal.size() > 0)
  169. GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(Item.gunpowder, 2), new Object[] { "dustSulfur", "dustSaltpeter", "dustCoal" }));
  170. GameRegistry.addRecipe(new ShapedOreRecipe(Block.tnt, new Object[] { "@@@", "@R@", "@@@", '@', Item.gunpowder, 'R', Item.redstone }));
  171. // Poison Powder
  172. GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(itemPoisonPowder, 3), new Object[] { Item.spiderEye, Item.rottenFlesh }));
  173. /** Add all Recipes */
  174. // Spikes
  175. GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockSpikes, 6), new Object[] { "CCC", "BBB", 'C', Block.cactus, 'B', Item.ingotIron }));
  176. GameRegistry.addRecipe(new ItemStack(blockSpikes, 1, 1), new Object[] { "E", "S", 'E', itemPoisonPowder, 'S', blockSpikes });
  177. GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockSpikes, 1, 2), new Object[] { "E", "S", 'E', itemSulfurDust, 'S', blockSpikes }));
  178. // Camouflage
  179. GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockCamo, 12), new Object[] { "WGW", "G G", "WGW", 'G', Block.vine, 'W', Block.cloth }));
  180. // Tracker
  181. GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(itemTracker), new Object[] { " Z ", "SBS", "SCS", 'Z', Item.compass, 'C', UniversalRecipe.CIRCUIT_T1.get(), 'B', UniversalRecipe.BATTERY.get(), 'S', Item.ingotIron }));
  182. GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(itemTracker), new Object[] { " Z ", "SBS", "SCS", 'Z', Item.compass, 'C', UniversalRecipe.CIRCUIT_T1.get(), 'B', Item.enderPearl, 'S', Item.ingotIron }));
  183. // Glass Pressure Plate
  184. GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockGlassPlate, 1, 0), new Object[] { "##", '#', Block.glass }));
  185. // Glass Button
  186. GameRegistry.addRecipe(new ItemStack(blockGlassButton, 2), new Object[] { "G", "G", 'G', Block.glass });
  187. // Proximity Detector
  188. GameRegistry.addRecipe(new ShapedOreRecipe(blockProximityDetector, new Object[] { "SSS", "S?S", "SSS", 'S', Item.ingotIron, '?', itemTracker }));
  189. // Signal Disrupter
  190. GameRegistry.addRecipe(new ShapedOreRecipe(itemSignalDisrupter, new Object[] { "WWW", "SCS", "SSS", 'S', Item.ingotIron, 'C', UniversalRecipe.CIRCUIT_T1.get(), 'W', UniversalRecipe.WIRE.get() }));
  191. // Antidote
  192. GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(itemAntidote, 6), new Object[] { "@@@", "@@@", "@@@", '@', Item.pumpkinSeeds }));
  193. GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(itemAntidote), new Object[] { "@@@", "@@@", "@@@", '@', Item.seeds }));
  194. // Concrete
  195. GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockConcrete, 8, 0), new Object[] { "SGS", "GWG", "SGS", 'G', Block.gravel, 'S', Block.sand, 'W', Item.bucketWater }));
  196. GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockConcrete, 8, 1), new Object[] { "COC", "OCO", "COC", 'C', new ItemStack(blockConcrete, 1, 0), 'O', Block.obsidian }));
  197. GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockConcrete, 8, 2), new Object[] { "COC", "OCO", "COC", 'C', new ItemStack(blockConcrete, 1, 1), 'O', Item.ingotIron }));
  198. // Reinforced rails
  199. GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockCombatRail, 16, 0), new Object[] { "C C", "CIC", "C C", 'I', new ItemStack(blockConcrete, 1, 0), 'C', Item.ingotIron }));
  200. // Reinforced Glass
  201. GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockReinforcedGlass, 8), new Object[] { "IGI", "GIG", "IGI", 'G', Block.glass, 'I', Item.ingotIron }));
  202. modproxies.postInit();
  203. }
  204. }