Im Trying to make a tag PHP: $item = Item::get(Item::REDSTONE);$item->setCustomName($this->plugin->prefix . ' Test ' . $player->getName());$item->setLore([ TextFormat::GOLD . TextFormat::BOLD . 'Test']);/** @var CompoundTag $nbt */$nbt = $item->getNamedTag() ?? new CompoundTag("", []);$nbt->bh = new StringTag("bh", "1000");$item->setNamedTag($nbt);$player->dropItem($item); I got error cannot access dyanmic field bh
That code is outdated, see here for how it works now: https://forums.pmmp.io/threads/adapting-old-code-using-compoundtags-since-api-3-0-0-alpha12.5975/ btw this post should be in Development, not Plugin Help
I Got This Argument 1 passed to pocketmine\item\Item::setNamedTag() must be an instance of pocketmine\nbt\tag\CompoundTag, PHP: $item = Item::get(Item::REDSTONE);$item->setCustomName($this->plugin->prefix . ' B ');$item->setLore([ TextFormat::GOLD . TextFormat::BOLD . 'B']);$item->setNamedTag(new StringTag("bh", "1000"));$item->setNamedTag(new StringTag("B", 's'));
You can't override the item's compound tag with a string tag, however adding them to the existing CompoundTag will work: PHP: $item = Item::get(Item::REDSTONE);$item->setCustomName($this->plugin->prefix . ' B ');$item->setLore([ TextFormat::GOLD . TextFormat::BOLD . 'B']);$item->setNamedTagEntry(new StringTag("bh", "1000"));$item->setNamedTagEntry(new StringTag("B", 's'));