diff --git a/src/pocketmine/item/Item.php b/src/pocketmine/item/Item.php index 26c38c261a..c0997258e3 100644 --- a/src/pocketmine/item/Item.php +++ b/src/pocketmine/item/Item.php @@ -36,6 +36,7 @@ use pocketmine\nbt\NBT; use pocketmine\nbt\tag\ByteTag; use pocketmine\nbt\tag\CompoundTag; use pocketmine\nbt\tag\ListTag; +use pocketmine\nbt\tag\NamedTag; use pocketmine\nbt\tag\ShortTag; use pocketmine\nbt\tag\StringTag; use pocketmine\nbt\tag\Tag; @@ -535,6 +536,18 @@ class Item implements ItemIds, \JsonSerializable{ return $this->getNamedTag()->{$name} ?? null; } + public function setNamedTagEntry(NamedTag $new) : void{ + $tag = $this->getNamedTag(); + $tag->{$new->getName()} = $new; + $this->setNamedTag($tag); + } + + public function removeNamedTagEntry(string $name) : void{ + $tag = $this->getNamedTag(); + unset($tag->{$name}); + $this->setNamedTag($tag); + } + /** * Returns a tree of Tag objects representing the Item's NBT. If the item does not have any NBT, an empty CompoundTag * object is returned to allow the caller to manipulate and apply back to the item.