Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Config does not work


Recommended Posts

Hello, I've used Helfull's tutorial on Properties files but my blocks always return a value of 0.


This is my PropertyManager class:




package cococraft.common;

import java.io.File;
import java.io.IOException;

import net.minecraft.client.Minecraft;
import net.minecraftforge.common.Configuration;

public class PropertyManager 

public static  Configuration config;

public static int CocoStoneID;
public static int MithrilOreID;
public static int SilverOreID;
public static int AmethystOreID;

public static int AmethystID;
public static int CocoIngotID;
public static int MithrilIngotID;
public static int SilverIngotID;

public static int CocoPickaxeID;
public static int CocoAxeID;
public static int CocoShovelID;
public static int CocoSwordID;
public static int CocoHoeID;

public static int MithrilPickaxeID;
public static int MithrilAxeID;
public static int MithrilShovelID;
public static int MithrilSwordID;
public static int MithrilHoeID;

public static int SilverPickaxeID;
public static int SilverAxeID;
public static int SilverShovelID;
public static int SilverSwordID;
public static int SilverHoeID;

public static int AmethystPickaxeID;
public static int AmethystAxeID;
public static int AmethystShovelID;
public static int AmethystSwordID;
public static int AmethystHoeID;

public static void initProps(String mod)
	File file = new File(Minecraft.getMinecraftDir() + "config/" + mod);

	File newFile = new File(Minecraft.getMinecraftDir() + "/config" + mod + "/CocoCraft2.cfg");

		System.out.println("Created Properties File!");
	catch(IOException exception)
		System.out.println("Couldn't create properties file ");
	config =  new Configuration(newFile);


	CocoStoneID = config.getOrCreateBlockIdProperty("CocoStoneID", 180).getInt(180);
	MithrilOreID = config.getOrCreateBlockIdProperty("MithrilOreID", 181).getInt(181);
	SilverOreID = config.getOrCreateBlockIdProperty("SilverOreID", 182).getInt(182);
	AmethystOreID = config.getOrCreateBlockIdProperty("AmethystOreID", 183).getInt(183);

	CocoIngotID = config.getOrCreateIntProperty("CocoIngotID", "item", 15000).getInt(15000);
	MithrilIngotID = config.getOrCreateIntProperty("MithrilIngotID", "item", 15001).getInt(15001);
	SilverIngotID = config.getOrCreateIntProperty("SilverIngotID", "item", 15002).getInt(15002);
	AmethystID = config.getOrCreateIntProperty("AmethystGemID", "item", 15003).getInt(15003);

	CocoPickaxeID = config.getOrCreateIntProperty("CocoPickaxeID", "item", 15004).getInt(15004);
	CocoAxeID = config.getOrCreateIntProperty("CocoAxeID", "item", 15005).getInt(15005);
	CocoShovelID = config.getOrCreateIntProperty("CocoShovelID", "item", 15006).getInt(15006);
	CocoSwordID = config.getOrCreateIntProperty("CocoSwordID", "item", 15007).getInt(15007);
	CocoHoeID = config.getOrCreateIntProperty("CocoHoeID", "item", 15008).getInt(15008);

	MithrilPickaxeID = config.getOrCreateIntProperty("MithrilPickaxeID", "item", 15009).getInt(15009);
	MithrilAxeID = config.getOrCreateIntProperty("MithrilAxeID", "item", 15010).getInt(15010);
	MithrilShovelID = config.getOrCreateIntProperty("MithrilShovelID", "item", 15011).getInt(15011);
	MithrilSwordID = config.getOrCreateIntProperty("MithrilSwordID", "item", 15012).getInt(15012);
	MithrilHoeID = config.getOrCreateIntProperty("MithrilHoeID", "item", 15013).getInt(15013);

	SilverPickaxeID = config.getOrCreateIntProperty("SilverPickaxeID", "item", 15014).getInt(15014);
	SilverAxeID = config.getOrCreateIntProperty("SilverAxeID", "item", 15015).getInt(15015);
	SilverShovelID = config.getOrCreateIntProperty("SilverShovelID", "item", 15016).getInt(15016);
	SilverSwordID = config.getOrCreateIntProperty("SilverSwordID", "item", 15017).getInt(15017);
	SilverHoeID = config.getOrCreateIntProperty("SilverHoeID", "item", 15018).getInt(15018);

	AmethystPickaxeID = config.getOrCreateIntProperty("AmethystPickaxeID", "item", 15019).getInt(15019);
	AmethystAxeID = config.getOrCreateIntProperty("AmethystAxeID", "item", 15020).getInt(15020);
	AmethystShovelID = config.getOrCreateIntProperty("AmethystShovelID", "item", 15021).getInt(15021);
	AmethystSwordID = config.getOrCreateIntProperty("AmethystSwordID", "item", 15022).getInt(15022);
	AmethystHoeID = config.getOrCreateIntProperty("AmethystHoeID", "item", 15023).getInt(15023);





