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

CompoundTag is no longer supported

Discussion in 'Development' started by Aenteritas, Sep 18, 2019.

  1. Aenteritas

    Aenteritas Silverfish

    Messages:
    22
    Error:
    upload_2019-9-18_7-4-48.png

    Code:
    PHP:
    <?php

    namespace phytonia\bedrock;

    use 
    pocketmine\entity\Human;
    use 
    pocketmine\nbt\tag\CompoundTag;
    use 
    pocketmine\nbt\tag\DoubleTag;
    use 
    pocketmine\nbt\tag\FloatTag;
    use 
    pocketmine\nbt\tag\ListTag;
    use 
    pocketmine\nbt\tag\ShortTag;
    use 
    pocketmine\nbt\tag\StringTag;
    use 
    pocketmine\Player;
    use 
    pocketmine\plugin\PluginBase;

    class 
    NPCManager extends PluginBase {

        public static function 
    addNPC(Player $player){
            
    $nbt = new CompoundTag;
            
    $nbt->Pos = new ListTag("Pos", [
                new 
    DoubleTag(""$player->getX()),
                new 
    DoubleTag(""$player->getY()),
                new 
    DoubleTag(""$player->getZ())
            ]);

            
    $nbt->Motion = new ListTag("Motion", [
                new 
    DoubleTag(""0),
                new 
    DoubleTag(""0),
                new 
    DoubleTag(""0)
            ]);

            
    $nbt->Rotation = new ListTag("Rotation", [
                new 
    FloatTag(""$player->getYaw()),
                new 
    FloatTag(""$player->getPitch())
            ]);

            
    $nbt->Health = new ShortTag("Health"20);

            
    $nbt->Skin = new CompoundTag("Skin", [
                
    "Data" => new StringTag("Data"$player->getSkin()->getSkinData()),
                
    "Name" => new StringTag("Name"$player->getSkin()->getSkinId())
            ]);

            
    $human = new Human($player->getLevel(), $nbt);
            
    $human->setNameTag($player->getName());
            
    $human->setNameTagVisible(false);
            
    $human->spawnTo($player);
        }
    }
    i want to make a NPC, but it did not work like i hoped. What did i need to change?
     

    Attached Files:

  2. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
  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.