diff --git a/src/pocketmine/entity/Living.php b/src/pocketmine/entity/Living.php index b4cad9433..aa182f1fa 100644 --- a/src/pocketmine/entity/Living.php +++ b/src/pocketmine/entity/Living.php @@ -560,7 +560,7 @@ abstract class Living extends Entity implements Damageable{ return; } - $this->attackTime = 10; //0.5 seconds cooldown + $this->attackTime = $source->getAttackCooldown(); if($source instanceof EntityDamageByEntityEvent){ $e = $source->getDamager(); diff --git a/src/pocketmine/event/entity/EntityDamageEvent.php b/src/pocketmine/event/entity/EntityDamageEvent.php index fb448db95..bbde1967d 100644 --- a/src/pocketmine/event/entity/EntityDamageEvent.php +++ b/src/pocketmine/event/entity/EntityDamageEvent.php @@ -69,6 +69,9 @@ class EntityDamageEvent extends EntityEvent implements Cancellable{ /** @var float[] */ private $originals; + /** @var int */ + private $attackCooldown = 10; + /** * @param Entity $entity @@ -197,4 +200,24 @@ class EntityDamageEvent extends EntityEvent implements Cancellable{ return true; } + + /** + * Returns the cooldown in ticks before the target entity can be attacked again. + * + * @return int + */ + public function getAttackCooldown() : int{ + return $this->attackCooldown; + } + + /** + * Returns the cooldown in ticks before the target entity can be attacked again. + * + * NOTE: This value is not used in non-Living entities + * + * @param int $attackCooldown + */ + public function setAttackCooldown(int $attackCooldown) : void{ + $this->attackCooldown = $attackCooldown; + } }