mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-03-03 16:51:28 +01:00
Fixed mana regen and consumption so gaining a higher mana cap has more obvious benefits
This commit is contained in:
parent
5f40b88fb4
commit
8331906d61
16 changed files with 36 additions and 29 deletions
|
@ -165,7 +165,7 @@ public class ChangelingFeedAbility implements Ability<Hit> {
|
|||
|
||||
@Override
|
||||
public void warmUp(Pony player, AbilitySlot slot) {
|
||||
player.getMagicalReserves().getExertion().add(6);
|
||||
player.getMagicalReserves().getExertion().addPercent(6);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -81,7 +81,7 @@ public class EarthPonyGrowAbility implements Ability<Pos> {
|
|||
|
||||
@Override
|
||||
public void warmUp(Pony player, AbilitySlot slot) {
|
||||
player.getMagicalReserves().getExertion().add(30);
|
||||
player.getMagicalReserves().getExertion().addPercent(30);
|
||||
|
||||
if (player.asWorld().isClient()) {
|
||||
player.spawnParticles(MagicParticleEffect.UNICORN, 1);
|
||||
|
|
|
@ -183,7 +183,7 @@ public class EarthPonyKickAbility implements Ability<Pos> {
|
|||
|
||||
@Override
|
||||
public void warmUp(Pony player, AbilitySlot slot) {
|
||||
player.getMagicalReserves().getExertion().add(40);
|
||||
player.getMagicalReserves().getExertion().addPercent(40);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -204,7 +204,7 @@ public class EarthPonyStompAbility implements Ability<Hit> {
|
|||
|
||||
@Override
|
||||
public void warmUp(Pony player, AbilitySlot slot) {
|
||||
player.getMagicalReserves().getExertion().add(40);
|
||||
player.getMagicalReserves().getExertion().addPercent(40);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -112,7 +112,7 @@ public class PegasusCaptureStormAbility implements Ability<Hit> {
|
|||
|
||||
@Override
|
||||
public void warmUp(Pony player, AbilitySlot slot) {
|
||||
player.getMagicalReserves().getExertion().add(6);
|
||||
player.getMagicalReserves().getExertion().addPercent(6);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -76,7 +76,7 @@ public class PegasusFlightToggleAbility implements Ability<Hit> {
|
|||
|
||||
@Override
|
||||
public void warmUp(Pony player, AbilitySlot slot) {
|
||||
player.getMagicalReserves().getExertion().add(6);
|
||||
player.getMagicalReserves().getExertion().addPercent(6);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -80,7 +80,7 @@ public class PegasusRainboomAbility implements Ability<Hit> {
|
|||
|
||||
@Override
|
||||
public void warmUp(Pony player, AbilitySlot slot) {
|
||||
player.getMagicalReserves().getExertion().add(6);
|
||||
player.getMagicalReserves().getExertion().addPercent(6);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -88,7 +88,7 @@ public class UnicornCastingAbility extends AbstractSpellCastingAbility {
|
|||
|
||||
if (amount < 0) {
|
||||
ChargeableItem.consumeEnergy(stack, amount);
|
||||
player.getMagicalReserves().getMana().add(amount * player.getMagicalReserves().getMana().getMax());
|
||||
player.getMagicalReserves().getMana().add(amount);
|
||||
player.asWorld().playSoundFromEntity(null, player.asEntity(), USounds.ITEM_AMULET_RECHARGE, SoundCategory.PLAYERS, 1, 1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -199,7 +199,7 @@ public class UnicornTeleportAbility implements Ability<Pos> {
|
|||
|
||||
@Override
|
||||
public void warmUp(Pony player, AbilitySlot slot) {
|
||||
player.getMagicalReserves().getExertion().add(30);
|
||||
player.getMagicalReserves().getExertion().addPercent(30);
|
||||
player.spawnParticles(MagicParticleEffect.UNICORN, 5);
|
||||
}
|
||||
|
||||
|
|
|
@ -98,7 +98,7 @@ public class RaceChangeStatusEffect extends StatusEffect {
|
|||
if (eq instanceof Pony pony) {
|
||||
MagicReserves magic = pony.getMagicalReserves();
|
||||
pony.setRespawnRace(race);
|
||||
magic.getExertion().add(50);
|
||||
magic.getExertion().addPercent(5);
|
||||
magic.getEnergy().add(3);
|
||||
magic.getExhaustion().add(3);
|
||||
|
||||
|
|
|
@ -63,8 +63,15 @@ public interface MagicReserves {
|
|||
/**
|
||||
* Adds a percentage increment to this bar's current value
|
||||
*/
|
||||
default void add(float step) {
|
||||
set(get() + (step / getMax()));
|
||||
default void addPercent(float percentChange) {
|
||||
set(get() + ((percentChange / 100F) * getMax()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a flat amount to this bar's current value
|
||||
*/
|
||||
default void add(float flatAmount) {
|
||||
set(get() + flatAmount);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -11,7 +11,7 @@ import net.minecraft.entity.data.TrackedData;
|
|||
import net.minecraft.nbt.NbtCompound;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
|
||||
public class ManaContainer implements MagicReserves, Tickable, NbtSerialisable, Copyable<ManaContainer> {
|
||||
class ManaContainer implements MagicReserves, Tickable, NbtSerialisable, Copyable<ManaContainer> {
|
||||
private final Pony pony;
|
||||
|
||||
private final Map<String, BarInst> bars = new HashMap<>();
|
||||
|
@ -87,23 +87,23 @@ public class ManaContainer implements MagicReserves, Tickable, NbtSerialisable,
|
|||
public void tick() {
|
||||
bars.values().forEach(BarInst::tick);
|
||||
|
||||
exertion.add(-10);
|
||||
exertion.addPercent(-10);
|
||||
|
||||
if (energy.get() > 5) {
|
||||
energy.multiply(0.8F);
|
||||
} else {
|
||||
energy.add(-1);
|
||||
energy.addPercent(-1);
|
||||
}
|
||||
|
||||
if (pony.getSpecies().canFly() && !pony.getPhysics().isFlying()) {
|
||||
exhaustion.multiply(0.8F);
|
||||
} else {
|
||||
exhaustion.add(-1);
|
||||
exhaustion.addPercent(-1);
|
||||
}
|
||||
|
||||
if (!pony.getSpecies().canFly() || !pony.getPhysics().isFlying()) {
|
||||
if (mana.getPercentFill() < 1 && mana.getShadowFill() == mana.getPercentFill()) {
|
||||
mana.add((mana.getMax() / 10F) * Math.max(1, pony.getLevel().get() * 4));
|
||||
mana.addPercent(MathHelper.clamp(1 + pony.getLevel().get(), 1, 50));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ class PlayerLevelStore implements Levelled.LevelStore {
|
|||
Levelled.LevelStore.super.add(levels);
|
||||
if (levels > 0) {
|
||||
if (upgradeMana) {
|
||||
pony.getMagicalReserves().getMana().add(pony.getMagicalReserves().getMana().getMax() / 2);
|
||||
pony.getMagicalReserves().getMana().addPercent(50);
|
||||
}
|
||||
pony.asWorld().playSound(null, pony.getOrigin(), levelUpSound, SoundCategory.PLAYERS, 1, 2);
|
||||
}
|
||||
|
|
|
@ -339,7 +339,7 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
|
|||
}
|
||||
|
||||
if (ticksDiving > 0 && ticksDiving % 25 == 0) {
|
||||
pony.getMagicalReserves().getCharge().add(25);
|
||||
pony.getMagicalReserves().getCharge().addPercent(12.5F);
|
||||
}
|
||||
} else {
|
||||
prevStrafe = 0;
|
||||
|
@ -474,15 +474,15 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
|
|||
if (ticksInAir > (level * 100)) {
|
||||
Bar mana = pony.getMagicalReserves().getMana();
|
||||
|
||||
float cost = (float)-getHorizontalMotion() * 20F / level;
|
||||
if (entity.isSneaking()) {
|
||||
float cost = (float)-getHorizontalMotion() / 2F;
|
||||
if (((LivingEntityDuck)entity).isJumping()) {
|
||||
cost /= 10;
|
||||
}
|
||||
|
||||
mana.add(cost);
|
||||
mana.add(MathHelper.clamp(cost, -100, 0));
|
||||
|
||||
if (mana.getPercentFill() < 0.2) {
|
||||
pony.getMagicalReserves().getExertion().add(2);
|
||||
pony.getMagicalReserves().getExertion().addPercent(2);
|
||||
pony.getMagicalReserves().getExhaustion().add(2 + (int)(getHorizontalMotion() * 50));
|
||||
|
||||
if (mana.getPercentFill() < 0.1 && ticksInAir % 10 == 0) {
|
||||
|
@ -499,7 +499,7 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
|
|||
|
||||
if (entity.getWorld().random.nextInt(110) == 1 && !pony.isClient()) {
|
||||
pony.getLevel().add(1);
|
||||
pony.getMagicalReserves().getCharge().add(4);
|
||||
pony.getMagicalReserves().getCharge().addPercent(4);
|
||||
pony.getMagicalReserves().getExertion().set(0);
|
||||
pony.getMagicalReserves().getExhaustion().set(0);
|
||||
mana.set(mana.getMax() * 100);
|
||||
|
|
|
@ -228,12 +228,12 @@ public class AlicornAmuletItem extends AmuletItem implements ItemTracker.Trackab
|
|||
|
||||
// constantly increase exertion
|
||||
if (reserves.getExertion().get() < reserves.getExertion().getMax()) {
|
||||
reserves.getExertion().add(2);
|
||||
reserves.getExertion().add(0.02F);
|
||||
}
|
||||
|
||||
// gradual corruption accumulation
|
||||
if (fullSecond && world.random.nextInt(12) == 0 && !pony.asEntity().isCreative()) {
|
||||
reserves.getEnergy().add(reserves.getEnergy().getMax() / 10F);
|
||||
reserves.getEnergy().add(10);
|
||||
pony.getCorruption().add((int)MathHelper.clamp(attachedTicks / ItemTracker.HOURS, 1, pony.getCorruption().getMax()));
|
||||
}
|
||||
|
||||
|
@ -245,8 +245,8 @@ public class AlicornAmuletItem extends AmuletItem implements ItemTracker.Trackab
|
|||
InteractionManager.INSTANCE.playLoopingSound(player, InteractionManager.SOUND_HEART_BEAT, 0);
|
||||
}
|
||||
|
||||
reserves.getExertion().add(reserves.getExertion().getMax());
|
||||
reserves.getEnergy().add(reserves.getEnergy().getMax() / 2F);
|
||||
reserves.getExertion().addPercent(10);
|
||||
reserves.getEnergy().add(10);
|
||||
living.asEntity().removeStatusEffect(StatusEffects.WEAKNESS);
|
||||
living.asEntity().removeStatusEffect(StatusEffects.NAUSEA);
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ public class StressfulEnchantment extends SimpleEnchantment {
|
|||
Bar bar = ((Pony)user).getMagicalReserves().getEnergy();
|
||||
float targetPercent = (level / (float)getMaxLevel()) * 0.25F;
|
||||
if (bar.getPercentFill() < targetPercent) {
|
||||
bar.add(10);
|
||||
bar.add(0.1F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue