mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-07 18:32:55 +00:00
Fixed paintings dropping multiple times, closes #2774
This commit is contained in:
@ -806,8 +806,18 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
|
||||
}
|
||||
|
||||
public function kill() : void{
|
||||
$this->health = 0;
|
||||
$this->scheduleUpdate();
|
||||
if($this->isAlive()){
|
||||
$this->health = 0;
|
||||
$this->onDeath();
|
||||
$this->scheduleUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Override this to do actions on death.
|
||||
*/
|
||||
protected function onDeath() : void{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -844,7 +854,6 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
|
||||
|
||||
if($amount <= 0){
|
||||
if($this->isAlive()){
|
||||
$this->health = 0;
|
||||
$this->kill();
|
||||
}
|
||||
}elseif($amount <= $this->getMaxHealth() or $amount < $this->health){
|
||||
|
@ -640,12 +640,6 @@ abstract class Living extends Entity implements Damageable{
|
||||
}
|
||||
}
|
||||
|
||||
public function kill() : void{
|
||||
parent::kill();
|
||||
$this->onDeath();
|
||||
$this->startDeathAnimation();
|
||||
}
|
||||
|
||||
protected function onDeath() : void{
|
||||
$ev = new EntityDeathEvent($this, $this->getDrops());
|
||||
$ev->call();
|
||||
@ -656,6 +650,8 @@ abstract class Living extends Entity implements Damageable{
|
||||
//TODO: check death conditions (must have been damaged by player < 5 seconds from death)
|
||||
//TODO: allow this number to be manipulated during EntityDeathEvent
|
||||
$this->level->dropExperience($this, $this->getXpDropAmount());
|
||||
|
||||
$this->startDeathAnimation();
|
||||
}
|
||||
|
||||
protected function onDeathUpdate(int $tickDiff) : bool{
|
||||
|
@ -93,8 +93,8 @@ class Painting extends Entity{
|
||||
return $nbt;
|
||||
}
|
||||
|
||||
public function kill() : void{
|
||||
parent::kill();
|
||||
protected function onDeath() : void{
|
||||
parent::onDeath();
|
||||
|
||||
$drops = true;
|
||||
|
||||
|
Reference in New Issue
Block a user