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

Fall Damage

Comments in 'Plugin Development' started by Samueljh1, Jan 22, 2015.

  1. Samueljh1
    Offline

    Samueljh1 Active Member Plugin Developer

    Joined:
    Jan 9, 2015
    Posts:
    316
    Plugins:
    5
    Minecraft User:
    Samueljh1_
    How can I get a Player (or Entity) fall damage event ? Is there a way to get this in on EntityDamage ??
  2. iksaku
    Offline

    iksaku Notable Member Plugin Developer

    Joined:
    Sep 2, 2013
    Posts:
    1,132
    Plugins:
    4
    Minecraft User:
    iksaku
    There are subclasses of the EntityDamageEvent, maybe there could be one.
    But remember:
    You always need to detect the parent "EntityDamageEvent" and after that, check with an "instaceof" statement the subclass ;)
    Falk likes this.
  3. Samueljh1
    Offline

    Samueljh1 Active Member Plugin Developer

    Joined:
    Jan 9, 2015
    Posts:
    316
    Plugins:
    5
    Minecraft User:
    Samueljh1_
    can u make an example snippet? :p
    P.s look at my signature xD
  4. mclab
    Offline

    mclab Active Member

    Joined:
    Dec 24, 2014
    Posts:
    49
    Minecraft User:
    Dragonflex
  5. Samueljh1
    Offline

    Samueljh1 Active Member Plugin Developer

    Joined:
    Jan 9, 2015
    Posts:
    316
    Plugins:
    5
    Minecraft User:
    Samueljh1_
  6. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    PHP:
    public function onDamage(EntityDamageEvent $ev){
        
    $isFall $ev->getCause() === EntityDamageEvent::CAUSE_FALL;
        
    // TODO handle the event
    }
    iJoshuaHD likes this.
  7. Samueljh1
    Offline

    Samueljh1 Active Member Plugin Developer

    Joined:
    Jan 9, 2015
    Posts:
    316
    Plugins:
    5
    Minecraft User:
    Samueljh1_
    Ty
  8. Samueljh1
    Offline

    Samueljh1 Active Member Plugin Developer

    Joined:
    Jan 9, 2015
    Posts:
    316
    Plugins:
    5
    Minecraft User:
    Samueljh1_
    So if it was fall would it return true?

    So then
    PHP:

    if($isFall){

    //Code

    }
  9. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Yes.
    Angelo Vidrio likes this.
  10. EnderLight
    Offline

    EnderLight New Member

    Joined:
    Dec 2, 2014
    Posts:
    7
    Minecraft User:
    enderraian
    How do i disabls fall damage
  11. Falk
    Offline

    Falk Staff Member Global Moderator

    Joined:
    Sep 2, 2013
    Posts:
    1,710
    Plugins:
    22
    Minecraft User:
    Falkirknh
    PHP:
    public function onDamage(EntityDamageEvent $event){
      if(
    $event->getCause() === EntityDamageEvent::CAUSE_FALL){
        
    $event->setCancelled();
      }
    }
    PEMapModder likes this.

Share This Page

Advertisement