mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-12 14:35:35 +00:00
Add Item->setNamedTagEntry() and Item->removeNamedTagEntry()
This commit is contained in:
parent
7239dbbb1a
commit
ae5aa31e7b
@ -36,6 +36,7 @@ use pocketmine\nbt\NBT;
|
|||||||
use pocketmine\nbt\tag\ByteTag;
|
use pocketmine\nbt\tag\ByteTag;
|
||||||
use pocketmine\nbt\tag\CompoundTag;
|
use pocketmine\nbt\tag\CompoundTag;
|
||||||
use pocketmine\nbt\tag\ListTag;
|
use pocketmine\nbt\tag\ListTag;
|
||||||
|
use pocketmine\nbt\tag\NamedTag;
|
||||||
use pocketmine\nbt\tag\ShortTag;
|
use pocketmine\nbt\tag\ShortTag;
|
||||||
use pocketmine\nbt\tag\StringTag;
|
use pocketmine\nbt\tag\StringTag;
|
||||||
use pocketmine\nbt\tag\Tag;
|
use pocketmine\nbt\tag\Tag;
|
||||||
@ -535,6 +536,18 @@ class Item implements ItemIds, \JsonSerializable{
|
|||||||
return $this->getNamedTag()->{$name} ?? null;
|
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
|
* 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.
|
* object is returned to allow the caller to manipulate and apply back to the item.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user