Solved Player On Top Of Chunk

Discussion in 'Plugin Development' started by JDJ, Jul 2, 2015.

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

    JDJ

    Essentially, I am getting a random coordinate to teleport a player to. I have the randomization done, but I need to know if they are on the top of the chunk (not suffocating). I also need to know that they are not in the air. Could someone provide a piece of example code?
     
  2. Offline

    meguy26

    @JDJ
    No, no example code...

    Two ways to do it:

    1. Get the random coordinates, and loop up and down through the y coordinate until the block under the player is not air, but the blocks the player is in are.
    2. Get the random coordinates, check if the block under the player is not air, but the blocks the player is in are, and if they are not re-run the randomization process.
     
  3. world.getHighestBlockAt(location)
     
    JDJ likes this.
  4. Offline

    meguy26

Thread Status:
Not open for further replies.

Share This Page