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

How do I pull a player Down?

Discussion in 'Development' started by CortexPE, May 3, 2017.

  1. CortexPE

    CortexPE Witch

    Messages:
    61
    GitHub:
    cortexpe
    How do I pull a player down after I disable flight?

    Help is appreciated
     
  2. Lowkey

    Lowkey Slime

    Messages:
    94
    You can acquire their 'Y' coordinate and proceed to pull them down by as much blocks as you wish.
     
  3. CortexPE

    CortexPE Witch

    Messages:
    61
    GitHub:
    cortexpe
    Mk. .-.
    That's hacky af tho.
     
  4. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    what's a better way then?
     
    Lowkey likes this.
  5. Jack Noordhuis

    Jack Noordhuis Zombie Pigman Poggit Reviewer

    Messages:
    618
    GitHub:
    JackNoordhuis
    I'd do something along the lines of this:
    PHP:
    $x $player->getX();
    $y $player->getY();
    $z $player->getZ();
    while(
    $player->getLevel()->getBlockIdAt($x$y$z) === 0) {
        
    $y--;
    }
    $player->teleport(new pocketmine\math\Vector3($x$y$z));
     
    Last edited: May 3, 2017
  6. Sandertv

    Sandertv Zombie Pigman Poggit Reviewer

    Messages:
    786
    GitHub:
    Sandertv
    Correction, $y--
     
  7. Jack Noordhuis

    Jack Noordhuis Zombie Pigman Poggit Reviewer

    Messages:
    618
    GitHub:
    JackNoordhuis
    Shhhh
     
  8. SalmonDE

    SalmonDE Zombie Pigman

    Messages:
    739
    GitHub:
    SalmonDE
    What about using $player->setMotion()? Not sure if this is wanted, but that's what I thought about.
     
  9. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    There's a much better way of doing this. Check out how WorldGuard handles it.
     
  10. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    but doesnt that just trust and hope that on player's side they dont have anti "anti fly packet" blocker?
    and trust that they will fall
     
    SalmonDE and svile like this.
  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.