Skip to content

Commit

Permalink
Fightback: immediate chase if idle
Browse files Browse the repository at this point in the history
also more debug cleanup
  • Loading branch information
mcmonkey4eva committed Aug 13, 2021
1 parent 6986e8e commit 303b8be
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions src/main/java/org/mcmonkey/sentinel/SentinelTrait.java
Expand Up @@ -940,19 +940,15 @@ else if (projectileSource != null && targetingHelper.isIgnored(projectileSource)
}
if (getGuarding() != null && damager.getUniqueId().equals(getGuarding())) {
if (isMe && SentinelPlugin.instance.noGuardDamage) {
if (SentinelPlugin.debugMe) {
debug("Ignoring damage from the player we're guarding.");
}
debug("Ignoring damage from the player we're guarding.");
event.setCancelled(true);
}
return;
}
if (isMe) {
stats_damageTaken += event.getFinalDamage();
if (runaway) {
if (SentinelPlugin.debugMe) {
debug("Ow! They hit me! Run!");
}
debug("Ow! They hit me! Run!");
targetingHelper.addAvoid(damager.getUniqueId());
}
}
Expand All @@ -961,18 +957,18 @@ else if (projectileSource != null && targetingHelper.isIgnored(projectileSource)
debug("Fighting back against attacker: " + damager.getUniqueId() + "! They hurt " + (isMe ? "me!" : "my friend!"));
}
targetingHelper.addTarget(damager.getUniqueId());
if (chasing == null) {
attackHelper.chase((LivingEntity) damager);
}
}
if (SentinelPlugin.debugMe && isMe) {
debug("Took damage of " + event.getFinalDamage() + " with currently remaining health " + getLivingEntity().getHealth()
+ (isKilling ? ". This will kill me." : "."));
debug("Took damage of " + event.getFinalDamage() + " with currently remaining health " + getLivingEntity().getHealth() + (isKilling ? ". This will kill me." : "."));
}
if (isKilling && isMe && SentinelPlugin.instance.blockEvents) {
// We're going to die but we've been requested to avoid letting a death event fire.
// The solution at this point is to fake our death: remove the NPC entity from existence and trigger our internal death handling sequence.
// We also mark the damage event cancelled to reduce trouble (ensure event doesn't try to apply damage to our now-gone entity).
if (SentinelPlugin.debugMe) {
debug("Died! Applying death workaround (due to config setting)");
}
debug("Died! Applying death workaround (due to config setting)");
generalDeathHandler(getLivingEntity());
npc.despawn(DespawnReason.PLUGIN);
event.setCancelled(true);
Expand Down

0 comments on commit 303b8be

Please sign in to comment.