mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-07 18:32:55 +00:00
fixed misusing isAlive(), close #1523
This commit is contained in:
@ -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);
|
||||
|
Reference in New Issue
Block a user