public function setCustomName(string $name)
{
if ($name === "") {
$this->clearCustomName();
}
if (!($hadCompoundTag = $this->hasCompoundTag())) {
$tag = new CompoundTag("", []);
} else {
$tag = $this->getNamedTag();
}
if (isset($tag->display) and $tag->display instanceof CompoundTag) {
$tag->display->Name = new StringTag("Name", $name);
} else {
$tag->display = new CompoundTag("display", ["Name" => new StringTag("Name", $name)]);
}
if (!$hadCompoundTag) {
$this->setCompoundTag($tag);
}
return $this;
}