[PR #4660] [MERGED] Looting on the killer's weapon counts on a server's mobs #5763

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

📋 Pull Request Information

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

Base: main ← Head: fix/looting-mob-drops


📝 Commits (2)

  • daa6d3b Looting on the killer's weapon counts on a server's mobs
  • 8b23993 lan_e2e looting: register the check, count picked-up drops

📊 Changes

2 files changed (+87 additions, -11 deletions)

View changed files

📝 crates/horizon-client/src/game/creatures.rs (+44 -9)
📝 tools/lan_e2e.py (+43 -2)

📄 Description

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

What

Looting on your sword adds to what a mob drops again, in single player and on servers.

Fixes #4496

Why

LivingEntity.die builds the entity loot context with the killer as attacker. enchanted_count_increase then reads Looting from that entity's items (EnchantmentHelper.getEnchantmentLevel over the enchantment's slots).

Horizon handles a mob's death in the server's tick (tick_creature_entities → mob_died), after the swing that killed it. drop_death_loot built the killing player from self.held(). Outside as_guest that is the server Game's own player, and that player holds nothing. On the server thread every player is a guest, the window's own too. So the killer never had a weapon, and Looting never counted.

Fix

  • New killer_loot_entity(guest) in game/creatures.rs. It reads the guest who struck the last blow (last_hurt_by_player) through as_guest, else the server's own player.
  • It fills the main hand (the selected slot, not the hand that acts), the off hand and the four armour slots, as getEnchantmentLevel reads them.
  • drop_death_loot takes that entity for both attacker and LAST_DAMAGE_PLAYER.
  • lan_e2e gets a looting check: the guest kills a pig with Looting 255, and it must drop more than the 1–3 porkchops it drops without Looting. A low roll gets a second try.

Checked

  • python3 tools/lan_e2e.py --check looting on Ubuntu 26.04 (Xvfb, server-thread host, a guest with Looting 255):
    • upstream/main 70436b6f7: FAIL, porkchops [1, 3] (the pig's own 1–3, Looting ignored);
    • this branch: PASS, 103 porkchops.
  • The check first failed for its own reasons (not in the dispatch table; the guest picks the drops up before they were counted). Both are fixed in the second commit.
  • pr_ready:
    • title::tests::each_world_preset_writes_its_own_generator fails on Windows (os error 267), in a test this PR doesn't touch.
    • The clippy failure comes from lints new in clippy 1.96 (nonminimal_bool, manual_range_contains) in code this PR doesn't touch. cargo clippy -p horizon-client --no-deps reports nothing in creatures.rs.

pr_ready (tools/pr_ready.py --quick --base upstream/main on DenisPC, against upstream/main at 0a7ad01ed, 6 min 35 s)

Check Result
Scope ✅ 2 files, +78 −10
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 481 passed (1 min 4 s)
rustfmt ✅ (8 s)
clippy ❌ failed (19 s)
tests: horizon-client ❌ 798 passed, 1 failed (4 min 59 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/4660 **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/looting-mob-drops` --- ### 📝 Commits (2) - [`daa6d3b`](https://github.com/horizon-rust/horizon/commit/daa6d3b1cae6c4b9cace88be3b1f4b7c9082d8d7) Looting on the killer's weapon counts on a server's mobs - [`8b23993`](https://github.com/horizon-rust/horizon/commit/8b23993cfbde36e4d9090caaeb087973b015d435) lan_e2e looting: register the check, count picked-up drops ### 📊 Changes **2 files changed** (+87 additions, -11 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/creatures.rs` (+44 -9) 📝 `tools/lan_e2e.py` (+43 -2) </details> ### 📄 Description > 🤖 Opened by DenisHumen's AI agent (Claude Code, Opus 5.5), not by DenisHumen personally. ## What Looting on your sword adds to what a mob drops again, in single player and on servers. Fixes #4496 ## Why `LivingEntity.die` builds the entity loot context with the killer as `attacker`. `enchanted_count_increase` then reads Looting from that entity's items (`EnchantmentHelper.getEnchantmentLevel` over the enchantment's slots). Horizon handles a mob's death in the server's tick (`tick_creature_entities` → `mob_died`), after the swing that killed it. `drop_death_loot` built the killing player from `self.held()`. Outside `as_guest` that is the server `Game`'s own player, and that player holds nothing. On the server thread every player is a guest, the window's own too. So the killer never had a weapon, and Looting never counted. ## Fix - New `killer_loot_entity(guest)` in `game/creatures.rs`. It reads the guest who struck the last blow (`last_hurt_by_player`) through `as_guest`, else the server's own player. - It fills the main hand (the selected slot, not the hand that acts), the off hand and the four armour slots, as `getEnchantmentLevel` reads them. - `drop_death_loot` takes that entity for both `attacker` and `LAST_DAMAGE_PLAYER`. - `lan_e2e` gets a `looting` check: the guest kills a pig with Looting 255, and it must drop more than the 1–3 porkchops it drops without Looting. A low roll gets a second try. ## Checked - `python3 tools/lan_e2e.py --check looting` on Ubuntu 26.04 (Xvfb, server-thread host, a guest with Looting 255): - upstream/main 70436b6f7: **FAIL**, porkchops `[1, 3]` (the pig's own 1–3, Looting ignored); - this branch: **PASS**, `103` porkchops. - The check first failed for its own reasons (not in the dispatch table; the guest picks the drops up before they were counted). Both are fixed in the second commit. - pr_ready: - `title::tests::each_world_preset_writes_its_own_generator` fails on Windows (os error 267), in a test this PR doesn't touch. - The clippy failure comes from lints new in clippy 1.96 (`nonminimal_bool`, `manual_range_contains`) in code this PR doesn't touch. `cargo clippy -p horizon-client --no-deps` reports nothing in `creatures.rs`. **pr_ready** (`tools/pr_ready.py --quick --base upstream/main` on DenisPC, against upstream/main at 0a7ad01ed, 6 min 35 s) | Check | Result | | --- | --- | | Scope | ✅ 2 files, +78 −10 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 481 passed (1 min 4 s) | | rustfmt | ✅ (8 s) | | clippy | ❌ failed (19 s) | | tests: horizon-client | ❌ 798 passed, 1 failed (4 min 59 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:14:49 +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#5763
No description provided.