mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-21 16:24:05 +00:00
Implemented no damage ticks
This commit is contained in:
parent
1a064d38b1
commit
add7879720
@ -566,6 +566,13 @@ abstract class Entity extends Location implements Metadatable{
|
||||
}
|
||||
}
|
||||
|
||||
if($this->noDamageTicks > 0){
|
||||
$this->noDamageTicks -= $tickDiff;
|
||||
if($this->noDamageTicks < 0){
|
||||
$this->noDamageTicks = 0;
|
||||
}
|
||||
}
|
||||
|
||||
$this->age += $tickDiff;
|
||||
$this->ticksLived += $tickDiff;
|
||||
|
||||
|
@ -69,7 +69,7 @@ abstract class Living extends Entity implements Damageable{
|
||||
}
|
||||
|
||||
public function attack($damage, $source = EntityDamageEvent::CAUSE_MAGIC){
|
||||
if($this->attackTime > 0){
|
||||
if($this->attackTime > 0 or $this->noDamageTicks > 0){
|
||||
$lastCause = $this->getLastDamageCause();
|
||||
if($lastCause instanceof EntityDamageEvent and $lastCause->getDamage() >= $damage){
|
||||
if($source instanceof EntityDamageEvent){
|
||||
@ -82,6 +82,8 @@ abstract class Living extends Entity implements Damageable{
|
||||
}else{
|
||||
return;
|
||||
}
|
||||
}else{
|
||||
return;
|
||||
}
|
||||
}elseif($source instanceof EntityDamageEvent){
|
||||
$this->server->getPluginManager()->callEvent($source);
|
||||
|
Loading…
x
Reference in New Issue
Block a user