protected function initEntity()
{
if (!$this->namedtag instanceof CompoundTag) {
throw new \InvalidArgumentException("Expecting CompoundTag, received " . get_class($this->namedtag));
}
if (isset($this->namedtag->CustomName)) {
$this->setNameTag($this->namedtag["CustomName"]);
if (isset($this->namedtag->CustomNameVisible)) {
$this->setNameTagVisible($this->namedtag["CustomNameVisible"] > 0);
}
}
$this->scheduleUpdate();
$this->addAttributes();
if (isset($this->namedtag->ActiveEffects)) {
foreach ($this->namedtag->ActiveEffects->getValue() as $e) {
$effect = Effect::getEffect($e["Id"]);
if ($effect === null) {
continue;
}
$effect->setAmplifier($e["Amplifier"])->setDuration($e["Duration"])->setVisible($e["ShowParticles"] > 0);
$this->addEffect($effect);
}
}
}