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

When you kill pig the pork goes to your inventory but also drops to the ground

Discussion in 'Help' started by Levi, Jan 3, 2018.

  1. Levi

    Levi Skeleton

    Messages:
    955
    GitHub:
    captainleviftw
    I'm using AUtoInv @Jack Noordhuis and teaspoon by @CortexPE
    I killed a pig and the pork drops to the ground but also goes to your inventory.. it doubles.. i want to stop that

    pretty sure this is the code to set drops of pigs in TeaSpoon

    PHP:
    public function getDrops(): array{
            
    $cause $this->lastDamageCause;
            if(
    $cause instanceof EntityDamageByEntityEvent){
                
    $damager $cause->getDamager();
                if(
    $damager instanceof Player){
                    
    //$looting = $damager->getInventory()->getItemInHand()->getEnchantment(Enchantment::LOOTING);
                    //if($looting !== null){
                        //$lootingL = $looting->getLevel();
                    //}else{
                        //$lootingL = 0;
                    //}

                    
    return [
                        
    Item::get(Item::RAW_PORKCHOP0mt_rand(13)),
                    ];
                }
            }

            return [];
        }
    and this is the code in Autoinv that add the entity drops to your inventory
    PHP:
    public function onDeath(EntityDeathEvent $event) {
            
    $victim $event->getEntity();
            
    $cause $victim->getLastDamageCause();
            if(
    $cause instanceof EntityDamageByEntityEvent) {
                
    $killer $cause->getDamager();
                if(
    $killer instanceof InventoryHolder) {
                    foreach(
    $event->getDrops() as $drop) {
                        
    $killer->getInventory()->addItem($drop);
                    }
                }
            } else {
                
    $event->setDrops([]);
            }
            return;
        }
    how can i stop the pork from dropping to the ground? I want it to only go to my inventory straight
     
  2. Jack Noordhuis

    Jack Noordhuis Zombie Pigman Poggit Reviewer

    Messages:
    618
    GitHub:
    JackNoordhuis
    AutoInv currently only supports adding player death drops directly to a killers inventory. I’ll add an option in the next few hours to support adding any entities drops directly to a killers inventory.
     
    Levi likes this.
  3. Jack Noordhuis

    Jack Noordhuis Zombie Pigman Poggit Reviewer

    Messages:
    618
    GitHub:
    JackNoordhuis
    I've updated AutoInv and you can grab the latest release from poggit. You will have to either delete or manually update your config to be able to use the new options.
     
  4. dktapps

    dktapps Administrator Staff Member PMMP Team

    Messages:
    774
    GitHub:
    dktapps
    please don't use TeaSpoon... can we boycott it already?
     
    EdwardHamHam likes this.
  5. Levi

    Levi Skeleton

    Messages:
    955
    GitHub:
    captainleviftw
    i not gonna use it if u add mobs to pocketmine-mp
     
  6. EdwardHamHam

    EdwardHamHam Skeleton

    Messages:
    962
    GitHub:
    edwardhamham
    It sounds like you're blackmailing him. If mobs are added it will be when they're good and ready.
     
    SOFe likes this.
  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.