Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

"PlayerJumpEvent" workaround

Comments in 'Plugin Development' started by thebigsmileXD, Oct 9, 2015.

  1. thebigsmileXD
    Offline

    thebigsmileXD Banned

    Joined:
    May 19, 2015
    Posts:
    845
    Plugins:
    1
    Minecraft User:
    XenialDan
    I would like to check if a player is jumping. Is there something in the PlayerMoveEvent that i can use?
  2. Svile
    Offline

    Svile Active Member

    Joined:
    Mar 30, 2015
    Posts:
    239
    Minecraft User:
    svile
    maybe
    PHP:
    public function onMove(PlayerMoveEvent $ev){
       if(!
    $ev->getPlayer()->onGround){
          
    //the player is jumping
       
    }
    }
    but maybe when a player fall it isn't on ground and it isn't jumping
    Last edited: Oct 9, 2015
  3. thebigsmileXD
    Offline

    thebigsmileXD Banned

    Joined:
    May 19, 2015
    Posts:
    845
    Plugins:
    1
    Minecraft User:
    XenialDan
    I already use this as flying ^^
    TonyDroide likes this.
  4. Kvetinac97
    Offline

    Kvetinac97 Active Member Plugin Developer

    Joined:
    Nov 17, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    Kvetinac97
    PHP:
    public function onMove(PlayerMoveEvent $ev){
     if (
    $ev->getFrom()->getY() === $ev->getTo()->getY()+and $ev->getPlayer()->getLevel()->getBlockIdAt($$ev->getFrom()->getFloorX(),$ev->getFrom()->getY(),$ev->getFrom()->getFloorZ())-!== 0){
      
    //do something
     
    }
    }
  5. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    Don't reply if you don't exactly know what you're doing.
    Pretty inconvenient. Why not:
    PHP:
    if($event->getFrom()->getY() < $event->getTo()->getY() and ($event->getPlayer()->getGamemode() !== 1) and $event->getPlayer()->getLevel()->getBlock($event->getPlayer()->getTo()->subtract(01)) instanceof Air){
        
    //code here
    }
    Kvetinac97 likes this.
  6. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    And he can be swimming. Or just flying up as a hack.
  7. thebigsmileXD
    Offline

    thebigsmileXD Banned

    Joined:
    May 19, 2015
    Posts:
    845
    Plugins:
    1
    Minecraft User:
    XenialDan
    What do you mean? For swimming theres isSwimming/isInsideOfWater i am pretty sure.
    Leave them alone ok?
    Atleast they try to help and they have nice ideas! Also your code also seems fine.
    Taha_The_Hacker likes this.
  8. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    What if a small part of their body is in a water pillar and other parts in air? It would be difficult to detect. And what if they are just climbing up ladders? Or on a minecart that is moving upwards? There are many reasons for a player to move upwards.
    thebigsmileXD likes this.
  9. thebigsmileXD
    Offline

    thebigsmileXD Banned

    Joined:
    May 19, 2015
    Posts:
    845
    Plugins:
    1
    Minecraft User:
    XenialDan
    Thats true, haven't thought about the other reasons :)

Share This Page

Advertisement