コード例 #1
0
 public static void unpath(World world, int i, int j, int k) {
   List<ChunkCoordinates> blocks = Lists.newLinkedList();
   List<ChunkCoordinates> notify = Lists.newLinkedList();
   blocks.add(new ChunkCoordinates(i, j, k));
   while (blocks.size() > 0) {
     ChunkCoordinates coords = blocks.remove(0);
     depolarize(world, coords.posX + 1, coords.posY, coords.posZ, blocks);
     depolarize(world, coords.posX, coords.posY + 1, coords.posZ, blocks);
     depolarize(world, coords.posX, coords.posY, coords.posZ + 1, blocks);
     depolarize(world, coords.posX - 1, coords.posY, coords.posZ, blocks);
     depolarize(world, coords.posX, coords.posY - 1, coords.posZ, blocks);
     depolarize(world, coords.posX, coords.posY, coords.posZ - 1, blocks);
     notify.add(coords);
   }
   for (ChunkCoordinates coords : notify) {
     if (world.blockExists(coords.posX, coords.posY, coords.posZ)) {
       world.markBlockForUpdate(coords.posX, coords.posY, coords.posZ);
       world.notifyBlocksOfNeighborChange(
           coords.posX,
           coords.posY,
           coords.posZ,
           world.getBlock(coords.posX, coords.posY, coords.posZ));
     }
   }
 }
コード例 #2
0
 private static void pathto(World world, int i, int j, int k) {
   List<ChunkCoordinates> blocks = Lists.newLinkedList();
   List<ChunkCoordinates> portals = Lists.newLinkedList();
   List<ChunkCoordinates> repath = Lists.newLinkedList();
   List<ChunkCoordinates> redraw = Lists.newLinkedList();
   blocks.add(new ChunkCoordinates(i, j, k));
   while ((portals.size() > 0) || (blocks.size() > 0)) {
     while (blocks.size() > 0) {
       ChunkCoordinates coords = blocks.remove(0);
       directPortal(world, coords.posX + 1, coords.posY, coords.posZ, 5, blocks, portals);
       directPortal(world, coords.posX, coords.posY + 1, coords.posZ, 1, blocks, portals);
       directPortal(world, coords.posX, coords.posY, coords.posZ + 1, 3, blocks, portals);
       directPortal(world, coords.posX - 1, coords.posY, coords.posZ, 6, blocks, portals);
       directPortal(world, coords.posX, coords.posY - 1, coords.posZ, 2, blocks, portals);
       directPortal(world, coords.posX, coords.posY, coords.posZ - 1, 4, blocks, portals);
       redraw.add(coords);
     }
     if (portals.size() > 0) {
       ChunkCoordinates coords = portals.remove(0);
       directPortal(world, coords.posX + 1, coords.posY, coords.posZ, 5, blocks, portals);
       directPortal(world, coords.posX, coords.posY + 1, coords.posZ, 1, blocks, portals);
       directPortal(world, coords.posX, coords.posY, coords.posZ + 1, 3, blocks, portals);
       directPortal(world, coords.posX - 1, coords.posY, coords.posZ, 6, blocks, portals);
       directPortal(world, coords.posX, coords.posY - 1, coords.posZ, 2, blocks, portals);
       directPortal(world, coords.posX, coords.posY, coords.posZ - 1, 4, blocks, portals);
       if (world.getBlock(coords.posX, coords.posY, coords.posZ) == NailedBlocks.portal) {
         repath.add(coords);
       }
     }
   }
   while (repath.size() > 0) {
     ChunkCoordinates coords = repath.remove(0);
     if (world.getBlock(coords.posX, coords.posY, coords.posZ) == NailedBlocks.portal) {
       if (!BlockPortal.isValidPortal(world, coords.posX, coords.posY, coords.posZ)) {
         repathNeighbors(world, coords.posX, coords.posY, coords.posZ);
         world.setBlock(coords.posX, coords.posY, coords.posZ, Blocks.air, 0, 0);
         addSurrounding(repath, coords.posX, coords.posY, coords.posZ);
       } else {
         redraw.add(coords);
       }
     }
   }
   for (ChunkCoordinates coords : redraw) {
     if (world.blockExists(coords.posX, coords.posY, coords.posZ)) {
       world.markBlockForUpdate(coords.posX, coords.posY, coords.posZ);
       world.notifyBlocksOfNeighborChange(
           coords.posX,
           coords.posY,
           coords.posZ,
           world.getBlock(coords.posX, coords.posY, coords.posZ));
     }
   }
 }