Jump to content

finding other mods block/item ids?


jordan30001

Recommended Posts

imho items and blocks can be aquired by normal means: looking for an item with specific name in an array

Item.itemsList

or for a block in

Block.blocksList

. if a mod is present you can find out either using the mod's api, using reflection or

Loader.isModLoaded

method (there will be even more ways I guess).

mnn.getNativeLang() != English

If I helped you please click on the "thank you" button.

Link to comment
Share on other sites

imho items and blocks can be aquired by normal means: looking for an item with specific name in an array

Item.itemsList

or for a block in

Block.blocksList

. if a mod is present you can find out either using the mod's api, using reflection or

Loader.isModLoaded

method (there will be even more ways I guess).

how would i figure out from the blockList what the block is?

You can either use Reflections or IndustrialCraft API.

 

RedPower has some rules about decompiling, so you should ask Eloraam before doing anything with it.

 

Reflecting would be de-obfuscating the mod with something like BON (beared octo nemesis) getting rid of everything except the item/block definitions then on post init check to see if the class exists if it doesn't it skips those blocks/items?

or is there an easier way?

Link to comment
Share on other sites

how would i figure out from the blockList what the block is?

by its name or class. lets say you're looking for a block named "stone", you'd just iterate over all blocks and look if it's the one you want.

for(int i=0; i<Block.blocksList.length; i++){
  Block current = Block.blocksList[i];
  if(current != null && "stone".equals(current.getBlockName())){
      // found block
  }
}

 

Reflecting would be de-obfuscating the mod with something like BON (beared octo nemesis) getting rid of everything except the item/block definitions then on post init check to see if the class exists if it doesn't it skips those blocks/items?

or is there an easier way?

I wrote you the easy way, use Loader.isModLoaded to check if the mod is present. If you need just IDs I don't see any reason why use reflection, also it might be illegal without consent of mod developer.

mnn.getNativeLang() != English

If I helped you please click on the "thank you" button.

Link to comment
Share on other sites

but some of the other major mods (not naming any names) are registering their block names as Null how would I work past this? is there any other name I can grab from somewhere

if the block can be uniquely identified by its class name, you can get and compare it like this:

String className = testedBlock.getClass().getCanonicalName();
if (className.equals("net.minecraft.block.BlockGrass")) {
  //found grass!
}

 

it is possible that the mod's block is not setting its name, because there's ItemBlock handling this block (block name is mainly used for getting title for user). you probably could look at all items searching for ones named after block you're looking for. after getting this item you'd simply cast it to

ItemBlock

and use

getBlockID

.

 

remarks:

  • cache your findings, do NOT search IDs more than once (probably in/from your @init method) after MC started
  • mark your mod to load after mods which blocks you're using

 

mnn.getNativeLang() != English

If I helped you please click on the "thank you" button.

Link to comment
Share on other sites

not this way, in a same loop (the for) you'd test a block to figure out if its class is what you want. similar code to this one should do the trick:

for(int i=0; i<Block.blocksList.length; i++){
  Block current = Block.blocksList[i];
  if(current != null){
    if("stone".equals(current.getBlockName())){
      // found block by its name (stone)
    }else{
      String className = current.getClass().getCanonicalName();
      if (className.equals("net.minecraft.block.BlockGrass")) {
        //found a block by its class name (grass)
      }  
    }
  }
}

mnn.getNativeLang() != English

If I helped you please click on the "thank you" button.

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.



×
×
  • Create New...

Important Information

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