Skip to content

Commit

Permalink
Added configuration file setup.
Browse files Browse the repository at this point in the history
  • Loading branch information
raymondbh committed Jun 8, 2016
1 parent f1d6fce commit a6e1bca
Show file tree
Hide file tree
Showing 10 changed files with 120 additions and 9 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ minecraft {
runDir = ""
}
}

configurations {
shade
compile.extendsFrom shade
Expand Down
4 changes: 2 additions & 2 deletions build.prop
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
minecraft_version=1.7.10
forge_version=10.13.4.1448-1.7.10
forge_version=10.13.4.1558-1.7.10
mod_version_maj=1
mod_version_min=0
mod_version_rev=3
mod_version_rev=5
release=stable
mod_id=TFC-Additions
group_name=org.rbh.tfcadditions
Expand Down
32 changes: 32 additions & 0 deletions src/main/java/org/rbh/tfcadditions/Config/ConfigGUI.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package org.rbh.tfcadditions.Config;

import cpw.mods.fml.client.config.GuiConfig;
import cpw.mods.fml.client.config.IConfigElement;
import net.minecraft.client.gui.GuiScreen;
import net.minecraftforge.common.config.ConfigElement;
import org.rbh.tfcadditions.Handlers.ConfigHandler;
import org.rbh.tfcadditions.Reference.Reference;

import java.util.ArrayList;
import java.util.List;


/**
* Created by raymondbh on 08.06.2016.
*/
public class ConfigGUI extends GuiConfig {

public ConfigGUI(GuiScreen parentScreen) {
super(parentScreen, getConfigElements(), Reference.ModID, false, false, Reference.ModName);
}

private static List<IConfigElement> getConfigElements() {

List<IConfigElement> configElementsList = new ArrayList<IConfigElement>();
for (String catName : ConfigHandler.config.getCategoryNames() ) {
if ( catName.contains(".")) continue;
configElementsList.add(new ConfigElement(ConfigHandler.config.getCategory(catName)));
}
return configElementsList;
}
}
33 changes: 33 additions & 0 deletions src/main/java/org/rbh/tfcadditions/Config/GUIFactory.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package org.rbh.tfcadditions.Config;

import cpw.mods.fml.client.IModGuiFactory;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;

import java.util.Set;

/**
* Created by raymondbh on 08.06.2016.
*/
public class GUIFactory implements IModGuiFactory {

@Override
public void initialize(Minecraft minecraftInstance) {

}

@Override
public Class<? extends GuiScreen> mainConfigGuiClass() {
return ConfigGUI.class;
}

@Override
public Set<RuntimeOptionCategoryElement> runtimeGuiCategories() {
return null;
}

@Override
public RuntimeOptionGuiHandler getHandlerFor(RuntimeOptionCategoryElement element) {
return null;
}
}
30 changes: 30 additions & 0 deletions src/main/java/org/rbh/tfcadditions/Handlers/ConfigHandler.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package org.rbh.tfcadditions.Handlers;

import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.common.config.Configuration;

/**
* Created by raymondbh on 08.06.2016.
*/
public class ConfigHandler {

public static final String GENERAL = "General";
public static Configuration config;

public static boolean HideNEI = false;

public static void preInit(FMLPreInitializationEvent event) {

config = new Configuration(event.getSuggestedConfigurationFile());
config.load();

loadGeneralConfig();
}

public static void loadGeneralConfig() {

HideNEI = config.getBoolean("HideNEIVanilla", GENERAL, false, "This will hide vanilla blocks not used by TFC in NEI.");

if(config.hasChanged()) config.save();
}
}
7 changes: 4 additions & 3 deletions src/main/java/org/rbh/tfcadditions/Proxy/ClientProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
import net.minecraft.item.ItemStack;
import org.rbh.tfcadditions.Blocks.BlockSetup;
import org.rbh.tfcadditions.Core.CreativeTabs;
import org.rbh.tfcadditions.Handlers.ConfigHandler;
import org.rbh.tfcadditions.Handlers.KeyBindingHandler;
import org.rbh.tfcadditions.Utility.CarpentersBlocksHandler;
import org.rbh.tfcadditions.Utility.NotEnoughItemsHandler;

/**
Expand All @@ -41,8 +41,9 @@ public void Init(FMLInitializationEvent event){
//if(CarpentersBlocksHandler.isLoaded())
// CarpentersBlocksHandler.Init();

//if(NotEnoughItemsHandler.isLoaded())
// NotEnoughItemsHandler.HideNEIItems();
//Hide vanilla blocks in NEI
if(NotEnoughItemsHandler.isLoaded() && ConfigHandler.HideNEI == true)
NotEnoughItemsHandler.HideNEIItems();

//Setup Creative Tab Icon
((CreativeTabs) CreativeTabs.TFCAdditions_Tab).setTabIconItemStack(new ItemStack(BlockSetup.StoneMMDent, 1, 5));
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/org/rbh/tfcadditions/Proxy/CommonProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
import org.rbh.tfcadditions.Blocks.BlockSetup;
import org.rbh.tfcadditions.Core.OreDictRegister;
import org.rbh.tfcadditions.Core.Recipes;
import org.rbh.tfcadditions.Handlers.ConfigHandler;
import org.rbh.tfcadditions.Handlers.CraftingHandler;
import org.rbh.tfcadditions.Items.ItemSetup;
import org.rbh.tfcadditions.Tools.ChiselMode_Dent;
import org.rbh.tfcadditions.Tools.ChiselMode_DentSmall;
import org.rbh.tfcadditions.Utility.CarpentersBlocksHandler;


/**
Expand All @@ -21,6 +21,8 @@
public class CommonProxy {

public void preInit(FMLPreInitializationEvent event){
ConfigHandler.preInit(event);

BlockSetup.LoadBlocks();
BlockSetup.RegisterBlocks();

Expand Down
4 changes: 3 additions & 1 deletion src/main/java/org/rbh/tfcadditions/Reference/Reference.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ public class Reference {

public static final String AssetPath = "/assets/" + ModID + "/";
public static final String AssetPathGui = "textures/gui/";
}

public static final String GUI_FACTORY = "org.rbh.tfcadditions.Config.GUIFactory";
}
12 changes: 11 additions & 1 deletion src/main/java/org/rbh/tfcadditions/TFCAdditions.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
package org.rbh.tfcadditions;

import cpw.mods.fml.client.event.ConfigChangedEvent;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import org.rbh.tfcadditions.Handlers.ConfigHandler;
import org.rbh.tfcadditions.Proxy.CommonProxy;
import org.rbh.tfcadditions.Reference.Reference;
import org.apache.logging.log4j.LogManager;
Expand All @@ -16,7 +20,7 @@
* Created by raymondbh on 15.07.2015.
*/

@Mod(modid = Reference.ModID, name = Reference.ModName, version = Reference.ModVersion)
@Mod(modid = Reference.ModID, name = Reference.ModName, version = Reference.ModVersion, guiFactory = Reference.GUI_FACTORY)
public class TFCAdditions {

public static final Logger LOG = LogManager.getLogger(Reference.ModID);
Expand All @@ -35,10 +39,16 @@ public void preInit(FMLPreInitializationEvent event){
@EventHandler
public void Init(FMLInitializationEvent event){
proxy.Init(event);
FMLCommonHandler.instance().bus().register(instance);
}

@EventHandler
public void postInit(FMLPostInitializationEvent event){
proxy.postInit(event);
}

@SubscribeEvent
public void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent eventArgs) {
if (eventArgs.modID.equals(Reference.ModID)) ConfigHandler.loadGeneralConfig();
}
}
2 changes: 1 addition & 1 deletion src/main/resources/mcmod.info
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"logoFile": "",
"screenshots": [ ],
"parent": "",
"requiredMods": ["Forge@[10.13.4.1448,)", "terrafirmacraft@[0.79.23,)" ],
"requiredMods": ["Forge@[10.13.4.1558,)", "terrafirmacraft@[0.79.23,)" ],
"dependencies": ["terrafirmacraft", "CarpentersBlocks", "NotEnoughItems"],
"dependants": [ ],
"useDependencyInformation": "true"
Expand Down

0 comments on commit a6e1bca

Please sign in to comment.