[PR #2015] [MERGED] Campfires cook food #3939

Closed
opened 2026-11-03 04:13:24 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/2015
Author: @vlesmentie
Created: 10/26/2026
Status: ✅ Merged
Merged: 10/26/2026
Merged by: @ludovic111

Base: main ← Head: feat/campfire-cooking


📝 Commits (5)

  • 5febf0d Campfires cook food
  • 3d401e5 Merge origin/main into feat/campfire-cooking
  • fdba6b4 Campfire timers mark their chunk for saving
  • a83d6f3 Campfire: a full campfire's use does not swing the arm
  • ba797f6 save_roundtrip: the lit campfire keeps cooking while Horizon runs

📊 Changes

8 files changed (+368 additions, -7 deletions)

View changed files

📝 crates/horizon-client/src/containers.rs (+102 -2)
📝 crates/horizon-client/src/game.rs (+15 -2)
📝 crates/horizon-client/src/game/block_entity_ticks.rs (+5 -1)
➕ crates/horizon-client/src/game/campfire.rs (+190 -0)
📝 crates/horizon-client/src/game/spill.rs (+6 -2)
📝 crates/horizon-client/src/lan/chunks.rs (+5 -0)
📝 crates/horizon-client/src/save.rs (+43 -0)
📝 tools/test_save_roundtrip_parity.py (+2 -0)

📄 Description

🤖 Opened by vlesmentie's AI agent (Claude Code, Claude Opus 5.5), not by vlesmentie themselves.

What and why

Fixes #1988.

Right-clicking a campfire with raw food did nothing: Horizon had no CampfireBlockEntity. This adds it, end to end
(352 lines, 7 files).

  • Block entity (containers.rs): BlockEntity::Campfire with four slots, each with its cookingProgress and
    cookingTime; place_food, cook_tick and cooldown_tick hold the slot logic. Campfires and soul campfires
    share the minecraft:campfire block entity type. It is not a Container (only Clearable), so slots() stays
    empty and hoppers don't reach in.
  • Saving (save.rs): Items, CookingTimes, CookingTotalTimes, as saveAdditional / loadAdditional
    (missing arrays load as zeros).
  • Placing (game/campfire.rs, from use_tool right after the cauldron, so before the item's own use such as
    eating): a held campfire_cooking input goes into the first free slot with its recipe's cookingtime; the use is
    consumed whether or not there was room; the item is used up outside creative; interact_with_campfire is
    awarded; block_change (the player, the state); the clients get the new items. A client of a server leaves it to
    the server.
  • Ticking (game/block_entity_ticks.rs): every campfire state ticks (lit: cookTick, unlit: cooldownTick).
    A finished item's result (the recipe's, or the item itself when no recipe takes it any more) drops at the block
    through Containers.dropItemStack (horizon_world::level::removal::drop_item_stack), the slot empties, the
    clients are told and a block_change goes out. Unlit, progress falls by 2 to no lower than 0.
  • Breaking (game/spill.rs): PreRemove::Campfire now drops the live block entity's items (it dropped four
    empty slots before); the saved-chunk path already read Items.
  • Clients (lan/chunks.rs): the update tag is Items alone (getUpdateTag), and remote_block_entity_data
    already loads it through decode_block_entity.
  • Drawing (campfire_geometry, beside vault_geometry): CampfireRenderer's pose per slot.

Vanilla reference

  • CampfireBlock.useItemOn: a RecipePropertySet.CAMPFIRE_INPUT item → on a ServerLevel, placeFood and
    awardStat(INTERACT_WITH_CAMPFIRE) → SUCCESS_SERVER, else CONSUME
  • CampfireBlockEntity.placeFood: first empty slot, cookingTime[i] = recipe.cookingTime(), cookingProgress[i] = 0,
    item.consumeAndReturn(1, entity), BLOCK_CHANGE with Context.of(entity, state), markUpdated
  • CampfireBlockEntity.cookTick / cooldownTick (Mth.clamp(progress - 2, 0, cookingTime)), getTicker (lit:
    cook on the server, particles on the client; unlit: cooldown)
  • saveAdditional / loadAdditional / getUpdateTag, preRemoveSideEffects (Containers.dropContents)
  • CampfireRenderer.submit: translate (0.5, 0.44921875, 0.5), YP by -Direction.from2DDataValue((i + facing) % 4) .toYRot(), XP 90°, translate (-0.3125, -0.3125, 0), scale 0.375, ItemDisplayContext.FIXED, seed
    (int) pos.asLong() + i

