public static getItemHelper ( |
||
$tag | ||
Результат |
public static function getItemHelper(CompoundTag $tag)
{
if (!isset($tag->id) or !isset($tag->Count)) {
return Item::get(0);
}
$item = Item::get($tag->id->getValue(), !isset($tag->Damage) ? 0 : $tag->Damage->getValue(), $tag->Count->getValue());
if (isset($tag->tag) and $tag->tag instanceof CompoundTag) {
$item->setNamedTag($tag->tag);
}
return $item;
}
protected function initEntity() { parent::initEntity(); $this->setMaxHealth(5); $this->setHealth($this->namedtag["Health"]); if (isset($this->namedtag->Age)) { $this->age = $this->namedtag["Age"]; } if (isset($this->namedtag->PickupDelay)) { $this->pickupDelay = $this->namedtag["PickupDelay"]; } if (isset($this->namedtag->Owner)) { $this->owner = $this->namedtag["Owner"]; } if (isset($this->namedtag->Thrower)) { $this->thrower = $this->namedtag["Thrower"]; } if (!isset($this->namedtag->Item)) { $this->close(); return; } assert($this->namedtag->Item instanceof CompoundTag); $this->item = NBT::getItemHelper($this->namedtag->Item); $this->server->getPluginManager()->callEvent(new ItemSpawnEvent($this)); }