diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index ce6744d24..743e9d81b 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -980,7 +980,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ foreach($this->usedChunks as $index => $c){ Level::getXZ($index, $chunkX, $chunkZ); foreach($this->level->getChunkEntities($chunkX, $chunkZ) as $entity){ - if($entity !== $this and !$entity->isClosed() and $entity->isAlive()){ + if($entity !== $this and !$entity->isClosed() and $entity->isAlive() and !$entity->isFlaggedForDespawn()){ $entity->spawnTo($this); } } @@ -1451,7 +1451,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ foreach($this->level->getNearbyEntities($this->boundingBox->grow(1, 0.5, 1), $this) as $entity){ $entity->scheduleUpdate(); - if(!$entity->isAlive()){ + if(!$entity->isAlive() or $entity->isFlaggedForDespawn()){ continue; } @@ -3662,7 +3662,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ if($source->isCancelled()){ return; }elseif($this->getLastDamageCause() === $source and $this->spawned){ - $this->broadcastEntityEvent(EntityEventPacket::HURT_ANIMATION); + $this->broadcastEntityEvent(EntityEventPacket::HURT_ANIMATION, null, [$this]); if($this->isSurvival()){ $this->exhaust(0.3, PlayerExhaustEvent::CAUSE_DAMAGE); diff --git a/src/pocketmine/entity/Entity.php b/src/pocketmine/entity/Entity.php index f9631603f..8916ccb87 100644 --- a/src/pocketmine/entity/Entity.php +++ b/src/pocketmine/entity/Entity.php @@ -1944,6 +1944,10 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ $this->needsDespawn = true; } + public function isFlaggedForDespawn() : bool{ + return $this->needsDespawn; + } + /** * Returns whether the entity has been "closed". * @return bool diff --git a/src/pocketmine/entity/FallingSand.php b/src/pocketmine/entity/FallingSand.php index 2f72ee76c..7ce9f7200 100644 --- a/src/pocketmine/entity/FallingSand.php +++ b/src/pocketmine/entity/FallingSand.php @@ -93,7 +93,7 @@ class FallingSand extends Entity{ $hasUpdate = parent::entityBaseTick($tickDiff); - if($this->isAlive()){ + if(!$this->isFlaggedForDespawn()){ $pos = Position::fromObject($this->add(-$this->width / 2, $this->height, -$this->width / 2)->floor(), $this->getLevel()); $this->block->position($pos); diff --git a/src/pocketmine/entity/Item.php b/src/pocketmine/entity/Item.php index 181fb922d..e8b0b4baf 100644 --- a/src/pocketmine/entity/Item.php +++ b/src/pocketmine/entity/Item.php @@ -105,7 +105,7 @@ class Item extends Entity{ $hasUpdate = parent::entityBaseTick($tickDiff); - if($this->isAlive()){ + if(!$this->isFlaggedForDespawn()){ if($this->pickupDelay > 0 and $this->pickupDelay < 32767){ //Infinite delay $this->pickupDelay -= $tickDiff; if($this->pickupDelay < 0){ diff --git a/src/pocketmine/entity/PrimedTNT.php b/src/pocketmine/entity/PrimedTNT.php index 71d1023ad..783067bbc 100644 --- a/src/pocketmine/entity/PrimedTNT.php +++ b/src/pocketmine/entity/PrimedTNT.php @@ -87,7 +87,7 @@ class PrimedTNT extends Entity implements Explosive{ $this->setDataProperty(self::DATA_FUSE_LENGTH, self::DATA_TYPE_INT, $this->fuse); } - if($this->isAlive()){ + if(!$this->isFlaggedForDespawn()){ $this->fuse -= $tickDiff; if($this->fuse <= 0){ diff --git a/src/pocketmine/entity/projectile/Projectile.php b/src/pocketmine/entity/projectile/Projectile.php index 70e1bf9a2..7ec665d62 100644 --- a/src/pocketmine/entity/projectile/Projectile.php +++ b/src/pocketmine/entity/projectile/Projectile.php @@ -121,7 +121,7 @@ abstract class Projectile extends Entity{ $hasUpdate = parent::entityBaseTick($tickDiff); - if($this->isAlive()){ + if(!$this->isFlaggedForDespawn()){ $movingObjectPosition = null; $moveVector = new Vector3($this->x + $this->motionX, $this->y + $this->motionY, $this->z + $this->motionZ); diff --git a/src/pocketmine/item/Item.php b/src/pocketmine/item/Item.php index 7c9b24e73..dcaacae67 100644 --- a/src/pocketmine/item/Item.php +++ b/src/pocketmine/item/Item.php @@ -215,9 +215,9 @@ class Item implements ItemIds, \JsonSerializable{ * * @param CompoundTag|string $tags * - * @return $this + * @return Item */ - public function setCompoundTag($tags){ + public function setCompoundTag($tags) : Item{ if($tags instanceof CompoundTag){ $this->setNamedTag($tags); }else{ @@ -259,9 +259,9 @@ class Item implements ItemIds, \JsonSerializable{ /** * @param CompoundTag $compound * - * @return $this + * @return Item */ - public function setCustomBlockData(CompoundTag $compound){ + public function setCustomBlockData(CompoundTag $compound) : Item{ $tags = clone $compound; $tags->setName(self::TAG_BLOCK_ENTITY_TAG); $this->setNamedTagEntry($tags); @@ -438,9 +438,9 @@ class Item implements ItemIds, \JsonSerializable{ /** * @param string $name * - * @return $this + * @return Item */ - public function setCustomName(string $name){ + public function setCustomName(string $name) : Item{ if($name === ""){ $this->clearCustomName(); } @@ -458,9 +458,9 @@ class Item implements ItemIds, \JsonSerializable{ } /** - * @return $this + * @return Item */ - public function clearCustomName(){ + public function clearCustomName() : Item{ $display = $this->getNamedTagEntry(self::TAG_DISPLAY); if($display instanceof CompoundTag){ $display->removeTag(self::TAG_DISPLAY_NAME); @@ -492,9 +492,9 @@ class Item implements ItemIds, \JsonSerializable{ /** * @param string[] $lines * - * @return $this + * @return Item */ - public function setLore(array $lines){ + public function setLore(array $lines) : Item{ $display = $this->getNamedTagEntry(self::TAG_DISPLAY); if(!($display instanceof CompoundTag)){ $display = new CompoundTag(self::TAG_DISPLAY, []); @@ -547,9 +547,9 @@ class Item implements ItemIds, \JsonSerializable{ * Sets the Item's NBT from the supplied CompoundTag object. * @param CompoundTag $tag * - * @return $this + * @return Item */ - public function setNamedTag(CompoundTag $tag){ + public function setNamedTag(CompoundTag $tag) : Item{ if($tag->getCount() === 0){ return $this->clearNamedTag(); } @@ -564,7 +564,7 @@ class Item implements ItemIds, \JsonSerializable{ * Removes the Item's NBT. * @return Item */ - public function clearNamedTag(){ + public function clearNamedTag() : Item{ return $this->setCompoundTag(""); } @@ -577,9 +577,9 @@ class Item implements ItemIds, \JsonSerializable{ /** * @param int $count - * @return $this + * @return Item */ - public function setCount(int $count){ + public function setCount(int $count) : Item{ $this->count = $count; return $this; @@ -677,9 +677,9 @@ class Item implements ItemIds, \JsonSerializable{ /** * @param int $meta - * @return $this + * @return Item */ - public function setDamage(int $meta){ + public function setDamage(int $meta) : Item{ $this->meta = $meta !== -1 ? $meta & 0x7FFF : -1; return $this; diff --git a/src/pocketmine/item/ItemBlock.php b/src/pocketmine/item/ItemBlock.php index 435dbbf44..b74db2565 100644 --- a/src/pocketmine/item/ItemBlock.php +++ b/src/pocketmine/item/ItemBlock.php @@ -41,9 +41,9 @@ class ItemBlock extends Item{ parent::__construct($itemId ?? $this->block->getId(), $meta, $this->block->getName()); } - public function setDamage(int $meta){ - $this->meta = $meta; - $this->block->setDamage($this->meta !== -1 ? $this->meta & 0xf : 0); + public function setDamage(int $meta) : Item{ + $this->block->setDamage($meta !== -1 ? $meta & 0xf : 0); + return parent::setDamage($meta); } public function getBlock() : Block{ diff --git a/src/pocketmine/nbt/JsonNBTParser.php b/src/pocketmine/nbt/JsonNBTParser.php index 48938f677..80f2721b8 100644 --- a/src/pocketmine/nbt/JsonNBTParser.php +++ b/src/pocketmine/nbt/JsonNBTParser.php @@ -82,7 +82,6 @@ class JsonNBTParser{ $tag = NBT::createTag($type); if($tag instanceof NamedTag){ - $tag->setName($key); $tag->setValue($value); $data[$key] = $tag; } diff --git a/src/raklib b/src/raklib index 268a93c57..0e2611533 160000 --- a/src/raklib +++ b/src/raklib @@ -1 +1 @@ -Subproject commit 268a93c575c3ffa699e8a66b854834989245bb05 +Subproject commit 0e26115330808b91ac3ab0b39e54fc9f9f679189 diff --git a/tests/plugins/PocketMine-DevTools b/tests/plugins/PocketMine-DevTools index 3446bcc77..ac9940c72 160000 --- a/tests/plugins/PocketMine-DevTools +++ b/tests/plugins/PocketMine-DevTools @@ -1 +1 @@ -Subproject commit 3446bcc774bcc278430e2cecd9d46a47f491656f +Subproject commit ac9940c72ac2b01aaf399dc7df78f12b39630057