Jump to content

Problem with config and (meta) item IDs [Solved]


Rogem

Recommended Posts

So, as the title says, I have a "small" problem with configs and meta item IDs...

 

Without further prattling, here's the code that causes the error:

 

@PreInit

public void loadConfig(FMLPreInitializationEvent event)

{

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

 

config.load();

 

int scienceMetaOreID = config.getItem("Science Ore ID", 10503).getInt();

int scienceMetaItemID = config.getItem("Science Item ID", 10504).getInt();

int scienceMetaIngotID = config.getItem("Science Ingot ID", 10505).getInt();

int scienceMetaOreBlockID = config.getBlock("Science Ore ID", 500).getInt();

 

config.save();

}

 

public static int scienceMetaItemID;

public static int scienceMetaIngotID;

public static int scienceMetaOreID;

public static int scienceMetaOreBlockID;

 

public Item scienceMetaItem = new ItemScienceMetaItem(scienceMetaItemID).setItemName("Meta Item");

public Item scienceMetaIngot = new ItemScienceMetaIngot(scienceMetaIngotID).setItemName("Meta Ingot");

public Item scienceMetaOre = new ItemScienceMetaOre(scienceMetaOreID).setItemName("Meta Ore");

 

private void registerItems() {

GameRegistry.registerItem(scienceMetaItem, "Meta Item");

GameRegistry.registerItem(scienceMetaIngot, "Meta Ingot");

GameRegistry.registerItem(scienceMetaOre, "Meta Ore");

 

}

 

And the specific error stuff:

 

2013-03-01 20:57:20 [iNFO] [ForgeModLoader] Forge Mod Loader version 4.7.4.520 for Minecraft 1.4.7 loading

2013-03-01 20:57:21 [iNFO] [sTDOUT] 27 achievements

2013-03-01 20:57:22 [iNFO] [sTDOUT] 210 recipes

2013-03-01 20:57:22 [iNFO] [sTDOUT] Setting user: Player586, -

2013-03-01 20:57:22 [iNFO] [sTDERR] Client asked for parameter: server

2013-03-01 20:57:22 [iNFO] [sTDOUT] LWJGL Version: 2.4.2

2013-03-01 20:57:22 [iNFO] [ForgeModLoader] Attempting early MinecraftForge initialization

2013-03-01 20:57:22 [iNFO] [sTDOUT] MinecraftForge v6.6.0.497 Initialized

2013-03-01 20:57:22 [iNFO] [ForgeModLoader] MinecraftForge v6.6.0.497 Initialized

2013-03-01 20:57:22 [iNFO] [sTDOUT] Replaced 84 ore recipies

2013-03-01 20:57:22 [iNFO] [ForgeModLoader] Completed early MinecraftForge initialization

2013-03-01 20:57:22 [iNFO] [ForgeModLoader] Searching C:\Users\Vellu\Desktop\MCP\jars\mods for mods

2013-03-01 20:57:23 [iNFO] [ForgeModLoader] Forge Mod Loader has identified 4 mods to load

2013-03-01 20:57:23 [iNFO] [ForgeModLoader] FML has found a non-mod file NotEnoughItems 1.4.7.0.jar in your mods directory. It will now be injected into your classpath. This could severe stability issues, it should be removed if possible.

2013-03-01 20:57:23 [iNFO] [sTDOUT] CONFLICT @ 0 item slot already occupied by net.minecraft.item.ItemSpade@5b3bd09d while adding testMod.ItemScienceMetaItem@33fd2236

2013-03-01 20:57:23 [iNFO] [ForgeModLoader] [itemTracker] The mod mod_scienceTest is overwriting existing item at 256 (net.minecraft.item.ItemSpade from Minecraft) with testMod.ItemScienceMetaItem

2013-03-01 20:57:23 [iNFO] [sTDOUT] CONFLICT @ 0 item slot already occupied by testMod.ItemScienceMetaItem@33fd2236 while adding testMod.ItemScienceMetaIngot@5a08a508

2013-03-01 20:57:23 [iNFO] [ForgeModLoader] [itemTracker] The mod mod_scienceTest is overwriting existing item at 256 (testMod.ItemScienceMetaItem from mod_scienceTest) with testMod.ItemScienceMetaIngot

