mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-12 16:59:44 +00:00
Merge commit '5dadf1237'
# Conflicts: # resources/vanilla
This commit is contained in:
commit
c72937a4af
@ -355,6 +355,9 @@ abstract class Living extends Entity{
|
|||||||
* to effects or armour.
|
* to effects or armour.
|
||||||
*/
|
*/
|
||||||
public function applyDamageModifiers(EntityDamageEvent $source) : void{
|
public function applyDamageModifiers(EntityDamageEvent $source) : void{
|
||||||
|
if($this->lastDamageCause !== null and $this->attackTime > 0){
|
||||||
|
$source->setModifier(-$this->lastDamageCause->getBaseDamage(), EntityDamageEvent::MODIFIER_PREVIOUS_DAMAGE_COOLDOWN);
|
||||||
|
}
|
||||||
if($source->canBeReducedByArmor()){
|
if($source->canBeReducedByArmor()){
|
||||||
//MCPE uses the same system as PC did pre-1.9
|
//MCPE uses the same system as PC did pre-1.9
|
||||||
$source->setModifier(-$source->getFinalDamage() * $this->getArmorPoints() * 0.04, EntityDamageEvent::MODIFIER_ARMOR);
|
$source->setModifier(-$source->getFinalDamage() * $this->getArmorPoints() * 0.04, EntityDamageEvent::MODIFIER_ARMOR);
|
||||||
@ -433,11 +436,6 @@ abstract class Living extends Entity{
|
|||||||
public function attack(EntityDamageEvent $source) : void{
|
public function attack(EntityDamageEvent $source) : void{
|
||||||
if($this->noDamageTicks > 0){
|
if($this->noDamageTicks > 0){
|
||||||
$source->setCancelled();
|
$source->setCancelled();
|
||||||
}elseif($this->attackTime > 0){
|
|
||||||
$lastCause = $this->getLastDamageCause();
|
|
||||||
if($lastCause !== null and $lastCause->getBaseDamage() >= $source->getBaseDamage()){
|
|
||||||
$source->setCancelled();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->effectManager->has(VanillaEffects::FIRE_RESISTANCE()) and (
|
if($this->effectManager->has(VanillaEffects::FIRE_RESISTANCE()) and (
|
||||||
|
@ -43,6 +43,7 @@ class EntityDamageEvent extends EntityEvent implements Cancellable{
|
|||||||
public const MODIFIER_CRITICAL = 7;
|
public const MODIFIER_CRITICAL = 7;
|
||||||
public const MODIFIER_TOTEM = 8;
|
public const MODIFIER_TOTEM = 8;
|
||||||
public const MODIFIER_WEAPON_ENCHANTMENTS = 9;
|
public const MODIFIER_WEAPON_ENCHANTMENTS = 9;
|
||||||
|
public const MODIFIER_PREVIOUS_DAMAGE_COOLDOWN = 10;
|
||||||
|
|
||||||
public const CAUSE_CONTACT = 0;
|
public const CAUSE_CONTACT = 0;
|
||||||
public const CAUSE_ENTITY_ATTACK = 1;
|
public const CAUSE_ENTITY_ATTACK = 1;
|
||||||
@ -184,4 +185,8 @@ class EntityDamageEvent extends EntityEvent implements Cancellable{
|
|||||||
public function setAttackCooldown(int $attackCooldown) : void{
|
public function setAttackCooldown(int $attackCooldown) : void{
|
||||||
$this->attackCooldown = $attackCooldown;
|
$this->attackCooldown = $attackCooldown;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function isCancelled() : bool{
|
||||||
|
return parent::isCancelled() or $this->getFinalDamage() <= 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user