Skip to content

Alexs Caves

BonsUnleashed edited this page Oct 7, 2026 · 3 revisions

Alex's Caves

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.

Four controls for Alex's Caves 2.0.2 (mod id alexscaves). Two are in its magnetism code: one point-of-interest query instead of two, and equipment checked without cloning arrays. One remembers the rare cave biome lookup per column during world generation. One is a fix: the Teletor's spawn setup stays inside the generation region, which stops a crash with C2ME. Background on Generation context fixes. 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
alexscaves_equipment_enumeration Alex's Caves 2.0.2 BOTH 1.0.8 opt 64 → 0 B per call
alexscaves_magnet_query Alex's Caves 2.0.2 BOTH 1.0.2 opt one POI query instead of two
alexscaves_rare_biome_column_memo Alex's Caves 2.0.2 SERVER 1.0.28 opt 112 → 20 ns and 422 → 5 B per lookup
alexscaves_teletor_generation_context Alex's Caves 2.0.2 BOTH 1.0.11 fix fixes a crash with C2ME

alexscaves_magnet_query

Since: 1.0.2 · Script (1.0.19 and earlier): bons_and_furious-MagnetUtil.js Patched: com.github.alexmodguy.alexscaves.server.entity.util.MagnetUtil.tickMagnetism Mixins (since 1.0.20): MagnetUtilQueryMixin, LivingEntityJumpingAccessor

What upstream did. Ran two nearby-magnet point-of-interest queries per eligible entity per tick, one for attracting and one for repelling magnets.

What the patch does. Runs a single traversal and partitions the results in their original order before the unchanged force callbacks and the rest of the tick.

What stays the same. Force accumulation order, radius, per-tick response, motion, attachment and world-wide magnet operation; no persistent cache and no biome restriction. 1,772 assertions equal, including 250 raw-bit force/velocity comparisons with the original method.

With Collections Of Optimizations (tested 4.4, since 1.0.27). Its option alexscaves.singleMagnetQuery makes the same change. While that option is on, this control steps aside; while it is off, this control applies and leaves COO's copy out, so only one copy runs. See Compatibility and target versions. With both copies (1.0.26 and earlier), Mixin refused COO's wrappers inside this patch and the game crashed on the first magnetism tick.

Measured. The magnetism hotspot was about 3.8 % of sampled server-thread busy time in the profile that motivated this; that is a baseline cost, not a measured saving, because the assertion harness measured equivalence rather than time.


alexscaves_equipment_enumeration

Since: 1.0.8 · Script (1.0.19 and earlier): furious8-magnet.js Patched: MagnetUtil.isDynamicallyMagnetic Mixin (since 1.0.20): MagnetUtilEquipmentMixin

What upstream did. Called EquipmentSlot.values() for every full equipment scan; that enum method returns a cloned array each time.

What the patch does. Keeps one private copy and iterates it in the same order.

What stays the same. The Magnetizing-effect check, the feet-only branch, every equipment and tag callback and the early-return order; equipment changes and tag reloads take effect immediately.

Measured. 64 → 0 B per call in both cases. Wall time: miss 31.60 → 35.31 ns (regressed in the final sample after improving in three earlier runs), last hit 32.92 → 31.12 ns. The consistent result is the removed array, not a time saving; it is kept because it is exact.


alexscaves_teletor_generation_context

Target: Alex's Caves 2.0.2 · Side: BOTH · Since: 1.0.11 (first as a patched JAR 2026-09-11) · Kind: fix Patched: com.github.alexmodguy.alexscaves.server.entity.living.TeletorEntity.finalizeSpawn — 1.0.19 script bons_and_furious-TeletorEntity.js Mixin (since 1.0.20): TeletorSpawnContextMixin

What upstream did. TeletorEntity.finalizeSpawn drew from the live world's random four times and added its floating weapon entity to the live Level even when it was handed a generation region. On a C2ME worker thread the random read stops generation with a ConcurrentModificationException, and the weapon insertion reaches into the live world from generation.

What the patch does. Takes both the random and the weapon insertion from the supplied region.

What stays the same. Ordinary spawning keeps the original path; weapon choice, equipment and enchantment logic and the Teletor-weapon UUID links are unchanged. Deliberate difference: during generation the four draws come from the region's random (same distribution) and the weapon is saved with the chunk instead of being added to the live world.

Measured. Fixes a C2ME crash. Twelve helper boundary/error cases and 2,000 concurrent operations pass; the actual Forge-transformed original fails on a worker thread, while the patched method passes 16 Teletors and 16 snails per native test with every weapon contained and linked. Together with scuba_gear_generation_context the exact 172-chunk C2ME ocean-ruin replay completes in 65.875 s.


alexscaves_rare_biome_column_memo

Since: 1.0.28 · Target: Alex's Caves 2.0.2 · Side: SERVER · Kind: opt

Mixin: RareBiomeColumnMixin

Alex's Caves rare-biome lookup once per column. Alex's Caves asks, before every overworld noise-biome lookup, whether a rare cave biome sits at that spot: a Voronoi cell search with two noise samples and its own allocations. The answer does not depend on height, yet a chunk's biome fill asks it for every quart of every section: 3,072 times per 768-high chunk for the same 16 columns. Each world generation thread now keeps the answers for the columns it is filling, keyed by the seed, the column, Alex's Caves' width-randomness setting and its configuration generation, and hands back the object Alex's Caves returned for that key. Every other lookup runs Alex's Caves' own code.

Measured: 112 -> 20 ns and 422 -> 5 B per lookup on real classes (0.34 -> 0.06 ms per 768-high chunk); 907,201 checks identical.

Bons and Furious

Minecraft 1.20.1 / Forge 1.0.34

Compatibility

Controls by mod

Links

Clone this wiki locally