pocketmine\entity\AttributeMap::getAttribute PHP Метод

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

public getAttribute ( integer $id ) : Attribute | null
$id integer
Результат Attribute | null
    public function getAttribute(int $id)
    {
        return $this->attributes[$id] ?? null;
    }

Usage Example

Пример #1
0
 public function setSprinting($value = true)
 {
     if ($value !== $this->isSprinting()) {
         $this->setDataFlag(self::DATA_FLAGS, self::DATA_FLAG_SPRINTING, (bool) $value);
         $attr = $this->attributeMap->getAttribute(Attribute::MOVEMENT_SPEED);
         $attr->setValue($value ? $attr->getValue() * 1.3 : $attr->getValue() / 1.3);
     }
 }