1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Cancel XP Orbs ?

Discussion in 'Development' started by iCirgio, Sep 9, 2018.

  1. iCirgio

    iCirgio Slime

    Messages:
    92
    GitHub:
    lolnova
    how can i try cancelling xp orbs for entities?

    1. i tried by setting their xp drop to 0 in a custom class extending the pocketmine one
    2. tried calling entityspawnevent then if its xp orb cancel event (threw cannot canel event error)
    3. tried despawning it when its spawn ( garbage entity error )
    4. tried getting drops if its xp orb remove it

    none worked so yeah. forums is my last hope
     
    Last edited: Sep 9, 2018
  2. RyanShaw

    RyanShaw Witch

    Messages:
    69
    Simply set their xp to 0 when they die
    PHP:
    public function onDeath(PlayerDeathEvent $event){
    $player $event->getPlayer();
    $player->setCurrentTotalXp(0);
    }
     
  3. iCirgio

    iCirgio Slime

    Messages:
    92
    GitHub:
    lolnova
    no no no. thats for players i want it for entities
     
  4. RyanShaw

    RyanShaw Witch

    Messages:
    69
    Oh, maybe use entitydeathevent then? This is all i can think of rn
    PHP:
        public function onEntityDeath(EntityDeathEvent $event){
        
    //you might need to check if its not instance of player
        
    $event->getEntity()->close(); //Thisll also stop the death animation and drops tho, you can set the drops again i guess.
        
    }
     
  5. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    Did you make sure to register the class after extending it?
     
  6. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    667
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.