mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-10-17 04:06:54 +00:00
Allow Tiles to decide how to copy data from an item
This commit is contained in:
@@ -23,6 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\tile;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
use pocketmine\nbt\tag\StringTag;
|
||||
|
||||
@@ -80,4 +81,15 @@ trait NameableTrait{
|
||||
$tag->setString(Nameable::TAG_CUSTOM_NAME, $this->customName);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Item $item
|
||||
* @see Tile::copyDataFromItem()
|
||||
*/
|
||||
protected function copyDataFromItem(Item $item) : void{
|
||||
parent::copyDataFromItem($item);
|
||||
if($item->hasCustomName()){ //this should take precedence over saved NBT
|
||||
$this->setName($item->getCustomName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user