Teleport player to DIM7 with same XZ coords and Y at highest block not air

Discussion in 'Plugin Development' started by Ivantacus, May 8, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    Ivantacus

    Hello!

    So I have been messing around trying to make a plugin for our private minecraft server copying codes from forums and looking at other plugins.

    First I wanted a player to teleport to spawn from any dimension and this works fine for me:

    Code:
     
    event.setCancelled(true);
    event.getPlayer().teleport(new Location(Bukkit.getWorld("World"), -265, 76, 5, 180, 6));
    event.getPlayer().sendMessage("Teleported to Spawn.");
    

    What I am having issues with is teleporting player to DIM7 (our mining world) with the same X and Z coords that he is standing on and using getHighestBlockYAt to not make the player stuck inside blocks.
    This is what I have got so far but I am really confused as to how to set it up really:
    Code:
         
    event.setCancelled(true);
    Location spawnloc = event.getPlayer().getLocation();
    teleport = event.getPlayer().teleport(new Location(Bukkit.getWorld("DIM7"), getPlayer(int) spawnloc.getX(), (int) spawnloc.getY(), (int) spawnloc.getZ()));
    event.getPlayer().getLocation().teleport();
    event.getPlayer().sendMessage("Teleported to Mining World.");
    I just started bukkit a few days ago so sorry for super bad code. :D
    Any help would be super appriciated!
     
  2. Ivantacus Before teleporting them, you'd want to get the block that's at that location. Then, you'd want to check if that block is air (and maybe the one above it too). If it isn't, add one to the y and try again. If it is, teleport the player.
     
Thread Status:
Not open for further replies.

Share This Page