mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-15 02:09:42 +00:00
Entity: defer kill() until post-construct
this fixes crashes and various bugs with death logic executing during the creation of entities, as well as an age-old Player crash after quitting the server when dying.
This commit is contained in:
parent
2a9586f6fd
commit
2104b2d32b
@ -554,7 +554,7 @@ abstract class Entity{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if($amount <= 0){
|
if($amount <= 0){
|
||||||
if($this->isAlive()){
|
if($this->isAlive() and !$this->justCreated){
|
||||||
$this->kill();
|
$this->kill();
|
||||||
}
|
}
|
||||||
}elseif($amount <= $this->getMaxHealth() or $amount < $this->health){
|
}elseif($amount <= $this->getMaxHealth() or $amount < $this->health){
|
||||||
@ -591,7 +591,12 @@ abstract class Entity{
|
|||||||
protected function entityBaseTick(int $tickDiff = 1) : bool{
|
protected function entityBaseTick(int $tickDiff = 1) : bool{
|
||||||
//TODO: check vehicles
|
//TODO: check vehicles
|
||||||
|
|
||||||
$this->justCreated = false;
|
if($this->justCreated){
|
||||||
|
$this->justCreated = false;
|
||||||
|
if(!$this->isAlive()){
|
||||||
|
$this->kill();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$changedProperties = $this->getSyncedNetworkData(true);
|
$changedProperties = $this->getSyncedNetworkData(true);
|
||||||
if(count($changedProperties) > 0){
|
if(count($changedProperties) > 0){
|
||||||
|
@ -2105,9 +2105,6 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected function onDeath() : void{
|
protected function onDeath() : void{
|
||||||
if(!$this->spawned){ //TODO: drop this hack
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
//Crafting grid must always be evacuated even if keep-inventory is true. This dumps the contents into the
|
//Crafting grid must always be evacuated even if keep-inventory is true. This dumps the contents into the
|
||||||
//main inventory and drops the rest on the ground.
|
//main inventory and drops the rest on the ground.
|
||||||
$this->doCloseInventory();
|
$this->doCloseInventory();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user