mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 16:51:42 +00:00
EntityDamageEvent: Add API to customize Living entity attack cooldown time
closes #2310
This commit is contained in:
parent
f582b5a3db
commit
47cd6fe105
@ -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();
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user