[GH-ISSUE #6221] Sheep graze with mobGriefing off: EatBlockGoal changes the block without the game rule #2020

Closed
opened 2026-11-02 15:51:25 +07:00 by bsakaguchi · 4 comments
Owner

Originally created by @CocofireHD on GitHub (Nov 1, 2026).
Original GitHub issue: https://github.com/horizon-rust/horizon/issues/6221

Originally assigned to: @CocofireHD on GitHub.

Version: nightly 2026-11-01 · main 975c07d91 · What I did: gamerule mob_griefing false, four sheep on a 5×5 grass shelf, waited 150 s. What happened: a minecraft:grass_block became minecraft:dirt (dirt 0 → 1 at 41.6 s). What I expected: with the rule off, nothing changes — vanilla's EatBlockGoal only touches the world when MOB_GRIEFING is true.

Cause: crates/horizon-client/src/mobs/goals.rs (EatBlock::tick, ~line 2578) sends the block changes unconditionally:

if cx.w.has_tag("minecraft:edible_for_sheep", &here) {
    cx.events.push(MobEvent::BreakBlock { pos: [x, y, z], drop: false });
    super::ai::ate(m);
} else if cx.w.block_name(x, y - 1, z) == "minecraft:grass_block" {
    cx.events.push(MobEvent::SetBlockName {
        pos: [x, y - 1, z], name: "minecraft:dirt", effect: true, flags: UPDATE_CLIENTS,
    });
    super::ai::ate(m);
}

Vanilla net.minecraft.world.entity.ai.goal.EatBlockGoal.tick gates both halves on the rule and keeps mob.ate() outside the gate:

54:  Level.getServerLevel(level).getGameRules().get(MOB_GRIEFING).booleanValue()
76:  ifeq 89        // off: skip destroyBlock(pos, false)
79:  Level.destroyBlock(pos, false)
89:  Mob.ate()
...
121: getGameRules().get(MOB_GRIEFING).booleanValue()
143: ifeq 182      // off: skip the particles and the setBlock
146: Level.levelEvent(2001, below, Block.getId(GRASS_BLOCK.defaultBlockState()))
166: Level.setBlock(below, DIRT.defaultBlockState(), 2)
182: Mob.ate()

MobWorld already carries the flag (crates/horizon-client/src/mobs.rs:2342 pub mob_griefing: bool), filled from the game rule in game/creatures.rs, and every other griefing mob in the tree reads it (allays, the dragon, explosions, a mob's projectiles), so this goal is the outlier.

Expected fix: wrap the MobEvent pushes in cx.w.mob_griefing, keep ai::ate(m) where it is (Sheep.ate still shears the coat and ages a baby up with the rule off), and add the case to the mob AI harness so it cannot come back.

🤖 Filed by CocofireHD's AI agent (Hermes Agent, deepseek-v4.1-flash), not by CocofireHD personally.

Originally created by @CocofireHD on GitHub (Nov 1, 2026). Original GitHub issue: https://github.com/horizon-rust/horizon/issues/6221 Originally assigned to: @CocofireHD on GitHub. **Version:** nightly 2026-11-01 · main `975c07d91` · **What I did:** `gamerule mob_griefing false`, four sheep on a 5×5 grass shelf, waited 150 s. **What happened:** a `minecraft:grass_block` became `minecraft:dirt` (dirt 0 → 1 at 41.6 s). **What I expected:** with the rule off, nothing changes — vanilla's `EatBlockGoal` only touches the world when `MOB_GRIEFING` is true. **Cause:** `crates/horizon-client/src/mobs/goals.rs` (`EatBlock::tick`, ~line 2578) sends the block changes unconditionally: ```rust if cx.w.has_tag("minecraft:edible_for_sheep", &here) { cx.events.push(MobEvent::BreakBlock { pos: [x, y, z], drop: false }); super::ai::ate(m); } else if cx.w.block_name(x, y - 1, z) == "minecraft:grass_block" { cx.events.push(MobEvent::SetBlockName { pos: [x, y - 1, z], name: "minecraft:dirt", effect: true, flags: UPDATE_CLIENTS, }); super::ai::ate(m); } ``` Vanilla `net.minecraft.world.entity.ai.goal.EatBlockGoal.tick` gates both halves on the rule and keeps `mob.ate()` outside the gate: ``` 54: Level.getServerLevel(level).getGameRules().get(MOB_GRIEFING).booleanValue() 76: ifeq 89 // off: skip destroyBlock(pos, false) 79: Level.destroyBlock(pos, false) 89: Mob.ate() ... 121: getGameRules().get(MOB_GRIEFING).booleanValue() 143: ifeq 182 // off: skip the particles and the setBlock 146: Level.levelEvent(2001, below, Block.getId(GRASS_BLOCK.defaultBlockState())) 166: Level.setBlock(below, DIRT.defaultBlockState(), 2) 182: Mob.ate() ``` `MobWorld` already carries the flag (`crates/horizon-client/src/mobs.rs:2342 pub mob_griefing: bool`), filled from the game rule in `game/creatures.rs`, and every other griefing mob in the tree reads it (allays, the dragon, explosions, a mob's projectiles), so this goal is the outlier. **Expected fix:** wrap the `MobEvent` pushes in `cx.w.mob_griefing`, keep `ai::ate(m)` where it is (`Sheep.ate` still shears the coat and ages a baby up with the rule off), and add the case to the mob AI harness so it cannot come back. 🤖 Filed by CocofireHD's AI agent (Hermes Agent, deepseek-v4.1-flash), not by CocofireHD personally.
Author
Owner

@CocofireHD commented on GitHub (Nov 1, 2026):

🤖 Agent: /claim

<!-- gh-comment-id:6561891156 --> @CocofireHD commented on GitHub (Nov 1, 2026): 🤖 Agent: /claim
Author
Owner

@oxi-does-dev commented on GitHub (Nov 1, 2026):

/claim

<!-- gh-comment-id:6562098532 --> @oxi-does-dev commented on GitHub (Nov 1, 2026): /claim
Author
Owner

@github-actions[bot] commented on GitHub (Nov 1, 2026):

🤖 Claims: refused, @CocofireHD already claimed this issue: pick another, or ask them here. (asked by @oxi-does-dev)

<!-- gh-comment-id:6562100308 --> @github-actions[bot] commented on GitHub (Nov 1, 2026): 🤖 Claims: refused, @CocofireHD already claimed this issue: pick another, or ask them here. (asked by @oxi-does-dev)
Author
Owner

@CocofireHD commented on GitHub (Nov 1, 2026):

🤖 Agent: fixed in #6261 — both halves of EatBlockGoal.tick's gate (ifeq 89 on destroyBlock, ifeq 182 on levelEvent(2001) + setBlock(DIRT)), with Mob.ate left outside it, plus two goal-level tests (sheep on grass, sheep on short grass) that fail when the gate is inverted.

Rebased onto main at dea6dea98 and pushed. Note for whoever merges: #6256 (fix/gp-sheep-griefing) is the same gate in the same function, opened 80 s before #6261 and without a link to this issue — one of the two can go.

<!-- gh-comment-id:6562494052 --> @CocofireHD commented on GitHub (Nov 1, 2026): 🤖 Agent: fixed in #6261 — both halves of `EatBlockGoal.tick`'s gate (`ifeq 89` on `destroyBlock`, `ifeq 182` on `levelEvent(2001)` + `setBlock(DIRT)`), with `Mob.ate` left outside it, plus two goal-level tests (sheep on grass, sheep on short grass) that fail when the gate is inverted. Rebased onto `main` at `dea6dea98` and pushed. Note for whoever merges: #6256 (`fix/gp-sheep-griefing`) is the same gate in the same function, opened 80 s before #6261 and without a link to this issue — one of the two can go.
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#2020
No description provided.