public function saveNBT()
{
if (!$this instanceof Player) {
$this->namedtag->id = new StringTag("id", $this->getSaveId());
if ($this->getNameTag() !== "") {
$this->namedtag->CustomName = new StringTag("CustomName", $this->getNameTag());
$this->namedtag->CustomNameVisible = new StringTag("CustomNameVisible", $this->isNameTagVisible());
} else {
unset($this->namedtag->CustomName);
unset($this->namedtag->CustomNameVisible);
}
}
$this->namedtag->Pos = new ListTag("Pos", [new DoubleTag(0, $this->x), new DoubleTag(1, $this->y), new DoubleTag(2, $this->z)]);
$this->namedtag->Motion = new ListTag("Motion", [new DoubleTag(0, $this->motionX), new DoubleTag(1, $this->motionY), new DoubleTag(2, $this->motionZ)]);
$this->namedtag->Rotation = new ListTag("Rotation", [new FloatTag(0, $this->yaw), new FloatTag(1, $this->pitch)]);
$this->namedtag->FallDistance = new FloatTag("FallDistance", $this->fallDistance);
$this->namedtag->Fire = new ShortTag("Fire", $this->fireTicks);
$this->namedtag->Air = new ShortTag("Air", $this->getDataProperty(self::DATA_AIR));
$this->namedtag->OnGround = new ByteTag("OnGround", $this->onGround == true ? 1 : 0);
$this->namedtag->Invulnerable = new ByteTag("Invulnerable", $this->invulnerable == true ? 1 : 0);
if (count($this->effects) > 0) {
$effects = [];
foreach ($this->effects as $effect) {
$effects[$effect->getId()] = new CompoundTag($effect->getId(), ["Id" => new ByteTag("Id", $effect->getId()), "Amplifier" => new ByteTag("Amplifier", $effect->getAmplifier()), "Duration" => new IntTag("Duration", $effect->getDuration()), "Ambient" => new ByteTag("Ambient", 0), "ShowParticles" => new ByteTag("ShowParticles", $effect->isVisible() ? 1 : 0)]);
}
$this->namedtag->ActiveEffects = new ListTag("ActiveEffects", $effects);
} else {
unset($this->namedtag->ActiveEffects);
}
}