From c925845173b3652681cfa45a7ed798d159a4a094 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Thu, 9 Mar 2017 21:33:55 +0000 Subject: [PATCH] Added forceSend for attribute value setting, fixed slowness >= 7 removed client-side when sprinting --- src/pocketmine/entity/Attribute.php | 5 ++++- src/pocketmine/entity/Entity.php | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/pocketmine/entity/Attribute.php b/src/pocketmine/entity/Attribute.php index 8c54ae996..be5a6cfae 100644 --- a/src/pocketmine/entity/Attribute.php +++ b/src/pocketmine/entity/Attribute.php @@ -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; } diff --git a/src/pocketmine/entity/Entity.php b/src/pocketmine/entity/Entity.php index c318f31f2..31de771ac 100644 --- a/src/pocketmine/entity/Entity.php +++ b/src/pocketmine/entity/Entity.php @@ -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); } }