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

Throwing Sword Call to a member function

Discussion in 'General discussion' started by Dandy Dwiki, May 18, 2020.

  1. Dandy Dwiki

    Dandy Dwiki Creeper

    Messages:
    5
    GitHub:
    dandyxd
    Hello, i'm a newbie that trying to create a PMMP Pocketmine Plugin, but when i try to make this plugins, i recently get error message
    Call to a member function getDataPropertyManager() on null"

    and here is my code

    PHP:
    $aimPos $ev->getPlayer()->getDirectionVector();
            
    $nbt = new CompoundTag("", [
                
    "Pos" => new ListTag("Pos", [
                    new 
    DoubleTag(""$ev->getPlayer()->x),
                    new 
    DoubleTag(""$ev->getPlayer()->$ev->getPlayer()->getEyeHeight()),
                    new 
    DoubleTag(""$ev->getPlayer()->z)
                ]),
                
    "Motion" => new ListTag("Motion", [
                    new 
    DoubleTag(""$aimPos->x),
                    new 
    DoubleTag(""$aimPos->y),
                    new 
    DoubleTag(""$aimPos->z)
                ]),
                
    "Rotation" => new ListTag("Rotation", [
                    new 
    FloatTag(""$ev->getPlayer()->yaw 75),
                    new 
    FloatTag(""$ev->getPlayer()->pitch)
                ]),
                
    "Health" => new ShortTag("Health"5),
                
    "Item" => new CompoundTag("Item", [
                    
    "id" => new ShortTag("id"Item::DIAMOND_SWORD),
                    
    "Damage" => new ShortTag("Damage"0),
                    
    "Count" => new ByteTag("Count"1),
                ]),
                
    "PickupDelay" => new ShortTag("PickupDelay"0x7F),
            ]);
    //initEntity()
            
    $player $ev->getPlayer();
            
    $sword Entity::createEntity("SwordThrowTask"$ev->getPlayer()->getLevel(), $nbt$ev->getPlayer());
            
    $sword->getDataPropertyManager()->setByte(Entity::DATA_ARMOR_STAND_POSE_INDEX8);
            
    $sword->setMotion($sword->getMotion()->multiply(1.5));
            
    $sword->spawnToAll();
            
    $player->getInventory()->setItemInHand(Item::get(Item::AIR));
     
  2. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
  3. Dandy Dwiki

    Dandy Dwiki Creeper

    Messages:
    5
    GitHub:
    dandyxd
  4. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
    What Entity are you trying to spawn? Why did you put "SwordThrowTask" there?
     
  5. Dandy Dwiki

    Dandy Dwiki Creeper

    Messages:
    5
    GitHub:
    dandyxd
    I wanted to spawn Armor Stand pose 8 but the armor stand is going invisible, then Holding a sword
     
  6. Dandy Dwiki

    Dandy Dwiki Creeper

    Messages:
    5
    GitHub:
    dandyxd
    SwordThrowTask is my Class , its at SwordThrowTask.php
     
  7. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
    But why did you put it in the createEntity method?
     
  8. Dandy Dwiki

    Dandy Dwiki Creeper

    Messages:
    5
    GitHub:
    dandyxd
    So it should be Item? or can you fix my code ? I told i'm newbje that trying to code
     
  9. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
    It's an armor stand, right? I don't think armor stands are registered in pmmp by default, you probably need to make your own ArmorStand class.
     
  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.