From 6fbcce7c22f72ddc6bdb5e81f59dfe606b33746d Mon Sep 17 00:00:00 2001 From: Sollace Date: Mon, 23 Aug 2021 23:08:03 +0200 Subject: [PATCH] Prevent flying sounds from playing whilst disguised --- .../unicopia/ability/magic/SpellContainer.java | 3 +-- .../unicopia/ability/magic/spell/SpellPredicate.java | 7 ++++++- .../unicopia/entity/player/PlayerPhysics.java | 12 ++++++++---- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/SpellContainer.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/SpellContainer.java index 71584c73..81cc9eeb 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/SpellContainer.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/SpellContainer.java @@ -14,8 +14,7 @@ public interface SpellContainer { } @Override - public void put(Spell effect) { - } + public void put(Spell effect) { } }; /** diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/SpellPredicate.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/SpellPredicate.java index 6de6d70d..a84cbec5 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/SpellPredicate.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/SpellPredicate.java @@ -3,12 +3,17 @@ package com.minelittlepony.unicopia.ability.magic.spell; import java.util.function.Predicate; import com.minelittlepony.unicopia.ability.magic.Attached; +import com.minelittlepony.unicopia.ability.magic.Caster; import com.minelittlepony.unicopia.ability.magic.Spell; import com.minelittlepony.unicopia.ability.magic.Suppressable; import com.minelittlepony.unicopia.ability.magic.Thrown; -public interface SpellPredicate extends Predicate { +public interface SpellPredicate extends Predicate { SpellPredicate IS_THROWN = s -> s instanceof Thrown; SpellPredicate IS_ATTACHED = s -> s instanceof Attached; SpellPredicate IS_SUPPRESSABLE = s -> s instanceof Suppressable; + + default boolean isOn(Caster caster) { + return caster.getSpellSlot().get(this, false).isPresent(); + } } \ No newline at end of file diff --git a/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerPhysics.java b/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerPhysics.java index 8bbfa3b6..9f9bfe89 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerPhysics.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerPhysics.java @@ -315,14 +315,16 @@ public class PlayerPhysics extends EntityPhysics implements Tickab ticksToGlide = 20; } - if (ticksInAir % 200 == 1 && pony.isClient()) { - InteractionManager.instance().playLoopingSound(entity, InteractionManager.SOUND_GLIDING); + if (!SpellType.DISGUISE.isOn(pony)) { + if (ticksInAir % 200 == 1 && pony.isClient()) { + InteractionManager.instance().playLoopingSound(entity, InteractionManager.SOUND_GLIDING); + } } velocity.y -= 0.02 * getGravitySignum(); velocity.x *= 0.9896; velocity.z *= 0.9896; - } else if (type == FlightType.INSECTOID) { + } else if (type == FlightType.INSECTOID && !SpellType.DISGUISE.isOn(pony)) { if (entity.world.isClient && !soundPlaying) { soundPlaying = true; InteractionManager.instance().playLoopingSound(entity, InteractionManager.SOUND_CHANGELING_BUZZ); @@ -474,7 +476,9 @@ public class PlayerPhysics extends EntityPhysics implements Tickab if (thrustScale <= 0.000001F & flapping) { flapping = false; - entity.playSound(getFlightType().getWingFlapSound(), 0.5F, 1); + if (!SpellType.DISGUISE.isOn(pony)) { + entity.playSound(getFlightType().getWingFlapSound(), 0.5F, 1); + } thrustScale = 1; }