mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-07 10:22:56 +00:00
Implemented #3836: Replace setCancelled() in events with cancel() and uncancel()
The motivation for this is to prevent passing a dynamic argument to cancellation, which in almost all cases is a bug in user code. This same mistake also appears in a few places in the PM core (as seen in this commit), but in those cases the mistakes were mostly harmless since they were taking place before the event was actually called. closes #3836
This commit is contained in:
@ -356,7 +356,7 @@ abstract class Living extends Entity{
|
||||
public function applyDamageModifiers(EntityDamageEvent $source) : void{
|
||||
if($this->lastDamageCause !== null and $this->attackTime > 0){
|
||||
if($this->lastDamageCause->getBaseDamage() >= $source->getBaseDamage()){
|
||||
$source->setCancelled();
|
||||
$source->cancel();
|
||||
}
|
||||
$source->setModifier(-$this->lastDamageCause->getBaseDamage(), EntityDamageEvent::MODIFIER_PREVIOUS_DAMAGE_COOLDOWN);
|
||||
}
|
||||
@ -437,7 +437,7 @@ abstract class Living extends Entity{
|
||||
|
||||
public function attack(EntityDamageEvent $source) : void{
|
||||
if($this->noDamageTicks > 0){
|
||||
$source->setCancelled();
|
||||
$source->cancel();
|
||||
}
|
||||
|
||||
if($this->effectManager->has(VanillaEffects::FIRE_RESISTANCE()) and (
|
||||
@ -446,7 +446,7 @@ abstract class Living extends Entity{
|
||||
or $source->getCause() === EntityDamageEvent::CAUSE_LAVA
|
||||
)
|
||||
){
|
||||
$source->setCancelled();
|
||||
$source->cancel();
|
||||
}
|
||||
|
||||
$this->applyDamageModifiers($source);
|
||||
|
Reference in New Issue
Block a user