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

ERROR

Discussion in 'Development' started by Barry_Bradley, Aug 16, 2019.

  1. Barry_Bradley

    Barry_Bradley Spider

    Messages:
    13
    PHP:
    [15:09:59] [Server thread/CRITICAL]: RuntimeException"Cannot access dynamic fi
    eld "
    Pos": Dynamic field access on pocketmine\nbt\tag\CompoundTag is no longer s
    upported" 
    (EXCEPTIONin "vendor/pocketmine/nbt/src/tag/NoDynamicFieldsTrait"
    Code:
    PHP:
    public function makeSlapper(Player $playerint $typestring $name){
            
    $type self::ENTITY_LIST[$type];
            
    $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"1);
            
    $nbt->Commands = new CompoundTag("Commands", []);
            
    $nbt->MenuName = new StringTag("MenuName""");
            
    $nbt->SlapperVersion = new StringTag("SlapperVersion"$this->getServer()->getPluginManager()->getPlugin("Slapper")->getDescription()->getVersion());
            if(
    $type === "Human") {
                
    $player->saveNBT();
                
    $nbt->Inventory = clone $player->namedtag->Inventory;
                
    $nbt->Skin = new CompoundTag("Skin", ["Data" => new StringTag("Data"$player->getSkin()->getSkinData()), "Name" => new StringTag("Name"$player->getSkin()->getSkinId())]);
            }
            
    $entity Entity::createEntity("Slapper{$type}"$player->getLevel(), $nbt);
            
    $entity->setNameTag($name);
            
    $entity->setNameTagVisible(true);
            
    $entity->setNameTagAlwaysVisible(true);
            
    $this->getServer()->getPluginManager()->callEvent(new SlapperCreationEvent($entity"Slapper{$type}"$playerSlapperCreationEvent::CAUSE_COMMAND));
            
    $entity->spawnToAll();
            
    $player->sendMessage("Created {$type} entity");
        }
     
  2. VirVolta

    VirVolta Silverfish

    Messages:
    16
    GitHub:
    VirvoltaSurMC
    To create basic nbts you can use the static function Entity::createBaseNBT($pos, $motion, $yaw, $pitch)

    Exemple:
    PHP:
    $nbt Entity::createBaseNBT($playernull$player->getYaw(), $player->getPitch());
     
  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.