Y-axis check?

Discussion in 'Plugin Development' started by Razorcane, Nov 9, 2011.

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

    Razorcane

    I have this sort of /goto function(not really a command, but they function the same way), and I want to do a check to make players land on the top-most non-air block on the Y-axis. Is there a way to do this?
     
  2. Is it something like this you are looking for ?
     
  3. Offline

    halley

    There is a built-in, pre-computed "top-most non-air block on the Y axis" function (given by World and ChunkSnapshot), but it's actually not as non-air as you might think. It's the lowest sun-lit block. If you build a pole out of fenceposts, the block returned is at the bottom of the post, because sunlight penetrates all the other posts.

    Just beware you may have to walk up the blocks to find the first truly air block from that. And remember, don't assume the top of the world is at 128-- custom world heights are comin'. Find out the height of the chunk or world.

    Oh, and consider what your command should do if you're in the nether-- topmost non-air is a bedrock ceiling. You can be teleported above that, but you can't walk down from there.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 21, 2016
Thread Status:
Not open for further replies.

Share This Page