mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-07 18:32:55 +00:00
Further cleanup on ListTag and CompoundTag usage
This commit is contained in:
@ -496,15 +496,16 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
|
||||
$this->id = Entity::$entityCount++;
|
||||
$this->namedtag = $nbt;
|
||||
|
||||
$this->chunk = $level->getChunk($this->namedtag["Pos"][0] >> 4, $this->namedtag["Pos"][2] >> 4, true);
|
||||
/** @var float[] $pos */
|
||||
$pos = $this->namedtag->getListTag("Pos")->getAllValues();
|
||||
|
||||
$this->chunk = $level->getChunk(((int) $pos[0]) >> 4, ((int) $pos[2]) >> 4, true);
|
||||
assert($this->chunk !== null);
|
||||
$this->setLevel($level);
|
||||
$this->server = $level->getServer();
|
||||
|
||||
$this->boundingBox = new AxisAlignedBB(0, 0, 0, 0, 0, 0);
|
||||
|
||||
/** @var float[] $pos */
|
||||
$pos = $this->namedtag->getListTag("Pos")->getAllValues();
|
||||
/** @var float[] $rotation */
|
||||
$rotation = $this->namedtag->getListTag("Rotation")->getAllValues();
|
||||
|
||||
|
@ -57,7 +57,7 @@ class Item extends Entity{
|
||||
parent::initEntity();
|
||||
|
||||
$this->setMaxHealth(5);
|
||||
$this->setHealth((int) $this->namedtag["Health"]);
|
||||
$this->setHealth($this->namedtag->getShort("Health", (int) $this->getHealth()));
|
||||
$this->age = $this->namedtag->getShort("Age", $this->age);
|
||||
$this->pickupDelay = $this->namedtag->getShort("PickupDelay", $this->pickupDelay);
|
||||
$this->owner = $this->namedtag->getString("Owner", $this->owner);
|
||||
|
@ -68,7 +68,7 @@ abstract class Living extends Entity implements Damageable{
|
||||
$health = $this->getMaxHealth();
|
||||
|
||||
if($this->namedtag->hasTag("HealF", FloatTag::class)){
|
||||
$health = new FloatTag("Health", (float) $this->namedtag["HealF"]);
|
||||
$health = new FloatTag("Health", $this->namedtag->getFloat("HealF"));
|
||||
$this->namedtag->removeTag("HealF");
|
||||
}elseif($this->namedtag->hasTag("Health")){
|
||||
$healthTag = $this->namedtag->getTag("Health");
|
||||
|
Reference in New Issue
Block a user