diff --git a/Changelog.txt b/Changelog.txt index de6f23d8a..720bcc707 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -10,6 +10,7 @@ Version 2.1.196 (API) Added McMMOEntityDamageByRuptureEvent (thanks qixils) NOTES: + For now Rupture is non-lethal, I may add back a lethal component at the end of its damage Rupture will be in a state of change for a while as I receive feedback (give me feedback in Discord!) Crossbows is not in the default fishing loot list, you'd have to add it yourself. For Devs: McMMOEntityDamageByRuptureEvent extends EntityDamageByEntityEvent and uses CUSTOM type damage diff --git a/pom.xml b/pom.xml index 1c31c575e..e53d470e9 100755 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.gmail.nossr50.mcMMO mcMMO - 2.1.196-SNAPSHOT + 2.1.196 mcMMO https://github.com/mcMMO-Dev/mcMMO diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/RuptureTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/RuptureTask.java index b38d77842..29c6d6e5b 100644 --- a/src/main/java/com/gmail/nossr50/runnables/skills/RuptureTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/skills/RuptureTask.java @@ -13,7 +13,7 @@ import org.jetbrains.annotations.NotNull; public class RuptureTask extends BukkitRunnable { public static final int DAMAGE_TICK_INTERVAL = 10; - public static final int ANIMATION_TICK_INTERVAL = 2; + public static final int ANIMATION_TICK_INTERVAL = 1; private final @NotNull McMMOPlayer ruptureSource; private final @NotNull LivingEntity targetEntity; @@ -44,38 +44,22 @@ public class RuptureTask extends BukkitRunnable { ruptureTick += 1; //Advance rupture tick by 1. damageTickTracker += 1; //Increment damage tick tracker + //TODO: Clean this code up, applyRupture() is a confusing name for something that returns boolean //Rupture hasn't ended yet if(ruptureTick < expireTick) { //Is it time to damage? if(damageTickTracker >= DAMAGE_TICK_INTERVAL) { damageTickTracker = 0; //Reset timer - double healthBeforeRuptureIsApplied = targetEntity.getHealth(); + if (applyRupture()) return; - //Ensure victim has health - if (healthBeforeRuptureIsApplied > 0.01) { - //Send a fake damage event - McMMOEntityDamageByRuptureEvent event = new McMMOEntityDamageByRuptureEvent(ruptureSource, targetEntity, calculateAdjustedTickDamage()); - mcMMO.p.getServer().getPluginManager().callEvent(event); - - //Ensure the event wasn't cancelled and damage is still greater than 0 - double damage = event.getFinalDamage(); - if (event.isCancelled() || damage <= 0 || healthBeforeRuptureIsApplied - damage <= 0) - return; - - if(animationTick >= ANIMATION_TICK_INTERVAL) { - ParticleEffectUtils.playBleedEffect(targetEntity); //Animate - animationTick = 0; - } else { - animationTick++; - } - - double damagedHealth = healthBeforeRuptureIsApplied - damage; - - targetEntity.setHealth(damagedHealth); //Hurt entity without the unwanted side effects of damage()} - } + playAnimation(); } } else { + if(!applyRupture()) { + playAnimation(); + } + endRupture(); } } else { @@ -84,6 +68,38 @@ public class RuptureTask extends BukkitRunnable { } } + private void playAnimation() { + if(animationTick >= ANIMATION_TICK_INTERVAL) { + ParticleEffectUtils.playBleedEffect(targetEntity); //Animate + animationTick = 0; + } else { + animationTick++; + } + } + + private boolean applyRupture() { + double healthBeforeRuptureIsApplied = targetEntity.getHealth(); + + //Ensure victim has health + if (healthBeforeRuptureIsApplied > 0.01) { + //Send a fake damage event + McMMOEntityDamageByRuptureEvent event = new McMMOEntityDamageByRuptureEvent(ruptureSource, targetEntity, calculateAdjustedTickDamage()); + mcMMO.p.getServer().getPluginManager().callEvent(event); + + //Ensure the event wasn't cancelled and damage is still greater than 0 + double damage = event.getFinalDamage(); + + if (event.isCancelled() || damage <= 0 || healthBeforeRuptureIsApplied - damage <= 0) + return true; + + double damagedHealth = healthBeforeRuptureIsApplied - damage; + + targetEntity.setHealth(damagedHealth); //Hurt entity without the unwanted side effects of damage()} + } + + return false; + } + public void refreshRupture() { damageTickTracker = DAMAGE_TICK_INTERVAL; ruptureTick = 0;