Checked against the 26.3 client jar's bytecode (javap).

Tests

  • containers::tests::campfire_slots_take_food_cook_it_and_cool_down: placing (first free slot, one item, the
    recipe's time, no fifth item), cooking (an item done on its time, the others keep going) and cooling (2 a tick,
    not below 0).
  • save::tests::campfire_block_entity_round_trips: save and load, both campfires as minecraft:campfire, and the
    update tag carrying Items only.
  • In game, a release build of this branch through horizon-ctl with fresh data dirs (single player on its
    server thread, survival): /give 3 raw beef, /setblock a campfire, one interact → the hand holds 2 on the
    client and the server, the campfire's data reads Items: [beef], CookingTimes: [14, 0, 0, 0],
    CookingTotalTimes: [600, 0, 0, 0]; 31 seconds later the campfire is empty and a cooked beef was dropped (and
    picked up). A screenshot shows the raw beef lying on the campfire's corners, on a soul campfire too.

Self-check

pr_ready (tools/pr_ready.py on debian, against origin/main at 1880e12f2, 3 min 16 s)

Check Result
Scope ✅ 7 files, +352 −7
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ➖ no Python change
rustfmt ✅ (15 s)
clippy ✅ (22 s)
tests: horizon-client ✅ 1273 passed (2 min 34 s)
doc tests ✅ 0 passed (5 s)
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ not run (no vanilla data here): CI's parity job picks the affected harnesses
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

The same suite run in parallel on this machine sometimes dies with SIGSEGV in a GPU test; it does so on main
without this change too (one run in two here), and single-threaded all 1130 library tests pass.

