Skip to content

AmbientSounds

BonsUnleashed edited this page Oct 7, 2026 · 3 revisions

AmbientSounds

Minecraft 1.20.1 / Forge: this page documents that build and its measurements. For the separate 170-control Minecraft 1.21.1 port, see Minecraft 1.21.1 NeoForge.

Three controls for AmbientSounds 6.3.8 (mod id ambientsounds), all client-side: a memo for its biome pattern matches, a bound for its terrain scan, and dimension name patterns that are compiled once. The terrain-scan bound is the largest single client-phase result in the mod. Every switch checks the code it would change against the tested build; another build is left untouched with one WARN line (see How the patches are applied).

Key Target Side Since Kind Result
ambientsounds_biome_match_cache AmbientSounds 6.3.8 CLIENT 1.0.2 opt ambient tick p95 3.790 → 2.029 ms
ambientsounds_dimension_patterns AmbientSounds 6.3.8 CLIENT 1.0.23 opt patterns compiled once
ambientsounds_terrain_scan_bound AmbientSounds 6.3.8 CLIENT 1.0.7 opt terrain analysis p95 −88.1 %

ambientsounds_biome_match_cache

Since: 1.0.2 · Script (1.0.19 and earlier): bons_and_furious-BiomeEnvironment_BiomeArea.js · Helper: AcBiomeMatchCache Patched: team.creative.ambientsounds.environment.BiomeEnvironment$BiomeArea.checkBiome Mixin (since 1.0.20): BiomeAreaMixin

What upstream did. On each environment scan AmbientSounds re-ran every biome regex condition of every loaded sound rule against the biome identifier string of every sampled position. In matched native windows the original executed 1,179,601 regex matches for 2,106,100 lookups.

What the patch does. Memoises the pure result of (regex pattern, biome identifier). Pattern keys are weak, so live rules keep their entries while discarded rules can be garbage-collected, and each pattern holds at most 256 identifiers. Tags, conditions and the scan cadence are still evaluated live; no biome holder, world state or sound decision is cached.

What stays the same. Current holder tags, condition evaluation, environment scanning, audio volume and every audible feature; 200,000 results were checked equal.

Measured. Ambient tick p95 3.790 → 2.029 ms and p99 6.491 → 4.294 ms.

History. The first version (1.0.2) used a fixed 128-pattern cache and thrashed once a pack had 131–141 live patterns; the weak-key memo shipped in 1.0.5 fixed that. If you saw no benefit from 1.0.2–1.0.4, that is why.


ambientsounds_terrain_scan_bound

Since: 1.0.7 · Script (1.0.19 and earlier): furious7-AmbientHeight.js · Helper: agentcraft.pure.AcAmbientHeight Patched: team.creative.ambientsounds.environment.TerrainEnvironment.getHeightBlock Mixin (since 1.0.20): TerrainEnvironmentMixin

What upstream did. AmbientSounds' terrain analysis scans 121 columns from the build ceiling downward to the first solid, leaves or water block, on a recurring cadence. In a world with a 320-block ceiling most of that walk is empty air above the terrain.

What the patch does. Before the column walk, it checks the chunk's section palettes from the top with a conservative predicate (any block that canOcclude, is in the leaves tag, or is water) and starts the unchanged original loop at the highest section that could possibly contain a match. Only loaded, in-bounds columns of an exact ClientLevel are bounded; everything else keeps the original start. A stale palette entry (a block type that has since been removed from the section) only makes the scan start higher than necessary, never lower.

What stays the same. The original terrain predicate, the scan cadence, the out-of-range VOID_AIR case, null-section AIR, the minimum-height exclusion and the no-hit result. Height sums were equal in every check (3,087 native checks).

Measured. Terrain analysis median 3.2833 → 0.2772 ms and p95 5.4517 → 0.6496 ms (−88.1 %) over 40 analyses per condition; warmed per-column benchmark 26.46 → 2.51 µs. Whole-frame p99 did not improve in that run (15.89 → 16.14 ms), so this reduces the scan's cost without a proven smoothness gain.

Switching it off. Also honours the legacy -Dbons_and_furious.ambientHeight=false (1.0.15 and earlier: -Dbons.pure.ambientHeight=false, which newer builds still accept).


ambientsounds_dimension_patterns

Since: 1.0.23 · Mixin: DimensionPatternMixin · Helper: bons.furious.patch.ambientsounds.DimensionPatterns Patched: team.creative.ambientsounds.dimension.AmbientDimension.is

What upstream did. AmbientSounds tests the current dimension against its configured name patterns with a regular expression that was compiled again on every test.

What the patch does. Each pattern is compiled once and kept; a pattern that does not compile still throws the same error on every test. Separate from ambientsounds_biome_match_cache, which covers biome conditions.

What stays the same. Every answer: in game 308 dimension checks (11 dimensions × 28 levels) identical with compiled and string patterns; 18 patterns cached.

Measured. One regex compile per pattern per session instead of one per check.

Bons and Furious

Minecraft 1.20.1 / Forge 1.0.34

Compatibility

Controls by mod

Links

Clone this wiki locally