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

Solved How to fix this error?

Discussion in 'Plugin Help' started by NovaDev, Apr 1, 2021.

  1. NovaDev

    NovaDev Spider

    Messages:
    7
    GitHub:
    hmm
    "Cannot access dynamic field "Pos": Dynamic field access on pocketmine\nbt\tag\CompoundTag is no longer supported"
     
  2. Primus

    Primus Zombie Pigman

    Messages:
    749
    Dynamic access was deprecated in god know which version. Use this instead
    PHP:
    $nbt->getTag('Pos'); // iirc
     
  3. NovaDev

    NovaDev Spider

    Messages:
    7
    GitHub:
    hmm
    I can spawn the NPC but in a couple of milliseconds it's disappear
    PHP:
    $nbt = new CompoundTag;
    $nbt->setTag(new ListTag('Pos', [
        new 
    DoubleTag(""$player->getX() + 0.5),
        new 
    DoubleTag(""$player->getY()),
        new 
    DoubleTag(""$player->getZ() + 0.5)
    ]));
    $nbt->setTag(new ListTag('Motion', [
        new 
    DoubleTag(""0),
        new 
    DoubleTag(""0),
        new 
    DoubleTag(""0)
    ]));
    $nbt->setTag(new ListTag('Rotation', [
        new 
    DoubleTag(""0),
        new 
    DoubleTag(""0)
    ]));
    $nbt->setTag(new ShortTag('Health'20));
    $nbt->setTag(new StringTag('Name'$player->getLowerCaseName()));

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

    $npc = new Human($player->getLevel(), $nbt);
    $npc->setNameTagVisible(false);
    $npc->spawnTo($player);
    And also the skin of NPC is not player skin
     
  4. minijaham

    minijaham Skeleton

    Messages:
    801
    GitHub:
    minijaham
    Did you register the entity?
     
  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.