[PR #6256] [CLOSED] Sheep leave the block alone while mobGriefing is off #6747

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/6256
Author: @MSedgeMC
Created: 11/1/2026
Status: ❌ Closed

Base: main ← Head: fix/gp-sheep-griefing


📝 Commits (1)

  • ef03897 Sheep leave the block alone while mobGriefing is off

📊 Changes

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

View changed files

📝 crates/horizon-client/src/mobs/goals.rs (+97 -13)

📄 Description

Vanilla's EatBlockGoal.tick makes both of its block changes only while MOB_GRIEFING is true, and calls Mob.ate outside that check.

 51: ifeq        99    // not edible for sheep: look at the block below
 58-73:           Level.getServerLevel(level).getGameRules().get(GameRules.MOB_GRIEFING).booleanValue()
 76: ifeq        89    // off: no block change
 79:              Level.destroyBlock(pos, false)
 89:              Mob.ate()                       // outside the gate
121-140:          the same MOB_GRIEFING read for the grass block below
143: ifeq        182   // off: no block event, no setBlock
146:              Level.levelEvent(2001, below, Block.getId(Blocks.GRASS_BLOCK.defaultBlockState()))
166:              Level.setBlock(below, Blocks.DIRT.defaultBlockState(), 2)
182:              Mob.ate()                       // outside the gate

Horizon's EatBlock::tick (crates/horizon-client/src/mobs/goals.rs, ~line 2586 on main) queued the BreakBlock and SetBlockName events unconditionally, so a sheep on a grass shelf with mobGriefing false still turned grass blocks into dirt.

The bite is now one small function, eat_block_bite, which takes the rule along with the two block facts and answers whether the mob ate and what the level changes: with the rule off the sheep still eats and the block stays.

Proven: cargo test -q -p horizon-client --lib eat_block -> 2 passed on the build VM. The tests cover both branches with the rule on and off (no event with it off, Mob.ate in both cases), the block event and UPDATE_CLIENTS flag the client needs, and the no-grass-to-eat case.

Not proven: the in-game check: gamerule mobGriefing false, four sheep on a grass shelf, watch that no grass block turns to dirt while they still graze (head down, coat regrows), then gamerule mobGriefing true and watch the blocks turn. The issue also asks for an eating case in the tick-for-tick mob comparison; that comparison was not run and no scenario was added to it.

Deliberate limit: the goal still starts and animates with the rule off, as vanilla's canUse does not read the rule either (the level check sits in tick).


🔄 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/6256 **Author:** [@MSedgeMC](https://github.com/MSedgeMC) **Created:** 11/1/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/gp-sheep-griefing` --- ### 📝 Commits (1) - [`ef03897`](https://github.com/horizon-rust/horizon/commit/ef03897b59aff382e941b9e06f67455db08f0873) Sheep leave the block alone while mobGriefing is off ### 📊 Changes **1 file changed** (+97 additions, -13 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/mobs/goals.rs` (+97 -13) </details> ### 📄 Description Vanilla's `EatBlockGoal.tick` makes both of its block changes only while `MOB_GRIEFING` is true, and calls `Mob.ate` outside that check. ``` 51: ifeq 99 // not edible for sheep: look at the block below 58-73: Level.getServerLevel(level).getGameRules().get(GameRules.MOB_GRIEFING).booleanValue() 76: ifeq 89 // off: no block change 79: Level.destroyBlock(pos, false) 89: Mob.ate() // outside the gate 121-140: the same MOB_GRIEFING read for the grass block below 143: ifeq 182 // off: no block event, no setBlock 146: Level.levelEvent(2001, below, Block.getId(Blocks.GRASS_BLOCK.defaultBlockState())) 166: Level.setBlock(below, Blocks.DIRT.defaultBlockState(), 2) 182: Mob.ate() // outside the gate ``` Horizon's `EatBlock::tick` (`crates/horizon-client/src/mobs/goals.rs`, ~line 2586 on main) queued the `BreakBlock` and `SetBlockName` events unconditionally, so a sheep on a grass shelf with `mobGriefing false` still turned grass blocks into dirt. The bite is now one small function, `eat_block_bite`, which takes the rule along with the two block facts and answers whether the mob ate and what the level changes: with the rule off the sheep still eats and the block stays. **Proven:** `cargo test -q -p horizon-client --lib eat_block` -> 2 passed on the build VM. The tests cover both branches with the rule on and off (no event with it off, `Mob.ate` in both cases), the block event and `UPDATE_CLIENTS` flag the client needs, and the no-grass-to-eat case. **Not proven:** the in-game check: `gamerule mobGriefing false`, four sheep on a grass shelf, watch that no grass block turns to dirt while they still graze (head down, coat regrows), then `gamerule mobGriefing true` and watch the blocks turn. The issue also asks for an eating case in the tick-for-tick mob comparison; that comparison was not run and no scenario was added to it. Deliberate limit: the goal still starts and animates with the rule off, as vanilla's `canUse` does not read the rule either (the level check sits in `tick`). --- <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:04 +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#6747
No description provided.