Added forceSend for attribute value setting, fixed slowness >= 7 removed client-side when sprinting

This commit is contained in:
Dylan K. Taylor 2017-03-09 21:33:55 +00:00
parent 7fb3c7343f
commit c925845173
2 changed files with 5 additions and 2 deletions

View File

@ -169,7 +169,7 @@ class Attribute{
return $this->currentValue;
}
public function setValue($value, $fit = false){
public function setValue($value, $fit = false, bool $forceSend = false){
if($value > $this->getMaxValue() or $value < $this->getMinValue()){
if(!$fit){
throw new \InvalidArgumentException("Value $value exceeds the range!");
@ -180,7 +180,10 @@ class Attribute{
if($this->currentValue != $value){
$this->desynchronized = true;
$this->currentValue = $value;
}elseif($forceSend){
$this->desynchronized = true;
}
return $this;
}

View File

@ -423,7 +423,7 @@ abstract class Entity extends Location implements Metadatable{
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));
$attr->setValue($value ? ($attr->getValue() * 1.3) : ($attr->getValue() / 1.3), false, true);
}
}