mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 05:06:45 +01:00
2.1.196
This commit is contained in:
parent
f983f95961
commit
da1fcfe30a
@ -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
|
||||||
|
2
pom.xml
2
pom.xml
@ -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>
|
||||||
|
@ -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,38 +44,22 @@ 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
|
||||||
double healthBeforeRuptureIsApplied = targetEntity.getHealth();
|
if (applyRupture()) return;
|
||||||
|
|
||||||
//Ensure victim has health
|
playAnimation();
|
||||||
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()}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if(!applyRupture()) {
|
||||||
|
playAnimation();
|
||||||
|
}
|
||||||
|
|
||||||
endRupture();
|
endRupture();
|
||||||
}
|
}
|
||||||
} else {
|
} 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() {
|
public void refreshRupture() {
|
||||||
damageTickTracker = DAMAGE_TICK_INTERVAL;
|
damageTickTracker = DAMAGE_TICK_INTERVAL;
|
||||||
ruptureTick = 0;
|
ruptureTick = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user