feat(client): slim skins wear the slim player model

A skin whose metadata says model slim (PlayerSkin.Model.SLIM) now draws
with PlayerModel's slim layer (3-pixel arms), on other players, the local
player's model, mannequins and the first-person arm. Without a skin, the
profile's default skin (DefaultPlayerSkin.get) keeps its own model, so
Alex and the other slim defaults are slim again.

Fixes #2926
This commit is contained in:
feeldev
2026-10-27 17:26:01 -05:00
parent 78c028321c
commit 9fe3ddfec3
8 changed files with 73 additions and 27 deletions
+12 -3
View File
@@ -1177,6 +1177,8 @@ struct WorldRest {
end_environment: Environment,
behaviours: Behaviours,
player_arm: Option<horizon_client::mobs::Part>,
/// The slim model's right arm (3 pixels wide).
player_arm_slim: Option<horizon_client::mobs::Part>,
player_type: Option<Arc<horizon_client::mobs::MobType>>,
/// `SpinAttackEffectModel` (Riptide's spinning boxes).
spin_attack: Option<horizon_client::mobs::Part>,
@@ -1249,8 +1251,12 @@ impl Resources {
fn threads(&self) -> usize {
self.core.threads
}
fn player_arm(&self) -> &Option<horizon_client::mobs::Part> {
&self.rest().player_arm
fn player_arm(&self, slim: bool) -> &Option<horizon_client::mobs::Part> {
if slim {
&self.rest().player_arm_slim
} else {
&self.rest().player_arm
}
}
fn player_type(&self) -> &Option<Arc<horizon_client::mobs::MobType>> {
&self.rest().player_type
@@ -10456,7 +10462,8 @@ impl Game<'_> {
if hand == Hand::Off {
continue;
}
let Some(arm) = self.res.player_arm().clone() else {
let slim = self.player_model.as_ref().is_some_and(|m| m.slim);
let Some(arm) = self.res.player_arm(slim).clone() else {
continue;
};
// The player's own skin, as the inventory's model shows it.
@@ -14514,6 +14521,8 @@ fn load_world_rest(
player_type: perspective::player_type(root),
player_arm: horizon_client::mobs::load_model(root, "minecraft:player#main")
.and_then(|m| m.children.into_iter().find(|c| c.name == "right_arm")),
player_arm_slim: horizon_client::mobs::load_model(root, "minecraft:player_slim#main")
.and_then(|m| m.children.into_iter().find(|c| c.name == "right_arm")),
spin_attack: horizon_client::mobs::load_model(root, "minecraft:spin_attack#main"),
})
}
@@ -158,7 +158,10 @@ pub(super) fn player_type(root: &Path) -> Option<Arc<MobType>> {
ambient_interval: 80,
flags: Default::default(),
model: Arc::new(model),
layers: Default::default(),
// PlayerModel's slim arms, for slim skins.
layers: horizon_client::mobs::load_model(root, "minecraft:player_slim#main")
.map(|slim| [("player_slim#main".to_owned(), Arc::new(slim))].into())
.unwrap_or_default(),
texture: "entity/player/wide/steve".into(),
brain: Brain::Passive,
anim: Anim::Humanoid { zombie_arms: false },
+25 -13
View File
@@ -3123,6 +3123,8 @@ impl Game<'_> {
entries.push((local, own));
}
let mut resolved: Vec<(u128, String)> = Vec::new();
// PlayerSkin.model of each resolved skin: the textures' `slim`.
let mut slim = std::collections::HashSet::new();
for (uuid, textures) in entries {
// PlayerInfo.createSkinLookup: only the local player's own skin
// may be unsigned.
@@ -3133,10 +3135,22 @@ impl Game<'_> {
})
};
if let Some(skin) = skin {
if textures.slim {
slim.insert(uuid);
}
resolved.push((uuid, skin));
}
}
resolved.retain(|(_, skin)| !skin.starts_with("skins/") || self.again_skin(skin));
// PlayerInfo.getSkin: the downloaded skin and its model, else the
// profile's default skin (DefaultPlayerSkin.get), slim or wide.
let skin_of = |skins: &HashMap<u128, String>, uuid: u128| match skins.get(&uuid) {
Some(skin) => (skin.clone(), slim.contains(&uuid)),
None => {
let skin = horizon_client::tab_list::default_skin(uuid);
(skin.to_owned(), skin.contains("/slim/"))
}
};
let Some((level, skins, own)) = self.remote.as_mut().map(|r| {
r.skins = resolved.into_iter().collect();
(
@@ -3145,30 +3159,26 @@ impl Game<'_> {
.map(|(id, uuid)| (*id as u32, *uuid))
.collect::<Vec<_>>(),
r.skins.clone(),
// Without a skin, the profile's default one (DefaultPlayerSkin.get).
r.skins
.get(&r.profile)
.cloned()
.unwrap_or_else(|| horizon_client::tab_list::default_model_skin(r.profile)),
r.profile,
)
}) else {
return;
};
for (id, uuid) in level {
let skin = skins
.get(&uuid)
.cloned()
.unwrap_or_else(|| horizon_client::tab_list::default_model_skin(uuid));
let (skin, is_slim) = skin_of(&skins, uuid);
if let Some(mob) = self
.mobs
.iter_mut()
.find(|m| m.id == id && &*m.kind.id == "minecraft:player")
{
mob.skin = Some(skin);
mob.slim = is_slim;
}
}
if let Some(mob) = self.player_model.as_mut() {
mob.skin = Some(own);
let (skin, is_slim) = skin_of(&skins, own);
mob.skin = Some(skin);
mob.slim = is_slim;
}
// ClientMannequin.updateSkin (PlayerSkinRenderCache.lookup): a
// mannequin's DATA_PROFILE `textures` property resolves like a
@@ -3218,7 +3228,7 @@ impl Game<'_> {
(m.id, textures)
})
.collect();
let mut resolved: Vec<(u32, Option<String>)> = Vec::new();
let mut resolved: Vec<(u32, Option<String>, bool)> = Vec::new();
for (id, textures) in mannequins {
let skin = {
let mut downloads = self.skin_downloads.borrow_mut();
@@ -3226,15 +3236,17 @@ impl Game<'_> {
downloads.state(kind, url)
})
};
resolved.push((id, skin));
let slim = skin.is_some() && textures.slim;
resolved.push((id, skin, slim));
}
for (id, skin) in resolved {
for (id, skin, slim) in resolved {
let skin = skin.filter(|s| !s.starts_with("skins/") || self.again_skin(s));
if let Some(mob) = self
.mobs
.iter_mut()
.find(|m| m.id == id && &*m.kind.id == "minecraft:mannequin")
{
mob.slim = slim && skin.is_some();
mob.skin = skin;
}
}
+3
View File
@@ -937,6 +937,8 @@ pub struct Mob {
/// The skin texture of a player mob (`PlayerInfo.getSkin`), which
/// replaces the type's default when its download is ready.
pub skin: Option<String>,
/// `PlayerSkin.model` is `SLIM`: the player model with 3-pixel arms.
pub slim: bool,
/// A mannequin's `DATA_PROFILE` (ResolvableProfile): the profile's
/// `textures` property resolves to `skin` like a player's.
pub profile: Option<horizon_protocol::entity_data::Profile>,
@@ -1908,6 +1910,7 @@ impl Mob {
rider: None,
outbox: Vec::new(),
skin: None,
slim: false,
profile: None,
attrs: Attrs {
speed: kind.speed,
+4 -2
View File
@@ -115,8 +115,9 @@ pub fn body(m: &Mob) -> (String, String) {
}
};
if avatar(m) {
// AvatarRenderer: PlayerModel's slim layer for a slim skin.
return (
"main".into(),
if m.slim { "player_slim#main" } else { "main" }.into(),
m.skin.clone().unwrap_or_else(|| m.kind.texture.clone()),
);
}
@@ -784,7 +785,8 @@ pub fn layers(m: &Mob) -> Vec<Layer> {
/// `HumanoidArmorLayer`: the armour models of the mob's main model with the
/// equipment textures (leather tinted, with its overlay).
fn humanoid_armor(m: &Mob, v: &mut Vec<Layer>) {
if super::equine::is_equine(m.species()) {
// A player's or mannequin's armour is drawn by the game's armour layers.
if super::equine::is_equine(m.species()) || avatar(m) {
return;
}
let (model, _) = body(m);
@@ -1331,6 +1331,7 @@ impl Def {
let mut v = vec![base];
let extra: &[&str] = match self.species {
Species::Pig => &["pig_baby", "cold_pig"],
Species::Mannequin => &["player_slim"],
Species::Cow => &[
"cow_baby",
"cold_cow",
+24
View File
@@ -17,6 +17,8 @@ pub enum Signature {
#[derive(Clone, Debug, Default, PartialEq, Eq)]
pub struct Textures {
pub skin: Option<String>,
/// The skin's `metadata.model` is `slim` (`PlayerModelType.SLIM`).
pub slim: bool,
pub cape: Option<String>,
pub elytra: Option<String>,
pub signed: bool,
@@ -101,6 +103,13 @@ pub fn unpack(value: &str, signature: Signature, valid_uris: &[&str]) -> Texture
if !allowed {
return empty;
}
if kind == "SKIN" {
out.slim = texture
.get("metadata")
.and_then(|m| m.get("model"))
.and_then(|m| m.as_str())
== Some("slim");
}
let slot = match kind.as_str() {
"SKIN" => &mut out.skin,
"CAPE" => &mut out.cape,
@@ -809,6 +818,21 @@ pub fn sha1(data: &[u8]) -> [u8; 20] {
#[cfg(test)]
mod tests {
/// `MinecraftProfileTexture.getMetadata("model")`: `slim` marks a slim
/// skin; no metadata is the wide (classic) model.
#[test]
fn a_skins_model_comes_from_its_metadata() {
use super::{Signature, TEXTURE_URIS, unpack};
let slim = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHBzOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlL2FiYyIsIm1ldGFkYXRhIjp7Im1vZGVsIjoic2xpbSJ9fX19";
let wide = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHBzOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlL2FiYyJ9fX0=";
let t = unpack(slim, Signature::Signed, &TEXTURE_URIS);
assert_eq!(
t.skin.as_deref(),
Some("https://textures.minecraft.net/texture/abc")
);
assert!(t.slim);
assert!(!unpack(wide, Signature::Signed, &TEXTURE_URIS).slim);
}
#[test]
fn profiles_parse_like_resolvable_profiles() {
use super::{NameOrId, Signature, parse_profile};
-8
View File
@@ -80,12 +80,6 @@ pub fn default_skin(uuid: u128) -> &'static str {
SKINS[hash.rem_euclid(SKINS.len() as i32) as usize]
}
/// The default skin a player model wears: `default_skin`'s character, in its wide variant, since
/// the player model has no slim arms.
pub fn default_model_skin(uuid: u128) -> String {
default_skin(uuid).replace("/slim/", "/wide/")
}
/// `blitSprite(sprite, x, y, w, h)`.
fn sprite(name: &'static str, x: i32, y: i32, w: i32, h: i32) -> GuiDraw {
GuiDraw::Sprite {
@@ -645,8 +639,6 @@ mod tests {
assert_eq!(ping_sprite(1000), "icon/ping_1");
// UUID.hashCode of 0 is 0: the first default skin.
assert_eq!(default_skin(0), "entity/player/slim/alex");
// The player model wears the same character with wide arms.
assert_eq!(default_model_skin(0), "entity/player/wide/alex");
assert!(!visible(true, true, 1, false));
assert!(visible(true, true, 1, true));
assert!(visible(true, false, 1, false));