Jump to content

Reference Block/Item without using IDs


Pugsworth

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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? :P

 

If you guys dont get it.. then well ya.. try harder...

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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';

Link to comment
Share on other sites

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;
}

 

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.