[PR #4198] [CLOSED] Villagers hold up the items they trade #5476

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/4198
Author: @kacpherek
Created: 10/30/2026
Status: ❌ Closed

Base: main ← Head: fix/split-villager-trades


📝 Commits (7)

  • 17c15df Draw the item a villager holds on its crossed arms
  • 1c455f0 Sync a mob's main hand enchantments to its viewers
  • f0b98ab Let a villager brain ask the level to roll its offers
  • 42b52dc Empty a villager's hand when it stops showing trades
  • 84f05bd Hold up the offer a villager sells for the item you hold
  • d8dd26a Cycle the items a villager holds up every 40 ticks
  • 04e2360 Keep a villager's shown item as the main hand stack

📊 Changes

8 files changed (+194 additions, -12 deletions)

View changed files

📝 crates/horizon-client/src/game/creatures.rs (+5 -0)
📝 crates/horizon-client/src/game/lan.rs (+11 -2)
📝 crates/horizon-client/src/game/mob_blocks.rs (+3 -3)
📝 crates/horizon-client/src/game/remote.rs (+12 -1)
📝 crates/horizon-client/src/mobs.rs (+6 -0)
📝 crates/horizon-client/src/mobs/finalize.rs (+1 -1)
📝 crates/horizon-client/src/mobs/render.rs (+16 -0)
📝 crates/horizon-client/src/mobs/villager_brain.rs (+140 -5)

📄 Description

What and why

  • Draw the item a villager holds on its crossed arms: A villager's held item was never drawn: its model has no hand arms, so ItemInHandLayer found no hand. Vanilla's VillagerRenderer adds CrossedArmsItemLayer, which puts the main hand's item on the arms and shows it in the GROUND display context (CrossedArmsItemLayer.java), as the witch already does.
  • Sync a mob's main hand enchantments to its viewers: the equipment packet carried the main hand's item without its enchantments, so an enchanted item a mob holds (the offer a villager shows) never glinted on a LAN viewer. Vanilla sends the whole stack (ClientboundSetEquipmentPacket); the server now sends the main hand's stack (count and components) with the held enchantments from the gear table, and the client keeps them there.
  • Let a villager brain ask the level to roll its offers: A brain tick holds only the mob, but AbstractVillager.getOffers makes the trades the first time they are asked for and that needs the level's trade data and random sequences. VillagerOffers has the game run ensure_offers for the villager, as the trading screen does.
  • Empty a villager's hand when it stops showing trades: ShowTradesToPlayer clears the main hand every tick it has nothing to show and again when it stops, restoring the default 0.085 drop chance (ShowTradesToPlayer.clearHeldItem).
  • Hold up the offer a villager sells for the item you hold: A villager looking at a player who holds a trade's cost now collects the offers in stock that take that item, holds up the first and keeps looking for 900 ticks instead of 40 (ShowTradesToPlayer.findItemsToDisplay, updateDisplayItems, displayFirstItem). The held stack keeps its count and enchantments and never drops (displayAsHeldItem). Offers not made yet are rolled by the level first.
  • Cycle the items a villager holds up every 40 ticks: With two or more matching offers the held item never changed. Vanilla counts 40 ticks, then holds up the next display item and wraps to the first (ShowTradesToPlayer.displayCyclingItems); start resets the counter and index.

The shown item is kept as the main hand stack through the held-stack API on main (set_main_hand_stack, take_main_hand), so its count and components stay with it.

Vanilla reference

CrossedArmsItemLayer.java, ClientboundSetEquipmentPacket, AbstractVillager.getOffers, ShowTradesToPlayer.findItemsToDisplay / updateDisplayItems / displayFirstItem / displayCyclingItems / clearHeldItem. Split out of #3945 as the review asked; the map banner and frame markers stay there.

Self-check

rustfmt on changed files; built by CI; not run in game. To check in game: stand in front of a villager with trades, hold an item it buys (an emerald, wheat), and see the item it sells held on its crossed arms; with two or more matching trades the item changes every two seconds; put the item away and the villager's hands empty.

fixes #3521


🔄 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/4198 **Author:** [@kacpherek](https://github.com/kacpherek) **Created:** 10/30/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/split-villager-trades` --- ### 📝 Commits (7) - [`17c15df`](https://github.com/horizon-rust/horizon/commit/17c15dfc05fa9c286369ac005d31554dd763bb1e) Draw the item a villager holds on its crossed arms - [`1c455f0`](https://github.com/horizon-rust/horizon/commit/1c455f0290af61c4f7f85a734b0d2917c169835e) Sync a mob's main hand enchantments to its viewers - [`f0b98ab`](https://github.com/horizon-rust/horizon/commit/f0b98ab38288d1749e2c8e602ec5955041ca865e) Let a villager brain ask the level to roll its offers - [`42b52dc`](https://github.com/horizon-rust/horizon/commit/42b52dccfd35055ef2ccecae9c9017e810347012) Empty a villager's hand when it stops showing trades - [`84f05bd`](https://github.com/horizon-rust/horizon/commit/84f05bddabe73339e5929f19925a3d0f5f13dfbf) Hold up the offer a villager sells for the item you hold - [`d8dd26a`](https://github.com/horizon-rust/horizon/commit/d8dd26a0e6cc0f1f1e5e6ade5601f7f7cb606117) Cycle the items a villager holds up every 40 ticks - [`04e2360`](https://github.com/horizon-rust/horizon/commit/04e23609c11661373552229ab715ee04e8a47c1b) Keep a villager's shown item as the main hand stack ### 📊 Changes **8 files changed** (+194 additions, -12 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/creatures.rs` (+5 -0) 📝 `crates/horizon-client/src/game/lan.rs` (+11 -2) 📝 `crates/horizon-client/src/game/mob_blocks.rs` (+3 -3) 📝 `crates/horizon-client/src/game/remote.rs` (+12 -1) 📝 `crates/horizon-client/src/mobs.rs` (+6 -0) 📝 `crates/horizon-client/src/mobs/finalize.rs` (+1 -1) 📝 `crates/horizon-client/src/mobs/render.rs` (+16 -0) 📝 `crates/horizon-client/src/mobs/villager_brain.rs` (+140 -5) </details> ### 📄 Description ## What and why - Draw the item a villager holds on its crossed arms: A villager's held item was never drawn: its model has no hand arms, so ItemInHandLayer found no hand. Vanilla's VillagerRenderer adds CrossedArmsItemLayer, which puts the main hand's item on the arms and shows it in the GROUND display context (CrossedArmsItemLayer.java), as the witch already does. - Sync a mob's main hand enchantments to its viewers: the equipment packet carried the main hand's item without its enchantments, so an enchanted item a mob holds (the offer a villager shows) never glinted on a LAN viewer. Vanilla sends the whole stack (ClientboundSetEquipmentPacket); the server now sends the main hand's stack (count and components) with the held enchantments from the gear table, and the client keeps them there. - Let a villager brain ask the level to roll its offers: A brain tick holds only the mob, but AbstractVillager.getOffers makes the trades the first time they are asked for and that needs the level's trade data and random sequences. VillagerOffers has the game run ensure_offers for the villager, as the trading screen does. - Empty a villager's hand when it stops showing trades: ShowTradesToPlayer clears the main hand every tick it has nothing to show and again when it stops, restoring the default 0.085 drop chance (ShowTradesToPlayer.clearHeldItem). - Hold up the offer a villager sells for the item you hold: A villager looking at a player who holds a trade's cost now collects the offers in stock that take that item, holds up the first and keeps looking for 900 ticks instead of 40 (ShowTradesToPlayer.findItemsToDisplay, updateDisplayItems, displayFirstItem). The held stack keeps its count and enchantments and never drops (displayAsHeldItem). Offers not made yet are rolled by the level first. - Cycle the items a villager holds up every 40 ticks: With two or more matching offers the held item never changed. Vanilla counts 40 ticks, then holds up the next display item and wraps to the first (ShowTradesToPlayer.displayCyclingItems); start resets the counter and index. The shown item is kept as the main hand stack through the held-stack API on main (`set_main_hand_stack`, `take_main_hand`), so its count and components stay with it. ## Vanilla reference CrossedArmsItemLayer.java, ClientboundSetEquipmentPacket, AbstractVillager.getOffers, ShowTradesToPlayer.findItemsToDisplay / updateDisplayItems / displayFirstItem / displayCyclingItems / clearHeldItem. Split out of #3945 as the review asked; the map banner and frame markers stay there. ## Self-check rustfmt on changed files; built by CI; not run in game. To check in game: stand in front of a villager with trades, hold an item it buys (an emerald, wheat), and see the item it sells held on its crossed arms; with two or more matching trades the item changes every two seconds; put the item away and the villager's hands empty. fixes #3521 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:12:51 +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#5476
No description provided.