Skip to content

Fix tamed horses despawning when player moves away#1057

Merged
codeHusky merged 1 commit intosmartcmd:mainfrom
MCbabel:fix/horse-despawn
Mar 10, 2026
Merged

Fix tamed horses despawning when player moves away#1057
codeHusky merged 1 commit intosmartcmd:mainfrom
MCbabel:fix/horse-despawn

Conversation

@MCbabel
Copy link
Contributor

@MCbabel MCbabel commented Mar 9, 2026

Description

Fix tamed horses despawning when the player moves away. This addresses a bug reported on the Discord server where multiple users experienced their tamed horses (including ones with saddles and armor) vanishing after leaving the area.

Changes

Previous Behavior

Tamed horses with saddles, armor, and leads would despawn when the player moved more than 128 blocks away. This caused players to permanently lose their equipped horses.

Root Cause

EntityHorse did not override removeWhenFarAway() and inherited the generic Animal::removeWhenFarAway() which only relies on a wander-distance-based despawn protection mechanism (isDespawnProtected). This mechanism could fail for horses that wandered far enough, regardless of their tamed/equipped status.

In contrast, Wolf and Ocelot already had their own removeWhenFarAway() overrides that checked !isTame(), preventing tamed wolves and cats from despawning. Horses lacked this protection entirely.

New Behavior

Tamed, saddled, leashed, or armored horses will no longer despawn regardless of distance from the player. Wild horses without any equipment still follow the normal despawn rules.

Fix Implementation

Added EntityHorse::removeWhenFarAway() override that returns false (preventing despawn) if any of these conditions are true:

  • isTamed() - horse has been tamed by a player
  • isSaddled() - horse has a saddle equipped
  • isLeashed() - horse is attached to a lead
  • getArmorType() > 0 - horse has armor equipped

Otherwise falls back to Animal::removeWhenFarAway() for wild horses.

Related Issues

  • Fixes a bug reported on the Discord server ("tamed horses are despawning", reported March 5 by multiple users)

@eh-K
Copy link
Contributor

eh-K commented Mar 10, 2026

Cant seem to reproduce the previous behavior but your changes appear to fix the issue completely.

@codeHusky codeHusky merged commit 91ae76f into smartcmd:main Mar 10, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants