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