mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-07 12:18:46 +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->age += $tickDiff;
|
||||||
$this->ticksLived += $tickDiff;
|
$this->ticksLived += $tickDiff;
|
||||||
|
|
||||||
|
@ -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);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user