mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-09 13:14:54 +00:00
Living: tighten validity checks on health NBT, don't use generic getValue() (it could return anything)
This commit is contained in:
parent
711ea3185d
commit
b57dcebb6f
@ -44,6 +44,7 @@ use pocketmine\math\VoxelRayTrace;
|
|||||||
use pocketmine\nbt\tag\CompoundTag;
|
use pocketmine\nbt\tag\CompoundTag;
|
||||||
use pocketmine\nbt\tag\FloatTag;
|
use pocketmine\nbt\tag\FloatTag;
|
||||||
use pocketmine\nbt\tag\ListTag;
|
use pocketmine\nbt\tag\ListTag;
|
||||||
|
use pocketmine\nbt\tag\ShortTag;
|
||||||
use pocketmine\network\mcpe\protocol\ActorEventPacket;
|
use pocketmine\network\mcpe\protocol\ActorEventPacket;
|
||||||
use pocketmine\network\mcpe\protocol\types\EntityMetadataFlags;
|
use pocketmine\network\mcpe\protocol\types\EntityMetadataFlags;
|
||||||
use pocketmine\network\mcpe\protocol\types\EntityMetadataProperties;
|
use pocketmine\network\mcpe\protocol\types\EntityMetadataProperties;
|
||||||
@ -105,9 +106,10 @@ abstract class Living extends Entity{
|
|||||||
|
|
||||||
if($nbt->hasTag("HealF", FloatTag::class)){
|
if($nbt->hasTag("HealF", FloatTag::class)){
|
||||||
$health = $nbt->getFloat("HealF");
|
$health = $nbt->getFloat("HealF");
|
||||||
}elseif($nbt->hasTag("Health")){
|
}elseif($nbt->hasTag("Health", ShortTag::class)){
|
||||||
$healthTag = $nbt->getTag("Health");
|
$health = $nbt->getShort("Health"); //Older versions of PocketMine-MP incorrectly saved this as a short instead of a float
|
||||||
$health = (float) $healthTag->getValue(); //Older versions of PocketMine-MP incorrectly saved this as a short instead of a float
|
}elseif($nbt->hasTag("Health", FloatTag::class)){
|
||||||
|
$health = $nbt->getFloat("Health");
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->setHealth($health);
|
$this->setHealth($health);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user