Cleaned up tile NBT handling, use new CompoundTag API methods

This commit is contained in:
Dylan K. Taylor
2017-10-16 16:48:24 +01:00
parent 0b1a9ba062
commit 20b86bdea8
11 changed files with 203 additions and 168 deletions

View File

@ -26,7 +26,6 @@ namespace pocketmine\tile;
use pocketmine\item\Item;
use pocketmine\math\Vector3;
use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\tag\StringTag;
use pocketmine\Player;
class EnchantTable extends Spawnable implements Nameable{
@ -41,13 +40,13 @@ class EnchantTable extends Spawnable implements Nameable{
public function addAdditionalSpawnData(CompoundTag $nbt) : void{
if($this->hasName()){
$nbt->CustomName = $this->namedtag->CustomName;
$nbt->setTag($this->namedtag->getTag("CustomName"));
}
}
protected static function createAdditionalNBT(CompoundTag $nbt, Vector3 $pos, ?int $face = null, ?Item $item = null, ?Player $player = null) : void{
if($item !== null and $item->hasCustomName()){
$nbt->CustomName = new StringTag("CustomName", $item->getCustomName());
$nbt->setString("CustomName", $item->getCustomName());
}
}
}