Finding certain blocks inside a cuboid?

Discussion in 'Spigot Plugin Development' started by digdiggydigger, Apr 13, 2017.

  1. How do i find all of the Iron Ore Blocks inside the coordinates X: -234 Y: 92 Z: 228 and X: -240 Y: 89 Z: 222
    I'm just lost, there's so many different methods on the internet and it's just got my confused on what to do...
     
  2. Try to use world edit API
     
  3. Helpful.. Lol I need some help on it..
     
  4. Create 3 nested for loops

    for(int x = startX;x < maxX ; x++)
    for(int y = startY;y < maxY ; y++)
    for(int z = startZ;z < maxZ;z++)
    int type = yourWorld.getBlockTypeIdAt(yourWorld, x,y,z);
    If type == Material.IRON_ORE.getOrdinal()
    //do stuff

    This method is deprecated but it is significantly faster than using getBlockAt().getMaterial() if you're dealing with big areas


    Sent from my iPhone using Tapatalk
     
    • Agree Agree x 1