2013-03-01 20:57:23 [iNFO] [sTDOUT] CONFLICT @ 0 item slot already occupied by testMod.ItemScienceMetaIngot@5a08a508 while adding testMod.ItemScienceMetaOre@4cdc161f

2013-03-01 20:57:23 [iNFO] [ForgeModLoader] [itemTracker] The mod mod_scienceTest is overwriting existing item at 256 (testMod.ItemScienceMetaIngot from mod_scienceTest) with testMod.ItemScienceMetaOre

2013-03-01 20:57:23 [iNFO] [ForgeModLoader] Configured a dormant chunk cache size of 0

2013-03-01 20:57:24 [iNFO] [sTDOUT] Starting up SoundSystem...

2013-03-01 20:57:24 [iNFO] [sTDOUT] Initializing LWJGL OpenAL

2013-03-01 20:57:24 [iNFO] [sTDOUT]    (The LWJGL binding of OpenAL.  For more information, see http://www.lwjgl.org)

2013-03-01 20:57:24 [iNFO] [sTDOUT] OpenAL initialized.

2013-03-01 20:57:25 [iNFO] [ForgeModLoader] Forge Mod Loader has successfully loaded 4 mods

2013-03-01 20:57:25 [iNFO] [sTDERR] java.io.IOException: Server returned HTTP response code: 503 for URL: http://s3.amazonaws.com/MinecraftResources/

2013-03-01 20:57:25 [iNFO] [sTDERR] at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)

2013-03-01 20:57:25 [iNFO] [sTDERR] at net.minecraft.util.ThreadDownloadResources.run(ThreadDownloadResources.java:57)

2013-03-01 21:00:44 [iNFO] [sTDOUT] Stopping!

2013-03-01 21:00:44 [iNFO] [sTDOUT] SoundSystem shutting down...

2013-03-01 21:00:45 [iNFO] [sTDOUT]    Author: Paul Lamb, www.paulscode.com

 

 

as you can see, the compiler decides to just give all three of my items the item ID "256" whenever I try to use a config file to determine them...

 

Any help is much appreciated, this is prohibiting me from doing science. ::)

Link to comment
Share on other sites

your ID's are called before they are initialized in your config.(hence, as they are ints they take the default value of 0) you need to move your item constructor to some other method, maby make one labled add items then assign your varible it's value e.g:

 

public Item scienceMetaItem;

 

public static void addItems(){

    scienceMetaItem = new ItemScienceMetaItem(scienceMetaItemID).setItemName("Meta Item");

}

 

 

call this after your config has happend

Link to comment
Share on other sites

Sadly, this did not work. I played around with the statics, too :/

 

 

Relevant code now:

 

public static int scienceMetaItemID;

public static int scienceMetaIngotID;

public static int scienceMetaOreID;

public static int scienceMetaOreBlockID;

 

public static Item scienceMetaItem;

public static Item scienceMetaOre;

public static Item scienceMetaIngot;

public static Block scienceMetaOreBlock;

 

 

 

@PreInit

public void loadConfig(FMLPreInitializationEvent event)

{

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

 

config.load();

 

int scienceMetaOreID = config.getItem("Science Ore ID", 10503).getInt();

int scienceMetaItemID = config.getItem("Science Item ID", 10504).getInt();

int scienceMetaIngotID = config.getItem("Science Ingot ID", 10505).getInt();

int scienceMetaOreBlockID = config.getBlock("Science Ore ID", 500).getInt();

 

config.save();

}

 

 

 

public static void addItems()

{

scienceMetaItem = new ItemScienceMetaItem(scienceMetaItemID).setItemName("Meta Item");

scienceMetaIngot = new ItemScienceMetaIngot(scienceMetaIngotID).setItemName("Meta Ingot");

scienceMetaOre = new ItemScienceMetaOre(scienceMetaOreID).setItemName("Meta Ore");

// item = new item.class(int itemID).setItemName(string name)

}

 

 

 

private void registerItems()