🤖 Generated with 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/2015 **Author:** [@vlesmentie](https://github.com/vlesmentie) **Created:** 10/26/2026 **Status:** ✅ Merged **Merged:** 10/26/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `feat/campfire-cooking` --- ### 📝 Commits (5) - [`5febf0d`](https://github.com/horizon-rust/horizon/commit/5febf0d95753a13eaf9ab420f265e08521a5e132) Campfires cook food - [`3d401e5`](https://github.com/horizon-rust/horizon/commit/3d401e55f41cb961de745d675c9687b2f6e1d5af) Merge origin/main into feat/campfire-cooking - [`fdba6b4`](https://github.com/horizon-rust/horizon/commit/fdba6b41530f3b0258acc5bd7dc778bb0b39f060) Campfire timers mark their chunk for saving - [`a83d6f3`](https://github.com/horizon-rust/horizon/commit/a83d6f33bea6bd2fc00197580b148edd3eaad3c8) Campfire: a full campfire's use does not swing the arm - [`ba797f6`](https://github.com/horizon-rust/horizon/commit/ba797f60a1063472bdf4d5f8dfc23e49c1b60a6b) save_roundtrip: the lit campfire keeps cooking while Horizon runs ### 📊 Changes **8 files changed** (+368 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/containers.rs` (+102 -2) 📝 `crates/horizon-client/src/game.rs` (+15 -2) 📝 `crates/horizon-client/src/game/block_entity_ticks.rs` (+5 -1) ➕ `crates/horizon-client/src/game/campfire.rs` (+190 -0) 📝 `crates/horizon-client/src/game/spill.rs` (+6 -2) 📝 `crates/horizon-client/src/lan/chunks.rs` (+5 -0) 📝 `crates/horizon-client/src/save.rs` (+43 -0) 📝 `tools/test_save_roundtrip_parity.py` (+2 -0) </details> ### 📄 Description > 🤖 Opened by vlesmentie's AI agent (Claude Code, Claude Opus 5.5), not by vlesmentie themselves. ## What and why Fixes #1988. Right-clicking a campfire with raw food did nothing: Horizon had no `CampfireBlockEntity`. This adds it, end to end (352 lines, 7 files). - **Block entity** (`containers.rs`): `BlockEntity::Campfire` with four slots, each with its `cookingProgress` and `cookingTime`; `place_food`, `cook_tick` and `cooldown_tick` hold the slot logic. Campfires and soul campfires share the `minecraft:campfire` block entity type. It is not a `Container` (only `Clearable`), so `slots()` stays empty and hoppers don't reach in. - **Saving** (`save.rs`): `Items`, `CookingTimes`, `CookingTotalTimes`, as `saveAdditional` / `loadAdditional` (missing arrays load as zeros). - **Placing** (`game/campfire.rs`, from `use_tool` right after the cauldron, so before the item's own use such as eating): a held `campfire_cooking` input goes into the first free slot with its recipe's `cookingtime`; the use is consumed whether or not there was room; the item is used up outside creative; `interact_with_campfire` is awarded; `block_change` (the player, the state); the clients get the new items. A client of a server leaves it to the server. - **Ticking** (`game/block_entity_ticks.rs`): every campfire state ticks (lit: `cookTick`, unlit: `cooldownTick`). A finished item's result (the recipe's, or the item itself when no recipe takes it any more) drops at the block through `Containers.dropItemStack` (`horizon_world::level::removal::drop_item_stack`), the slot empties, the clients are told and a `block_change` goes out. Unlit, progress falls by 2 to no lower than 0. - **Breaking** (`game/spill.rs`): `PreRemove::Campfire` now drops the live block entity's items (it dropped four empty slots before); the saved-chunk path already read `Items`. - **Clients** (`lan/chunks.rs`): the update tag is `Items` alone (`getUpdateTag`), and `remote_block_entity_data` already loads it through `decode_block_entity`. - **Drawing** (`campfire_geometry`, beside `vault_geometry`): `CampfireRenderer`'s pose per slot. ## Vanilla reference - `CampfireBlock.useItemOn`: a `RecipePropertySet.CAMPFIRE_INPUT` item → on a `ServerLevel`, `placeFood` and `awardStat(INTERACT_WITH_CAMPFIRE)` → `SUCCESS_SERVER`, else `CONSUME` - `CampfireBlockEntity.placeFood`: first empty slot, `cookingTime[i] = recipe.cookingTime()`, `cookingProgress[i] = 0`, `item.consumeAndReturn(1, entity)`, `BLOCK_CHANGE` with `Context.of(entity, state)`, `markUpdated` - `CampfireBlockEntity.cookTick` / `cooldownTick` (`Mth.clamp(progress - 2, 0, cookingTime)`), `getTicker` (lit: cook on the server, particles on the client; unlit: cooldown) - `saveAdditional` / `loadAdditional` / `getUpdateTag`, `preRemoveSideEffects` (`Containers.dropContents`) - `CampfireRenderer.submit`: translate (0.5, 0.44921875, 0.5), `YP` by `-Direction.from2DDataValue((i + facing) % 4) .toYRot()`, `XP` 90°, translate (-0.3125, -0.3125, 0), scale 0.375, `ItemDisplayContext.FIXED`, seed `(int) pos.asLong() + i` Checked against the 26.3 client jar's bytecode (`javap`). ## Tests - `containers::tests::campfire_slots_take_food_cook_it_and_cool_down`: placing (first free slot, one item, the recipe's time, no fifth item), cooking (an item done on its time, the others keep going) and cooling (2 a tick, not below 0). - `save::tests::campfire_block_entity_round_trips`: save and load, both campfires as `minecraft:campfire`, and the update tag carrying `Items` only. - **In game**, a release build of this branch through `horizon-ctl` with fresh data dirs (single player on its server thread, survival): `/give` 3 raw beef, `/setblock` a campfire, one `interact` → the hand holds 2 on the client and the server, the campfire's data reads `Items: [beef]`, `CookingTimes: [14, 0, 0, 0]`, `CookingTotalTimes: [600, 0, 0, 0]`; 31 seconds later the campfire is empty and a cooked beef was dropped (and picked up). A screenshot shows the raw beef lying on the campfire's corners, on a soul campfire too. ## Self-check **pr_ready** (`tools/pr_ready.py` on debian, against origin/main at 1880e12f2, 3 min 16 s) | Check | Result | | --- | --- | | Scope | ✅ 7 files, +352 −7 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ➖ no Python change | | rustfmt | ✅ (15 s) | | clippy | ✅ (22 s) | | tests: horizon-client | ✅ 1273 passed (2 min 34 s) | | doc tests | ✅ 0 passed (5 s) | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ not run (no vanilla data here): CI's parity job picks the affected harnesses | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | The same suite run in parallel on this machine sometimes dies with SIGSEGV in a GPU test; it does so on `main` without this change too (one run in two here), and single-threaded all 1130 library tests pass. 🤖 Generated with [Claude Code](https://claude.com/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 04:13:24 +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#3939
No description provided.