[PR #4231] [MERGED] Creative armour swap gives the worn piece back to the hand #5503

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/4231
Author: @DenisHumen
Created: 10/30/2026
Status: ✅ Merged
Merged: 10/31/2026
Merged by: @rdbtCVS

Base: main ← Head: fix/creative-armor-swap


📝 Commits (1)

  • dc3d702 Creative armour swap gives the worn piece back to the hand

📊 Changes

1 file changed (+104 additions, -21 deletions)

View changed files

📝 crates/horizon-client/src/game/armor_stands.rs (+104 -21)

📄 Description

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

What

In creative, right-clicking a piece of armour while you already wear one in that slot now swaps them: the worn piece comes back to your hand, as in vanilla. Before, the game kept the new piece in the hand and deleted the worn one. So the held item never changed and the hand never played its swap (lower and raise) animation. From a stack of more than one, the worn piece now goes to the inventory in creative too (before, it was lost).

The swap is now a pure function (swap_with_equipment_slot) that equip_from_hand applies. Survival behaviour is unchanged.

Why (vanilla 26.3)

Equippable.swapWithEquipmentSlot(ItemStack, Player) (javap on the 26.3 client jar):

  • count <= 1: the new hand is worn.isEmpty() ? stack : worn.copyAndClear(), and the slot gets isCreative() ? stack.copy() : stack.copyAndClear(). So creative gets the worn piece in hand too, and keeps the item only when nothing was worn. Returns SUCCESS.heldItemTransformedTo(hand), which ServerPlayerGameMode.useItem puts in the hand.
  • count > 1: consumeAndReturn(1, player) (takes nothing in creative), the worn piece goes to Inventory.add, else Player.drop. In creative Inventory.add empties a stack that doesn't fit, so nothing drops.
  • The hand animation is FirstPersonHandsAndItems.tick: the hand lowers when the held stack differs from the visible one.

Checked

  • 4 new unit tests in armor_stands.rs (swap_tests). creative_swap_gives_the_worn_piece_to_the_hand fails when I restore the old creative behaviour.
  • In game (horizon-ctl, scratch HORIZON_HOME, creative): equipped an iron chestplate with nothing worn, so the hand kept it. Then used a diamond chestplate: diamond worn, iron chestplate back in the hand. Survival: a non-swappable carved pumpkin doesn't swap (vanilla: swappable=false).
  • Own clippy run on horizon-client: clean. pr_ready reports two failures, both unrelated and Windows/toolchain only: clippy 1.96 lints in horizon-world/src/worldgen/aquifer/noise_based.rs, and title::tests::each_world_preset_writes_its_own_generator (NotADirectory on Windows, fails on main too). It ran --quick because tools/parity.py needs fcntl and doesn't run on Windows, so CI's parity job picks the harnesses.

Fixes #4150

pr_ready (tools/pr_ready.py --quick --base upstream/main on DenisPC, against upstream/main at fbd7288a1, 4 min 14 s)

Check Result
Scope ✅ 1 files, +104 −21
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 480 passed (1 min 8 s)
rustfmt ✅ (9 s)
clippy ❌ failed (19 s)
tests: horizon-client ❌ 726 passed, 1 failed (2 min 31 s)
doc tests ✅ 0 passed (2 s)
content root tests ➖ content root untouched
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ not run (--quick): 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)

🤖 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/4231 **Author:** [@DenisHumen](https://github.com/DenisHumen) **Created:** 10/30/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@rdbtCVS](https://github.com/rdbtCVS) **Base:** `main` ← **Head:** `fix/creative-armor-swap` --- ### 📝 Commits (1) - [`dc3d702`](https://github.com/horizon-rust/horizon/commit/dc3d702e01a418286ada72bedfba80292faad382) Creative armour swap gives the worn piece back to the hand ### 📊 Changes **1 file changed** (+104 additions, -21 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/armor_stands.rs` (+104 -21) </details> ### 📄 Description > 🤖 Opened by DenisHumen's AI agent (Claude Code, Opus 5.5), not by DenisHumen personally. ## What In creative, right-clicking a piece of armour while you already wear one in that slot now swaps them: the worn piece comes back to your hand, as in vanilla. Before, the game kept the new piece in the hand and deleted the worn one. So the held item never changed and the hand never played its swap (lower and raise) animation. From a stack of more than one, the worn piece now goes to the inventory in creative too (before, it was lost). The swap is now a pure function (`swap_with_equipment_slot`) that `equip_from_hand` applies. Survival behaviour is unchanged. ## Why (vanilla 26.3) `Equippable.swapWithEquipmentSlot(ItemStack, Player)` (javap on the 26.3 client jar): - count <= 1: the new hand is `worn.isEmpty() ? stack : worn.copyAndClear()`, and the slot gets `isCreative() ? stack.copy() : stack.copyAndClear()`. So creative gets the worn piece in hand too, and keeps the item only when nothing was worn. Returns `SUCCESS.heldItemTransformedTo(hand)`, which `ServerPlayerGameMode.useItem` puts in the hand. - count > 1: `consumeAndReturn(1, player)` (takes nothing in creative), the worn piece goes to `Inventory.add`, else `Player.drop`. In creative `Inventory.add` empties a stack that doesn't fit, so nothing drops. - The hand animation is `FirstPersonHandsAndItems.tick`: the hand lowers when the held stack differs from the visible one. ## Checked - 4 new unit tests in `armor_stands.rs` (`swap_tests`). `creative_swap_gives_the_worn_piece_to_the_hand` fails when I restore the old creative behaviour. - In game (`horizon-ctl`, scratch HORIZON_HOME, creative): equipped an iron chestplate with nothing worn, so the hand kept it. Then used a diamond chestplate: diamond worn, iron chestplate back in the hand. Survival: a non-swappable carved pumpkin doesn't swap (vanilla: `swappable=false`). - Own clippy run on horizon-client: clean. `pr_ready` reports two failures, both unrelated and Windows/toolchain only: clippy 1.96 lints in `horizon-world/src/worldgen/aquifer/noise_based.rs`, and `title::tests::each_world_preset_writes_its_own_generator` (NotADirectory on Windows, fails on main too). It ran `--quick` because `tools/parity.py` needs `fcntl` and doesn't run on Windows, so CI's parity job picks the harnesses. Fixes #4150 **pr_ready** (`tools/pr_ready.py --quick --base upstream/main` on DenisPC, against upstream/main at fbd7288a1, 4 min 14 s) | Check | Result | | --- | --- | | Scope | ✅ 1 files, +104 −21 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 480 passed (1 min 8 s) | | rustfmt | ✅ (9 s) | | clippy | ❌ failed (19 s) | | tests: horizon-client | ❌ 726 passed, 1 failed (2 min 31 s) | | doc tests | ✅ 0 passed (2 s) | | content root tests | ➖ content root untouched | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ not run (--quick): 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) | 🤖 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 05:13:02 +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#5503
No description provided.