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

cactus damage

Comments in 'Plugin Development' started by Creeperface, Aug 13, 2015.

  1. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    what event is when player is damaged by cactus? it is not EntityDamageByBlockEvent.
  2. TigerHix
    Offline

    TigerHix Active Member

    Joined:
    May 11, 2015
    Posts:
    61
    Minecraft User:
    TigerHix
    It is EntityDamageByBlockEvent. Or you can listen to EntityDamageEvent, and check for the $event->getCause() === EntityDamageEvent::CAUSE_CONTACT.
    Legoboy0215 and Creeperface like this.
  3. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    hm i try again
  4. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    when i was killed by cactus it is not EntityDamageByBlockEvent
  5. TigerHix
    Offline

    TigerHix Active Member

    Joined:
    May 11, 2015
    Posts:
    61
    Minecraft User:
    TigerHix
    I am pretty sure it is. Check out the source code of PocketMine, in method onEntityCollide(Entity) of class Cactus. When you ever collide with a cactus, EntityDamageByBlockEvent fires.
  6. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    cause 0 works
  7. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    death cause is 0 but EntityDamageByBlockEvent not
  8. TigerHix
    Offline

    TigerHix Active Member

    Joined:
    May 11, 2015
    Posts:
    61
    Minecraft User:
    TigerHix
    Ughhh! I am sincerely sorry, had fallen into this PM-exclusive trap again.

    In order to handle EntityDamageByBlockEvent, you need to listen to EntityDamageEvent, and check is the event instanceof EntityDamageByBlockEvent.
  9. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    i know xD i did it so
    EntityDamageByChildEntityEvent and EntityDamageByEntityEvent work
  10. CrazedMiner
    Offline

    CrazedMiner Notable Member Plugin Developer

    Joined:
    Jan 31, 2015
    Posts:
    348
    Plugins:
    2
    Minecraft User:
    CrazedMinerYT
    PHP:
    $victim $event->getEntity();
    $causeId $victim->getLastDamageCause()->getCause();
    $cause $victim->getLastDamageCause();
    if(
    $causeId == EntityDamageEvent::CAUSE_CONTACT) {
        if(
    $cause instanceof EntityDamageByBlockEvent) {
            
    $killer $cause->getDamager();
            if(
    $killer->getId() === Block::CACTUS) {
                
    //Do Something
            
    }
        }
    }
  11. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    I have same code but doesn't work
  12. CrazedMiner
    Offline

    CrazedMiner Notable Member Plugin Developer

    Joined:
    Jan 31, 2015
    Posts:
    348
    Plugins:
    2
    Minecraft User:
    CrazedMinerYT
    It works, make sure you "use" all the events your checking.
  13. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    When i check instance of entitydamagebyentityevent or entitydamagebychildentityevent it works under that i have byBlock And it doesn't work
  14. CrazedMiner
    Offline

    CrazedMiner Notable Member Plugin Developer

    Joined:
    Jan 31, 2015
    Posts:
    348
    Plugins:
    2
    Minecraft User:
    CrazedMinerYT
    PHP:
    use pocketmine\event\entity\EntityDamageByBlockEvent;
  15. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    Experiment
  16. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    omg if i have not it in use it can not find class -,-
    im not so stupid :p
    CrazedMiner, PEMapModder and Xenturio like this.
  17. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    so why it is not EntityDamageByBlockEvent?
  18. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    It is. It works if you have the correct import.
    TigerHix likes this.

Share This Page

Advertisement