diff --git a/src/main/java/com/minelittlepony/unicopia/USounds.java b/src/main/java/com/minelittlepony/unicopia/USounds.java index bd2601b1..11cf2f53 100644 --- a/src/main/java/com/minelittlepony/unicopia/USounds.java +++ b/src/main/java/com/minelittlepony/unicopia/USounds.java @@ -13,6 +13,7 @@ public interface USounds { SoundEvent ENTITY_PLAYER_CHANGELING_BUZZ = register("entity.player.changeling.buzz"); 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"); diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/UHud.java b/src/main/java/com/minelittlepony/unicopia/client/gui/UHud.java index 05b81900..33a25915 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/UHud.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/UHud.java @@ -6,11 +6,13 @@ import java.util.Random; import org.jetbrains.annotations.Nullable; import com.minelittlepony.unicopia.Race; +import com.minelittlepony.unicopia.USounds; import com.minelittlepony.unicopia.ability.AbilityDispatcher; import com.minelittlepony.unicopia.ability.AbilitySlot; import com.minelittlepony.unicopia.ability.magic.spell.DisguiseSpell; import com.minelittlepony.unicopia.ability.magic.spell.SpellType; 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.effect.SunBlindnessStatusEffect; 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.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.entity.player.PlayerEntity; import net.minecraft.text.Text; import net.minecraft.util.Arm; import net.minecraft.util.Identifier; @@ -57,6 +58,9 @@ public class UHud extends DrawableHelper { int xDirection; + @Nullable + private LoopingSoundInstance heartbeatSound; + public void render(InGameHud hud, MatrixStack matrices, float tickDelta) { if (client.player == null) { @@ -182,14 +186,20 @@ public class UHud extends DrawableHelper { float exhaustion = pony.getMagicalReserves().getExhaustion().getPercentFill(); if (exhaustion > 0) { - if (tickDelta == 0) { - client.getSoundManager().play(PositionedSoundInstance.master(SoundEvents.BLOCK_ANVIL_BREAK, 1)); + if (exhaustion > 0.5F && (heartbeatSound == null || heartbeatSound.isDone())) { + 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; - float radius = (1 + (float)Math.sin(client.player.age / 7F)) / 2F; - radius = 0.14F + radius * 0.2F; + float rate = exhaustion > 0.5F ? 2.5F : 7F; + + 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 alpha2 = 0; diff --git a/src/main/resources/assets/unicopia/lang/en_us.json b/src/main/resources/assets/unicopia/lang/en_us.json index ef59783a..d2d8c94e 100644 --- a/src/main/resources/assets/unicopia/lang/en_us.json +++ b/src/main/resources/assets/unicopia/lang/en_us.json @@ -385,6 +385,10 @@ "unicopia.subtitle.slime_retract": "Sqonk", "unicopia.subtitle.changeling_buzz": "Drone Buzzing", "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.description": "A world of magic and adventure", diff --git a/src/main/resources/assets/unicopia/sounds.json b/src/main/resources/assets/unicopia/sounds.json index 0a308d50..86e9a97e 100644 --- a/src/main/resources/assets/unicopia/sounds.json +++ b/src/main/resources/assets/unicopia/sounds.json @@ -11,12 +11,14 @@ }, "item.magic.aura": { "category": "player", + "subtitle": "unicopia.subtitle.magic_aura", "sounds": [ "unicopia:aura/aura0" ] }, "entity.player.rebound": { "category": "player", + "subtitle": "unicopia.subtitle.player.rebound", "sounds": [ "unicopia:boing/boing0", "unicopia:boing/boing1", @@ -50,6 +52,13 @@ "unicopia:ears/ringing" ] }, + "entity.player.heartbeat": { + "category": "ambient", + "subtitle": "unicopia.subtitle.heartbeat", + "sounds": [ + "unicopia:heartbeat/heartbeat" + ] + }, "ambient.wind.gust": { "category": "ambient", "subtitle": "unicopia.subtitle.wind_rush", @@ -72,7 +81,7 @@ }, "record.pet": { "category": "blocks", - "stream": true, + "stream": true, "sounds": [ { "name": "unicopia:record/pet", "stream": true} ] diff --git a/src/main/resources/assets/unicopia/sounds/heartbeat/heartbeat.ogg b/src/main/resources/assets/unicopia/sounds/heartbeat/heartbeat.ogg new file mode 100644 index 00000000..4dd5a73f Binary files /dev/null and b/src/main/resources/assets/unicopia/sounds/heartbeat/heartbeat.ogg differ