mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-27 15:17:59 +01:00
Added heartbeat sound to the exhaustion effect
This commit is contained in:
parent
8932c17c6d
commit
9f4713018f
5 changed files with 31 additions and 7 deletions
|
@ -13,6 +13,7 @@ public interface USounds {
|
||||||
SoundEvent ENTITY_PLAYER_CHANGELING_BUZZ = register("entity.player.changeling.buzz");
|
SoundEvent ENTITY_PLAYER_CHANGELING_BUZZ = register("entity.player.changeling.buzz");
|
||||||
|
|
||||||
SoundEvent ENTITY_PLAYER_EARS_RINGING = register("entity.player.ears_ring");
|
SoundEvent ENTITY_PLAYER_EARS_RINGING = register("entity.player.ears_ring");
|
||||||
|
SoundEvent ENTITY_PLAYER_HEARTBEAT = register("entity.player.heartbeat");
|
||||||
|
|
||||||
SoundEvent ITEM_MAGIC_AURA = register("item.magic.aura");
|
SoundEvent ITEM_MAGIC_AURA = register("item.magic.aura");
|
||||||
|
|
||||||
|
|
|
@ -6,11 +6,13 @@ import java.util.Random;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.Race;
|
import com.minelittlepony.unicopia.Race;
|
||||||
|
import com.minelittlepony.unicopia.USounds;
|
||||||
import com.minelittlepony.unicopia.ability.AbilityDispatcher;
|
import com.minelittlepony.unicopia.ability.AbilityDispatcher;
|
||||||
import com.minelittlepony.unicopia.ability.AbilitySlot;
|
import com.minelittlepony.unicopia.ability.AbilitySlot;
|
||||||
import com.minelittlepony.unicopia.ability.magic.spell.DisguiseSpell;
|
import com.minelittlepony.unicopia.ability.magic.spell.DisguiseSpell;
|
||||||
import com.minelittlepony.unicopia.ability.magic.spell.SpellType;
|
import com.minelittlepony.unicopia.ability.magic.spell.SpellType;
|
||||||
import com.minelittlepony.unicopia.client.KeyBindingsHandler;
|
import com.minelittlepony.unicopia.client.KeyBindingsHandler;
|
||||||
|
import com.minelittlepony.unicopia.client.sound.LoopingSoundInstance;
|
||||||
import com.minelittlepony.unicopia.entity.behaviour.Disguise;
|
import com.minelittlepony.unicopia.entity.behaviour.Disguise;
|
||||||
import com.minelittlepony.unicopia.entity.effect.SunBlindnessStatusEffect;
|
import com.minelittlepony.unicopia.entity.effect.SunBlindnessStatusEffect;
|
||||||
import com.minelittlepony.unicopia.entity.effect.UEffects;
|
import com.minelittlepony.unicopia.entity.effect.UEffects;
|
||||||
|
@ -22,10 +24,9 @@ import net.minecraft.client.font.TextRenderer;
|
||||||
import net.minecraft.client.gui.DrawableHelper;
|
import net.minecraft.client.gui.DrawableHelper;
|
||||||
import net.minecraft.client.gui.hud.InGameHud;
|
import net.minecraft.client.gui.hud.InGameHud;
|
||||||
import net.minecraft.client.gui.screen.ingame.InventoryScreen;
|
import net.minecraft.client.gui.screen.ingame.InventoryScreen;
|
||||||
import net.minecraft.client.sound.PositionedSoundInstance;
|
|
||||||
import net.minecraft.client.util.math.MatrixStack;
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
import net.minecraft.entity.EntityDimensions;
|
import net.minecraft.entity.EntityDimensions;
|
||||||
import net.minecraft.sound.SoundEvents;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.util.Arm;
|
import net.minecraft.util.Arm;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
|
@ -57,6 +58,9 @@ public class UHud extends DrawableHelper {
|
||||||
|
|
||||||
int xDirection;
|
int xDirection;
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
private LoopingSoundInstance<PlayerEntity> heartbeatSound;
|
||||||
|
|
||||||
public void render(InGameHud hud, MatrixStack matrices, float tickDelta) {
|
public void render(InGameHud hud, MatrixStack matrices, float tickDelta) {
|
||||||
|
|
||||||
if (client.player == null) {
|
if (client.player == null) {
|
||||||
|
@ -182,14 +186,20 @@ public class UHud extends DrawableHelper {
|
||||||
float exhaustion = pony.getMagicalReserves().getExhaustion().getPercentFill();
|
float exhaustion = pony.getMagicalReserves().getExhaustion().getPercentFill();
|
||||||
|
|
||||||
if (exhaustion > 0) {
|
if (exhaustion > 0) {
|
||||||
if (tickDelta == 0) {
|
if (exhaustion > 0.5F && (heartbeatSound == null || heartbeatSound.isDone())) {
|
||||||
client.getSoundManager().play(PositionedSoundInstance.master(SoundEvents.BLOCK_ANVIL_BREAK, 1));
|
client.getSoundManager().play(
|
||||||
|
heartbeatSound = new LoopingSoundInstance<>(client.player, player -> {
|
||||||
|
return Pony.of(player).getMagicalReserves().getExhaustion().getPercentFill() > 0.5F;
|
||||||
|
}, USounds.ENTITY_PLAYER_HEARTBEAT, 1, 1)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
int color = 0x880000;
|
int color = 0x880000;
|
||||||
|
|
||||||
float radius = (1 + (float)Math.sin(client.player.age / 7F)) / 2F;
|
float rate = exhaustion > 0.5F ? 2.5F : 7F;
|
||||||
radius = 0.14F + radius * 0.2F;
|
|
||||||
|
float radius = (1 + (float)Math.sin(client.player.age / rate)) / 2F;
|
||||||
|
radius = 0.1F + radius * 0.1F;
|
||||||
|
|
||||||
int alpha1 = (int)(MathHelper.clamp(exhaustion * radius * 2, 0, 1) * 205) << 24 & -16777216;
|
int alpha1 = (int)(MathHelper.clamp(exhaustion * radius * 2, 0, 1) * 205) << 24 & -16777216;
|
||||||
int alpha2 = 0;
|
int alpha2 = 0;
|
||||||
|
|
|
@ -385,6 +385,10 @@
|
||||||
"unicopia.subtitle.slime_retract": "Sqonk",
|
"unicopia.subtitle.slime_retract": "Sqonk",
|
||||||
"unicopia.subtitle.changeling_buzz": "Drone Buzzing",
|
"unicopia.subtitle.changeling_buzz": "Drone Buzzing",
|
||||||
"unicopia.subtitle.batpony_eeee": "Batpony Screeches",
|
"unicopia.subtitle.batpony_eeee": "Batpony Screeches",
|
||||||
|
"unicopia.subtitle.magic_aura": "Magic Humming",
|
||||||
|
"unicopia.subtitle.player.rebound": "Player Bounces Off Wall",
|
||||||
|
"unicopia.subtitle.ears_ring": "Ears Ringing",
|
||||||
|
"unicopia.subtitle.heartbeat": "Heart Beats",
|
||||||
|
|
||||||
"advancements.unicopia.root.title": "Unicopia",
|
"advancements.unicopia.root.title": "Unicopia",
|
||||||
"advancements.unicopia.root.description": "A world of magic and adventure",
|
"advancements.unicopia.root.description": "A world of magic and adventure",
|
||||||
|
|
|
@ -11,12 +11,14 @@
|
||||||
},
|
},
|
||||||
"item.magic.aura": {
|
"item.magic.aura": {
|
||||||
"category": "player",
|
"category": "player",
|
||||||
|
"subtitle": "unicopia.subtitle.magic_aura",
|
||||||
"sounds": [
|
"sounds": [
|
||||||
"unicopia:aura/aura0"
|
"unicopia:aura/aura0"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"entity.player.rebound": {
|
"entity.player.rebound": {
|
||||||
"category": "player",
|
"category": "player",
|
||||||
|
"subtitle": "unicopia.subtitle.player.rebound",
|
||||||
"sounds": [
|
"sounds": [
|
||||||
"unicopia:boing/boing0",
|
"unicopia:boing/boing0",
|
||||||
"unicopia:boing/boing1",
|
"unicopia:boing/boing1",
|
||||||
|
@ -50,6 +52,13 @@
|
||||||
"unicopia:ears/ringing"
|
"unicopia:ears/ringing"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"entity.player.heartbeat": {
|
||||||
|
"category": "ambient",
|
||||||
|
"subtitle": "unicopia.subtitle.heartbeat",
|
||||||
|
"sounds": [
|
||||||
|
"unicopia:heartbeat/heartbeat"
|
||||||
|
]
|
||||||
|
},
|
||||||
"ambient.wind.gust": {
|
"ambient.wind.gust": {
|
||||||
"category": "ambient",
|
"category": "ambient",
|
||||||
"subtitle": "unicopia.subtitle.wind_rush",
|
"subtitle": "unicopia.subtitle.wind_rush",
|
||||||
|
@ -72,7 +81,7 @@
|
||||||
},
|
},
|
||||||
"record.pet": {
|
"record.pet": {
|
||||||
"category": "blocks",
|
"category": "blocks",
|
||||||
"stream": true,
|
"stream": true,
|
||||||
"sounds": [
|
"sounds": [
|
||||||
{ "name": "unicopia:record/pet", "stream": true}
|
{ "name": "unicopia:record/pet", "stream": true}
|
||||||
]
|
]
|
||||||
|
|
Binary file not shown.
Loading…
Reference in a new issue