fix: fix hardcoded sounds played when resource is requested

This commit is contained in:
Vitaly Turovsky 2025-02-24 21:22:06 +03:00
commit 2f200a876a
2 changed files with 8 additions and 8 deletions

View file

@ -776,7 +776,7 @@ export async function connect (connectOptions: ConnectOptions) {
playerState.onlineMode = !!connectOptions.authenticatedAccount
setLoadingScreenStatus('Placing blocks (starting viewer)')
if (connectOptions.worldStateFileContents && connectOptions.worldStateFileContents.length < 3 * 1024 * 1024) {
if (!connectOptions.worldStateFileContents || connectOptions.worldStateFileContents.length < 3 * 1024 * 1024) {
localStorage.lastConnectOptions = JSON.stringify(connectOptions)
}
connectOptions.onSuccessfulPlay?.()

View file

@ -107,16 +107,16 @@ subscribeKey(miscUiState, 'gameLoaded', async () => {
await playHardcodedSound(soundId, position, volume, pitch)
})
bot.on('hardcodedSoundEffectHeard', async (soundIdNum, soundCategory, position, volume, pitch) => {
const soundKey = soundMap!.soundsIdToName[soundIdNum]
if (soundKey === undefined) return
await playGeneralSound(soundKey, position, volume, pitch)
})
bot._client.on('sound_effect', async (packet) => {
const soundResource = packet['soundEvent']?.resource as string | undefined
if (packet.soundId !== 0 || !soundResource) return
const pos = new Vec3(packet.x / 8, packet.y / 8, packet.z / 8)
if (packet.soundId !== 0 || !soundResource) {
const soundKey = soundMap!.soundsIdToName[packet.soundId]
if (soundKey === undefined) return
await playGeneralSound(soundKey, pos, packet.volume, packet.pitch)
return
}
await playHardcodedSound(soundResource.replace('minecraft:', ''), pos, packet.volume, packet.pitch)
})