Fix tamed horses despawning when player moves away#1057
Merged
codeHusky merged 1 commit intosmartcmd:mainfrom Mar 10, 2026
Merged
Fix tamed horses despawning when player moves away#1057codeHusky merged 1 commit intosmartcmd:mainfrom
codeHusky merged 1 commit intosmartcmd:mainfrom
Conversation
Contributor
|
Cant seem to reproduce the previous behavior but your changes appear to fix the issue completely. |
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
EntityHorsedid not overrideremoveWhenFarAway()and inherited the genericAnimal::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,
WolfandOcelotalready had their ownremoveWhenFarAway()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 returnsfalse(preventing despawn) if any of these conditions are true:isTamed()- horse has been tamed by a playerisSaddled()- horse has a saddle equippedisLeashed()- horse is attached to a leadgetArmorType() > 0- horse has armor equippedOtherwise falls back to
Animal::removeWhenFarAway()for wild horses.Related Issues