Fixed mana not being consumed at correct rates and added a ring for the xp progress

This commit is contained in:
Sollace 2020-10-09 19:35:47 +02:00
parent c300e401b5
commit 312afe3d46
4 changed files with 12 additions and 6 deletions

View file

@ -35,6 +35,8 @@ class ManaRingSlot extends Slot {
arcBegin = renderRing(matrices, 17, 13, 0, mana.getMana(), 0xFF88FF99); arcBegin = renderRing(matrices, 17, 13, 0, mana.getMana(), 0xFF88FF99);
if (!uHud.client.player.isCreative()) { if (!uHud.client.player.isCreative()) {
renderRing(matrices, 13, 11, 0, mana.getXp(), 0x88880099);
double cost = abilities.getStats().stream() double cost = abilities.getStats().stream()
.mapToDouble(s -> s.getCost(KeyBindingsHandler.INSTANCE.page)) .mapToDouble(s -> s.getCost(KeyBindingsHandler.INSTANCE.page))
.reduce(Double::sum) .reduce(Double::sum)
@ -44,7 +46,7 @@ class ManaRingSlot extends Slot {
float percent = mana.getMana().getPercentFill(); float percent = mana.getMana().getPercentFill();
float max = mana.getMana().getMax(); float max = mana.getMana().getMax();
cost = Math.min(max, cost) / max; cost = Math.min(max, cost * 10) / max;
cost = Math.min(percent, cost); cost = Math.min(percent, cost);

View file

@ -20,6 +20,12 @@ public interface MagicReserves {
*/ */
Bar getMana(); Bar getMana();
/**
* The progress to the next experience level.
* This is increased slowly by performing actions that consume mana.
*/
Bar getXp();
public interface Bar { public interface Bar {
/** /**

View file

@ -34,6 +34,7 @@ public class ManaContainer implements MagicReserves {
return mana; return mana;
} }
@Override
public Bar getXp() { public Bar getXp() {
return xp; return xp;
} }
@ -49,10 +50,7 @@ public class ManaContainer implements MagicReserves {
float diff = value - get(); float diff = value - get();
if (diff < 0) { if (diff < 0) {
if (pony.getLevel().canLevelUp()) { if (pony.getLevel().canLevelUp()) {
xp.add(-diff / (float)Math.pow(1000, 1 + pony.getLevel().get()));
diff /= Math.pow(1000, 1 + pony.getLevel().get());
xp.add(-diff);
if (xp.getPercentFill() >= 1) { if (xp.getPercentFill() >= 1) {
pony.getLevel().add(1); pony.getLevel().add(1);
xp.set(0); xp.set(0);

View file

@ -130,7 +130,7 @@ public class PlayerPhysics extends EntityPhysics<Pony> implements Tickable, Moti
if (ticksInAir++ > (level * 100)) { if (ticksInAir++ > (level * 100)) {
Bar mana = pony.getMagicalReserves().getMana(); Bar mana = pony.getMagicalReserves().getMana();
mana.add((int)(-getHorizontalMotion(entity) * 50 / level)); mana.add((float)-getHorizontalMotion(entity) * 20F / level);
if (mana.getPercentFill() < 0.2) { if (mana.getPercentFill() < 0.2) {
pony.getMagicalReserves().getExertion().add(2); pony.getMagicalReserves().getExertion().add(2);