diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/ManaRingSlot.java b/src/main/java/com/minelittlepony/unicopia/client/gui/ManaRingSlot.java index afa49488..c796e6d3 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/ManaRingSlot.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/ManaRingSlot.java @@ -65,8 +65,8 @@ class ManaRingSlot extends Slot { } private double renderRing(MatrixStack matrices, double outerRadius, double innerRadius, double offsetAngle, Bar bar, int color, float tickDelta) { - double fill = bar.getPercentFill() * DrawableUtil.TAU; - double shadow = bar.getShadowFill() * DrawableUtil.TAU; + double fill = bar.getPercentFill(tickDelta) * DrawableUtil.TAU; + double shadow = bar.getShadowFill(tickDelta) * DrawableUtil.TAU; DrawableUtil.drawArc(matrices, innerRadius, outerRadius, offsetAngle, fill, color, true); diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookProfilePageContent.java b/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookProfilePageContent.java index 71dcb05f..cd424205 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookProfilePageContent.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookProfilePageContent.java @@ -67,7 +67,8 @@ public class SpellbookProfilePageContent implements SpellbookChapterList.Content int y = SpellbookScreen.TITLE_Y; - float delta = pony.asEntity().age + client.getTickDelta(); + float tickDelta = client.getTickDelta(); + float delta = pony.asEntity().age + tickDelta; int currentLevel = pony.getLevel().get(); float currentScaledLevel = pony.getLevel().getScaled(1); float currentCorruption = pony.getCorruption().getScaled(1); @@ -100,8 +101,8 @@ public class SpellbookProfilePageContent implements SpellbookChapterList.Content double growth = MathHelper.sin(delta / 9F) * 2; double radius = 40 + growth; - float xpPercentage = reserves.getXp().getPercentFill(); - float manaPercentage = reserves.getMana().getPercentFill(); + float xpPercentage = reserves.getXp().getPercentFill(tickDelta); + float manaPercentage = reserves.getMana().getPercentFill(tickDelta); float alphaF = (MathHelper.sin(delta / 9F) + 1) / 2F; int alpha = (int)(alphaF * 0x10) & 0xFF; diff --git a/src/main/java/com/minelittlepony/unicopia/entity/player/MagicReserves.java b/src/main/java/com/minelittlepony/unicopia/entity/player/MagicReserves.java index 5db0b016..8b39defa 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/player/MagicReserves.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/player/MagicReserves.java @@ -41,7 +41,14 @@ public interface MagicReserves { /** * Gets the current value of this bar */ - float get(); + default float get() { + return get(1); + } + + /** + * Gets the (lerped) value of this bar + */ + float get(float tickDelta); /** * Sets the absolute value @@ -52,13 +59,20 @@ public interface MagicReserves { * Gets the percentage fill of this bar */ default float getPercentFill() { - return get() / getMax(); + return getPercentFill(1); + } + + /** + * Gets the percentage fill of this bar + */ + default float getPercentFill(float tickDelta) { + return get(tickDelta) / getMax(); } /** * Gets the shadow fill used for animating on the UI */ - float getShadowFill(); + float getShadowFill(float tickDelta); /** * Adds a percentage increment to this bar's current value diff --git a/src/main/java/com/minelittlepony/unicopia/entity/player/ManaContainer.java b/src/main/java/com/minelittlepony/unicopia/entity/player/ManaContainer.java index 96441f63..450e2fe3 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/player/ManaContainer.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/player/ManaContainer.java @@ -102,8 +102,8 @@ class ManaContainer implements MagicReserves, Tickable, NbtSerialisable, Copyabl } if (!pony.getSpecies().canFly() || !pony.getPhysics().isFlying()) { - if (mana.getPercentFill() < 1 && mana.getShadowFill() == mana.getPercentFill()) { - mana.addPercent(MathHelper.clamp(1 + pony.getLevel().get(), 1, 50)); + if (mana.getPercentFill() < 1 && mana.getShadowFill(1) <= mana.getPercentFill(1)) { + mana.addPercent(MathHelper.clamp(1 + pony.getLevel().get(), 1, 50) / 4F); } } @@ -157,6 +157,8 @@ class ManaContainer implements MagicReserves, Tickable, NbtSerialisable, Copyabl private final float max; private float trailingValue; + private float prevTrailingValue; + private float prevValue; BarInst(TrackedData marker, float max, float initial) { this.marker = marker; @@ -171,8 +173,13 @@ class ManaContainer implements MagicReserves, Tickable, NbtSerialisable, Copyabl } @Override - public float getShadowFill() { - return trailingValue; + public float get(float tickDelta) { + return MathHelper.lerp(tickDelta, prevValue, get()); + } + + @Override + public float getShadowFill(float tickDelta) { + return MathHelper.lerp(tickDelta, prevTrailingValue, trailingValue); } @Override @@ -203,6 +210,9 @@ class ManaContainer implements MagicReserves, Tickable, NbtSerialisable, Copyabl } void tick() { + prevValue = get(); + prevTrailingValue = trailingValue; + float fill = getPercentFill(); float trailingIncrement = 0.003F;