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

DoubleJump

Discussion in 'Development' started by Nora1903, Jul 24, 2018.

  1. Nora1903

    Nora1903 Slime

    Messages:
    82
    GitHub:
    cuongvnz
    Yea, Which method that let a player double jump when he double-tap into jump button ?( survival mode)
    Thanks!
     
  2. KHAV

    KHAV Baby Zombie

    Messages:
    152
    GitHub:
    xkhhv
    Using public $jump make it ++ in JumpEvent and when $jump be 2 using Player::SetMotion you can do it.
     
  3. Nora1903

    Nora1903 Slime

    Messages:
    82
    GitHub:
    cuongvnz
    o_O i will try
     
  4. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    still what about in air jump??
    do the client send a packet when they jump in air?
     
  5. Saiini14 TV

    Saiini14 TV Silverfish

    Messages:
    15
    GitHub:
    saini14
    Yes, it is called the PlayerActionPacket, It is Setting 8 for the packet.
     
  6. SleepSpace9

    SleepSpace9 Slime

    Messages:
    78
    GitHub:
    sleepspace9
    The client doesn't send this packet when pressing the jump button while your are already in the air. So your Player::SetMotion would only be triggered on every second jump from the ground. I think that's why @Thunder33345 was especially asking for "in air jumps".
     
  7. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    667

    He is a pretty good developer, this works for me.
     
  8. Saiini14 TV

    Saiini14 TV Silverfish

    Messages:
    15
    GitHub:
    saini14
    Oh then i do not think there is one, none that i have heard of.
     
  9. SalmonDE

    SalmonDE Zombie Pigman

    Messages:
    739
    GitHub:
    SalmonDE
    You can enable flying for the player after jumping and listen for the PlayerToggleFlightEvent. Of course you have to disable fly immediately after the second jump.
     
    corytortoise and SleepSpace9 like this.
  10. SleepSpace9

    SleepSpace9 Slime

    Messages:
    78
    GitHub:
    sleepspace9
    I agree to @SalmonDE, this is the only implementation I know without using additional actions like right click in the air using a predefined item.
     
  11. Saiini14 TV

    Saiini14 TV Silverfish

    Messages:
    15
    GitHub:
    saini14
    Why did I not think of that? Welp, just saiini being saiini I guess
     
  12. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    i disagree since this wont work for laggy players
    it would be nice if fly isnt involved

    Code:
    // DoubleJump by FreeGamingHere
        public function setFlyOnJump(PlayerToggleFlightEvent $event) {
            $player = $event->getPlayer();
            if($player->getLevel()->getFolderName() == $this->getServer()->getDefaultLevel()->getFolderName()) {
                if($event->isFlying() && $player->hasPermission("lobby.doublejump")) {
                    $player->setFlying(false);
                    $jump = $player->getLocation()->multiply(0, 0.001, 0);
                    $jump->y = 1.1;
                    $player->setMotion($jump);
                    $event->setCancelled(true);
                }
            }
        }
    
    yeah this one also uses the fly check
    which might be unreliable for people who lags or intentional lagswitch
     
  13. SalmonDE

    SalmonDE Zombie Pigman

    Messages:
    739
    GitHub:
    SalmonDE
    I was never implying that this was the right way to do. I was simply offering one solution to the op, which should work well enough for the majority of players.
     
  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.