Acoustics stage 1: direct-path occlusion ported from Sound Physics Remastered 453654e (GPL-3.0, separate files), off by default; stereo output on surround devices; mixer sum in a fixed order (API 21)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-30 22:09:23 +03:00
committed by airdef
parent 32f6161921
commit 7012640e54
17 changed files with 1298 additions and 4 deletions
+1
View File
@@ -803,6 +803,7 @@ Where a capture is.
| `spawn-particles` | `func(particles: list<particle-spawn>)` | Spawns particles on this client only: no command, no server. At most 512 spawns a call. |
| `play-sound` | `func(event: string, x: f64, y: f64, z: f64, volume: f32, pitch: f32)` | Plays a sound event (`minecraft:entity.generic.explode`, `<mod>:<name>`) at a point on this client. |
| `sound-source-generation` | `func() -> u32` | Moves on whenever the game released every source of every mod (the world closed, the session ended, a film began or ended, the sounds reloaded). A mod reads it before `sound-sources` and starts its sources again when it changed. |
| `acoustics` | `func() -> bool` | Whether the game muffles sounds by what lies between them and the listener (AirDef fork, API level 21: `HORIZON_ACOUSTICS`). A mod that muffles by itself (a `_far` variant for a distant blast) plays the near one instead when this is true, so nothing is muffled twice. |
| `sound-sources` | `func(generation: u32, ops: list<source-op>) -> bool` | Starts, updates and stops persistent sound sources. `generation` is the `sound-source-generation` the mod's sources belong to; if it is not the current one the call is ignored and returns false (read the generation, forget the sources, start them again). Stops are never dropped by a limit: only new sources beyond 256 running are, and at most 512 entries a call count. Every source of a mod that stops or is reloaded is released by the game. |
| `query-ground` | `func(columns: list<tuple<s32, s32>>)` | Asks for the ground height of these columns (x, z): at most 512 a tick, answered by `ground` from the next tick on. |
| `ground` | `func() -> list<tuple<s32, s32, s32>>` | The answers to the last tick's `query-ground`: (x, z, y), y one above the highest block that blocks motion or holds a fluid, as the motion blocking heightmap; -64 where the chunk isn't loaded. |
+4
View File
@@ -114,6 +114,10 @@ What real mods need next, in the order modpacks and servers need it:
source updated once a tick has no steps; 24 sources hold a voice (loudest and nearest times priority), the rest of
the loops stay virtual; a stop is never lost to a limit; the sources of a mod that stops or is reloaded are
released. A film mixes them on its own clock like `play-sound`.
- API level 21 (AirDef fork, capability `render`): `acoustics` tells whether the game muffles sounds by what
lies between them and the listener (`HORIZON_ACOUSTICS=1`: a wall or a mountain dims a sound and cuts its highs,
traced from a snapshot of the loaded chunks, never in the audio callback). A mod that muffles by itself, such as a
`_far` variant for a distant blast, plays the near one when it is true, so nothing is muffled twice.
- API level 19 (AirDef fork, capability `command`): `set-tree` gives a client mod's command a tree of subcommands
(literals), typed words (`word`, `choice`, `integer` and `number` with bounds, `names` from a list, `block-pos`),
optional branches (`runs`), the rest of the line (`text`) and `key=value` options; `set-suggestions` sets the list a