turt2live

Untitled

Nov 23rd, 2011
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.34 KB | None | 0 0
  1. World world = player.getWorld();
  2. Random rand = new Random(System.currentTimeMillis());
  3. Block block = null;
  4. int ticks = 0;
  5. while(block == null){
  6.     double x = 0.0;
  7.     double y = 0.0;
  8.     MIN_X_DISTANCE = Integer.parseInt(getNode("minX").replaceAll("\\'", ""));
  9.     MIN_Y_DISTANCE = Integer.parseInt(getNode("minY").replaceAll("\\'", ""));
  10.     MAX_X_DISTANCE = Integer.parseInt(getNode("maxX").replaceAll("\\'", ""));
  11.     MAX_Y_DISTANCE = Integer.parseInt(getNode("maxY").replaceAll("\\'", ""));
  12.     while(x<MIN_X_DISTANCE){
  13.         x = rand.nextInt(MAX_X_DISTANCE);
  14.     }
  15.     while(y<MIN_Y_DISTANCE){
  16.         y = rand.nextInt(MAX_Y_DISTANCE);
  17.     }
  18.     block = world.getHighestBlockAt(new Location(world, x, world.getMaxHeight(), y));
  19.     if(block != null){
  20.         if(block.getType() == Material.AIR || block.getType() == Material.BEDROCK){
  21.             block = null;
  22.         }
  23.     }
  24.     ticks ++;
  25.     if(ticks >= 100){
  26.         block = player.getTargetBlock(null, 100);
  27.         if(block != null){
  28.             if(block.getType() == Material.AIR || block.getType() == Material.BEDROCK){
  29.                 block = null;
  30.             }
  31.         }
  32.         if(block == null){
  33.             Location location = player.getLocation();
  34.             block = world.getHighestBlockAt(location);
  35.         }
  36.         System.out.println("[meaRandomTP] ***** Could not find block after 100 ticks! *****");
  37.         break;
  38.     }
  39. }
  40. Location location = block.getLocation();
  41. location.setZ(location.getY()+3);
  42. player.teleport(location);
  43.  
Advertisement
Add Comment
Please, Sign In to add comment