[PR #6643] [MERGED] Far terrain on servers without horizon:lod: read Bobby's cache too (after #6327) #7009

Closed
opened 2026-11-03 06:31:55 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/6643
Author: @some-du6e
Created: 11/2/2026
Status: ✅ Merged
Merged: 11/2/2026
Merged by: @ludovic111

Base: main ← Head: far-terrain/5-bobby


📝 Commits (7)

  • c0c6fa6 Server far terrain: no slab of one chunk over a cell it barely covers
  • 9df7144 Far terrain: sample again the tiles a server chunk was kept too late for
  • 497db27 Far terrain: a sample still waiting for BlueMap's data isn't drawn
  • 3acfde7 Far terrain: BlueMap's coarser levels stand in while the finest loads
  • 0ddb4d8 Far terrain on servers: read Bobby's cache too
  • 115443b Merge main into #6327
  • 4abd6dd Merge #6327's main merge into #6643

📊 Changes

9 files changed (+1549 additions, -91 deletions)

View changed files

📝 crates/horizon-client-render/src/bluemap.rs (+165 -23)
📝 crates/horizon-client-render/src/gfx/lod.rs (+24 -4)
📝 crates/horizon-client-render/src/lod.rs (+635 -15)
📝 crates/horizon-client-render/src/server_terrain.rs (+483 -46)
📝 crates/horizon-client-render/src/streaming.rs (+12 -0)
📝 crates/horizon-client/src/game.rs (+37 -2)
📝 crates/horizon-client/src/game/remote.rs (+5 -0)
📝 crates/horizon-client/src/save.rs (+187 -0)
📝 docs/graphics.md (+1 -1)

📄 Description

Players who use the Bobby mod on Java already have a cache of the servers they play on, often of areas Horizon never saw. With #6323–#6327, Horizon's far terrain on a server without horizon:lod draws only the chunks Horizon itself kept. This PR also reads Bobby's cache, read-only, so those areas show up from the first visit.

The first version of #6323 had a Bobby reader, and Ludovic asked how its layout was learned (Bobby is LGPL-3.0). I couldn't show that, so it was removed, and this one was written clean-room from Bobby's files on disk. Details are under "Other projects' code".

This PR: 0ddb4d89e

  • Finding the folder. .bobby lives in the game folder (HORIZON_MINECRAFT_DIR, else the official launcher's, found the same way as horizon-prepare's minecraft_dir). The level's folder is <address as typed, ':' as '_'>/<hashed seed>/<namespace>/<path>. Server names are compared without case, with or without the default port, since neither was observed. Another seed, dimension or port doesn't match.
  • Reading a chunk. When Horizon's store has no chunk, or holds an old record, far terrain reads it from Bobby's region file (opened read-only). It decodes it as a vanilla chunk with its stored light (save::decode_lit, handed in from game.rs), summarizes it the way a loaded chunk is, and keeps it in server-terrain/. So each chunk is read from Bobby once, and Bobby's folder is never written. A chunk of another DataVersion, one that doesn't decode or one without light gives nothing.
  • Races. A Bobby chunk is never written over one the server sent while it was being decoded. store remembers what it read, so an unchanged chunk isn't read from disk again.
  • Wide cells. Bobby's region headers count when far cells look for kept chunks.
  • Friend worlds and splitscreen guests still keep no server terrain, so they don't read Bobby either.
  • Docs. One sentence in docs/graphics.md.

Tests:

  • Folders by address: port typed or not, : as _, case. Another seed, dimension or port doesn't match. An empty address or a missing root finds nothing.
  • A Bobby-shaped region: counted for wide cells before any read, then read, summarized and kept. Bobby's file stays byte-for-byte unchanged, and another version's chunk is ignored.
  • With prepared resources: a chunk with both palette shapes (plain names, and compounds with {"": name} wrappers) decodes with its light and is kept.
  • With prepared resources and HORIZON_TEST_BOBBY: every Overworld chunk of a .bobby folder Bobby really wrote (three worlds, found by address and seed) is read with a surface.

Other projects' code

  • Bobby (LGPL-3.0, Modrinth): no source read. CONTRIBUTING allows running a mod and observing it, so that is all that was done.
    1. Run it. A fork-only workflow (ci/bobby-observe, run) runs a real 26.3 Fabric client with Bobby 5.2.16 and Fabric API against three local vanilla 26.3 servers: 127.0.0.1 seed 1111, localhost:25566 seed 2222, 127.0.0.1 seed 3333. It teleports the player around, quits, and uploads the .bobby folder with a byte-level dump of its files.
    2. Describe it. A description of the files was written from that output alone (below). For example, the seed folders match the login's hashed seed: SHA-256 of 1111 gives -9030034075591913594.
    3. Write it. The importer was written from that description by a fresh agent told never to read Bobby's source or the removed Horizon code (no git history, other refs or other worktrees). It reports reading only the description and files at this branch's HEAD. The reviewer had the same rules.
  • Nothing else.
The description the importer was written from

What Bobby leaves on disk (observed, 2026-11-01)

Written only from the files Bobby 5.2.16+mc26.3 (Fabric, with Fabric API 0.165.0+26.3) wrote while a
real 26.3 client played on three local vanilla 26.3 servers, in GitHub Actions run
https://github.com/some-du6e/horizon/actions/runs/41362977525 (workflow bobby-observe.yml on the
fork branch ci/bobby-observe; its artifact bobby-observe holds the folders, logs and a byte-level
dump). Bobby's source was not read. Default config/bobby.conf (the file Bobby wrote; relevant lines:
enabled=true, dynamic-multi-world=false, delete-unused-regions-after-days=-1).

