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

Armor Inventory doesn't exist

Discussion in 'Development' started by DiamondGamer30, Dec 4, 2019.

  1. DiamondGamer30

    DiamondGamer30 Baby Zombie

    Messages:
    175
    GitHub:
    diamondgamermcpe
    I have this AI plugin but when I var_dump() the player object, it is blank.

    Code:
    object(core\NexusPlayer)#113620 (0) {
    }
    
    This happens when I attempt to attack my target.

    PHP:
    $event = new EntityDamageByEntityEvent($this$targetEntityDamageEvent::CAUSE_ENTITY_ATTACK$this->getBaseAttackDamage());
    $target->attack($event);
    This is how I find my targets.

    PHP:
    $distance 15;
    $target null;
    foreach(
    $this->getLevel()->getPlayers() as $player) {
        if(
    $player instanceof self) {
            continue;
        }
        if(
    $player instanceof NexusPlayer and $player->distance($this) <= $distance) {
            
    $distance $player->distance($this);
            
    $target $player;
        }
    }
    $this->target = ($target != null $target null);
    The error I got.

    Code:
    [03:04:40] [Server thread/CRITICAL]: Error: "Call to a member function getContents() on null" (EXCEPTION) in "src/pocketmine/entity/Living" at line 423
    [03:04:40] [Server thread/DEBUG]: #0 src/pocketmine/entity/Living(466): pocketmine\entity\Living->getArmorPoints()
    [03:04:40] [Server thread/DEBUG]: #1 src/pocketmine/entity/Human(764): pocketmine\entity\Living->applyDamageModifiers(object pocketmine\event\entity\EntityDamageByEntityEvent)
    [03:04:40] [Server thread/DEBUG]: #2 src/pocketmine/entity/Living(562): pocketmine\entity\Human->applyDamageModifiers(object pocketmine\event\entity\EntityDamageByEntityEvent)
    [03:04:40] [Server thread/DEBUG]: #3 src/pocketmine/Player(3737): pocketmine\entity\Living->attack(object pocketmine\event\entity\EntityDamageByEntityEvent)
    [03:04:40] [Server thread/DEBUG]: #4 plugins/NexusPE/src/core/combat/boss/Boss(173): pocketmine\Player->attack(object pocketmine\event\entity\EntityDamageByEntityEvent)
    [03:04:40] [Server thread/DEBUG]: #5 plugins/NexusPE/src/core/combat/boss/Boss(84): core\combat\boss\Boss->attackTarget()
    
     
  2. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
    You armorInventory appears to be null, have you tried calling the initEntity() method of the entity object?
     
  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.