[PR #3544] [MERGED] Frogs long jump: FrogAi's long jump activity (fixes #2841) #5039

Closed
opened 2026-11-03 05:09:47 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/3544
Author: @degepie
Created: 10/29/2026
Status: ✅ Merged
Merged: 10/29/2026
Merged by: @levzzz5154

Base: main ← Head: fix/issue-2841-frog-jump


📝 Commits (4)

  • 5f26977 Frogs long jump: FrogAi's long jump activity (fixes #2841)
  • 7e459e5 Frogs long jump: level and unseeded randoms, activity gate TODO
  • cefa615 Merge remote-tracking branch 'hr/main' into fix-3544
  • f065bab Merge main into the branch; the zombie villager's cure step gets the level random

📊 Changes

10 files changed (+483 additions, -18 deletions)

View changed files

📝 crates/horizon-client/src/mobs/ai.rs (+18 -3)
📝 crates/horizon-client/src/mobs/animal_brain.rs (+1 -0)
📝 crates/horizon-client/src/mobs/breeze.rs (+43 -3)
📝 crates/horizon-client/src/mobs/frog.rs (+398 -3)
📝 crates/horizon-client/src/mobs/goals.rs (+4 -1)
📝 crates/horizon-client/src/mobs/living.rs (+2 -2)
📝 crates/horizon-client/src/mobs/monster_brain.rs (+1 -0)
📝 crates/horizon-client/src/mobs/nav.rs (+1 -1)
📝 crates/horizon-client/src/mobs/warden.rs (+8 -2)
📝 crates/horizon-client/src/mobs/warden_brain.rs (+7 -3)

📄 Description

🤖 Opened by degepie's AI agent (Claude Code), not by degepie personally.

Fixes #2841.

What

Frogs never long-jumped. The client half was already in place: the jump animation state follows Pose.LONG_JUMPING. What was missing was the server's LONG_JUMP activity from FrogAi, so a frog only ever walked, slowly, as the report says. This PR ports that activity.

Vanilla

  • FrogAi.initJumpActivity: LongJumpMidJump (landing sound frog.step) and LongJumpToPreferredBlock with TIME_BETWEEN_LONG_JUMPS = UniformInt(100, 140), height 2, width 4, MAX_JUMP_VELOCITY_MULTIPLIER = 3.5714288, sound frog.long_jump, tag frog_prefer_jump_to (lily_pad, big_dripleaf), chance 0.5, and FrogAi.isAcceptableLandingSpot. The activity only runs while LONG_JUMP_COOLDOWN_TICKS is absent and the frog is out of water. updateActivity ranks it below the tongue and above swimming and idling.
  • LongJumpToRandomPos: checkExtraStartConditions needs the frog on the ground, out of water and lava, and not on honey; otherwise the cooldown gets half a sample. start collects every block of the box except the frog's own, weighted by ceil(distSqr). tick/pickCandidate draws candidates with WeightedRandom.getRandomItem. It skips the frog's own column and unacceptable spots. It keeps the first spot that calculateOptimalJumpVector can reach (ALLOWED_ANGLES 65/70/75/80, max velocity = jump strength × multiplier) and that createPath(target, 0, 8) cannot walk to. The frog then faces that spot for PREPARE_JUMP_DURATION = 40 ticks. At the jump it turns to its body yaw, discards friction, and its velocity becomes the arc lengthened by jump boost. canStillUse requires the frog to stay exactly where it started, with tries left and something still to try; when that fails before the jump, the cooldown gets half a sample.
  • LongJumpToPreferredBlock.getJumpCandidate: half of the searches look for a spot above a preferred block first, then fall back to the first spot passed over.
  • LongJumpUtil.calculateJumpVectorForAngle with checkCollision and isClearTransition: samples the arc and checks that the mob's box fits along it.
  • LongJumpMidJump: starts the tick after the leap (LONG_JUMPING pose, no friction) and runs until the frog is on the ground, for at most TIME_OUT_DURATION = 100 ticks (Behavior.tickOrStop/timedOut). Water also ends it, because updateActivity switches the brain to the swim activity. stop damps the horizontal speed to 0.1 when it lands, plays frog.step at volume 2, restores friction and the standing pose, and sets a full cooldown sample.
  • CountDownCooldownTicks(LONG_JUMP_COOLDOWN_TICKS) in the core activity.

How

  • mobs/frog.rs: a LongJump goal at priority 3, between ShootTongue (2) and Croak (4). It takes MOVE and LOOK and checks every tick. Like the activity, it keeps the idle croak and stroll from starting. It can't be interrupted mid-jump. Mid-jump it ends on landing, after 100 ticks, or in water, and every way it stops restores friction and the pose. The cooldown memory counts down in server_ai_step. It is the long_jump_cooldown entry that finalize already writes.
  • mobs/breeze.rs: jump_vector (LongJumpUtil.calculateJumpVectorForAngle) takes an optional world and does the collision sampling when given one. The breeze passes None, so its behaviour is unchanged.
  • mobs/living.rs: one line. travelInAir also skips friction while a frog's discard_friction is set.
  • mobs/nav.rs: create_path_raw is now pub(super), so the 3-argument createPath(pos, reach, maxPathLength) can be used. It has no ground-surface search, as in vanilla.

Verified

  • Unit tests in mobs::frog::tests: candidate box order and weights, the weighted draw, and the cooldown memory. All mobs:: lib tests pass.
  • In game (release build, scratch home, offscreen, server thread): a 25×25 grass platform with a 5×5 pool, three lily pads and a stone step, and five summoned frogs. Positions were sampled about every 0.45 s for about 70 s.
    • Before (v0.2.91): all 5 frogs stayed at y = 150.00, with 0 jumps.
    • After (two runs): 3 of the 5 frogs jumped. They made 7–13 arcs each, up to about 4 blocks high, hopped between the lily pads (landing at y 150.09, the top of a lily pad) and onto the stone step. The frogs that entered the pool kept moving; none froze. Between jumps each frog stood still for several seconds, which fits the 100–140 tick cooldown plus the 40 tick wind-up. After landing a frog did not keep sliding. The 2 frogs left on open flat grass did not jump: every spot within reach there is walkable in 8 blocks, and vanilla's frogs don't jump there either.

Known differences

  • Vanilla draws the weighted candidate and the cooldown samples from the level random, and shuffles the angles with an unseeded JDK Random (Collections.shuffle). Goals here have no level random, so all of these draws use the frog's own random. The behaviour is the same, but the draw sequence isn't.
  • In vanilla, a stroll that was already under way keeps walking (MoveToTargetSink is a core behaviour), which makes the jump search fail because the frog moved. Here the goal's MOVE flag stops the stroll, so a frog that was walking may jump a little more readily.
  • The collision sampling uses the block collision check without other entities' boxes.
  • There is no frog scenario in the mob_ai harness. Because of the random sources above, a scenario would diverge early, so none was added.
  • #2586 / #2698 rename the cooldown memory key from long_jump_cooldown to long_jump_cooling_down (the vanilla id). If either lands, update LONG_JUMP_COOLDOWN in frog.rs to match. Otherwise the frog won't see the cooldown that finalize sets.
  • Goats also use LongJumpToRandomPos in vanilla (GoatAi) but have no long jump in Horizon yet. That is not part of this PR.

pr_ready (tools/pr_ready.py --quick on horizon-build, against origin/main at b56048d99, 3 min 13 s)

Check Result
Scope ✅ 4 files, +431 −8
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 408 passed (42 s)
rustfmt ✅ (8 s)
clippy ✅
tests: horizon-client ✅ 1289 passed (2 min 19 s)
doc tests ✅ 0 passed (2 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 ➖ 347 affected, to run in CI (--quick)

🤖 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/3544 **Author:** [@degepie](https://github.com/degepie) **Created:** 10/29/2026 **Status:** ✅ Merged **Merged:** 10/29/2026 **Merged by:** [@levzzz5154](https://github.com/levzzz5154) **Base:** `main` ← **Head:** `fix/issue-2841-frog-jump` --- ### 📝 Commits (4) - [`5f26977`](https://github.com/horizon-rust/horizon/commit/5f269772d962a127285fbc108fc329805e86c122) Frogs long jump: FrogAi's long jump activity (fixes #2841) - [`7e459e5`](https://github.com/horizon-rust/horizon/commit/7e459e5fb1a44a55c6211e5889ad7f5dd94daa0a) Frogs long jump: level and unseeded randoms, activity gate TODO - [`cefa615`](https://github.com/horizon-rust/horizon/commit/cefa6153d1be3746fb83acaca71215c126afea98) Merge remote-tracking branch 'hr/main' into fix-3544 - [`f065bab`](https://github.com/horizon-rust/horizon/commit/f065bab2e4fd845c18490537112e8a89a72e4e07) Merge main into the branch; the zombie villager's cure step gets the level random ### 📊 Changes **10 files changed** (+483 additions, -18 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/mobs/ai.rs` (+18 -3) 📝 `crates/horizon-client/src/mobs/animal_brain.rs` (+1 -0) 📝 `crates/horizon-client/src/mobs/breeze.rs` (+43 -3) 📝 `crates/horizon-client/src/mobs/frog.rs` (+398 -3) 📝 `crates/horizon-client/src/mobs/goals.rs` (+4 -1) 📝 `crates/horizon-client/src/mobs/living.rs` (+2 -2) 📝 `crates/horizon-client/src/mobs/monster_brain.rs` (+1 -0) 📝 `crates/horizon-client/src/mobs/nav.rs` (+1 -1) 📝 `crates/horizon-client/src/mobs/warden.rs` (+8 -2) 📝 `crates/horizon-client/src/mobs/warden_brain.rs` (+7 -3) </details> ### 📄 Description > 🤖 Opened by degepie's AI agent (Claude Code), not by degepie personally. Fixes #2841. ## What Frogs never long-jumped. The client half was already in place: the jump animation state follows `Pose.LONG_JUMPING`. What was missing was the server's `LONG_JUMP` activity from `FrogAi`, so a frog only ever walked, slowly, as the report says. This PR ports that activity. ## Vanilla - `FrogAi.initJumpActivity`: `LongJumpMidJump` (landing sound `frog.step`) and `LongJumpToPreferredBlock` with `TIME_BETWEEN_LONG_JUMPS` = UniformInt(100, 140), height 2, width 4, `MAX_JUMP_VELOCITY_MULTIPLIER` = 3.5714288, sound `frog.long_jump`, tag `frog_prefer_jump_to` (`lily_pad`, `big_dripleaf`), chance 0.5, and `FrogAi.isAcceptableLandingSpot`. The activity only runs while `LONG_JUMP_COOLDOWN_TICKS` is absent and the frog is out of water. `updateActivity` ranks it below the tongue and above swimming and idling. - `LongJumpToRandomPos`: `checkExtraStartConditions` needs the frog on the ground, out of water and lava, and not on honey; otherwise the cooldown gets half a sample. `start` collects every block of the box except the frog's own, weighted by `ceil(distSqr)`. `tick`/`pickCandidate` draws candidates with `WeightedRandom.getRandomItem`. It skips the frog's own column and unacceptable spots. It keeps the first spot that `calculateOptimalJumpVector` can reach (`ALLOWED_ANGLES` 65/70/75/80, max velocity = jump strength × multiplier) and that `createPath(target, 0, 8)` cannot walk to. The frog then faces that spot for `PREPARE_JUMP_DURATION` = 40 ticks. At the jump it turns to its body yaw, discards friction, and its velocity becomes the arc lengthened by jump boost. `canStillUse` requires the frog to stay exactly where it started, with tries left and something still to try; when that fails before the jump, the cooldown gets half a sample. - `LongJumpToPreferredBlock.getJumpCandidate`: half of the searches look for a spot above a preferred block first, then fall back to the first spot passed over. - `LongJumpUtil.calculateJumpVectorForAngle` with `checkCollision` and `isClearTransition`: samples the arc and checks that the mob's box fits along it. - `LongJumpMidJump`: starts the tick after the leap (`LONG_JUMPING` pose, no friction) and runs until the frog is on the ground, for at most `TIME_OUT_DURATION` = 100 ticks (`Behavior.tickOrStop`/`timedOut`). Water also ends it, because `updateActivity` switches the brain to the swim activity. `stop` damps the horizontal speed to 0.1 when it lands, plays `frog.step` at volume 2, restores friction and the standing pose, and sets a full cooldown sample. - `CountDownCooldownTicks(LONG_JUMP_COOLDOWN_TICKS)` in the core activity. ## How - `mobs/frog.rs`: a `LongJump` goal at priority 3, between `ShootTongue` (2) and `Croak` (4). It takes MOVE and LOOK and checks every tick. Like the activity, it keeps the idle croak and stroll from starting. It can't be interrupted mid-jump. Mid-jump it ends on landing, after 100 ticks, or in water, and every way it stops restores friction and the pose. The cooldown memory counts down in `server_ai_step`. It is the `long_jump_cooldown` entry that `finalize` already writes. - `mobs/breeze.rs`: `jump_vector` (`LongJumpUtil.calculateJumpVectorForAngle`) takes an optional world and does the collision sampling when given one. The breeze passes `None`, so its behaviour is unchanged. - `mobs/living.rs`: one line. `travelInAir` also skips friction while a frog's `discard_friction` is set. - `mobs/nav.rs`: `create_path_raw` is now `pub(super)`, so the 3-argument `createPath(pos, reach, maxPathLength)` can be used. It has no ground-surface search, as in vanilla. ## Verified - Unit tests in `mobs::frog::tests`: candidate box order and weights, the weighted draw, and the cooldown memory. All `mobs::` lib tests pass. - In game (release build, scratch home, offscreen, server thread): a 25×25 grass platform with a 5×5 pool, three lily pads and a stone step, and five summoned frogs. Positions were sampled about every 0.45 s for about 70 s. - Before (v0.2.91): all 5 frogs stayed at y = 150.00, with 0 jumps. - After (two runs): 3 of the 5 frogs jumped. They made 7–13 arcs each, up to about 4 blocks high, hopped between the lily pads (landing at y 150.09, the top of a lily pad) and onto the stone step. The frogs that entered the pool kept moving; none froze. Between jumps each frog stood still for several seconds, which fits the 100–140 tick cooldown plus the 40 tick wind-up. After landing a frog did not keep sliding. The 2 frogs left on open flat grass did not jump: every spot within reach there is walkable in 8 blocks, and vanilla's frogs don't jump there either. ## Known differences - Vanilla draws the weighted candidate and the cooldown samples from the level random, and shuffles the angles with an unseeded JDK `Random` (`Collections.shuffle`). Goals here have no level random, so all of these draws use the frog's own random. The behaviour is the same, but the draw sequence isn't. - In vanilla, a stroll that was already under way keeps walking (`MoveToTargetSink` is a core behaviour), which makes the jump search fail because the frog moved. Here the goal's MOVE flag stops the stroll, so a frog that was walking may jump a little more readily. - The collision sampling uses the block collision check without other entities' boxes. - There is no frog scenario in the `mob_ai` harness. Because of the random sources above, a scenario would diverge early, so none was added. - #2586 / #2698 rename the cooldown memory key from `long_jump_cooldown` to `long_jump_cooling_down` (the vanilla id). If either lands, update `LONG_JUMP_COOLDOWN` in `frog.rs` to match. Otherwise the frog won't see the cooldown that `finalize` sets. - Goats also use `LongJumpToRandomPos` in vanilla (`GoatAi`) but have no long jump in Horizon yet. That is not part of this PR. **pr_ready** (`tools/pr_ready.py --quick` on horizon-build, against origin/main at b56048d99, 3 min 13 s) | Check | Result | | --- | --- | | Scope | ✅ 4 files, +431 −8 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 408 passed (42 s) | | rustfmt | ✅ (8 s) | | clippy | ✅ | | tests: horizon-client | ✅ 1289 passed (2 min 19 s) | | doc tests | ✅ 0 passed (2 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 | ➖ 347 affected, to run in CI (--quick) | 🤖 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 05:09:47 +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#5039
No description provided.