Implement a locking variable to circumvent a infinite regression (#2901)

closes #2876
This commit is contained in:
Fabian Faßbender 2019-05-03 15:46:51 +02:00 committed by Dylan T
parent 59334d652f
commit c5498bb3fa

View File

@ -562,6 +562,8 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
/** @var bool */
protected $constructed = false;
/** @var bool */
private $closeInFlight = false;
public function __construct(Level $level, CompoundTag $nbt){
$this->constructed = true;
@ -2109,7 +2111,12 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
* WARNING: Entities are unusable after this has been executed!
*/
public function close() : void{
if($this->closeInFlight){
return;
}
if(!$this->closed){
$this->closeInFlight = true;
(new EntityDespawnEvent($this))->call();
$this->closed = true;
@ -2128,6 +2135,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
$this->namedtag = null;
$this->lastDamageCause = null;
$this->closeInFlight = false;
}
}