Where

<game folder>/.bobby/ (the client's --gameDir; for the official launcher that is the
.minecraft folder).

Layout

.bobby/<server>/<hashed seed>/<namespace>/<path>/r.<X>.<Z>.mca
.bobby/<server>/<hashed seed>/<namespace>/<path>/last_access

Observed folders, from the three servers:

Joined as (--quickPlayMultiplayer) World seed Folder
127.0.0.1 (port 25565) 1111 127.0.0.1/-9030034075591913594/minecraft/overworld/, …/minecraft/the_nether/
localhost:25566 2222 localhost_25566/-7181178862026813658/minecraft/overworld/
127.0.0.1 (port 25565), another world 3333 127.0.0.1/4696776658964135993/minecraft/overworld/
  • <server>: the address as the player typed it, with : written as _. Typed without a port, no
    port appears. Not observed: an address typed with :25565, upper-case letters, or characters a file
    system can't hold.
  • <hashed seed>: the signed decimal of the hashed seed the server sends at login (vanilla's
    obfuscated seed: the first 8 bytes, little-endian, of SHA-256 over the world seed's 8 bytes,
    little-endian). Checked: 1111 → -9030034075591913594, 2222 → -7181178862026813658,
    3333 → 4696776658964135993. Two worlds behind one address get two folders.
  • <namespace>/<path>: the dimension's key, minecraft:overworld → minecraft/overworld,
    minecraft:the_nether → minecraft/the_nether.
  • Not observed: dynamic-multi-world=true (Bobby's config says it starts a new cache at each world
    change and merges similar ones; its layout is unknown), and single player (Bobby is off there by
    default: view-distance-overwrite=0).

Region files

Standard Anvil region files: r.<X>.<Z>.mca for region X, Z (32 × 32 chunks), a 4096-byte location
table, a 4096-byte timestamp table (seconds), 4096-byte sectors, each chunk a 4-byte length and a
compression byte. Every chunk observed used compression 2 (zlib). No external .mcc files.

Chunks present are the ones the client was sent and then unloaded: a square around each place the
player stood (server view distance 4, client render distance 12), e.g. local (26..31, 26..31) of
r.-1.-1.mca.

A chunk

Chunk NBT in the shape of a 26.3 save (root compound, unnamed). Top-level keys, in file order:
isLightOn, Status, zPos, block_entities, yPos, DataVersion, xPos, Heightmaps,
sections, age.

