Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 12 additions & 13 deletions src/main/java/net/torocraft/torohealth/bars/BarState.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class BarState {

public float health;
public float previousHealth;
public float previousHealthDisplay;
public float previousHealthDisplay = 0;
public float previousHealthDelay;
public int lastDmg;
public int lastDmgCumulative;
Expand Down Expand Up @@ -61,25 +61,24 @@ private void handleHealthChange() {
lastDmgCumulative += lastDmg;

lastDmgDelay = HEALTH_INDICATOR_DELAY * 2;
previousHealthDisplay = Math.max(lastHealth, previousHealthDisplay);
if (previousHealthDisplay <= lastHealth) {
previousHealthDelay = HEALTH_INDICATOR_DELAY;
}
lastHealth = health;
if (ToroHealth.CONFIG.particle.show) {
BarStates.PARTICLES.add(new BarParticle(entity, lastDmg));
}
updateAnimationSpeed();
}

private void updateAnimationSpeed() {
animationSpeed = (previousHealthDisplay - health) / 10f;
}

private void updateAnimations() {
if (previousHealthDelay > 0) {
float diff = previousHealthDisplay - health;
if (diff > 0) {
animationSpeed = diff / 10f;
if (previousHealthDelay <= 0) {
previousHealthDisplay = Math.max(previousHealthDisplay - animationSpeed, health);
}
} else if (previousHealthDelay < 1 && previousHealthDisplay > health) {
previousHealthDisplay -= animationSpeed;
} else {
previousHealthDisplay = health;
previousHealth = health;
previousHealthDelay = HEALTH_INDICATOR_DELAY;
}
}

}