Added flight sounds for changelings

This commit is contained in:
Sollace 2021-08-17 20:55:35 +02:00
parent 536502027d
commit 5db8150c02
11 changed files with 29 additions and 10 deletions

View file

@ -3,10 +3,12 @@ package com.minelittlepony.unicopia.client;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import com.minelittlepony.unicopia.FlightType;
import com.minelittlepony.unicopia.InteractionManager;
import com.minelittlepony.unicopia.USounds;
import com.minelittlepony.unicopia.client.sound.LoopingSoundInstance;
import com.minelittlepony.unicopia.entity.effect.SunBlindnessStatusEffect;
import com.minelittlepony.unicopia.entity.player.PlayerPhysics;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.entity.player.dummy.DummyClientPlayerEntity;
import com.minelittlepony.unicopia.network.handler.ClientNetworkHandler;
@ -50,6 +52,11 @@ public class ClientInteractionManager extends InteractionManager {
);
} else if (type == SOUND_MINECART && source instanceof AbstractMinecartEntity) {
soundManager.play(new MovingMinecartSoundInstance((AbstractMinecartEntity)source));
} else if (type == SOUND_CHANGELING_BUZZ && source instanceof PlayerEntity) {
soundManager.play(new LoopingSoundInstance<>((PlayerEntity)source, e -> {
PlayerPhysics physics = Pony.of(e).getPhysics();
return physics.isFlying() && physics.getFlightType() == FlightType.INSECTOID;
}, USounds.ENTITY_PLAYER_CHANGELING_BUZZ, 1F, 1F));
}
}

View file

@ -1,6 +1,7 @@
package com.minelittlepony.unicopia.entity.player;
import com.minelittlepony.unicopia.FlightType;
import com.minelittlepony.unicopia.InteractionManager;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.USounds;
import com.minelittlepony.unicopia.ability.magic.spell.SpellType;
@ -50,6 +51,8 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
public boolean isFlyingEither = false;
public boolean isFlyingSurvival = false;
private boolean soundPlaying;
private int wallHitCooldown;
private Vec3d lastPos = Vec3d.ZERO;
@ -89,22 +92,26 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
float spreadAmount = -0.5F;
if (isFlying()) {
//spreadAmount += Math.sin(pony.getEntity().age / 4F) * 8;
spreadAmount += isGliding() ? 3 : thrustScale * 60;
if (getFlightType() == FlightType.INSECTOID) {
spreadAmount += Math.sin(pony.getEntity().age * 4F) * 8;
} else {
spreadAmount += isGliding() ? 3 : thrustScale * 60;
}
} else {
spreadAmount += MathHelper.clamp(-entity.getVelocity().y, 0, 2);
spreadAmount += Math.sin(entity.age / 9F) / 9F;
}
if (entity.isSneaking()) {
spreadAmount += 2;
}
spreadAmount += MathHelper.clamp(-entity.getVelocity().y, 0, 2);
spreadAmount += Math.sin(entity.age / 9F) / 9F;
spreadAmount = MathHelper.clamp(spreadAmount, -2, 5);
return pony.getInterpolator().interpolate("wingSpreadAmount", spreadAmount, 10);
}
private FlightType getFlightType() {
public FlightType getFlightType() {
if (UItems.PEGASUS_AMULET.isApplicable(entity)) {
return FlightType.ARTIFICIAL;
@ -210,11 +217,14 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
tickFlight(type, velocity);
} else {
ticksInAir = 0;
soundPlaying = false;
if (!creative && type.isAvian()) {
checkAvianTakeoffConditions(velocity);
}
}
} else {
soundPlaying = false;
}
lastPos = new Vec3d(entity.getX(), 0, entity.getZ());
@ -266,6 +276,11 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
velocity.y -= 0.02 * getGravitySignum();
velocity.x *= 0.9896;
velocity.z *= 0.9896;
} else if (type == FlightType.INSECTOID) {
if (entity.world.isClient && !soundPlaying) {
soundPlaying = true;
InteractionManager.instance().playLoopingSound(entity, InteractionManager.SOUND_CHANGELING_BUZZ);
}
}
}

View file

@ -18,7 +18,6 @@ import com.minelittlepony.unicopia.ability.magic.Affine;
import com.minelittlepony.unicopia.ability.magic.Spell;
import com.minelittlepony.unicopia.ability.magic.spell.SpellType;
import com.minelittlepony.unicopia.advancement.UCriteria;
import com.minelittlepony.unicopia.entity.Physics;
import com.minelittlepony.unicopia.entity.PonyContainer;
import com.minelittlepony.unicopia.entity.Living;
import com.minelittlepony.unicopia.entity.Trap;
@ -184,7 +183,7 @@ public class Pony extends Living<PlayerEntity> implements Transmittable, Copieab
}
@Override
public Physics getPhysics() {
public PlayerPhysics getPhysics() {
return gravity;
}

View file

@ -40,9 +40,7 @@
"category": "player",
"subtitle": "unicopia.subtitle.changeling_buzz",
"sounds": [
"unicopia:cicada/cicada_4",
"unicopia:cicada/cicada_5",
"unicopia:cicada/cicada_6"
"unicopia:changeling/buzz0"
]
},
"entity.player.ears_ring": {