Posted October 24, 201312 yr Is there a way to get a block/item from just the UnlocalizedName2? e.g. get the Emerald Ore Block from just 'oreEmerald'. I thought that would work, but appears it might not for mods or anything else that might creep in. Essentially, I need a way to refer to a block/item based on something that is not id dependent and can be used across any mod configuration. I really don't want to have to hardcode anything since it needs to be as dynamic as it can be, while also supporting mod items. Pretty much what Mojang is doing with 'minecraft:stone', etc.
October 24, 201312 yr Public int getBlockByName (String name) Foreach block in blockList If block.unlocolaizedName.equals(name) Return block.blockID; If you guys dont get it.. then well ya.. try harder...
October 24, 201312 yr please use hashmap if its an operation that will be used a lot how to debug 101:http://www.minecraftforge.net/wiki/Debug_101 -hydroflame, author of the forge revolution-
October 26, 201311 yr Author I thought that would work, but appears it might not for mods or anything else that might creep in. Essentially, I need a way to refer to a block/item based on something that is not id dependent and can be used across any mod configuration. I really don't want to have to hardcode anything since it needs to be as dynamic as it can be, while also supporting mod items. Pretty much what Mojang is doing with 'minecraft:stone', etc.
October 26, 201311 yr Well you asked for being able to get any block by it's name, that's what we solved If you want all blocks just grab every !=null in blocklist into your own list/system and refer to them however you want after that. But what are you trying to accomplish? If you don't want to refer to them by any ID like blockID or name then I'm just wondering what you need it for? You could use reflection I guess, but what's the purpose of it all? If you guys dont get it.. then well ya.. try harder...
October 26, 201311 yr Author I thought maybe it could be that simple, but upon further investigation, it's not. I want a way to use a name like "blockStone" (using a vanilla block as an example) in a config file, and always have it refer to the same block no matter which configuration of mods or ids there are.
October 26, 201311 yr Well I don't see the problem with that, it should work without a problem? If you guys dont get it.. then well ya.. try harder...
October 26, 201311 yr For 1.7 that will change. For 1.6 the unique identifier is the blockID. So for the vanilla blocks you can just use the blockID and for the other blocks you use the name? If you guys dont get it.. then well ya.. try harder...
October 26, 201311 yr I must admit though that I'm very confused as to the point of all this What do you want to disable/enable from the config file? The whole block itself? If you guys dont get it.. then well ya.. try harder...
October 27, 201311 yr Author I want to be able to let the user choose what block/item to use, but not be restricted by the id. A couple issues I've ran into with just using the unlocalized name is for stuff like slabs or records. Each record's unlocalized name is just 'record'. Single slab and double slab both have the unlocalized name of 'stoneSlab' or 'woodSlab';
October 28, 201311 yr Well you asked for being able to get any block by it's name, that's what we solved If you want all blocks just grab every !=null in blocklist into your own list/system and refer to them however you want after that. Could I use something like that in a function in my MainMod class to get unused blockID's to assign to my blocks. I currently use this for tabID's public int getUniqueTabId() { startTabId = CreativeTabs.creativeTabArray.length; return startTabId; } could I use something like: public int getUniqueBlockId() { for (i = 0; i < BlockList.length; i++) { If (block(i) == null) return i; } return 0; }
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.