improve step sound
This commit is contained in:
@@ -211,7 +211,14 @@ window.Minecraft = class {
|
||||
let soundName = block.getSound().getBreakSound();
|
||||
|
||||
// Play sound
|
||||
this.soundManager.playSound(soundName, hitResult.x + 0.5, hitResult.y + 0.5, hitResult.z + 0.5, 1.0);
|
||||
this.soundManager.playSound(
|
||||
soundName,
|
||||
hitResult.x + 0.5,
|
||||
hitResult.y + 0.5,
|
||||
hitResult.z + 0.5,
|
||||
1.0,
|
||||
1.0
|
||||
);
|
||||
|
||||
// Destroy block
|
||||
this.world.setBlockAt(hitResult.x, hitResult.y, hitResult.z, 0);
|
||||
@@ -241,7 +248,11 @@ window.Minecraft = class {
|
||||
// Don't place blocks if the player is standing there
|
||||
if (!placedBoundingBox.intersects(this.player.boundingBox)) {
|
||||
let typeId = this.inventory.getItemInSelectedSlot();
|
||||
if (typeId !== 0) {
|
||||
|
||||
// Get previous block
|
||||
let prevTypeId = this.world.getBlockAt(x, y, z);
|
||||
|
||||
if (typeId !== 0 && prevTypeId !== typeId) {
|
||||
// Place block
|
||||
this.world.setBlockAt(x, y, z, typeId);
|
||||
|
||||
@@ -252,7 +263,14 @@ window.Minecraft = class {
|
||||
// Play sound
|
||||
let sound = block.getSound();
|
||||
let soundName = sound.getStepSound();
|
||||
this.soundManager.playSound(soundName, hitResult.x + 0.5, hitResult.y + 0.5, hitResult.z + 0.5, sound.getPitch() * 0.8);
|
||||
this.soundManager.playSound(
|
||||
soundName,
|
||||
hitResult.x + 0.5,
|
||||
hitResult.y + 0.5,
|
||||
hitResult.z + 0.5,
|
||||
1.0,
|
||||
sound.getPitch() * 0.8
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -296,7 +296,7 @@ window.Player = class {
|
||||
|
||||
// Play sound
|
||||
if (!block.isLiquid()) {
|
||||
this.minecraft.soundManager.playSound(sound.getStepSound(), this.x, this.y, this.z, sound.getPitch());
|
||||
this.minecraft.soundManager.playSound(sound.getStepSound(), this.x, this.y, this.z, 0.15, sound.getPitch());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ window.SoundManager = class {
|
||||
return sound;
|
||||
}
|
||||
|
||||
playSound(name, x, y, z, pitch) {
|
||||
playSound(name, x, y, z, volume, pitch) {
|
||||
let pool = this.soundPool[name];
|
||||
|
||||
if (typeof pool === "undefined") {
|
||||
@@ -76,7 +76,8 @@ window.SoundManager = class {
|
||||
// Update position
|
||||
sound.position.set(x, y, z);
|
||||
|
||||
// Update pitch
|
||||
// Update volume and pitch
|
||||
sound.setVolume(volume);
|
||||
sound.filters[0].frequency.setValueAtTime(12000 * pitch, sound.context.currentTime);
|
||||
|
||||
// Play sound
|
||||
|
||||
Reference in New Issue
Block a user