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

Cancel Suffocation

Comments in 'Plugin Development' started by JackboyPlay, Feb 10, 2016.

  1. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
    How to Cancel Suffocation in a Wall?
    Or drowning in water?
    Sorry for the bad english :D
  2. xBeastMode
    Offline

    xBeastMode Active Member

    Joined:
    Nov 27, 2015
    Posts:
    292
    PHP:
    use pocketmine\event\entity\EntityDamageEvent;
    public function 
    onDamage(EntityDamageEvent $e){
    if(
    $e->getCause() === 3){//suffocation
    //do something
    }
    }
    Svile likes this.
  3. Svile
    Offline

    Svile Active Member

    Joined:
    Mar 30, 2015
    Posts:
    239
    Minecraft User:
    svile
    $e->setCancelled();
  4. xBeastMode
    Offline

    xBeastMode Active Member

    Joined:
    Nov 27, 2015
    Posts:
    292
    or $e->setDamage(0), which will not damage the player.
  5. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
    which is drowning?
  6. Svile
    Offline

    Svile Active Member

    Joined:
    Mar 30, 2015
    Posts:
    239
    Minecraft User:
    svile
    is the same as suffocation
  7. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    Code:
    const MODIFIER_BASE = 0
    const MODIFIER_ARMOR = 1
    const CAUSE_CONTACT = 0
    const CAUSE_ENTITY_ATTACK = 1
    const CAUSE_PROJECTILE = 2
    const CAUSE_SUFFOCATION = 3
    const CAUSE_FALL = 4
    const CAUSE_FIRE = 5
    const CAUSE_FIRE_TICK = 6
    const CAUSE_LAVA = 7
    const CAUSE_DROWNING = 8
    const CAUSE_BLOCK_EXPLOSION = 9
    const CAUSE_ENTITY_EXPLOSION = 10
    const CAUSE_VOID = 11
    const CAUSE_SUICIDE = 12
    const CAUSE_MAGIC = 13
    const CAUSE_CUSTOM = 14
    
    You can use if($e->getCause() == EntityDamageEvent::CAUSE_SUFFOCATION or just 3

    Documentation from: http://docs.pocketmine.net/d5/de3/classpocketmine_1_1event_1_1entity_1_1_entity_damage_event.html
    Last edited: Feb 11, 2016
    JackboyPlay likes this.
  8. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
  9. xBeastMode
    Offline

    xBeastMode Active Member

    Joined:
    Nov 27, 2015
    Posts:
    292
    if($e->getCause() === EntityDamageEvent::CAUSE_SUFFOCATION);
    HotFireyDeath likes this.
  10. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Don't take the constant 3. It might be changed in the future. Always use the constant reference.
  11. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    Oh, forgot to write that, dont think I didnt know that :D

Share This Page

Advertisement