Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- World world = player.getWorld();
- Random rand = new Random(System.currentTimeMillis());
- Block block = null;
- int ticks = 0;
- while(block == null){
- double x = 0.0;
- double y = 0.0;
- MIN_X_DISTANCE = Integer.parseInt(getNode("minX").replaceAll("\\'", ""));
- MIN_Y_DISTANCE = Integer.parseInt(getNode("minY").replaceAll("\\'", ""));
- MAX_X_DISTANCE = Integer.parseInt(getNode("maxX").replaceAll("\\'", ""));
- MAX_Y_DISTANCE = Integer.parseInt(getNode("maxY").replaceAll("\\'", ""));
- while(x<MIN_X_DISTANCE){
- x = rand.nextInt(MAX_X_DISTANCE);
- }
- while(y<MIN_Y_DISTANCE){
- y = rand.nextInt(MAX_Y_DISTANCE);
- }
- block = world.getHighestBlockAt(new Location(world, x, world.getMaxHeight(), y));
- if(block != null){
- if(block.getType() == Material.AIR || block.getType() == Material.BEDROCK){
- block = null;
- }
- }
- ticks ++;
- if(ticks >= 100){
- block = player.getTargetBlock(null, 100);
- if(block != null){
- if(block.getType() == Material.AIR || block.getType() == Material.BEDROCK){
- block = null;
- }
- }
- if(block == null){
- Location location = player.getLocation();
- block = world.getHighestBlockAt(location);
- }
- System.out.println("[meaRandomTP] ***** Could not find block after 100 ticks! *****");
- break;
- }
- }
- Location location = block.getLocation();
- location.setZ(location.getY()+3);
- player.teleport(location);
Advertisement
Add Comment
Please, Sign In to add comment