pocketmine\entity\Attribute::setValue PHP Method

setValue() public method

public setValue ( $value, boolean $fit = true, boolean $shouldSend = false )
$fit boolean
$shouldSend boolean
    public function setValue($value, bool $fit = true, bool $shouldSend = false)
    {
        if ($value > $this->getMaxValue() or $value < $this->getMinValue()) {
            if (!$fit) {
                Server::getInstance()->getLogger()->error("[Attribute / {$this->getName()}] Value {$value} exceeds the range!");
            }
            $value = min(max($value, $this->getMinValue()), $this->getMaxValue());
        }
        if ($this->currentValue != $value) {
            $this->desynchronized = true;
            $this->currentValue = $value;
        }
        if ($shouldSend) {
            $this->desynchronized = true;
        }
        return $this;
    }