Implemented no damage ticks

This commit is contained in:
Shoghi Cervantes 2014-12-05 02:24:08 +01:00
parent 1a064d38b1
commit add7879720
2 changed files with 10 additions and 1 deletions

View File

@ -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->age += $tickDiff;
$this->ticksLived += $tickDiff; $this->ticksLived += $tickDiff;

View File

@ -69,7 +69,7 @@ abstract class Living extends Entity implements Damageable{
} }
public function attack($damage, $source = EntityDamageEvent::CAUSE_MAGIC){ public function attack($damage, $source = EntityDamageEvent::CAUSE_MAGIC){
if($this->attackTime > 0){ if($this->attackTime > 0 or $this->noDamageTicks > 0){
$lastCause = $this->getLastDamageCause(); $lastCause = $this->getLastDamageCause();
if($lastCause instanceof EntityDamageEvent and $lastCause->getDamage() >= $damage){ if($lastCause instanceof EntityDamageEvent and $lastCause->getDamage() >= $damage){
if($source instanceof EntityDamageEvent){ if($source instanceof EntityDamageEvent){
@ -82,6 +82,8 @@ abstract class Living extends Entity implements Damageable{
}else{ }else{
return; return;
} }
}else{
return;
} }
}elseif($source instanceof EntityDamageEvent){ }elseif($source instanceof EntityDamageEvent){
$this->server->getPluginManager()->callEvent($source); $this->server->getPluginManager()->callEvent($source);