Advertisement
riking

Neighbors

Jul 12th, 2011
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.91 KB | None | 0 0
  1. package net.minecraft.src;
  2.  
  3. public class Neighbors implements Iterator
  4. {
  5.     private byte cur;
  6.     private World worldinstance;
  7.     public Neighbors(World world)
  8.     {
  9.         cur=0;
  10.         worldinstance = world;
  11.     }
  12.     public boolean hasNext()
  13.     {
  14.         return cur<6;
  15.     }
  16.     public Object next()
  17.     {
  18.         cur++;
  19.         switch(cur)
  20.         {
  21.             case 1:
  22.                 return Block.blockList[worldinstance.getBlockId(x-1, y, z)]
  23.             break;
  24.             case 2:
  25.                 return Block.blockList[worldinstance.getBlockId(x+1, y, z)]
  26.             break;
  27.             case 3:
  28.                 return Block.blockList[worldinstance.getBlockId(x, y, z-1)]
  29.             break;
  30.             case 4:
  31.                 return Block.blockList[worldinstance.getBlockId(x, y, z+1)]
  32.             break;
  33.             case 5:
  34.                 return Block.blockList[worldinstance.getBlockId(x, y-1, z)]
  35.             break;
  36.             case 6:
  37.                 return Block.blockList[worldinstance.getBlockId(x, y+1, z)]
  38.             break;
  39.         }
  40.     }
  41.     public void remove()
  42.     {
  43.         throw new UnsupportedOperationException();
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement