[PR #6345] [CLOSED] Sheep graze: gate EatBlockGoal's block changes on mob_griefing #6814

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/6345
Author: @oxi-does-dev
Created: 11/1/2026
Status: ❌ Closed

Base: main ← Head: sheep-graze-gamerule


📝 Commits (1)

  • 7c6899e Sheep graze: gate EatBlockGoal's block changes on mob_griefing

📊 Changes

8 files changed (+140 additions, -29 deletions)

View changed files

📝 crates/horizon-client/examples/probe/mob_ai_probe.rs (+5 -1)
📝 crates/horizon-client/src/mobs/ai.rs (+19 -13)
📝 crates/horizon-client/src/mobs/enderman.rs (+1 -1)
📝 crates/horizon-client/src/mobs/goals.rs (+87 -10)
📝 crates/horizon-client/src/mobs/phantom.rs (+3 -2)
📝 crates/horizon-client/src/mobs/world.rs (+12 -2)
📝 mods/horizon/src/test/java/dev/horizonlab/parity/VanillaMobAiOracle.java (+6 -0)
📝 tools/test_mob_ai_parity.py (+7 -0)

📄 Description

Closes #6221.

Vanilla (EatBlockGoal.tick, 26.3)

net.minecraft.world.entity.ai.goal.EatBlockGoal.tick() gates both block
changes behind GameRules.MOB_GRIEFING — the eaten short grass
(destroyBlock) and the grass block below turned to dirt (setBlock) —
but calls this.mob.ate() either way (verified via tools/rea_vanilla.py).

Change

crates/horizon-client/src/mobs/goals.rs (EatBlock::tick): both
MobEvent::BreakBlock and MobEvent::SetBlockName now only fire when
cx.w.mob_griefing is on; super::ai::ate(m) stays unconditional, so the
eat animation and the wool regrow still happen with the rule off.

Tests

  • New unit test a_sheep_grazing_with_mob_griefing_off_leaves_the_block
    (goals.rs): grazing over a grass block with mob_griefing off emits no
    block events and leaves the block; with the rule on it turns to dirt.
    (Needed with_built_test_world/with_test_world_rules to take the game
    rule; the one external caller in phantom.rs passes true.)
  • New mob-AI parity scenario sheep_graze_no_griefing
    (tools/test_mob_ai_parity.py): a baby sheep grazing with
    mob_griefing=false — all 801 ticks match vanilla. The scenario
    option mob_griefing was added to both the Rust probe
    (mob_ai_probe.rs) and the Java oracle (VanillaMobAiOracle.java).

Note: a sheep_graze scenario with mob_griefing on (rule default) shows a
pre-existing eat-cadence divergence after the grass block is destroyed
(first divergence at tick 194; the goal/roll draws differ, so the sheep
re-grazes on different ticks). It is untouched by this fix — with the rule
on this patch is a no-op — and left to its own issue.

pr_ready (--quick)

Check Result
Scope ✅ 8 files, +140 −29
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 586 passed (1 min 0 s)
rustfmt ✅ (9 s)
clippy ✅ (2 min 0 s)
tests: horizon-client ❌ 1199 passed, 1 failed (7 min 15 s)
doc tests ✅ 0 passed (4 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 ➖ 73 affected, to run in CI (--quick): armor_stand_frost, arrow, arrow_wind_charge, auto_jump, blending, block_removal, boat_authority, boat_paddle_reset, boat_submerged, command_exec, composter, container_title and 61 more
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

The one failing test
(entities::armor_stand_motion_tests::a_tick_keeps_the_previous_position_for_interpolation,
"an airborne stand must fall") also fails on unmodified origin/main at
455b691 — a pre-existing flake, not touched by this patch.


🔄 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/6345 **Author:** [@oxi-does-dev](https://github.com/oxi-does-dev) **Created:** 11/1/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `sheep-graze-gamerule` --- ### 📝 Commits (1) - [`7c6899e`](https://github.com/horizon-rust/horizon/commit/7c6899e288cb1918fba24e14e1ec760f58b6513a) Sheep graze: gate EatBlockGoal's block changes on mob_griefing ### 📊 Changes **8 files changed** (+140 additions, -29 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/examples/probe/mob_ai_probe.rs` (+5 -1) 📝 `crates/horizon-client/src/mobs/ai.rs` (+19 -13) 📝 `crates/horizon-client/src/mobs/enderman.rs` (+1 -1) 📝 `crates/horizon-client/src/mobs/goals.rs` (+87 -10) 📝 `crates/horizon-client/src/mobs/phantom.rs` (+3 -2) 📝 `crates/horizon-client/src/mobs/world.rs` (+12 -2) 📝 `mods/horizon/src/test/java/dev/horizonlab/parity/VanillaMobAiOracle.java` (+6 -0) 📝 `tools/test_mob_ai_parity.py` (+7 -0) </details> ### 📄 Description Closes #6221. ## Vanilla (`EatBlockGoal.tick`, 26.3) `net.minecraft.world.entity.ai.goal.EatBlockGoal.tick()` gates both block changes behind `GameRules.MOB_GRIEFING` — the eaten short grass (`destroyBlock`) and the grass block below turned to dirt (`setBlock`) — but calls `this.mob.ate()` either way (verified via `tools/rea_vanilla.py`). ## Change `crates/horizon-client/src/mobs/goals.rs` (`EatBlock::tick`): both `MobEvent::BreakBlock` and `MobEvent::SetBlockName` now only fire when `cx.w.mob_griefing` is on; `super::ai::ate(m)` stays unconditional, so the eat animation and the wool regrow still happen with the rule off. ## Tests - New unit test `a_sheep_grazing_with_mob_griefing_off_leaves_the_block` (`goals.rs`): grazing over a grass block with `mob_griefing` off emits no block events and leaves the block; with the rule on it turns to dirt. (Needed `with_built_test_world`/`with_test_world_rules` to take the game rule; the one external caller in `phantom.rs` passes `true`.) - New mob-AI parity scenario `sheep_graze_no_griefing` (`tools/test_mob_ai_parity.py`): a baby sheep grazing with `mob_griefing=false` — **all 801 ticks match vanilla**. The scenario option `mob_griefing` was added to both the Rust probe (`mob_ai_probe.rs`) and the Java oracle (`VanillaMobAiOracle.java`). Note: a `sheep_graze` scenario with `mob_griefing` on (rule default) shows a pre-existing eat-cadence divergence after the grass block is destroyed (first divergence at tick 194; the goal/roll draws differ, so the sheep re-grazes on different ticks). It is untouched by this fix — with the rule on this patch is a no-op — and left to its own issue. ## pr_ready (`--quick`) | Check | Result | | --- | --- | | Scope | ✅ 8 files, +140 −29 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 586 passed (1 min 0 s) | | rustfmt | ✅ (9 s) | | clippy | ✅ (2 min 0 s) | | tests: horizon-client | ❌ 1199 passed, 1 failed (7 min 15 s) | | doc tests | ✅ 0 passed (4 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 | ➖ 73 affected, to run in CI (--quick): armor_stand_frost, arrow, arrow_wind_charge, auto_jump, blending, block_removal, boat_authority, boat_paddle_reset, boat_submerged, command_exec, composter, container_title and 61 more | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | The one failing test (`entities::armor_stand_motion_tests::a_tick_keeps_the_previous_position_for_interpolation`, "an airborne stand must fall") also fails on unmodified `origin/main` at 455b691 — a pre-existing flake, not touched by this patch. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:27:25 +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#6814
No description provided.