From 2aed9b8b50c34c36fb47dcf1b47b5b555eb83cd8 Mon Sep 17 00:00:00 2001 From: LemADEC Date: Sun, 30 Aug 2015 18:05:30 +0200 Subject: [PATCH] Refactored event handlers --- src/main/java/cr0s/warpdrive/WarpDrive.java | 640 +++--------------- .../java/cr0s/warpdrive/config/Recipes.java | 451 ++++++++++++ .../warpdrive/config/WarpDriveConfig.java | 266 ++++---- .../LivingHandler.java} | 51 +- .../WorldHandler.java} | 9 +- 5 files changed, 716 insertions(+), 701 deletions(-) create mode 100644 src/main/java/cr0s/warpdrive/config/Recipes.java rename src/main/java/cr0s/warpdrive/{SpaceEventHandler.java => event/LivingHandler.java} (97%) rename src/main/java/cr0s/warpdrive/{EventListeners.java => event/WorldHandler.java} (95%) diff --git a/src/main/java/cr0s/warpdrive/WarpDrive.java b/src/main/java/cr0s/warpdrive/WarpDrive.java index fe3e5f9a..ef42271c 100644 --- a/src/main/java/cr0s/warpdrive/WarpDrive.java +++ b/src/main/java/cr0s/warpdrive/WarpDrive.java @@ -7,11 +7,8 @@ import net.minecraft.block.material.Material; import net.minecraft.client.Minecraft; import net.minecraft.command.ICommandSender; import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemArmor.ArmorMaterial; -import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ChatComponentText; @@ -26,9 +23,6 @@ import net.minecraftforge.common.ForgeChunkManager.Ticket; import net.minecraftforge.common.ForgeChunkManager.Type; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.util.EnumHelper; -import net.minecraftforge.oredict.ShapedOreRecipe; -import net.minecraftforge.oredict.ShapelessOreRecipe; - import org.apache.logging.log4j.Logger; import cpw.mods.fml.common.FMLCommonHandler; @@ -96,11 +90,14 @@ import cr0s.warpdrive.command.CommandGenerate; import cr0s.warpdrive.command.CommandInvisible; import cr0s.warpdrive.command.CommandJumpgates; import cr0s.warpdrive.command.CommandSpace; +import cr0s.warpdrive.config.Recipes; import cr0s.warpdrive.config.WarpDriveConfig; import cr0s.warpdrive.data.CamerasRegistry; import cr0s.warpdrive.data.CloakManager; import cr0s.warpdrive.data.JumpgatesRegistry; import cr0s.warpdrive.data.StarMapRegistry; +import cr0s.warpdrive.event.LivingHandler; +import cr0s.warpdrive.event.WorldHandler; import cr0s.warpdrive.item.ItemAirCanisterFull; import cr0s.warpdrive.item.ItemComponent; import cr0s.warpdrive.item.ItemHelmet; @@ -186,14 +183,14 @@ public class WarpDrive implements LoadingCallback { public static String defHelpStr = "help(\"functionName\"): returns help for the function specified"; public static String defEnergyStr = "getEnergyLevel(): returns currently contained energy, max contained energy"; public static String defUpgradeStr = "upgrades(): returns a list of currently installed upgrades"; - + public static Logger logger; - + @EventHandler - public void preInit(FMLPreInitializationEvent event) { + public void onFMLPreInitialization(FMLPreInitializationEvent event) { logger = event.getModLog(); - WarpDriveConfig.preInit(event.getModConfigurationDirectory().getAbsolutePath()); + WarpDriveConfig.onFMLpreInitialization(event.getModConfigurationDirectory().getAbsolutePath()); if (FMLCommonHandler.instance().getSide().isClient()) { MinecraftForge.EVENT_BUS.register(new RenderOverlayCamera(Minecraft.getMinecraft())); @@ -201,137 +198,134 @@ public class WarpDrive implements LoadingCallback { FMLCommonHandler.instance().bus().register(new ClientCameraHandler()); } } - + @EventHandler - public void init(FMLInitializationEvent event) { + public void onFMLInitialization(FMLInitializationEvent event) { PacketHandler.init(); - } - - @EventHandler - public void load(FMLInitializationEvent event) { - WarpDriveConfig.load(); - + + WarpDriveConfig.onFMLInitialization(); + // CORE CONTROLLER blockShipController = new BlockShipController(0, Material.rock); - + GameRegistry.registerBlock(blockShipController, "blockShipController"); GameRegistry.registerTileEntity(TileEntityShipController.class, MODID + ":blockShipController"); - + // WARP CORE blockShipCore = new BlockShipCore(0, Material.rock); - + GameRegistry.registerBlock(blockShipCore, "blockShipCore"); GameRegistry.registerTileEntity(TileEntityShipCore.class, MODID + ":blockShipCore"); - + // WARP RADAR blockRadar = new BlockRadar(0, Material.rock); - + GameRegistry.registerBlock(blockRadar, "blockRadar"); GameRegistry.registerTileEntity(TileEntityRadar.class, MODID + ":blockRadar"); - + // WARP ISOLATION blockWarpIsolation = new BlockWarpIsolation(0, Material.rock); - + GameRegistry.registerBlock(blockWarpIsolation, "blockWarpIsolation"); - + // AIR GENERATOR blockAirGenerator = new BlockAirGenerator(0, Material.rock); - + GameRegistry.registerBlock(blockAirGenerator, "blockAirGenerator"); GameRegistry.registerTileEntity(TileEntityAirGenerator.class, MODID + ":blockAirGenerator"); - + // AIR BLOCK blockAir = new BlockAir(); - + GameRegistry.registerBlock(blockAir, "blockAir"); - + // GAS BLOCK blockGas = new BlockGas(); - + GameRegistry.registerBlock(blockGas, "blockGas"); - + // LASER EMITTER blockLaser = new BlockLaser(0, Material.rock); - + GameRegistry.registerBlock(blockLaser, "blockLaser"); GameRegistry.registerTileEntity(TileEntityLaser.class, MODID + ":blockLaser"); - + // LASER EMITTER WITH CAMERA blockLaserCamera = new BlockLaserCamera(0, Material.rock); - + GameRegistry.registerBlock(blockLaserCamera, "blockLaserCamera"); - + // CAMERA blockCamera = new BlockCamera(0, Material.rock); - + GameRegistry.registerBlock(blockCamera, "blockCamera"); GameRegistry.registerTileEntity(TileEntityCamera.class, MODID + ":blockCamera"); - + // MONITOR blockMonitor = new BlockMonitor(); - + GameRegistry.registerBlock(blockMonitor, "blockMonitor"); GameRegistry.registerTileEntity(TileEntityMonitor.class, MODID + ":blockMonitor"); - + // MINING LASER blockMiningLaser = new BlockMiningLaser(0, Material.rock); - + GameRegistry.registerBlock(blockMiningLaser, "blockMiningLaser"); GameRegistry.registerTileEntity(TileEntityMiningLaser.class, MODID + ":blockMiningLaser"); - + // LASER TREE FARM blockLaserTreeFarm = new BlockLaserTreeFarm(0, Material.rock); - + GameRegistry.registerBlock(blockLaserTreeFarm, "blockLaserTreeFarm"); GameRegistry.registerTileEntity(TileEntityLaserTreeFarm.class, MODID + ":blockLaserTreeFarm"); - + // LASER MEDIUM blockLaserMedium = new BlockLaserMedium(0, Material.rock); - + GameRegistry.registerBlock(blockLaserMedium, "blockLaserMedium"); GameRegistry.registerTileEntity(TileEntityLaserMedium.class, MODID + ":blockLaserMedium"); - + // LIFT blockLift = new BlockLift(0, Material.rock); - + GameRegistry.registerBlock(blockLift, "blockLift"); GameRegistry.registerTileEntity(TileEntityLift.class, MODID + ":blockLift"); - + // IRIDIUM BLOCK blockIridium = new BlockIridium(); - + GameRegistry.registerBlock(blockIridium, "blockIridium"); - + // HIGHLY ADVANCED MACHINE BLOCK if (WarpDriveConfig.isIndustrialCraft2loaded) { blockHighlyAdvancedMachine = new BlockHighlyAdvancedMachine(); - + GameRegistry.registerBlock(blockHighlyAdvancedMachine, "blockHighlyAdvancedMachine"); } - + // SHIP SCANNER blockShipScanner = new BlockShipScanner(0, Material.rock); - + GameRegistry.registerBlock(blockShipScanner, "blockShipScanner"); GameRegistry.registerTileEntity(TileEntityShipScanner.class, MODID + ":blockShipScanner"); - + // CLOAKING DEVICE CORE blockCloakingCore = new BlockCloakingCore(0, Material.rock); - + GameRegistry.registerBlock(blockCloakingCore, "blockCloakingCore"); GameRegistry.registerTileEntity(TileEntityCloakingCore.class, MODID + ":blockCloakingCore"); - + // CLOAKING DEVICE COIL blockCloakingCoil = new BlockCloakingCoil(0, Material.rock); - + GameRegistry.registerBlock(blockCloakingCoil, "blockCloakingCoil"); - + // TRANSPORTER blockTransporter = new BlockTransporter(Material.rock); - + GameRegistry.registerBlock(blockTransporter, "blockTransporter"); GameRegistry.registerTileEntity(TileEntityTransporter.class, MODID + ":blockTransporter"); - + // REACTOR MONITOR if (WarpDriveConfig.isIndustrialCraft2loaded) { blockIC2reactorLaserMonitor = new BlockIC2reactorLaserMonitor(Material.rock); @@ -341,31 +335,31 @@ public class WarpDrive implements LoadingCallback { } // TRANSPORT BEACON blockTransportBeacon = new BlockTransportBeacon(); - + GameRegistry.registerBlock(blockTransportBeacon, "blockTransportBeacon"); - + // POWER REACTOR, LASER, STORE blockEnanReactorCore = new BlockEnanReactorCore(); GameRegistry.registerBlock(blockEnanReactorCore, "blockEnanReactorCore"); GameRegistry.registerTileEntity(TileEntityEnanReactorCore.class, MODID + ":blockEnanReactorCore"); - + blockEnanReactorLaser = new BlockEnanReactorLaser(); GameRegistry.registerBlock(blockEnanReactorLaser, "blockEnanReactorLaser"); GameRegistry.registerTileEntity(TileEntityEnanReactorLaser.class, MODID + ":blockEnanReactorLaser"); - + blockEnergyBank = new BlockEnergyBank(); GameRegistry.registerBlock(blockEnergyBank, "blockEnergyBank"); GameRegistry.registerTileEntity(TileEntityEnergyBank.class, MODID + ":blockEnergyBank"); - + // CHUNK LOADER blockChunkLoader = new BlockChunkLoader(); GameRegistry.registerBlock(blockChunkLoader, "blockChunkLoader"); GameRegistry.registerTileEntity(TileEntityChunkLoader.class, MODID + ":blockChunkLoader"); - + // DECORATIVE blockDecorative = new BlockDecorative(); GameRegistry.registerBlock(blockDecorative, ItemBlockDecorative.class, "blockDecorative"); - + // REACTOR LASER FOCUS if (WarpDriveConfig.isIndustrialCraft2loaded) { itemIC2reactorLaserFocus = new ItemIC2reactorLaserFocus(); @@ -374,530 +368,93 @@ public class WarpDrive implements LoadingCallback { // COMPONENT ITEMS itemComponent = new ItemComponent(); GameRegistry.registerItem(itemComponent, "itemComponent"); - + itemHelmet = new ItemHelmet(armorMaterial, 0); GameRegistry.registerItem(itemHelmet, "itemHelmet"); - + itemAirCanisterFull = new ItemAirCanisterFull(); GameRegistry.registerItem(itemAirCanisterFull, "itemAirCanisterFull"); - + itemUpgrade = new ItemUpgrade(); GameRegistry.registerItem(itemUpgrade, "itemUpgrade"); proxy.registerEntities(); + ForgeChunkManager.setForcedChunkLoadingCallback(instance, instance); - + spaceWorldGenerator = new SpaceWorldGenerator(); GameRegistry.registerWorldGenerator(spaceWorldGenerator, 0); hyperSpaceWorldGenerator = new HyperSpaceWorldGenerator(); GameRegistry.registerWorldGenerator(hyperSpaceWorldGenerator, 0); - - registerSpaceDimension(); - registerHyperSpaceDimension(); - - MinecraftForge.EVENT_BUS.register(new SpaceEventHandler()); - + + spaceBiome = (new BiomeSpace(WarpDriveConfig.G_SPACE_BIOME_ID)).setColor(0).setDisableRain().setBiomeName("Space"); + BiomeDictionary.registerBiomeType(spaceBiome, BiomeDictionary.Type.DEAD, BiomeDictionary.Type.WASTELAND); + DimensionManager.registerProviderType(WarpDriveConfig.G_SPACE_PROVIDER_ID, SpaceWorldProvider.class, true); + DimensionManager.registerDimension(WarpDriveConfig.G_SPACE_DIMENSION_ID, WarpDriveConfig.G_SPACE_PROVIDER_ID); + + DimensionManager.registerProviderType(WarpDriveConfig.G_HYPERSPACE_PROVIDER_ID, HyperSpaceWorldProvider.class, true); + DimensionManager.registerDimension(WarpDriveConfig.G_HYPERSPACE_DIMENSION_ID, WarpDriveConfig.G_HYPERSPACE_PROVIDER_ID); + if (FMLCommonHandler.instance().getEffectiveSide().isClient()) { creativeTabWarpDrive.setBackgroundImageName("items.png"); } - if (WarpDriveConfig.isComputerCraftLoaded) { - peripheralHandler = new WarpDrivePeripheralHandler(); - peripheralHandler.register(); - } } - + @EventHandler - public void postInit(FMLPostInitializationEvent event) { + public void onFMLPostInitialization(FMLPostInitializationEvent event) { space = DimensionManager.getWorld(WarpDriveConfig.G_SPACE_DIMENSION_ID); hyperSpace = DimensionManager.getWorld(WarpDriveConfig.G_HYPERSPACE_DIMENSION_ID); WarpDriveConfig.postInit(); if (WarpDriveConfig.isIndustrialCraft2loaded && WarpDriveConfig.RECIPES_ENABLE_IC2) { - initIC2Recipes(); + Recipes.initIC2(); } if (WarpDriveConfig.isIndustrialCraft2loaded && WarpDriveConfig.RECIPES_ENABLE_HARD_IC2) { - initHardIC2Recipes(); + Recipes.initHardIC2(); } if (WarpDriveConfig.RECIPES_ENABLE_VANILLA) { - initVanillaRecipes(); + Recipes.initVanilla(); } + // Registers starMap = new StarMapRegistry(); jumpgates = new JumpgatesRegistry(); cloaks = new CloakManager(); cameras = new CamerasRegistry(); - EventListeners watcher = new EventListeners(); - MinecraftForge.EVENT_BUS.register(watcher); - FMLCommonHandler.instance().bus().register(watcher); - } - - private static void initVanillaRecipes() { - itemComponent.registerRecipes(); - blockDecorative.initRecipes(); - itemUpgrade.initRecipes(); + // Event handlers + WorldHandler worldHandler = new WorldHandler(); + MinecraftForge.EVENT_BUS.register(worldHandler); + FMLCommonHandler.instance().bus().register(worldHandler); - // WarpCore - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockShipCore), false, "ipi", "ici", "idi", - 'i', Items.iron_ingot, - 'p', itemComponent.getItemStack(6), - 'c', itemComponent.getItemStack(2), - 'd', Items.diamond)); + MinecraftForge.EVENT_BUS.register(new LivingHandler()); - // Controller - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockShipController), false, "ici", "idi", "iii", - 'i', Items.iron_ingot, - 'c', itemComponent.getItemStack(5), - 'd', Items.diamond)); - - // Radar - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockRadar), false, "ggg", "pdc", "iii", - 'i', Items.iron_ingot, - 'c', itemComponent.getItemStack(5), - 'p', itemComponent.getItemStack(6), - 'g', Blocks.glass, - 'd', Items.diamond)); - - // Isolation Block - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockWarpIsolation), false, "igi", "geg", "igi", - 'i', Items.iron_ingot, - 'g', Blocks.glass, - 'e', Items.ender_pearl)); - - // Air generator - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockAirGenerator), false, "ibi", "i i", "ipi", - 'i', Items.iron_ingot, - 'b', Blocks.iron_bars, - 'p', itemComponent.getItemStack(6))); - - // Laser - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockLaser), false, "ili", "iri", "ici", - 'i', Items.iron_ingot, - 'r', Items.redstone, - 'c', itemComponent.getItemStack(5), - 'l', itemComponent.getItemStack(3), - 'p', itemComponent.getItemStack(6))); - - // Mining laser - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockMiningLaser), false, "ici", "iti", "ili", - 'i', Items.iron_ingot, - 'r', Items.redstone, - 't', itemComponent.getItemStack(1), - 'c', itemComponent.getItemStack(5), - 'l', itemComponent.getItemStack(3))); - - // Tree farm laser - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockLaserTreeFarm), false, "ili", "sts", "ici", - 'i', Items.iron_ingot, - 's', "treeSapling", - 't', itemComponent.getItemStack(1), - 'c', itemComponent.getItemStack(5), - 'l', itemComponent.getItemStack(3))); - - // Laser Lift - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockLift), false, "ipi", "rtr", "ili", - 'i', Items.iron_ingot, - 'r', Items.redstone, - 't', itemComponent.getItemStack(1), - 'l', itemComponent.getItemStack(3), - 'p', itemComponent.getItemStack(6))); - - // Transporter - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockTransporter), false, "iii", "ptc", "iii", - 'i', Items.iron_ingot, - 't', itemComponent.getItemStack(1), - 'c', itemComponent.getItemStack(5), - 'p', itemComponent.getItemStack(6))); - - // Particle Booster - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockLaserMedium), false, "ipi", "rgr", "iii", - 'i', Items.iron_ingot, - 'r', Items.redstone, - 'g', Blocks.glass, - 'p', itemComponent.getItemStack(6))); - - // Camera - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockCamera), false, "ngn", "i i", "ici", - 'i', Items.iron_ingot, - 'n', Items.gold_nugget, - 'g', Blocks.glass, - 'c', itemComponent.getItemStack(5))); - - // LaserCamera - GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(blockLaserCamera), blockCamera, blockLaser)); - - // Monitor - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockMonitor), false, "ggg", "iti", "ici", - 'i', Items.iron_ingot, - 't', Blocks.torch, - 'g', Blocks.glass, - 'c', itemComponent.getItemStack(5))); - - // Cloaking device - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockCloakingCore), false, "ipi", "lrl", "ici", - 'i', Items.iron_ingot, - 'r', Items.redstone, - 'l', itemComponent.getItemStack(3), - 'c', itemComponent.getItemStack(5), - 'p', itemComponent.getItemStack(6))); - - // Cloaking coil - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockCloakingCoil), false, "ini", "rdr", "ini", - 'i', Items.iron_ingot, - 'd', Items.diamond, - 'r', Items.redstone, - 'n', Items.gold_nugget)); - - // Power Laser - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockEnanReactorLaser), false, "iii", "ilg", "ici", - 'i', Items.iron_ingot, - 'g', Blocks.glass, - 'c', itemComponent.getItemStack(5), - 'l', itemComponent.getItemStack(3))); - - // Power Reactor - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockEnanReactorCore), false, "ipi", "gog", "ici", - 'i', Items.iron_ingot, - 'g', Blocks.glass, - 'o', itemComponent.getItemStack(4), - 'c', itemComponent.getItemStack(5), - 'p', itemComponent.getItemStack(6))); - - // Power Store - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockEnergyBank), false, "ipi", "isi", "ici", - 'i', Items.iron_ingot, - 's', itemComponent.getItemStack(7), - 'c', itemComponent.getItemStack(5), - 'p', itemComponent.getItemStack(6))); - - // Transport Beacon - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockTransportBeacon), false, " e ", "ldl", " s ", - 'e', Items.ender_pearl, - 'l', "dyeBlue", - 'd', Items.diamond, - 's', Items.stick)); - - // Chunk Loader - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockChunkLoader), false, "ipi", "ici", "ifi", - 'i', Items.iron_ingot, - 'p', itemComponent .getItemStack(6), - 'c', itemComponent.getItemStack(0), - 'f', itemComponent.getItemStack(5))); - - // Helmet - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(itemHelmet), false, "iii", "iwi", "gcg", - 'i', Items.iron_ingot, - 'w', Blocks.wool, - 'g', Blocks.glass, - 'c', itemComponent.getItemStack(8))); - } - - private static void initIC2Recipes() { - ItemStack advancedAlloy = WarpDriveConfig.getModItemStack("IC2", "itemPartAlloy", -1).copy(); - ItemStack iridiumAlloy = WarpDriveConfig.getModItemStack("IC2", "itemPartIridium", -1).copy(); - ItemStack advancedMachine = WarpDriveConfig.getModItemStack("IC2", "blockMachine", 12).copy(); - ItemStack miner = WarpDriveConfig.getModItemStack("IC2", "blockMachine", 7).copy(); - ItemStack magnetizer = WarpDriveConfig.getModItemStack("IC2", "blockMachine", 9).copy(); - ItemStack fiberGlassCable = WarpDriveConfig.getModItemStack("IC2", "itemCable", 9).copy(); - ItemStack circuit = WarpDriveConfig.getModItemStack("IC2", "itemPartCircuit", -1).copy(); - ItemStack advancedCircuit = WarpDriveConfig.getModItemStack("IC2", "itemPartCircuitAdv", -1).copy(); - ItemStack ironPlate = WarpDriveConfig.getModItemStack("IC2", "itemPlates", 4).copy(); - ItemStack mfe = WarpDriveConfig.getModItemStack("IC2", "blockElectric", 1).copy(); - - GameRegistry.addRecipe(new ItemStack(blockShipCore), "ici", "cmc", "ici", - 'i', iridiumAlloy, - 'm', advancedMachine, - 'c', advancedCircuit); - - GameRegistry.addRecipe(new ItemStack(blockShipController), "iic", "imi", "cii", - 'i', iridiumAlloy, - 'm', advancedMachine, - 'c', advancedCircuit); - - GameRegistry.addRecipe(new ItemStack(blockRadar), "ifi", "imi", "imi", - 'i', iridiumAlloy, - 'm', advancedMachine, - 'f', WarpDriveConfig.getModItemStack("IC2", "itemFreq", -1)); - - GameRegistry.addRecipe(new ItemStack(blockWarpIsolation), "iii", "idi", "iii", - 'i', WarpDriveConfig.getModItemStack("IC2", "itemPartIridium", -1), - 'm', advancedMachine, - 'd', Blocks.diamond_block); - - GameRegistry.addRecipe(new ItemStack(blockAirGenerator), "lcl", "lml", "lll", - 'l', Blocks.leaves, - 'm', advancedMachine, - 'c', advancedCircuit); - - GameRegistry.addRecipe(new ItemStack(blockLaser), "sss", "ama", "aaa", - 'm', advancedMachine, - 'a', advancedAlloy, - 's', advancedCircuit); - - GameRegistry.addRecipe(new ItemStack(blockMiningLaser), "aaa", "ama", "ccc", - 'c', advancedCircuit, - 'a', advancedAlloy, - 'm', miner); - - GameRegistry.addRecipe(new ItemStack(blockLaserMedium), "afc", "ama", "cfa", - 'c', advancedCircuit, - 'a', advancedAlloy, - 'f', fiberGlassCable, - 'm', mfe); - - GameRegistry.addRecipe(new ItemStack(blockLift), "aca", "ama", "a#a", - 'c', advancedCircuit, - 'a', WarpDriveConfig.getModItemStack("IC2", "itemPartAlloy", -1), - 'm', magnetizer); - - GameRegistry.addRecipe(new ItemStack(blockIridium), "iii", "iii", "iii", - 'i', iridiumAlloy); - - GameRegistry.addShapelessRecipe(new ItemStack(iridiumAlloy.getItem(), 9), new ItemStack(blockIridium)); - - GameRegistry.addRecipe(new ItemStack(blockLaserCamera), "imi", "cec", "#k#", - 'i', iridiumAlloy, - 'm', advancedMachine, - 'c', advancedCircuit, - 'e', blockLaser, - 'k', blockCamera); - - GameRegistry.addRecipe(new ItemStack(blockCamera), "cgc", "gmg", "cgc", - 'm', advancedMachine, - 'c', advancedCircuit, - 'g', Blocks.glass); - - GameRegistry.addRecipe(new ItemStack(blockMonitor), "gcg", "gmg", "ggg", - 'm', advancedMachine, - 'c', advancedCircuit, - 'g', Blocks.glass); - - GameRegistry.addRecipe(new ItemStack(blockShipScanner), "sgs", "mma", "amm", - 'm', advancedMachine, - 'a', advancedAlloy, - 's', advancedCircuit, - 'g', Blocks.glass); - - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockLaserTreeFarm), false, new Object[] { "cwc", "wmw", "cwc", - 'c', circuit, - 'w', "logWood", - 'm', blockMiningLaser })); - - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockTransporter), false, new Object[] { "ece", "imi", "iei", - 'e', Items.ender_pearl, - 'c', circuit, - 'i', ironPlate, - 'm', advancedMachine })); - - if (WarpDriveConfig.isIndustrialCraft2loaded) { - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(itemIC2reactorLaserFocus), false, new Object[] { " p ", "pdp", " p ", - 'p', ironPlate, - 'd', "gemDiamond" })); - - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockIC2reactorLaserMonitor), false, new Object[] { "pdp", "dmd", "pdp", - 'p', ironPlate, - 'd', "gemDiamond", - 'm', mfe })); + if (WarpDriveConfig.isComputerCraftLoaded) { + peripheralHandler = new WarpDrivePeripheralHandler(); + peripheralHandler.register(); } - - GameRegistry.addRecipe(new ItemStack(blockCloakingCore), "imi", "mcm", "imi", - 'i', blockIridium, - 'c', blockCloakingCoil, - 'm', advancedMachine); - - GameRegistry.addRecipe(new ItemStack(blockCloakingCoil), "iai", "aca", "iai", - 'i', iridiumAlloy, - 'c', advancedCircuit, - 'a', advancedAlloy); } - - private static void initHardIC2Recipes() { - ItemStack advancedAlloy = WarpDriveConfig.getModItemStack("IC2", "itemPartAlloy", -1).copy(); - ItemStack iridiumAlloy = WarpDriveConfig.getModItemStack("IC2", "itemPartIridium", -1).copy(); - ItemStack advancedMachine = WarpDriveConfig.getModItemStack("IC2", "blockMachine", 12).copy(); - ItemStack magnetizer = WarpDriveConfig.getModItemStack("IC2", "blockMachine", 9).copy(); - ItemStack fiberGlassCable = WarpDriveConfig.getModItemStack("IC2", "itemCable", 9).copy(); - ItemStack mfe = WarpDriveConfig.getModItemStack("IC2", "blockElectric", 1).copy(); - ItemStack mfsu = WarpDriveConfig.getModItemStack("IC2", "blockElectric", 2).copy(); - ItemStack energiumDust = WarpDriveConfig.getModItemStack("IC2", "itemDust2", 2).copy(); - ItemStack crystalmemory = WarpDriveConfig.getModItemStack("IC2", "itemcrystalmemory", -1).copy(); - ItemStack itemHAMachine = new ItemStack(blockHighlyAdvancedMachine).copy(); - - GameRegistry.addRecipe(new ItemStack(blockShipCore),"uau", "tmt", "uau", - 'a', advancedAlloy, - 't', WarpDriveConfig.getModItemStack("IC2", "blockMachine2", 0), // Teleporter - 'm', itemHAMachine, - 'u', mfsu); - - if (WarpDriveConfig.isOpenComputersLoaded) { - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockShipController), false, new Object[] { "aha", "cmc", "apa", // With OC Adapter - 'a', advancedAlloy, - 'm', itemHAMachine, - 'c', "circuitAdvanced", - 'h', crystalmemory, - 'p', WarpDriveConfig.getModItemStack("OpenComputers", "adapter", -1)})); - } else if (WarpDriveConfig.isComputerCraftLoaded) { - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockShipController), false, new Object[] { "aha", "cmc", "apa", // With CC Modem - 'a', advancedAlloy, - 'm', itemHAMachine, - 'c', "circuitAdvanced", - 'h', crystalmemory, - 'p', WarpDriveConfig.getModItemStack("ComputerCraft", "CC-Cable", 1)})); - } else { - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockShipController), false, new Object[] { "aha", "cmc", "aca", - 'a', advancedAlloy, - 'm', itemHAMachine, - 'c', "circuitAdvanced", - 'h', crystalmemory})); - } - - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockRadar), false, new Object[] { "afa", "cmc", "aca", - 'a', advancedAlloy, - 'm', itemHAMachine, - 'c', "circuitAdvanced", - 'f', WarpDriveConfig.getModItemStack("IC2", "itemFreq", -1)})); - - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockWarpIsolation), false, new Object[] { "sls", "lml", "sls", - 's', "plateDenseSteel", - 'l', "plateDenseLead", - 'm', itemHAMachine})); - - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockAirGenerator), false, new Object[] { "lel", "vmv", "lcl", - 'l', Blocks.leaves, - 'm', WarpDriveConfig.getModItemStack("IC2", "blockMachine", 0), - 'c', "circuitBasic", - 'e', WarpDriveConfig.getModItemStack("IC2", "blockMachine", 5), // Compressor - 'v', WarpDriveConfig.getModItemStack("IC2", "reactorVent", -1)})); - - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockLaser), false, new Object[] { "aca", "cmc", "ala", - 'm', advancedMachine, - 'a', advancedAlloy, - 'c', "circuitAdvanced", - 'l', WarpDriveConfig.getModItemStack("IC2", "itemToolMiningLaser", -1)})); - - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockMiningLaser), false, new Object[] { "pcp", "pap", "plp", - 'c', "circuitAdvanced", - 'p', advancedAlloy, - 'a', WarpDriveConfig.getModItemStack("IC2", "blockMachine2", 11), // Advanced Miner - 'l', blockLaser})); - - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockLaserMedium), false, new Object[] { "efe", "aca", "ama", - 'c', "circuitAdvanced", - 'a', advancedAlloy, - 'f', fiberGlassCable, - 'e', energiumDust, - 'm', mfe})); - - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockLift), false, new Object[] { "aca", "ama", "aea", - 'c', "circuitAdvanced", - 'a', advancedAlloy, - 'm', magnetizer, - 'e', energiumDust})); - - GameRegistry.addRecipe(new ItemStack(blockIridium), "iii", "iii", "iii", - 'i', iridiumAlloy); - - GameRegistry.addShapelessRecipe(new ItemStack(iridiumAlloy.getItem(), 9), new ItemStack(blockIridium)); - - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockLaserCamera), false, new Object[] { "ala", "sss", "aca", - 'a', advancedAlloy, - 's', "circuitAdvanced", - 'l', blockLaser, - 'c', blockCamera})); - - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockCamera), false, new Object[] { "aed", "cma", "aga", - 'a', advancedAlloy, - 'e', WarpDriveConfig.getModItemStack("IC2", "itemRecipePart", 1), // Electric Motor - 'd', "gemDiamond", - 'c', crystalmemory, - 'm', advancedMachine, - 'g', WarpDriveConfig.getModItemStack("IC2", "itemCable", 2)})); - - - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockMonitor), false, new Object[] { "ala", "aca", "aga", - 'a', advancedAlloy, - 'l', Blocks.redstone_lamp, - 'c', "circuitAdvanced", - 'g', "paneGlassColorless" })); - - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockShipScanner), false, new Object[] { "ici", "isi", "mcm", - 'm', mfsu, - 'i', iridiumAlloy, - 'c', "circuitAdvanced", - 's', WarpDriveConfig.getModItemStack("IC2", "blockMachine2", 7) })); // Scanner - - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockLaserTreeFarm), false, new Object[] { "awa", "cmc", "asa", - 'a', advancedAlloy, - 'c', "circuitAdvanced", - 'w', "logWood", - 'm', blockMiningLaser, - 's', WarpDriveConfig.getModItemStack("IC2", "itemToolChainsaw", -1) })); - - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockTransporter), false, new Object[] { "aea", "ctc", "ama", - 'a', advancedAlloy, - 'e', Items.ender_pearl, - 'c', "circuitAdvanced", - 'm', advancedMachine, - 't', WarpDriveConfig.getModItemStack("IC2", "blockMachine2", 0) })); // Teleporter - - // IC2 is loaded for this recipe set - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(itemIC2reactorLaserFocus), false, new Object[] { "a a", " d ", "a a", - 'a', advancedAlloy, - 'd', "gemDiamond" })); - - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockIC2reactorLaserMonitor), false, new Object[] { "pdp", "dmd", "pdp", - 'p', advancedAlloy, - 'd', "gemDiamond", - 'm', mfe })); - - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockCloakingCore), false, new Object[] { "ici", "cmc", "igi", - 'i', blockIridium, - 'c', blockCloakingCoil, - 'm', blockHighlyAdvancedMachine, - 'g', "circuitAdvanced" })); - - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockCloakingCoil), false, new Object[] { "iai", "ccc", "iai", - 'i', iridiumAlloy, - 'c', WarpDriveConfig.getModItemStack("IC2", "itemRecipePart", 0), // Coil - 'a', advancedAlloy })); - - GameRegistry.addRecipe(new ItemStack(blockHighlyAdvancedMachine), "iii", "imi", "iii", - 'i', iridiumAlloy, - 'm', advancedMachine); - } - - private static void registerSpaceDimension() { - spaceBiome = (new BiomeSpace(WarpDriveConfig.G_SPACE_BIOME_ID)).setColor(0).setDisableRain().setBiomeName("Space"); - BiomeDictionary.registerBiomeType(spaceBiome, BiomeDictionary.Type.DEAD, BiomeDictionary.Type.WASTELAND); - DimensionManager.registerProviderType(WarpDriveConfig.G_SPACE_PROVIDER_ID, SpaceWorldProvider.class, true); - DimensionManager.registerDimension(WarpDriveConfig.G_SPACE_DIMENSION_ID, WarpDriveConfig.G_SPACE_PROVIDER_ID); - } - - private static void registerHyperSpaceDimension() { - DimensionManager.registerProviderType(WarpDriveConfig.G_HYPERSPACE_PROVIDER_ID, HyperSpaceWorldProvider.class, true); - DimensionManager.registerDimension(WarpDriveConfig.G_HYPERSPACE_DIMENSION_ID, WarpDriveConfig.G_HYPERSPACE_PROVIDER_ID); - } - + @EventHandler - public void onServerStarting(FMLServerStartingEvent event) { - WarpDrive.logger.info("onServerStarting"); + public void onFMLServerStarting(FMLServerStartingEvent event) { + WarpDrive.logger.info("onFMLServerStarting"); event.registerServerCommand(new CommandGenerate()); event.registerServerCommand(new CommandSpace()); event.registerServerCommand(new CommandInvisible()); event.registerServerCommand(new CommandJumpgates()); event.registerServerCommand(new CommandDebug()); } - - public Ticket registerChunkLoadTE(TileEntityAbstractChunkLoading te, boolean refreshLoading) { - World worldObj = te.getWorldObj(); + + public Ticket registerChunkLoadTE(TileEntityAbstractChunkLoading tileEntity, boolean refreshLoading) { + World worldObj = tileEntity.getWorldObj(); if (ForgeChunkManager.ticketCountAvailableFor(this, worldObj) > 0) { Ticket t = ForgeChunkManager.requestTicket(this, worldObj, Type.NORMAL); if (t != null) { - te.giveTicket(t); // FIXME calling the caller is a bad idea + tileEntity.giveTicket(t); // FIXME calling the caller is a bad idea if (refreshLoading) - te.refreshLoading(); + tileEntity.refreshLoading(); return t; } else { WarpDrive.logger.error("Ticket not granted"); @@ -951,8 +508,9 @@ public class WarpDrive implements LoadingCallback { sender.addChatMessage(new ChatComponentText(line)); } } + @Mod.EventHandler - public void remap(FMLMissingMappingsEvent event) { + public void onFMLMissingMappings(FMLMissingMappingsEvent event) { for (FMLMissingMappingsEvent.MissingMapping mapping: event.get()) { if (mapping.type == GameRegistry.Type.ITEM) { if (mapping.name.equals("WarpDrive:airBlock")) { diff --git a/src/main/java/cr0s/warpdrive/config/Recipes.java b/src/main/java/cr0s/warpdrive/config/Recipes.java new file mode 100644 index 00000000..5f738f83 --- /dev/null +++ b/src/main/java/cr0s/warpdrive/config/Recipes.java @@ -0,0 +1,451 @@ +package cr0s.warpdrive.config; + +import cpw.mods.fml.common.registry.GameRegistry; +import cr0s.warpdrive.WarpDrive; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraftforge.oredict.ShapedOreRecipe; +import net.minecraftforge.oredict.ShapelessOreRecipe; + +/** + * Hold the different recipe sets + * + * @author LemADEC + * + */ +public class Recipes { + + public static void initVanilla() { + WarpDrive.itemComponent.registerRecipes(); + WarpDrive.blockDecorative.initRecipes(); + WarpDrive.itemUpgrade.initRecipes(); + + // WarpCore + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(WarpDrive.blockShipCore), false, "ipi", "ici", "idi", + 'i', Items.iron_ingot, + 'p', WarpDrive.itemComponent.getItemStack(6), + 'c', WarpDrive.itemComponent.getItemStack(2), + 'd', Items.diamond)); + + // Controller + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(WarpDrive.blockShipController), false, "ici", "idi", "iii", + 'i', Items.iron_ingot, + 'c', WarpDrive.itemComponent.getItemStack(5), + 'd', Items.diamond)); + + // Radar + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(WarpDrive.blockRadar), false, "ggg", "pdc", "iii", + 'i', Items.iron_ingot, + 'c', WarpDrive.itemComponent.getItemStack(5), + 'p', WarpDrive.itemComponent.getItemStack(6), + 'g', Blocks.glass, + 'd', Items.diamond)); + + // Isolation Block + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(WarpDrive.blockWarpIsolation), false, "igi", "geg", "igi", + 'i', Items.iron_ingot, + 'g', Blocks.glass, + 'e', Items.ender_pearl)); + + // Air generator + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(WarpDrive.blockAirGenerator), false, "ibi", "i i", "ipi", + 'i', Items.iron_ingot, + 'b', Blocks.iron_bars, + 'p', WarpDrive.itemComponent.getItemStack(6))); + + // Laser + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(WarpDrive.blockLaser), false, "ili", "iri", "ici", + 'i', Items.iron_ingot, + 'r', Items.redstone, + 'c', WarpDrive.itemComponent.getItemStack(5), + 'l', WarpDrive.itemComponent.getItemStack(3), + 'p', WarpDrive.itemComponent.getItemStack(6))); + + // Mining laser + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(WarpDrive.blockMiningLaser), false, "ici", "iti", "ili", + 'i', Items.iron_ingot, + 'r', Items.redstone, + 't', WarpDrive.itemComponent.getItemStack(1), + 'c', WarpDrive.itemComponent.getItemStack(5), + 'l', WarpDrive.itemComponent.getItemStack(3))); + + // Tree farm laser + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(WarpDrive.blockLaserTreeFarm), false, "ili", "sts", "ici", + 'i', Items.iron_ingot, + 's', "treeSapling", + 't', WarpDrive.itemComponent.getItemStack(1), + 'c', WarpDrive.itemComponent.getItemStack(5), + 'l', WarpDrive.itemComponent.getItemStack(3))); + + // Laser Lift + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(WarpDrive.blockLift), false, "ipi", "rtr", "ili", + 'i', Items.iron_ingot, + 'r', Items.redstone, + 't', WarpDrive.itemComponent.getItemStack(1), + 'l', WarpDrive.itemComponent.getItemStack(3), + 'p', WarpDrive.itemComponent.getItemStack(6))); + + // Transporter + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(WarpDrive.blockTransporter), false, "iii", "ptc", "iii", + 'i', Items.iron_ingot, + 't', WarpDrive.itemComponent.getItemStack(1), + 'c', WarpDrive.itemComponent.getItemStack(5), + 'p', WarpDrive.itemComponent.getItemStack(6))); + + // Particle Booster + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(WarpDrive.blockLaserMedium), false, "ipi", "rgr", "iii", + 'i', Items.iron_ingot, + 'r', Items.redstone, + 'g', Blocks.glass, + 'p', WarpDrive.itemComponent.getItemStack(6))); + + // Camera + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(WarpDrive.blockCamera), false, "ngn", "i i", "ici", + 'i', Items.iron_ingot, + 'n', Items.gold_nugget, + 'g', Blocks.glass, + 'c', WarpDrive.itemComponent.getItemStack(5))); + + // LaserCamera + GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(WarpDrive.blockLaserCamera), WarpDrive.blockCamera, WarpDrive.blockLaser)); + + // Monitor + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(WarpDrive.blockMonitor), false, "ggg", "iti", "ici", + 'i', Items.iron_ingot, + 't', Blocks.torch, + 'g', Blocks.glass, + 'c', WarpDrive.itemComponent.getItemStack(5))); + + // Cloaking device + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(WarpDrive.blockCloakingCore), false, "ipi", "lrl", "ici", + 'i', Items.iron_ingot, + 'r', Items.redstone, + 'l', WarpDrive.itemComponent.getItemStack(3), + 'c', WarpDrive.itemComponent.getItemStack(5), + 'p', WarpDrive.itemComponent.getItemStack(6))); + + // Cloaking coil + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(WarpDrive.blockCloakingCoil), false, "ini", "rdr", "ini", + 'i', Items.iron_ingot, + 'd', Items.diamond, + 'r', Items.redstone, + 'n', Items.gold_nugget)); + + // Power Laser + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(WarpDrive.blockEnanReactorLaser), false, "iii", "ilg", "ici", + 'i', Items.iron_ingot, + 'g', Blocks.glass, + 'c', WarpDrive.itemComponent.getItemStack(5), + 'l', WarpDrive.itemComponent.getItemStack(3))); + + // Power Reactor + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(WarpDrive.blockEnanReactorCore), false, "ipi", "gog", "ici", + 'i', Items.iron_ingot, + 'g', Blocks.glass, + 'o', WarpDrive.itemComponent.getItemStack(4), + 'c', WarpDrive.itemComponent.getItemStack(5), + 'p', WarpDrive.itemComponent.getItemStack(6))); + + // Power Store + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(WarpDrive.blockEnergyBank), false, "ipi", "isi", "ici", + 'i', Items.iron_ingot, + 's', WarpDrive.itemComponent.getItemStack(7), + 'c', WarpDrive.itemComponent.getItemStack(5), + 'p', WarpDrive.itemComponent.getItemStack(6))); + + // Transport Beacon + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(WarpDrive.blockTransportBeacon), false, " e ", "ldl", " s ", + 'e', Items.ender_pearl, + 'l', "dyeBlue", + 'd', Items.diamond, + 's', Items.stick)); + + // Chunk Loader + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(WarpDrive.blockChunkLoader), false, "ipi", "ici", "ifi", + 'i', Items.iron_ingot, + 'p', WarpDrive.itemComponent .getItemStack(6), + 'c', WarpDrive.itemComponent.getItemStack(0), + 'f', WarpDrive.itemComponent.getItemStack(5))); + + // Helmet + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(WarpDrive.itemHelmet), false, "iii", "iwi", "gcg", + 'i', Items.iron_ingot, + 'w', Blocks.wool, + 'g', Blocks.glass, + 'c', WarpDrive.itemComponent.getItemStack(8))); + } + + public static void initIC2() { + ItemStack advancedAlloy = WarpDriveConfig.getModItemStack("IC2", "itemPartAlloy", -1).copy(); + ItemStack iridiumAlloy = WarpDriveConfig.getModItemStack("IC2", "itemPartIridium", -1).copy(); + ItemStack advancedMachine = WarpDriveConfig.getModItemStack("IC2", "blockMachine", 12).copy(); + ItemStack miner = WarpDriveConfig.getModItemStack("IC2", "blockMachine", 7).copy(); + ItemStack magnetizer = WarpDriveConfig.getModItemStack("IC2", "blockMachine", 9).copy(); + ItemStack fiberGlassCable = WarpDriveConfig.getModItemStack("IC2", "itemCable", 9).copy(); + ItemStack circuit = WarpDriveConfig.getModItemStack("IC2", "itemPartCircuit", -1).copy(); + ItemStack advancedCircuit = WarpDriveConfig.getModItemStack("IC2", "itemPartCircuitAdv", -1).copy(); + ItemStack ironPlate = WarpDriveConfig.getModItemStack("IC2", "itemPlates", 4).copy(); + ItemStack mfe = WarpDriveConfig.getModItemStack("IC2", "blockElectric", 1).copy(); + + GameRegistry.addRecipe(new ItemStack(WarpDrive.blockShipCore), "ici", "cmc", "ici", + 'i', iridiumAlloy, + 'm', advancedMachine, + 'c', advancedCircuit); + + GameRegistry.addRecipe(new ItemStack(WarpDrive.blockShipController), "iic", "imi", "cii", + 'i', iridiumAlloy, + 'm', advancedMachine, + 'c', advancedCircuit); + + GameRegistry.addRecipe(new ItemStack(WarpDrive.blockRadar), "ifi", "imi", "imi", + 'i', iridiumAlloy, + 'm', advancedMachine, + 'f', WarpDriveConfig.getModItemStack("IC2", "itemFreq", -1)); + + GameRegistry.addRecipe(new ItemStack(WarpDrive.blockWarpIsolation), "iii", "idi", "iii", + 'i', WarpDriveConfig.getModItemStack("IC2", "itemPartIridium", -1), + 'm', advancedMachine, + 'd', Blocks.diamond_block); + + GameRegistry.addRecipe(new ItemStack(WarpDrive.blockAirGenerator), "lcl", "lml", "lll", + 'l', Blocks.leaves, + 'm', advancedMachine, + 'c', advancedCircuit); + + GameRegistry.addRecipe(new ItemStack(WarpDrive.blockLaser), "sss", "ama", "aaa", + 'm', advancedMachine, + 'a', advancedAlloy, + 's', advancedCircuit); + + GameRegistry.addRecipe(new ItemStack(WarpDrive.blockMiningLaser), "aaa", "ama", "ccc", + 'c', advancedCircuit, + 'a', advancedAlloy, + 'm', miner); + + GameRegistry.addRecipe(new ItemStack(WarpDrive.blockLaserMedium), "afc", "ama", "cfa", + 'c', advancedCircuit, + 'a', advancedAlloy, + 'f', fiberGlassCable, + 'm', mfe); + + GameRegistry.addRecipe(new ItemStack(WarpDrive.blockLift), "aca", "ama", "a#a", + 'c', advancedCircuit, + 'a', WarpDriveConfig.getModItemStack("IC2", "itemPartAlloy", -1), + 'm', magnetizer); + + GameRegistry.addRecipe(new ItemStack(WarpDrive.blockIridium), "iii", "iii", "iii", + 'i', iridiumAlloy); + + GameRegistry.addShapelessRecipe(new ItemStack(iridiumAlloy.getItem(), 9), new ItemStack(WarpDrive.blockIridium)); + + GameRegistry.addRecipe(new ItemStack(WarpDrive.blockLaserCamera), "imi", "cec", "#k#", + 'i', iridiumAlloy, + 'm', advancedMachine, + 'c', advancedCircuit, + 'e', WarpDrive.blockLaser, + 'k', WarpDrive.blockCamera); + + GameRegistry.addRecipe(new ItemStack(WarpDrive.blockCamera), "cgc", "gmg", "cgc", + 'm', advancedMachine, + 'c', advancedCircuit, + 'g', Blocks.glass); + + GameRegistry.addRecipe(new ItemStack(WarpDrive.blockMonitor), "gcg", "gmg", "ggg", + 'm', advancedMachine, + 'c', advancedCircuit, + 'g', Blocks.glass); + + GameRegistry.addRecipe(new ItemStack(WarpDrive.blockShipScanner), "sgs", "mma", "amm", + 'm', advancedMachine, + 'a', advancedAlloy, + 's', advancedCircuit, + 'g', Blocks.glass); + + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(WarpDrive.blockLaserTreeFarm), false, new Object[] { "cwc", "wmw", "cwc", + 'c', circuit, + 'w', "logWood", + 'm', WarpDrive.blockMiningLaser })); + + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(WarpDrive.blockTransporter), false, new Object[] { "ece", "imi", "iei", + 'e', Items.ender_pearl, + 'c', circuit, + 'i', ironPlate, + 'm', advancedMachine })); + + if (WarpDriveConfig.isIndustrialCraft2loaded) { + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(WarpDrive.itemIC2reactorLaserFocus), false, new Object[] { " p ", "pdp", " p ", + 'p', ironPlate, + 'd', "gemDiamond" })); + + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(WarpDrive.blockIC2reactorLaserMonitor), false, new Object[] { "pdp", "dmd", "pdp", + 'p', ironPlate, + 'd', "gemDiamond", + 'm', mfe })); + } + + GameRegistry.addRecipe(new ItemStack(WarpDrive.blockCloakingCore), "imi", "mcm", "imi", + 'i', WarpDrive.blockIridium, + 'c', WarpDrive.blockCloakingCoil, + 'm', advancedMachine); + + GameRegistry.addRecipe(new ItemStack(WarpDrive.blockCloakingCoil), "iai", "aca", "iai", + 'i', iridiumAlloy, + 'c', advancedCircuit, + 'a', advancedAlloy); + } + + public static void initHardIC2() { + ItemStack advancedAlloy = WarpDriveConfig.getModItemStack("IC2", "itemPartAlloy", -1).copy(); + ItemStack iridiumAlloy = WarpDriveConfig.getModItemStack("IC2", "itemPartIridium", -1).copy(); + ItemStack advancedMachine = WarpDriveConfig.getModItemStack("IC2", "blockMachine", 12).copy(); + ItemStack magnetizer = WarpDriveConfig.getModItemStack("IC2", "blockMachine", 9).copy(); + ItemStack fiberGlassCable = WarpDriveConfig.getModItemStack("IC2", "itemCable", 9).copy(); + ItemStack mfe = WarpDriveConfig.getModItemStack("IC2", "blockElectric", 1).copy(); + ItemStack mfsu = WarpDriveConfig.getModItemStack("IC2", "blockElectric", 2).copy(); + ItemStack energiumDust = WarpDriveConfig.getModItemStack("IC2", "itemDust2", 2).copy(); + ItemStack crystalmemory = WarpDriveConfig.getModItemStack("IC2", "itemcrystalmemory", -1).copy(); + ItemStack itemHAMachine = new ItemStack(WarpDrive.blockHighlyAdvancedMachine).copy(); + + GameRegistry.addRecipe(new ItemStack(WarpDrive.blockShipCore),"uau", "tmt", "uau", + 'a', advancedAlloy, + 't', WarpDriveConfig.getModItemStack("IC2", "blockMachine2", 0), // Teleporter + 'm', itemHAMachine, + 'u', mfsu); + + if (WarpDriveConfig.isOpenComputersLoaded) { + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(WarpDrive.blockShipController), false, new Object[] { "aha", "cmc", "apa", // With OC Adapter + 'a', advancedAlloy, + 'm', itemHAMachine, + 'c', "circuitAdvanced", + 'h', crystalmemory, + 'p', WarpDriveConfig.getModItemStack("OpenComputers", "adapter", -1)})); + } else if (WarpDriveConfig.isComputerCraftLoaded) { + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(WarpDrive.blockShipController), false, new Object[] { "aha", "cmc", "apa", // With CC Modem + 'a', advancedAlloy, + 'm', itemHAMachine, + 'c', "circuitAdvanced", + 'h', crystalmemory, + 'p', WarpDriveConfig.getModItemStack("ComputerCraft", "CC-Cable", 1)})); + } else { + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(WarpDrive.blockShipController), false, new Object[] { "aha", "cmc", "aca", + 'a', advancedAlloy, + 'm', itemHAMachine, + 'c', "circuitAdvanced", + 'h', crystalmemory})); + } + + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(WarpDrive.blockRadar), false, new Object[] { "afa", "cmc", "aca", + 'a', advancedAlloy, + 'm', itemHAMachine, + 'c', "circuitAdvanced", + 'f', WarpDriveConfig.getModItemStack("IC2", "itemFreq", -1)})); + + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(WarpDrive.blockWarpIsolation), false, new Object[] { "sls", "lml", "sls", + 's', "plateDenseSteel", + 'l', "plateDenseLead", + 'm', itemHAMachine})); + + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(WarpDrive.blockAirGenerator), false, new Object[] { "lel", "vmv", "lcl", + 'l', Blocks.leaves, + 'm', WarpDriveConfig.getModItemStack("IC2", "blockMachine", 0), + 'c', "circuitBasic", + 'e', WarpDriveConfig.getModItemStack("IC2", "blockMachine", 5), // Compressor + 'v', WarpDriveConfig.getModItemStack("IC2", "reactorVent", -1)})); + + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(WarpDrive.blockLaser), false, new Object[] { "aca", "cmc", "ala", + 'm', advancedMachine, + 'a', advancedAlloy, + 'c', "circuitAdvanced", + 'l', WarpDriveConfig.getModItemStack("IC2", "itemToolMiningLaser", -1)})); + + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(WarpDrive.blockMiningLaser), false, new Object[] { "pcp", "pap", "plp", + 'c', "circuitAdvanced", + 'p', advancedAlloy, + 'a', WarpDriveConfig.getModItemStack("IC2", "blockMachine2", 11), // Advanced Miner + 'l', WarpDrive.blockLaser})); + + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(WarpDrive.blockLaserMedium), false, new Object[] { "efe", "aca", "ama", + 'c', "circuitAdvanced", + 'a', advancedAlloy, + 'f', fiberGlassCable, + 'e', energiumDust, + 'm', mfe})); + + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(WarpDrive.blockLift), false, new Object[] { "aca", "ama", "aea", + 'c', "circuitAdvanced", + 'a', advancedAlloy, + 'm', magnetizer, + 'e', energiumDust})); + + GameRegistry.addRecipe(new ItemStack(WarpDrive.blockIridium), "iii", "iii", "iii", + 'i', iridiumAlloy); + + GameRegistry.addShapelessRecipe(new ItemStack(iridiumAlloy.getItem(), 9), new ItemStack(WarpDrive.blockIridium)); + + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(WarpDrive.blockLaserCamera), false, new Object[] { "ala", "sss", "aca", + 'a', advancedAlloy, + 's', "circuitAdvanced", + 'l', WarpDrive.blockLaser, + 'c', WarpDrive.blockCamera})); + + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(WarpDrive.blockCamera), false, new Object[] { "aed", "cma", "aga", + 'a', advancedAlloy, + 'e', WarpDriveConfig.getModItemStack("IC2", "itemRecipePart", 1), // Electric Motor + 'd', "gemDiamond", + 'c', crystalmemory, + 'm', advancedMachine, + 'g', WarpDriveConfig.getModItemStack("IC2", "itemCable", 2)})); + + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(WarpDrive.blockMonitor), false, new Object[] { "ala", "aca", "aga", + 'a', advancedAlloy, + 'l', Blocks.redstone_lamp, + 'c', "circuitAdvanced", + 'g', "paneGlassColorless" })); + + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(WarpDrive.blockShipScanner), false, new Object[] { "ici", "isi", "mcm", + 'm', mfsu, + 'i', iridiumAlloy, + 'c', "circuitAdvanced", + 's', WarpDriveConfig.getModItemStack("IC2", "blockMachine2", 7) })); // Scanner + + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(WarpDrive.blockLaserTreeFarm), false, new Object[] { "awa", "cmc", "asa", + 'a', advancedAlloy, + 'c', "circuitAdvanced", + 'w', "logWood", + 'm', WarpDrive.blockMiningLaser, + 's', WarpDriveConfig.getModItemStack("IC2", "itemToolChainsaw", -1) })); + + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(WarpDrive.blockTransporter), false, new Object[] { "aea", "ctc", "ama", + 'a', advancedAlloy, + 'e', Items.ender_pearl, + 'c', "circuitAdvanced", + 'm', advancedMachine, + 't', WarpDriveConfig.getModItemStack("IC2", "blockMachine2", 0) })); // Teleporter + + // IC2 is loaded for this recipe set + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(WarpDrive.itemIC2reactorLaserFocus), false, new Object[] { "a a", " d ", "a a", + 'a', advancedAlloy, + 'd', "gemDiamond" })); + + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(WarpDrive.blockIC2reactorLaserMonitor), false, new Object[] { "pdp", "dmd", "pdp", + 'p', advancedAlloy, + 'd', "gemDiamond", + 'm', mfe })); + + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(WarpDrive.blockCloakingCore), false, new Object[] { "ici", "cmc", "igi", + 'i', WarpDrive.blockIridium, + 'c', WarpDrive.blockCloakingCoil, + 'm', WarpDrive.blockHighlyAdvancedMachine, + 'g', "circuitAdvanced" })); + + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(WarpDrive.blockCloakingCoil), false, new Object[] { "iai", "ccc", "iai", + 'i', iridiumAlloy, + 'c', WarpDriveConfig.getModItemStack("IC2", "itemRecipePart", 0), // Coil + 'a', advancedAlloy })); + + GameRegistry.addRecipe(new ItemStack(WarpDrive.blockHighlyAdvancedMachine), "iii", "imi", "iii", + 'i', iridiumAlloy, + 'm', advancedMachine); + } +} diff --git a/src/main/java/cr0s/warpdrive/config/WarpDriveConfig.java b/src/main/java/cr0s/warpdrive/config/WarpDriveConfig.java index fd80faff..d14cf340 100644 --- a/src/main/java/cr0s/warpdrive/config/WarpDriveConfig.java +++ b/src/main/java/cr0s/warpdrive/config/WarpDriveConfig.java @@ -38,7 +38,7 @@ public class WarpDriveConfig { // structures "structures-default.xml", "structures-netherores.xml", }; - + /* * The variables which store whether or not individual mods are loaded */ @@ -54,30 +54,30 @@ public class WarpDriveConfig { public static boolean isOpenComputersLoaded = false; public static boolean isThermalExpansionLoaded = false; public static boolean isAdvancedRepulsionSystemsLoaded = false; - + // ForgeMultipart (microblocks) support public static Method forgeMultipart_helper_createTileFromNBT = null; public static Method forgeMultipart_helper_sendDescPacket = null; public static Method forgeMultipart_tileMultipart_onChunkLoad = null; - + public static ItemStack IC2_air; public static ItemStack IC2_empty; public static ItemStack IC2_rubberWood; public static ItemStack IC2_Resin; public static Item IC2_fluidCell; public static Block CC_Computer, CC_peripheral, CCT_Turtle, CCT_Expanded, CCT_Advanced; - + public static ItemStack GT_Ores, GT_Granite, GT_Machine; public static ItemStack IC2_solarPanel; public static int AS_Turbine, AS_deuteriumCell; public static int ICBM_Machine, ICBM_Missile, ICBM_Explosive; public static Item GS_ultimateLappack; public static ArrayList forceFieldBlocks; - + public static ArrayList minerOres, minerLogs, minerLeaves, scannerIgnoreBlocks; public static ArrayList spaceHelmets, jetpacks; public static ArrayList commonWorldGenOres; - + // Mod configuration (see loadWarpDriveConfig() for comments/definitions) // General public static int G_SPACE_BIOME_ID = 95; @@ -90,20 +90,20 @@ public class WarpDriveConfig { public static int G_ENTITY_SPHERE_GENERATOR_ID = 241; public static int G_ENTITY_STAR_CORE_ID = 242; public static int G_ENTITY_CAMERA_ID = 243; - + public static final int LUA_SCRIPTS_NONE = 0; public static final int LUA_SCRIPTS_TEMPLATES = 1; public static final int LUA_SCRIPTS_ALL = 2; public static int G_LUA_SCRIPTS = LUA_SCRIPTS_ALL; public static String G_SCHEMALOCATION = "warpDrive_schematics"; public static int G_BLOCKS_PER_TICK = 3500; - + public static boolean RECIPES_ENABLE_IC2 = true; public static boolean RECIPES_ENABLE_HARD_IC2 = false; public static boolean RECIPES_ENABLE_VANILLA = false; public static boolean RECIPES_ENABLE_MIXED = false; - - // logging + + // Logging public static boolean LOGGING_JUMP = false; public static boolean LOGGING_ENERGY = false; public static boolean LOGGING_EFFECTS = false; @@ -119,11 +119,11 @@ public class WarpDriveConfig { public static boolean LOGGING_RADAR = false; public static boolean LOGGING_BREATHING = false; public static boolean LOGGING_WORLDGEN = false; - - // Transition planes + + // Planets public static Planet[] PLANETS = null; - - // Warp Drive Core + + // Ship public static int SHIP_MAX_ENERGY_STORED = 100000000; public static int SHIP_NORMALJUMP_ENERGY_PER_BLOCK = 10; public static int SHIP_NORMALJUMP_ENERGY_PER_DISTANCE = 100; @@ -145,31 +145,31 @@ public class WarpDriveConfig { public static int SHIP_CORE_ISOLATION_UPDATE_INTERVAL_SECONDS = 10; public static String[] SHIP_VOLUME_UNLIMITED_PLAYERNAMES = { "notch", "someone" }; public static boolean SHIP_WARMUP_SICKNESS = true; - - // Warp Radar + + // Radar public static int RADAR_MAX_ENERGY_STORED = 100000000; // 100kk eU public static int RADAR_MAX_ISOLATION_RANGE = 2; public static int RADAR_MIN_ISOLATION_BLOCKS = 5; public static int RADAR_MAX_ISOLATION_BLOCKS = 132; public static double RADAR_MIN_ISOLATION_EFFECT = 0.12; public static double RADAR_MAX_ISOLATION_EFFECT = 1.00; - + // Ship Scanner public static int SS_MAX_ENERGY_STORED = 500000000; public static int SS_ENERGY_PER_BLOCK_SCAN = 100; // eU per block of ship volume // (including air) public static int SS_ENERGY_PER_BLOCK_DEPLOY = 5000; public static int SS_MAX_DEPLOY_RADIUS_BLOCKS = 50; - - // Particle Booster + + // Laser medium public static int LASER_MEDIUM_MAX_ENERGY_STORED = 100000; - + // Laser Emitter public static int LASER_CANNON_MAX_MEDIUMS_COUNT = 10; public static int LASER_CANNON_MAX_LASER_ENERGY = 4000000; public static int LASER_CANNON_EMIT_FIRE_DELAY_TICKS = 20 * 3; public static int LASER_CANNON_EMIT_SCAN_DELAY_TICKS = 10; - + public static double LASER_CANNON_BOOSTER_BEAM_ENERGY_EFFICIENCY = 0.60D; public static int LASER_CANNON_ENERGY_LOSS_PER_BLOCK = 5000; public static int LASER_CANNON_ENTITY_HIT_SET_ON_FIRE_SECONDS = 100; @@ -179,7 +179,7 @@ public class WarpDriveConfig { public static float LASER_CANNON_ENTITY_HIT_EXPLOSION_BASE_STRENGTH = 4.0F; public static int LASER_CANNON_ENTITY_HIT_EXPLOSION_ENERGY_PER_STRENGTH = 125000; public static float LASER_CANNON_ENTITY_HIT_EXPLOSION_MAX_STRENGTH = 4.0F; - + public static int LASER_CANNON_BLOCK_HIT_ENERGY = 70000; public static int LASER_CANNON_BLOCK_HIT_ENERGY_PER_BLOCK_RESISTANCE = 1000; public static int LASER_CANNON_BLOCK_HIT_ENERGY_PER_DISTANCE = 10; @@ -187,8 +187,8 @@ public class WarpDriveConfig { public static float LASER_CANNON_BLOCK_HIT_EXPLOSION_BASE_STRENGTH = 8.0F; public static int LASER_CANNON_BLOCK_HIT_EXPLOSION_ENERGY_PER_STRENGTH = 125000; public static float LASER_CANNON_BLOCK_HIT_EXPLOSION_MAX_STRENGTH = 100F; - - // Mining Laser + + // Mining laser // BuildCraft quarry values for reference // - harvesting one block is 60 MJ/block = 600 RF/block = ~145 EU/block // - maximum speed is 3.846 ticks per blocks @@ -215,11 +215,11 @@ public class WarpDriveConfig { public static double MINING_LASER_SILKTOUCH_ENERGY_FACTOR = 1.5; public static double MINING_LASER_SILKTOUCH_DEUTERIUM_L = 1.0; public static double MINING_LASER_FORTUNE_ENERGY_FACTOR = 1.5; - + // Tree farm public static int TREE_FARM_MIN_RADIUS = 5; public static int TREE_FARM_MAX_RADIUS = 16; - + // Cloaking public static int CLOAKING_MAX_ENERGY_STORED = 500000000; public static int CLOAKING_COIL_CAPTURE_BLOCKS = 5; @@ -227,43 +227,43 @@ public class WarpDriveConfig { public static int CLOAKING_TIER1_ENERGY_PER_BLOCK = 32; public static int CLOAKING_TIER2_ENERGY_PER_BLOCK = 128; public static int CLOAKING_FIELD_REFRESH_INTERVAL_SECONDS = 3; - + // Air generator public static int AIRGEN_ENERGY_PER_CANISTER = 20; public static int AIRGEN_ENERGY_PER_NEWAIRBLOCK = 12; public static int AIRGEN_ENERGY_PER_EXISTINGAIRBLOCK = 4; public static int AIRGEN_MAX_ENERGY_STORED = 4000; public static int AIRGEN_AIR_GENERATION_TICKS = 40; - + // IC2 Reactor monitor public static int IC2_REACTOR_MAX_ENERGY_STORED = 1000000; public static double IC2_REACTOR_ENERGY_PER_HEAT = 2; public static int IC2_REACTOR_COOLING_INTERVAL_TICKS = 10; - + // Transporter public static int TRANSPORTER_MAX_ENERGY = 1000000; public static boolean TRANSPORTER_USE_RELATIVE_COORDS = true; public static double TRANSPORTER_ENERGY_PER_BLOCK = 100.0; public static double TRANSPORTER_MAX_BOOST_MUL = 4.0; - - // Enantiomorphic Power reactor + + // Enantiomorphic power reactor public static int ENAN_REACTOR_MAX_ENERGY_STORED = 100000000; public static int ENAN_REACTOR_UPDATE_INTERVAL_TICKS = 5; public static int ENAN_REACTOR_MAX_LASERS_PER_SECOND = 6; - + // Power store public static int ENERGY_BANK_MAX_ENERGY_STORED = 1000000; - - // Laser Lift + + // Laser lift public static int LIFT_MAX_ENERGY_STORED = 2400; public static int LIFT_ENERGY_PER_ENTITY = 800; public static int LIFT_UPDATE_INTERVAL_TICKS = 10; - - // Chunk Loader + + // Chunk loader public static int CL_MAX_ENERGY = 1000000; public static int CL_MAX_DISTANCE = 2; public static int CL_RF_PER_CHUNKTICK = 320; - + public static Block getModBlock(final String mod, final String id) { try { return GameRegistry.findBlock(mod, id); @@ -273,7 +273,7 @@ public class WarpDriveConfig { } return null; } - + public static ItemStack getModItemStack(final String mod, final String id, final int meta) { try { ItemStack item = new ItemStack((Item) Item.itemRegistry.getObject(mod + ":" + id)); @@ -285,24 +285,24 @@ public class WarpDriveConfig { WarpDrive.logger.info("Failed to get mod item for " + mod + ":" + id + ":" + meta); } return null; - } - - public static void preInit(final String stringConfigDirectory) { + } + + public static void onFMLpreInitialization(final String stringConfigDirectory) { // create mod folder configDirectory = new File(stringConfigDirectory, WarpDrive.MODID); configDirectory.mkdir(); if (!configDirectory.isDirectory()) { throw new RuntimeException("Unable to create config directory " + configDirectory); } - + // read configuration file loadWarpDriveConfig(new File(configDirectory, WarpDrive.MODID + ".cfg")); } - + public static void loadWarpDriveConfig(File file) { Configuration config = new Configuration(file); config.load(); - + // General G_SPACE_BIOME_ID = clamp(Integer.MIN_VALUE, Integer.MAX_VALUE, config.get("general", "space_biome_id", G_SPACE_BIOME_ID, "Space biome ID").getInt()); @@ -317,7 +317,7 @@ public class WarpDriveConfig { G_SPACE_WORLDBORDER_BLOCKS = clamp(0, 3000000, config.get("general", "space_worldborder_blocks", G_SPACE_WORLDBORDER_BLOCKS, "World border applied to hyperspace & space, set to 0 to disable it").getInt()); - + G_ENTITY_JUMP_ID = clamp(Integer.MIN_VALUE, Integer.MAX_VALUE, config.get("general", "entity_jump_id", G_ENTITY_JUMP_ID, "Entity jump ID").getInt()); G_ENTITY_SPHERE_GENERATOR_ID = clamp(Integer.MIN_VALUE, Integer.MAX_VALUE, @@ -326,7 +326,7 @@ public class WarpDriveConfig { config.get("general", "entity_star_core_id", G_ENTITY_STAR_CORE_ID, "Entity star core ID").getInt()); G_ENTITY_CAMERA_ID = clamp(Integer.MIN_VALUE, Integer.MAX_VALUE, config.get("general", "entity_camera_id", G_ENTITY_CAMERA_ID, "Entity camera ID").getInt()); - + G_LUA_SCRIPTS = clamp(0, 2, config.get("general", "lua_scripts", G_LUA_SCRIPTS, "LUA scripts to load when connecting machines: 0 = none, 1 = templates in a subfolder, 2 = ready to roll (templates are still provided)").getInt()); @@ -334,14 +334,14 @@ public class WarpDriveConfig { G_BLOCKS_PER_TICK = clamp(100, 100000, config.get("general", "blocks_per_tick", G_BLOCKS_PER_TICK, "Number of blocks to move per ticks, too high will cause lag spikes on ship jumping or deployment, too low may break the ship wirings").getInt()); - + // Recipes RECIPES_ENABLE_VANILLA = config.get("recipes", "enable_vanilla", RECIPES_ENABLE_VANILLA, "Vanilla recipes by DarkholmeTenk").getBoolean(false); RECIPES_ENABLE_IC2 = config.get("recipes", "enable_ic2", RECIPES_ENABLE_IC2, "Original recipes based on IndustrialCrat2 by Cr0s").getBoolean(true); RECIPES_ENABLE_HARD_IC2 = config.get("recipes", "enable_hard_ic2", RECIPES_ENABLE_HARD_IC2, "Harder recipes based on IC2 by YuRaNnNzZZ").getBoolean(false); RECIPES_ENABLE_MIXED = config.get("recipes", "enable_mixed", RECIPES_ENABLE_MIXED, "Mixed recipes for Lem'ADEC's packs (currently requires at least AppliedEnergistics, Extracells, AtomicScience, IndustrialCraft2, GraviSuite and ThermalExpansion").getBoolean(false); - + // Logging LOGGING_JUMP = config.get("logging", "enable_jump_debugLogs", LOGGING_JUMP, "Detailled jump logs to help debug the mod, enable it before reporting a bug").getBoolean(false); LOGGING_ENERGY = config.get("logging", "enable_energy_debugLogs", LOGGING_ENERGY, "Detailled energy logs to help debug the mod, enable it before reporting a bug").getBoolean(false); @@ -365,18 +365,18 @@ public class WarpDriveConfig { LOGGING_RADAR = config.get("logging", "enable_radar_logs", LOGGING_RADAR, "Detailled radar logs to help debug the mod, enable it before reporting a bug").getBoolean(false); LOGGING_BREATHING = config.get("logging", "enable_breathing_logs", LOGGING_BREATHING, "Detailled breathing logs to help debug the mod, enable it before reporting a bug").getBoolean(false); LOGGING_WORLDGEN = config.get("logging", "enable_worldgen_logs", LOGGING_WORLDGEN, "Detailled world generation logs to help debug the mod, enable it before reporting a bug").getBoolean(false); - + // Planets config.addCustomCategoryComment("planets", "Planets are other dimensions connected through the Space dimension. Default is overworld with 100k radius.\n" + "Each planet orbit is square shaped and defined as a list of 7 integers (all measured in blocks)."); - + ConfigCategory cat = config.getCategory("planets"); String[] planetsName = cat.getValues().keySet().toArray(new String[0]); if (planetsName.length == 0) { planetsName = new String[] { "overworld" }; } - + int[] defaultPlanet = { 0, 0, 0, 100000, 100000, 0, 0 }; // 30000000 is Minecraft limit for SetBlock PLANETS = new Planet[planetsName.length]; int index = 0; @@ -394,7 +394,7 @@ public class WarpDriveConfig { } // FIXME: check planets aren't overlapping // We're not checking invalid dimension id, so they can be pre-allocated (see MystCraft) - + // Ship SHIP_MAX_ENERGY_STORED = clamp(0, Integer.MAX_VALUE, config.get("ship", "max_energy_stored", SHIP_MAX_ENERGY_STORED, "Maximum energy storage").getInt()); @@ -408,10 +408,10 @@ public class WarpDriveConfig { config.get("ship", "hyperjump_energy_per_block", SHIP_HYPERJUMP_ENERGY_PER_BLOCK).getInt()); SHIP_TELEPORT_ENERGY_PER_ENTITY = clamp(0, Integer.MAX_VALUE, config.get("ship", "teleport_energy_per_entity", SHIP_TELEPORT_ENERGY_PER_ENTITY).getInt()); - + SHIP_MAX_JUMP_DISTANCE = clamp(0, 30000000, config.get("ship", "max_jump_distance", SHIP_MAX_JUMP_DISTANCE, "Maximum jump length value in blocks").getInt()); - + SHIP_VOLUME_MAX_ON_PLANET_SURFACE = clamp(0, 10000000, config.get("ship", "volume_max_on_planet_surface", SHIP_VOLUME_MAX_ON_PLANET_SURFACE, "Maximum ship mass (in blocks) to jump on earth").getInt()); @@ -420,14 +420,14 @@ public class WarpDriveConfig { "Minimum ship mass (in blocks) to enter or exit hyperspace without a jumpgate").getInt()); SHIP_VOLUME_UNLIMITED_PLAYERNAMES = config.get("ship", "volume_unlimited_playernames", SHIP_VOLUME_UNLIMITED_PLAYERNAMES, "List of player names which have unlimited block counts to their ship").getStringList(); - + SHIP_MAX_SIDE_SIZE = clamp(0, 30000000, config.get("ship", "max_side_size", SHIP_MAX_SIDE_SIZE, "Maximum ship size on each axis in blocks").getInt()); SHIP_COLLISION_TOLERANCE_BLOCKS = clamp(0, 30000000, config.get("ship", "collision_tolerance_blocks", SHIP_COLLISION_TOLERANCE_BLOCKS, "Tolerance in block in case of collision before causing damages...").getInt()); SHIP_COOLDOWN_INTERVAL_SECONDS = clamp(0, 3600, config.get("ship", "cooldown_interval_seconds", SHIP_COOLDOWN_INTERVAL_SECONDS, "Cooldown seconds to wait after jumping").getInt()); - + SHIP_SHORTJUMP_THRESHOLD_BLOCKS = clamp(0, 30000000, config.get("ship", "shortjump_threhold_blocs", SHIP_SHORTJUMP_THRESHOLD_BLOCKS, "Short jump definition").getInt()); SHIP_SHORTJUMP_WARMUP_SECONDS = clamp(0, 3600, @@ -437,53 +437,53 @@ public class WarpDriveConfig { SHIP_WARMUP_RANDOM_TICKS = clamp(10, 200, config.get("ship", "warmup_random_ticks", SHIP_WARMUP_RANDOM_TICKS, "Random variation added to warmup (measured in ticks)").getInt()); SHIP_WARMUP_SICKNESS = config.get("ship", "warmup_sickness", true, "Enable warp sickness during warmup").getBoolean(true); - + SHIP_CORE_REGISTRY_UPDATE_INTERVAL_SECONDS = clamp(0, 300, config.get("ship", "core_registry_update_interval", SHIP_CORE_REGISTRY_UPDATE_INTERVAL_SECONDS, "(measured in seconds)").getInt()); SHIP_CORE_ISOLATION_UPDATE_INTERVAL_SECONDS = clamp(0, 300, config.get("ship", "core_isolation_update_interval", SHIP_CORE_ISOLATION_UPDATE_INTERVAL_SECONDS, "(measured in seconds)").getInt()); SHIP_CONTROLLER_UPDATE_INTERVAL_SECONDS = clamp(0, 300, config.get("ship", "controller_update_interval", SHIP_CONTROLLER_UPDATE_INTERVAL_SECONDS, "(measured in seconds)").getInt()); - + // Radar RADAR_MAX_ENERGY_STORED = clamp(0, Integer.MAX_VALUE, config.get("radar", "max_energy_stored", RADAR_MAX_ENERGY_STORED).getInt()); RADAR_MAX_ISOLATION_RANGE = clamp(2, 8, config.get("radar", "max_isolation_range", RADAR_MAX_ISOLATION_RANGE, "radius around core where isolation blocks count (2 to 8), higher is lagger").getInt()); - + RADAR_MIN_ISOLATION_BLOCKS = clamp(0, 20, config.get("radar", "min_isolation_blocks", RADAR_MIN_ISOLATION_BLOCKS, "number of isolation blocks required to get some isolation (0 to 20)").getInt()); RADAR_MAX_ISOLATION_BLOCKS = clamp(5, 100, config.get("radar", "max_isolation_blocks", RADAR_MAX_ISOLATION_BLOCKS, "number of isolation blocks required to reach maximum effect (5 to 100)").getInt()); - + RADAR_MIN_ISOLATION_EFFECT = clamp(0.01D, 0.95D, config.get("radar", "min_isolation_effect", RADAR_MIN_ISOLATION_EFFECT, "isolation effect achieved with min number of isolation blocks (0.01 to 0.95)").getDouble(0.12D)); RADAR_MAX_ISOLATION_EFFECT = clamp(0.01D, 1.0D, config.get("radar", "max_isolation_effect", RADAR_MAX_ISOLATION_EFFECT, "isolation effect achieved with max number of isolation blocks (0.01 to 1.00)").getDouble(1.00D)); - + // Ship Scanner SS_MAX_ENERGY_STORED = clamp(1, Integer.MAX_VALUE, config.get("ship_scanner", "max_energy_stored", SS_MAX_ENERGY_STORED, "Maximum energy storage").getInt()); - + SS_ENERGY_PER_BLOCK_SCAN = config.get("ship_scanner", "energy_per_block_when_scanning", SS_ENERGY_PER_BLOCK_SCAN, "Energy consummed per block when scanning a ship (use -1 to consume everything)").getInt(); if (SS_ENERGY_PER_BLOCK_SCAN != -1) { SS_ENERGY_PER_BLOCK_SCAN = clamp(1, SS_MAX_ENERGY_STORED, SS_ENERGY_PER_BLOCK_SCAN); } - + SS_ENERGY_PER_BLOCK_DEPLOY = config.get("ship_scanner", "energy_per_block_when_deploying", SS_ENERGY_PER_BLOCK_DEPLOY, "Energy consummed per block when deploying a ship (use -1 to consume everything)").getInt(); if (SS_ENERGY_PER_BLOCK_DEPLOY != -1) { SS_ENERGY_PER_BLOCK_DEPLOY = clamp(1, SS_MAX_ENERGY_STORED, SS_ENERGY_PER_BLOCK_DEPLOY); } - + SS_MAX_DEPLOY_RADIUS_BLOCKS = clamp(5, 150, config.get("ship_scanner", "max_deploy_radius_blocks", SS_MAX_DEPLOY_RADIUS_BLOCKS, "Max distance from ship scanner to ship core, measured in blocks (5-150)").getInt()); - + // Laser medium LASER_MEDIUM_MAX_ENERGY_STORED = clamp(1, Integer.MAX_VALUE, config.get("laser_medium", "max_energy_stored", LASER_MEDIUM_MAX_ENERGY_STORED).getInt()); - + // Laser cannon LASER_CANNON_MAX_MEDIUMS_COUNT = clamp(1, 64, config.get("laser_cannon", "max_mediums_count", LASER_CANNON_MAX_MEDIUMS_COUNT).getInt()); @@ -493,19 +493,19 @@ public class WarpDriveConfig { config.get("laser_cannon", "emit_fire_delay_ticks", LASER_CANNON_EMIT_FIRE_DELAY_TICKS, "Delay while booster beams are accepted, before actually shooting").getInt()); LASER_CANNON_EMIT_SCAN_DELAY_TICKS = clamp(1, 100, config.get("laser_cannon", "emit_scan_delay_ticks", LASER_CANNON_EMIT_SCAN_DELAY_TICKS, "Delay while booster beams are accepted, before actually scanning").getInt()); - + LASER_CANNON_BOOSTER_BEAM_ENERGY_EFFICIENCY = clamp(0.01D, 10.0D, config.get("laser_cannon", "booster_beam_energy_efficiency", LASER_CANNON_BOOSTER_BEAM_ENERGY_EFFICIENCY).getDouble(0.6D)); LASER_CANNON_ENERGY_LOSS_PER_BLOCK = clamp(1, LASER_CANNON_MAX_LASER_ENERGY / 10, config.get("laser_cannon", "energy_loss_per_block", LASER_CANNON_ENERGY_LOSS_PER_BLOCK).getInt()); - + LASER_CANNON_ENTITY_HIT_SET_ON_FIRE_SECONDS = clamp(0, 300, config.get("laser_cannon", "entity_hit_set_on_fire_seconds", LASER_CANNON_ENTITY_HIT_SET_ON_FIRE_SECONDS).getInt()); LASER_CANNON_ENTITY_HIT_ENERGY_PER_DAMAGE = clamp(0, LASER_CANNON_MAX_LASER_ENERGY, config.get("laser_cannon", "entity_hit_energy_per_damage", LASER_CANNON_ENTITY_HIT_ENERGY_PER_DAMAGE).getInt()); LASER_CANNON_ENTITY_HIT_MAX_DAMAGE = clamp(0, Integer.MAX_VALUE, config.get("laser_cannon", "entity_hit_max_damage", LASER_CANNON_ENTITY_HIT_MAX_DAMAGE).getInt()); - + LASER_CANNON_ENTITY_HIT_ENERGY_THRESHOLD_FOR_EXPLOSION = clamp(0, Integer.MAX_VALUE, config.get("laser_cannon", "entity_hit_energy_threshold_for_explosion", LASER_CANNON_ENTITY_HIT_ENERGY_THRESHOLD_FOR_EXPLOSION, "Minimum energy to cause explosion effect").getInt()); LASER_CANNON_ENTITY_HIT_EXPLOSION_BASE_STRENGTH = (float) clamp(0.0D, 100.0D, @@ -514,14 +514,14 @@ public class WarpDriveConfig { config.get("laser_cannon", "entity_hit_explosion_energy_per_strength", LASER_CANNON_ENTITY_HIT_EXPLOSION_ENERGY_PER_STRENGTH, "Energy per added explosion strength").getInt()); LASER_CANNON_ENTITY_HIT_EXPLOSION_MAX_STRENGTH = (float) clamp(0.0D, 1000.0D, config.get("laser_cannon", "entity_hit_explosion_max_strength", LASER_CANNON_ENTITY_HIT_EXPLOSION_MAX_STRENGTH, "Maximum explosion strength, set to 0 to disable explosion completly").getDouble()); - + LASER_CANNON_BLOCK_HIT_ENERGY = clamp(0, Integer.MAX_VALUE, config.get("laser_cannon", "block_hit_energy", LASER_CANNON_BLOCK_HIT_ENERGY, "Base energy consummed from hitting a block").getInt()); LASER_CANNON_BLOCK_HIT_ENERGY_PER_BLOCK_RESISTANCE = clamp(0, Integer.MAX_VALUE, config.get("laser_cannon", "block_hit_energy_per_block_resistance", LASER_CANNON_BLOCK_HIT_ENERGY_PER_BLOCK_RESISTANCE, "Energy consummed per explosive resistance points").getInt()); LASER_CANNON_BLOCK_HIT_ENERGY_PER_DISTANCE = clamp(0, Integer.MAX_VALUE, config.get("laser_cannon", "block_hit_energy_per_distance", LASER_CANNON_BLOCK_HIT_ENERGY_PER_DISTANCE, "Energy consummed per distance travelled").getInt()); - + LASER_CANNON_BLOCK_HIT_EXPLOSION_RESISTANCE_THRESHOLD = clamp(0.0D, 1000000.0D, config.get("laser_cannon", "block_hit_explosion_resistance_threshold", LASER_CANNON_BLOCK_HIT_EXPLOSION_RESISTANCE_THRESHOLD, "Block explosion resistance threshold to cause an explosion").getDouble()); LASER_CANNON_BLOCK_HIT_EXPLOSION_BASE_STRENGTH = (float) clamp(0.0D, 1000.0D, @@ -530,20 +530,20 @@ public class WarpDriveConfig { config.get("laser_cannon", "block_hit_explosion_energy_per_strength", LASER_CANNON_BLOCK_HIT_EXPLOSION_ENERGY_PER_STRENGTH, "Energy per added explosion strength").getInt()); LASER_CANNON_BLOCK_HIT_EXPLOSION_MAX_STRENGTH = (float) clamp(0.0D, 1000.0D, config.get("laser_cannon", "block_hit_explosion_max_strength", LASER_CANNON_BLOCK_HIT_EXPLOSION_MAX_STRENGTH, "Maximum explosion strength, set to 0 to disable explosion completly").getDouble()); - + // Mining Laser MINING_LASER_MAX_MEDIUMS_COUNT = clamp(1, 64, config.get("mining_laser", "max_mediums_count", MINING_LASER_MAX_MEDIUMS_COUNT).getInt()); MINING_LASER_RADIUS_BLOCKS = clamp(1, 64, config.get("mining_laser", "radius_blocks", MINING_LASER_RADIUS_BLOCKS).getInt()); - + MINING_LASER_WARMUP_DELAY_TICKS = clamp(1, 300, config.get("mining_laser", "warmup_delay_ticks", MINING_LASER_WARMUP_DELAY_TICKS).getInt()); MINING_LASER_SCAN_DELAY_TICKS = clamp(1, 300, config.get("mining_laser", "scan_delay_ticks", MINING_LASER_SCAN_DELAY_TICKS).getInt()); MINING_LASER_MINE_DELAY_TICKS = clamp(1, 300, config.get("mining_laser", "mine_delay_ticks", MINING_LASER_MINE_DELAY_TICKS).getInt()); - + MINING_LASER_PLANET_ENERGY_PER_LAYER = clamp(1, Integer.MAX_VALUE, config.get("mining_laser", "planet_energy_per_layer", MINING_LASER_PLANET_ENERGY_PER_LAYER).getInt()); MINING_LASER_PLANET_ENERGY_PER_BLOCK = clamp(1, Integer.MAX_VALUE, @@ -552,7 +552,7 @@ public class WarpDriveConfig { config.get("mining_laser", "space_energy_per_layer", MINING_LASER_SPACE_ENERGY_PER_LAYER).getInt()); MINING_LASER_SPACE_ENERGY_PER_BLOCK = clamp(1, Integer.MAX_VALUE, config.get("mining_laser", "space_energy_per_block", MINING_LASER_SPACE_ENERGY_PER_BLOCK).getInt()); - + MINING_LASER_ORESONLY_ENERGY_FACTOR = clamp(0.01D, 1000.0D, config.get("mining_laser", "oresonly_energy_factor", MINING_LASER_ORESONLY_ENERGY_FACTOR).getDouble(4.0D)); MINING_LASER_SILKTOUCH_ENERGY_FACTOR = clamp(0.01D, 1000.0D, @@ -561,13 +561,13 @@ public class WarpDriveConfig { config.get("mining_laser", "silktouch_deuterium_l", MINING_LASER_SILKTOUCH_DEUTERIUM_L).getDouble(1.0D)); MINING_LASER_FORTUNE_ENERGY_FACTOR = clamp(0.01D, 1000.0D, config.get("mining_laser", "fortune_energy_factor", MINING_LASER_FORTUNE_ENERGY_FACTOR).getDouble(2.5D)); - + // Tree Farm TREE_FARM_MIN_RADIUS = clamp(1, 30, config.get("tree_farm", "min_radius", TREE_FARM_MIN_RADIUS, "Minimum radius on X and Z axis, measured in blocks").getInt()); TREE_FARM_MAX_RADIUS = clamp(TREE_FARM_MIN_RADIUS, 30, config.get("tree_farm", "max_radius", TREE_FARM_MAX_RADIUS, "Maximum radius on X and Z axis, measured in blocks").getInt()); - + // Cloaking CLOAKING_MAX_ENERGY_STORED = clamp(1, Integer.MAX_VALUE, config.get("cloaking", "max_energy_stored", CLOAKING_MAX_ENERGY_STORED, "Maximum energy storage").getInt()); @@ -581,7 +581,7 @@ public class WarpDriveConfig { config.get("cloaking", "tier2_energy_per_block", CLOAKING_TIER2_ENERGY_PER_BLOCK).getInt()); CLOAKING_FIELD_REFRESH_INTERVAL_SECONDS = clamp(1, 30, config.get("cloaking", "field_refresh_interval_seconds", CLOAKING_FIELD_REFRESH_INTERVAL_SECONDS).getInt()); - + // Air generator AIRGEN_MAX_ENERGY_STORED = clamp(1, Integer.MAX_VALUE, config.get("air_generator", "max_energy_stored", AIRGEN_MAX_ENERGY_STORED).getInt()); @@ -593,7 +593,7 @@ public class WarpDriveConfig { config.get("air_generator", "energy_per_existing_air_block", AIRGEN_ENERGY_PER_EXISTINGAIRBLOCK).getInt()); AIRGEN_AIR_GENERATION_TICKS = clamp(1, 300, config.get("air_generator", "air_generation_ticks", AIRGEN_AIR_GENERATION_TICKS).getInt()); - + // Reactor monitor IC2_REACTOR_MAX_ENERGY_STORED = clamp(1, Integer.MAX_VALUE, config.get("ic2_reactor_laser", "max_energy_stored", IC2_REACTOR_MAX_ENERGY_STORED).getInt()); @@ -601,7 +601,7 @@ public class WarpDriveConfig { config.get("ic2_reactor_laser", "energy_per_heat", IC2_REACTOR_ENERGY_PER_HEAT).getDouble(2)); IC2_REACTOR_COOLING_INTERVAL_TICKS = clamp(0, 1200, config.get("ic2_reactor_laser", "cooling_interval_ticks", IC2_REACTOR_COOLING_INTERVAL_TICKS).getInt()); - + // Transporter TRANSPORTER_MAX_ENERGY = clamp(1, Integer.MAX_VALUE, config.get("transporter", "max_energy", TRANSPORTER_MAX_ENERGY).getInt()); @@ -610,7 +610,7 @@ public class WarpDriveConfig { config.get("transporter", "energy_per_block", TRANSPORTER_ENERGY_PER_BLOCK).getDouble(100.0D)); TRANSPORTER_MAX_BOOST_MUL = clamp(1.0D, 1000.0D, config.get("transporter", "max_boost", TRANSPORTER_MAX_BOOST_MUL).getDouble(4.0)); - + // Enantiomorphic reactor ENAN_REACTOR_MAX_ENERGY_STORED = clamp(1, Integer.MAX_VALUE, config.get("enantiomorphic_reactor", "max_energy_stored", ENAN_REACTOR_MAX_ENERGY_STORED).getInt()); @@ -618,10 +618,10 @@ public class WarpDriveConfig { config.get("enantiomorphic_reactor", "update_interval_ticks", ENAN_REACTOR_UPDATE_INTERVAL_TICKS).getInt()); ENAN_REACTOR_MAX_LASERS_PER_SECOND = clamp(4, 80, config.get("enantiomorphic_reactor", "max_lasers", ENAN_REACTOR_MAX_LASERS_PER_SECOND, "Maximum number of stabiliation laser shots per seconds before loosing effiency").getInt()); - + // Energy bank ENERGY_BANK_MAX_ENERGY_STORED = config.get("energy_bank", "max_energy_stored", ENERGY_BANK_MAX_ENERGY_STORED).getInt(); - + // Lift LIFT_MAX_ENERGY_STORED = clamp(1, Integer.MAX_VALUE, config.get("lift", "max_energy_stored", LIFT_MAX_ENERGY_STORED).getInt()); @@ -629,19 +629,19 @@ public class WarpDriveConfig { config.get("lift", "energy_per_entity", LIFT_ENERGY_PER_ENTITY, "Energy consummed per entity moved").getInt()); LIFT_UPDATE_INTERVAL_TICKS = clamp(1, 60, config.get("lift", "update_interval_ticks", LIFT_UPDATE_INTERVAL_TICKS).getInt()); - + config.save(); } - + public static int clamp(final int min, final int max, final int value) { return Math.min(max, Math.max(value, min)); } - + public static double clamp(final double min, final double max, final double value) { return Math.min(max, Math.max(value, min)); } - - public static void load() { + + public static void onFMLInitialization() { commonWorldGenOres = new ArrayList(); commonWorldGenOres.add(Blocks.iron_ore); commonWorldGenOres.add(Blocks.gold_ore); @@ -649,64 +649,64 @@ public class WarpDriveConfig { commonWorldGenOres.add(Blocks.emerald_ore); commonWorldGenOres.add(Blocks.lapis_ore); commonWorldGenOres.add(Blocks.redstone_ore); - + forceFieldBlocks = new ArrayList(); - + spaceHelmets = new ArrayList(); jetpacks = new ArrayList(); minerOres = new ArrayList(); minerLogs = new ArrayList(); minerLeaves = new ArrayList(); scannerIgnoreBlocks = new ArrayList(); - + isForgeMultipartLoaded = Loader.isModLoaded("ForgeMultipart"); if (isForgeMultipartLoaded) { loadForgeMultipart(); } - + isIndustrialCraft2loaded = Loader.isModLoaded("IC2"); if (isIndustrialCraft2loaded) { loadIC2(); } - + isComputerCraftLoaded = Loader.isModLoaded("ComputerCraft"); if (isComputerCraftLoaded) { loadCC(); } - + isAdvancedSolarPanelLoaded = Loader.isModLoaded("AdvancedSolarPanel"); if (isAdvancedSolarPanelLoaded) { loadASP(); } - + isAtomicScienceLoaded = Loader.isModLoaded("ResonantInduction|Atomic"); if (isAtomicScienceLoaded) { loadAtomicScience(); } - + isMFFSLoaded = Loader.isModLoaded("MFFS"); if (isMFFSLoaded) { loadMFFS(); } - + isGraviSuiteLoaded = Loader.isModLoaded("GraviSuite"); if (isGraviSuiteLoaded) { loadGraviSuite(); } - + isThermalExpansionLoaded = Loader.isModLoaded("ThermalExpansion"); if (isThermalExpansionLoaded) { loadThermalExpansion(); } - + isAdvancedRepulsionSystemsLoaded = Loader.isModLoaded("AdvancedRepulsionSystems"); if (isAdvancedRepulsionSystemsLoaded) { loadAdvancedRepulsionSystems(); } - + isAppliedEnergistics2Loaded = Loader.isModLoaded("appliedenergistics2"); isOpenComputersLoaded = Loader.isModLoaded("OpenComputers"); - + // minerOres.add(WarpDrive.blockIridium); minerOres.add(Blocks.coal_ore); @@ -717,17 +717,17 @@ public class WarpDriveConfig { minerOres.add(Blocks.torch); minerOres.add(Blocks.glowstone); minerOres.add(Blocks.redstone_block); - + // Ignore WarpDrive blocks (which potentially will be duplicated by // cheaters using ship scan/deploy) scannerIgnoreBlocks.add(WarpDrive.blockShipCore); scannerIgnoreBlocks.add(WarpDrive.blockShipController); scannerIgnoreBlocks.add(WarpDrive.blockIridium); - + if (isIndustrialCraft2loaded) { // Metadata: 0 Batbox, 1 MFE, 2 MFSU, 3 LV transformer, 4 MV transformer, 5 HV transformer, 6 EV transformer, 7 CESU scannerIgnoreBlocks.add(Block.getBlockFromName("IC2:blockElectric")); - + // Metadata: 0 Batbox, 1 CESU, 2 MFE, 3 MFSU scannerIgnoreBlocks.add(Block.getBlockFromName("IC2:blockChargepad")); } @@ -745,7 +745,7 @@ public class WarpDriveConfig { scannerIgnoreBlocks.add(t); } } - + public static void postInit() { // read XML files File[] files = configDirectory.listFiles(new FilenameFilter() { @@ -759,15 +759,15 @@ public class WarpDriveConfig { unpackResourceToFolder(defaultXMLfilename, "config", configDirectory); } } - + FillerManager.loadOres(configDirectory); StructureManager.loadStructures(configDirectory); - + LoadOreDict(); - + FillerManager.finishLoading(); } - + private static void LoadOreDict() { String[] oreNames = OreDictionary.getOreNames(); for (String oreName : oreNames) { @@ -795,7 +795,7 @@ public class WarpDriveConfig { } } } - + private static void loadForgeMultipart() { try { Class forgeMultipart_helper = Class.forName("codechicken.multipart.MultipartHelper"); @@ -809,22 +809,22 @@ public class WarpDriveConfig { exception.printStackTrace(); } } - + private static void loadIC2() { try { IC2_solarPanel = getModItemStack("IC2", "blockGenerator", 3); - + spaceHelmets.add(getModItemStack("IC2", "itemArmorHazmatHelmet", -1).getItem()); spaceHelmets.add(getModItemStack("IC2", "itemSolarHelmet", -1).getItem()); spaceHelmets.add(getModItemStack("IC2", "itemArmorNanoHelmet", -1).getItem()); spaceHelmets.add(getModItemStack("IC2", "itemArmorQuantumHelmet", -1).getItem()); - + jetpacks.add(getModItemStack("IC2", "itemArmorJetpack", -1).getItem()); jetpacks.add(getModItemStack("IC2", "itemArmorJetpackElectric", -1).getItem()); - + IC2_empty = getModItemStack("IC2", "itemCellEmpty", -1); IC2_air = getModItemStack("IC2", "itemCellEmpty", 5); - + ItemStack rubberWood = getModItemStack("IC2", "blockRubWood", -1); IC2_Resin = getModItemStack("IC2", "itemHarz", -1); if (rubberWood != null) { @@ -847,14 +847,14 @@ public class WarpDriveConfig { if (ore != null) { commonWorldGenOres.add(Block.getBlockFromItem(ore.getItem())); } - + IC2_fluidCell = getModItemStack("IC2", "itemFluidCell", -1).getItem(); } catch (Exception exception) { WarpDrive.logger.error("Error loading IndustrialCraft2 classes"); exception.printStackTrace(); } } - + private static void loadCC() { try { CC_Computer = getModBlock("ComputerCraft", "CC-Computer"); @@ -867,7 +867,7 @@ public class WarpDriveConfig { exception.printStackTrace(); } } - + private static void loadASP() { try { spaceHelmets.add((Item) Item.itemRegistry.getObject("AdvancedSolarPanel:advanced_solar_helmet")); @@ -879,7 +879,7 @@ public class WarpDriveConfig { isAdvancedSolarPanelLoaded = false; } } - + private static void loadAtomicScience() { try { /* TODO: Does not exist for 1.7 @@ -895,7 +895,7 @@ public class WarpDriveConfig { isAtomicScienceLoaded = false; } } - + private static void loadICBM() { try { /* TODO: Does not exist yet for 1.7 @@ -909,7 +909,7 @@ public class WarpDriveConfig { isICBMLoaded = false; } } - + private static void loadMFFS() { try { forceFieldBlocks.add(Block.getBlockFromName("MFFS:FIXME_field")); // FIXME @@ -920,7 +920,7 @@ public class WarpDriveConfig { isMFFSLoaded = false; } } - + private static void loadGraviSuite() { try { spaceHelmets.add((Item) Item.itemRegistry.getObject("GraviSuite.ultimateSolarHelmet")); // FIXME @@ -933,7 +933,7 @@ public class WarpDriveConfig { isGraviSuiteLoaded = false; } } - + private static void loadThermalExpansion() { try { // TEEnergyCell = @@ -945,10 +945,10 @@ public class WarpDriveConfig { isThermalExpansionLoaded = false; } } - + private static void loadAdvancedRepulsionSystems() { try { - + forceFieldBlocks.add(Block.getBlockFromName("AdvancedRepulsionSystems:field")); } catch (Exception exception) { WarpDrive.logger.error("Error loading AdvancedRepulsionSystems classes"); @@ -956,7 +956,7 @@ public class WarpDriveConfig { isAdvancedRepulsionSystemsLoaded = false; } } - + public static DocumentBuilder getXmlDocumentBuilder() { if (xmlDocumentBuilder == null) { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); @@ -968,30 +968,30 @@ public class WarpDriveConfig { exception.printStackTrace(); } } - + return xmlDocumentBuilder; } - + /* * Copy a default configuration file from the mod's resources to the specified configuration folder */ public static void unpackResourceToFolder(final String filename, final String sourceResourcePath, File targetFolder) { // targetFolder is already created by caller - + String resourceName = sourceResourcePath + "/" + filename; - + File destination = new File(targetFolder, filename); - + try { InputStream inputStream = WarpDrive.class.getClassLoader().getResourceAsStream(resourceName); BufferedOutputStream outputStream = new BufferedOutputStream(new FileOutputStream(destination)); - + byte[] byteBuffer = new byte[Math.max(8192, inputStream.available())]; int bytesRead; while ((bytesRead = inputStream.read(byteBuffer)) >= 0) { outputStream.write(byteBuffer, 0, bytesRead); } - + inputStream.close(); outputStream.close(); } catch (Exception exception) { diff --git a/src/main/java/cr0s/warpdrive/SpaceEventHandler.java b/src/main/java/cr0s/warpdrive/event/LivingHandler.java similarity index 97% rename from src/main/java/cr0s/warpdrive/SpaceEventHandler.java rename to src/main/java/cr0s/warpdrive/event/LivingHandler.java index 52962488..b8a49233 100644 --- a/src/main/java/cr0s/warpdrive/SpaceEventHandler.java +++ b/src/main/java/cr0s/warpdrive/event/LivingHandler.java @@ -1,4 +1,4 @@ -package cr0s.warpdrive; +package cr0s.warpdrive.event; import java.util.HashMap; @@ -17,6 +17,7 @@ import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent; import net.minecraftforge.event.entity.living.LivingFallEvent; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cr0s.warpdrive.WarpDrive; import cr0s.warpdrive.api.IBreathingHelmet; import cr0s.warpdrive.config.WarpDriveConfig; import cr0s.warpdrive.world.SpaceTeleporter; @@ -25,22 +26,22 @@ import cr0s.warpdrive.world.SpaceTeleporter; * * @author Cr0s */ -public class SpaceEventHandler { +public class LivingHandler { private HashMap entity_airBlock; private HashMap player_airTank; private HashMap player_cloakTicks; - + private final int CLOAK_CHECK_TIMEOUT_TICKS = 100; private final int AIR_BLOCK_TICKS = 20; private final int AIR_TANK_TICKS = 300; private final int AIR_DROWN_TICKS = 20; - - public SpaceEventHandler() { + + public LivingHandler() { entity_airBlock = new HashMap(); player_airTank = new HashMap(); player_cloakTicks = new HashMap(); } - + @SubscribeEvent public void onLivingUpdate(LivingUpdateEvent event) { if (FMLCommonHandler.instance().getEffectiveSide().isClient()) { @@ -51,7 +52,7 @@ public class SpaceEventHandler { int x = MathHelper.floor_double(entity.posX); int y = MathHelper.floor_double(entity.posY); int z = MathHelper.floor_double(entity.posZ); - + // Instant kill if entity exceeds world's limit if (WarpDriveConfig.G_SPACE_WORLDBORDER_BLOCKS > 0 && (Math.abs(x) > WarpDriveConfig.G_SPACE_WORLDBORDER_BLOCKS || Math.abs(z) > WarpDriveConfig.G_SPACE_WORLDBORDER_BLOCKS)) { @@ -60,24 +61,24 @@ public class SpaceEventHandler { return; } } - + entity.attackEntityFrom(DamageSource.outOfWorld, 9000); return; } if (entity instanceof EntityPlayerMP) { updatePlayerCloakState(entity); - + // skip players in creative if (((EntityPlayerMP) entity).capabilities.isCreativeMode) { return; } } - + // skip dead or invulnerable entities if (entity.isDead || entity.isEntityInvulnerable()) { return; } - + // If entity is in vacuum, check and start consuming air cells if ( entity.worldObj.provider.dimensionId == WarpDriveConfig.G_SPACE_DIMENSION_ID || entity.worldObj.provider.dimensionId == WarpDriveConfig.G_HYPERSPACE_DIMENSION_ID) { @@ -91,7 +92,7 @@ public class SpaceEventHandler { entity_airBlock.put(entity.getEntityId(), AIR_BLOCK_TICKS); } else if (air <= 1) {// time elapsed => consume air block entity_airBlock.put(entity.getEntityId(), AIR_BLOCK_TICKS); - + int metadata; if (block1.isAssociatedBlock(WarpDrive.blockAir)) { metadata = entity.worldObj.getBlockMetadata(x, y, z); @@ -113,7 +114,7 @@ public class SpaceEventHandler { EntityPlayerMP player = (EntityPlayerMP) entity; String playerName = player.getCommandSenderName(); air = player_airTank.get(playerName); - + boolean hasHelmet = false; ItemStack helmetStack = player.getCurrentArmor(3); if (helmetStack != null) { @@ -154,7 +155,7 @@ public class SpaceEventHandler { } } } - + if (!hasHelmet) { if (air == null) {// new player in space => grace period player_airTank.put(playerName, AIR_TANK_TICKS); @@ -165,7 +166,7 @@ public class SpaceEventHandler { player_airTank.put(playerName, air - 1); } } - + // If player falling down, teleport on earth if (entity.posY < -10.0D) { player.mcServer.getConfigurationManager().transferPlayerToDimension(player, 0, @@ -181,20 +182,20 @@ public class SpaceEventHandler { } } } - + private void updatePlayerCloakState(EntityLivingBase entity) { try { EntityPlayerMP player = (EntityPlayerMP) entity; Integer cloakTicks = player_cloakTicks.get(player.getCommandSenderName()); - + if (cloakTicks == null) { player_cloakTicks.put(player.getCommandSenderName(), 0); return; } - + if (cloakTicks >= CLOAK_CHECK_TIMEOUT_TICKS) { player_cloakTicks.put(player.getCommandSenderName(), 0); - + WarpDrive.cloaks.updatePlayer(player); } else { player_cloakTicks.put(player.getCommandSenderName(), cloakTicks + 1); @@ -203,7 +204,7 @@ public class SpaceEventHandler { e.printStackTrace(); } } - + private static boolean consumeO2(ItemStack[] inventory, EntityPlayerMP entityPlayer) { for (int j = 0; j < inventory.length; ++j) { if (inventory[j] != null && inventory[j] == WarpDriveConfig.IC2_air) { @@ -211,7 +212,7 @@ public class SpaceEventHandler { if (inventory[j].stackSize <= 0) { inventory[j] = null; } - + if (WarpDriveConfig.IC2_empty != null) { // WarpDrive.debugPrint("giveEmptyCell"); ItemStack emptyCell = new ItemStack(WarpDriveConfig.IC2_empty.getItem(), 1, 0); @@ -226,16 +227,16 @@ public class SpaceEventHandler { } return false; } - + @SubscribeEvent - public void livingFall(LivingFallEvent event) { + public void onLivingFall(LivingFallEvent event) { EntityLivingBase entity = event.entityLiving; float distance = event.distance; - + if (entity instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) entity; int check = MathHelper.ceiling_float_int(distance - 3.0F); - + if (check > 0) { if ( (player.getCurrentArmor(0) != null && player.getCurrentArmor(0) == WarpDriveConfig.getModItemStack("IC2", "itemArmorQuantumBoots", -1)) // FIXME cache the value || (player.getCurrentArmor(2) != null && WarpDriveConfig.jetpacks.contains(player.getCurrentArmor(2)))) { diff --git a/src/main/java/cr0s/warpdrive/EventListeners.java b/src/main/java/cr0s/warpdrive/event/WorldHandler.java similarity index 95% rename from src/main/java/cr0s/warpdrive/EventListeners.java rename to src/main/java/cr0s/warpdrive/event/WorldHandler.java index c4b9fb30..ff81176a 100644 --- a/src/main/java/cr0s/warpdrive/EventListeners.java +++ b/src/main/java/cr0s/warpdrive/event/WorldHandler.java @@ -1,17 +1,22 @@ -package cr0s.warpdrive; +package cr0s.warpdrive.event; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.PlayerEvent.PlayerChangedDimensionEvent; import cpw.mods.fml.common.network.FMLNetworkEvent.ClientConnectedToServerEvent; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import cr0s.warpdrive.WarpDrive; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.world.ChunkCoordIntPair; import net.minecraftforge.event.entity.EntityJoinWorldEvent; import net.minecraftforge.event.world.ChunkWatchEvent; import net.minecraftforge.event.world.WorldEvent; -public class EventListeners { +/** +* +* @author LemADEC +*/ +public class WorldHandler { //TODO: register as event receiver public void onChunkLoaded(ChunkWatchEvent event) {