[PR #6849] [MERGED] Despawn an untamed cat or ocelot once it is 2400 ticks old #7141

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/6849
Author: @MSedgeMC
Created: 11/2/2026
Status: ✅ Merged
Merged: 11/2/2026
Merged by: @ludovic111

Base: main ← Head: fix/cat-ocelot-despawn


📝 Commits (1)

  • e77404a Despawn an untamed cat or ocelot once it is 2400 ticks old

📊 Changes

2 files changed (+29 additions, -6 deletions)

View changed files

📝 crates/horizon-client/src/mobs/ai.rs (+27 -4)
📝 tools/port_map/game-011.tsv (+2 -2)

📄 Description

Vanilla behaviour

Animal.removeWhenFarAway returns false, so animals stay; the two felines are
the exception. Cat.removeWhenFarAway is !isTame() && tickCount > 2400 and
Ocelot.removeWhenFarAway is !isTrusting() && tickCount > 2400, both on
Entity.tickCount.

What Horizon got wrong

check_despawn (mobs/ai.rs) kept every creature animal and took the
ocelot out of that guard, then decided with m.extra.age <= 2400. That is
AgeableMob.age, the baby counter an adult keeps at 0, never Entity.tickCount,
so the condition was always true and neither a wild ocelot nor a wild cat was
ever removed for distance: vanilla lets both go 2400 ticks after they spawn.

feline_removed_when_far(species, tamed, ticks) now holds the rule on
m.age (Entity.tickCount), with the cat's tame flag and the ocelot's
trusting flag; check_despawn's animal guard reads it. Every other animal is
untouched (feline_removed_when_far is false for them).

Proven

cargo test -q -p horizon-client-lib --lib despawn — 3 passed, 0 failed. The
new an_untamed_feline_goes_once_it_is_old: nothing at 2400 ticks, removal at
2401, neither a tamed cat nor a trusting ocelot at 12000, and no other animal
at any age.

cargo clippy -q -p horizon-client-lib --lib -- -D warnings clean;
rustfmt --edition 2024 --check crates/horizon-client/src/mobs/ai.rs clean.

Not proven

No in-game check: watching a wild cat or ocelot past 2400 ticks more than 128
blocks from any player, then coming back to find it gone. The unit test pins
the rule check_despawn reads, not the despawn itself.

tools/port_map/game-011.tsv rows for both methods move from missing to
port at mobs/ai.rs::feline_removed_when_far.


🔄 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/6849 **Author:** [@MSedgeMC](https://github.com/MSedgeMC) **Created:** 11/2/2026 **Status:** ✅ Merged **Merged:** 11/2/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/cat-ocelot-despawn` --- ### 📝 Commits (1) - [`e77404a`](https://github.com/horizon-rust/horizon/commit/e77404a1f0cfc6f7edda832947215b4cfcc59f8f) Despawn an untamed cat or ocelot once it is 2400 ticks old ### 📊 Changes **2 files changed** (+29 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/mobs/ai.rs` (+27 -4) 📝 `tools/port_map/game-011.tsv` (+2 -2) </details> ### 📄 Description ## Vanilla behaviour `Animal.removeWhenFarAway` returns false, so animals stay; the two felines are the exception. `Cat.removeWhenFarAway` is `!isTame() && tickCount > 2400` and `Ocelot.removeWhenFarAway` is `!isTrusting() && tickCount > 2400`, both on `Entity.tickCount`. ## What Horizon got wrong `check_despawn` (`mobs/ai.rs`) kept every `creature` animal and took the ocelot out of that guard, then decided with `m.extra.age <= 2400`. That is `AgeableMob.age`, the baby counter an adult keeps at 0, never `Entity.tickCount`, so the condition was always true and neither a wild ocelot nor a wild cat was ever removed for distance: vanilla lets both go 2400 ticks after they spawn. `feline_removed_when_far(species, tamed, ticks)` now holds the rule on `m.age` (`Entity.tickCount`), with the cat's tame flag and the ocelot's trusting flag; `check_despawn`'s animal guard reads it. Every other animal is untouched (`feline_removed_when_far` is false for them). ## Proven `cargo test -q -p horizon-client-lib --lib despawn` — 3 passed, 0 failed. The new `an_untamed_feline_goes_once_it_is_old`: nothing at 2400 ticks, removal at 2401, neither a tamed cat nor a trusting ocelot at 12000, and no other animal at any age. `cargo clippy -q -p horizon-client-lib --lib -- -D warnings` clean; `rustfmt --edition 2024 --check crates/horizon-client/src/mobs/ai.rs` clean. ## Not proven No in-game check: watching a wild cat or ocelot past 2400 ticks more than 128 blocks from any player, then coming back to find it gone. The unit test pins the rule `check_despawn` reads, not the despawn itself. `tools/port_map/game-011.tsv` rows for both methods move from `missing` to `port` at `mobs/ai.rs::feline_removed_when_far`. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:34:34 +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#7141
No description provided.