Record the thrower of guest drops and the player behind a lead
This commit is contained in:
@@ -2320,11 +2320,18 @@ impl Game<'_> {
|
||||
yaw.cos() * pitch.cos() * 0.3 + spread.sin() * strength,
|
||||
];
|
||||
self.spawn_item(thrown, [eye[0], eye[1] - 0.3, eye[2]], v, 40);
|
||||
if thrown_from_hand && self.lan_acting.is_none() {
|
||||
let uuid = self.level.ensure_player_uuid();
|
||||
if thrown_from_hand {
|
||||
let uuid = self.acting_player_uuid();
|
||||
self.dropped.last_mut().unwrap().thrower = Some(uuid);
|
||||
}
|
||||
}
|
||||
/// The UUID of the player acting: the guest whose turn it is, else the host.
|
||||
pub(super) fn acting_player_uuid(&mut self) -> [i32; 4] {
|
||||
match self.lan_acting_uuid {
|
||||
Some(guest) => horizon_client::lan::playerdata::uuid_ints(guest),
|
||||
None => self.level.ensure_player_uuid(),
|
||||
}
|
||||
}
|
||||
fn tick_items(&mut self) {
|
||||
let mut items = std::mem::take(&mut self.dropped);
|
||||
// ServerLevel.tick: only entities in entity-ticking chunks tick.
|
||||
|
||||
@@ -612,9 +612,13 @@ impl Game<'_> {
|
||||
.mobs
|
||||
.iter()
|
||||
.find(|m| m.id == id)
|
||||
.and_then(|m| m.extra.leash)
|
||||
.and_then(|holder| match holder {
|
||||
horizon_client::mobs::leash::Holder::Player => Some(Target::Player),
|
||||
.and_then(|m| m.extra.leash.map(|holder| (holder, m.extra.leash_player)))
|
||||
.and_then(|(holder, player)| match holder {
|
||||
// The player who tied it (the host's when unrecorded).
|
||||
horizon_client::mobs::leash::Holder::Player => {
|
||||
let uuid = player.or(self.level.player_uuid)?;
|
||||
self.target_by_uuid(horizon_client::lan::playerdata::ints_uuid(uuid))
|
||||
}
|
||||
horizon_client::mobs::leash::Holder::Mob(i) => Some(Target::Mob(i)),
|
||||
horizon_client::mobs::leash::Holder::Knot(_) => None,
|
||||
})
|
||||
|
||||
@@ -104,6 +104,9 @@ impl Game<'_> {
|
||||
};
|
||||
let m = &mut self.mobs[i];
|
||||
if let Some(h) = holder {
|
||||
if h == Holder::Player {
|
||||
m.extra.leash_player = Some(player_uuid);
|
||||
}
|
||||
m.extra.leash = Some(h);
|
||||
m.extra.leash_pending = None;
|
||||
} else if m.age > 100 {
|
||||
@@ -201,7 +204,9 @@ impl Game<'_> {
|
||||
if self.mobs[index].extra.leash.is_some() {
|
||||
self.break_leash(id, true, false);
|
||||
}
|
||||
let holder = self.acting_player_uuid();
|
||||
self.mobs[index].extra.leash = Some(Holder::Player);
|
||||
self.mobs[index].extra.leash_player = Some(holder);
|
||||
self.lead_sound("tied", at);
|
||||
// The lead is always used up.
|
||||
if let Some(stack) = self.held_mut().as_mut() {
|
||||
|
||||
@@ -728,6 +728,8 @@ pub struct Extra {
|
||||
/// the spin the rope's torque gives it.
|
||||
pub leash: Option<leash::Holder>,
|
||||
pub leash_pending: Option<leash::Pending>,
|
||||
/// The UUID of the player behind `Holder::Player` (host or guest).
|
||||
pub leash_player: Option<[i32; 4]>,
|
||||
pub leash_spin: f64,
|
||||
/// More species scratch values.
|
||||
pub scratch: [i32; 4],
|
||||
|
||||
Reference in New Issue
Block a user