Client: remote players keep their skins instead of falling back
skins::unpack discarded a profile's whole textures payload when any one entry lacked "url" or pointed outside the texture services' domains, so a player with e.g. an unusual cape lost their skin too; it now drops only the offending texture. The 32 skin atlas slots evicted past players back to defaults on busy servers — now 128. A dimension reset (join game or respawn onto another world) now also clears the entity-id→profile map so a re-used entity id can't pin the wrong skin or name to a player, and the nametag join falls back to the player-list entry's name. Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
@@ -1006,6 +1006,9 @@ impl Game<'_> {
|
||||
r.stepped.clear();
|
||||
r.head_lerps.clear();
|
||||
r.pending_items.clear();
|
||||
// The entity ids are the old world's; the new dimension's
|
||||
// player entities re-map to their profiles on AddEntity.
|
||||
r.level_players.clear();
|
||||
// A new ClientLevel: a new chunk storage, centred on 0, 0.
|
||||
r.chunk_center = (0, 0);
|
||||
}
|
||||
@@ -5065,7 +5068,14 @@ impl Game<'_> {
|
||||
r.level_players
|
||||
.iter()
|
||||
.filter(|(_, uuid)| **uuid != r.profile)
|
||||
.filter_map(|(id, uuid)| Some((*id as u32, r.players.get(uuid)?.clone())))
|
||||
.filter_map(|(id, uuid)| {
|
||||
let name = r
|
||||
.players
|
||||
.get(uuid)
|
||||
.cloned()
|
||||
.or_else(|| r.tab_players.get(uuid).map(|t| t.name.clone()))?;
|
||||
Some((*id as u32, name))
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
/// `ClientClockManager.tick`: the clock moves on by the game time that
|
||||
|
||||
@@ -78,7 +78,9 @@ pub const MAP_SLOTS: usize = 256;
|
||||
/// The atlas slot the minimap extra draws into.
|
||||
pub const MINIMAP_SPRITE: &str = "horizon/minimap";
|
||||
/// Atlas slots for downloaded player skins (`skins/<sha1>`), 64x64 each.
|
||||
pub const SKIN_SLOTS: usize = 32;
|
||||
/// Vanilla registers a texture per skin; too few slots evict a busy
|
||||
/// server's players back to their default skins.
|
||||
pub const SKIN_SLOTS: usize = 128;
|
||||
/// Reused by the visible rows of the classic world selector.
|
||||
pub const WORLD_ICON_SLOTS: usize = 32;
|
||||
/// Atlas slots for the pack icons on the pack screen, one per icon drawn
|
||||
|
||||
@@ -92,22 +92,23 @@ pub fn unpack(value: &str, signature: Signature, valid_uris: &[&str]) -> Texture
|
||||
..empty.clone()
|
||||
};
|
||||
for (kind, texture) in textures {
|
||||
let Some(url) = texture.get("url").and_then(|u| u.as_str()) else {
|
||||
return empty;
|
||||
};
|
||||
let allowed = valid_uris
|
||||
.iter()
|
||||
.any(|u| url.starts_with(&u.replace("{textureId}", "")));
|
||||
if !allowed {
|
||||
return empty;
|
||||
}
|
||||
let slot = match kind.as_str() {
|
||||
"SKIN" => &mut out.skin,
|
||||
"CAPE" => &mut out.cape,
|
||||
"ELYTRA" => &mut out.elytra,
|
||||
_ => continue,
|
||||
};
|
||||
*slot = Some(url.to_owned());
|
||||
// One bad entry (no `url`, or a URL outside the texture services'
|
||||
// domains) drops only that texture, not the whole payload.
|
||||
let Some(url) = texture.get("url").and_then(|u| u.as_str()) else {
|
||||
continue;
|
||||
};
|
||||
let allowed = valid_uris
|
||||
.iter()
|
||||
.any(|u| url.starts_with(&u.replace("{textureId}", "")));
|
||||
if allowed {
|
||||
*slot = Some(url.to_owned());
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user