Posted February 27, 201312 yr If I wanted to lets say get the block ID and meta of ic2's machine block or rp2's screwdriver. How could I achieve this? Also how would I detect if its installed?
February 28, 201312 yr You can either use Reflections or IndustrialCraft API. RedPower has some rules about decompiling, so you should ask Eloraam before doing anything with it.
February 28, 201312 yr 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.
March 5, 201312 yr Author 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?
March 5, 201312 yr 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.
March 6, 201312 yr Author ] Ok I tried this and it works perfectly for most mods (major mods) 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
March 6, 201312 yr 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.
March 7, 201312 yr Author so if i wanted to bind grass i would use String className = Blockgrass.getClass().getCanonicalName(); but I cannot access it because of the static modifier
March 7, 201312 yr 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.
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.