isLightOn: byte = 1
Status: string = "full"
xPos: int, zPos: int, yPos: int = -4
DataVersion: int = 5023        (26.3's)
block_entities: list, empty    (Bobby's default no-block-entities=true)
Heightmaps: OCEAN_FLOOR, MOTION_BLOCKING_NO_LEAVES, MOTION_BLOCKING, WORLD_SURFACE (long[37] each)
sections: list of 24 compounds (overworld, Y -4..19), each with:
    Y: byte
    block_states: { palette: list, data: long[] (absent when the palette has one entry) }
    biomes: { palette: list of strings ("minecraft:meadow"), data: long[] when more than one }
    BlockLight: byte[2048], only in some sections
    SkyLight: byte[2048], only in some sections
age: long = 1793576311368      (not a vanilla key: milliseconds since the epoch)

The block palette comes in two shapes, both seen in one chunk:

  • a list of strings, every entry a block id with no properties: ["minecraft:stone", "minecraft:gravel", "minecraft:air"];
  • a list of compounds, when at least one entry has properties. An entry without properties is
    then wrapped as a compound whose only key is the empty name: {"": "minecraft:stone"}. One with
    properties is {id: "minecraft:pointed_dripstone", properties: {waterlogged: "false", ...}}
    (lower-case id and properties, as vanilla's own block states since data version 5006).

That is how 26.3's NBT writes a list whose elements don't share one type (strings and compounds),
not something particular to Bobby as far as these files show; it was not compared against a
vanilla server's own region files in this run. Light: not every section has BlockLight or
SkyLight; a missing layer is a missing layer, as in a saved world.

last_access

One per dimension folder, 49–142 bytes, binary: varints (region X, region Z as zig-zag-free signed
varints such as ff ff ff ff 0f for -1) and timestamps (seconds, varint), one entry a region. Bobby's
own bookkeeping for delete-unused-regions-after-days. Not needed to read the chunks; a reader should
leave it alone.

For a reader

  • Read only: never write into .bobby.
  • Find the folder from what the client knows at login: the address as typed (: → _), the login's
    hashed seed, the dimension key. Since an address typed with :25565 or in another case wasn't
    observed, a reader can accept both host and host_25565 and compare names case-insensitively.
  • A missing folder, a missing region, a chunk of another DataVersion or one that fails to decode:
    nothing from Bobby for that chunk.

The stack

On top of #6327 (it holds #6323–#6327), so review only the commit above. Merge it after them.

Checked

  • CI on the fork (run, on this tree): cargo fmt --check; clippy --all-targets -D warnings on horizon-client-render, horizon-client, horizon-client-lib and horizon-mods; the render, client and client-lib tests. Then a second job downloads 26.3 from Mojang, prepares resources, and runs the two resource tests above: the synthetic chunk, and the real .bobby folder from the observe run. Both passed, in 72 s.
  • Review: one round by an independent clean-room reviewer. It found a race (fixed: a Bobby chunk could overwrite one the server had just sent) and a caching regression in store (fixed). Left as is: a stale Bobby chunk can still count toward a wide cell, as Horizon's own stale records already do. Also left: only the official launcher's .minecraft is searched, so Prism, MultiMC and Modrinth instances need HORIZON_MINECRAFT_DIR.
  • Not run: the parity harnesses and pr_ready.py (they need .local/, which this machine doesn't build), and a live game on a server with a Bobby cache.

Suggested labels, since this fork can't set them: feature and needs-proof.

Note

Filed by Opus 5.5 using Claude Code.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/6643 **Author:** [@some-du6e](https://github.com/some-du6e) **Created:** 11/2/2026 **Status:** ✅ Merged **Merged:** 11/2/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `far-terrain/5-bobby` --- ### 📝 Commits (7) - [`c0c6fa6`](https://github.com/horizon-rust/horizon/commit/c0c6fa6b1776c209f5c60d0fff2f44ec95bd6e43) Server far terrain: no slab of one chunk over a cell it barely covers - [`9df7144`](https://github.com/horizon-rust/horizon/commit/9df7144bde3f72f9df6ac23f25878f81ddb6c245) Far terrain: sample again the tiles a server chunk was kept too late for - [`497db27`](https://github.com/horizon-rust/horizon/commit/497db27914ce5e37a59dd6d6de89c7ce5d95da91) Far terrain: a sample still waiting for BlueMap's data isn't drawn - [`3acfde7`](https://github.com/horizon-rust/horizon/commit/3acfde75ba69a52c207861728a59060d5bf36967) Far terrain: BlueMap's coarser levels stand in while the finest loads - [`0ddb4d8`](https://github.com/horizon-rust/horizon/commit/0ddb4d89e4bb43cb126bd2cf0052c9784253da12) Far terrain on servers: read Bobby's cache too - [`115443b`](https://github.com/horizon-rust/horizon/commit/115443b7a738f47d2fab5700550551d40e805b70) Merge main into #6327 - [`4abd6dd`](https://github.com/horizon-rust/horizon/commit/4abd6ddad3f8e8b9d108c0ef583cec00f55b1f03) Merge #6327's main merge into #6643 ### 📊 Changes **9 files changed** (+1549 additions, -91 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/bluemap.rs` (+165 -23) 📝 `crates/horizon-client-render/src/gfx/lod.rs` (+24 -4) 📝 `crates/horizon-client-render/src/lod.rs` (+635 -15) 📝 `crates/horizon-client-render/src/server_terrain.rs` (+483 -46) 📝 `crates/horizon-client-render/src/streaming.rs` (+12 -0) 📝 `crates/horizon-client/src/game.rs` (+37 -2) 📝 `crates/horizon-client/src/game/remote.rs` (+5 -0) 📝 `crates/horizon-client/src/save.rs` (+187 -0) 📝 `docs/graphics.md` (+1 -1) </details> ### 📄 Description Players who use the Bobby mod on Java already have a cache of the servers they play on, often of areas Horizon never saw. With #6323–#6327, Horizon's far terrain on a server without `horizon:lod` draws only the chunks Horizon itself kept. This PR also reads Bobby's cache, read-only, so those areas show up from the first visit. The first version of #6323 had a Bobby reader, and Ludovic asked how its layout was learned (Bobby is LGPL-3.0). I couldn't show that, so it was removed, and this one was written clean-room from Bobby's files on disk. Details are under "Other projects' code". ## This PR: `0ddb4d89e` - **Finding the folder.** `.bobby` lives in the game folder (`HORIZON_MINECRAFT_DIR`, else the official launcher's, found the same way as `horizon-prepare`'s `minecraft_dir`). The level's folder is `<address as typed, ':' as '_'>/<hashed seed>/<namespace>/<path>`. Server names are compared without case, with or without the default port, since neither was observed. Another seed, dimension or port doesn't match. - **Reading a chunk.** When Horizon's store has no chunk, or holds an old record, far terrain reads it from Bobby's region file (opened read-only). It decodes it as a vanilla chunk with its stored light (`save::decode_lit`, handed in from `game.rs`), summarizes it the way a loaded chunk is, and keeps it in `server-terrain/`. So each chunk is read from Bobby once, and Bobby's folder is never written. A chunk of another `DataVersion`, one that doesn't decode or one without light gives nothing. - **Races.** A Bobby chunk is never written over one the server sent while it was being decoded. `store` remembers what it read, so an unchanged chunk isn't read from disk again. - **Wide cells.** Bobby's region headers count when far cells look for kept chunks. - Friend worlds and splitscreen guests still keep no server terrain, so they don't read Bobby either. - **Docs.** One sentence in `docs/graphics.md`. Tests: - Folders by address: port typed or not, `:` as `_`, case. Another seed, dimension or port doesn't match. An empty address or a missing root finds nothing. - A Bobby-shaped region: counted for wide cells before any read, then read, summarized and kept. Bobby's file stays byte-for-byte unchanged, and another version's chunk is ignored. - With prepared resources: a chunk with both palette shapes (plain names, and compounds with `{"": name}` wrappers) decodes with its light and is kept. - With prepared resources and `HORIZON_TEST_BOBBY`: every Overworld chunk of a `.bobby` folder Bobby really wrote (three worlds, found by address and seed) is read with a surface. ## Other projects' code - **Bobby** (LGPL-3.0, [Modrinth](https://modrinth.com/mod/bobby)): **no source read.** CONTRIBUTING allows running a mod and observing it, so that is all that was done. 1. **Run it.** A fork-only workflow ([`ci/bobby-observe`](https://github.com/some-du6e/horizon/tree/ci/bobby-observe), [run](https://github.com/some-du6e/horizon/actions/runs/41362977525)) runs a real 26.3 Fabric client with Bobby 5.2.16 and Fabric API against three local vanilla 26.3 servers: `127.0.0.1` seed 1111, `localhost:25566` seed 2222, `127.0.0.1` seed 3333. It teleports the player around, quits, and uploads the `.bobby` folder with a byte-level dump of its files. 2. **Describe it.** A description of the files was written from that output alone (below). For example, the seed folders match the login's hashed seed: SHA-256 of 1111 gives `-9030034075591913594`. 3. **Write it.** The importer was written from that description by a fresh agent told never to read Bobby's source or the removed Horizon code (no git history, other refs or other worktrees). It reports reading only the description and files at this branch's HEAD. The reviewer had the same rules. - Nothing else. <details><summary>The description the importer was written from</summary> ### What Bobby leaves on disk (observed, 2026-11-01) Written only from the files Bobby 5.2.16+mc26.3 (Fabric, with Fabric API 0.165.0+26.3) wrote while a real 26.3 client played on three local vanilla 26.3 servers, in GitHub Actions run https://github.com/some-du6e/horizon/actions/runs/41362977525 (workflow `bobby-observe.yml` on the fork branch `ci/bobby-observe`; its artifact `bobby-observe` holds the folders, logs and a byte-level dump). Bobby's source was not read. Default `config/bobby.conf` (the file Bobby wrote; relevant lines: `enabled=true`, `dynamic-multi-world=false`, `delete-unused-regions-after-days=-1`). #### Where `<game folder>/.bobby/` (the client's `--gameDir`; for the official launcher that is the `.minecraft` folder). #### Layout ``` .bobby/<server>/<hashed seed>/<namespace>/<path>/r.<X>.<Z>.mca .bobby/<server>/<hashed seed>/<namespace>/<path>/last_access ``` Observed folders, from the three servers: | Joined as (`--quickPlayMultiplayer`) | World seed | Folder | |---|---|---| | `127.0.0.1` (port 25565) | 1111 | `127.0.0.1/-9030034075591913594/minecraft/overworld/`, `…/minecraft/the_nether/` | | `localhost:25566` | 2222 | `localhost_25566/-7181178862026813658/minecraft/overworld/` | | `127.0.0.1` (port 25565), another world | 3333 | `127.0.0.1/4696776658964135993/minecraft/overworld/` | - **`<server>`**: the address as the player typed it, with `:` written as `_`. Typed without a port, no port appears. Not observed: an address typed with `:25565`, upper-case letters, or characters a file system can't hold. - **`<hashed seed>`**: the signed decimal of the hashed seed the server sends at login (vanilla's obfuscated seed: the first 8 bytes, little-endian, of SHA-256 over the world seed's 8 bytes, little-endian). Checked: 1111 → -9030034075591913594, 2222 → -7181178862026813658, 3333 → 4696776658964135993. Two worlds behind one address get two folders. - **`<namespace>/<path>`**: the dimension's key, `minecraft:overworld` → `minecraft/overworld`, `minecraft:the_nether` → `minecraft/the_nether`. - Not observed: `dynamic-multi-world=true` (Bobby's config says it starts a new cache at each world change and merges similar ones; its layout is unknown), and single player (Bobby is off there by default: `view-distance-overwrite=0`). #### Region files Standard Anvil region files: `r.<X>.<Z>.mca` for region X, Z (32 × 32 chunks), a 4096-byte location table, a 4096-byte timestamp table (seconds), 4096-byte sectors, each chunk a 4-byte length and a compression byte. Every chunk observed used compression 2 (zlib). No external `.mcc` files. Chunks present are the ones the client was sent and then unloaded: a square around each place the player stood (server view distance 4, client render distance 12), e.g. local (26..31, 26..31) of `r.-1.-1.mca`. #### A chunk Chunk NBT in the shape of a 26.3 save (root compound, unnamed). Top-level keys, in file order: `isLightOn`, `Status`, `zPos`, `block_entities`, `yPos`, `DataVersion`, `xPos`, `Heightmaps`, `sections`, `age`. ``` isLightOn: byte = 1 Status: string = "full" xPos: int, zPos: int, yPos: int = -4 DataVersion: int = 5023 (26.3's) block_entities: list, empty (Bobby's default no-block-entities=true) Heightmaps: OCEAN_FLOOR, MOTION_BLOCKING_NO_LEAVES, MOTION_BLOCKING, WORLD_SURFACE (long[37] each) sections: list of 24 compounds (overworld, Y -4..19), each with: Y: byte block_states: { palette: list, data: long[] (absent when the palette has one entry) } biomes: { palette: list of strings ("minecraft:meadow"), data: long[] when more than one } BlockLight: byte[2048], only in some sections SkyLight: byte[2048], only in some sections age: long = 1793576311368 (not a vanilla key: milliseconds since the epoch) ``` The block palette comes in two shapes, both seen in one chunk: - a **list of strings**, every entry a block id with no properties: `["minecraft:stone", "minecraft:gravel", "minecraft:air"]`; - a **list of compounds**, when at least one entry has properties. An entry without properties is then wrapped as a compound whose only key is the empty name: `{"": "minecraft:stone"}`. One with properties is `{id: "minecraft:pointed_dripstone", properties: {waterlogged: "false", ...}}` (lower-case `id` and `properties`, as vanilla's own block states since data version 5006). That is how 26.3's NBT writes a list whose elements don't share one type (strings and compounds), not something particular to Bobby as far as these files show; it was not compared against a vanilla server's own region files in this run. Light: not every section has `BlockLight` or `SkyLight`; a missing layer is a missing layer, as in a saved world. #### `last_access` One per dimension folder, 49–142 bytes, binary: varints (region X, region Z as zig-zag-free signed varints such as `ff ff ff ff 0f` for -1) and timestamps (seconds, varint), one entry a region. Bobby's own bookkeeping for `delete-unused-regions-after-days`. Not needed to read the chunks; a reader should leave it alone. #### For a reader - Read only: never write into `.bobby`. - Find the folder from what the client knows at login: the address as typed (`:` → `_`), the login's hashed seed, the dimension key. Since an address typed with `:25565` or in another case wasn't observed, a reader can accept both `host` and `host_25565` and compare names case-insensitively. - A missing folder, a missing region, a chunk of another `DataVersion` or one that fails to decode: nothing from Bobby for that chunk. </details> ## The stack On top of #6327 (it holds #6323–#6327), so review only the commit above. Merge it after them. ## Checked - **CI on the fork** ([run](https://github.com/some-du6e/horizon/actions/runs/41367225537), on this tree): `cargo fmt --check`; `clippy --all-targets -D warnings` on `horizon-client-render`, `horizon-client`, `horizon-client-lib` and `horizon-mods`; the render, client and client-lib tests. Then a second job downloads 26.3 from Mojang, prepares resources, and runs the two resource tests above: the synthetic chunk, and the real `.bobby` folder from the observe run. Both passed, in 72 s. - **Review:** one round by an independent clean-room reviewer. It found a race (fixed: a Bobby chunk could overwrite one the server had just sent) and a caching regression in `store` (fixed). Left as is: a stale Bobby chunk can still count toward a wide cell, as Horizon's own stale records already do. Also left: only the official launcher's `.minecraft` is searched, so Prism, MultiMC and Modrinth instances need `HORIZON_MINECRAFT_DIR`. - **Not run:** the parity harnesses and `pr_ready.py` (they need `.local/`, which this machine doesn't build), and a live game on a server with a Bobby cache. Suggested labels, since this fork can't set them: `feature` and `needs-proof`. > [!NOTE] > Filed by Opus 5.5 using Claude Code. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:31:55 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#7009
No description provided.