public static getAttribute ( $id ) : null | |
||
$id | ||
return | null | |
public function setMaxHealth($amount) { if (is_null($this->attributeMap->getAttribute(Attribute::HEALTH))) { $this->attributeMap->addAttribute(Attribute::getAttribute(Attribute::HEALTH)); } $this->attributeMap->getAttribute(Attribute::HEALTH)->setMaxValue($amount); }
protected function addAttributes() { $this->attributeMap->addAttribute(Attribute::getAttribute(Attribute::HEALTH)); $this->attributeMap->addAttribute(Attribute::getAttribute(Attribute::FOLLOW_RANGE)); $this->attributeMap->addAttribute(Attribute::getAttribute(Attribute::KNOCKBACK_RESISTANCE)); $this->attributeMap->addAttribute(Attribute::getAttribute(Attribute::MOVEMENT_SPEED)); $this->attributeMap->addAttribute(Attribute::getAttribute(Attribute::ATTACK_DAMAGE)); $this->attributeMap->addAttribute(Attribute::getAttribute(Attribute::ABSORPTION)); }
protected function addAttributes() { parent::addAttributes(); if (is_null($this->attributeMap->getAttribute(Attribute::SATURATION))) { $this->attributeMap->addAttribute(Attribute::getAttribute(Attribute::SATURATION)); } if (is_null($this->attributeMap->getAttribute(Attribute::EXHAUSTION))) { $this->attributeMap->addAttribute(Attribute::getAttribute(Attribute::EXHAUSTION)); } if (is_null($this->attributeMap->getAttribute(Attribute::HUNGER))) { $this->attributeMap->addAttribute(Attribute::getAttribute(Attribute::HUNGER)); } if (is_null($this->attributeMap->getAttribute(Attribute::EXPERIENCE_LEVEL))) { $this->attributeMap->addAttribute(Attribute::getAttribute(Attribute::EXPERIENCE_LEVEL)); } if (is_null($this->attributeMap->getAttribute(Attribute::EXPERIENCE))) { $this->attributeMap->addAttribute(Attribute::getAttribute(Attribute::EXPERIENCE)); } }
protected function addAttributes() { parent::addAttributes(); $this->attributeMap->addAttribute(Attribute::getAttribute(Attribute::SATURATION)); $this->attributeMap->addAttribute(Attribute::getAttribute(Attribute::EXHAUSTION)); $this->attributeMap->addAttribute(Attribute::getAttribute(Attribute::HUNGER)); $this->attributeMap->addAttribute(Attribute::getAttribute(Attribute::EXPERIENCE_LEVEL)); $this->attributeMap->addAttribute(Attribute::getAttribute(Attribute::EXPERIENCE)); $this->attributeMap->addAttribute(Attribute::getAttribute(Attribute::HEALTH)); $this->attributeMap->addAttribute(Attribute::getAttribute(Attribute::MOVEMENT_SPEED)); $this->attributeMap->addAttribute(Attribute::getAttribute(Attribute::ABSORPTION)); }
public function onDataPacketSendEvent(DataPacketSendEvent $event) { $pk = $event->getPacket(); if ($pk instanceof SetHealthPacket) { $attribute = Attribute::getAttribute(Attribute::MAX_HEALTH); $attributeData = AttributeProvider::getInstance()->getAttribute($event->getPlayer()); $attribute->setMinValue(0); $attribute->setMaxValue($attributeData->getMaxHealth()); if ($pk->health > $attributeData->getMaxHealth()) { $pk->health = $attributeData->getMaxHealth(); } $attribute->setValue($pk->health); $attributePacket = new UpdateAttributesPacket(); $attributePacket->entityId = 0; $attributePacket->entries = [$attribute]; $event->setCancelled(); $event->getPlayer()->dataPacket($attributePacket); } }
public function notifyXP() { $this->sendAttribute(Attribute::getAttribute(Attribute::EXPERIENCE_LEVEL)->setMaxValue(self::MAX_LEVEL)->setValue($this->getStatus()->level), Attribute::getAttribute(Attribute::EXPERIENCE)->setValue($this->getStatus()->getXp() / $this->getNeededXP())); }