mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-05 17:36:12 +00:00
Implemented Absorption effect
This is a little buggy due to a client-sided bug. https://bugs.mojang.com/browse/MCPE-20520 TODO: add attribute save/restore
This commit is contained in:
@ -735,7 +735,21 @@ abstract class Entity extends Location implements Metadatable{
|
||||
|
||||
$this->setLastDamageCause($source);
|
||||
|
||||
$this->setHealth($this->getHealth() - $source->getFinalDamage());
|
||||
$damage = $source->getFinalDamage();
|
||||
|
||||
$absorption = $this->getAbsorption();
|
||||
if($absorption > 0){
|
||||
if($absorption > $damage){
|
||||
//Use absorption health before normal health.
|
||||
$this->setAbsorption($absorption - $damage);
|
||||
$damage = 0;
|
||||
}else{
|
||||
$this->setAbsorption(0);
|
||||
$damage -= $absorption;
|
||||
}
|
||||
}
|
||||
|
||||
$this->setHealth($this->getHealth() - $damage);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -785,6 +799,14 @@ abstract class Entity extends Location implements Metadatable{
|
||||
}
|
||||
}
|
||||
|
||||
public function getAbsorption() : int{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function setAbsorption(int $absorption){
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param EntityDamageEvent $type
|
||||
*/
|
||||
|
Reference in New Issue
Block a user