Added config and GuiConfig
This commit is contained in:
parent
b3d6ea1358
commit
a054ac6eba
8 changed files with 242 additions and 19 deletions
|
@ -1,6 +1,9 @@
|
||||||
package techreborn;
|
package techreborn;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
import techreborn.client.GuiHandler;
|
import techreborn.client.GuiHandler;
|
||||||
|
import techreborn.config.ConfigTechReborn;
|
||||||
import techreborn.init.ModBlocks;
|
import techreborn.init.ModBlocks;
|
||||||
import techreborn.init.ModItems;
|
import techreborn.init.ModItems;
|
||||||
import techreborn.lib.ModInfo;
|
import techreborn.lib.ModInfo;
|
||||||
|
@ -8,11 +11,22 @@ import cpw.mods.fml.common.Mod;
|
||||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||||
|
|
||||||
@Mod(modid = ModInfo.MOD_ID, name = ModInfo.MOD_NAME, version = ModInfo.MOD_VERSION, dependencies = ModInfo.MOD_DEPENDENCUIES)
|
@Mod(modid = ModInfo.MOD_ID, name = ModInfo.MOD_NAME, version = ModInfo.MOD_VERSION, dependencies = ModInfo.MOD_DEPENDENCUIES, guiFactory = ModInfo.GUI_FACTORY_CLASS)
|
||||||
public class Core {
|
public class Core {
|
||||||
|
public static ConfigTechReborn config;
|
||||||
|
|
||||||
@Mod.Instance
|
@Mod.Instance
|
||||||
public static Core INSTANCE;
|
public static Core INSTANCE;
|
||||||
|
|
||||||
|
@Mod.EventHandler
|
||||||
|
public void preinit(FMLPreInitializationEvent event)
|
||||||
|
{
|
||||||
|
INSTANCE = this;
|
||||||
|
String path = event.getSuggestedConfigurationFile().getAbsolutePath()
|
||||||
|
.replace(ModInfo.MOD_ID, "TechReborn");
|
||||||
|
|
||||||
|
config = ConfigTechReborn.initialize(new File(path));
|
||||||
|
}
|
||||||
|
|
||||||
@Mod.EventHandler
|
@Mod.EventHandler
|
||||||
public void init(FMLPreInitializationEvent event)
|
public void init(FMLPreInitializationEvent event)
|
||||||
|
|
61
src/main/java/techreborn/config/ConfigTechReborn.java
Normal file
61
src/main/java/techreborn/config/ConfigTechReborn.java
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
package techreborn.config;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
import net.minecraftforge.common.config.Configuration;
|
||||||
|
|
||||||
|
public class ConfigTechReborn {
|
||||||
|
private static ConfigTechReborn instance = null;
|
||||||
|
public static String CATEGORY_WORLD = "world";
|
||||||
|
|
||||||
|
//WORLDGEN
|
||||||
|
public static boolean GalenaOreTrue;
|
||||||
|
|
||||||
|
public static Configuration config;
|
||||||
|
|
||||||
|
private ConfigTechReborn(File configFile)
|
||||||
|
{
|
||||||
|
config = new Configuration(configFile);
|
||||||
|
config.load();
|
||||||
|
|
||||||
|
ConfigTechReborn.Configs();
|
||||||
|
|
||||||
|
config.save();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ConfigTechReborn initialize(File configFile)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (instance == null)
|
||||||
|
instance = new ConfigTechReborn(configFile);
|
||||||
|
else
|
||||||
|
throw new IllegalStateException(
|
||||||
|
"Cannot initialize TechReborn Config twice");
|
||||||
|
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ConfigTechReborn instance()
|
||||||
|
{
|
||||||
|
if (instance == null) {
|
||||||
|
|
||||||
|
throw new IllegalStateException(
|
||||||
|
"Instance of TechReborn Config requested before initialization");
|
||||||
|
}
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Configs()
|
||||||
|
{
|
||||||
|
GalenaOreTrue = config.get(CATEGORY_WORLD,
|
||||||
|
"Allow GalenaOre", true,
|
||||||
|
"Allow GalenaOre to be generated in your world.")
|
||||||
|
.getBoolean(true);
|
||||||
|
|
||||||
|
if (config.hasChanged())
|
||||||
|
config.save();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
78
src/main/java/techreborn/config/TechRebornConfigGui.java
Normal file
78
src/main/java/techreborn/config/TechRebornConfigGui.java
Normal file
|
@ -0,0 +1,78 @@
|
||||||
|
package techreborn.config;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.minecraft.client.gui.GuiScreen;
|
||||||
|
import net.minecraftforge.common.config.ConfigElement;
|
||||||
|
import net.minecraftforge.common.config.Configuration;
|
||||||
|
import cpw.mods.fml.client.config.DummyConfigElement;
|
||||||
|
import cpw.mods.fml.client.config.GuiConfig;
|
||||||
|
import cpw.mods.fml.client.config.GuiConfigEntries;
|
||||||
|
import cpw.mods.fml.client.config.IConfigElement;
|
||||||
|
import cpw.mods.fml.client.config.GuiConfigEntries.CategoryEntry;
|
||||||
|
|
||||||
|
public class TechRebornConfigGui extends GuiConfig{
|
||||||
|
public TechRebornConfigGui(GuiScreen top)
|
||||||
|
{
|
||||||
|
super(top, getConfigCategories(), "TechReborn", false, false,
|
||||||
|
GuiConfig.getAbridgedConfigPath(ConfigTechReborn.config
|
||||||
|
.toString()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<IConfigElement> getConfigCategories()
|
||||||
|
{
|
||||||
|
List<IConfigElement> list = new ArrayList<IConfigElement>();
|
||||||
|
list.add(new DummyConfigElement.DummyCategoryElement("General",
|
||||||
|
"tr.configgui.category.trGeneral", TRGeneral.class));
|
||||||
|
list.add(new DummyConfigElement.DummyCategoryElement("World Gen",
|
||||||
|
"tr.configgui.category.trWorld", TRWORLD.class));
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class TRGeneral extends CategoryEntry {
|
||||||
|
|
||||||
|
public TRGeneral(GuiConfig owningScreen, GuiConfigEntries owningEntryList, IConfigElement configElement)
|
||||||
|
{
|
||||||
|
super(owningScreen, owningEntryList, configElement);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected GuiScreen buildChildScreen()
|
||||||
|
{
|
||||||
|
return new GuiConfig(this.owningScreen,
|
||||||
|
(new ConfigElement(ConfigTechReborn.config
|
||||||
|
.getCategory(Configuration.CATEGORY_GENERAL)))
|
||||||
|
.getChildElements(), this.owningScreen.modID,
|
||||||
|
Configuration.CATEGORY_GENERAL,
|
||||||
|
this.configElement.requiresWorldRestart()|| this.owningScreen.allRequireWorldRestart,
|
||||||
|
this.configElement.requiresMcRestart()|| this.owningScreen.allRequireMcRestart,
|
||||||
|
GuiConfig.getAbridgedConfigPath(ConfigTechReborn.config.toString()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// World
|
||||||
|
public static class TRWORLD extends CategoryEntry {
|
||||||
|
public TRWORLD(GuiConfig owningScreen, GuiConfigEntries owningEntryList, IConfigElement configElement)
|
||||||
|
{
|
||||||
|
super(owningScreen, owningEntryList, configElement);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected GuiScreen buildChildScreen()
|
||||||
|
{
|
||||||
|
return new GuiConfig(this.owningScreen,
|
||||||
|
(new ConfigElement(ConfigTechReborn.config
|
||||||
|
.getCategory(ConfigTechReborn.CATEGORY_WORLD)))
|
||||||
|
.getChildElements(), this.owningScreen.modID,
|
||||||
|
Configuration.CATEGORY_GENERAL,
|
||||||
|
this.configElement.requiresWorldRestart()
|
||||||
|
|| this.owningScreen.allRequireWorldRestart,
|
||||||
|
this.configElement.requiresMcRestart()
|
||||||
|
|| this.owningScreen.allRequireMcRestart,
|
||||||
|
GuiConfig.getAbridgedConfigPath(ConfigTechReborn.config
|
||||||
|
.toString()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
37
src/main/java/techreborn/config/TechRebornGUIFactory.java
Normal file
37
src/main/java/techreborn/config/TechRebornGUIFactory.java
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
package techreborn.config;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.gui.GuiScreen;
|
||||||
|
import cpw.mods.fml.client.IModGuiFactory;
|
||||||
|
import cpw.mods.fml.client.IModGuiFactory.RuntimeOptionCategoryElement;
|
||||||
|
import cpw.mods.fml.client.IModGuiFactory.RuntimeOptionGuiHandler;
|
||||||
|
|
||||||
|
public class TechRebornGUIFactory implements IModGuiFactory{
|
||||||
|
@Override
|
||||||
|
public void initialize(Minecraft minecraftInstance)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<? extends GuiScreen> mainConfigGuiClass()
|
||||||
|
{
|
||||||
|
return TechRebornConfigGui.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<RuntimeOptionCategoryElement> runtimeGuiCategories()
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public RuntimeOptionGuiHandler getHandlerFor(
|
||||||
|
RuntimeOptionCategoryElement element)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -22,22 +22,27 @@ public class ModBlocks {
|
||||||
|
|
||||||
public static void init()
|
public static void init()
|
||||||
{
|
{
|
||||||
|
thermalGenerator = new BlockThermalGenerator().setBlockName("techreborn.thermalGenerator").setBlockTextureName("techreborn:ThermalGenerator_other").setCreativeTab(TechRebornCreativeTab.instance);
|
||||||
|
GameRegistry.registerBlock(thermalGenerator, "techreborn.thermalGenerator");
|
||||||
|
GameRegistry.registerTileEntity(TileThermalGenerator.class, "TileThermalGenerator");
|
||||||
|
|
||||||
|
quantumTank = new BlockQuantumTank().setBlockName("techreborn.quantumTank").setBlockTextureName("techreborn:quantumTank").setCreativeTab(TechRebornCreativeTab.instance);
|
||||||
|
GameRegistry.registerBlock(quantumTank, "techreborn.quantumTank");
|
||||||
|
GameRegistry.registerTileEntity(TileQuantumTank.class, "TileQuantumTank");
|
||||||
|
|
||||||
|
quantumChest = new BlockQuantumChest().setBlockName("techreborn.quantumChest").setBlockTextureName("techreborn:quantumChest").setCreativeTab(TechRebornCreativeTab.instance);
|
||||||
|
GameRegistry.registerBlock(quantumChest, "techreborn.quantumChest");
|
||||||
|
GameRegistry.registerTileEntity(TileQuantumChest.class, "TileQuantumChest");
|
||||||
|
|
||||||
|
ore = new BlockOre(Material.rock);
|
||||||
|
GameRegistry.registerBlock(ore, ItemBlockOre.class, "techreborn.ore");
|
||||||
|
|
||||||
|
registerOreDict();
|
||||||
|
}
|
||||||
|
|
||||||
thermalGenerator = new BlockThermalGenerator().setBlockName("techreborn.thermalGenerator").setBlockTextureName("techreborn:ThermalGenerator_other").setCreativeTab(TechRebornCreativeTab.instance);
|
public static void registerOreDict()
|
||||||
GameRegistry.registerBlock(thermalGenerator, "techreborn.thermalGenerator");
|
{
|
||||||
GameRegistry.registerTileEntity(TileThermalGenerator.class, "TileThermalGenerator");
|
//TODO
|
||||||
|
|
||||||
quantumTank = new BlockQuantumTank().setBlockName("techreborn.quantumTank").setBlockTextureName("techreborn:quantumTank").setCreativeTab(TechRebornCreativeTab.instance);
|
|
||||||
GameRegistry.registerBlock(quantumTank, "techreborn.quantumTank");
|
|
||||||
GameRegistry.registerTileEntity(TileQuantumTank.class, "TileQuantumTank");
|
|
||||||
|
|
||||||
quantumChest = new BlockQuantumChest().setBlockName("techreborn.quantumChest").setBlockTextureName("techreborn:quantumChest").setCreativeTab(TechRebornCreativeTab.instance);
|
|
||||||
GameRegistry.registerBlock(quantumChest, "techreborn.quantumChest");
|
|
||||||
GameRegistry.registerTileEntity(TileQuantumChest.class, "TileQuantumChest");
|
|
||||||
|
|
||||||
ore = new BlockOre(Material.rock);
|
|
||||||
GameRegistry.registerBlock(ore, ItemBlockOre.class, "techreborn.ore");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,13 @@ public class ModItems {
|
||||||
{
|
{
|
||||||
dusts = new ItemDusts();
|
dusts = new ItemDusts();
|
||||||
GameRegistry.registerItem(dusts, "dust");
|
GameRegistry.registerItem(dusts, "dust");
|
||||||
|
|
||||||
|
registerOreDict();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void registerOreDict()
|
||||||
|
{
|
||||||
|
//TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ public class ModInfo
|
||||||
public static final String MOD_ID = "techreborn";
|
public static final String MOD_ID = "techreborn";
|
||||||
public static final String MOD_VERSION = "@MODVERSION@";
|
public static final String MOD_VERSION = "@MODVERSION@";
|
||||||
public static final String MOD_DEPENDENCUIES = "required-after:IC2@:";
|
public static final String MOD_DEPENDENCUIES = "required-after:IC2@:";
|
||||||
public static final String SERVER_PROXY_CLASS = "TechReborn.proxies.CommonProxy";
|
public static final String SERVER_PROXY_CLASS = "techreborn.proxies.CommonProxy";
|
||||||
public static final String CLIENT_PROXY_CLASS = "TechReborn.proxies.ClientProxy";
|
public static final String CLIENT_PROXY_CLASS = "techreborn.proxies.ClientProxy";
|
||||||
public static final String GUI_FACTORY_CLASS = "TechReborn.client.gui.TechRebornGUIFactory";
|
public static final String GUI_FACTORY_CLASS = "techreborn.config.TechRebornGUIFactory";
|
||||||
}
|
}
|
||||||
|
|
21
src/main/resources/mcmod.info
Normal file
21
src/main/resources/mcmod.info
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"modid": "techreborn",
|
||||||
|
"name": "TechReborn",
|
||||||
|
"description": "",
|
||||||
|
"version": "@MODVERSION@",
|
||||||
|
"url": "",
|
||||||
|
"updateUrl": "",
|
||||||
|
"authorList": [
|
||||||
|
"modmuss50, Gigabit101"
|
||||||
|
|
||||||
|
],
|
||||||
|
"credits": "",
|
||||||
|
"logoFile": "",
|
||||||
|
"screenshots": [
|
||||||
|
],
|
||||||
|
"parent":"",
|
||||||
|
"dependencies": [
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
Loading…
Reference in a new issue