diff --git a/crates/horizon-client/src/game/allays.rs b/crates/horizon-client/src/game/allays.rs index 27f40f980..e6f654bc4 100644 --- a/crates/horizon-client/src/game/allays.rs +++ b/crates/horizon-client/src/game/allays.rs @@ -89,6 +89,16 @@ impl Game<'_> { } } } + /// The UUID of the player an allay likes (`LIKED_PLAYER`). + fn allay_liked_uuid(&self, i: usize) -> [i32; 4] { + // An allay saved before its player was kept belongs to the host. + self.mobs[i] + .extra + .owner + .filter(|u| *u != [0, 0, 0, 1]) + .or(self.level.player_uuid) + .unwrap_or([0, 0, 0, 1]) + } /// `AllayAi.getLikedPlayer`: the player the allay was given an item by, /// found by UUID among the host and the guests of the level (the window /// is a guest on the server thread), when they are not a spectator and @@ -98,13 +108,7 @@ impl Game<'_> { if !m.extra.tame { return None; } - // An allay saved before its player was kept belongs to the host. - let uuid = m - .extra - .owner - .filter(|u| *u != [0, 0, 0, 1]) - .or(self.level.player_uuid) - .unwrap_or([0, 0, 0, 1]); + let uuid = self.allay_liked_uuid(i); let host = self .player_view() .filter(|p| !p.spectator && self.level.player_uuid.unwrap_or([0, 0, 0, 1]) == uuid) @@ -159,6 +163,19 @@ impl Game<'_> { ]; let len = (d[0] * d[0] + d[1] * d[1] + d[2] * d[2]).sqrt().max(1e-6); let v = [d[0] / len * 0.2, d[1] / len * 0.3, d[2] / len * 0.2]; + // AllayAi.throwItem: the liked player hears of the block below the deposit. + let below = [ + target.x.floor() as i32, + (target.y - 1.0).floor() as i32, + target.z.floor() as i32, + ]; + let uuid = self.allay_liked_uuid(i); + let stack = ItemStack::new(&item, 1); + self.for_each_player(|g| { + if g.acting_uuid() == uuid && !g.spectator() { + g.trigger_block("minecraft:allay_drop_item_on_block", below, &stack); + } + }); let m = &mut self.mobs[i]; m.extra.ints[1] -= 1; m.extra.ints[3] = 60;