1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Solved GetHighestBlockAt

Discussion in 'Development' started by xXNiceAssassinlo YT, Apr 6, 2018.

  1. xXNiceAssassinlo YT

    xXNiceAssassinlo YT Zombie Pigman

    Messages:
    499
    GitHub:
    xXNiceYT
    PHP:
        public function execute(CommandSender $senderstring $commandLabel, array $args) : bool{
            if(!
    $sender instanceof Player){
                
    $sender->sendMessage(C::RED "Please use this command ingame.");
                return 
    false;
            }
            
    $world $this->getServer()->getLevelByName("world");
            
    $x rand(1,9999);
            
    $z rand(1,9999);
            
    $y $world->getHighestBlockAt($x 5$z 5);

            
    $sender->teleport(new Position($x$y$z));

            return 
    true;
        }
    not workinf teleports me to bedrock
     
  2. LewBr

    LewBr Zombie

    Messages:
    385
    GitHub:
    lewbr
    Maybe this is a chunk rendering problem, i mean, you need to render the block before processing the event, (but i'm not sure)
     
  3. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    If the chunk was never loaded (a totally fresh chunk), Level::getHighestBlockAt() returns -1.
     
  4. LewBr

    LewBr Zombie

    Messages:
    385
    GitHub:
    lewbr
    that's what I wanted to say, but you are more specific.
     
  5. xXNiceAssassinlo YT

    xXNiceAssassinlo YT Zombie Pigman

    Messages:
    499
    GitHub:
    xXNiceYT
    How do I load it
     
  6. LewBr

    LewBr Zombie

    Messages:
    385
    GitHub:
    lewbr
    you need to go to this area, actually i don't know exactly how to load them whitout going to the area or if has an way to load that.
     
    xXNiceAssassinlo YT likes this.
  7. xXNiceAssassinlo YT

    xXNiceAssassinlo YT Zombie Pigman

    Messages:
    499
    GitHub:
    xXNiceYT
    Thx sm
     
  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.