This commit is contained in:
nossr50 2021-04-23 11:26:35 -07:00
parent f983f95961
commit da1fcfe30a
3 changed files with 42 additions and 25 deletions

View File

@ -10,6 +10,7 @@ Version 2.1.196
(API) Added McMMOEntityDamageByRuptureEvent (thanks qixils) (API) Added McMMOEntityDamageByRuptureEvent (thanks qixils)
NOTES: 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!) 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. 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 For Devs: McMMOEntityDamageByRuptureEvent extends EntityDamageByEntityEvent and uses CUSTOM type damage

View File

@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>com.gmail.nossr50.mcMMO</groupId> <groupId>com.gmail.nossr50.mcMMO</groupId>
<artifactId>mcMMO</artifactId> <artifactId>mcMMO</artifactId>
<version>2.1.196-SNAPSHOT</version> <version>2.1.196</version>
<name>mcMMO</name> <name>mcMMO</name>
<url>https://github.com/mcMMO-Dev/mcMMO</url> <url>https://github.com/mcMMO-Dev/mcMMO</url>
<scm> <scm>

View File

@ -13,7 +13,7 @@ import org.jetbrains.annotations.NotNull;
public class RuptureTask extends BukkitRunnable { public class RuptureTask extends BukkitRunnable {
public static final int DAMAGE_TICK_INTERVAL = 10; 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 McMMOPlayer ruptureSource;
private final @NotNull LivingEntity targetEntity; private final @NotNull LivingEntity targetEntity;
@ -44,12 +44,40 @@ public class RuptureTask extends BukkitRunnable {
ruptureTick += 1; //Advance rupture tick by 1. ruptureTick += 1; //Advance rupture tick by 1.
damageTickTracker += 1; //Increment damage tick tracker 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 //Rupture hasn't ended yet
if(ruptureTick < expireTick) { if(ruptureTick < expireTick) {
//Is it time to damage? //Is it time to damage?
if(damageTickTracker >= DAMAGE_TICK_INTERVAL) { if(damageTickTracker >= DAMAGE_TICK_INTERVAL) {
damageTickTracker = 0; //Reset timer damageTickTracker = 0; //Reset timer
if (applyRupture()) return;
playAnimation();
}
} else {
if(!applyRupture()) {
playAnimation();
}
endRupture();
}
} else {
targetEntity.removeMetadata(mcMMO.RUPTURE_META_KEY, mcMMO.p);
this.cancel(); //Task no longer needed
}
}
private void playAnimation() {
if(animationTick >= ANIMATION_TICK_INTERVAL) {
ParticleEffectUtils.playBleedEffect(targetEntity); //Animate
animationTick = 0;
} else {
animationTick++;
}
}
private boolean applyRupture() {
double healthBeforeRuptureIsApplied = targetEntity.getHealth(); double healthBeforeRuptureIsApplied = targetEntity.getHealth();
//Ensure victim has health //Ensure victim has health
@ -60,28 +88,16 @@ public class RuptureTask extends BukkitRunnable {
//Ensure the event wasn't cancelled and damage is still greater than 0 //Ensure the event wasn't cancelled and damage is still greater than 0
double damage = event.getFinalDamage(); double damage = event.getFinalDamage();
if (event.isCancelled() || damage <= 0 || healthBeforeRuptureIsApplied - damage <= 0)
return;
if(animationTick >= ANIMATION_TICK_INTERVAL) { if (event.isCancelled() || damage <= 0 || healthBeforeRuptureIsApplied - damage <= 0)
ParticleEffectUtils.playBleedEffect(targetEntity); //Animate return true;
animationTick = 0;
} else {
animationTick++;
}
double damagedHealth = healthBeforeRuptureIsApplied - damage; double damagedHealth = healthBeforeRuptureIsApplied - damage;
targetEntity.setHealth(damagedHealth); //Hurt entity without the unwanted side effects of damage()} targetEntity.setHealth(damagedHealth); //Hurt entity without the unwanted side effects of damage()}
} }
}
} else { return false;
endRupture();
}
} else {
targetEntity.removeMetadata(mcMMO.RUPTURE_META_KEY, mcMMO.p);
this.cancel(); //Task no longer needed
}
} }
public void refreshRupture() { public void refreshRupture() {