Solved Player Head

Discussion in 'Development' started by Amon28, May 23, 2017.

  1. Amon28

    Amon28 Slime

    Messages:
    76
    GitHub:
    amon28
    How do I add Steve head in player inv "Item::get(397:3, 0, 1);" doesn't work
     
  2. Marabou

    Marabou Baby Zombie

    Messages:
    137
    GitHub:
    wiligangster
    *Facepalm*
    Item::get(397, 3, 1);
     
  3. KelvinCyaX

    KelvinCyaX Silverfish

    Messages:
    18
    GitHub:
    CyanKelv
    Oops my bad.. Item::get(397,3,1); But you should really look at the error and pocketmine API.. it explains all..
     
  4. Amon28

    Amon28 Slime

    Messages:
    76
    GitHub:
    amon28
    This is the error When I do that it says "Call to a member function getWindowId() on integer"
     
  5. KelvinCyaX

    KelvinCyaX Silverfish

    Messages:
    18
    GitHub:
    CyanKelv
    Show your code please..
     
  6. Amon28

    Amon28 Slime

    Messages:
    76
    GitHub:
    amon28
    PHP:
    use pocketmine\Server;
    use 
    pocketmine\Player;
    use 
    pocketmine\event\player\PlayerDeathEvent;
    use 
    pocketmine\event\entity\EntityDamageEvent;
    use 
    pocketmine\event\entity\EntityDamageByEntityEvent;
    use 
    pocketmine\inventory\Inventory;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\item\Item;
    use 
    pocketmine\entity\Entity;

    class 
    Main extends PluginBase implements Listener{
        
        public function 
    onEnable(){
            
    $this->getServer()->getPluginManager()->registerEvents($this,$this);
        }
        
        public function 
    onDeath(PlayerDeathEvent $ev){

         
    $player $ev->getPlayer();
         
    $cause $player->getLastDamageCause();
     
        if(
    $cause instanceof EntityDamageByEntityEvent){
         
    $damager $cause->getDamager();
        if(
    $damager instanceof Player){
         
    $inv $damager->getInventory();
         
    $head Item::get(937,3,1);
         
    $name $player->getName();
         
    $head->setCustomName("$name's Head");
         
    $inv->addItem($head);
         
    $damager->getInventory()->sendContents($damager->getInventory());
         
    $damager->sendMessage("you got $name's Head");
      }
    }
    }
     
  7. corytortoise

    corytortoise Skeleton

    Messages:
    825
    GitHub:
    corytortoise
    Can you show the full error?
     
  8. Amon28

    Amon28 Slime

    Messages:
    76
    GitHub:
    amon28
    CRITICAL> "Could not pass event 'pocketmine\event\player\PlayerDeathEvent' to 'PlayerHead v1': Call to a member function getWindowId() on integer on PlayerHead\Main
    CRITICAL> Error: "Call to a member function getWindowId() on integer" (EXCEPTION) in "/src/pocketmine/inventory/PlayerInventory" at line 521
     
  9. Michael

    Michael Baby Zombie

    Messages:
    113
    GitHub:
    michaelm04
    Code looks a little messy try to fix the line spacing and lineup, also the problem is your passing the inventory instead of the player,
    PHP:
    $damager->getInventory()->sendContents($damager);
     
    DogTheBlock and corytortoise like this.
  10. Amon28

    Amon28 Slime

    Messages:
    76
    GitHub:
    amon28
    I fixed the plug in no more errors and I'm able to get Steve head thanks guys :)
    The plugin is public in my github
     

Share This Page

  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.