Jump to content

Get block ID by name?


electro1574

Recommended Posts

Hi.

 

I hope I'm not asking something obvious, but I haven't been able to find the answer anywhere.

 

Is it possible to get a block object and/or ID by the block's text name, for mod-generated blocks?  It seems to me that, from a programming point of view, this would be the best way of allowing mods to interact with each other, without worrying about internal IDs.

 

I'd like to write a mod that makes use of custom blocks that exist in another mod, but that mod uses undocumented ID/meta values.  (Specifically, I want to use some of the blocks from the Condensed Blocks mod in recipes.)

 

I've tried using the ID Resolver mod to find out more info about the blocks in question, but it just hangs my Minecraft during loading.

 

The mod does use a config file for the base IDs of the blocks, but the few blocks I'm looking for, specifically, don't have any mention in the config.

 

Anyone have any ideas?

 

Thanks.

 

Link to comment
Share on other sites

Hi.

 

I hope I'm not asking something obvious, but I haven't been able to find the answer anywhere.

 

Is it possible to get a block object and/or ID by the block's text name, for mod-generated blocks?  It seems to me that, from a programming point of view, this would be the best way of allowing mods to interact with each other, without worrying about internal IDs.

 

I'd like to write a mod that makes use of custom blocks that exist in another mod, but that mod uses undocumented ID/meta values.  (Specifically, I want to use some of the blocks from the Condensed Blocks mod in recipes.)

 

I've tried using the ID Resolver mod to find out more info about the blocks in question, but it just hangs my Minecraft during loading.

 

The mod does use a config file for the base IDs of the blocks, but the few blocks I'm looking for, specifically, don't have any mention in the config.

 

Anyone have any ideas?

 

Thanks.

 

Link to comment
Share on other sites

foreach Block block inn BlockList

if (block.name == name)

return block

minecraft is coded in java not in c#

c#

foreach(Block b in Block.blocksList){

if(b.name.Equals(name))

return block;

}

java

for(Block b : Block.blocksList){

if(b.name.equals(name)

return block;

}

Link to comment
Share on other sites

foreach Block block inn BlockList

if (block.name == name)

return block

minecraft is coded in java not in c#

c#

foreach(Block b in Block.blocksList){

if(b.name.Equals(name))

return block;

}

java

for(Block b : Block.blocksList){

if(b.name.equals(name)

return block;

}

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.