mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-08 10:53:05 +00:00
Type-hinted NBT tag constructors, made getValue() and setValue() more strict, fix dozens of assorted related bugs
This commit is contained in:
@ -32,6 +32,7 @@ use pocketmine\event\entity\EntityRegainHealthEvent;
|
||||
use pocketmine\event\Timings;
|
||||
use pocketmine\item\Item as ItemItem;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\nbt\tag\FloatTag;
|
||||
use pocketmine\nbt\tag\ShortTag;
|
||||
use pocketmine\network\mcpe\protocol\EntityEventPacket;
|
||||
use pocketmine\utils\BlockIterator;
|
||||
@ -51,10 +52,12 @@ abstract class Living extends Entity implements Damageable{
|
||||
parent::initEntity();
|
||||
|
||||
if(isset($this->namedtag->HealF)){
|
||||
$this->namedtag->Health = new ShortTag("Health", (int) $this->namedtag["HealF"]);
|
||||
$this->namedtag->Health = new FloatTag("Health", (float) $this->namedtag["HealF"]);
|
||||
unset($this->namedtag->HealF);
|
||||
}elseif(!isset($this->namedtag->Health) or !($this->namedtag->Health instanceof ShortTag)){
|
||||
$this->namedtag->Health = new ShortTag("Health", $this->getMaxHealth());
|
||||
}elseif(isset($this->namedtag->Health) and !($this->namedtag->Health instanceof FloatTag)){
|
||||
$this->namedtag->Health = new FloatTag("Health", (float) $this->namedtag->Health->getValue());
|
||||
}else{
|
||||
$this->namedtag->Health = new FloatTag("Health", (float) $this->getMaxHealth());
|
||||
}
|
||||
|
||||
$this->setHealth($this->namedtag["Health"]);
|
||||
|
Reference in New Issue
Block a user