Jester stomp sounds, not step !
This commit is contained in:
@@ -91,9 +91,9 @@ export abstract class Entity {
|
||||
this.walk_position += this.walk_speed;
|
||||
}
|
||||
|
||||
// after moving each tick: a step every STEP_DISTANCE it walks with a block under its feet, own when it has its own
|
||||
// step sound (see ENTITY_SOUNDS), the block's otherwise
|
||||
play_steps(own: string | undefined) {
|
||||
// after moving each tick: a step every STEP_DISTANCE it walks with a block under its feet, what own gives when it
|
||||
// has its own step sound (see ENTITY_SOUNDS), the block's otherwise
|
||||
play_steps(own?: () => string | undefined) {
|
||||
const [x, y, z] = [Math.floor(this.x), Math.floor(this.y - 0.2), Math.floor(this.z)];
|
||||
const nid = this.level.get_block(x, y, z);
|
||||
const below = nid === AIR ? undefined : EverythingRegistry.get_by_id<BlockRegistry>("blocks", nid);
|
||||
@@ -102,7 +102,8 @@ export abstract class Entity {
|
||||
if (this.#walked < STEP_DISTANCE) return;
|
||||
this.#walked %= STEP_DISTANCE;
|
||||
const at = { x: this.x, y: this.y, z: this.z };
|
||||
if (own) sounds.play(own, { at });
|
||||
const sound = own?.();
|
||||
if (sound) sounds.play(sound, { at });
|
||||
else sounds.play_of(below.sounds, "step", { at, volume: BLOCK_STEP_VOLUME });
|
||||
}
|
||||
|
||||
|
||||
@@ -199,7 +199,7 @@ export class LocalPlayer extends Player {
|
||||
if (Math.abs(this.vz) < MIN_SPEED) this.vz = 0;
|
||||
this.update_swim_animation();
|
||||
// creeping and flying are quiet
|
||||
if (this.on_ground && !this.sneaking) this.play_steps(undefined);
|
||||
if (this.on_ground && !this.sneaking) this.play_steps();
|
||||
this.#send_position(
|
||||
(this.on_ground && !was_on_ground) || this.swimming !== was_swimming ||
|
||||
this.holding_sneak !== was_holding_sneak,
|
||||
|
||||
@@ -107,7 +107,10 @@ export class RemoteEntity extends Entity {
|
||||
this.update_walk_animation();
|
||||
if (this.swing_ticks !== undefined && ++this.swing_ticks >= SWING_TICKS) this.swing_ticks = undefined;
|
||||
if (!this.dead) {
|
||||
this.play_steps(sound_of(this.#sounds, "step"));
|
||||
this.play_steps(() => {
|
||||
const own = sound_of(this.#sounds, "step");
|
||||
return this.animation ? this.animation.step_sound(own) : own;
|
||||
});
|
||||
if (--this.#ambient_ticks <= 0) {
|
||||
this.#ambient_ticks = random_ambient_ticks();
|
||||
sounds.play_of(this.#sounds, "ambient", { follow: this.id });
|
||||
|
||||
@@ -58,6 +58,6 @@ export class RemotePlayer extends Player {
|
||||
this.z += (this.target_z - this.z) * t;
|
||||
this.update_walk_animation();
|
||||
this.update_swim_animation();
|
||||
this.play_steps(undefined);
|
||||
this.play_steps();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,6 +74,14 @@ export class EntityAnimation {
|
||||
return posed ? offsets : undefined;
|
||||
}
|
||||
|
||||
// the sound its next step makes, what the animator says when it has a step_sound, own otherwise
|
||||
step_sound(own: string | undefined): string | undefined {
|
||||
const animator = this.#animator;
|
||||
if (!animator?.step_sound) return own;
|
||||
let sound: string | undefined;
|
||||
return this.#run("step_sound", () => sound = animator.step_sound!()) ? sound : own;
|
||||
}
|
||||
|
||||
#on_data(field: string) {
|
||||
const animator = this.#animator;
|
||||
if (animator?.on_data) this.#run("on_data", () => animator.on_data!(field, this.#source.age));
|
||||
|
||||
Reference in New Issue
Block a user