And this is my block declaration:


public static final Block CocoStone = (new ModBlockOre(pm.CocoStoneID, 0)).setBlockName("CocoStone").setResistance(2F).setHardness(2F);
public static final Block MithrilOre = (new ModBlockOre(pm.MithrilOreID, 1)).setBlockName("MithrilORe").setResistance(2F).setHardness(2F);
public static final Block SilverOre = (new ModBlockOre(pm.SilverOreID, 2)).setBlockName("SilverOre").setResistance(2F).setHardness(2F);
public static final Block AmethystOre = (new ModBlockOre(pm.AmethystOreID, 3)).setBlockName("Amethyst").setResistance(2F).setHardness(2F);


FYI pm is PropertyManager


Thanks in advance.

Link to comment
Share on other sites

this is the way i do my configs


public void initConfig(FMLPreInitializationEvent evt) {
	evt.getModMetadata().version = Resources.version;
	Configuration cfg = new Configuration(new File(Loader.instance().getConfigDir() + "/Viper283/CvC/config.cfg"));
	try {
		debugText = cfg.getOrCreateBooleanProperty("Debug Text", cfg.CATEGORY_GENERAL, true).getBoolean(true);
	} catch(Exception e) {
		System.out.println(logger + "Failed to load config for reason: ");
	} finally {



FYI logger is "[CvC]: "

also this is in my mod file

Link to comment
Share on other sites

No offense to the author, but I wouldn't take a tutorial on writing a property file written by someone who can't write 'property' correct too serious ;).


Take a look at the advanced config tutorial on the wiki (http://www.minecraftforge.net/wiki/How_to_make_an_advanced_configuration_file). While it is 'technically' out of date, it still works fine for 1.3.2.

Link to comment
Share on other sites

No offense to the author, but I wouldn't take a tutorial on writing a property file written by someone who can't write 'property' correct too serious ;).


Take a look at the advanced config tutorial on the wiki (http://www.minecraftforge.net/wiki/How_to_make_an_advanced_configuration_file). While it is 'technically' out of date, it still works fine for 1.3.2.


Thanks! But I also would like to have it in another class, so my mod file's smaller.

Link to comment
Share on other sites

Thanks! But I also would like to have it in another class, so my mod file's smaller.


Sure go ahead and place it anywhere you like. The config system is nothing more than a File and a Configuration object, place them anywhere you like.


Note though that it is in no way needed though to keep a separate variable for each block/item id. In fact I personally find it very redundant to do so.

I personally like to just call config.getOrCreateBlockIdProperty directly when initialising the blocks. I also dislike personally setting the id for each entry. I just have one nextBlockID variable which I give a starting value and then just increment with each block call.


But again the only thing you have to do is initialize the File and Configuration objects, then create your objects and finally not forget to save the config to disc. How and where you do this is all up to personal preference :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • I have been trying to download Forge but the Windows Installer isn't coming up, I can see the installer one would use for Linux but no Windows, I have downloaded Java and Jarfix but nothing is working, can someone help?  
    • So I thought that when a capability is attached to an item/entity/etc... the capability will stay until whatever it's attached to is gone. But this doesn't seem to be the case, as when I printed to console whenever a capability is attached, it seems as though a new version of the capability is attached to an item every time I select it in my hotbar, hover over it in inventory, etc. Is this how it's supposed to work? If so, why?
    • Hi, I'm trying to set up a simple forge server just to play with a couple of my friends, but no matter what I do or try I cannot seem to get a Mods folder and for the actual forge part of the server to actually launch. Every time I try to launch the forge.jar via a .bat file I just get a bunch of errors [Errors below] I'm not sure what I'm doing wrong. If I can get some help that would be awesome, thanks C:\Users\User\Desktop\Server>java -Xms2G -Xmx6G -jar forge-1.12.2- nogui A problem occurred running the Server launcher.java.lang.reflect.InvocationTargetException         at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)         at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)         at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)         at java.base/java.lang.reflect.Method.invoke(Method.java:567)         at net.minecraftforge.fml.relauncher.ServerLaunchWrapper.run(ServerLaunchWrapper.java:70)         at net.minecraftforge.fml.relauncher.ServerLaunchWrapper.main(ServerLaunchWrapper.java:34) Caused by: java.lang.ClassCastException: class jdk.internal.loader.ClassLoaders$AppClassLoader cannot be cast to class java.net.URLClassLoader (jdk.internal.loader.ClassLoaders$AppClassLoader and java.net.URLClassLoader are in module java.base of loader 'bootstrap')         at net.minecraft.launchwrapper.Launch.<init>(Launch.java:34)         at net.minecraft.launchwrapper.Launch.main(Launch.java:28)         ... 6 more C:\Users\User\Desktop\Server>pause Press any key to continue . . .  
    • Is it ok if i ask what that is?
  • Topics

  • Who's Online (See full list)

  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.