diff --git a/.dockerignore b/.dockerignore
index 417a1867c..458330c93 100644
--- a/.dockerignore
+++ b/.dockerignore
@@ -2,7 +2,6 @@
target/
.local/
**/node_modules/
-website/
benchmarks/
packs/
mods/
diff --git a/.gitattributes b/.gitattributes
index 358aeae7a..f9e1922d7 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -2,5 +2,5 @@
# where Git for Windows' core.autocrlf would check them out with CRLF.
docs/launcher-commands.md text eol=lf
docs/horizon-ctl-commands.md text eol=lf
-website/src/tokens.css text eol=lf
+crates/horizon-theme/tokens.css text eol=lf
docs/api/*-reference.md text eol=lf
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index eff82fa99..39ea920da 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -73,6 +73,42 @@ jobs:
run: |
cargo +stable test --workspace --lib --bins --tests --features horizon-client/mods,horizon-mods/pack
cargo +stable test --workspace --doc --features horizon-client/mods,horizon-mods/pack
+ # The launcher is its own workspace (launcher/Cargo.toml), so verify's cargo runs never build it. A pull request that
+ # changes it or a crate it builds is checked here, and so is every push to main: two pull requests can each pass
+ # alone and break it together (#2059 and the registry ratings did, 2026-10-26).
+ launcher:
+ runs-on: ubuntu-latest
+ timeout-minutes: 30
+ steps:
+ - uses: actions/checkout@v4
+ with:
+ fetch-depth: 0
+ - name: Does this pull request change the launcher or a crate it builds?
+ if: github.event_name == 'pull_request'
+ id: launcher
+ env:
+ BASE_SHA: ${{ github.event.pull_request.base.sha }}
+ HEAD_SHA: ${{ github.event.pull_request.head.sha }}
+ run: python3 tools/ci/rust_changes.py --launcher "$BASE_SHA" "$HEAD_SHA" >> "$GITHUB_OUTPUT"
+ - name: Install Rust and the headers GPUI links against
+ if: steps.launcher.outputs.required != 'false'
+ run: |
+ sudo apt-get update && sudo apt-get install -y --no-install-recommends libxkbcommon-x11-dev libwayland-dev \
+ libx11-xcb-dev libfontconfig-dev libvulkan-dev libasound2-dev libudev-dev
+ rustup toolchain install stable --profile minimal --component rustfmt --component clippy
+ - uses: Swatinem/rust-cache@v2
+ if: steps.launcher.outputs.required != 'false'
+ with:
+ workspaces: launcher
+ shared-key: launcher
+ save-if: ${{ github.ref == 'refs/heads/main' }}
+ - name: Check the launcher's formatting, lint and tests
+ if: steps.launcher.outputs.required != 'false'
+ working-directory: launcher
+ run: |
+ cargo +stable fmt --check
+ cargo +stable clippy --all-targets --locked -- -D warnings
+ cargo +stable test --locked --lib
# Most pull requests leave the harnesses to parity-main, which runs them on main a batch of merges at a time
# (.github/workflows/parity-main.yml; releases wait for it). A pull request still runs them itself when it changes
# a harness, an oracle, a probe or the runner, or carries the run-parity label (run-parity.yml, when it is added).
diff --git a/AGENTS.md b/AGENTS.md
index dcd4ca595..e1fa9e7fe 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -54,7 +54,8 @@ Game workspace (root `Cargo.toml`); `launcher/` and `crates/horizon-telemetry-se
Other top-level folders: `tools/` (harnesses and dev scripts), `tests/` (Python unit tests: `python3 -m
unittest discover -s tests`), `mods/horizon/src/test/java/dev/horizonlab/parity/` (Java oracles),
-`website/` (playhorizon.dev; its paths are relative to `website/`), `docs/`, `.github/workflows/`.
+`docs/`, `.github/workflows/`. The website (playhorizon.dev) is the private ludovic111/horizon-site: its build
+reads `README.md`, `launcher/links.json`, `docs/api/`, `roadmap/roadmap.json` and `crates/horizon-theme/tokens.css` from main.
## Build and test fast
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 21951c083..03f3bd97b 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -4,8 +4,8 @@ Thanks for helping. Horizon is Minecraft: Java Edition 26.3 rewritten in Rust, a
everything is that **it plays exactly like vanilla**. This page is the short version of how we work; questions are
welcome on [Discord](https://discord.gg/HcTeMZxe5E).
-This repository holds the game, the launcher and the website, plus the tools, tests and docs that build, check and
-release them. Anything else (videos, Discord and other community material) lives elsewhere.
+This repository holds the game and the launcher, plus the tools, tests and docs that build, check and release them.
+The website (playhorizon.dev) is built in a separate repository from this one's README, `docs/api/` and roadmap. Anything else (videos, Discord and other community material) lives elsewhere.
**Where to start: [playhorizon.dev/hub](https://playhorizon.dev/hub).** It shows what is being done now and next
([ROADMAP.md](ROADMAP.md) in the repository), the work board, good first tasks, and the forms to report a bug or
diff --git a/Cargo.lock b/Cargo.lock
index 0e93bba0e..809df3a5a 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1368,6 +1368,7 @@ dependencies = [
"horizon-core",
"horizon-dualsense",
"horizon-friends",
+ "horizon-hdr",
"horizon-mods",
"horizon-protocol",
"horizon-server-files",
@@ -1426,6 +1427,14 @@ dependencies = [
"spake2",
]
+[[package]]
+name = "horizon-hdr"
+version = "0.1.0"
+dependencies = [
+ "ash",
+ "wgpu",
+]
+
[[package]]
name = "horizon-mod-sdk"
version = "0.1.0"
diff --git a/Cargo.toml b/Cargo.toml
index e4628f962..59bfe5e33 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[workspace]
exclude = ["launcher", "crates/horizon-telemetry-server", "crates/horizon-mod-registry", "third_party/wgpu-hal"]
-members = ["crates/horizon-core", "crates/horizon-dualsense", "crates/horizon-threads", "crates/horizon-world", "crates/horizon-client", "crates/horizon-server-files", "crates/horizon-server", "crates/horizon-bots", "crates/horizon-assets", "crates/horizon-protocol", "crates/horizon-theme", "crates/horizon-prepare", "crates/horizon-telemetry", "crates/horizon-bench", "crates/horizon-friends", "crates/horizon-relay", "crates/horizon-mod-sdk", "crates/horizon-mods", "crates/horizon-mods/tests/guest", "crates/horizon-mods/tests/ui_guest", "crates/cargo-horizon-mod", "crates/horizon-port-pack", "crates/horizon-shaders", "crates/horizon-shader-api", "crates/horizon-release-sign", "crates/horizon-mod-sdk/examples/coords-hud", "crates/horizon-mod-sdk/examples/predator-missile", "crates/horizon-mod-sdk/examples/welcome", "mods/official/fps-overlay", "mods/official/keystrokes", "mods/official/minimap", "mods/official/zoom", "xtask"]
+members = ["crates/horizon-core", "crates/horizon-dualsense", "crates/horizon-threads", "crates/horizon-hdr", "crates/horizon-world", "crates/horizon-client", "crates/horizon-server-files", "crates/horizon-server", "crates/horizon-bots", "crates/horizon-assets", "crates/horizon-protocol", "crates/horizon-theme", "crates/horizon-prepare", "crates/horizon-telemetry", "crates/horizon-bench", "crates/horizon-friends", "crates/horizon-relay", "crates/horizon-mod-sdk", "crates/horizon-mods", "crates/horizon-mods/tests/guest", "crates/horizon-mods/tests/ui_guest", "crates/cargo-horizon-mod", "crates/horizon-port-pack", "crates/horizon-shaders", "crates/horizon-shader-api", "crates/horizon-release-sign", "crates/horizon-mod-sdk/examples/coords-hud", "crates/horizon-mod-sdk/examples/predator-missile", "crates/horizon-mod-sdk/examples/welcome", "mods/official/fps-overlay", "mods/official/keystrokes", "mods/official/minimap", "mods/official/zoom", "xtask"]
resolver = "2"
[workspace.package]
diff --git a/ROADMAP.md b/ROADMAP.md
index 4a2b90643..9b82f4fac 100644
--- a/ROADMAP.md
+++ b/ROADMAP.md
@@ -134,7 +134,7 @@ Better tools for mod makers: a test runner that needs no game window, templates
`cargo horizon-mod test` runs a mod's test scripts against a fake game snapshot ([#1816](https://github.com/ludovic111/horizon/issues/1816)) and, for server mods, scripted server events ([#1837](https://github.com/ludovic111/horizon/issues/1837)); the content template and the guides are merged ([#1859](https://github.com/ludovic111/horizon/issues/1859), [#1810](https://github.com/ludovic111/horizon/issues/1810), [docs/api/stability.md](docs/api/stability.md)). Left: templates for hud, server and machine mods, typed wrappers in the SDK, a frozen 0.1 compatibility mod that every runtime must load, a CI check that fails when a stable reference entry is removed without a new major version, and the SDK on crates.io once the API is stable.
-More: [website/docs/test-a-mod.md](website/docs/test-a-mod.md)
+More: [https://playhorizon.dev/docs/test-a-mod](https://playhorizon.dev/docs/test-a-mod)
@@ -310,7 +310,7 @@ Horizon should run well on small machines: integrated graphics, the Steam Deck,
Partly done: an opt-in 60 FPS cap with fewer workers on battery, Far Detail Reduced for integrated GPUs and animated textures on the GPU (both shipped). Left: measured targets and fixes per class of machine (memory use, worker counts, startup) on a Steam Deck, old Intel and Apple Silicon Macs and 8 GB computers, reported on the Benchmarks page.
-More: [docs/benchmark.md](docs/benchmark.md) · [website/docs/performance.md](website/docs/performance.md)
+More: [docs/benchmark.md](docs/benchmark.md) · [https://playhorizon.dev/docs/performance](https://playhorizon.dev/docs/performance)
@@ -600,7 +600,9 @@ You can port a mod to Horizon with your own AI agent on your own computer. Horiz
Technical
-A player runs their own agent locally with `horizon-ctl` and the MCP servers ([docs/agent-control.md](docs/agent-control.md)), `cargo horizon-mod`, `horizon-port-pack` and the parity harnesses as the check. Horizon writes the guide ([website/docs/agents.md](website/docs/agents.md), [docs/modpacks.md](docs/modpacks.md)) and runs no agents, accounts or keys for players. The No AI switch turns all of it off.
+A player runs their own agent locally with `horizon-ctl` and the MCP servers ([docs/agent-control.md](docs/agent-control.md)), `cargo horizon-mod`, `horizon-port-pack` and the parity harnesses as the check. Horizon writes the guide (playhorizon.dev/docs/agents, [docs/modpacks.md](docs/modpacks.md)) and runs no agents, accounts or keys for players. The No AI switch turns all of it off.
+
+More: [https://playhorizon.dev/docs/agents](https://playhorizon.dev/docs/agents)
@@ -936,7 +938,9 @@ Run Horizon's built-in benchmark and share the report: every new computer makes
Technical
-`horizon-launcher play --arg=--benchmark --arg=standard` writes a JSON report; `horizon-launcher data benchmark ` shows what would be sent and uploads it ([website/docs/performance.md](website/docs/performance.md)). Results from three installs with the same hardware appear on the Benchmarks page. Example: [#1711](https://github.com/ludovic111/horizon/issues/1711).
+`horizon-launcher play --arg=--benchmark --arg=standard` writes a JSON report; `horizon-launcher data benchmark ` shows what would be sent and uploads it (playhorizon.dev/docs/performance). Results from three installs with the same hardware appear on the Benchmarks page. Example: [#1711](https://github.com/ludovic111/horizon/issues/1711).
+
+More: [https://playhorizon.dev/docs/performance](https://playhorizon.dev/docs/performance)
diff --git a/crates/cargo-horizon-mod/src/check.rs b/crates/cargo-horizon-mod/src/check.rs
index f42674da8..33095a115 100644
--- a/crates/cargo-horizon-mod/src/check.rs
+++ b/crates/cargo-horizon-mod/src/check.rs
@@ -262,6 +262,9 @@ fn play(path: &Path, report: &mut Report) -> Result<(), String> {
format!("{}: {text}", if error { "error" } else { "feedback" })
}
Output::Command { line } => format!("command: /{line}"),
+ Output::QuietCommands { lines, .. } => {
+ format!("{} quiet command(s)", lines.len())
+ }
Output::Stopped { reason, .. } => return Err(format!("it stopped: {reason}")),
Output::OpenScreen { .. } => "opened a screen".to_string(),
Output::CloseScreen { .. } => "closed its screen".to_string(),
diff --git a/crates/horizon-assets/src/item_model.rs b/crates/horizon-assets/src/item_model.rs
index 5999805eb..d567bc6ac 100644
--- a/crates/horizon-assets/src/item_model.rs
+++ b/crates/horizon-assets/src/item_model.rs
@@ -1031,19 +1031,22 @@ pub struct ItemModels {
}
impl ItemModels {
- pub fn components(&self, stack: &StackView) -> Components {
- let mut out = self
- .prototypes
- .get(&stack.item)
- .cloned()
- .unwrap_or_default();
+ /// The stack's components: its item's defaults with the stack's patch on top. A stack
+ /// with no patch (most stacks a screen draws) borrows the defaults instead of copying them.
+ pub fn components(&self, stack: &StackView) -> std::borrow::Cow<'_, Components> {
+ static NONE: Components = BTreeMap::new();
+ let prototype = self.prototypes.get(&stack.item).unwrap_or(&NONE);
+ if stack.patch.is_empty() {
+ return std::borrow::Cow::Borrowed(prototype);
+ }
+ let mut out = prototype.clone();
for (key, value) in &stack.patch {
match value {
Some(v) => out.insert(key.clone(), v.clone()),
None => out.remove(key),
};
}
- out
+ std::borrow::Cow::Owned(out)
}
/// `ItemModelResolver.updateForTopItem`.
pub fn resolve(&self, stack: &StackView, ctx: &Context, env: &dyn ItemEnv) -> ResolvedItem {
diff --git a/crates/horizon-client/Cargo.toml b/crates/horizon-client/Cargo.toml
index d7c6d812b..f1011c534 100644
--- a/crates/horizon-client/Cargo.toml
+++ b/crates/horizon-client/Cargo.toml
@@ -12,6 +12,7 @@ horizon-assets = { path = "../horizon-assets" }
horizon-core = { path = "../horizon-core" }
# The server thread ahead of the workers (MinecraftServer.spin's Thread.setPriority).
horizon-threads = { path = "../horizon-threads" }
+horizon-hdr = { path = "../horizon-hdr" }
horizon-world = { path = "../horizon-world" }
horizon-protocol = { path = "../horizon-protocol" }
# server.properties, eula.txt and the user lists, shared with horizon-server.
diff --git a/crates/horizon-client/examples/probe/creative_mining_probe.rs b/crates/horizon-client/examples/probe/creative_mining_probe.rs
new file mode 100644
index 000000000..897e4bf81
--- /dev/null
+++ b/crates/horizon-client/examples/probe/creative_mining_probe.rs
@@ -0,0 +1,48 @@
+use horizon_client::{
+ Result,
+ item_data::StackData,
+ items::{ItemStack, Items},
+};
+use horizon_world::nbt::Tag;
+use serde_json::Value;
+use std::{
+ fs::File,
+ io::{BufRead, BufReader, BufWriter, Write},
+ path::Path,
+};
+
+pub fn main() -> Result<()> {
+ let args: Vec<_> = crate::args().collect();
+ let root = Path::new(env!("CARGO_MANIFEST_DIR")).join("../../.local/horizon-client/26.3");
+ let items = Items::catalog(&root)?;
+ let mut out = BufWriter::new(File::create(&args[2])?);
+ for line in BufReader::new(File::open(&args[1])?).lines() {
+ let row: Value = serde_json::from_str(&line?)?;
+ let mut stack = ItemStack::new(
+ row["item"].as_str().unwrap(),
+ row["count"].as_u64().unwrap() as u32,
+ );
+ match row["tool"].as_str().unwrap() {
+ "default" => {}
+ mode => {
+ let mut data = StackData::default();
+ let tool = if mode == "implicit" {
+ Tag::compound([] as [(&str, Tag); 0])
+ } else {
+ Tag::compound([(
+ "can_destroy_blocks_in_creative",
+ Tag::Byte(i8::from(mode == "allow")),
+ )])
+ };
+ data.set_other("minecraft:tool", Some(tool));
+ stack.extra = Some(Box::new(data));
+ }
+ }
+ writeln!(
+ out,
+ "{}",
+ items.can_destroy_block(Some(&stack), row["creative"].as_bool().unwrap())
+ )?;
+ }
+ Ok(())
+}
diff --git a/crates/horizon-client/examples/probe/main.rs b/crates/horizon-client/examples/probe/main.rs
index 1e1bc04d9..6b4c3d7dd 100644
--- a/crates/horizon-client/examples/probe/main.rs
+++ b/crates/horizon-client/examples/probe/main.rs
@@ -27,6 +27,7 @@ mod chat_screen_fixture;
mod cloud_fixture;
mod command_parse_fixture;
mod container_screen_probe;
+mod creative_mining_probe;
mod creative_search_fixture;
mod cushion_placement_probe;
mod emitter_particles_probe;
@@ -84,6 +85,7 @@ mod sound_engine_fixture;
mod sound_event_fixture;
mod spawn_rules_fixture;
mod sprint_probe;
+mod squid_client_probe;
mod subtitle_fixture;
mod tab_list_fixture;
mod team_rules_fixture;
@@ -108,6 +110,8 @@ probes! {
block_transform_fixture,
breaking_fixture,
camera_probe,
+ squid_client_probe,
+ creative_mining_probe,
cushion_placement_probe,
cauldron_fixture,
chat_screen_fixture,
diff --git a/crates/horizon-client/examples/probe/section_mesh_fixture.rs b/crates/horizon-client/examples/probe/section_mesh_fixture.rs
index e212a5268..89624b78c 100644
--- a/crates/horizon-client/examples/probe/section_mesh_fixture.rs
+++ b/crates/horizon-client/examples/probe/section_mesh_fixture.rs
@@ -7,7 +7,7 @@ use horizon_client::{
biome::{BiomeInfo, Biomes, GrassModifier},
blocks::BlockFacts,
chunk::{Chunk, Light, MIN_Y, index},
- mesher::{MeshTables, Mesher, OPAQUE_LAYER, TerrainVertex},
+ mesher::{EMISSION_BITS, MeshTables, Mesher, OPAQUE_LAYER, TerrainVertex},
models,
};
use horizon_core::biome::BiomeZoom;
@@ -161,7 +161,15 @@ fn scene(
.iter()
.map(|v| {
let ([x, y, z], [u, w]) = (v.pos, v.uv());
- json!([x, y, z, u, w, argb(v.color), light_coords(v.light)])
+ json!([
+ x,
+ y,
+ z,
+ u,
+ w,
+ argb(v.color | EMISSION_BITS),
+ light_coords(v.light)
+ ])
})
.collect();
quads.push(json!({"layer": layer, "sprite": sprite, "vertices": vertices}));
diff --git a/crates/horizon-client/examples/probe/squid_client_probe.rs b/crates/horizon-client/examples/probe/squid_client_probe.rs
new file mode 100644
index 000000000..f9f9c9b2c
--- /dev/null
+++ b/crates/horizon-client/examples/probe/squid_client_probe.rs
@@ -0,0 +1,51 @@
+use horizon_client::{
+ Result,
+ mobs::{Mob, MobTypes, aquatic},
+};
+use horizon_core::geometry::Vec3;
+use serde_json::Value;
+use std::{
+ fs::File,
+ io::{BufRead, BufReader, BufWriter, Write},
+ path::Path,
+ sync::Arc,
+};
+
+pub fn main() -> Result<()> {
+ let args: Vec<_> = crate::args().collect();
+ let root = Path::new(env!("CARGO_MANIFEST_DIR")).join("../../.local/horizon-client/26.3");
+ let types = MobTypes::load(&root)?;
+ let mut out = BufWriter::new(File::create(&args[2])?);
+ for line in BufReader::new(File::open(&args[1])?).lines() {
+ let row: Value = serde_json::from_str(&line?)?;
+ let kind = Arc::new(
+ types.types[&format!("minecraft:{}", row["species"].as_str().unwrap())].clone(),
+ );
+ let mut mob = Mob::new(1, kind, Vec3::ZERO, 0.0);
+ mob.fluids.in_water = row["water"].as_bool().unwrap();
+ mob.velocity = Vec3::new(
+ row["x"].as_f64().unwrap(),
+ row["y"].as_f64().unwrap(),
+ row["z"].as_f64().unwrap(),
+ );
+ mob.body_yaw = row["body"].as_f64().unwrap() as f32;
+ for (i, value) in row["v"].as_array().unwrap().iter().enumerate() {
+ mob.anim.v[i] = value.as_f64().unwrap() as f32;
+ }
+ if row["reset"].as_bool().unwrap() {
+ aquatic::squid_cycle_event(&mut mob);
+ }
+ let velocity = mob.velocity;
+ aquatic::squid_client_step(&mut mob);
+ assert_eq!(
+ velocity, mob.velocity,
+ "a remote animation must preserve packet velocity"
+ );
+ write!(out, "{:08x}", mob.body_yaw.to_bits())?;
+ for value in &mob.anim.v[..6] {
+ write!(out, " {:08x}", value.to_bits())?;
+ }
+ writeln!(out)?;
+ }
+ Ok(())
+}
diff --git a/crates/horizon-client/src/animate_tick.rs b/crates/horizon-client/src/animate_tick.rs
index 48e8f16f4..28b28544b 100644
--- a/crates/horizon-client/src/animate_tick.rs
+++ b/crates/horizon-client/src/animate_tick.rs
@@ -58,7 +58,10 @@ enum Animate {
BubbleColumn {
drag: bool,
},
- Fire,
+ /// `BaseFireBlock` (`SoulFireBlock.canBurn` is always true).
+ Fire {
+ soul: bool,
+ },
/// An active sculk sensor.
SculkSensor,
/// Potent sulfur that is not dry.
@@ -140,7 +143,8 @@ fn classify(name: &str, prop: &dyn Fn(&str) -> Option) -> Animate {
"bubble_column" => Animate::BubbleColumn {
drag: prop("drag").as_deref() == Some("true"),
},
- "fire" | "soul_fire" => Animate::Fire,
+ "fire" => Animate::Fire { soul: false },
+ "soul_fire" => Animate::Fire { soul: true },
"dried_ghast" => Animate::DriedGhast {
waterlogged: prop("waterlogged").as_deref() == Some("true"),
},
@@ -190,6 +194,8 @@ pub struct AnimateTables {
power_transmitter: Vec,
/// `#triggers_ambient_dried_ghast_block_sounds` (soul sand, soul soil).
dried_ghast_sounds: Vec,
+ /// `FireBlock.canBurn`: states with ignite odds above zero (none waterlogged).
+ burnable: Vec,
/// Biome id -> ambient particles and probabilities (`minecraft:visual/ambient_particles`).
ambient: Vec>,
}
@@ -220,6 +226,21 @@ impl AnimateTables {
})
.collect()
};
+ let behaviour: serde_json::Value =
+ serde_json::from_slice(&std::fs::read(root.join("block-behaviours.json"))?)?;
+ let ignite_odds = behaviour["fire"]["igniteOdds"].as_object();
+ let burnable = (0..registry.len() as u32)
+ .map(|id| {
+ // FireBlock.getIgniteOdds: a waterlogged state never burns.
+ registry.state(BlockStateId(id)).is_some_and(|s| {
+ s.properties.get("waterlogged").map(String::as_str) != Some("true")
+ && ignite_odds
+ .and_then(|m| m.get(s.name.as_str()))
+ .and_then(serde_json::Value::as_i64)
+ .is_some_and(|odds| odds > 0)
+ })
+ })
+ .collect();
let mut ambient = vec![Vec::new(); biomes.list.len()];
for (name, &id) in &biomes.index {
let path = root.join(format!(
@@ -248,6 +269,7 @@ impl AnimateTables {
power_provider: by_state("minecraft:enchantment_power_provider"),
power_transmitter: by_state("minecraft:enchantment_power_transmitter"),
dried_ghast_sounds: by_state("minecraft:triggers_ambient_dried_ghast_block_sounds"),
+ burnable,
ambient,
})
}
@@ -1103,7 +1125,7 @@ fn block_animate_tick(
}
}
}
- Animate::Fire => {
+ Animate::Fire { soul } => {
let r = engine.random();
if next_int(r, 24) == 0 {
let (volume, pitch) = (1.0 + r.next_float(), r.next_float() * 0.7 + 0.3);
@@ -1115,6 +1137,55 @@ fn block_animate_tick(
pitch,
);
}
+ // BaseFireBlock.animateTick: three large smoke above the fire, or
+ // two at each burnable neighbour's face when nothing burnable or
+ // sturdy supports it (SoulFireBlock.canBurn is always true).
+ let can_burn = |p: [i32; 3]| {
+ soul || tables
+ .burnable
+ .get(ctx.state(p).0 as usize)
+ .copied()
+ .unwrap_or(false)
+ };
+ let below = [pos[0], pos[1] - 1, pos[2]];
+ let sturdy = ctx.facts.get(ctx.state(below)).sturdy_full & (1 << 1) != 0;
+ if !can_burn(below) && !sturdy {
+ // (neighbour, coordinate axis, face at the axis' high end): the
+ // west, east, north, south and above faces, in vanilla order.
+ for (at, axis, high) in [
+ ([pos[0] - 1, pos[1], pos[2]], 0usize, false),
+ ([pos[0] + 1, pos[1], pos[2]], 0, true),
+ ([pos[0], pos[1], pos[2] - 1], 2, false),
+ ([pos[0], pos[1], pos[2] + 1], 2, true),
+ ([pos[0], pos[1] + 1, pos[2]], 1, true),
+ ] {
+ if !can_burn(at) {
+ continue;
+ }
+ for _ in 0..2 {
+ let r = engine.random();
+ let d = [r.next_double(), r.next_double(), r.next_double()];
+ let mut p = [fx + d[0], fy + d[1], fz + d[2]];
+ // The face coordinate hugs the edge: `* 0.1F` (float).
+ p[axis] = if high {
+ f64::from(pos[axis]) + 1.0 - d[axis] * f64::from(0.1f32)
+ } else {
+ f64::from(pos[axis]) + d[axis] * f64::from(0.1f32)
+ };
+ add(engine, T::LargeSmoke, p, [0.0; 3]);
+ }
+ }
+ } else {
+ for _ in 0..3 {
+ let r = engine.random();
+ let p = [
+ fx + r.next_double(),
+ fy + r.next_double() * 0.5 + 0.5,
+ fz + r.next_double(),
+ ];
+ add(engine, T::LargeSmoke, p, [0.0; 3]);
+ }
+ }
}
}
}
@@ -1157,13 +1228,19 @@ pub fn campfire_particles<'a>(
if r.next_float() < 0.11 {
let count = next_int(r, 2) + 2;
for _ in 0..count {
- make_campfire_smoke(engine, pos, signal);
+ make_campfire_smoke(engine, pos, signal, false);
}
}
}
}
-/// `CampfireBlock.makeParticles` (always visible, overriding the limiter).
-pub fn make_campfire_smoke(engine: &mut ParticleEngine, pos: [i32; 3], signal: bool) {
+/// `CampfireBlock.makeParticles` (always visible, overriding the limiter);
+/// `smoking` adds the plain smoke puff at the logs.
+pub fn make_campfire_smoke(
+ engine: &mut ParticleEngine,
+ pos: [i32; 3],
+ signal: bool,
+ smoking: bool,
+) {
let r = engine.random();
let sign = |r: &mut LegacyRandom| if r.next_boolean() { 1.0 } else { -1.0 };
let dx = r.next_double() / 3.0;
@@ -1177,6 +1254,17 @@ pub fn make_campfire_smoke(engine: &mut ParticleEngine, pos: [i32; 3], signal: b
T::CampfireCosySmoke
};
engine.create(&ParticleOptions::simple(ty), [x, y, z], [0.0, 0.07, 0.0]);
+ if smoking {
+ let r = engine.random();
+ let dx = r.next_double() / 4.0 * sign(r);
+ let dz = r.next_double() / 4.0 * sign(r);
+ let at = [
+ f64::from(pos[0]) + 0.5 + dx,
+ f64::from(pos[1]) + 0.4,
+ f64::from(pos[2]) + 0.5 + dz,
+ ];
+ engine.create(&ParticleOptions::simple(T::Smoke), at, [0.0, 0.005, 0.0]);
+ }
}
#[cfg(test)]
diff --git a/crates/horizon-client/src/biome.rs b/crates/horizon-client/src/biome.rs
index 63ad004d4..c8c15e44e 100644
--- a/crates/horizon-client/src/biome.rs
+++ b/crates/horizon-client/src/biome.rs
@@ -28,6 +28,9 @@ pub struct BiomeInfo {
pub spawn_costs: HashMap,
/// The `gameplay/creature_world_gen_spawn_probability` attribute.
pub creature_probability: f32,
+ /// The `gameplay/increased_fire_burnout` attribute (jungles, swamps, peaks,
+ /// mushroom fields).
+ pub increased_fire_burnout: bool,
pub name: String,
pub temperature: f32,
pub downfall: f32,
@@ -128,6 +131,9 @@ impl Biomes {
attributes["minecraft:gameplay/creature_world_gen_spawn_probability"]
.as_f64()
.unwrap_or(0.1) as f32,
+ increased_fire_burnout: attributes["minecraft:gameplay/increased_fire_burnout"]
+ .as_bool()
+ .unwrap_or(false),
temperature,
downfall,
precipitation: v["has_precipitation"].as_bool().unwrap_or(true),
diff --git a/crates/horizon-client/src/block_entity_nbt.rs b/crates/horizon-client/src/block_entity_nbt.rs
index 54d230eb4..a4c02ba3b 100644
--- a/crates/horizon-client/src/block_entity_nbt.rs
+++ b/crates/horizon-client/src/block_entity_nbt.rs
@@ -664,7 +664,9 @@ pub fn canonical(tag: &Tag) -> Option {
}
"minecraft:trial_spawner" => {
// `TrialSpawnerStateData.Packed` and `FullConfig`: every key is optional
- // and defaulted by vanilla; they are kept as loaded.
+ // and defaulted by vanilla; they are kept as loaded. No `spawn_data` is
+ // added: an absent one loads as Optional.empty and is not stored, and
+ // an empty entity would keep the spawner from ever picking a mob.
if let Tag::Compound(c) = tag {
for (k, v) in c {
let key = k.to_string_lossy();
@@ -676,12 +678,6 @@ pub fn canonical(tag: &Tag) -> Option {
}
}
}
- if !f.out.contains_key(&"spawn_data".into()) {
- f.put(
- "spawn_data",
- Tag::compound([("entity", Tag::Compound(Compound::new()))]),
- );
- }
}
"minecraft:vault" => {
// `VaultConfig.DEFAULT` (when the config is absent): the trial key and the
@@ -827,6 +823,21 @@ mod tests {
canonical(&snbt(s)).expect("known type")
}
+ #[test]
+ fn a_trial_spawner_without_spawn_data_saves_none() {
+ let fresh = canon(
+ r#"{id:"minecraft:trial_spawner",x:1,y:2,z:3,normal_config:"minecraft:trial_chamber/ranged/skeleton/normal"}"#,
+ );
+ assert_eq!(fresh.get("spawn_data"), None);
+ let picked = canon(
+ r#"{id:"minecraft:trial_spawner",x:1,y:2,z:3,spawn_data:{entity:{id:"minecraft:skeleton"}}}"#,
+ );
+ assert_eq!(
+ picked.get("spawn_data"),
+ Some(&snbt(r#"{entity:{id:"minecraft:skeleton"}}"#))
+ );
+ }
+
#[test]
fn every_type_has_defaults() {
for id in TYPES.iter().chain(NEWEST.iter()) {
diff --git a/crates/horizon-client/src/chunk.rs b/crates/horizon-client/src/chunk.rs
index c0bec476b..7cd375343 100644
--- a/crates/horizon-client/src/chunk.rs
+++ b/crates/horizon-client/src/chunk.rs
@@ -161,6 +161,9 @@ pub struct Chunk {
/// Structure starts reaching into this chunk (`structures.References`):
/// structure id and the start's chunk.
pub structure_refs: Vec<(Arc, (i32, i32))>,
+ /// The starts generation made in this chunk (`structures.starts`), saved
+ /// with the state their placement has reached by then.
+ pub structure_starts: Vec>,
}
impl Chunk {
pub fn empty(x: i32, z: i32) -> Self {
@@ -178,6 +181,7 @@ impl Chunk {
block_entities: Vec::new(),
block_names: Vec::new(),
structure_refs: Vec::new(),
+ structure_starts: Vec::new(),
postprocess: Vec::new(),
saved: None,
entities: Vec::new(),
diff --git a/crates/horizon-client/src/containers.rs b/crates/horizon-client/src/containers.rs
index 00e3f05b8..6aba0970e 100644
--- a/crates/horizon-client/src/containers.rs
+++ b/crates/horizon-client/src/containers.rs
@@ -94,9 +94,66 @@ pub enum BlockEntity {
Beehive(Box),
/// `CommandBlockEntity` of the three command blocks (`crate::command_block`).
CommandBlock(Box),
+ /// `CampfireBlockEntity` of campfires and soul campfires.
+ Campfire(Box),
/// `SkullBlockEntity` of every skull and head block.
Skull(Skull),
}
+/// `CampfireBlockEntity`: four cooking slots, each with its
+/// `cookingProgress` and `cookingTime` (the recipe's).
+#[derive(Clone, Debug, Default, PartialEq)]
+pub struct Campfire {
+ pub items: [Option; 4],
+ pub progress: [i32; 4],
+ pub total: [i32; 4],
+}
+impl Campfire {
+ /// `placeFood`'s slot: the first empty one, given the item's
+ /// `campfire_cooking` time; it takes one item of `held`.
+ pub fn place_food(&mut self, held: &mut ItemStack, cooking_time: i32) -> bool {
+ let Some(slot) = self.items.iter().position(Option::is_none) else {
+ return false;
+ };
+ self.total[slot] = cooking_time;
+ self.progress[slot] = 0;
+ self.items[slot] = Some(ItemStack {
+ count: 1,
+ ..held.clone()
+ });
+ held.count = held.count.saturating_sub(1);
+ true
+ }
+ /// `cookTick` (lit): each item's progress rises by one; the slots whose
+ /// progress reached their cooking time give up their item (the caller
+ /// drops its result).
+ pub fn cook_tick(&mut self) -> Vec<(usize, ItemStack)> {
+ let mut done = Vec::new();
+ for i in 0..4 {
+ if self.items[i].is_none() {
+ continue;
+ }
+ self.progress[i] += 1;
+ if self.progress[i] >= self.total[i]
+ && let Some(item) = self.items[i].take()
+ {
+ done.push((i, item));
+ }
+ }
+ done
+ }
+ /// `cooldownTick` (unlit): the progress falls by two, no lower than 0.
+ /// Whether anything changed (`setChanged`).
+ pub fn cooldown_tick(&mut self) -> bool {
+ let mut changed = false;
+ for i in 0..4 {
+ if self.progress[i] > 0 {
+ changed = true;
+ self.progress[i] = (self.progress[i] - 2).clamp(0, self.total[i]);
+ }
+ }
+ changed
+ }
+}
/// `SkullBlockEntity`: the player profile the head shows (kept as loaded:
/// a compound, or a string when it names a player only), the note block
/// sound and `custom_name`.
@@ -315,6 +372,9 @@ impl BlockEntity {
if name == "minecraft:brewing_stand" {
return Some(Self::Brewing(Box::new(crate::brewing::BrewingStand::new())));
}
+ if name == "minecraft:campfire" || name == "minecraft:soul_campfire" {
+ return Some(Self::Campfire(Box::default()));
+ }
let size = match name {
"minecraft:chest" | "minecraft:trapped_chest" | "minecraft:barrel" => 27,
n if n.ends_with("copper_chest") => 27,
@@ -352,6 +412,7 @@ impl BlockEntity {
Self::Beehive(_) => "minecraft:beehive",
Self::CommandBlock(_) => "minecraft:command_block",
Self::Skull(_) => "minecraft:skull",
+ Self::Campfire(_) => "minecraft:campfire",
}
}
pub fn contents(&self) -> Vec {
@@ -373,6 +434,7 @@ impl BlockEntity {
Self::Sculk(_) => Vec::new(),
Self::Banner(_) => Vec::new(),
Self::Crafter(c) => c.items.iter().flatten().cloned().collect(),
+ Self::Campfire(c) => c.items.iter().flatten().cloned().collect(),
}
}
pub fn slots(&self) -> &[Option] {
@@ -393,7 +455,9 @@ impl BlockEntity {
| Self::TrialSpawner(_)
| Self::Vault(_)
| Self::Beehive(_)
- | Self::CommandBlock(_) => &[],
+ | Self::CommandBlock(_)
+ // Not a Container (only Clearable): hoppers don't reach in.
+ | Self::Campfire(_) => &[],
}
}
pub fn slots_mut(&mut self) -> &mut [Option] {
@@ -414,7 +478,8 @@ impl BlockEntity {
| Self::TrialSpawner(_)
| Self::Vault(_)
| Self::Beehive(_)
- | Self::CommandBlock(_) => &mut [],
+ | Self::CommandBlock(_)
+ | Self::Campfire(_) => &mut [],
}
}
}
@@ -706,6 +771,41 @@ mod tests {
use super::*;
use horizon_core::random::{LegacyRandom, RandomSource};
+ #[test]
+ fn campfire_slots_take_food_cook_it_and_cool_down() {
+ let mut c = Campfire::default();
+ let mut beef = ItemStack::new("minecraft:beef", 2);
+ // placeFood: the first free slot, one item, its recipe's time.
+ assert!(c.place_food(&mut beef, 600));
+ assert_eq!(beef.count, 1);
+ assert_eq!(c.items[0].as_ref().map(|s| s.count), Some(1));
+ assert_eq!((c.progress[0], c.total[0]), (0, 600));
+ let mut fish = ItemStack::new("minecraft:cod", 1);
+ assert!(c.place_food(&mut fish, 3));
+ assert_eq!(c.items[1].as_ref().map(|s| &*s.item), Some("minecraft:cod"));
+ // cookTick: the cod is done on its third tick, the beef keeps cooking.
+ assert!(c.cook_tick().is_empty());
+ assert!(c.cook_tick().is_empty());
+ let done = c.cook_tick();
+ assert_eq!(done.len(), 1);
+ assert_eq!((done[0].0, &*done[0].1.item), (1, "minecraft:cod"));
+ assert!(c.items[1].is_none());
+ assert_eq!(c.progress[0], 3);
+ // cooldownTick: two a tick, never below zero.
+ assert!(c.cooldown_tick());
+ assert_eq!(c.progress[0], 1);
+ assert!(c.cooldown_tick());
+ assert_eq!(c.progress[0], 0);
+ // Full: four slots, no fifth.
+ for _ in 0..3 {
+ let mut more = ItemStack::new("minecraft:potato", 1);
+ assert!(c.place_food(&mut more, 600));
+ }
+ let mut fifth = ItemStack::new("minecraft:potato", 1);
+ assert!(!c.place_food(&mut fifth, 600));
+ assert_eq!(fifth.count, 1);
+ }
+
/// A whole amount pays itself without a draw; a fraction is a chance of one more.
#[test]
fn create_experience_rounds_the_fraction_by_chance() {
diff --git a/crates/horizon-client/src/creative.rs b/crates/horizon-client/src/creative.rs
index 033b4daec..1a227db65 100644
--- a/crates/horizon-client/src/creative.rs
+++ b/crates/horizon-client/src/creative.rs
@@ -3,7 +3,12 @@
//! (`creative-inventory.json`), a 9x5 scrolling grid and the search tab.
use crate::{Result, items::ItemStack, ui::EditBox};
use serde_json::Value;
-use std::{collections::HashMap, fs, path::Path};
+use std::{
+ collections::HashMap,
+ fs,
+ path::Path,
+ sync::{Arc, Mutex},
+};
#[derive(Clone, Debug)]
pub struct Tab {
@@ -40,6 +45,17 @@ pub struct Creative {
/// The search tab's stacks, in its display order.
search_items: Vec,
search_index: Vec,
+ /// ItemPickerMenu.items: what the grid shows, filled when the tab or the
+ /// search changes (selectTab, refreshSearchResults), not on every frame.
+ shown: Mutex