automatically copy out recipe files & cleaned up some old config options
This commit is contained in:
parent
77a74d05fe
commit
677da80e8d
|
@ -1,10 +1,13 @@
|
|||
package net.machinemuse.powersuits.common
|
||||
|
||||
import java.nio.file.{Paths, Files}
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler
|
||||
import cpw.mods.fml.relauncher.Side
|
||||
import net.machinemuse.api.IModularItem
|
||||
import net.machinemuse.api.IPowerModule
|
||||
import net.machinemuse.api.ModuleManager
|
||||
import net.machinemuse.numina.basemod.Numina
|
||||
import net.machinemuse.powersuits.powermodule.armor.BasicPlatingModule
|
||||
import net.machinemuse.powersuits.powermodule.armor.DiamondPlatingModule
|
||||
import net.machinemuse.powersuits.powermodule.armor.EnergyShieldModule
|
||||
|
@ -23,11 +26,13 @@ import net.machinemuse.utils.MuseStringUtils
|
|||
import net.minecraft.creativetab.CreativeTabs
|
||||
import net.minecraftforge.common.config.Configuration
|
||||
import org.lwjgl.input.Keyboard
|
||||
import java.io.File
|
||||
import java.io.{FileOutputStream, FileInputStream, File}
|
||||
import java.util.Arrays
|
||||
import java.util.Collections
|
||||
import java.util.List
|
||||
|
||||
import scala.io.Source
|
||||
|
||||
/**
|
||||
* Initial attempt at storing all tweakable/configurable values in one class.
|
||||
* This got really messy really fast so it's in the process of being
|
||||
|
@ -36,6 +41,37 @@ import java.util.List
|
|||
* @author MachineMuse
|
||||
*/
|
||||
object Config {
|
||||
/**
|
||||
* Called in post-init. Extracts recipes if the configuration value is not found.
|
||||
*/
|
||||
def extractRecipes() = {
|
||||
val key = "Auto-extract recipes"
|
||||
if(!config.hasKey(Configuration.CATEGORY_GENERAL, key) || config.get(Configuration.CATEGORY_GENERAL, key, false).getBoolean) {
|
||||
var found=false
|
||||
if(ModCompatibility.isThermalExpansionLoaded) {
|
||||
found=true
|
||||
//TE
|
||||
copyRecipe("mps-thermalexpansion.recipes")
|
||||
}
|
||||
if (ModCompatibility.isIndustrialCraftLoaded) {
|
||||
found=true
|
||||
//IC2
|
||||
copyRecipe("mps-vanilla.recipes")
|
||||
}
|
||||
if(!found) {
|
||||
//vanilla
|
||||
copyRecipe("mps-thermalexpansion.recipes")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def copyRecipe(inFile:String): Unit = {
|
||||
val src = classOf[CommonProxy].getClassLoader.getResourceAsStream(inFile)
|
||||
val dest = new File(Numina.configDir.toString + "/machinemuse/recipes/" + inFile)
|
||||
if(!dest.exists()) {
|
||||
Files.copy(src, dest.toPath)
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Called in the pre-init phase of initialization, informs Forge that we
|
||||
* want the following blockIDs.
|
||||
|
|
|
@ -3,14 +3,11 @@ package net.machinemuse.powersuits.common;
|
|||
import cpw.mods.fml.common.Loader;
|
||||
import net.machinemuse.api.IModularItem;
|
||||
import net.machinemuse.api.ModuleManager;
|
||||
import net.machinemuse.numina.general.MuseLogger;
|
||||
import net.machinemuse.powersuits.powermodule.armor.ApiaristArmorModule;
|
||||
import net.machinemuse.powersuits.powermodule.armor.HazmatModule;
|
||||
import net.machinemuse.powersuits.powermodule.misc.AirtightSealModule;
|
||||
import net.machinemuse.powersuits.powermodule.misc.ThaumGogglesModule;
|
||||
import net.machinemuse.powersuits.powermodule.tool.GrafterModule;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
@ -59,39 +56,6 @@ public class ModCompatibility {
|
|||
return Config.getConfig().get("Special Modules", "Thaumcraft Goggles Module", defaultval).getBoolean(defaultval);
|
||||
}
|
||||
|
||||
public static boolean vanillaRecipesEnabled() {
|
||||
boolean defaultval = (!isBasicComponentsLoaded()) && (!isIndustrialCraftLoaded());
|
||||
return Config.getConfig().get(Configuration.CATEGORY_GENERAL, "Vanilla Recipes", defaultval).getBoolean(defaultval);
|
||||
}
|
||||
|
||||
private static boolean isAtomicScienceLoaded() {
|
||||
return Loader.isModLoaded("AtomicScience");
|
||||
}
|
||||
|
||||
public static boolean UERecipesEnabled() {
|
||||
boolean defaultval = isBasicComponentsLoaded();
|
||||
return Config.getConfig().get(Configuration.CATEGORY_GENERAL, "Universal Electricity Recipes", defaultval).getBoolean(defaultval);
|
||||
}
|
||||
|
||||
public static boolean IC2RecipesEnabled() {
|
||||
boolean defaultval = isIndustrialCraftLoaded() && (!isGregTechLoaded());
|
||||
return Config.getConfig().get(Configuration.CATEGORY_GENERAL, "IndustrialCraft Recipes", defaultval).getBoolean(defaultval);
|
||||
}
|
||||
|
||||
public static boolean GregTechRecipesEnabled() {
|
||||
boolean defaultval = isGregTechLoaded();
|
||||
return Config.getConfig().get(Configuration.CATEGORY_GENERAL, "Gregtech Recipes", defaultval).getBoolean(defaultval);
|
||||
}
|
||||
|
||||
public static boolean ThermalExpansionRecipesEnabled() {
|
||||
boolean defaultval = isThermalExpansionLoaded();
|
||||
return Config.getConfig().get(Configuration.CATEGORY_GENERAL, "Thermal Expansion Recipes", defaultval).getBoolean(defaultval);
|
||||
}
|
||||
|
||||
public static double getUERatio() {
|
||||
return Config.getConfig().get(Configuration.CATEGORY_GENERAL, "Energy per UEJ", 1.0).getDouble(1.0);
|
||||
}
|
||||
|
||||
public static double getIC2Ratio() {
|
||||
return Config.getConfig().get(Configuration.CATEGORY_GENERAL, "Energy per IC2 EU", 0.4).getDouble(0.4);
|
||||
}
|
||||
|
@ -104,44 +68,10 @@ public class ModCompatibility {
|
|||
return Config.getConfig().get(Configuration.CATEGORY_GENERAL, "Energy per RF", 0.1).getDouble(0.1);
|
||||
}
|
||||
|
||||
// These 2 elements are basically copied from IC2 api
|
||||
private static Class Ic2Items;
|
||||
|
||||
public static ItemStack getIC2Item(String name) {
|
||||
try {
|
||||
if (Ic2Items == null)
|
||||
Ic2Items = Class.forName("ic2.core.Ic2Items");
|
||||
|
||||
Object ret = Ic2Items.getField(name).get(null);
|
||||
|
||||
if (ret instanceof ItemStack) {
|
||||
return ((ItemStack) ret).copy();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
MuseLogger.logError("IC2 API: Call getItem failed for " + name);
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static ItemStack getGregtechItem(int aIndex, int aAmount, int aMeta) {
|
||||
try {
|
||||
return (ItemStack) Class.forName("gregtechmod.api.GregTech_API")
|
||||
.getMethod("getGregTechItem", new Class[]{Integer.TYPE, Integer.TYPE, Integer.TYPE})
|
||||
.invoke(null, Integer.valueOf(aIndex), Integer.valueOf(aAmount), Integer.valueOf(aMeta));
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void registerModSpecificModules() {
|
||||
// Make the IC2 energy ratio show up in config file
|
||||
getBCRatio();
|
||||
// Make the energy ratios show up in config file
|
||||
getIC2Ratio();
|
||||
getRFRatio();
|
||||
getUERatio();
|
||||
|
||||
// Thaumcraft
|
||||
if (isThaumCraftLoaded() && enableThaumGogglesModule()) {
|
||||
|
@ -150,7 +80,7 @@ public class ModCompatibility {
|
|||
|
||||
//IPowerModule module = new MultimeterModule(Collections.singletonList((IModularItem) MPSItems.powerTool()));
|
||||
|
||||
// Atomic Science
|
||||
// Hazmat
|
||||
if (isIndustrialCraftLoaded()) {
|
||||
ModuleManager.addModule(new HazmatModule(Arrays.<IModularItem>asList(MPSItems.powerArmorHead(), MPSItems.powerArmorTorso(), MPSItems.powerArmorLegs(), MPSItems.powerArmorFeet())));
|
||||
}
|
||||
|
@ -181,9 +111,4 @@ public class ModCompatibility {
|
|||
// return null;
|
||||
// }
|
||||
|
||||
public static ItemStack getMFFSItem(String name, int quantity) throws ClassNotFoundException, NoSuchFieldException, IllegalAccessException {
|
||||
Object obj = Class.forName("mods.mffs.common.ModularForceFieldSystem").getField("MFFSitemFieldTeleporter").get(null);
|
||||
ItemStack stack = new ItemStack((Item) obj, quantity);
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,9 +45,6 @@ object ModularPowersuits {
|
|||
Config.getSalvageChance
|
||||
Config.baseMaxHeat
|
||||
Config.allowConflictingKeybinds
|
||||
Config.fontURI
|
||||
Config.fontName
|
||||
Config.fontDetail
|
||||
Config.fontAntiAliasing
|
||||
Config.useCustomFonts
|
||||
Config.glowMultiplier
|
||||
|
@ -64,6 +61,7 @@ object ModularPowersuits {
|
|||
@Mod.EventHandler def postInit(event: FMLPostInitializationEvent) {
|
||||
proxy.postInit()
|
||||
ModCompatibility.registerModSpecificModules()
|
||||
Config.extractRecipes
|
||||
Config.getConfig.save
|
||||
}
|
||||
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
package net.machinemuse.powersuits.powermodule.tool;
|
||||
|
||||
import net.machinemuse.api.IModularItem;
|
||||
import net.machinemuse.powersuits.common.ModCompatibility;
|
||||
import net.machinemuse.powersuits.item.ItemComponent;
|
||||
import net.machinemuse.powersuits.powermodule.PowerModuleBase;
|
||||
import net.machinemuse.utils.MuseCommonStrings;
|
||||
import net.machinemuse.utils.MuseItemUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -22,11 +20,6 @@ public class MFFSFieldTeleporterModule extends PowerModuleBase {
|
|||
public MFFSFieldTeleporterModule(List<IModularItem> validItems) throws IllegalAccessException, NoSuchFieldException, ClassNotFoundException {
|
||||
super(validItems);
|
||||
addBaseProperty(FIELD_TELEPORTER_ENERGY_CONSUMPTION, 20000, "J");
|
||||
ItemStack stack = ModCompatibility.getMFFSItem("MFFSitemForcePowerCrystal", 1);
|
||||
if (stack == null) {
|
||||
throw new IllegalAccessException("Failed to get MFFS forcefield teleporter");
|
||||
}
|
||||
addInstallCost(stack);
|
||||
addInstallCost(MuseItemUtils.copyAndResize(ItemComponent.controlCircuit, 1));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue