mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-23 21:38:00 +01:00
Added a separate stat for magical exhaustion
This commit is contained in:
parent
d75d48d13d
commit
ca787254f2
10 changed files with 72 additions and 31 deletions
|
@ -145,7 +145,7 @@ public class UnicornCastingAbility implements Ability<Hit> {
|
|||
|
||||
@Override
|
||||
public void preApply(Pony player, AbilitySlot slot) {
|
||||
player.getMagicalReserves().getEnergy().multiply(3.3F);
|
||||
player.getMagicalReserves().getExhaustion().multiply(3.3F);
|
||||
|
||||
if (getAmulet(player).getResult() == ActionResult.CONSUME) {
|
||||
Vec3d eyes = player.getMaster().getCameraPosVec(1);
|
||||
|
|
|
@ -87,7 +87,7 @@ public class UnicornProjectileAbility implements Ability<Hit> {
|
|||
|
||||
@Override
|
||||
public void preApply(Pony player, AbilitySlot slot) {
|
||||
player.getMagicalReserves().getEnergy().multiply(3.3F);
|
||||
player.getMagicalReserves().getExhaustion().multiply(3.3F);
|
||||
player.spawnParticles(MagicParticleEffect.UNICORN, 5);
|
||||
}
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ public class JoustingSpell extends AbstractSpell implements Attached {
|
|||
|
||||
source.getEntity().setVelocity(velocity);
|
||||
if (source instanceof Pony) {
|
||||
((Pony)source).getMagicalReserves().getEnergy().multiply(0.2F);
|
||||
((Pony)source).getMagicalReserves().getExhaustion().multiply(0.2F);
|
||||
}
|
||||
|
||||
return !source.getEntity().isRemoved() && age++ < 90 + 7 * (source.getLevel().get() + 1);
|
||||
|
|
|
@ -63,7 +63,7 @@ class ManaRingSlot extends Slot {
|
|||
}
|
||||
}
|
||||
|
||||
arcBegin = renderRing(matrices, 17, 13, arcBegin, mana.getEnergy(), 0xFF002299, tickDelta);
|
||||
arcBegin = renderRing(matrices, 17, 13, arcBegin, mana.getExhaustion(), 0xFF002299, tickDelta);
|
||||
|
||||
matrices.pop();
|
||||
|
||||
|
|
|
@ -21,8 +21,10 @@ import net.minecraft.client.font.TextRenderer;
|
|||
import net.minecraft.client.gui.DrawableHelper;
|
||||
import net.minecraft.client.gui.hud.InGameHud;
|
||||
import net.minecraft.client.gui.screen.ingame.InventoryScreen;
|
||||
import net.minecraft.client.sound.PositionedSoundInstance;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.entity.EntityDimensions;
|
||||
import net.minecraft.sound.SoundEvents;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Arm;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
@ -66,32 +68,7 @@ public class UHud extends DrawableHelper {
|
|||
|
||||
Pony pony = Pony.of(client.player);
|
||||
|
||||
boolean hasEffect = client.player.hasStatusEffect(SunBlindnessStatusEffect.INSTANCE);
|
||||
|
||||
if (hasEffect || (pony.getSpecies() == Race.BAT && SunBlindnessStatusEffect.hasSunExposure(client.player))) {
|
||||
float i = hasEffect ? (client.player.getStatusEffect(SunBlindnessStatusEffect.INSTANCE).getDuration() - tickDelta) / SunBlindnessStatusEffect.MAX_DURATION : 0;
|
||||
|
||||
float pulse = (1 + (float)Math.sin(client.player.age / 108F)) * 0.25F;
|
||||
|
||||
float strength = MathHelper.clamp(pulse + i, 0.3F, 1F);
|
||||
|
||||
int alpha1 = (int)(strength * 205) << 24 & -16777216;
|
||||
int alpha2 = (int)(alpha1 * 0.6F);
|
||||
|
||||
fillGradient(matrices, 0, 0, scaledWidth, scaledHeight / 2, 0xFFFFFF | alpha1, 0xFFFFFF | alpha2);
|
||||
fillGradient(matrices, 0, scaledHeight / 2, scaledWidth, scaledHeight, 0xFFFFFF | alpha2, 0xFFFFFF | alpha1);
|
||||
|
||||
if (hasEffect) {
|
||||
matrices.push();
|
||||
matrices.translate(scaledWidth, 0, 0);
|
||||
matrices.multiply(Vec3f.POSITIVE_Z.getDegreesQuaternion(90));
|
||||
|
||||
fillGradient(matrices, 0, 0, scaledHeight, scaledWidth / 2, 0xFFFFFF | 0, 0xFFFFFF | alpha2);
|
||||
fillGradient(matrices, 0, scaledWidth / 2, scaledHeight, scaledWidth, 0xFFFFFF | alpha2, 0xFFFFFF | 0);
|
||||
|
||||
matrices.pop();
|
||||
}
|
||||
}
|
||||
renderViewEffects(pony, matrices, scaledWidth, scaledHeight, tickDelta);
|
||||
|
||||
if (client.currentScreen instanceof HidesHud || client.player.isSpectator() || client.options.hudHidden) {
|
||||
return;
|
||||
|
@ -169,6 +146,50 @@ public class UHud extends DrawableHelper {
|
|||
}
|
||||
}
|
||||
|
||||
protected void renderViewEffects(Pony pony, MatrixStack matrices, int scaledWidth, int scaledHeight, float tickDelta) {
|
||||
|
||||
boolean hasEffect = client.player.hasStatusEffect(SunBlindnessStatusEffect.INSTANCE);
|
||||
|
||||
if (hasEffect || (pony.getSpecies() == Race.BAT && SunBlindnessStatusEffect.hasSunExposure(client.player))) {
|
||||
float i = hasEffect ? (client.player.getStatusEffect(SunBlindnessStatusEffect.INSTANCE).getDuration() - tickDelta) / SunBlindnessStatusEffect.MAX_DURATION : 0;
|
||||
|
||||
float pulse = (1 + (float)Math.sin(client.player.age / 108F)) * 0.25F;
|
||||
|
||||
float strength = MathHelper.clamp(pulse + i, 0.3F, 1F);
|
||||
|
||||
int alpha1 = (int)(strength * 205) << 24 & -16777216;
|
||||
int alpha2 = (int)(alpha1 * 0.6F);
|
||||
|
||||
fillGradient(matrices, 0, 0, scaledWidth, scaledHeight / 2, 0xFFFFFF | alpha1, 0xFFFFFF | alpha2);
|
||||
fillGradient(matrices, 0, scaledHeight / 2, scaledWidth, scaledHeight, 0xFFFFFF | alpha2, 0xFFFFFF | alpha1);
|
||||
|
||||
if (hasEffect) {
|
||||
matrices.push();
|
||||
matrices.translate(scaledWidth, 0, 0);
|
||||
matrices.multiply(Vec3f.POSITIVE_Z.getDegreesQuaternion(90));
|
||||
|
||||
fillGradient(matrices, 0, 0, scaledHeight, scaledWidth / 2, 0xFFFFFF | 0, 0xFFFFFF | alpha2);
|
||||
fillGradient(matrices, 0, scaledWidth / 2, scaledHeight, scaledWidth, 0xFFFFFF | alpha2, 0xFFFFFF | 0);
|
||||
|
||||
matrices.pop();
|
||||
}
|
||||
}
|
||||
|
||||
float exhaustion = pony.getMagicalReserves().getExhaustion().getPercentFill();
|
||||
|
||||
if (exhaustion > 0.5F) {
|
||||
if (tickDelta == 0) {
|
||||
client.getSoundManager().play(PositionedSoundInstance.master(SoundEvents.BLOCK_ANVIL_BREAK, 1));
|
||||
}
|
||||
|
||||
int alpha1 = 205 << 24 & -16777216;
|
||||
int alpha2 = (int)(alpha1 * 0.6F);
|
||||
|
||||
fillGradient(matrices, 0, 0, scaledWidth, scaledHeight / 2, 0xFFFFFF | alpha1, 0x000000 | alpha2);
|
||||
fillGradient(matrices, 0, scaledHeight / 2, scaledWidth, scaledHeight, 0xFFFFFF | alpha2, 0x000000 | alpha1);
|
||||
}
|
||||
}
|
||||
|
||||
public void setMessage(Text message) {
|
||||
this.message = message;
|
||||
this.messageTime = 60;
|
||||
|
|
|
@ -93,6 +93,7 @@ public class RaceChangeStatusEffect extends StatusEffect {
|
|||
MagicReserves magic = pony.getMagicalReserves();
|
||||
magic.getExertion().add(50);
|
||||
magic.getEnergy().add(3);
|
||||
magic.getExhaustion().add(3);
|
||||
|
||||
if (state.shouldShowParticles()) {
|
||||
pony.spawnParticles(ParticleTypes.TOTEM_OF_UNDYING, 5);
|
||||
|
|
|
@ -14,6 +14,11 @@ public interface MagicReserves {
|
|||
*/
|
||||
Bar getEnergy();
|
||||
|
||||
/**
|
||||
* Gets the amount of fatigue induced by using magic.
|
||||
*/
|
||||
Bar getExhaustion();
|
||||
|
||||
/**
|
||||
* Gets the amount of magical energy the player has.
|
||||
* This is increases slowly with time by performing certain actions.
|
||||
|
|
|
@ -9,6 +9,7 @@ public class ManaContainer implements MagicReserves, Tickable {
|
|||
private final Pony pony;
|
||||
|
||||
private final BarInst energy;
|
||||
private final BarInst exhaustion;
|
||||
private final BarInst exertion;
|
||||
private final BarInst mana;
|
||||
private final BarInst xp;
|
||||
|
@ -16,6 +17,7 @@ public class ManaContainer implements MagicReserves, Tickable {
|
|||
public ManaContainer(Pony pony) {
|
||||
this.pony = pony;
|
||||
this.energy = new BarInst(Pony.ENERGY, 100F, 0);
|
||||
this.exhaustion = new BarInst(Pony.EXHAUSTION, 100F, 0);
|
||||
this.exertion = new BarInst(Pony.EXERTION, 10F, 0);
|
||||
this.xp = new BarInst(Pony.XP, 1, 0);
|
||||
this.mana = new XpCollectingBar(Pony.MANA, 100F, 100F);
|
||||
|
@ -26,6 +28,11 @@ public class ManaContainer implements MagicReserves, Tickable {
|
|||
return exertion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Bar getExhaustion() {
|
||||
return exhaustion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Bar getEnergy() {
|
||||
return energy;
|
||||
|
@ -56,6 +63,12 @@ public class ManaContainer implements MagicReserves, Tickable {
|
|||
energy.add(-1);
|
||||
}
|
||||
|
||||
if (exhaustion.get() > 5) {
|
||||
exhaustion.multiply(0.8F);
|
||||
} else {
|
||||
exhaustion.add(-1);
|
||||
}
|
||||
|
||||
if (!pony.getSpecies().canFly() || !pony.getPhysics().isFlying()) {
|
||||
if (mana.getShadowFill() <= mana.getPercentFill()) {
|
||||
mana.add(18);
|
||||
|
|
|
@ -364,7 +364,7 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
|
|||
|
||||
if (mana.getPercentFill() < 0.2) {
|
||||
pony.getMagicalReserves().getExertion().add(2);
|
||||
pony.getMagicalReserves().getEnergy().add(2 + (int)(getHorizontalMotion(entity) * 5));
|
||||
pony.getMagicalReserves().getExhaustion().add(2 + (int)(getHorizontalMotion(entity) * 50));
|
||||
|
||||
if (mana.getPercentFill() < 0.1 && ticksInAir % 10 == 0) {
|
||||
float exhaustion = (0.3F * ticksInAir) / 70;
|
||||
|
|
|
@ -62,6 +62,7 @@ public class Pony extends Living<PlayerEntity> implements Transmittable, Copieab
|
|||
private static final TrackedData<Integer> RACE = DataTracker.registerData(PlayerEntity.class, TrackedDataHandlerRegistry.INTEGER);
|
||||
|
||||
static final TrackedData<Float> ENERGY = DataTracker.registerData(PlayerEntity.class, TrackedDataHandlerRegistry.FLOAT);
|
||||
static final TrackedData<Float> EXHAUSTION = DataTracker.registerData(PlayerEntity.class, TrackedDataHandlerRegistry.FLOAT);
|
||||
static final TrackedData<Float> EXERTION = DataTracker.registerData(PlayerEntity.class, TrackedDataHandlerRegistry.FLOAT);
|
||||
static final TrackedData<Float> MANA = DataTracker.registerData(PlayerEntity.class, TrackedDataHandlerRegistry.FLOAT);
|
||||
static final TrackedData<Float> XP = DataTracker.registerData(PlayerEntity.class, TrackedDataHandlerRegistry.FLOAT);
|
||||
|
|
Loading…
Reference in a new issue