Merge pull request #356 from ludovic111/feat/version-consts

🤖 Agent: merged (version-port tooling, rebased on main). Ludovic asked on 10-21 to clear the PR queue.
This commit is contained in:
Ludovic Marie
2026-10-21 16:16:03 +02:00
committed by GitHub
46 changed files with 335 additions and 86 deletions
+2
View File
@@ -33,6 +33,8 @@ jobs:
run: bash tools/ci/runner-env.sh
- name: Vanilla data, and resources prepared by this preparer
run: bash tools/ci/vanilla-data.sh
- name: The version constants are the pinned jar's
run: python3 tools/gen_version_consts.py --check
- name: The harnesses this change can affect
env:
PARITY_HOSTS: ''
Generated
+1
View File
@@ -1539,6 +1539,7 @@ version = "0.1.0"
dependencies = [
"flate2",
"getrandom 0.3.4",
"horizon-core",
"horizon-world",
"serde_json",
"sha1",
@@ -137,7 +137,7 @@ fn world(assets: &Assets, facts: &BlockFacts, floor: bool) -> Result<World> {
fn main() -> Result<()> {
let args: Vec<String> = std::env::args().collect();
let root = Path::new(".local/horizon-client/26.3");
let root = &Path::new(".local/horizon-client").join(horizon_core::VANILLA_VERSION);
let assets = Assets::load(root)?;
let facts = BlockFacts::load(root, assets.registry)?;
let collision = collisions::load(root, assets.registry)?;
@@ -54,7 +54,7 @@ pub fn prepared_resources(dir: &Path) -> Option<PathBuf> {
.ok()
.and_then(|t| serde_json::from_str::<Value>(&t).ok())
.and_then(|v| v["minecraft"]["version"].as_str().map(str::to_owned))
.unwrap_or_else(|| "26.3".into());
.unwrap_or_else(|| horizon_core::VANILLA_VERSION.into());
let resources = dir.join(".local/horizon-client").join(version);
resources
.join("horizon-resources.json")
+8 -2
View File
@@ -241,7 +241,10 @@ fn memory() -> String {
pub fn system_details() -> Vec<(String, String)> {
let mut out = vec![
("Horizon Version".to_owned(), version()),
("Minecraft Version".to_owned(), "26.3".to_owned()),
(
"Minecraft Version".to_owned(),
horizon_core::VANILLA_VERSION.to_owned(),
),
("Operating System".to_owned(), operating_system()),
("CPU".to_owned(), cpu()),
("Memory".to_owned(), memory()),
@@ -605,7 +608,10 @@ mod tests {
assert!(first.contains("crash.rs"), "{}", report.stack);
let text = report.text();
assert!(text.contains("Description: Unexpected error"));
assert!(text.contains("\tMinecraft Version: 26.3\n"));
assert!(text.contains(&format!(
"\tMinecraft Version: {}\n",
horizon_core::VANILLA_VERSION
)));
assert!(text.contains("\tOperating System: "));
assert!(text.contains("\tCPU: "));
let home = std::env::temp_dir().join(format!("horizon-crash-save-{}", std::process::id()));
+2 -1
View File
@@ -597,7 +597,8 @@ mod fire_environment_tests {
#[test]
fn ordinary_items_burn_but_native_netherite_resists_lava() {
let root = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
.join("../../.local/horizon-client/26.3");
.join("../../.local/horizon-client")
.join(horizon_core::VANILLA_VERSION);
if !root.join("items.json").exists() {
return;
}
+2 -1
View File
@@ -1761,7 +1761,8 @@ mod axolotl_nbt_tests {
#[test]
fn bucket_cooldown_and_brain_memories_survive_and_expired_cooldown_is_removed() {
let root = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
.join("../../.local/horizon-client/26.3");
.join("../../.local/horizon-client")
.join(horizon_core::VANILLA_VERSION);
if !root.join("items.json").exists() {
return;
}
+16 -3
View File
@@ -230,7 +230,12 @@ impl Title {
color::mix(muted, color::TEXT, hover),
"Quit game",
);
ui.caps(24.0, h - 12.0 - 18.0, muted, "Horizon 26.3");
ui.caps(
24.0,
h - 12.0 - 18.0,
muted,
&format!("Horizon {}", horizon_core::VANILLA_VERSION),
);
}
/// Home: the launcher's Play page over the backdrop.
fn home(&self, ui: &mut Ui, x: f32, w: f32) {
@@ -241,7 +246,10 @@ impl Title {
x,
y,
muted,
"Minecraft 26.3 · Java Edition, rewritten in Rust",
&format!(
"Minecraft {} · Java Edition, rewritten in Rust",
horizon_core::VANILLA_VERSION
),
);
y += 24.0;
let line = (t::HERO * 1.1).round();
@@ -1189,7 +1197,12 @@ pub mod pause {
&["Game", "Advancements", "Statistics", "Options"],
0,
);
ui.caps(24.0, h - 12.0 - 18.0, color::FAINT, "Horizon 26.3");
ui.caps(
24.0,
h - 12.0 - 18.0,
color::FAINT,
&format!("Horizon {}", horizon_core::VANILLA_VERSION),
);
ui.offset = (0.0, 8.0 * (1.0 - p));
let x = SIDEBAR + 48.0;
let cw = (w - x - 48.0).min(760.0);
+3 -2
View File
@@ -292,7 +292,7 @@ impl Options {
resources: if sibling.join("horizon-resources.json").exists() {
sibling
} else {
PathBuf::from(".local/horizon-client/26.3")
std::path::Path::new(".local/horizon-client").join(horizon_core::VANILLA_VERSION)
},
distance: 12,
distance_override: None,
@@ -331,7 +331,8 @@ impl Options {
match arg.as_str() {
"--help" | "-h" => {
println!(
"Horizon — Minecraft Java Edition 26.3 in Rust\n\n --resources PATH Prepared resources (horizon-prepare)\n --render-distance N Chunks, 2..64 (default 12)\n --world NAME World folder under saves/ (default \"New World\")\n --seed N World seed for new worlds (default 0)\n --creative Creative mode (default survival)\n --test-terrain Simple test terrain instead of vanilla generation\n --frames N Exit after N frames (testing)\n --world-frames N Exit after N frames drawn in the world (testing)\n --smoke-report PATH Write a JSON report on exit\n --benchmark SCENARIO Run a benchmark (standard, village, forest, ocean, mountain), write its report to benchmarks/ and quit\n --control Accept horizon-ctl commands on a local socket\n --control-socket PATH Control socket path (default $XDG_RUNTIME_DIR/horizon-control.sock)\n --server HOST[:PORT] Join a multiplayer server (offline mode) at start\n --name NAME Player name for multiplayer (default: generated once, kept in horizon-player.txt)\n --session-file PATH Signed-in account from the launcher (read once, then deleted)\n --dev-mod PATH A Horizon mod (.hmod or folder) to develop: always on, reloaded when rebuilt\n\nControls: mouse look, WASD move, Space jump, Left Shift sneak, Left Ctrl sprint,\nleft click break, right click place/use, 1-9/scroll hotbar, E inventory,\nQ drop, F3 debug, Esc pause."
"Horizon — Minecraft Java Edition {} in Rust\n\n --resources PATH Prepared resources (horizon-prepare)\n --render-distance N Chunks, 2..64 (default 12)\n --world NAME World folder under saves/ (default \"New World\")\n --seed N World seed for new worlds (default 0)\n --creative Creative mode (default survival)\n --test-terrain Simple test terrain instead of vanilla generation\n --frames N Exit after N frames (testing)\n --world-frames N Exit after N frames drawn in the world (testing)\n --smoke-report PATH Write a JSON report on exit\n --benchmark SCENARIO Run a benchmark (standard, village, forest, ocean, mountain), write its report to benchmarks/ and quit\n --control Accept horizon-ctl commands on a local socket\n --control-socket PATH Control socket path (default $XDG_RUNTIME_DIR/horizon-control.sock)\n --server HOST[:PORT] Join a multiplayer server (offline mode) at start\n --name NAME Player name for multiplayer (default: generated once, kept in horizon-player.txt)\n --session-file PATH Signed-in account from the launcher (read once, then deleted)\n --dev-mod PATH A Horizon mod (.hmod or folder) to develop: always on, reloaded when rebuilt\n\nControls: mouse look, WASD move, Space jump, Left Shift sneak, Left Ctrl sprint,\nleft click break, right click place/use, 1-9/scroll hotbar, E inventory,\nQ drop, F3 debug, Esc pause.",
horizon_core::VANILLA_VERSION
);
return Ok(None);
}
@@ -59,12 +59,7 @@ pub(in crate::game) struct CommandExtras {
pub results: Option<Vec<(bool, i32)>>,
}
/// `version.json` of the 26.3 jars.
const VERSION_ID: &str = "26.3";
const DATA_VERSION: i32 = 5023;
const STABLE: bool = true;
/// `Date.toString()` of the build time in UTC.
const BUILD_TIME: &str = "Tue Sep 15 11:20:48 UTC 2026";
use horizon_core::version::{BUILD_TIME, DATA_VERSION, STABLE, VANILLA_VERSION, VERSION_ID};
fn num(n: impl std::fmt::Display) -> Text {
Text::literal(n.to_string())
@@ -974,7 +969,10 @@ impl Game<'_> {
let protocol = horizon_protocol::PROTOCOL_VERSION;
let mut lines: Vec<Text> = [
("commands.version.id", vec![Text::literal(VERSION_ID)]),
("commands.version.name", vec![Text::literal(VERSION_ID)]),
(
"commands.version.name",
vec![Text::literal(VANILLA_VERSION)],
),
("commands.version.data", vec![num(DATA_VERSION)]),
("commands.version.series", vec![Text::literal("main")]),
(
+7 -1
View File
@@ -484,7 +484,13 @@ impl Game<'_> {
})
},
));
log("INFO", "Starting minecraft server version 26.3");
log(
"INFO",
&format!(
"Starting minecraft server version {}",
horizon_core::VANILLA_VERSION
),
);
log("INFO", "Loading properties");
let game_mode = props.game_mode;
log(
+2 -1
View File
@@ -488,7 +488,8 @@ mod tests {
#[test]
fn primed_tnt_follows_water_currents_after_moving() {
let root = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
.join("../../.local/horizon-client/26.3");
.join("../../.local/horizon-client")
.join(horizon_core::VANILLA_VERSION);
if !root.join("movement-properties.nbt").exists() {
return;
}
+2 -1
View File
@@ -4476,7 +4476,8 @@ mod sprite_upload_tests {
#[test]
fn real_rail_mips_do_not_change_with_larger_array_layers() {
let root = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
.join("../../.local/horizon-client/26.3");
.join("../../.local/horizon-client")
.join(horizon_core::VANILLA_VERSION);
if !root
.join("assets/minecraft/textures/block/rail.png")
.exists()
+4 -1
View File
@@ -326,7 +326,10 @@ fn serve_legacy(mut stream: TcpStream, shared: &Shared) -> Result<(), String> {
return Ok(());
}
}
format!("\u{a7}1\0127\026.3\0{motd}\0{online}\0{max}")
format!(
"\u{a7}1\0127\0{}\0{motd}\0{online}\0{max}",
horizon_core::VANILLA_VERSION
)
};
let units: Vec<u16> = body.encode_utf16().collect();
let mut out = vec![0xFF];
+2 -1
View File
@@ -2014,7 +2014,8 @@ pub(crate) mod tests {
/// A menu over the game's data (`.local/horizon-client`); skipped without it.
pub(crate) fn with_menu(kind: Kind, test: impl FnOnce(&Env, &mut Menu)) {
let root = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
.join("../../.local/horizon-client/26.3");
.join("../../.local/horizon-client")
.join(horizon_core::VANILLA_VERSION);
if !root.join("items.json").exists() {
return;
}
+39 -13
View File
@@ -2020,7 +2020,9 @@ mod tests {
let root = std::env::var_os("HORIZON_TEST_RESOURCES")
.map(std::path::PathBuf::from)
.unwrap_or_else(|| {
Path::new(env!("CARGO_MANIFEST_DIR")).join("../../.local/horizon-client/26.3")
Path::new(env!("CARGO_MANIFEST_DIR"))
.join("../../.local/horizon-client")
.join(horizon_core::VANILLA_VERSION)
});
if !root.join("movement-properties.nbt").exists() {
eprintln!("skipped sword sweep regression: prepared resources unavailable");
@@ -2054,7 +2056,9 @@ mod tests {
let root = std::env::var_os("HORIZON_TEST_RESOURCES")
.map(std::path::PathBuf::from)
.unwrap_or_else(|| {
Path::new(env!("CARGO_MANIFEST_DIR")).join("../../.local/horizon-client/26.3")
Path::new(env!("CARGO_MANIFEST_DIR"))
.join("../../.local/horizon-client")
.join(horizon_core::VANILLA_VERSION)
});
if !root.join("movement-properties.nbt").exists() {
return;
@@ -2126,7 +2130,9 @@ mod tests {
#[test]
fn spectator_scroll_speed_controls_horizontal_and_vertical_flight() {
let root = Path::new(env!("CARGO_MANIFEST_DIR")).join("../../.local/horizon-client/26.3");
let root = Path::new(env!("CARGO_MANIFEST_DIR"))
.join("../../.local/horizon-client")
.join(horizon_core::VANILLA_VERSION);
if !root.join("movement-properties.nbt").exists() {
return;
}
@@ -2167,7 +2173,9 @@ mod tests {
#[test]
fn resident_spectator_flight_ignores_solid_and_climbable_blocks() {
let root = Path::new(env!("CARGO_MANIFEST_DIR")).join("../../.local/horizon-client/26.3");
let root = Path::new(env!("CARGO_MANIFEST_DIR"))
.join("../../.local/horizon-client")
.join(horizon_core::VANILLA_VERSION);
if !root.join("movement-properties.nbt").exists() {
return;
}
@@ -2230,7 +2238,9 @@ mod tests {
let root = std::env::var_os("HORIZON_TEST_RESOURCES")
.map(std::path::PathBuf::from)
.unwrap_or_else(|| {
Path::new(env!("CARGO_MANIFEST_DIR")).join("../../.local/horizon-client/26.3")
Path::new(env!("CARGO_MANIFEST_DIR"))
.join("../../.local/horizon-client")
.join(horizon_core::VANILLA_VERSION)
});
if !root.join("movement-properties.nbt").exists() {
eprintln!("skipped hunger regression: prepared resources unavailable");
@@ -2297,7 +2307,9 @@ mod tests {
let root = std::env::var_os("HORIZON_TEST_RESOURCES")
.map(std::path::PathBuf::from)
.unwrap_or_else(|| {
Path::new(env!("CARGO_MANIFEST_DIR")).join("../../.local/horizon-client/26.3")
Path::new(env!("CARGO_MANIFEST_DIR"))
.join("../../.local/horizon-client")
.join(horizon_core::VANILLA_VERSION)
});
if !root.join("movement-properties.nbt").exists() {
eprintln!("skipped damage regression: prepared resources unavailable");
@@ -2474,7 +2486,9 @@ mod tests {
/// per `nextStep` metre while walking.
#[test]
fn resident_water_landing_cancels_a_preset_fall() {
let root = Path::new(env!("CARGO_MANIFEST_DIR")).join("../../.local/horizon-client/26.3");
let root = Path::new(env!("CARGO_MANIFEST_DIR"))
.join("../../.local/horizon-client")
.join(horizon_core::VANILLA_VERSION);
if !root.join("movement-properties.nbt").exists() {
return;
}
@@ -2519,7 +2533,9 @@ mod tests {
let root = std::env::var_os("HORIZON_TEST_RESOURCES")
.map(std::path::PathBuf::from)
.unwrap_or_else(|| {
Path::new(env!("CARGO_MANIFEST_DIR")).join("../../.local/horizon-client/26.3")
Path::new(env!("CARGO_MANIFEST_DIR"))
.join("../../.local/horizon-client")
.join(horizon_core::VANILLA_VERSION)
});
if !root.join("movement-properties.nbt").exists() {
eprintln!("skipping resident water/lava test: prepared resources unavailable");
@@ -2776,7 +2792,9 @@ mod tests {
#[test]
fn resident_swimming_uses_previous_eyes_and_requires_water_at_the_feet() {
let root = Path::new(env!("CARGO_MANIFEST_DIR")).join("../../.local/horizon-client/26.3");
let root = Path::new(env!("CARGO_MANIFEST_DIR"))
.join("../../.local/horizon-client")
.join(horizon_core::VANILLA_VERSION);
if !root.join("movement-properties.nbt").exists() {
return;
}
@@ -2849,7 +2867,9 @@ mod tests {
#[test]
fn resident_fire_precedes_first_tick_lava_and_water_extinguishing() {
let root = Path::new(env!("CARGO_MANIFEST_DIR")).join("../../.local/horizon-client/26.3");
let root = Path::new(env!("CARGO_MANIFEST_DIR"))
.join("../../.local/horizon-client")
.join(horizon_core::VANILLA_VERSION);
if !root.join("movement-properties.nbt").exists() {
return;
}
@@ -2901,7 +2921,9 @@ mod tests {
#[test]
fn resident_bubble_columns_and_nautilus_preserve_their_air_rules() {
let root = Path::new(env!("CARGO_MANIFEST_DIR")).join("../../.local/horizon-client/26.3");
let root = Path::new(env!("CARGO_MANIFEST_DIR"))
.join("../../.local/horizon-client")
.join(horizon_core::VANILLA_VERSION);
if !root.join("movement-properties.nbt").exists() {
return;
}
@@ -2971,7 +2993,9 @@ mod tests {
#[test]
fn resident_mixed_fluids_use_lava_height_for_ground_jumps() {
let root = Path::new(env!("CARGO_MANIFEST_DIR")).join("../../.local/horizon-client/26.3");
let root = Path::new(env!("CARGO_MANIFEST_DIR"))
.join("../../.local/horizon-client")
.join(horizon_core::VANILLA_VERSION);
if !root.join("movement-properties.nbt").exists() {
return;
}
@@ -3020,7 +3044,9 @@ mod tests {
#[test]
fn footsteps_follow_the_walked_distance_not_the_tick() {
let root = Path::new(env!("CARGO_MANIFEST_DIR")).join("../../.local/horizon-client/26.3");
let root = Path::new(env!("CARGO_MANIFEST_DIR"))
.join("../../.local/horizon-client")
.join(horizon_core::VANILLA_VERSION);
if !root.join("movement-properties.nbt").exists() {
return;
}
+1 -1
View File
@@ -15,7 +15,7 @@ use std::{
};
/// SharedConstants resource pack format of 26.3 (major, minor).
pub const RESOURCE_FORMAT: (i64, i64) = (97, 1);
pub const RESOURCE_FORMAT: (i64, i64) = horizon_core::version::RESOURCE_PACK_FORMAT;
#[derive(Clone, Debug)]
pub enum Source {
@@ -206,12 +206,16 @@ mod tick_parity {
.map(PathBuf::from)
.unwrap_or_else(|| {
let manifest = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
let local = manifest.join("../../.local/horizon-client/26.3");
let local = manifest
.join("../../.local/horizon-client")
.join(horizon_core::VANILLA_VERSION);
if local.join("gameplay-facts.json").exists() {
local
} else {
// The branch worktree lives below the main checkout.
manifest.join("../../../../.local/horizon-client/26.3")
manifest
.join("../../../../.local/horizon-client")
.join(horizon_core::VANILLA_VERSION)
}
});
if !root.join("gameplay-facts.json").exists() {
+1 -1
View File
@@ -46,7 +46,7 @@ use std::{
},
};
pub const VERSION_NAME: &str = "26.3";
pub const VERSION_NAME: &str = horizon_core::VANILLA_VERSION;
/// Snapshot live block entities and custom names for a save batch without
/// mutating the world. Each map is visited once, retaining its iteration order
+3 -1
View File
@@ -415,7 +415,9 @@ mod tests {
#[test]
fn native_fire_sprites_register_full_animation_sequences() {
let root = Path::new(env!("CARGO_MANIFEST_DIR")).join("../../.local/horizon-client/26.3");
let root = Path::new(env!("CARGO_MANIFEST_DIR"))
.join("../../.local/horizon-client")
.join(horizon_core::VANILLA_VERSION);
if !root
.join("assets/minecraft/textures/block/fire_0.png")
.exists()
+3 -1
View File
@@ -877,7 +877,9 @@ mod tests {
/// Checks against the prepared vanilla resources when they are present.
#[test]
fn prepared_vanilla_data() {
let root = Path::new(env!("CARGO_MANIFEST_DIR")).join("../../.local/horizon-client/26.3");
let root = Path::new(env!("CARGO_MANIFEST_DIR"))
.join("../../.local/horizon-client")
.join(horizon_core::VANILLA_VERSION);
if !root.join("items.json").exists() {
return;
}
+2 -2
View File
@@ -825,8 +825,8 @@ impl Title {
];
}
}
let version = "Horizon 26.3 (Rust)";
batch.text(atlas, version, 2.0, h - 10.0, u32::MAX, true);
let version = format!("Horizon {} (Rust)", horizon_core::VANILLA_VERSION);
batch.text(atlas, &version, 2.0, h - 10.0, u32::MAX, true);
let notice = "Not affiliated with Mojang or Microsoft";
let tw = HudBatch::text_width(atlas, notice);
batch.text(atlas, notice, w - tw - 2.0, h - 10.0, u32::MAX, true);
+5 -4
View File
@@ -469,13 +469,14 @@ mod tests {
/// Against the prepared vanilla resources when they are present.
#[test]
fn prepared_vanilla_edition() {
let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join(
"../../.local/horizon-client/26.3/assets/minecraft/textures/gui/title/edition.png",
);
let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
.join("../../.local/horizon-client")
.join(horizon_core::VANILLA_VERSION)
.join("assets/minecraft/textures/gui/title/edition.png");
let Ok((w, h, pixels)) = crate::hud::decode(&path) else {
return;
};
let out = rust_edition(w, h, &pixels).expect("vanilla 26.3's edition.png");
let out = rust_edition(w, h, &pixels).expect("vanilla's edition.png");
assert_eq!(
columns(&out, EDITION_START..WIDTH),
columns(&pixels, EDITION_START..WIDTH)
@@ -24,7 +24,9 @@ use std::{
};
fn resources() -> Option<std::path::PathBuf> {
let root = Path::new(env!("CARGO_MANIFEST_DIR")).join("../../.local/horizon-client/26.3");
let root = Path::new(env!("CARGO_MANIFEST_DIR"))
.join("../../.local/horizon-client")
.join(horizon_core::VANILLA_VERSION);
root.join("items.json").exists().then_some(root)
}
+7 -2
View File
@@ -34,7 +34,9 @@ use std::{
};
fn resources() -> Option<std::path::PathBuf> {
let root = Path::new(env!("CARGO_MANIFEST_DIR")).join("../../.local/horizon-client/26.3");
let root = Path::new(env!("CARGO_MANIFEST_DIR"))
.join("../../.local/horizon-client")
.join(horizon_core::VANILLA_VERSION);
root.join("items.json").exists().then_some(root)
}
@@ -305,7 +307,10 @@ fn status_and_join() {
Ok(r.json)
});
let v: serde_json::Value = serde_json::from_str(&json).unwrap();
assert_eq!(v["version"]["protocol"], 777);
assert_eq!(
v["version"]["protocol"],
horizon_core::version::PROTOCOL_VERSION
);
// ServerStatus.CODEC writes a plain literal MOTD as a bare string.
assert_eq!(v["description"], "Test - World");
@@ -26,7 +26,9 @@ use std::{
};
fn resources() -> Option<std::path::PathBuf> {
let root = Path::new(env!("CARGO_MANIFEST_DIR")).join("../../.local/horizon-client/26.3");
let root = Path::new(env!("CARGO_MANIFEST_DIR"))
.join("../../.local/horizon-client")
.join(horizon_core::VANILLA_VERSION);
root.join("items.json").exists().then_some(root)
}
+4 -2
View File
@@ -1,4 +1,4 @@
//! Horizon's initial simulation primitives, targeting Minecraft Java Edition 26.3.
//! Horizon's initial simulation primitives, targeting the Minecraft Java Edition version in [`version`].
//!
//! This is not a playable game. Differential checks cover only the operations
//! listed in docs/rust-parity.md; the rest of vanilla remains unimplemented.
@@ -17,4 +17,6 @@ pub mod storage;
pub mod text;
pub mod ticks;
pub const VANILLA_VERSION: &str = "26.3";
pub mod version;
pub use version::VANILLA_VERSION;
+21
View File
@@ -0,0 +1,21 @@
//! What Minecraft 26.3 states about itself (the client jar's `version.json`,
//! `SharedConstants.getCurrentVersion()`). Generated by tools/gen_version_consts.py; do not edit by hand.
/// `WorldVersion.id()`.
pub const VERSION_ID: &str = "26.3";
/// `WorldVersion.name()`: level.dat, the server list, crash reports.
pub const VANILLA_VERSION: &str = "26.3";
/// `SharedConstants.getProtocolVersion()`.
pub const PROTOCOL_VERSION: i32 = 777;
/// `WorldVersion.dataVersion()`: the DataVersion of saved chunks, entities and level.dat.
pub const DATA_VERSION: i32 = 5023;
/// `WorldVersion.packVersion(PackType.CLIENT_RESOURCES)`: (major, minor).
pub const RESOURCE_PACK_FORMAT: (i64, i64) = (97, 1);
/// `WorldVersion.packVersion(PackType.SERVER_DATA)`: (major, minor).
pub const DATA_PACK_FORMAT: (i64, i64) = (121, 0);
/// The Java major version the game runs on.
pub const JAVA_VERSION: u32 = 25;
/// `WorldVersion.stable()`: false for snapshots and pre-releases.
pub const STABLE: bool = true;
/// `WorldVersion.buildTime()` as `Date.toString()` prints it in UTC (`/version`).
pub const BUILD_TIME: &str = "Tue Sep 15 11:20:48 UTC 2026";
+1
View File
@@ -7,6 +7,7 @@ rust-version.workspace = true
description = "Horizon's Minecraft Java Edition 26.3 network protocol (version 777)"
[dependencies]
horizon-core = { path = "../horizon-core" }
horizon-world = { path = "../horizon-world" }
flate2 = { version = "1.1.10", default-features = false, features = ["zlib-rs", "runtime_detection"] }
serde_json = "1.0.151"
+4 -4
View File
@@ -1,4 +1,4 @@
//! The Minecraft Java Edition 26.3 network protocol (protocol version 777):
//! The Minecraft Java Edition network protocol (of the version in `horizon_core::version`):
//! primitive codecs, framing, compression, encryption, and typed packets for
//! every connection state, shared by the Horizon client and (later) server.
#![forbid(unsafe_code)]
@@ -17,10 +17,10 @@ pub mod secure_chat;
pub mod servers;
pub mod text;
/// SharedConstants.getProtocolVersion() for 26.3.
pub const PROTOCOL_VERSION: i32 = 777;
/// SharedConstants.getProtocolVersion().
pub const PROTOCOL_VERSION: i32 = horizon_core::version::PROTOCOL_VERSION;
/// The game version servers report in their status.
pub const GAME_VERSION: &str = "26.3";
pub const GAME_VERSION: &str = horizon_core::VANILLA_VERSION;
/// Connection protocol states (ConnectionProtocol).
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
+1 -1
View File
@@ -15,7 +15,7 @@ use std::io;
use std::path::{Path, PathBuf};
/// The name `SharedConstants.getCurrentVersion().name()` writes in level.dat.
pub const VERSION_NAME: &str = "26.3";
pub const VERSION_NAME: &str = horizon_core::version::VANILLA_VERSION;
const FILE_FIXER_INTRODUCTION: i32 = 4772;
/// The versions of the file fixes, in order.
@@ -21,7 +21,8 @@ fn fixture() -> Option<&'static Fixture> {
.map(PathBuf::from)
.unwrap_or_else(|| {
PathBuf::from(env!("CARGO_MANIFEST_DIR"))
.join("../../.local/horizon-client/26.3")
.join("../../.local/horizon-client")
.join(horizon_core::VANILLA_VERSION)
});
// Trees need the feature block-behaviour exports in the worldgen bundle.
if !root.join("block-behaviours.json").exists()
+3 -2
View File
@@ -1,5 +1,5 @@
//! Behaviour tests over an in-memory level. They need the prepared client
//! resources (`HORIZON_RESOURCES`, or `.local/horizon-client/26.3` at the
//! resources (`HORIZON_RESOURCES`, or `.local/horizon-client/<version>` at the
//! repository root) and are skipped when those are absent.
use super::*;
use crate::chunk::BlockState;
@@ -22,7 +22,8 @@ fn fixture() -> Option<&'static Fixture> {
.map(PathBuf::from)
.unwrap_or_else(|| {
PathBuf::from(env!("CARGO_MANIFEST_DIR"))
.join("../../.local/horizon-client/26.3")
.join("../../.local/horizon-client")
.join(horizon_core::VANILLA_VERSION)
});
if !root.join("block-behaviours.json").exists() {
eprintln!("skipping level tests: no resources at {}", root.display());
+1 -1
View File
@@ -122,7 +122,7 @@ pub mod world_movement;
pub mod world_ray;
pub mod worldgen;
pub const DATA_VERSION: i32 = 5023;
pub const DATA_VERSION: i32 = horizon_core::version::DATA_VERSION;
pub mod item_stack_refs;
pub mod simple_container;
+3 -2
View File
@@ -51,7 +51,7 @@ fn run(args: &[String]) -> Result<(), Box<dyn Error>> {
};
match command {
"--help" | "-h" if args.len() == 1 => println!(
"Horizon world data tools — Java Edition 26.3\n\
"Horizon world data tools — Java Edition {}\n\
inspect <region.mca>\n\
copy-region <source.mca> <new-directory/r.x.z.mca> [gzip|zlib|none|lz4]\n\
get-block <region.mca> <x> <y> <z>\n\
@@ -59,7 +59,8 @@ fn run(args: &[String]) -> Result<(), Box<dyn Error>> {
nbt-copy <input> <new-output> <input-codec> <output-codec>\n\
nbt-network-copy <input> <new-output> <input-codec> <output-codec>\n\
Existing output files are refused. edit-block-data changes saved block data only;\n\
it does not run lighting, heightmaps, ticks or neighbor updates."
it does not run lighting, heightmaps, ticks or neighbor updates.",
horizon_core::VANILLA_VERSION
),
"nbt-copy" | "nbt-network-copy" if args.len() == 5 => {
let bytes =
+11 -13
View File
@@ -25,23 +25,20 @@ to players. Players still prepare their own copy from their official launcher (`
exporters (`mods/horizon/src/test/java/dev/horizonlab/parity/Vanilla*Exporter.java`) against the jar for block
behaviours, worldgen bundles and the like. CI does the same through `tools/ci/vanilla-data.sh`, keyed by the
version in `research-lock.json`.
- **Version facts baked into the code.** The client jar's own `version.json` states them (26.3: world version 5023,
protocol 777, resource pack 97.1, data pack 121.0, Java 25); Horizon copies them by hand today:
| Where | What |
| --- | --- |
| `crates/horizon-core/src/lib.rs` | `VANILLA_VERSION` |
| `crates/horizon-protocol/src/lib.rs` | `PROTOCOL_VERSION`, `GAME_VERSION` |
| `crates/horizon-protocol/src/packets/configuration.rs` | the `minecraft:core` known pack version |
| `crates/horizon-world/src/lib.rs`, `crates/horizon-client/src/game/commands/extra.rs` | `DATA_VERSION` (twice) |
| `crates/horizon-client/src/save.rs`, `crates/horizon-world/src/datafix/files.rs`, `game/commands/extra.rs` | the version name (three times) |
| `crates/horizon-client/src/crash.rs`, `bin/horizon-ctl/launch.rs`, `launcher/src/backend.rs` | `"26.3"` fallbacks |
| `tools/perf_bench.py`, `tools/vanilla_client.py` | the vanilla client's `--version` |
- **Version facts in the code.** The client jar's own `version.json` states them (26.3: world version 5023,
protocol 777, resource pack 97.1, data pack 121.0, Java 25). `tools/gen_version_consts.py` writes them into
one generated file, `crates/horizon-core/src/version.rs` (`VANILLA_VERSION`, `PROTOCOL_VERSION`,
`DATA_VERSION`, the pack formats, Java, `/version`'s build time), and every Rust site reads them from there
(`horizon_protocol::PROTOCOL_VERSION`, `horizon_world::DATA_VERSION` and the save's version name are aliases
of it; the status, the legacy ping, the crash report, `/version`, the title screens and the default resource
folder use it). CI checks the file against the pinned jar (`--check`). Test fixtures that state a version
(a level.dat to read, a relay message) keep their literals: they test parsing, not the pin.
- **Generated tables** (each has its generator in `tools/`):
| Output | Generator | Input |
| --- | --- | --- |
| `crates/horizon-core/src/version.rs` | `gen_version_consts.py` | the client jar's `version.json` |
| `crates/horizon-protocol/src/ids.rs` | `generate_packet_ids.py` | `packets.json` report |
| `crates/horizon-client/src/lan/tracking.rs` | `generate_entity_tracking.py` | decompiled `EntityTypes` |
| `crates/horizon-client/src/lan/command_suggestions.rs` | `generate_command_suggestions.py` | `VanillaCommandSuggestionsExporter` |
@@ -298,4 +295,5 @@ python3 tools/vanilla_map.py versions/26.3/classes.json net.minecraft.world.food
| `detect`, `prepare`, `diff` (facts, packets, registries, blocks, items, commands, data, assets), `gc` | done |
| Class index (`tools/class_index.py`), class diff with moves, `vanilla_map.json` (`tools/vanilla_map.py`) | done |
| Port report (`tools/port_report.py`, `report`), `port` | done |
| Changed-class decompilation, `regen`, `version_consts` refactor, candidate harness run, `publish`, launchd agent | later |
| `version_consts`: one generated file for the version facts (`tools/gen_version_consts.py`) | done |
| Changed-class decompilation, `regen`, candidate harness run, `publish`, launchd agent | later |
+8
View File
@@ -2637,6 +2637,13 @@ dependencies = [
"serde_json",
]
[[package]]
name = "horizon-core"
version = "0.1.0"
dependencies = [
"libm",
]
[[package]]
name = "horizon-friends"
version = "0.1.0"
@@ -2663,6 +2670,7 @@ dependencies = [
"getrandom 0.3.4",
"gpui",
"horizon-bench",
"horizon-core",
"horizon-friends",
"horizon-port-pack",
"horizon-prepare",
+1
View File
@@ -22,6 +22,7 @@ dirs = "5"
self-replace = "1"
clap = { version = "4", features = ["derive"] }
horizon-theme = { path = "../crates/horizon-theme" }
horizon-core = { path = "../crates/horizon-core" }
horizon-prepare = { path = "../crates/horizon-prepare" }
# Join a friend: invite codes (the game does the joining).
horizon-friends = { path = "../crates/horizon-friends" }
+1 -1
View File
@@ -479,7 +479,7 @@ fn read_json(path: &Path) -> Option<serde_json::Value> {
fn game_version_at(dir: &Path) -> String {
read_json(&dir.join("research-lock.json"))
.and_then(|v| v["minecraft"]["version"].as_str().map(String::from))
.unwrap_or_else(|| "26.3".into())
.unwrap_or_else(|| horizon_core::VANILLA_VERSION.into())
}
pub fn resources(tag: &str) -> PathBuf {
+3 -2
View File
@@ -80,7 +80,7 @@ pub fn launcher_entry(exe: &Path) -> String {
Type=Application\n\
Name=Horizon\n\
GenericName=Game launcher\n\
Comment=Install, prepare and play Horizon, Minecraft: Java Edition 26.3 rewritten in Rust\n\
Comment=Install, prepare and play Horizon, Minecraft: Java Edition {minecraft} rewritten in Rust\n\
Exec={}\n\
TryExec={}\n\
Icon=horizon\n\
@@ -88,7 +88,8 @@ pub fn launcher_entry(exe: &Path) -> String {
Categories=Game;\n\
StartupWMClass=horizon-launcher\n",
quote(exe),
exe.display()
exe.display(),
minecraft = horizon_core::VANILLA_VERSION,
)
}
+1 -1
View File
@@ -31,7 +31,7 @@ fn tools() -> Value {
"inputSchema": { "type": "object", "properties": { "tag": { "type": "string", "description": "A release tag such as v2026.10.13, or \"latest\"." } }, "required": ["tag"] } },
{ "name": "remove_version", "description": "Remove an installed Horizon version and its prepared resources.",
"inputSchema": { "type": "object", "properties": { "tag": { "type": "string" } }, "required": ["tag"] } },
{ "name": "prepare_resources", "description": "Prepare a version's resources from the player's own Minecraft install (needs Minecraft 26.3 played once in the official launcher and Java 25; versions before horizon-prepare also need Python 3.10+). Can take several minutes; returns the end of the log.",
{ "name": "prepare_resources", "description": "Prepare a version's resources from the player's own Minecraft install (needs the Minecraft release that version is built for, played once in the official launcher, and its Java; versions before horizon-prepare also need Python 3.10+). Can take several minutes; returns the end of the log.",
"inputSchema": { "type": "object", "properties": { "version": version, "minecraft_dir": { "type": "string", "description": "The game folder of the official launcher, Prism Launcher, MultiMC, the Modrinth App, ATLauncher or GDLauncher. Default: the launcher's setting, then every launcher's default folder." } } } },
{ "name": "launch_client", "description": "Start the Horizon client (a game window on the player's screen) under agent control: the game_* tools then play it. Returns once it has started; game_wait_ready waits for the world.",
"inputSchema": { "type": "object", "properties": { "version": version,
+48
View File
@@ -0,0 +1,48 @@
import json
from pathlib import Path
import re
import tempfile
import unittest
import zipfile
from tools import gen_version_consts as gen
from tools import lab
INFO = {
"id": "26.4", "name": "26.4", "world_version": 5100, "protocol_version": 780,
"pack_version": {"resource_major": 99, "resource_minor": 0, "data_major": 124, "data_minor": 2},
"build_time": "2026-12-01T09:05:07+00:00", "java_version": 25, "stable": False,
}
class GenVersionConstsTests(unittest.TestCase):
def test_renders_every_fact(self):
text = gen.render(INFO)
for line in ['pub const VERSION_ID: &str = "26.4";', 'pub const VANILLA_VERSION: &str = "26.4";',
"pub const PROTOCOL_VERSION: i32 = 780;", "pub const DATA_VERSION: i32 = 5100;",
"pub const RESOURCE_PACK_FORMAT: (i64, i64) = (99, 0);",
"pub const DATA_PACK_FORMAT: (i64, i64) = (124, 2);", "pub const JAVA_VERSION: u32 = 25;",
"pub const STABLE: bool = false;", 'pub const BUILD_TIME: &str = "Tue Dec 01 09:05:07 UTC 2026";']:
self.assertIn(line, text)
def test_build_time_is_printed_in_utc(self):
self.assertEqual(gen.java_date("2026-09-15T13:20:48+02:00"), "Tue Sep 15 11:20:48 UTC 2026")
def test_reads_the_jar(self):
with tempfile.TemporaryDirectory() as directory:
jar = Path(directory) / "client.jar"
with zipfile.ZipFile(jar, "w") as archive:
archive.writestr("version.json", json.dumps(INFO))
self.assertEqual(gen.jar_info(jar), INFO)
def test_committed_file_is_the_pinned_version(self):
"""A pin bump regenerates version.rs: the lock and the constants never disagree."""
text = gen.OUT.read_text()
pinned = json.loads(lab.LOCK.read_text())["minecraft"]
self.assertEqual(re.search(r'VANILLA_VERSION: &str = "([^"]+)"', text)[1], pinned["version"])
self.assertEqual(int(re.search(r"JAVA_VERSION: u32 = (\d+)", text)[1]), pinned["java_major"])
self.assertIn("Generated by tools/gen_version_consts.py", text)
if __name__ == "__main__":
unittest.main()
+4 -3
View File
@@ -72,12 +72,13 @@ class PortReportTests(unittest.TestCase):
built = self.build()
kinds = [(i["rank"], i["kind"]) for i in built["items"]]
self.assertEqual(sorted(k for r, k in kinds if r == 1),
["components", "facts", "protocol", "regenerate", "regenerate", "report-format",
"save-format"])
["components", "facts", "protocol", "regenerate", "regenerate", "regenerate",
"report-format", "save-format"])
self.assertEqual([i["id"] for i in built["items"]], list(range(1, len(kinds) + 1)))
self.assertEqual(kinds, sorted(kinds, key=lambda k: k[0]))
regenerated = {i["files"][0] for i in built["items"] if i["kind"] == "regenerate"}
self.assertEqual(regenerated, {"crates/horizon-protocol/src/ids.rs", "crates/horizon-client/src/lan/tracking.rs"})
self.assertEqual(regenerated, {"crates/horizon-core/src/version.rs", "crates/horizon-protocol/src/ids.rs",
"crates/horizon-client/src/lan/tracking.rs"})
def test_save_format_lists_new_schemas_and_fixes(self):
save = next(i for i in self.build()["items"] if i["kind"] == "save-format")
+85
View File
@@ -0,0 +1,85 @@
#!/usr/bin/env python3
"""Generate crates/horizon-core/src/version.rs: what the pinned Minecraft version states about itself in its
client jar's version.json (name, protocol, data version, pack formats, Java, build time). Every Rust site that
needs one of these facts reads it from there, so a version bump rewrites this one file
(docs/version-ports.md, "Regenerate").
gen_version_consts.py [--jar CLIENT_JAR] [--out PATH] [--check]
The default jar is the pinned one (.local/minecraft/<research-lock.json version>/jars/client.jar).
--check exits 1 when the committed file differs from what the jar says.
"""
import argparse
from datetime import datetime, timezone
import json
from pathlib import Path
import sys
import zipfile
try:
from . import lab
except ImportError:
import lab
OUT = lab.ROOT / "crates/horizon-core/src/version.rs"
def jar_info(client_jar):
with zipfile.ZipFile(client_jar) as archive:
return json.loads(archive.read("version.json"))
def java_date(iso):
"""`Date.toString()` of an ISO-8601 instant, in UTC (Locale.ROOT names)."""
return datetime.fromisoformat(iso).astimezone(timezone.utc).strftime("%a %b %d %H:%M:%S UTC %Y")
def render(info):
pack = info["pack_version"]
return "\n".join([
f"//! What Minecraft {info['name']} states about itself (the client jar's `version.json`,",
"//! `SharedConstants.getCurrentVersion()`). Generated by tools/gen_version_consts.py; do not edit by hand.",
"",
"/// `WorldVersion.id()`.",
f"pub const VERSION_ID: &str = {json.dumps(info['id'])};",
"/// `WorldVersion.name()`: level.dat, the server list, crash reports.",
f"pub const VANILLA_VERSION: &str = {json.dumps(info['name'])};",
"/// `SharedConstants.getProtocolVersion()`.",
f"pub const PROTOCOL_VERSION: i32 = {info['protocol_version']};",
"/// `WorldVersion.dataVersion()`: the DataVersion of saved chunks, entities and level.dat.",
f"pub const DATA_VERSION: i32 = {info['world_version']};",
"/// `WorldVersion.packVersion(PackType.CLIENT_RESOURCES)`: (major, minor).",
f"pub const RESOURCE_PACK_FORMAT: (i64, i64) = ({pack['resource_major']}, {pack['resource_minor']});",
"/// `WorldVersion.packVersion(PackType.SERVER_DATA)`: (major, minor).",
f"pub const DATA_PACK_FORMAT: (i64, i64) = ({pack['data_major']}, {pack['data_minor']});",
"/// The Java major version the game runs on.",
f"pub const JAVA_VERSION: u32 = {info['java_version']};",
"/// `WorldVersion.stable()`: false for snapshots and pre-releases.",
f"pub const STABLE: bool = {'true' if info['stable'] else 'false'};",
"/// `WorldVersion.buildTime()` as `Date.toString()` prints it in UTC (`/version`).",
f"pub const BUILD_TIME: &str = {json.dumps(java_date(info['build_time']))};",
"",
])
def main():
parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
parser.add_argument("--jar", type=Path, help="client jar (default: the pinned one in .local)")
parser.add_argument("--out", type=Path, default=OUT)
parser.add_argument("--check", action="store_true", help="exit 1 if --out differs instead of writing it")
args = parser.parse_args()
jar = args.jar or lab.config()[1] / "jars" / "client.jar"
text = render(jar_info(jar))
if args.check:
if not args.out.exists() or args.out.read_text() != text:
print(f"{args.out} does not match {jar}; run tools/gen_version_consts.py", file=sys.stderr)
return 1
return 0
args.out.write_text(text)
print(f"wrote {args.out}")
return 0
if __name__ == "__main__":
sys.exit(main())
+1
View File
@@ -30,6 +30,7 @@ PROTOCOL = "net/minecraft/network/protocol/"
DATAFIX = "net/minecraft/util/datafix/"
# Generated tables, what makes them stale, and how to regenerate them (docs/version-ports.md, "Regenerate").
GENERATORS = [
("crates/horizon-core/src/version.rs", "python3 tools/gen_version_consts.py", lambda d: bool(d["facts"])),
("crates/horizon-protocol/src/ids.rs", "python3 tools/generate_packet_ids.py",
lambda d: bool(d["packets"])),
("crates/horizon-client/src/lan/tracking.rs", "python3 tools/generate_entity_tracking.py",
+1 -1
View File
@@ -45,7 +45,7 @@ PARITY_SHARDS = 6
PARITY_RUST_SCOPE = [
'crates/horizon-world/src/datafix/', 'crates/horizon-world/src/nbt.rs', 'crates/horizon-world/src/region.rs',
'crates/horizon-world/src/compression.rs', 'crates/horizon-core/src/position.rs', 'crates/horizon-core/src/position/',
'crates/horizon-core/src/geometry/',
'crates/horizon-core/src/geometry/', 'crates/horizon-core/src/version.rs',
]
IGNORED = {