getAttribute() публичный статический Метод

public static getAttribute ( $id ) : null | Attribute
$id
Результат null | Attribute
Пример #1
0
 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);
 }
Пример #2
0
 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));
 }
Пример #3
0
 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));
     }
 }
Пример #4
0
 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));
 }
Пример #5
0
 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);
     }
 }
Пример #6
0
 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()));
 }