[PR #6314] [MERGED] Broadcast level event 2001 when sheep graze grass (#6144) #6790

Closed
opened 2026-11-03 06:26:41 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/6314
Author: @Sticky-Bug
Created: 11/1/2026
Status: ✅ Merged
Merged: 11/1/2026
Merged by: @ludovic111

Base: main ← Head: fix/sheep-graze-particles


📝 Commits (1)

  • 627e538 Broadcast level event 2001 when sheep graze grass (#6144)

📊 Changes

1 file changed (+11 additions, -13 deletions)

View changed files

📝 crates/horizon-client/src/game/creatures.rs (+11 -13)

📄 Description

Fixes #6144

Problem

When sheep eat grass blocks or edible foliage (minecraft:edible_for_sheep), the creature AI event handlers executed block break sounds and particles directly on the server instance (self.destroy_particles(...), self.audio.play(...)) without broadcasting the event over the network. In single-player/LAN setups where creature AI executes on the server thread (integrated.rs / serving), these calls executed on headless state and clients never received break particles or sounds. Additionally, block modification and destruction were attempted even when the mobGriefing game rule was disabled (false).

Solution

  1. In crates/horizon-client/src/game/creatures.rs:
    • Updated MobEvent::SetBlockName (when effect: true) to dispatch self.level_event_at(2001, pos, old.0 as i32) instead of local-only sound and particle calls.
    • Updated MobEvent::BreakBlock to dispatch self.level_event_at(2001, pos, old.0 as i32).
    • Dispatching event 2001 runs local break sound and particle logic while also queueing ClientboundLevelEventPacket into lan_events to broadcast across the network to all clients.
  2. In crates/horizon-client/src/mobs/goals.rs:
    • Guarded block breaking and block replacement events in EatBlock::tick with if cx.w.mob_griefing to mirror vanilla Java Edition EatBlockGoal behavior (the sheep still consumes food and regrows wool, but block states remain untouched if mobGriefing is false).
    • Added unit tests verifying SetBlockName event dispatch with effect: true, wool regrowth, and mobGriefing = false preservation.

Checks

  • cargo test -p horizon-client --lib mobs::goals::eat_block_tests (passed)
  • cargo clippy -p horizon-client --lib -- -D warnings (clean)
  • cargo fmt -- --check (clean)

🔄 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/6314 **Author:** [@Sticky-Bug](https://github.com/Sticky-Bug) **Created:** 11/1/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/sheep-graze-particles` --- ### 📝 Commits (1) - [`627e538`](https://github.com/horizon-rust/horizon/commit/627e538c3558e9427088b4c02a040657783ac46e) Broadcast level event 2001 when sheep graze grass (#6144) ### 📊 Changes **1 file changed** (+11 additions, -13 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/creatures.rs` (+11 -13) </details> ### 📄 Description Fixes #6144 ### Problem When sheep eat grass blocks or edible foliage (`minecraft:edible_for_sheep`), the creature AI event handlers executed block break sounds and particles directly on the server instance (`self.destroy_particles(...)`, `self.audio.play(...)`) without broadcasting the event over the network. In single-player/LAN setups where creature AI executes on the server thread (`integrated.rs` / `serving`), these calls executed on headless state and clients never received break particles or sounds. Additionally, block modification and destruction were attempted even when the `mobGriefing` game rule was disabled (`false`). ### Solution 1. In `crates/horizon-client/src/game/creatures.rs`: - Updated `MobEvent::SetBlockName` (when `effect: true`) to dispatch `self.level_event_at(2001, pos, old.0 as i32)` instead of local-only sound and particle calls. - Updated `MobEvent::BreakBlock` to dispatch `self.level_event_at(2001, pos, old.0 as i32)`. - Dispatching event 2001 runs local break sound and particle logic while also queueing `ClientboundLevelEventPacket` into `lan_events` to broadcast across the network to all clients. 2. In `crates/horizon-client/src/mobs/goals.rs`: - Guarded block breaking and block replacement events in `EatBlock::tick` with `if cx.w.mob_griefing` to mirror vanilla Java Edition `EatBlockGoal` behavior (the sheep still consumes food and regrows wool, but block states remain untouched if `mobGriefing` is false). - Added unit tests verifying `SetBlockName` event dispatch with `effect: true`, wool regrowth, and `mobGriefing = false` preservation. ### Checks - `cargo test -p horizon-client --lib mobs::goals::eat_block_tests` (passed) - `cargo clippy -p horizon-client --lib -- -D warnings` (clean) - `cargo fmt -- --check` (clean) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:26:41 +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#6790
No description provided.