Last active
May 13, 2020 15:23
-
-
Save PJZ9n/75d8de45a8bfa3cd306bf850e4f4ffd7 to your computer and use it in GitHub Desktop.
NBT
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(strict_types=1); | |
/** @var \pocketmine\item\Item $item */ | |
$namedtag = $item->getNamedTag(); | |
//セットするタグ | |
$setTag = new \pocketmine\nbt\tag\CompoundTag("プラグイン名", [ | |
new \pocketmine\nbt\tag\StringTag("キー1", "値aaaabbbb"), | |
]); | |
//セットする | |
$namedtag->setTag($setTag); | |
//アイテムからCompoundTagを取得 | |
$getTag = $namedtag->getCompoundTag("プラグイン名"); | |
//取得 | |
$value = $getTag->getString("キー1", "存在しなかったときの値(任意)"); | |
var_dump($value);//値aaaabbbb になるはず |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment