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

Run command from Mob

Comments in 'Plugin Development' started by CookieSteve, May 3, 2015.

  1. CookieSteve
    Offline

    CookieSteve Active Member

    Joined:
    Apr 22, 2014
    Posts:
    132
    Minecraft User:
    iStrqfeChris
    Can someone show me some example code for running a command after you hit a mob Like a zombie
  2. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    Maybe try
    PHP:
    public function onZombieClick(EntityDamageEvent $event){
    $zombie $event->getEntity();
    if(
    $event instanceof EntityDamageByEntityEvent){
    $player $event->getDamager();
    if(
    $player instanceof Player){
    if(
    $zombie instanceof Zombie){
    // Do something
    }
    }
    }
    }
    I'm not sure if this works but it should.
  3. CookieSteve
    Offline

    CookieSteve Active Member

    Joined:
    Apr 22, 2014
    Posts:
    132
    Minecraft User:
    iStrqfeChris
    Thanks I'll test it out :)
  4. CookieSteve
    Offline

    CookieSteve Active Member

    Joined:
    Apr 22, 2014
    Posts:
    132
    Minecraft User:
    iStrqfeChris
    I said EntityDamageEvent doesnt exist
  5. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    It does, remeber to import from entity event, not player.
    PHP:
    use pocketmine\event\entity\EntityDamageEvent;
  6. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    mobs aren't command senders.

Share This Page

Advertisement