From 8dcd00fc623d0c5c0e75843fe24839028ed15f96 Mon Sep 17 00:00:00 2001 From: socksprox Date: Sun, 25 Oct 2026 21:54:47 +0100 Subject: [PATCH 1/4] AGENTS.md: the feature-request loop When an agent is asked for a feature it runs the whole loop itself: check open PRs for the area first, work in a new worktree on the latest upstream main, build and run pr_ready, then push to the fork and open the pull request against upstream, never the fork. Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- AGENTS.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/AGENTS.md b/AGENTS.md index 2d883b33b..ed76c08dd 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -27,6 +27,10 @@ Feature → files → harness for the most-changed areas: [docs/architecture.md] change), none for a fix. Agents never add `release-now`: the maintainer decides it. Merges ship in batches of 5, or after 6 hours ([docs/release-flow.md](docs/release-flow.md)). - Contributors first: `gh pr list --state open --search ` before you start; never duplicate theirs. +- Asked for a feature? Run the whole loop: check open PRs for the area (above), work in a new worktree, + `git fetch` the upstream remote (`ludovic111/horizon`) and start from its latest `main`, build, run + `tools/pr_ready.py`, then push to your fork and open the pull request against upstream's `main` — + never against the fork itself. ## Crates From 820cc211d32d6bf0c7fa677a9c99a60f4cfc0aa8 Mon Sep 17 00:00:00 2001 From: socksprox Date: Sun, 25 Oct 2026 21:55:02 +0100 Subject: [PATCH 2/4] Player heads render their owner's skin Placed player_head blocks kept no profile: skulls had no block entity, so the renderer fell back to a hardcoded steve for every head. Give skulls a real BlockEntity carrying vanilla's SkullBlockEntity fields (profile, note_block_sound, custom_name) so the placement pipeline lands minecraft:profile in it the way block_entity_item already maps, encode and decode it through save so regions keep it, send its update tag to remote clients, and resolve the profile through the skin downloader the head items and the tab list share: the downloaded skin slot once it lands, the profile's DefaultPlayerSkin uuid pick while it fetches, SKIN_BY_TYPE steve without a profile. Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- .../probe/block_entity_render_fixture.rs | 1 + .../horizon-client/src/block_entity_render.rs | 16 +++- crates/horizon-client/src/containers.rs | 24 +++++- crates/horizon-client/src/game.rs | 7 +- .../src/game/block_entity_anims.rs | 32 ++++++++ crates/horizon-client/src/game/minecarts.rs | 1 + crates/horizon-client/src/lan/chunks.rs | 14 ++++ crates/horizon-client/src/save.rs | 68 +++++++++++++++- crates/horizon-client/src/skins.rs | 77 +++++++++++++++++++ 9 files changed, 233 insertions(+), 7 deletions(-) diff --git a/crates/horizon-client/examples/probe/block_entity_render_fixture.rs b/crates/horizon-client/examples/probe/block_entity_render_fixture.rs index a0e3471bc..1db978b77 100644 --- a/crates/horizon-client/examples/probe/block_entity_render_fixture.rs +++ b/crates/horizon-client/examples/probe/block_entity_render_fixture.rs @@ -367,6 +367,7 @@ pub fn main() -> Result<()> { lid: &|_| open, sign: &|_| sign.as_ref(), banner: &|_| layers.clone(), + skull: &|_| None, glyph: &|c| atlas.glyph_cell(c), }; let mut verts = Vec::new(); diff --git a/crates/horizon-client/src/block_entity_render.rs b/crates/horizon-client/src/block_entity_render.rs index af4168307..a863d6214 100644 --- a/crates/horizon-client/src/block_entity_render.rs +++ b/crates/horizon-client/src/block_entity_render.rs @@ -730,6 +730,10 @@ pub struct Scene<'a> { pub sign: &'a dyn Fn([i32; 3]) -> Option<&'a crate::signs::SignData>, /// Banner layers at a position: pattern texture and RGB tint, bottom first. pub banner: &'a dyn Fn([i32; 3]) -> Vec<(String, u32)>, + /// The skin sprite a `player_head` shows at a position (`SkullBlockRenderer` + /// profile → skin): a downloaded `skins/` slot or the profile's + /// `DefaultPlayerSkin` fallback; None keeps `SKIN_BY_TYPE` (steve). + pub skull: &'a dyn Fn([i32; 3]) -> Option, /// Font glyph cell (none for blank glyphs such as the space) and advance. pub glyph: &'a dyn Fn(char) -> (Option, f32), } @@ -1277,7 +1281,16 @@ impl BlockEntityRenderer { SkullType::Creeper => ("creeper_head", "entity/creeper/creeper"), SkullType::Dragon => ("dragon_skull", "entity/enderdragon/dragon"), SkullType::Piglin => ("piglin_head", "entity/piglin/piglin"), - SkullType::Player => ("player_head", "entity/player/slim/steve"), + SkullType::Player => ("player_head", "entity/player/wide/steve"), + }; + // SkullBlockRenderer.getRenderType: the profile's skin when it + // resolves, `SKIN_BY_TYPE` (steve) otherwise. + let skin; + let texture = if *kind == SkullType::Player { + skin = (scene.skull)(pos); + skin.as_deref().unwrap_or(texture) + } else { + texture }; let (Some(model), Some(paint)) = (self.models.get(model), paint(texture, 0xFFFFFF, packed)) @@ -1886,6 +1899,7 @@ mod tests { lid: &|_| 0.0, sign: &|_| None, banner: &|_| Vec::new(), + skull: &|_| None, glyph: &|_| (None, 0.0), }; // Compare the cached world path with the original model renderer, diff --git a/crates/horizon-client/src/containers.rs b/crates/horizon-client/src/containers.rs index de2e1b2e9..7c9da6862 100644 --- a/crates/horizon-client/src/containers.rs +++ b/crates/horizon-client/src/containers.rs @@ -79,6 +79,17 @@ pub enum BlockEntity { Beehive(Box), /// `CommandBlockEntity` of the three command blocks (`crate::command_block`). CommandBlock(Box), + /// `SkullBlockEntity` of every skull and head block. + Skull(Skull), +} +/// `SkullBlockEntity`: the player profile the head shows (kept as loaded — +/// `SkullOwner` is a compound, or a string when it names a player only), +/// the note block sound and `custom_name`. +#[derive(Clone, Debug, Default)] +pub struct Skull { + pub profile: Option, + pub note_block_sound: Option, + pub custom_name: Option, } /// `CrafterBlockEntity`: nine slots that can be disabled, the powered flag /// and the ticks left in the crafting animation. @@ -233,6 +244,9 @@ impl BlockEntity { if name.ends_with("_banner") { return Some(Self::Banner(Banner::default())); } + if name.ends_with("_head") || name.ends_with("_skull") { + return Some(Self::Skull(Skull::default())); + } if name == "minecraft:beacon" { return Some(Self::Beacon(Box::new(Beacon { last_check_y: i32::MIN / 2, @@ -278,6 +292,7 @@ impl BlockEntity { Self::Vault(_) => "minecraft:vault", Self::Beehive(_) => "minecraft:beehive", Self::CommandBlock(_) => "minecraft:command_block", + Self::Skull(_) => "minecraft:skull", } } pub fn contents(&self) -> Vec { @@ -293,7 +308,8 @@ impl BlockEntity { | Self::TrialSpawner(_) | Self::Vault(_) | Self::Beehive(_) - | Self::CommandBlock(_) => Vec::new(), + | Self::CommandBlock(_) + | Self::Skull(_) => Vec::new(), Self::Lectern(l) => l.book.iter().cloned().collect(), Self::Sculk(_) => Vec::new(), Self::Banner(_) => Vec::new(), @@ -310,7 +326,8 @@ impl BlockEntity { | Self::Beacon(_) | Self::Lectern(_) | Self::Sculk(_) - | Self::Banner(_) => &[], + | Self::Banner(_) + | Self::Skull(_) => &[], Self::Crafter(c) => &c.items, Self::CreakingHeart(_) | Self::Spawner(_) @@ -330,7 +347,8 @@ impl BlockEntity { | Self::Beacon(_) | Self::Lectern(_) | Self::Sculk(_) - | Self::Banner(_) => &mut [], + | Self::Banner(_) + | Self::Skull(_) => &mut [], Self::Crafter(c) => &mut c.items, Self::CreakingHeart(_) | Self::Spawner(_) diff --git a/crates/horizon-client/src/game.rs b/crates/horizon-client/src/game.rs index 52d7ce8dd..bfdebe44a 100644 --- a/crates/horizon-client/src/game.rs +++ b/crates/horizon-client/src/game.rs @@ -5133,7 +5133,8 @@ impl Game<'_> { | BlockEntity::TrialSpawner(_) | BlockEntity::Vault(_) | BlockEntity::Beehive(_) - | BlockEntity::CommandBlock(_), + | BlockEntity::CommandBlock(_) + | BlockEntity::Skull(_), ) => {} None => { v.extend((0..self.craft_size * self.craft_size).map(|i| 100 + i)); @@ -5392,7 +5393,8 @@ impl Game<'_> { | BlockEntity::TrialSpawner(_) | BlockEntity::Vault(_) | BlockEntity::Beehive(_) - | BlockEntity::CommandBlock(_), + | BlockEntity::CommandBlock(_) + | BlockEntity::Skull(_), ) => {} None if self.mount_active() => self.draw_mount_background(batch, ox, oy), None => { @@ -6884,6 +6886,7 @@ impl Game<'_> { _ => None, }, banner: &|p| self.banner_layers_at(p), + skull: &|p| self.skull_skin_at(p), glyph: &|c| self.gui.atlas.glyph_cell(c), }; // Block entities outside the view frustum are skipped (with a diff --git a/crates/horizon-client/src/game/block_entity_anims.rs b/crates/horizon-client/src/game/block_entity_anims.rs index 619fcd009..136738350 100644 --- a/crates/horizon-client/src/game/block_entity_anims.rs +++ b/crates/horizon-client/src/game/block_entity_anims.rs @@ -8,8 +8,10 @@ use horizon_client::{ block_entity_anim::{BellEntity, EndGateway, Shulker, ShulkerStatus, Ticker}, block_entity_render::BlockAnim, collisions::{SceneCollisions, no_collision_empty}, + containers::BlockEntity, particles::{ParticleOptions, ParticleType}, save::number, + skins, }; use horizon_core::geometry::{Aabb, Vec3}; use horizon_world::nbt::Tag; @@ -392,4 +394,34 @@ impl Game<'_> { pub(super) fn chest_lid(&self, pos: [i32; 3], partial: f32) -> f32 { self.be_anims.lid(pos, partial) } + /// `SkullBlockRenderer.getPlayerSkin`: the skin sprite of the `profile` of + /// the player head at `pos`. The skin download is started here; while it + /// is in flight (or when it cannot be got) the profile's uuid picks the + /// `DefaultPlayerSkin` for it, and a profile with no id keeps steve. A + /// head with no profile answers None so `SKIN_BY_TYPE` applies. + pub(super) fn skull_skin_at(&self, pos: [i32; 3]) -> Option { + let key = (pos[0], pos[1], pos[2]); + let profile = match self.world.block_entities.get(&key) { + Some(BlockEntity::Skull(s)) => s.profile.clone(), + _ => None, + } + .or_else(|| self.saved_tag(pos).and_then(|t| t.get("profile").cloned())); + let profile = profile?; + if let Some(url) = skins::profile_skin_url_nbt(&profile) + && let Some(location) = + skins::texture_hash(&url).map(|hash| skins::skin_location(&hash)) + { + self.skin_downloads + .borrow_mut() + .state(skins::Kind::Skin, &url); + if self.gui.atlas.sprites.contains_key(&location) { + return Some(location); + } + } + Some( + skins::profile_uuid_nbt(&profile) + .map(|uuid| horizon_client::tab_list::default_skin(uuid).to_owned()) + .unwrap_or_else(|| "entity/player/wide/steve".to_owned()), + ) + } } diff --git a/crates/horizon-client/src/game/minecarts.rs b/crates/horizon-client/src/game/minecarts.rs index 6b8b51dde..8d4920b48 100644 --- a/crates/horizon-client/src/game/minecarts.rs +++ b/crates/horizon-client/src/game/minecarts.rs @@ -1463,6 +1463,7 @@ impl Game<'_> { lid: &lid, sign: &|_| None, banner: &|_| Vec::new(), + skull: &|_| None, glyph: &|c| self.gui.atlas.glyph_cell(c), }; self.res diff --git a/crates/horizon-client/src/lan/chunks.rs b/crates/horizon-client/src/lan/chunks.rs index 65b092881..d7dcc6cd8 100644 --- a/crates/horizon-client/src/lan/chunks.rs +++ b/crates/horizon-client/src/lan/chunks.rs @@ -937,6 +937,20 @@ pub fn entity_tag(entity: &BlockEntity) -> Option { match entity { BlockEntity::Sign(sign) => Some(Tag::compound(sign.encode())), BlockEntity::Spawner(s) => Some(s.update_tag()), + // SkullBlockEntity: the profile is the whole reason a head differs. + BlockEntity::Skull(s) => { + let mut entries = Vec::new(); + if let Some(profile) = &s.profile { + entries.push(("profile", profile.clone())); + } + if let Some(sound) = &s.note_block_sound { + entries.push(("note_block_sound", Tag::String(sound.as_str().into()))); + } + if let Some(name) = &s.custom_name { + entries.push(("custom_name", name.clone())); + } + Some(Tag::compound(entries)) + } BlockEntity::Jukebox(_) | BlockEntity::Lectern(_) => None, _ => None, } diff --git a/crates/horizon-client/src/save.rs b/crates/horizon-client/src/save.rs index da5735c17..c59c3c974 100644 --- a/crates/horizon-client/src/save.rs +++ b/crates/horizon-client/src/save.rs @@ -548,6 +548,17 @@ pub fn encode_block_entity( entries.push(("creaking", uuid_tag(uuid))); } } + BlockEntity::Skull(s) => { + if let Some(profile) = &s.profile { + entries.push(("profile", profile.clone())); + } + if let Some(sound) = &s.note_block_sound { + entries.push(("note_block_sound", string(sound))); + } + if let Some(name) = &s.custom_name { + entries.push(("custom_name", name.clone())); + } + } BlockEntity::Spawner(s) => entries.extend(s.save()), BlockEntity::TrialSpawner(s) => entries.extend(s.save()), BlockEntity::Vault(v) => entries.extend(v.save()), @@ -622,6 +633,19 @@ pub fn decode_block_entity(tag: &Tag) -> Option<((i32, i32, i32), crate::contain }; return Some((pos, BlockEntity::Beacon(Box::new(beacon)))); } + // A skull's block entity id is not its block's name (every head block). + if id == "minecraft:skull" { + return Some(( + pos, + BlockEntity::Skull(crate::containers::Skull { + profile: tag.get("profile").cloned(), + note_block_sound: text(tag.get("note_block_sound")), + custom_name: tag + .get("custom_name") + .and_then(crate::block_entity_nbt::component), + }), + )); + } // A spawner's block entity id is not its block's name. let block = match id.as_str() { "minecraft:mob_spawner" => "minecraft:spawner", @@ -683,7 +707,8 @@ pub fn decode_block_entity(tag: &Tag) -> Option<((i32, i32, i32), crate::contain | BlockEntity::Beacon(_) | BlockEntity::Lectern(_) | BlockEntity::Banner(_) - | BlockEntity::CreakingHeart(_) => {} + | BlockEntity::CreakingHeart(_) + | BlockEntity::Skull(_) => {} BlockEntity::Spawner(s) => **s = crate::mobs::spawner::Spawner::load(tag), BlockEntity::TrialSpawner(s) => **s = crate::mobs::trial_spawner::TrialSpawner::load(tag), BlockEntity::Vault(v) => **v = crate::vault::Vault::load(tag), @@ -3876,6 +3901,47 @@ mod tests { } use super::*; + #[test] + fn skull_block_entity_keeps_its_profile() { + // A placed `player_head` as vanilla saves it: the owning player's + // `profile` survives load, encode and `canonical`. + let saved = horizon_world::nbt::parse_snbt( + r#"{id:"minecraft:skull",x:10,y:64,z:20,profile:{name:"Steve",id:[I;1,2,3,4],properties:[{name:"textures",value:"abc"}]},note_block_sound:"minecraft:entity.player.hurt",custom_name:"Trophy"}"#, + ) + .unwrap() + .0; + let (pos, back) = decode_block_entity(&saved).expect("skull"); + assert_eq!(pos, (10, 64, 20)); + let crate::containers::BlockEntity::Skull(skull) = &back else { + panic!("not a skull"); + }; + assert_eq!(skull.profile, saved.get("profile").cloned()); + assert_eq!( + skull.note_block_sound.as_deref(), + Some("minecraft:entity.player.hurt") + ); + assert_eq!(back.id(), "minecraft:skull"); + let tag = encode_block_entity(pos, &back, "minecraft:player_head"); + assert_eq!( + crate::block_entity_nbt::id(&tag).as_deref(), + Some("minecraft:skull") + ); + assert_eq!(tag.get("profile"), saved.get("profile")); + let (_, again) = decode_block_entity(&tag).expect("skull again"); + let crate::containers::BlockEntity::Skull(again) = again else { + panic!("not a skull"); + }; + assert_eq!(again.profile, skull.profile); + // A profile-less head (skeleton, creeper) round-trips too. + let plain = encode_block_entity( + pos, + &crate::containers::BlockEntity::Skull(crate::containers::Skull::default()), + "minecraft:creeper_head", + ); + let (_, decoded) = decode_block_entity(&plain).expect("plain skull"); + assert!(matches!(decoded, crate::containers::BlockEntity::Skull(_))); + } + #[test] fn uuid_text_round_trips() { let u = [-158327916, 1572358581, -2125825222, -487948715]; diff --git a/crates/horizon-client/src/skins.rs b/crates/horizon-client/src/skins.rs index 9014032c4..ee6851e00 100644 --- a/crates/horizon-client/src/skins.rs +++ b/crates/horizon-client/src/skins.rs @@ -130,6 +130,47 @@ pub fn profile_skin_url(profile: &serde_json::Value) -> Option { unpack(value, Signature::Unsigned, &TEXTURE_URIS).skin } +/// `profile_skin_url` on a block entity's `profile` NBT (`SkullBlockEntity`): +/// the same `properties` list, held as a compound. A name-only profile (a +/// string tag) has no properties and no skin URL. +pub fn profile_skin_url_nbt(profile: &horizon_world::nbt::Tag) -> Option { + let properties = match profile.get("properties")? { + horizon_world::nbt::Tag::List(list) => list, + _ => return None, + }; + let value = properties.iter().find_map(|p| { + let name = nbt_text(p.get("name"))?; + (name == "textures") + .then(|| nbt_text(p.get("value"))) + .flatten() + })?; + unpack(&value, Signature::Unsigned, &TEXTURE_URIS).skin +} + +/// The profile's uuid as u128: `id` as an int array (block entity NBT) or a +/// uuid string (older and component forms). Used for `DefaultPlayerSkin.get` +/// when a head's skin is not downloaded yet. +pub fn profile_uuid_nbt(profile: &horizon_world::nbt::Tag) -> Option { + match profile.get("id")? { + horizon_world::nbt::Tag::IntArray(v) if v.len() == 4 => Some( + v.iter() + .fold(0u128, |a, &w| (a << 32) | u128::from(w as u32)), + ), + horizon_world::nbt::Tag::String(s) => { + let digits: String = s.to_string_lossy().chars().filter(|c| *c != '-').collect(); + u128::from_str_radix(&digits, 16).ok() + } + _ => None, + } +} + +fn nbt_text(tag: Option<&horizon_world::nbt::Tag>) -> Option { + match tag { + Some(horizon_world::nbt::Tag::String(s)) => Some(s.to_string_lossy()), + _ => None, + } +} + /// `MinecraftProfileTexture.getHash`: the base name of the URL's path. pub fn texture_hash(url: &str) -> Option { let rest = url.split_once("://")?.1; @@ -457,6 +498,42 @@ mod tests { use super::*; + #[test] + fn skull_block_entity_profiles_supply_head_skins() { + let value = "eyJ0ZXh0dXJlcyI6IHsiU0tJTiI6IHsidXJsIjogImh0dHBzOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlL2FiYzEyMyJ9fX0="; + let profile = horizon_world::nbt::parse_snbt(&format!( + r#"{{name:"T",id:[I;-158327916,1572358581,-2125825222,-487948715],properties:[{{name:"textures",value:"{value}"}}]}}"# + )) + .unwrap() + .0; + assert_eq!( + super::profile_skin_url_nbt(&profile).as_deref(), + Some("https://textures.minecraft.net/texture/abc123") + ); + assert_eq!( + super::profile_uuid_nbt(&profile), + Some( + [-158327916, 1572358581, -2125825222, -487948715] + .iter() + .fold(0u128, |a, &w: &i32| (a << 32) | u128::from(w as u32)) + ) + ); + // A name-only profile (a string tag) has no properties: no url, no id. + let named = horizon_world::nbt::Tag::String("MHF_Blaze".into()); + assert_eq!(super::profile_skin_url_nbt(&named), None); + assert_eq!(super::profile_uuid_nbt(&named), None); + // A uuid in string form decodes too. + let text_id = horizon_world::nbt::parse_snbt( + r#"{name:"T",id:"e843a1f4-0000-0001-0000-000200000003"}"#, + ) + .unwrap() + .0; + assert_eq!( + super::profile_uuid_nbt(&text_id), + Some(u128::from_str_radix("e843a1f4000000010000000200000003", 16).unwrap()) + ); + } + #[test] fn sha1_and_base64() { let hex: String = sha1(b"abc").iter().map(|b| format!("{b:02x}")).collect(); From 6824224a333df0771dcf085566cb898416463be3 Mon Sep 17 00:00:00 2001 From: Ludovic Marie <136255825+ludovic111@users.noreply.github.com> Date: Mon, 26 Oct 2026 00:06:22 +0100 Subject: [PATCH 3/4] Player heads: read the profile's skin once, and no skull on a piston head - Skull keeps what its profile draws (the skin URL, its skins/ sprite and the default skin), computed when the block entity loads, instead of decoding base64 JSON and hashing it for every head every frame; skull_skin_at no longer scans the chunk's saved block entities. - BlockEntity::for_block gave minecraft:piston_head a skull block entity (it ends in _head), which would have been saved as minecraft:skull. - AGENTS.md is left as it is on main: the workflow note is not part of this fix. Co-Authored-By: Claude Opus 5.5 --- AGENTS.md | 4 -- .../horizon-client/src/block_entity_render.rs | 6 +-- crates/horizon-client/src/containers.rs | 50 +++++++++++++++++-- .../src/game/block_entity_anims.rs | 37 ++++++-------- crates/horizon-client/src/save.rs | 18 ++++--- 5 files changed, 74 insertions(+), 41 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index ed76c08dd..2d883b33b 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -27,10 +27,6 @@ Feature → files → harness for the most-changed areas: [docs/architecture.md] change), none for a fix. Agents never add `release-now`: the maintainer decides it. Merges ship in batches of 5, or after 6 hours ([docs/release-flow.md](docs/release-flow.md)). - Contributors first: `gh pr list --state open --search ` before you start; never duplicate theirs. -- Asked for a feature? Run the whole loop: check open PRs for the area (above), work in a new worktree, - `git fetch` the upstream remote (`ludovic111/horizon`) and start from its latest `main`, build, run - `tools/pr_ready.py`, then push to your fork and open the pull request against upstream's `main` — - never against the fork itself. ## Crates diff --git a/crates/horizon-client/src/block_entity_render.rs b/crates/horizon-client/src/block_entity_render.rs index a863d6214..620640188 100644 --- a/crates/horizon-client/src/block_entity_render.rs +++ b/crates/horizon-client/src/block_entity_render.rs @@ -733,7 +733,7 @@ pub struct Scene<'a> { /// The skin sprite a `player_head` shows at a position (`SkullBlockRenderer` /// profile → skin): a downloaded `skins/` slot or the profile's /// `DefaultPlayerSkin` fallback; None keeps `SKIN_BY_TYPE` (steve). - pub skull: &'a dyn Fn([i32; 3]) -> Option, + pub skull: &'a dyn Fn([i32; 3]) -> Option<&'a str>, /// Font glyph cell (none for blank glyphs such as the space) and advance. pub glyph: &'a dyn Fn(char) -> (Option, f32), } @@ -1285,10 +1285,8 @@ impl BlockEntityRenderer { }; // SkullBlockRenderer.getRenderType: the profile's skin when it // resolves, `SKIN_BY_TYPE` (steve) otherwise. - let skin; let texture = if *kind == SkullType::Player { - skin = (scene.skull)(pos); - skin.as_deref().unwrap_or(texture) + (scene.skull)(pos).unwrap_or(texture) } else { texture }; diff --git a/crates/horizon-client/src/containers.rs b/crates/horizon-client/src/containers.rs index 7c9da6862..1f8fad151 100644 --- a/crates/horizon-client/src/containers.rs +++ b/crates/horizon-client/src/containers.rs @@ -82,14 +82,56 @@ pub enum BlockEntity { /// `SkullBlockEntity` of every skull and head block. Skull(Skull), } -/// `SkullBlockEntity`: the player profile the head shows (kept as loaded — -/// `SkullOwner` is a compound, or a string when it names a player only), -/// the note block sound and `custom_name`. +/// `SkullBlockEntity`: the player profile the head shows (kept as loaded: +/// a compound, or a string when it names a player only), the note block +/// sound and `custom_name`. #[derive(Clone, Debug, Default)] pub struct Skull { pub profile: Option, pub note_block_sound: Option, pub custom_name: Option, + /// What `profile` draws, read from it once rather than every frame. + pub skin: Option, +} +impl Skull { + pub fn new( + profile: Option, + note_block_sound: Option, + custom_name: Option, + ) -> Self { + let skin = profile.as_ref().map(SkullSkin::of); + Self { + profile, + note_block_sound, + custom_name, + skin, + } + } +} +/// `SkullBlockRenderer.getPlayerSkin` of a head's profile: its skin's URL +/// with the `skins/` sprite it downloads to, and the +/// `DefaultPlayerSkin` drawn until that sprite is there (steve for a +/// profile with no id). +#[derive(Clone, Debug)] +pub struct SkullSkin { + pub download: Option<(String, String)>, + pub fallback: &'static str, +} +impl SkullSkin { + pub fn of(profile: &horizon_world::nbt::Tag) -> Self { + let download = crate::skins::profile_skin_url_nbt(profile).and_then(|url| { + let location = crate::skins::skin_location(&crate::skins::texture_hash(&url)?); + Some((url, location)) + }); + let fallback = crate::skins::profile_uuid_nbt(profile) + .map_or("entity/player/wide/steve", crate::tab_list::default_skin); + Self { download, fallback } + } +} +/// The skull and head blocks (`SkullBlock`, `WallSkullBlock`): every +/// `*_skull` and `*_head` but the piston's head. +fn is_skull(name: &str) -> bool { + name.ends_with("_skull") || (name.ends_with("_head") && name != "minecraft:piston_head") } /// `CrafterBlockEntity`: nine slots that can be disabled, the powered flag /// and the ticks left in the crafting animation. @@ -244,7 +286,7 @@ impl BlockEntity { if name.ends_with("_banner") { return Some(Self::Banner(Banner::default())); } - if name.ends_with("_head") || name.ends_with("_skull") { + if is_skull(name) { return Some(Self::Skull(Skull::default())); } if name == "minecraft:beacon" { diff --git a/crates/horizon-client/src/game/block_entity_anims.rs b/crates/horizon-client/src/game/block_entity_anims.rs index 136738350..55f9c42ba 100644 --- a/crates/horizon-client/src/game/block_entity_anims.rs +++ b/crates/horizon-client/src/game/block_entity_anims.rs @@ -394,34 +394,25 @@ impl Game<'_> { pub(super) fn chest_lid(&self, pos: [i32; 3], partial: f32) -> f32 { self.be_anims.lid(pos, partial) } - /// `SkullBlockRenderer.getPlayerSkin`: the skin sprite of the `profile` of + /// `SkullBlockRenderer.getPlayerSkin`: the skin sprite of the profile of /// the player head at `pos`. The skin download is started here; while it - /// is in flight (or when it cannot be got) the profile's uuid picks the - /// `DefaultPlayerSkin` for it, and a profile with no id keeps steve. A - /// head with no profile answers None so `SKIN_BY_TYPE` applies. - pub(super) fn skull_skin_at(&self, pos: [i32; 3]) -> Option { - let key = (pos[0], pos[1], pos[2]); - let profile = match self.world.block_entities.get(&key) { - Some(BlockEntity::Skull(s)) => s.profile.clone(), - _ => None, - } - .or_else(|| self.saved_tag(pos).and_then(|t| t.get("profile").cloned())); - let profile = profile?; - if let Some(url) = skins::profile_skin_url_nbt(&profile) - && let Some(location) = - skins::texture_hash(&url).map(|hash| skins::skin_location(&hash)) - { + /// is in flight (or when it cannot be got) the profile's default skin + /// stands in. A head with no profile answers None: `SKIN_BY_TYPE`. + pub(super) fn skull_skin_at(&self, pos: [i32; 3]) -> Option<&str> { + let Some(BlockEntity::Skull(skull)) = + self.world.block_entities.get(&(pos[0], pos[1], pos[2])) + else { + return None; + }; + let skin = skull.skin.as_ref()?; + if let Some((url, location)) = &skin.download { self.skin_downloads .borrow_mut() - .state(skins::Kind::Skin, &url); - if self.gui.atlas.sprites.contains_key(&location) { + .state(skins::Kind::Skin, url); + if self.gui.atlas.sprites.contains_key(location) { return Some(location); } } - Some( - skins::profile_uuid_nbt(&profile) - .map(|uuid| horizon_client::tab_list::default_skin(uuid).to_owned()) - .unwrap_or_else(|| "entity/player/wide/steve".to_owned()), - ) + Some(skin.fallback) } } diff --git a/crates/horizon-client/src/save.rs b/crates/horizon-client/src/save.rs index c59c3c974..964a32cb4 100644 --- a/crates/horizon-client/src/save.rs +++ b/crates/horizon-client/src/save.rs @@ -637,13 +637,12 @@ pub fn decode_block_entity(tag: &Tag) -> Option<((i32, i32, i32), crate::contain if id == "minecraft:skull" { return Some(( pos, - BlockEntity::Skull(crate::containers::Skull { - profile: tag.get("profile").cloned(), - note_block_sound: text(tag.get("note_block_sound")), - custom_name: tag - .get("custom_name") + BlockEntity::Skull(crate::containers::Skull::new( + tag.get("profile").cloned(), + text(tag.get("note_block_sound")), + tag.get("custom_name") .and_then(crate::block_entity_nbt::component), - }), + )), )); } // A spawner's block entity id is not its block's name. @@ -3940,6 +3939,13 @@ mod tests { ); let (_, decoded) = decode_block_entity(&plain).expect("plain skull"); assert!(matches!(decoded, crate::containers::BlockEntity::Skull(_))); + // The heads and skulls have one; the piston's head is no skull. + use crate::containers::BlockEntity; + assert!(matches!( + BlockEntity::for_block("minecraft:player_wall_head"), + Some(BlockEntity::Skull(_)) + )); + assert!(BlockEntity::for_block("minecraft:piston_head").is_none()); } #[test] From c89434557b2a60283485d28fea0ed0b6806c6fc3 Mon Sep 17 00:00:00 2001 From: Ludovic Marie <136255825+ludovic111@users.noreply.github.com> Date: Mon, 26 Oct 2026 04:09:25 +0100 Subject: [PATCH 4/4] Player heads without a skin show slim steve, as vanilla SkullBlockRenderer's SKIN_BY_TYPE is DefaultPlayerSkin.getDefaultTexture(), DEFAULT_SKINS[6] = entity/player/slim/steve; the block_entity_render harness found Horizon drawing nothing for heads without a profile. Co-Authored-By: Claude Opus 5.5 --- crates/horizon-client/src/block_entity_render.rs | 4 ++-- crates/horizon-client/src/containers.rs | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/crates/horizon-client/src/block_entity_render.rs b/crates/horizon-client/src/block_entity_render.rs index 620640188..10c5e2509 100644 --- a/crates/horizon-client/src/block_entity_render.rs +++ b/crates/horizon-client/src/block_entity_render.rs @@ -732,7 +732,7 @@ pub struct Scene<'a> { pub banner: &'a dyn Fn([i32; 3]) -> Vec<(String, u32)>, /// The skin sprite a `player_head` shows at a position (`SkullBlockRenderer` /// profile → skin): a downloaded `skins/` slot or the profile's - /// `DefaultPlayerSkin` fallback; None keeps `SKIN_BY_TYPE` (steve). + /// `DefaultPlayerSkin` fallback; None keeps `SKIN_BY_TYPE` (`DefaultPlayerSkin.getDefaultTexture`, slim steve). pub skull: &'a dyn Fn([i32; 3]) -> Option<&'a str>, /// Font glyph cell (none for blank glyphs such as the space) and advance. pub glyph: &'a dyn Fn(char) -> (Option, f32), @@ -1281,7 +1281,7 @@ impl BlockEntityRenderer { SkullType::Creeper => ("creeper_head", "entity/creeper/creeper"), SkullType::Dragon => ("dragon_skull", "entity/enderdragon/dragon"), SkullType::Piglin => ("piglin_head", "entity/piglin/piglin"), - SkullType::Player => ("player_head", "entity/player/wide/steve"), + SkullType::Player => ("player_head", "entity/player/slim/steve"), }; // SkullBlockRenderer.getRenderType: the profile's skin when it // resolves, `SKIN_BY_TYPE` (steve) otherwise. diff --git a/crates/horizon-client/src/containers.rs b/crates/horizon-client/src/containers.rs index 1f8fad151..a968408db 100644 --- a/crates/horizon-client/src/containers.rs +++ b/crates/horizon-client/src/containers.rs @@ -123,8 +123,9 @@ impl SkullSkin { let location = crate::skins::skin_location(&crate::skins::texture_hash(&url)?); Some((url, location)) }); + // DefaultPlayerSkin.get(id), or getDefaultSkin (slim steve) without an id. let fallback = crate::skins::profile_uuid_nbt(profile) - .map_or("entity/player/wide/steve", crate::tab_list::default_skin); + .map_or("entity/player/slim/steve", crate::tab_list::default_skin); Self { download, fallback } } }