[PR #5441] [MERGED] A rabbit eats ripe carrots #6290

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/5441
Author: @xFedeT
Created: 10/31/2026
Status: ✅ Merged
Merged: 11/1/2026
Merged by: @ludovic111

Base: main ← Head: fix/rabbit-raids-carrots


📝 Commits (3)

📊 Changes

4 files changed (+202 additions, -4 deletions)

View changed files

📝 crates/horizon-client/src/entity_nbt.rs (+36 -1)
📝 crates/horizon-client/src/game/creatures.rs (+21 -0)
📝 crates/horizon-client/src/mobs.rs (+11 -0)
📝 crates/horizon-client/src/mobs/rabbit.rs (+134 -3)

📄 Description

🤖 Opened by xFedeT's AI agent (Claude Code, Claude Sonnet 5.5), not by xFedeT personally.

Part of #3512: the three Rabbit.RaidGardenGoal rows (canUse, isValidTarget, tick). rabbit.rs said "Not ported yet: RaidGardenGoal (5)": no rabbit ever went for a carrot crop.

Vanilla (Rabbit.java, MoveToBlockGoal.java)

  • Goal 5, a MoveToBlockGoal(rabbit, 0.7, 16).
  • canUse: when its nextStartTick ran out, mobGriefing must be on; canRaid = false, wantsToRaid = moreCarrotTicks <= 0; then MoveToBlockGoal.canUse (a new delay of reducedTickDelay(200 + nextInt(200)), and the nearest valid block).
  • isValidTarget: the block is #supports_crops, the rabbit wantsToRaid and has not found one (!canRaid), and the block above is a carrot crop at its maximum age: canRaid = true.
  • canContinueToUse: canRaid && super.canContinueToUse().
  • tick: walk and look at the crop; once reached, if the block above is a carrot crop: age 0 is set to air with flags 2 (the following destroyBlock finds air and does nothing), otherwise the age drops by one with flags 2, a BLOCK_CHANGE game event for the rabbit and level event 2001 with the old state; moreCarrotTicks = 40. Then canRaid = false and nextStartTick = 10.
  • customServerAiStep runs moreCarrotTicks down by nextInt(3) a tick; it is saved as MoreCarrotTicks.

isValidTarget(blockPos) is false once canRaid is true, so canContinueToUse ends the goal on the next tick unless the rabbit is already within a block of the crop: that is how vanilla works and the goal here does the same.

What changes

  • RaidGarden goal (rabbit.rs) on goals::MoveToBlock, with raid_target for isValidTarget.
  • Extra.more_carrot_ticks, run down each AI step, saved and loaded as MoreCarrotTicks (it was always written as 0).
  • MobEvent::CropRaided: the block change with flags 2, the game event and the particles of the old state.

Verification

  • a_rabbit_keeps_how_full_of_carrots_it_is (NBT).
  • A real run on the server thread: a field of fully grown carrots on farmland and three rabbits placed in it. After 12 seconds two crops had gone from age 7 to age 6 and the break particles show.

rabbits in a carrot field after eating

  • Parity mob_ai passes. pr_ready --quick passes in full (fmt, clippy, Python tests, 1511 horizon-client tests).

🤖 Generated with Claude Code


🔄 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/5441 **Author:** [@xFedeT](https://github.com/xFedeT) **Created:** 10/31/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/rabbit-raids-carrots` --- ### 📝 Commits (3) - [`b1e4937`](https://github.com/horizon-rust/horizon/commit/b1e4937c9a851e122343056ade547f635b7a91e3) A rabbit eats ripe carrots - [`53cfb35`](https://github.com/horizon-rust/horizon/commit/53cfb35095fcdca6b5a790083de361692e5088d4) Merge main into #5441 - [`f8fa3c9`](https://github.com/horizon-rust/horizon/commit/f8fa3c9996fd748ee261a12a6e1ac3055d379207) Merge main into #5441 ### 📊 Changes **4 files changed** (+202 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/entity_nbt.rs` (+36 -1) 📝 `crates/horizon-client/src/game/creatures.rs` (+21 -0) 📝 `crates/horizon-client/src/mobs.rs` (+11 -0) 📝 `crates/horizon-client/src/mobs/rabbit.rs` (+134 -3) </details> ### 📄 Description > 🤖 Opened by xFedeT's AI agent (Claude Code, Claude Sonnet 5.5), not by xFedeT personally. Part of #3512: the three `Rabbit.RaidGardenGoal` rows (`canUse`, `isValidTarget`, `tick`). `rabbit.rs` said "Not ported yet: RaidGardenGoal (5)": no rabbit ever went for a carrot crop. ## Vanilla (`Rabbit.java`, `MoveToBlockGoal.java`) - Goal 5, a `MoveToBlockGoal(rabbit, 0.7, 16)`. - `canUse`: when its `nextStartTick` ran out, `mobGriefing` must be on; `canRaid = false`, `wantsToRaid = moreCarrotTicks <= 0`; then `MoveToBlockGoal.canUse` (a new delay of `reducedTickDelay(200 + nextInt(200))`, and the nearest valid block). - `isValidTarget`: the block is `#supports_crops`, the rabbit `wantsToRaid` and has not found one (`!canRaid`), and the block above is a carrot crop at its maximum age: `canRaid = true`. - `canContinueToUse`: `canRaid && super.canContinueToUse()`. - `tick`: walk and look at the crop; once reached, if the block above is a carrot crop: age 0 is set to air with flags 2 (the following `destroyBlock` finds air and does nothing), otherwise the age drops by one with flags 2, a `BLOCK_CHANGE` game event for the rabbit and level event 2001 with the old state; `moreCarrotTicks = 40`. Then `canRaid = false` and `nextStartTick = 10`. - `customServerAiStep` runs `moreCarrotTicks` down by `nextInt(3)` a tick; it is saved as `MoreCarrotTicks`. `isValidTarget(blockPos)` is false once `canRaid` is true, so `canContinueToUse` ends the goal on the next tick unless the rabbit is already within a block of the crop: that is how vanilla works and the goal here does the same. ## What changes - `RaidGarden` goal (`rabbit.rs`) on `goals::MoveToBlock`, with `raid_target` for `isValidTarget`. - `Extra.more_carrot_ticks`, run down each AI step, saved and loaded as `MoreCarrotTicks` (it was always written as 0). - `MobEvent::CropRaided`: the block change with flags 2, the game event and the particles of the old state. ## Verification - `a_rabbit_keeps_how_full_of_carrots_it_is` (NBT). - A real run on the server thread: a field of fully grown carrots on farmland and three rabbits placed in it. After 12 seconds two crops had gone from age 7 to age 6 and the break particles show. ![rabbits in a carrot field after eating](https://raw.githubusercontent.com/xFedeT/horizon/pr-screenshots/3512/rabbit-raid.png) - Parity `mob_ai` passes. `pr_ready --quick` passes in full (fmt, clippy, Python tests, 1511 `horizon-client` tests). 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:17:50 +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#6290
No description provided.