Only let a tame parrot land on its saved owner

This commit is contained in:
Kacpherek
2026-10-26 21:38:16 +01:00
parent 9ca7162169
commit be714b38bb
2 changed files with 19 additions and 1 deletions
@@ -27,6 +27,10 @@ impl Game<'_> {
let Some(p) = self.player.as_ref() else {
return;
};
// The acting player must be the saved owner (`getOwner`).
if !horizon_client::mobs::tame::owned_by(self.mobs[i].extra.owner, self.acting_uuid()) {
return;
}
if self.riding.is_some()
|| !p.ground.on_ground
|| p.fluids.was_touching_water
+15 -1
View File
@@ -123,13 +123,15 @@ impl Goal for LandOnOwnersShoulder {
}
fn can_use(&mut self, m: &mut Mob, cx: &mut Cx) -> bool {
// ShoulderRidingEntity.canSitOnShoulder: rideCooldownCounter > 100.
owner(m, cx.w).is_some_and(|(_, _, spectator)| !spectator)
is_owner(m, cx.w)
&& owner(m, cx.w).is_some_and(|(_, _, spectator)| !spectator)
&& !m.extra.sitting
&& m.age > 100
}
fn tick(&mut self, m: &mut Mob, cx: &mut Cx) {
if !m.extra.sitting
&& m.extra.leash.is_none()
&& is_owner(m, cx.w)
&& cx
.w
.player
@@ -172,6 +174,18 @@ fn owner(m: &Mob, w: &MobWorld) -> Option<(Vec3, f64, bool)> {
let p = w.player.as_ref()?;
Some((p.position, p.eye[1], p.spectator))
}
/// Whether the player the mob sees is the one saved as its owner (with
/// guests on, that player is whoever stands nearest).
fn is_owner(m: &Mob, w: &MobWorld) -> bool {
w.player
.as_ref()
.is_some_and(|p| owned_by(m.extra.owner, p.uuid))
}
/// Whether `uuid` is the saved owner. A host with no UUID yet owns what it
/// tamed under the placeholder `[0, 0, 0, 1]`.
pub fn owned_by(owner: Option<[i32; 4]>, uuid: [i32; 4]) -> bool {
owner.is_some_and(|o| o == uuid || (o == [0, 0, 0, 1] && uuid == [0; 4]))
}
/// `TamableAnimal.unableToMoveToOwner`.
fn unable_to_move_to_owner(m: &Mob, w: &MobWorld) -> bool {
m.extra.sitting || w.player.as_ref().is_some_and(|p| p.spectator)