First above ground air block

Discussion in 'Development' started by BruhLol, Mar 11, 2018.

  1. BruhLol

    BruhLol Slime

    Messages:
    76
    So i am trying to make an envoy plugin, i was wondering how to get the first above ground air block so i can set the chest tile there, since the location of the envoy needs to be random, i can mt_rand $x and $z but what about $y? I dont want envoys floating in air... Also how to get range of $x and $z of a certain area?
     
  2. LewBr

    LewBr Zombie

    Messages:
    384
    GitHub:
    lewbr
    to get the range you can do something like this:
    PHP:
    if($x 77 and $x 60 and $z 141 and $z 165)
    and do that with $z too if you want, so the block will spawn only in area of $x 60,61,62,63,65 to 77 and the same on $z, they will spawn only inside 141 to 165.
     
    BruhLol likes this.
  3. Sandertv

    Sandertv Zombie Pigman

    Messages:
    785
    GitHub:
    Sandertv
    Try Level->getHighestBlockAt() + 1
     
    BruhLol and Teamblocket like this.
  4. Teamblocket

    Teamblocket Zombie

    Messages:
    306
    GitHub:
    teamblocket
    Level->getHighestBlockAt(int $z, int $z) + 1;*
     
  5. BruhLol

    BruhLol Slime

    Messages:
    76
    This gives the last block, i want the first
     
  6. Muqsit

    Muqsit Wither Skeleton Verified

    Messages:
    1,349
    GitHub:
    muqsit
    That's a bug I guess. It happens with chunks that were never created. Level->getHighestBlockAt(X, Z) indirectly creates the chunk at X, Z and returns -1 if the chunk doesn't exist.
     
    BruhLol likes this.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.