Solved Getting block ID's

Discussion in 'Plugin Development' started by acecheesecr14, Jan 12, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    acecheesecr14

    Hey, I'm really stuck in this situation!

    Is there a way that I can have a loop going through all the ID's, checking if it is a block? This includes Mods using MCPC+.

    I already have the if statment
    Code:java
    1. if (isBlock(int blockID)){
    2. portalgun.common.PortalGun.addBlockIDToGrabList(int blockID);
    3. }


    ANY HELP APPRECIATED!
     
  2. Offline

    newboyhun

  3. Offline

    acecheesecr14

    I'm on there now, but I was hoping that bukkit would have a function or something that could list all the ID's.
    And thanks for the swift reply!
     
  4. Offline

    Maurdekye

    You could do something hacky, like below;
    Code:java
    1. ArrayList<Integer> ids = new ArrayList<Integer>();
    2. Block center = getServer().getWorlds().get(0).getBlockAt(0, 0, 0);
    3. for (int i=1;i<=4096;i++) {
    4. try {
    5. center.setTypeId(i);
    6. ids.add(i);
    7. } catch (Exception e) {}
    8. }


    Basically, it gets the block at (0, 0, 0) in the first loaded world and tries to set it to every block id from 1 to 4096. If it succeeds, it adds the id to the list. If it fails, it throws the error, skips the addition to the list and continues to the next id. Also, setTypeId() is deprecated since they expect you to use setType() with instances from the Material class.
     
  5. Offline

    acecheesecr14

    Hahaha that seems extremely "hacky", but I would only need to run it once :D save all the id's to a config file or a csv file?
     
  6. Offline

    Maurdekye

    You know, it would be much easier to just run it and copy the output straight into the code. It's not much data at all, and likely to stay the same for a long time until new blocks are added, and besides; you'll probably need to update your program anyway when that happens with the latest version of Bukkit. Creating files is a hassle, and should be avoided when possible.
     
  7. Offline

    acecheesecr14

    Its not for Bukkit. Its for FTB Ultimate :D
    I dont want to ban the portal gun, and i was looking through the Portalgun Docs and i found
    Code:java
    1. portalgun.common.PortalGun.addBlockIDToGrabList(int blockID);
    .
    So I'm glad this will probably work!
     
  8. Offline

    NoLiver92

  9. Offline

    acecheesecr14

    I'm AWARE xD, But this works, and it might as well be official....
     
Thread Status:
Not open for further replies.

Share This Page