{

GameRegistry.registerItem(scienceMetaItem, "Meta Item");

GameRegistry.registerItem(scienceMetaIngot, "Meta Ingot");

GameRegistry.registerItem(scienceMetaOre, "Meta Ore");

// GameRegistry.registerItem(Item item, string name)

}

 

 

Oh, and error log:

 

2013-03-02 09:59:41 [iNFO] [ForgeModLoader] Forge Mod Loader version 4.7.4.520 for Minecraft 1.4.7 loading

2013-03-02 09:59:43 [iNFO] [sTDOUT] 27 achievements

2013-03-02 09:59:43 [iNFO] [sTDOUT] 210 recipes

2013-03-02 09:59:43 [iNFO] [sTDOUT] Setting user: Player58, -

2013-03-02 09:59:43 [iNFO] [sTDERR] Client asked for parameter: server

2013-03-02 09:59:43 [iNFO] [sTDOUT] LWJGL Version: 2.4.2

2013-03-02 09:59:44 [iNFO] [ForgeModLoader] Attempting early MinecraftForge initialization

2013-03-02 09:59:44 [iNFO] [sTDOUT] MinecraftForge v6.6.0.497 Initialized

2013-03-02 09:59:44 [iNFO] [ForgeModLoader] MinecraftForge v6.6.0.497 Initialized

2013-03-02 09:59:44 [iNFO] [sTDOUT] Replaced 84 ore recipies

2013-03-02 09:59:44 [iNFO] [ForgeModLoader] Completed early MinecraftForge initialization

2013-03-02 09:59:44 [iNFO] [ForgeModLoader] Searching C:\Users\Vellu\Desktop\MCP\jars\mods for mods

2013-03-02 09:59:45 [iNFO] [ForgeModLoader] Forge Mod Loader has identified 4 mods to load

2013-03-02 09:59:45 [iNFO] [ForgeModLoader] Configured a dormant chunk cache size of 0

2013-03-02 09:59:45 [iNFO] [sTDOUT] Starting up SoundSystem...

2013-03-02 09:59:45 [iNFO] [sTDOUT] Initializing LWJGL OpenAL

2013-03-02 09:59:45 [iNFO] [sTDOUT]    (The LWJGL binding of OpenAL.  For more information, see http://www.lwjgl.org)

2013-03-02 09:59:46 [iNFO] [sTDOUT] OpenAL initialized.

2013-03-02 09:59:46 [iNFO] [sTDOUT] CONFLICT @ 0 item slot already occupied by net.minecraft.item.ItemSpade@b568ac5 while adding testMod.ItemScienceMetaItem@5eb09153

2013-03-02 09:59:46 [iNFO] [ForgeModLoader] [itemTracker] The mod mod_scienceTest is overwriting existing item at 256 (net.minecraft.item.ItemSpade from Minecraft) with testMod.ItemScienceMetaItem

2013-03-02 09:59:46 [iNFO] [sTDOUT] CONFLICT @ 0 item slot already occupied by testMod.ItemScienceMetaItem@5eb09153 while adding testMod.ItemScienceMetaIngot@5ce1b5b2

2013-03-02 09:59:46 [iNFO] [ForgeModLoader] [itemTracker] The mod mod_scienceTest is overwriting existing item at 256 (testMod.ItemScienceMetaItem from mod_scienceTest) with testMod.ItemScienceMetaIngot

2013-03-02 09:59:46 [iNFO] [sTDOUT] CONFLICT @ 0 item slot already occupied by testMod.ItemScienceMetaIngot@5ce1b5b2 while adding testMod.ItemScienceMetaOre@440e7e7b

2013-03-02 09:59:46 [iNFO] [ForgeModLoader] [itemTracker] The mod mod_scienceTest is overwriting existing item at 256 (testMod.ItemScienceMetaIngot from mod_scienceTest) with testMod.ItemScienceMetaOre

2013-03-02 09:59:46 [iNFO] [ForgeModLoader] Forge Mod Loader has successfully loaded 4 mods

2013-03-02 10:02:16 [iNFO] [sTDOUT] Stopping!

2013-03-02 10:02:16 [iNFO] [sTDOUT] SoundSystem shutting down...

2013-03-02 10:02:16 [iNFO] [sTDOUT]    Author: Paul Lamb, www.paulscode.com

 

 

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.