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]