mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-06 03:47:16 +00:00
fixed misusing isAlive(), close #1523
This commit is contained in:
parent
99f06c6c18
commit
0e64c3dad8
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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){
|
||||
|
@ -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){
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user