From a6d2eb9d6421d1bbf54c4fb366438a70682946de Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Mon, 26 Oct 2026 18:17:27 +0100 Subject: [PATCH 01/36] Shulkers keep their body still while the head turns --- crates/horizon-client/src/mobs/control.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/crates/horizon-client/src/mobs/control.rs b/crates/horizon-client/src/mobs/control.rs index 3df557362..70a40b23f 100644 --- a/crates/horizon-client/src/mobs/control.rs +++ b/crates/horizon-client/src/mobs/control.rs @@ -389,6 +389,13 @@ impl Mob { } /// BodyRotationControl.clientTick (Mob.tickHeadTurn). pub fn body_rotation_tick(&mut self) { + // Shulker.ShulkerBodyRotationControl.clientTick is empty: the body + // stays at 0 (recreateFromPacket), only the head turns. + if self.species() == super::Species::Shulker { + self.body_yaw = 0.0; + self.previous_body_yaw = 0.0; + return; + } let dx = self.position.x - self.previous.x; let dz = self.position.z - self.previous.z; let max = self.kind.max_head_y_rot; From e92937d956f8f2d5bb57bd945f80de91cece120c Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Mon, 26 Oct 2026 18:44:23 +0100 Subject: [PATCH 02/36] Apply Slowness with Bane of Arthropods Post-attack effects only handled ignite, so the apply_mob_effect effect of Bane of Arthropods never did anything. Handle apply_mob_effect like vanilla. --- .../src/game/enchant_effects.rs | 80 ++++++++++++++----- crates/horizon-client/src/game/potions.rs | 2 +- 2 files changed, 63 insertions(+), 19 deletions(-) diff --git a/crates/horizon-client/src/game/enchant_effects.rs b/crates/horizon-client/src/game/enchant_effects.rs index 7cdb3e526..ac194dcba 100644 --- a/crates/horizon-client/src/game/enchant_effects.rs +++ b/crates/horizon-client/src/game/enchant_effects.rs @@ -153,8 +153,10 @@ impl Game<'_> { items: Some(self.res.items()), ..Default::default() }; - // minecraft:post_attack ignite effects of the attacker's weapon (fire aspect). + // minecraft:post_attack effects of the attacker's weapon on the victim: + // ignite (fire aspect) and apply_mob_effect (bane of arthropods). let mut ignite = 0.0f32; + let mut mob_effects = Vec::new(); for (id, level) in held.enchantments() { let Some(def) = self.res.stations().enchantments.get(id) else { continue; @@ -164,24 +166,33 @@ impl Game<'_> { .into_iter() .flatten() { - if effect["enchanted"] == "attacker" - && effect["affected"] == "victim" - && effect["effect"]["type"] == "minecraft:ignite" + let e = &effect["effect"]; + let kind_of = e["type"].as_str(); + if effect["enchanted"] != "attacker" + || effect["affected"] != "victim" + || !matches!( + kind_of, + Some("minecraft:ignite" | "minecraft:apply_mob_effect") + ) { - let mut random = self.world.random.clone(); - let ok = effect.get("requirements").is_none_or(|r| { - self.res - .stations() - .enchantments - .condition(r, *level, &ctx, &mut random) - }); - self.world.random = random; - if ok { - ignite = ignite.max(horizon_client::enchant::level_value( - &effect["effect"]["duration"], - *level, - )); - } + continue; + } + let mut random = self.world.random.clone(); + let ok = effect.get("requirements").is_none_or(|r| { + self.res + .stations() + .enchantments + .condition(r, *level, &ctx, &mut random) + }); + self.world.random = random; + if !ok { + continue; + } + if kind_of == Some("minecraft:ignite") { + ignite = + ignite.max(horizon_client::enchant::level_value(&e["duration"], *level)); + } else { + mob_effects.push((e.clone(), *level)); } } } @@ -191,8 +202,41 @@ impl Game<'_> { { m.ignite_for_ticks((ignite * 20.0) as i32); } + for (effect, level) in mob_effects { + self.apply_mob_effect(mob, &effect, level); + } self.post_attack_bursts(&held, &kind); } + /// `ApplyMobEffect.apply`: one of `to_apply` (a single id or a list) for a + /// random duration and amplifier between the level-based bounds. + fn apply_mob_effect(&mut self, mob: usize, effect: &serde_json::Value, level: u32) { + use horizon_client::enchant::level_value; + let Some(m) = self.mobs.get_mut(mob) else { + return; + }; + let ids: Vec<&str> = match &effect["to_apply"] { + serde_json::Value::String(id) => vec![id.as_str()], + serde_json::Value::Array(list) => list.iter().filter_map(|v| v.as_str()).collect(), + _ => Vec::new(), + }; + if ids.is_empty() { + return; + } + // HolderSet.getRandomElement, then Mth.randomBetween for both values. + let pick = m.random.next_int_bound(ids.len() as i32).unwrap_or(0) as usize; + let mut between = |min: &str, max: &str| { + let (lo, hi) = ( + level_value(&effect[min], level), + level_value(&effect[max], level), + ); + m.random.next_float() * (hi - lo) + lo + }; + let ticks = (between("min_duration", "max_duration") * 20.0).round() as i32; + let amplifier = (between("min_amplifier", "max_amplifier").round() as i32).max(0); + if let Some(id) = super::potions::mob_effect_id(ids[pick]) { + m.add_effect(id, ticks, amplifier); + } + } /// `minecraft:post_attack` explode effects on the attacker (wind burst): /// a burst at the player's feet that only knocks back and triggers /// blocks (`ExplodeEffect` with `block_interaction: trigger`). diff --git a/crates/horizon-client/src/game/potions.rs b/crates/horizon-client/src/game/potions.rs index 13eae7d3e..834f6f708 100644 --- a/crates/horizon-client/src/game/potions.rs +++ b/crates/horizon-client/src/game/potions.rs @@ -28,7 +28,7 @@ pub(super) struct ThrownPotion { age: u32, } /// A mob's effect ids carry the `minecraft:` namespace. -fn mob_effect_id(id: &str) -> Option<&'static str> { +pub(super) fn mob_effect_id(id: &str) -> Option<&'static str> { use std::{collections::HashMap, sync::OnceLock}; static IDS: OnceLock> = OnceLock::new(); let id = id.trim_start_matches("minecraft:"); From 555ddb94bf8a20bf241dde847137fea335f2b2eb Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Mon, 26 Oct 2026 18:45:13 +0100 Subject: [PATCH 03/36] Use the impaling entity tag for thrown tridents The bonus went to every swimming or water-breathing mob, including undead, blazes, ghasts and iron golems. Read the damage from the enchantment data so only #sensitive_to_impaling mobs take it. --- crates/horizon-client/src/game/trident.rs | 29 +++++++++++++++++++---- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/crates/horizon-client/src/game/trident.rs b/crates/horizon-client/src/game/trident.rs index c31094596..9e7f9f65d 100644 --- a/crates/horizon-client/src/game/trident.rs +++ b/crates/horizon-client/src/game/trident.rs @@ -5,6 +5,7 @@ use super::{Game, view_vector}; use horizon_client::{ collisions::SceneCollisions, + enchant::EffectContext, items::ItemStack, mesher::Vertex, mobs::{Damage, DamageKind, Who, anim::Poses}, @@ -305,11 +306,29 @@ impl Game<'_> { } } if let Some((id, _)) = hit_mob { - let impaling = t.stack.enchantment_level("minecraft:impaling") as f32; - let aquatic = self.mobs.iter().find(|m| m.id == id).is_some_and(|m| { - m.kind.flags.aquatic_swimmer || m.kind.flags.breathes_water - }); - let damage = 8.0 + if aquatic { 2.5 * impaling } else { 0.0 }; + // ThrownTrident.getDamage: `EnchantmentHelper.modifyDamage` on 8 + // (impaling hits `#sensitive_to_impaling`, the aquatic tag). + let victim = self + .mobs + .iter() + .find(|m| m.id == id) + .map(|m| m.kind.id.clone()); + let ctx = EffectContext { + this: victim.as_deref(), + attacker: Some("minecraft:player"), + direct_attacker: Some("minecraft:trident"), + is_direct: true, + damage_type: Some("minecraft:trident"), + items: Some(self.res.items()), + ..Default::default() + }; + let damage = self.res.stations().enchantments.modify_value( + Some(&t.stack), + "minecraft:damage", + &ctx, + &mut self.world.random, + 8.0, + ); t.dealt_damage = true; if let Some(m) = self.mobs.iter_mut().find(|m| m.id == id) { let from = Some([t.position.x, t.position.y, t.position.z]); From 564b230ab168a3be7c0e468ae546acd72fd8dc7e Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Mon, 26 Oct 2026 18:45:13 +0100 Subject: [PATCH 04/36] Make a warden's hit disable the player's shield A warden holds no weapon, so its blows never put the shield on cooldown. Warden.getSecondsToDisableBlocking is a flat 5 seconds, so use that when the attacker is a warden. --- crates/horizon-client/src/game/shield.rs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/crates/horizon-client/src/game/shield.rs b/crates/horizon-client/src/game/shield.rs index c4f7f98d1..a26bc5d75 100644 --- a/crates/horizon-client/src/game/shield.rs +++ b/crates/horizon-client/src/game/shield.rs @@ -182,12 +182,17 @@ impl Game<'_> { return; }; let (mx, mz) = (m.position.x, m.position.z); - let disable = m - .extra - .main_hand - .as_deref() - .and_then(|item| self.res.items().get(item)) - .map_or(0.0, |i| i.disable_blocking_seconds); + // LivingEntity.getSecondsToDisableBlocking: the held weapon's value; + // Warden overrides it with a flat 5 seconds. + let disable = if m.species() == horizon_client::mobs::Species::Warden { + 5.0 + } else { + m.extra + .main_hand + .as_deref() + .and_then(|item| self.res.items().get(item)) + .map_or(0.0, |i| i.disable_blocking_seconds) + }; // Ravager.blockedByItem: stunned half the time (the defender pushed // apart), else the defender flung away; no roar in progress. if m.species() == horizon_client::mobs::Species::Ravager { From dbef78bcb82f2b123f17c3358aa65aa7953a4f41 Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Mon, 26 Oct 2026 18:45:54 +0100 Subject: [PATCH 05/36] Apply Unbreaking to armor wear from Thorns Thorns always cost the worn piece 2 durability. Run it through the same durability loss as other wear so Unbreaking can cancel points. --- crates/horizon-client/src/game/enchant_effects.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/horizon-client/src/game/enchant_effects.rs b/crates/horizon-client/src/game/enchant_effects.rs index 7cdb3e526..4417f0df8 100644 --- a/crates/horizon-client/src/game/enchant_effects.rs +++ b/crates/horizon-client/src/game/enchant_effects.rs @@ -303,8 +303,10 @@ impl Game<'_> { continue; } hits.push(1.0 + self.world.random.next_float() * 4.0); + // ChangeItemDamage -> ItemStack.hurtAndBreak: unbreaking applies. + let loss = self.durability_loss(&stack, 2); if let Some(s) = self.armor[slot].as_mut() { - s.damage += 2; + s.damage += loss; if self .res .items() From bf527e7a13ccf3b6477dbc49004086c44a8832a7 Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Mon, 26 Oct 2026 18:46:36 +0100 Subject: [PATCH 06/36] Apply knockback resistance to Punch arrows --- crates/horizon-client/src/game/creatures.rs | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/crates/horizon-client/src/game/creatures.rs b/crates/horizon-client/src/game/creatures.rs index 2b65a3289..38dd455c8 100644 --- a/crates/horizon-client/src/game/creatures.rs +++ b/crates/horizon-client/src/game/creatures.rs @@ -2123,10 +2123,24 @@ impl Game<'_> { hurt } }; - // doKnockback: Punch pushes along the flight. + // doKnockback: Punch pushes along the flight, less the target's + // knockback resistance. let flight = (p.velocity.x * p.velocity.x + p.velocity.z * p.velocity.z).sqrt(); - if hurt && p.bonus.punch > 0 && flight > 1e-6 { - let k = f64::from(p.bonus.punch) * 0.6 / flight; + let resistance = match who { + Who::Player => self + .player + .as_mut() + .and_then(|pl| pl.attribute("minecraft:knockback_resistance").ok()) + .unwrap_or(0.0), + Who::Mob(id) => self + .mobs + .iter() + .find(|m| m.id == id) + .map_or(0.0, |m| m.attrs.knockback_resistance), + }; + let push = f64::from(p.bonus.punch) * 0.6 * (1.0 - resistance).max(0.0); + if hurt && push > 0.0 && flight > 1e-6 { + let k = push / flight; self.handle_mob_events(vec![MobEvent::Push { target: who, velocity: [p.velocity.x * k, 0.1, p.velocity.z * k], From c1844dfe57e5b3f02b90f9fabad813753aa7e7a4 Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Mon, 26 Oct 2026 18:46:37 +0100 Subject: [PATCH 07/36] Let mobs trample farmland when they land on it A cow dropped onto farmland left it untouched. A landing mob now turns farmland to dirt with chance fall distance - 0.5, when mob griefing is on and the mob is big enough, and is lifted onto the dirt. --- crates/horizon-client/src/mobs/living.rs | 25 ++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/crates/horizon-client/src/mobs/living.rs b/crates/horizon-client/src/mobs/living.rs index 394821ace..afd0c26db 100644 --- a/crates/horizon-client/src/mobs/living.rs +++ b/crates/horizon-client/src/mobs/living.rs @@ -440,11 +440,36 @@ impl Mob { } if self.on_ground { if self.fall_distance > 0.0 { + self.trample_farmland(w, events); self.cause_fall_damage(events); } self.fall_distance = 0.0; } } + /// `FarmlandBlock.fallOn`: a landing on farmland turns it to dirt with + /// chance `fallDistance - 0.5`, if mobs may grief and the mob's + /// `width * width * height` is over 0.512. `Block.pushEntitiesUp` lifts + /// the mob onto the dirt, which is a full block. + fn trample_farmland(&mut self, w: &MobWorld, events: &mut Vec) { + let p = self.block_on_legacy(w); + if w.block_name(p[0], p[1], p[2]) != "minecraft:farmland" { + return; + } + let roll = f64::from(self.random.next_float()); + let Some(dirt) = w.registry.default_state("minecraft:dirt") else { + return; + }; + if roll < self.fall_distance - 0.5 + && w.mob_griefing + && self.width() * self.width() * self.height() > 0.512 + { + events.push(MobEvent::SetBlock { + pos: p, + state: dirt, + }); + self.position.y = self.position.y.max(f64::from(p[1]) + 1.0); + } + } /// Entity.updateFluidInteraction: the fluid state, then touching water /// resets the fall and entering it (after the first tick) splashes. pub(super) fn update_fluids(&mut self, w: &MobWorld, events: &mut Vec) { From 90501f9ab4ab5cb04e85d6aa5d032d25e8e6bda2 Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Mon, 26 Oct 2026 18:46:46 +0100 Subject: [PATCH 08/36] Keep leashed mobs and carrying endermen from despawning Mob.requiresCustomPersistence also covers a leashed mob and an enderman holding a block, and the spawn caps skip such mobs. Gather the existing cases in one helper, add the missing ones, and use it for both the despawn check and the cap count. --- .../src/game/natural_spawning.rs | 3 ++- crates/horizon-client/src/mobs/ai.rs | 20 +++++++++++++------ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/crates/horizon-client/src/game/natural_spawning.rs b/crates/horizon-client/src/game/natural_spawning.rs index 0035f5082..5afa72416 100644 --- a/crates/horizon-client/src/game/natural_spawning.rs +++ b/crates/horizon-client/src/game/natural_spawning.rs @@ -504,7 +504,8 @@ impl<'a> Game<'a> { m.position.z.floor() as i32, ], is_mob: true, - persistent: m.persistent, + persistent: m.persistent + || horizon_client::mobs::ai::requires_custom_persistence(m), }) .collect(); let players = players diff --git a/crates/horizon-client/src/mobs/ai.rs b/crates/horizon-client/src/mobs/ai.rs index 2676c3a37..3b9a8ed04 100644 --- a/crates/horizon-client/src/mobs/ai.rs +++ b/crates/horizon-client/src/mobs/ai.rs @@ -1017,6 +1017,19 @@ pub fn despawn_check(m: &mut Mob, w: &MobWorld) -> bool { } true } +/// `Mob.requiresCustomPersistence` and its overrides: a passenger or a leashed +/// mob, a raider in a raid, an enderman carrying a block, a tame nautilus, a +/// sulfur cube holding a block or let out of a bucket. The spawn caps do not +/// count these mobs either (`NaturalSpawner.createState`). +pub fn requires_custom_persistence(m: &Mob) -> bool { + super::riders::keeps_alive(m) + || m.extra.leash.is_some() + || super::raider::state(m).is_some_and(|s| s.raid_id.is_some()) + || m.species() == Species::Enderman && m.extra.carried.is_some() + || super::nautilus::is_nautilus(m.species()) && m.extra.tame + || m.species() == Species::SulfurCube + && (super::sulfur_cube::has_body(m) || m.extra.scratch[3] != 0) +} /// Mob.checkDespawn, before the tick (players are the only despawn /// reference). Returns false when the mob is discarded. fn check_despawn(m: &mut Mob, w: &MobWorld) -> bool { @@ -1032,12 +1045,7 @@ fn check_despawn(m: &mut Mob, w: &MobWorld) -> bool { return true; }; let d = m.distance_sqr(p); - // requiresCustomPersistence: raiders in a raid, a tame nautilus, a sulfur - // cube holding a block or let out of a bucket. - let persistent = m.persistent - || super::nautilus::is_nautilus(m.species()) && m.extra.tame - || m.species() == Species::SulfurCube - && (super::sulfur_cube::has_body(m) || m.extra.scratch[3] != 0); + let persistent = m.persistent || requires_custom_persistence(m); // removeWhenFarAway: animals, villagers, golems, patrols and raiders, // zombie villagers being cured and ridden mobs stay. let creature = m.kind.category == "creature"; From 7569f9615a193b50443eaff428e126651a647ce2 Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Mon, 26 Oct 2026 18:47:58 +0100 Subject: [PATCH 09/36] Treat unbreakable items as undamageable in the anvil and grindstone --- crates/horizon-client/src/stations.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/crates/horizon-client/src/stations.rs b/crates/horizon-client/src/stations.rs index a307b35cf..3fa480656 100644 --- a/crates/horizon-client/src/stations.rs +++ b/crates/horizon-client/src/stations.rs @@ -151,8 +151,12 @@ pub struct AnvilResult { pub repair_item_count_cost: u32, pub only_renaming: bool, } +/// `ItemStack.isDamageableItem`: durability, and not `minecraft:unbreakable`. pub fn is_damageable(items: &Items, stack: &ItemStack) -> bool { items.get(&stack.item).is_some_and(|i| i.max_damage > 0) + && stack + .data() + .is_none_or(|d| d.other("minecraft:unbreakable").is_none()) } fn max_damage(items: &Items, stack: &ItemStack) -> i32 { items.get(&stack.item).map_or(0, |i| i.max_damage as i32) From 2277c85fc3e486fa36ef6f4569a826a73db0cbd4 Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Mon, 26 Oct 2026 19:07:02 +0100 Subject: [PATCH 10/36] Run neighbour updates when a mob trampling farmland places dirt --- crates/horizon-client/src/game/creatures.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/horizon-client/src/game/creatures.rs b/crates/horizon-client/src/game/creatures.rs index 2b65a3289..f08f41d01 100644 --- a/crates/horizon-client/src/game/creatures.rs +++ b/crates/horizon-client/src/game/creatures.rs @@ -1037,9 +1037,9 @@ impl Game<'_> { [0.0, 0.2, 0.0], 10, ), - MobEvent::SetBlock { pos, state } => { - self.world.set(pos[0], pos[1], pos[2], state)? - } + // `Level.setBlockAndUpdate`: neighbour and shape updates, so a crop + // above trampled farmland breaks and drops. + MobEvent::SetBlock { pos, state } => self.level_set(pos, state)?, MobEvent::SetDoorOpen { pos, open } => { let pos = BlockPos::new(pos[0], pos[1], pos[2]); self.with_level(|b, level, ticks| b.set_door_open(level, ticks, pos, open)); From a45c73bb36609301725aafb7fa66ae7a57387d3c Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Mon, 26 Oct 2026 19:12:49 +0100 Subject: [PATCH 11/36] Credit the player who kills the ender dragon --- crates/horizon-client/src/game/dragon.rs | 80 ++++++++++++++++++++++-- 1 file changed, 76 insertions(+), 4 deletions(-) diff --git a/crates/horizon-client/src/game/dragon.rs b/crates/horizon-client/src/game/dragon.rs index fff03ef1c..b2f04d77c 100644 --- a/crates/horizon-client/src/game/dragon.rs +++ b/crates/horizon-client/src/game/dragon.rs @@ -262,6 +262,9 @@ pub(super) struct Dragon { /// only damage above the last hit lands, and only the excess. invulnerable: i32, last_hurt: f32, + /// `lastHurtByPlayer` with its 100 tick memory: the player credited with + /// the kill, and the dragon tick of their last hit. + hurt_by_player: Option<(FightWho, i32)>, pub death_time: i32, pub flap: f32, pub old_flap: f32, @@ -385,6 +388,7 @@ impl Dragon { hurt_time: 0, invulnerable: 0, last_hurt: 0.0, + hurt_by_player: None, death_time: 0, flap: 0.0, old_flap: 0.0, @@ -426,6 +430,10 @@ impl Dragon { pub fn alive(&self) -> bool { self.health > 0.0 } + /// `isDeadOrDying` for the killing blow: the dying flight, or no health. + fn down(&self) -> bool { + matches!(self.phase, Phase::Dying { .. }) || !self.alive() + } fn part_box(&self, i: usize) -> Aabb { let (w, h) = PART_SIZES[i]; let p = self.parts[i].0; @@ -903,7 +911,7 @@ impl Game<'_> { if let Some(d) = self.dragon.as_mut() { if d.nearest_crystal == Some(index) { d.nearest_crystal = None; - self.hurt_dragon(0, 10.0, true, false); + self.hurt_dragon(0, 10.0, true, by, false); } else if let Some(n) = d.nearest_crystal.as_mut() && *n > index { @@ -975,17 +983,40 @@ impl Game<'_> { self.destroy_crystal(index, by, CrystalDamage::Direct); Hurt::Landed { full: true } } else if id >= SPECIAL { - self.hurt_dragon((id - SPECIAL) as usize, amount, by_player, arrow) + let by = by_player.then(|| self.acting_player()); + self.hurt_dragon((id - SPECIAL) as usize, amount, by_player, by, arrow) } else { Hurt::Refused } } /// `EnderDragon.hurt(part, source, damage)` on the dragon in the level. - fn hurt_dragon(&mut self, part: usize, damage: f32, counts: bool, arrow: bool) -> Hurt { + /// `by` is the player behind the hit, remembered for the kill credit. + fn hurt_dragon( + &mut self, + part: usize, + damage: f32, + counts: bool, + by: Option, + arrow: bool, + ) -> Hurt { let Some(d) = self.dragon.as_mut() else { return Hurt::Refused; }; + let was_down = d.down(); let hurt = d.hurt(part, damage, counts, arrow); + // LivingEntity.hurtServer: a player's hit sets lastHurtByPlayer (100 ticks). + if counts + && matches!(hurt, Hurt::Landed { .. }) + && let Some(who) = by + { + d.hurt_by_player = Some((who, d.ticks)); + } + if !was_down && d.down() { + self.credit_dragon_kill(); + } + let Some(d) = self.dragon.as_ref() else { + return hurt; + }; if hurt == (Hurt::Landed { full: true }) { let at = [d.position.x, d.position.y, d.position.z]; let pitch = 0.8 + self.world.random.next_float() * 0.3; @@ -994,6 +1025,47 @@ impl Game<'_> { } hurt } + /// `LivingEntity.die`: `getKillCredit().awardKillScore`, for the player + /// who hurt the dragon within the last 100 ticks. A guest's kill is + /// theirs: their statistics, scores and advancements. + fn credit_dragon_kill(&mut self) { + let Some(d) = self.dragon.as_ref() else { + return; + }; + let Some((who, _)) = d.hurt_by_player.filter(|(_, hit)| d.ticks - hit <= 100) else { + return; + }; + let view = horizon_client::advancements::EntityView { + kind: "minecraft:ender_dragon".to_owned(), + position: [d.position.x, d.position.y, d.position.z], + ..Default::default() + }; + let id = d.id; + let guest = match who { + FightWho::Guest(conn) if self.lan_acting.is_none() => Some(conn), + _ => None, + }; + let credited = guest.is_some_and(|conn| { + let Some(mut host) = self.lan.take() else { + return false; + }; + let done = self + .as_guest(&mut host, conn, |g| g.award_dragon_kill(id, &view)) + .is_some(); + self.lan = Some(host); + done + }); + if !credited { + self.award_dragon_kill(id, &view); + } + } + /// `ServerPlayer.awardKillScore` for the dragon, on the killer's state. + fn award_dragon_kill(&mut self, id: u32, view: &horizon_client::advancements::EntityView) { + self.stats.add("killed", "minecraft:ender_dragon", 1); + self.stats.custom("mob_kills", 1); + self.score_player_killed(super::commands::Target::Mob(id)); + self.trigger_entity("minecraft:player_killed_entity", "entity", view); + } /// Player melee on the dragon's parts or a crystal under the crosshair. /// The dragon part under the crosshair within reach: its id and distance. pub(super) fn dragon_hit(&self) -> Option<(u32, f64)> { @@ -2716,7 +2788,7 @@ impl Game<'_> { self.seen_percent(center, [lo.x, lo.y, lo.z], [hi.x, hi.y, hi.z]) }); for (part, amount) in hits { - self.hurt_dragon(part, amount, true, false); + self.hurt_dragon(part, amount, true, None, false); } } } From e6587dce6a005413b2617d281826dde4ca6663f0 Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Mon, 26 Oct 2026 19:17:05 +0100 Subject: [PATCH 12/36] Respawn at once without a death screen when immediate_respawn is on --- crates/horizon-client/src/game.rs | 11 ++- crates/horizon-client/src/game/lan.rs | 2 + crates/horizon-client/src/game/remote.rs | 29 ++++++-- crates/horizon-client/src/game/screens.rs | 86 ++++++++++++----------- crates/horizon-client/src/lan/hub.rs | 17 ++++- 5 files changed, 95 insertions(+), 50 deletions(-) diff --git a/crates/horizon-client/src/game.rs b/crates/horizon-client/src/game.rs index 8448f0837..2d0efc34d 100644 --- a/crates/horizon-client/src/game.rs +++ b/crates/horizon-client/src/game.rs @@ -4614,9 +4614,14 @@ impl Game<'_> { if let Some(host) = &self.lan { host.hub.entity_event(host.host_entity, 3, feet); } - self.screen = Screen::Dead; - self.capture(false); - self.ui.death_time = 0; + if self.ui.rules.bool("immediate_respawn") { + // Gui.setScreen: without the death screen the player respawns at once. + self.respawn_player()?; + } else { + self.screen = Screen::Dead; + self.capture(false); + self.ui.death_time = 0; + } } else if dead { // LivingEntity.tickDeath: 20 ticks after dying the player is // removed, and Player.remove's inventoryMenu.removed drops what diff --git a/crates/horizon-client/src/game/lan.rs b/crates/horizon-client/src/game/lan.rs index 5292cd31b..9b52cc46e 100644 --- a/crates/horizon-client/src/game/lan.rs +++ b/crates/horizon-client/src/game/lan.rs @@ -974,6 +974,8 @@ impl Game<'_> { self.ui.rules.bool("player_movement_check"), self.ui.rules.bool("elytra_movement_check"), ); + host.hub + .set_immediate_respawn(self.ui.rules.bool("immediate_respawn")); // A server with several levels runs a pass for each // (`tick_server`): the network is read once, before the first. let pass = self.level_pass; diff --git a/crates/horizon-client/src/game/remote.rs b/crates/horizon-client/src/game/remote.rs index 3cfbd15e3..1a684cb75 100644 --- a/crates/horizon-client/src/game/remote.rs +++ b/crates/horizon-client/src/game/remote.rs @@ -192,6 +192,8 @@ pub(super) struct Remote { stop_mining: bool, placing: Option<([i32; 3], u64)>, death_message: Option, + /// `LocalPlayer.showDeathScreen`: off with `immediate_respawn`. + show_death_screen: bool, player_type: Option>, /// Inventory as last synchronised, for creative-mode slot updates. synced: Vec>, @@ -476,6 +478,7 @@ impl Game<'_> { stop_mining: false, placing: None, death_message: None, + show_death_screen: true, player_type, synced: vec![None; 36], decode_errors: 0, @@ -1623,6 +1626,7 @@ impl Game<'_> { r.online_mode = p.online_mode; r.entity_id = p.player_id; r.view_distance = p.chunk_radius; + r.show_death_screen = p.show_death_screen; } self.streaming.radius = self.settings.render_distance.min(p.chunk_radius + 1).max(2); @@ -2182,7 +2186,11 @@ impl Game<'_> { pl.health.flash_health_change(p.health); } self.apply_remote_health(); - if p.health <= 0.0 && self.screen != Screen::Dead && self.player.is_some() { + // The death screen opens (or the respawn is asked for) with the + // death packet when the rule hides it. + let shown = self.remote.as_ref().is_none_or(|r| r.show_death_screen); + if p.health <= 0.0 && shown && self.screen != Screen::Dead && self.player.is_some() + { self.screen = Screen::Dead; self.ui.death_time = 0; self.capture(false); @@ -2198,11 +2206,16 @@ impl Game<'_> { r.death_message = Some(message); } // ClientPacketListener.handlePlayerCombatKill: the death - // screen, whatever health was last sent. + // screen, whatever health was last sent, or `respawn()` at + // once when it is hidden. if me && self.screen != Screen::Dead && self.player.is_some() { - self.screen = Screen::Dead; - self.ui.death_time = 0; - self.capture(false); + if self.remote.as_ref().is_none_or(|r| r.show_death_screen) { + self.screen = Screen::Dead; + self.ui.death_time = 0; + self.capture(false); + } else { + self.respawn_player()?; + } } } C::TrackedWaypoint(p) => self.handle_waypoint(&p), @@ -2278,6 +2291,12 @@ impl Game<'_> { r.game_mode = mode; } } + // IMMEDIATE_RESPAWN: LocalPlayer.setShowDeathScreen. + 11 => { + if let Some(r) = self.remote.as_mut() { + r.show_death_screen = p.param == 0.0; + } + } 7 => { self.world.weather.rain_level = (p.param, p.param); self.world.weather.raining = p.param > 0.0; diff --git a/crates/horizon-client/src/game/screens.rs b/crates/horizon-client/src/game/screens.rs index f8885f83a..3a2c3deda 100644 --- a/crates/horizon-client/src/game/screens.rs +++ b/crates/horizon-client/src/game/screens.rs @@ -286,6 +286,50 @@ impl Game<'_> { ); } } + /// LocalPlayer.respawn: the player comes back (the death screen's + /// button, or at once with `immediate_respawn`). + pub(super) fn respawn_player(&mut self) -> Result<()> { + if self.remote.is_none() { + let keep = self.ui.rules.bool("keep_inventory") || self.spectator(); + self.experience.respawn(keep); + // The guests are sent the respawned host as a new entity, not the dead body. + if let Some(host) = self.lan.as_mut() { + let id = host.host_entity; + host.hub.respawned(id); + } + // Autosaves keep a login position; death must resolve the respawn point instead. + self.level.position = None; + } + if self.remote.is_some() { + self.ui.death_text = None; + self.toggles.respawn(); + self.remote_respawn(); + } else if self.respawn_config.is_some() { + // LocalPlayer.respawn: KeyMapping.resetToggleKeys. + self.toggles.respawn(); + // PlayerList.respawn at the respawn anchor, once it is loaded. + self.begin_anchor_respawn()?; + self.screen = Screen::Playing; + self.ui.death_text = None; + self.spawn_player()?; + self.capture(true); + } else { + // LocalPlayer.respawn: KeyMapping.resetToggleKeys. + self.toggles.respawn(); + self.respawn_out_of_end()?; + self.player = None; + self.screen = Screen::Playing; + self.ui.death_text = None; + self.spawn_player()?; + self.capture(true); + } + // ServerGamePacketListenerImpl.handleClientCommand: a hardcore world's + // respawned player only watches. + if self.remote.is_none() && self.level.hardcore { + self.set_mode(GameMode::Spectator); + } + Ok(()) + } pub(super) fn death_click(&mut self) -> Result<()> { if self .ui @@ -303,51 +347,11 @@ impl Game<'_> { .into_iter() .find(|d| ui::hovered(self.cursor, d.0, d.1, 200.0, 20.0)) .map(|d| d.3); - if hit == Some(0) && self.remote.is_none() { - let keep = self.ui.rules.bool("keep_inventory") || self.spectator(); - self.experience.respawn(keep); - // The guests are sent the respawned host as a new entity, not the dead body. - if let Some(host) = self.lan.as_mut() { - let id = host.host_entity; - host.hub.respawned(id); - } - // Autosaves keep a login position; death must resolve the respawn point instead. - self.level.position = None; - } match hit { - Some(0) if self.remote.is_some() => { - self.ui.death_text = None; - self.toggles.respawn(); - self.remote_respawn(); - } - Some(0) if self.respawn_config.is_some() => { - // LocalPlayer.respawn: KeyMapping.resetToggleKeys. - self.toggles.respawn(); - // PlayerList.respawn at the respawn anchor, once it is loaded. - self.begin_anchor_respawn()?; - self.screen = Screen::Playing; - self.ui.death_text = None; - self.spawn_player()?; - self.capture(true); - } - Some(0) => { - // LocalPlayer.respawn: KeyMapping.resetToggleKeys. - self.toggles.respawn(); - self.respawn_out_of_end()?; - self.player = None; - self.screen = Screen::Playing; - self.ui.death_text = None; - self.spawn_player()?; - self.capture(true); - } + Some(0) => self.respawn_player()?, Some(1) => self.close_world()?, _ => {} } - // ServerGamePacketListenerImpl.handleClientCommand: a hardcore world's - // respawned player only watches. - if hit == Some(0) && self.remote.is_none() && self.level.hardcore { - self.set_mode(GameMode::Spectator); - } if hit.is_some() { self.audio.play_button_click(); } diff --git a/crates/horizon-client/src/lan/hub.rs b/crates/horizon-client/src/lan/hub.rs index b1a8cbc62..8c60dc75f 100644 --- a/crates/horizon-client/src/lan/hub.rs +++ b/crates/horizon-client/src/lan/hub.rs @@ -43,6 +43,7 @@ pub mod game_event { pub const RAIN_LEVEL: u8 = 7; pub const THUNDER_LEVEL: u8 = 8; pub const GUARDIAN_ELDER_EFFECT: u8 = 10; + pub const IMMEDIATE_RESPAWN: u8 = 11; pub const LEVEL_CHUNKS_LOAD_START: u8 = 13; } @@ -149,6 +150,8 @@ pub struct Hub { /// The `player_movement_check` and `elytra_movement_check` game rules, /// set by the game before each tick. pub movement_checks: (bool, bool), + /// The `immediate_respawn` game rule, as the players were last told. + immediate_respawn: bool, /// An integrated server's owner (`MinecraftServer.isSingleplayerOwner`), /// whose moves are never checked. pub singleplayer_owner: Option, @@ -324,6 +327,7 @@ impl Hub { guests: Vec::new(), sync, ticks: 0, + immediate_respawn: false, movement_checks: (true, true), singleplayer_owner: None, riding: Default::default(), @@ -399,6 +403,17 @@ impl Hub { g.sender.send(body.clone()); } } + /// MinecraftServer.onGameRuleChanged: every player is told when + /// `immediate_respawn` changes; a joining player's Login carries it. + pub fn set_immediate_respawn(&mut self, on: bool) { + if self.immediate_respawn != on { + self.immediate_respawn = on; + self.broadcast(&C::GameEvent(play::GameEvent { + event: game_event::IMMEDIATE_RESPAWN, + param: if on { 1.0 } else { 0.0 }, + })); + } + } /// PlayerList.setViewDistance: every player is told the new radius, /// and each one's chunks follow it, up to what they asked for /// (ChunkMap.getPlayerViewDistance). @@ -633,7 +648,7 @@ impl Hub { chunk_radius: self.config.view_distance, simulation_distance: self.config.simulation_distance, reduced_debug_info: false, - show_death_screen: true, + show_death_screen: !self.immediate_respawn, limited_crafting: false, spawn: self.spawn_info(mode), // MinecraftServer.usesAuthentication, enforceSecureProfile. From 97f8bca9daf9eb3f18b4bab27c3bd36cc8ca56e2 Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Mon, 26 Oct 2026 19:32:41 +0100 Subject: [PATCH 13/36] Raiders skip ominous banners they cannot reach A captainless raider walked towards the nearest fallen ominous banner even when no path led to it. Check that a path reaches the banner before going for it, and skip a banner without one for 600 ticks, like vanilla. --- crates/horizon-client/src/game/raids.rs | 17 +++++++---- crates/horizon-client/src/mobs/raider.rs | 37 ++++++++++++++++++------ 2 files changed, 39 insertions(+), 15 deletions(-) diff --git a/crates/horizon-client/src/game/raids.rs b/crates/horizon-client/src/game/raids.rs index bedca5708..e34d9feed 100644 --- a/crates/horizon-client/src/game/raids.rs +++ b/crates/horizon-client/src/game/raids.rs @@ -762,7 +762,7 @@ impl Game<'_> { } positions.push((m.id, m.position, s.active_raid)); } - let banners: Vec<(usize, Vec3)> = self + let banners: Vec<(usize, u32, Vec3)> = self .dropped .iter() .enumerate() @@ -771,7 +771,7 @@ impl Game<'_> { && e.stack.data().is_some_and(|d| d.ominous_banner) && e.pickup_delay == 0 }) - .map(|(i, e)| (i, e.position)) + .map(|(i, e)| (i, e.id, e.position)) .collect(); let mut taken: Vec = Vec::new(); let mut collectors: Vec<(usize, u32)> = Vec::new(); @@ -858,18 +858,23 @@ impl Game<'_> { { let near = banners .iter() - .filter(|(i, p)| { + .filter(|(i, item, p)| { !taken.contains(i) + && !s + .unreachable_banners + .iter() + .any(|&(b, until)| b == *item && now < until) && (p.x - position.x).abs() <= range && (p.z - position.z).abs() <= range && (p.y - position.y).abs() <= 8.0 }) .min_by(|a, b| { - a.1.distance_squared(position) - .total_cmp(&b.1.distance_squared(position)) + a.2.distance_squared(position) + .total_cmp(&b.2.distance_squared(position)) }); - if let Some((i, p)) = near { + if let Some((i, item, p)) = near { s.banner_at = Some([p.x, p.y, p.z]); + s.banner_item = *item; if p.distance_squared(position) < 1.414 * 1.414 { // pickUpItem: the banner becomes the wave's leader. taken.push(*i); diff --git a/crates/horizon-client/src/mobs/raider.rs b/crates/horizon-client/src/mobs/raider.rs index 6c3ab9b64..a2c3ffe33 100644 --- a/crates/horizon-client/src/mobs/raider.rs +++ b/crates/horizon-client/src/mobs/raider.rs @@ -38,6 +38,11 @@ pub struct State { pub in_village: bool, /// A dropped ominous banner this raider may fetch. pub banner_at: Option<[f64; 3]>, + /// The item entity of `banner_at`. + pub banner_item: u32, + /// Banners with no path to them, and until when (game time): + /// `unreachableBannerCache`. + pub unreachable_banners: Vec<(u32, i64)>, /// Beds around the raid's centre. pub homes: Option>>, /// A ravager carrying a raider, set every tick from `Extra::rider`. @@ -113,7 +118,7 @@ pub fn register(m: &mut Mob) { } m.extra.raider = Some(Box::default()); m.ai.goals.add(4, LongDistancePatrol::new(0.7, 0.595)); - m.ai.goals.add(1, ObtainBanner); + m.ai.goals.add(1, ObtainBanner::default()); m.ai.goals.add(3, PathfindToRaid); m.ai.goals.add(4, MoveThroughVillage::new(1.05, 1.0)); m.ai.goals.add(5, Celebration); @@ -336,23 +341,37 @@ fn close_to_center(p: [i32; 3], at: Vec3, distance: f64) -> bool { /// `Raider.ObtainRaidLeaderBannerGoal`: walk to a fallen ominous banner when /// the wave has no living leader (the game finds the banner and picks it up). -#[derive(Clone, Debug)] -pub struct ObtainBanner; +#[derive(Clone, Debug, Default)] +pub struct ObtainBanner { + path_to_banner: Option, +} impl Goal for ObtainBanner { goal_clone!(); fn flags(&self) -> u8 { MOVE } - fn can_use(&mut self, m: &mut Mob, _cx: &mut Cx) -> bool { - state(m).is_some_and(|s| s.banner_at.is_some()) + fn can_use(&mut self, m: &mut Mob, cx: &mut Cx) -> bool { + let Some((at, item)) = state(m).and_then(|s| s.banner_at.map(|at| (at, s.banner_item))) + else { + return false; + }; + // A banner with no path to it is skipped for 600 ticks. + let path = m.create_path_to_entity(cx.w, at, 1); + if path.as_ref().is_some_and(|p| p.reached) { + self.path_to_banner = path; + return true; + } + let now = cx.w.game_time; + let s = state_mut(m); + s.unreachable_banners.retain(|&(_, until)| now < until); + s.unreachable_banners.push((item, now + 600)); + false } fn can_continue(&mut self, m: &mut Mob, _cx: &mut Cx) -> bool { !m.ai.nav.is_done() && state(m).is_some_and(|s| s.banner_at.is_some()) } - fn start(&mut self, m: &mut Mob, cx: &mut Cx) { - if let Some(at) = state(m).and_then(|s| s.banner_at) { - m.nav_move_to(cx.w, at, 1.15); - } + fn start(&mut self, m: &mut Mob, _cx: &mut Cx) { + m.nav_move_to_path(self.path_to_banner.take(), 1.15); } } From c74626448c544dae0101e005eafa4c23fab19981 Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Mon, 26 Oct 2026 19:40:06 +0100 Subject: [PATCH 14/36] Show the crosshair to spectators over containers, stations and portals --- crates/horizon-client/src/game.rs | 6 ++- crates/horizon-client/src/game/hand.rs | 56 +++++++++++++++++++++++++- 2 files changed, 60 insertions(+), 2 deletions(-) diff --git a/crates/horizon-client/src/game.rs b/crates/horizon-client/src/game.rs index 58b89a140..91d953722 100644 --- a/crates/horizon-client/src/game.rs +++ b/crates/horizon-client/src/game.rs @@ -5141,7 +5141,11 @@ impl Game<'_> { let delay = horizon_client::attack_strength::delay(self.main_hand_attack_speed()); let strength = self.hand_strength.scale(0.0, self.main_hand_attack_speed()); // The 3D crosshair (F3) takes the 2D one's place. - if self.camera_type.first_person() && !spectator && !self.debug_crosshair() { + // Hud.extractCrosshair: a spectator only sees it over something to open. + if self.camera_type.first_person() + && (!spectator || self.spectator_crosshair()) + && !self.debug_crosshair() + { let attack = (indicator == 1).then_some(strength); let full = attack.is_some_and(|a| { hud_layout::full_attack_indicator(a, delay, self.crosshair_living()) diff --git a/crates/horizon-client/src/game/hand.rs b/crates/horizon-client/src/game/hand.rs index d91d3b979..c3fd78310 100644 --- a/crates/horizon-client/src/game/hand.rs +++ b/crates/horizon-client/src/game/hand.rs @@ -3,7 +3,7 @@ //! `continueAttack`, `MultiPlayerGameMode` block breaking), the arm swing //! (`LivingEntity.SwingState`) and the first-person equip heights //! (`FirstPersonHandsAndItems`) with the item swap ticker they read. -use super::{Game, Mining, Screen}; +use super::{Game, Mining, Screen, minecarts::CartKind}; use horizon_client::{ Result, attack_strength::HeldStack, @@ -289,6 +289,60 @@ impl Game<'_> { // Only alive mobs are hit, so a picked living entity is alive. Some(true) } + /// `Hud.canRenderCrosshairForSpectator` for the nearest hit in reach: an + /// entity that is a `MenuProvider` (a chest or hopper minecart, a chest + /// boat), or a block whose `showAsInteractableInSpectatorMode` holds. + pub(super) fn spectator_crosshair(&self) -> bool { + let cart = self.cart_hit().map(|(i, d)| { + let kind = &self.carts[i].kind; + (d, matches!(kind, CartKind::Chest | CartKind::Hopper)) + }); + let boat = self.boat_hit().map(|(i, d)| (d, self.boats[i].chest)); + let others = [ + self.mob_hit().map(|h| h.1), + self.armor_stand_hit().map(|h| h.1), + self.cushion_hit().map(|h| h.1), + self.painting_hit().map(|h| h.1), + self.frame_hit().map(|h| h.1), + self.dragon_hit().map(|h| h.1), + ]; + let nearest = cart + .into_iter() + .chain(boat) + .chain(others.into_iter().flatten().map(|d| (d, false))) + .min_by(|a, b| a.0.total_cmp(&b.0)); + if let Some((distance, menu)) = nearest + && self.before_block(distance) + { + return menu; + } + let Some(hit) = self.pick() else { + return false; + }; + let name = &*self + .res + .facts() + .get(self.world.block(hit.pos[0], hit.pos[1], hit.pos[2])) + .name; + let name = name.trim_start_matches("minecraft:"); + match name { + // BlockBehaviour.getMenuProvider and `instanceof Portal`. + "crafting_table" | "enchanting_table" | "anvil" | "chipped_anvil" | "damaged_anvil" + | "stonecutter" | "loom" | "cartography_table" | "grindstone" | "smithing_table" + | "barrel" | "furnace" | "blast_furnace" | "smoker" | "brewing_stand" | "hopper" + | "dispenser" | "dropper" | "crafter" | "lectern" | "beacon" | "nether_portal" + | "end_portal" | "end_gateway" => true, + // ChestBlock.getMenuProvider: none while a redstone conductor + // sits on top (a sitting cat aside). + "chest" | "trapped_chest" => { + let above = self.world.block(hit.pos[0], hit.pos[1] + 1, hit.pos[2]); + self.res.behaviours().facts(above).flags + & horizon_world::level::data::state_flags::CONDUCTOR + == 0 + } + _ => name.ends_with("shulker_box"), + } + } /// `Attributes.ATTACK_SPEED` with the main-hand item's modifier. pub(super) fn main_hand_attack_speed(&self) -> f64 { horizon_client::attack_strength::BASE_ATTACK_SPEED From 752138e866916b5f116b7fbb933f07bee2138144 Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Mon, 26 Oct 2026 19:43:27 +0100 Subject: [PATCH 15/36] Cats sit on a chest only while nobody has it open, and on a bed's foot only --- crates/horizon-client/examples/probe/mob_ai_probe.rs | 3 +++ crates/horizon-client/src/game/creatures.rs | 1 + crates/horizon-client/src/mobs.rs | 2 ++ crates/horizon-client/src/mobs/tame.rs | 7 +++++-- 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/crates/horizon-client/examples/probe/mob_ai_probe.rs b/crates/horizon-client/examples/probe/mob_ai_probe.rs index ecdf02901..2fdb12ce9 100644 --- a/crates/horizon-client/examples/probe/mob_ai_probe.rs +++ b/crates/horizon-client/examples/probe/mob_ai_probe.rs @@ -1069,6 +1069,8 @@ pub fn main() -> horizon_client::Result<()> { for (i, m) in mobs.iter().enumerate() { print(&mut out, 0, i, m, s.creative, world.game_time); } + // No player has a chest open in the scenarios. + let lid_openers = std::collections::HashMap::new(); // The MobWorld every step sees, over a snapshot of the mobs. macro_rules! mob_world { ($snapshot:expr) => { @@ -1103,6 +1105,7 @@ pub fn main() -> horizon_client::Result<()> { // FlatLevelSource.getSeaLevel. sea_level: -63, items: Some(&items), + lid_openers: &lid_openers, } }; } diff --git a/crates/horizon-client/src/game/creatures.rs b/crates/horizon-client/src/game/creatures.rs index 845d2aee6..88f3fd669 100644 --- a/crates/horizon-client/src/game/creatures.rs +++ b/crates/horizon-client/src/game/creatures.rs @@ -422,6 +422,7 @@ impl Game<'_> { sea_level: if self.dim == Dim::Nether { 32 } else { 63 }, teams: std::sync::Arc::new(self.mob_teams()), items: Some(self.res.items()), + lid_openers: &self.lid_openers, difficulty: self.local_difficulty( self.player .as_ref() diff --git a/crates/horizon-client/src/mobs.rs b/crates/horizon-client/src/mobs.rs index 6b1e16f5c..06930be93 100644 --- a/crates/horizon-client/src/mobs.rs +++ b/crates/horizon-client/src/mobs.rs @@ -1529,6 +1529,8 @@ pub struct MobWorld<'a> { pub teams: std::sync::Arc>, /// Item data (max stack sizes), when the host has it. pub items: Option<&'a crate::items::Items>, + /// `ChestBlockEntity.getOpenCount`: the players with each chest open. + pub lid_openers: &'a HashMap<(i32, i32, i32), i32>, } /// `Entity.getTeam` of the player and of the mobs on a team. #[derive(Clone, Debug, Default)] diff --git a/crates/horizon-client/src/mobs/tame.rs b/crates/horizon-client/src/mobs/tame.rs index 1e725df80..30ac762b9 100644 --- a/crates/horizon-client/src/mobs/tame.rs +++ b/crates/horizon-client/src/mobs/tame.rs @@ -835,7 +835,7 @@ impl Goal for CatLieOnBlock { m.extra.flag = self.0.reached; } } -/// `CatSitOnBlockGoal`: chests, lit furnaces and beds. +/// `CatSitOnBlockGoal`: unopened chests, lit furnaces and the foot of beds. #[derive(Clone, Debug)] struct CatSitOnBlock(super::goals::MoveToBlock); fn can_sit_on(w: &MobWorld, p: [i32; 3]) -> bool { @@ -846,7 +846,10 @@ fn can_sit_on(w: &MobWorld, p: [i32; 3]) -> bool { match f.name.as_ref() { // The lit state is the only light source a furnace has. "minecraft:furnace" => f.emission > 0, - _ => true, + // `ChestBlockEntity.getOpenCount(level, pos) < 1`. + "minecraft:chest" => !w.lid_openers.contains_key(&(p[0], p[1], p[2])), + // A bed's foot only (`BedBlock.PART != HEAD`). + _ => w.prop(p[0], p[1], p[2], "part") != Some("head"), } } impl Goal for CatSitOnBlock { From 8aad511579676fa39072a685482a9ed3b9a1bacc Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Mon, 26 Oct 2026 19:46:01 +0100 Subject: [PATCH 16/36] Drop the cursor stack when the dead player respawns --- crates/horizon-client/src/game/screens.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/crates/horizon-client/src/game/screens.rs b/crates/horizon-client/src/game/screens.rs index 3a2c3deda..69ae69633 100644 --- a/crates/horizon-client/src/game/screens.rs +++ b/crates/horizon-client/src/game/screens.rs @@ -290,6 +290,14 @@ impl Game<'_> { /// button, or at once with `immediate_respawn`). pub(super) fn respawn_player(&mut self) -> Result<()> { if self.remote.is_none() { + // PlayerList.respawn removes the dead player, and Player.remove's + // inventoryMenu.removed drops what the cursor held, whatever + // keep_inventory says (the 20-tick branch handles a later respawn). + if let Some(stack) = self.carried.take() + && let Some(eye) = self.eye_position() + { + self.throw_from_eyes(stack, eye); + } let keep = self.ui.rules.bool("keep_inventory") || self.spectator(); self.experience.respawn(keep); // The guests are sent the respawned host as a new entity, not the dead body. From 851789830a7fbf4b325963f5252273fc5281627a Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Mon, 26 Oct 2026 20:44:17 +0100 Subject: [PATCH 17/36] Open chat links from open_url click events --- crates/horizon-client/src/component.rs | 4 ++ crates/horizon-client/src/game.rs | 16 ++++++ crates/horizon-client/src/game/chat.rs | 65 +++++++++++++++++++++++++ crates/horizon-client/src/game/packs.rs | 4 ++ crates/horizon-client/src/text.rs | 3 ++ 5 files changed, 92 insertions(+) diff --git a/crates/horizon-client/src/component.rs b/crates/horizon-client/src/component.rs index fced49898..0f0adef57 100644 --- a/crates/horizon-client/src/component.rs +++ b/crates/horizon-client/src/component.rs @@ -173,6 +173,10 @@ fn object_style(o: &serde_json::Map) -> Style { if let Some(e) = o.get("click_event").and_then(Value::as_object) { let text = |k: &str| e.get(k).and_then(Value::as_str).map(str::to_owned); style.click = match e.get("action").and_then(Value::as_str) { + // ClickEvent.OpenUrl.CODEC: ExtraCodecs.UNTRUSTED_URI allows http and https only. + Some("open_url") => text("url") + .filter(|u| u.starts_with("http://") || u.starts_with("https://")) + .map(crate::text::ClickEvent::OpenUrl), Some("suggest_command") => text("command").map(crate::text::ClickEvent::SuggestCommand), Some("copy_to_clipboard") => { text("value").map(crate::text::ClickEvent::CopyToClipboard) diff --git a/crates/horizon-client/src/game.rs b/crates/horizon-client/src/game.rs index b4b2861ce..f4682e44c 100644 --- a/crates/horizon-client/src/game.rs +++ b/crates/horizon-client/src/game.rs @@ -1218,6 +1218,8 @@ struct Game<'a> { pending_pack_reload: bool, /// A server's resource packs (game/server_packs.rs). server_packs: server_packs::ServerPackState, + /// The link a chat click asks to open (`ConfirmLinkScreen`). + link_prompt: Option, dialogs: dialogs::DialogState, world_renderer_ready: bool, collision: &'a BlockCollisionRegistry<'a>, @@ -5150,6 +5152,7 @@ impl Game<'_> { }; self.draw_dialog(&mut batch); self.draw_pack_prompt(&mut batch); + self.draw_link_prompt(&mut batch); // Gui.extractRenderState: the debug overlay comes after the screen // and the toasts, so it is over everything, menus included. self.draw_debug_overlay(&mut batch, size); @@ -11825,6 +11828,11 @@ impl ApplicationHandler for Game<'_> { self.advancements_scroll(scaled(raw_x) as f32, d); } } + WindowEvent::MouseInput { state, button, .. } if self.link_prompt.is_some() => { + if state == ElementState::Pressed && button == MouseButton::Left { + self.link_prompt_click(); + } + } WindowEvent::MouseInput { state, button, .. } if self.server_packs.prompt.is_some() => { @@ -12044,6 +12052,13 @@ impl ApplicationHandler for Game<'_> { } } // ConfirmScreen.keyPressed: Escape answers no. + WindowEvent::KeyboardInput { event, .. } if self.link_prompt.is_some() => { + if event.state == ElementState::Pressed + && event.physical_key == PhysicalKey::Code(KeyCode::Escape) + { + self.answer_link_prompt(false); + } + } WindowEvent::KeyboardInput { event, .. } if self.server_packs.prompt.is_some() => { if event.state == ElementState::Pressed && event.physical_key == PhysicalKey::Code(KeyCode::Escape) @@ -12559,6 +12574,7 @@ impl<'a> Game<'a> { world_loader: None, pending_pack_reload: false, server_packs: Default::default(), + link_prompt: None, dialogs: Default::default(), world_renderer_ready: false, collision: res.collision(), diff --git a/crates/horizon-client/src/game/chat.rs b/crates/horizon-client/src/game/chat.rs index 03174c009..29cda8b2c 100644 --- a/crates/horizon-client/src/game/chat.rs +++ b/crates/horizon-client/src/game/chat.rs @@ -695,6 +695,7 @@ impl Game<'_> { Some(ClickEvent::OpenFile(path)) => { super::packs::open_folder(std::path::Path::new(&path)); } + Some(ClickEvent::OpenUrl(url)) => self.click_url(url), Some(ClickEvent::SuggestCommand(command)) => { if let Some(screen) = self.ui.chat_screen.as_mut() { screen.suggest_command(&m, &c, &command); @@ -703,6 +704,70 @@ impl Game<'_> { None => {} } } + /// `Screen.clickUrlAction`: nothing with Web Links off, else the link + /// opens, after the confirmation unless Prompt on Links is off. + fn click_url(&mut self, url: String) { + if !self.settings.chat_links { + return; + } + if self.settings.file.bool("chatLinksPrompt") { + self.link_prompt = Some(url); + } else { + super::packs::open_uri(&url); + } + } + /// `ConfirmLinkScreen` (untrusted): the link and its warning over the + /// chat, answered yes to open it. + fn link_prompt_layout( + &self, + url: &str, + size: (f32, f32), + ) -> horizon_client::confirm_screen::Confirm { + let warning = Text::translate("chat.link.warning", &[]).with_color(0xFF_CCCC); + let message = Text::literal(url) + .append(Text::literal("\n")) + .append(warning); + horizon_client::confirm_screen::Confirm::new( + &self.gui.atlas.font, + size, + &Text::translate("chat.link.confirm", &[]), + &message, + ) + } + pub(super) fn draw_link_prompt(&self, batch: &mut HudBatch) { + let Some(url) = &self.link_prompt else { + return; + }; + let atlas = &self.gui.atlas; + let (w, h) = (batch.width, batch.height); + horizon_client::ui::menu_background(batch, atlas, 0.0, 0.0, w, h, true); + let (yes, no) = ( + Text::translate("gui.yes", &[]), + Text::translate("gui.no", &[]), + ); + self.link_prompt_layout(url, (w, h)) + .draw(batch, atlas, self.cursor, [&yes, &no]); + } + /// The prompt's answer: the link opens on yes; either way the chat is back. + pub(super) fn answer_link_prompt(&mut self, yes: bool) { + if let Some(url) = self.link_prompt.take() + && yes + { + super::packs::open_uri(&url); + } + } + pub(super) fn link_prompt_click(&mut self) { + let Some(url) = &self.link_prompt else { + return; + }; + let answer = self + .link_prompt_layout(url, self.gui_size()) + .answer_at(self.cursor); + if let Some(yes) = answer { + self.audio.play_button_click(); + self.answer_link_prompt(yes); + } + } /// Chat lines over the HUD (focused while the chat screen is open). pub(super) fn draw_chat(&mut self, batch: &mut HudBatch) { let focused = self.screen == Screen::Chat; diff --git a/crates/horizon-client/src/game/packs.rs b/crates/horizon-client/src/game/packs.rs index 569c63083..92587e1f6 100644 --- a/crates/horizon-client/src/game/packs.rs +++ b/crates/horizon-client/src/game/packs.rs @@ -34,6 +34,10 @@ pub fn open_folder(dir: &Path) { log::warn!("Horizon: could not open {}: {e}", dir.display()); } } +/// `Util.getPlatform().openUri`: the system's handler for a link. +pub fn open_uri(uri: &str) { + open_folder(Path::new(uri)); +} /// The resource root to load from, given the vanilla root, the selection and /// a server's packs, which go on top (`Pack.Position.TOP`, fixed). pub fn startup_root( diff --git a/crates/horizon-client/src/text.rs b/crates/horizon-client/src/text.rs index 4c04c9da5..20cbdc65a 100644 --- a/crates/horizon-client/src/text.rs +++ b/crates/horizon-client/src/text.rs @@ -42,6 +42,8 @@ pub fn named_color(name: &str) -> Option { /// Click actions carried by locally constructed text components. #[derive(Clone, Debug, PartialEq, Eq)] pub enum ClickEvent { + /// `ClickEvent.OpenUrl`: an http or https link. + OpenUrl(String), SuggestCommand(String), CopyToClipboard(String), /// A local file to open with the system handler. @@ -529,6 +531,7 @@ fn style_json(style: &Style) -> Vec<(String, Value)> { } if let Some(click) = &style.click { let event = match click { + ClickEvent::OpenUrl(url) => json!({ "action": "open_url", "url": url }), ClickEvent::SuggestCommand(command) => { json!({ "action": "suggest_command", "command": command }) } From 3fe301aaa1e610c095e26cb61882140b6419af89 Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Mon, 26 Oct 2026 21:17:18 +0100 Subject: [PATCH 18/36] Record the dragon's attacker before the crystal blast and only for applied damage --- crates/horizon-client/src/game/dragon.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/crates/horizon-client/src/game/dragon.rs b/crates/horizon-client/src/game/dragon.rs index b2f04d77c..f97070da7 100644 --- a/crates/horizon-client/src/game/dragon.rs +++ b/crates/horizon-client/src/game/dragon.rs @@ -48,6 +48,9 @@ pub(super) struct Fight { respawn: Option<(Respawn, i32)>, /// The four crystals on the exit portal driving the respawn. respawn_crystals: Vec, + /// The player behind the crystal blast under way, whose `explosion` + /// damage source names them (`EndCrystal.hurtServer`). + blast_by: Option, dirty: bool, } #[derive(Clone, Copy, Debug, PartialEq, Eq)] @@ -899,8 +902,12 @@ impl Game<'_> { .any(|p| p.distance_squared(c.position) < 0.01); if damage == CrystalDamage::Direct { let at = [c.position.x, c.position.y, c.position.z]; + // The blast's damage source carries the player, so the dragon + // remembers them before the blast can kill it. + self.fight.blast_by = by; let _ = self.server_explode(at, 6.0, super::explosion::BlockInteraction::Destroy, false); + self.fight.blast_by = None; } if respawn_crystal { self.abort_respawn(); @@ -1003,10 +1010,13 @@ impl Game<'_> { return Hurt::Refused; }; let was_down = d.down(); + let (cooldown, last_hurt) = (d.invulnerable, d.last_hurt); let hurt = d.hurt(part, damage, counts, arrow); - // LivingEntity.hurtServer: a player's hit sets lastHurtByPlayer (100 ticks). + // LivingEntity.hurtServer: damage that is applied sets lastHurtByPlayer + // (100 ticks); a hit the damage cooldown absorbs returns before that. if counts && matches!(hurt, Hurt::Landed { .. }) + && (d.invulnerable != cooldown || d.last_hurt != last_hurt) && let Some(who) = by { d.hurt_by_player = Some((who, d.ticks)); @@ -2787,8 +2797,9 @@ impl Game<'_> { let (lo, hi) = (b.min_position(), b.max_position()); self.seen_percent(center, [lo.x, lo.y, lo.z], [hi.x, hi.y, hi.z]) }); + let by = self.fight.blast_by; for (part, amount) in hits { - self.hurt_dragon(part, amount, true, None, false); + self.hurt_dragon(part, amount, true, by, false); } } } From cdafcd756f1c436a9a41cceaa7fee118982bbe11 Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Mon, 26 Oct 2026 21:18:05 +0100 Subject: [PATCH 19/36] Open links and page links in written books --- crates/horizon-client/src/component.rs | 7 ++ crates/horizon-client/src/game/books.rs | 104 +++++++++++++++++++----- crates/horizon-client/src/game/chat.rs | 5 +- crates/horizon-client/src/item_data.rs | 23 ++++-- crates/horizon-client/src/lan/guest.rs | 13 +-- crates/horizon-client/src/text.rs | 3 + 6 files changed, 123 insertions(+), 32 deletions(-) diff --git a/crates/horizon-client/src/component.rs b/crates/horizon-client/src/component.rs index 0f0adef57..cfb15bf0d 100644 --- a/crates/horizon-client/src/component.rs +++ b/crates/horizon-client/src/component.rs @@ -177,6 +177,13 @@ fn object_style(o: &serde_json::Map) -> Style { Some("open_url") => text("url") .filter(|u| u.starts_with("http://") || u.starts_with("https://")) .map(crate::text::ClickEvent::OpenUrl), + // ClickEvent.ChangePage.CODEC: ExtraCodecs.POSITIVE_INT. + Some("change_page") => e + .get("page") + .and_then(Value::as_i64) + .and_then(|p| i32::try_from(p).ok()) + .filter(|p| *p >= 1) + .map(crate::text::ClickEvent::ChangePage), Some("suggest_command") => text("command").map(crate::text::ClickEvent::SuggestCommand), Some("copy_to_clipboard") => { text("value").map(crate::text::ClickEvent::CopyToClipboard) diff --git a/crates/horizon-client/src/game/books.rs b/crates/horizon-client/src/game/books.rs index 2f38dffd9..610b52265 100644 --- a/crates/horizon-client/src/game/books.rs +++ b/crates/horizon-client/src/game/books.rs @@ -8,7 +8,7 @@ use horizon_client::{ containers::{BlockEntity, Lectern}, first_person::Hand, hud::{HudBatch, rgba}, - item_data::WrittenBook, + item_data::{StackData, WrittenBook}, items::ItemStack, menu::{Kind, Menu}, text::Text, @@ -59,14 +59,86 @@ pub(super) enum BookScreen { page_edit: ui::EditBox, }, View { - pages: Vec, + pages: Vec, page: usize, lectern: Option<(i32, i32, i32)>, }, } +/// The pages a book screen reads: a written book's components (so their +/// click events stay), else a writable book's text. +fn view_pages(data: Option<&StackData>) -> Vec { + let Some(data) = data else { return Vec::new() }; + let Some(w) = &data.written else { + return data.writable_pages.iter().map(Text::literal).collect(); + }; + let tagged = w.page_tags.len() == w.pages.len(); + w.pages + .iter() + .enumerate() + .map(|(i, page)| match tagged.then(|| &w.page_tags[i]) { + Some(tag @ horizon_world::nbt::Tag::Compound(_)) => { + horizon_client::entity_nbt::name_text(tag) + } + _ => Text::literal(page), + }) + .collect() +} impl Game<'_> { fn book_lines(&self, page: &str) -> Vec { - self.gui.atlas.font.split(&Text::literal(page), 114.0) + self.page_lines(&Text::literal(page)) + } + fn page_lines(&self, page: &Text) -> Vec { + self.gui.atlas.font.split(page, 114.0) + } + /// `BookViewScreen.mouseClicked`: the click event of the text under the + /// cursor on the page. + fn book_link_at(&self, page: &Text, left: f32) -> Option { + let (mx, my) = self.cursor; + let row = ((my - 32.0) / 9.0).floor(); + if row < 0.0 || row >= LINES as f32 { + return None; + } + let lines = self.page_lines(page); + let line = lines.get(row as usize)?.resolve_legacy(); + let mut x = mx - (left + 36.0); + if x < 0.0 { + return None; + } + for (c, style) in line.chars() { + x -= self.gui.atlas.font.advance(c, style); + if x < 0.0 { + return style.click.clone(); + } + } + None + } + /// `BookViewScreen.handleClickEvent`: a page link turns to its page + /// (`forcePage`), a web link goes through the confirm-link flow. + fn book_follow_link( + &mut self, + link: horizon_client::text::ClickEvent, + count: usize, + lectern: Option<(i32, i32, i32)>, + ) { + use horizon_client::text::ClickEvent; + match link { + ClickEvent::ChangePage(target) => { + let target = (target - 1).clamp(0, count.saturating_sub(1) as i32); + let Some(BookScreen::View { page, .. }) = self.book.as_mut() else { + return; + }; + if let Some(key) = lectern { + // LecternScreen.forcePage: the menu's button 100 + page. + if target != *page as i32 { + self.lectern_button(key, 100 + target); + } + } else if target != *page as i32 { + *page = target as usize; + } + } + ClickEvent::OpenUrl(url) => self.click_url(url), + _ => {} + } } /// `WritableBookItem.use` / `WrittenBookItem.use` (`Player.openItemGui`). /// A server's player writes in its own client's editor @@ -115,11 +187,7 @@ impl Game<'_> { } } "minecraft:written_book" => BookScreen::View { - pages: stack - .data() - .and_then(|d| d.written.as_ref()) - .map(|w| w.pages.clone()) - .unwrap_or_default(), + pages: view_pages(stack.data()), page: 0, lectern: None, }, @@ -215,6 +283,7 @@ impl Game<'_> { author, generation: 0, pages, + page_tags: Vec::new(), }); *stack = written; } else { @@ -685,11 +754,7 @@ impl Game<'_> { return false; }; let Some(book) = &l.book else { return false }; - let data = book.data(); - let pages = data - .and_then(|d| d.written.as_ref().map(|w| w.pages.clone())) - .or_else(|| data.map(|d| d.writable_pages.clone())) - .unwrap_or_default(); + let pages = view_pages(book.data()); let page = (l.page.max(0) as usize).min(pages.len().saturating_sub(1)); self.stats.custom("interact_with_lectern", 1); self.open_book(BookScreen::View { @@ -811,11 +876,7 @@ impl Game<'_> { page, }) = self.book.as_mut() { - let data = book.as_ref().and_then(ItemStack::data); - *pages = data - .and_then(|d| d.written.as_ref().map(|w| w.pages.clone())) - .or_else(|| data.map(|d| d.writable_pages.clone())) - .unwrap_or_default(); + *pages = view_pages(book.as_ref().and_then(ItemStack::data)); *page = (*page).min(pages.len().saturating_sub(1)); } } @@ -955,7 +1016,10 @@ impl Game<'_> { lectern, }) => { let (page, count, lectern) = (*page, pages.len(), *lectern); - if page + 1 < count && inside(left + 116.0, 159.0, 23.0, 13.0) { + // The text's click event first, then the buttons. + if let Some(link) = pages.get(page).and_then(|t| self.book_link_at(t, left)) { + self.book_follow_link(link, count, lectern); + } else if page + 1 < count && inside(left + 116.0, 159.0, 23.0, 13.0) { self.turn_page(true); } else if page > 0 && inside(left + 43.0, 159.0, 23.0, 13.0) { self.turn_page(false); @@ -1195,7 +1259,7 @@ impl Game<'_> { } => { indicator(batch, *page, pages.len()); if let Some(text) = pages.get(*page) { - for (i, line) in self.book_lines(text).iter().take(LINES).enumerate() { + for (i, line) in self.page_lines(text).iter().take(LINES).enumerate() { batch.text_styled( atlas, line, diff --git a/crates/horizon-client/src/game/chat.rs b/crates/horizon-client/src/game/chat.rs index 29cda8b2c..d9a8f39ae 100644 --- a/crates/horizon-client/src/game/chat.rs +++ b/crates/horizon-client/src/game/chat.rs @@ -701,12 +701,13 @@ impl Game<'_> { screen.suggest_command(&m, &c, &command); } } - None => {} + // Screen.defaultHandleClickEvent: a page link means nothing in chat. + Some(ClickEvent::ChangePage(_)) | None => {} } } /// `Screen.clickUrlAction`: nothing with Web Links off, else the link /// opens, after the confirmation unless Prompt on Links is off. - fn click_url(&mut self, url: String) { + pub(super) fn click_url(&mut self, url: String) { if !self.settings.chat_links { return; } diff --git a/crates/horizon-client/src/item_data.rs b/crates/horizon-client/src/item_data.rs index ac624e85b..856eb2af3 100644 --- a/crates/horizon-client/src/item_data.rs +++ b/crates/horizon-client/src/item_data.rs @@ -127,6 +127,9 @@ pub struct WrittenBook { pub author: String, pub generation: u8, pub pages: Vec, + /// Each page's component when it is not a plain string, so that its + /// click events survive; empty or one per page. + pub page_tags: Vec, } impl StackData { pub fn is_empty(&self) -> bool { @@ -522,11 +525,14 @@ pub fn components_tag(damage: u32, data: Option<&StackData>) -> Option { )); } if let Some(w) = &d.written { - let pages = w - .pages - .iter() - .map(|p| raw(Tag::String(p.as_str().into()))) - .collect(); + let pages = if w.page_tags.len() == w.pages.len() { + w.page_tags.iter().cloned().map(raw).collect() + } else { + w.pages + .iter() + .map(|p| raw(Tag::String(p.as_str().into()))) + .collect() + }; entries.push(( "minecraft:written_book_content", Tag::compound({ @@ -707,6 +713,13 @@ pub fn decode_components(components: Option<&Tag>) -> (u32, Option pages.iter().filter_map(filterable_text).collect(), _ => Vec::new(), }, + page_tags: match b.get("pages") { + Some(Tag::List(pages)) => pages + .iter() + .map(|p| p.get("raw").unwrap_or(p).clone()) + .collect(), + _ => Vec::new(), + }, }), fireworks: c .get("minecraft:fireworks") diff --git a/crates/horizon-client/src/lan/guest.rs b/crates/horizon-client/src/lan/guest.rs index 7e43cf04e..f29ea7048 100644 --- a/crates/horizon-client/src/lan/guest.rs +++ b/crates/horizon-client/src/lan/guest.rs @@ -631,11 +631,14 @@ fn network_stack( title: w.title.clone(), author: w.author.clone(), generation: i32::from(w.generation), - pages: w - .pages - .iter() - .map(|p| horizon_protocol::text::literal(p)) - .collect(), + pages: if w.page_tags.len() == w.pages.len() { + w.page_tags.clone() + } else { + w.pages + .iter() + .map(|p| horizon_protocol::text::literal(p)) + .collect() + }, resolved: true, }, ), diff --git a/crates/horizon-client/src/text.rs b/crates/horizon-client/src/text.rs index 20cbdc65a..78d905622 100644 --- a/crates/horizon-client/src/text.rs +++ b/crates/horizon-client/src/text.rs @@ -44,6 +44,8 @@ pub fn named_color(name: &str) -> Option { pub enum ClickEvent { /// `ClickEvent.OpenUrl`: an http or https link. OpenUrl(String), + /// `ClickEvent.ChangePage`: a book's page, counted from 1. + ChangePage(i32), SuggestCommand(String), CopyToClipboard(String), /// A local file to open with the system handler. @@ -532,6 +534,7 @@ fn style_json(style: &Style) -> Vec<(String, Value)> { if let Some(click) = &style.click { let event = match click { ClickEvent::OpenUrl(url) => json!({ "action": "open_url", "url": url }), + ClickEvent::ChangePage(page) => json!({ "action": "change_page", "page": page }), ClickEvent::SuggestCommand(command) => { json!({ "action": "suggest_command", "command": command }) } From 9958fe0e49b49e0a933c65d32309e1d362f18674 Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Mon, 26 Oct 2026 21:29:26 +0100 Subject: [PATCH 20/36] Light redstone ore when an entity stands on it --- crates/horizon-client/src/game/sculk.rs | 26 +++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/crates/horizon-client/src/game/sculk.rs b/crates/horizon-client/src/game/sculk.rs index 7916c46a1..9b066a710 100644 --- a/crates/horizon-client/src/game/sculk.rs +++ b/crates/horizon-client/src/game/sculk.rs @@ -1530,6 +1530,9 @@ impl Game<'_> { }); if let Some((at, on_ground, health, flying)) = player { let crouch = self.keys.contains(&KeyCode::ShiftLeft); + if on_ground && !self.spectator() { + self.step_on_redstone_ore(at, crouch); + } let in_water = self.in_water_at(at); self.entity_motion_events( Who::Player, @@ -1548,6 +1551,26 @@ impl Game<'_> { } } + /// `RedStoneOreBlock.stepOn`: standing on the ore lights it, unless the + /// entity is stepping carefully (`attack_block` only lights an unlit ore). + fn step_on_redstone_ore(&mut self, at: [f64; 3], carefully: bool) { + if carefully { + return; + } + // getOnPosLegacy: 0.2 below the feet. + let pos = [ + at[0].floor() as i32, + (at[1] - 0.2).floor() as i32, + at[2].floor() as i32, + ]; + if matches!( + &*self.block_name(pos), + "minecraft:redstone_ore" | "minecraft:deepslate_redstone_ore" + ) { + let _ = self.attack_block(pos); + } + } + fn tick_mob_sculk_events(&mut self) { let snapshot: Vec<(u32, [f64; 3], bool, bool, Species, Option)> = self .mobs @@ -1565,6 +1588,9 @@ impl Game<'_> { }) .collect(); for (id, at, on_ground, in_water, species, damaged) in snapshot { + if on_ground { + self.step_on_redstone_ore(at, false); + } let emits = !matches!(species, Species::Shulker); if emits { self.entity_motion_events(Who::Mob(id), at, on_ground, in_water, false, false); From 414a2b82a8b9855da62e94467c3352c208376ce4 Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Mon, 26 Oct 2026 21:30:57 +0100 Subject: [PATCH 21/36] Do not rebuild the End exit podium once the fight has its location --- crates/horizon-client/src/game/end.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/crates/horizon-client/src/game/end.rs b/crates/horizon-client/src/game/end.rs index 32d5113b0..749680cd7 100644 --- a/crates/horizon-client/src/game/end.rs +++ b/crates/horizon-client/src/game/end.rs @@ -599,7 +599,9 @@ impl Game<'_> { /// EnderDragonFight without a dragon: once the centre of the main island /// is loaded, place the active exit portal (EndPodiumFeature) and the - /// first gateway (spawnNewGateway) if the portal is not there yet. + /// first gateway (spawnNewGateway) if the portal is not there yet. Like + /// scanState and spawnExitPortal, only while the fight has no exit portal + /// location: a podium that is later broken stays broken. fn ensure_exit_portal(&mut self) -> Result<()> { if self.travelling.is_some() || !(-1..=0).all(|cz| (-1..=0).all(|cx| self.streaming.is_lit(cx, cz))) @@ -609,8 +611,15 @@ impl Game<'_> { } let won = self.fight.previously_killed; let gateway = self.first_gateway(); - if (0..256).any(|y| &*self.block_name([0, y, 0]) == "minecraft:bedrock") { - // The podium exists; the gateway may have been out of range when it was placed. + let bedrock_top = (0..256) + .rev() + .find(|&y| &*self.block_name([0, y, 0]) == "minecraft:bedrock"); + if bedrock_top.is_some() || self.exit_portal().is_some() { + if let Some(top) = bedrock_top { + // findExitPortal remembers the location of a podium that is already there. + self.set_exit_portal([0, top - 3, 0]); + } + // The gateway may have been out of range when it was placed. if won && self.world.loaded(gateway[0], gateway[2]) && &*self.block_name(gateway) != "minecraft:end_gateway" From b33ae69938eda922d839b881fbce082ade1f3956 Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Mon, 26 Oct 2026 21:43:08 +0100 Subject: [PATCH 22/36] Find the End podium level from its rim so a broken centre column is fine --- crates/horizon-client/src/game/end.rs | 48 +++++++++++++++++++-------- 1 file changed, 35 insertions(+), 13 deletions(-) diff --git a/crates/horizon-client/src/game/end.rs b/crates/horizon-client/src/game/end.rs index 749680cd7..4f05c4a5b 100644 --- a/crates/horizon-client/src/game/end.rs +++ b/crates/horizon-client/src/game/end.rs @@ -611,14 +611,13 @@ impl Game<'_> { } let won = self.fight.previously_killed; let gateway = self.first_gateway(); - let bedrock_top = (0..256) - .rev() - .find(|&y| &*self.block_name([0, y, 0]) == "minecraft:bedrock"); - if bedrock_top.is_some() || self.exit_portal().is_some() { - if let Some(top) = bedrock_top { - // findExitPortal remembers the location of a podium that is already there. - self.set_exit_portal([0, top - 3, 0]); + if self.exit_portal().is_none() { + // findExitPortal remembers the location of a podium that is already there. + if let Some(level) = self.podium_level() { + self.set_exit_portal([0, level, 0]); } + } + if self.exit_portal().is_some() { // The gateway may have been out of range when it was placed. if won && self.world.loaded(gateway[0], gateway[2]) @@ -650,17 +649,40 @@ impl Game<'_> { } Ok(()) } + /// The portal level of the podium around the centre column, read from the + /// bedrock that EndPodiumFeature places (rim at the portal level, disc + /// below it, the torch column) so a broken column does not hide it. + fn podium_level(&self) -> Option { + let mut offsets: Vec<[i32; 3]> = (0..4).map(|dy| [0, dy, 0]).collect(); + for z in -4..=4i32 { + for x in -4..=4i32 { + let flat = f64::from(x * x + z * z); + if (6.25..12.25).contains(&flat) { + offsets.push([x, 0, z]); + } else if flat + 1.0 < 6.25 { + offsets.push([x, -1, z]); + } + } + } + (1..253) + .map(|y| { + let score = offsets + .iter() + .filter(|o| &*self.block_name([o[0], y + o[1], o[2]]) == "minecraft:bedrock") + .count(); + (score, y) + }) + .filter(|&(score, _)| score >= 3) + .max() + .map(|(_, y)| y) + } /// `spawnExitPortal(true)` after the dragon dies. pub(super) fn activate_exit_portal(&mut self) -> Result<()> { let origin = match self.exit_portal() { Some(o) => o, None => { - // The rim's level: the top of the bedrock column minus three. - let top = (0..256) - .rev() - .find(|&y| &*self.block_name([0, y, 0]) == "minecraft:bedrock") - .unwrap_or(64); - [0, top - 3, 0] + // The rim's level, found without assuming the centre column is intact. + [0, self.podium_level().unwrap_or(61), 0] } }; self.place_podium(origin, true) From e41c602359730f1a7b34f333df6d0f12b369a04f Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Mon, 26 Oct 2026 21:46:00 +0100 Subject: [PATCH 23/36] Keep picking up a banner next to a raider even when its path was cached as unreachable --- crates/horizon-client/src/game/raids.rs | 36 +++++++++++++++---------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/crates/horizon-client/src/game/raids.rs b/crates/horizon-client/src/game/raids.rs index e34d9feed..dd3f3f29e 100644 --- a/crates/horizon-client/src/game/raids.rs +++ b/crates/horizon-client/src/game/raids.rs @@ -856,23 +856,31 @@ impl Game<'_> { && raids.get(id).is_some_and(|r| r.leader(s.wave).is_none()) && !leaders.contains(&(id, s.wave)) { + let in_reach = |(i, _, p): &&(usize, u32, Vec3)| { + !taken.contains(i) + && (p.x - position.x).abs() <= range + && (p.z - position.z).abs() <= range + && (p.y - position.y).abs() <= 8.0 + }; + let by_distance = |a: &&(usize, u32, Vec3), b: &&(usize, u32, Vec3)| { + a.2.distance_squared(position) + .total_cmp(&b.2.distance_squared(position)) + }; + // The unreachable cache only picks the navigation target; + // a banner next to the raider is still picked up. let near = banners .iter() - .filter(|(i, item, p)| { - !taken.contains(i) - && !s - .unreachable_banners - .iter() - .any(|&(b, until)| b == *item && now < until) - && (p.x - position.x).abs() <= range - && (p.z - position.z).abs() <= range - && (p.y - position.y).abs() <= 8.0 + .filter(in_reach) + .filter(|(_, item, _)| { + !s.unreachable_banners + .iter() + .any(|&(b, until)| b == *item && now < until) }) - .min_by(|a, b| { - a.2.distance_squared(position) - .total_cmp(&b.2.distance_squared(position)) - }); - if let Some((i, item, p)) = near { + .min_by(by_distance); + let nearest = banners.iter().filter(in_reach).min_by(by_distance); + let adjacent = + nearest.filter(|(_, _, p)| p.distance_squared(position) < 1.414 * 1.414); + if let Some((i, item, p)) = adjacent.or(near) { s.banner_at = Some([p.x, p.y, p.z]); s.banner_item = *item; if p.distance_squared(position) < 1.414 * 1.414 { From db985f717ce34b63566922b7e3d79cc6559d2c73 Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Mon, 26 Oct 2026 21:46:04 +0100 Subject: [PATCH 24/36] Spectator crosshair also checks the other half of a double chest --- crates/horizon-client/src/game/hand.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/crates/horizon-client/src/game/hand.rs b/crates/horizon-client/src/game/hand.rs index c3fd78310..60869952f 100644 --- a/crates/horizon-client/src/game/hand.rs +++ b/crates/horizon-client/src/game/hand.rs @@ -333,12 +333,16 @@ impl Game<'_> { | "dispenser" | "dropper" | "crafter" | "lectern" | "beacon" | "nether_portal" | "end_portal" | "end_gateway" => true, // ChestBlock.getMenuProvider: none while a redstone conductor - // sits on top (a sitting cat aside). + // sits on top of either half (a sitting cat aside). "chest" | "trapped_chest" => { - let above = self.world.block(hit.pos[0], hit.pos[1] + 1, hit.pos[2]); - self.res.behaviours().facts(above).flags - & horizon_world::level::data::state_flags::CONDUCTOR - == 0 + let key = (hit.pos[0], hit.pos[1], hit.pos[2]); + let blocked = |p: (i32, i32, i32)| { + let above = self.world.block(p.0, p.1 + 1, p.2); + self.res.behaviours().facts(above).flags + & horizon_world::level::data::state_flags::CONDUCTOR + != 0 + }; + !blocked(key) && self.chest_other_half(key).is_none_or(|o| !blocked(o)) } _ => name.ends_with("shulker_box"), } From 35a02c79a8d433e86e5b1aa1a8f5afdbbfa268fb Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Mon, 26 Oct 2026 21:46:18 +0100 Subject: [PATCH 25/36] Cats also skip chests a copper golem has open --- crates/horizon-client/src/mobs/tame.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/crates/horizon-client/src/mobs/tame.rs b/crates/horizon-client/src/mobs/tame.rs index 30ac762b9..0049e7f98 100644 --- a/crates/horizon-client/src/mobs/tame.rs +++ b/crates/horizon-client/src/mobs/tame.rs @@ -846,8 +846,13 @@ fn can_sit_on(w: &MobWorld, p: [i32; 3]) -> bool { match f.name.as_ref() { // The lit state is the only light source a furnace has. "minecraft:furnace" => f.emission > 0, - // `ChestBlockEntity.getOpenCount(level, pos) < 1`. - "minecraft:chest" => !w.lid_openers.contains_key(&(p[0], p[1], p[2])), + // `ChestBlockEntity.getOpenCount(level, pos) < 1`: players' openers + // and the copper golems' own count. + "minecraft:chest" => { + let key = (p[0], p[1], p[2]); + !w.lid_openers.contains_key(&key) + && w.world.chest_openers.get(&key).is_none_or(|o| o.0 < 1) + } // A bed's foot only (`BedBlock.PART != HEAD`). _ => w.prop(p[0], p[1], p[2], "part") != Some("head"), } From d8b8246622bbbbb0cb1479dfff79536cf7318587 Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Mon, 26 Oct 2026 21:46:31 +0100 Subject: [PATCH 26/36] Light redstone ore under dropped items too --- crates/horizon-client/src/game/sculk.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/crates/horizon-client/src/game/sculk.rs b/crates/horizon-client/src/game/sculk.rs index 9b066a710..23c3c2acf 100644 --- a/crates/horizon-client/src/game/sculk.rs +++ b/crates/horizon-client/src/game/sculk.rs @@ -1515,6 +1515,16 @@ impl Game<'_> { fn tick_entity_events(&mut self) { self.tick_player_sculk_events(); self.tick_mob_sculk_events(); + // Dropped items are entities too: Entity.applyEffectsFromBlocks. + let items: Vec<[f64; 3]> = self + .dropped + .iter() + .filter(|i| i.on_ground) + .map(|i| [i.position.x, i.position.y, i.position.z]) + .collect(); + for at in items { + self.step_on_redstone_ore(at, false); + } } /// Entity.move emits on the authoritative server too, for each ServerPlayer. From 77fe538e09b0b8677634083d6fdca88d9f543b45 Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Mon, 26 Oct 2026 21:48:05 +0100 Subject: [PATCH 27/36] Let only the owner command a tame wolf or cat, and make pets follow their owner Sitting, standing, dyeing and healing a cat or wolf now check the saved owner. The follow, teleport and owner-hurt goals use the owner, not the nearest player, and a new tame wolf or cat is owned by whoever tamed it. --- crates/horizon-client/src/game/creatures.rs | 22 ++++++++++++++----- crates/horizon-client/src/game/lan_mobs.rs | 15 ++++++++++++- crates/horizon-client/src/mobs/tame.rs | 24 +++++++++++++-------- 3 files changed, 46 insertions(+), 15 deletions(-) diff --git a/crates/horizon-client/src/game/creatures.rs b/crates/horizon-client/src/game/creatures.rs index f6961ab13..68964a3fd 100644 --- a/crates/horizon-client/src/game/creatures.rs +++ b/crates/horizon-client/src/game/creatures.rs @@ -2739,6 +2739,7 @@ impl Game<'_> { .items() .get(&item) .is_some_and(|i| i.max_damage > 0); + let acting = self.acting_uuid(); let m = &mut self.mobs[index]; if !m.alive() { return Ok(false); @@ -2833,6 +2834,7 @@ impl Game<'_> { } Species::Wolf if m.extra.tame + && m.extra.owner == Some(acting) && item.ends_with("_dye") && horizon_client::mobs::render::DYE_NAMES .iter() @@ -2855,7 +2857,9 @@ impl Game<'_> { consume = true; } Species::Wolf - if m.extra.tame && !(is_food && m.extra.age == 0 && m.extra.in_love <= 0) => + if m.extra.tame + && m.extra.owner == Some(acting) + && !(is_food && m.extra.age == 0 && m.extra.in_love <= 0) => { m.extra.sitting = !m.extra.sitting; m.ai.jumping = false; @@ -2875,7 +2879,7 @@ impl Game<'_> { let tamed = m.random.next_int_bound(3).unwrap_or(1) == 0; if tamed { horizon_client::mobs::tame::set_tame(m, true); - m.extra.owner = self.level.player_uuid.or(Some([0, 0, 0, 1])); + m.extra.owner = Some(acting); m.persistent = true; m.nav_stop(); m.ai.target = None; @@ -2902,6 +2906,7 @@ impl Game<'_> { // Cat.mobInteract: dye, heal or sit when tame; fish may tame a wild one. Species::Cat if m.extra.tame + && m.extra.owner == Some(acting) && item.ends_with("_dye") && horizon_client::mobs::render::DYE_NAMES .iter() @@ -2924,7 +2929,12 @@ impl Game<'_> { m.persistent = true; consume = true; } - Species::Cat if m.extra.tame && is_food && m.health < m.attrs.max_health => { + Species::Cat + if m.extra.tame + && m.extra.owner == Some(acting) + && is_food + && m.health < m.attrs.max_health => + { let heal = self .res .items() @@ -2937,7 +2947,9 @@ impl Game<'_> { eat = eating_sound(m, &mut self.world.random); } Species::Cat - if m.extra.tame && !(is_food && m.extra.age == 0 && m.extra.in_love <= 0) => + if m.extra.tame + && m.extra.owner == Some(acting) + && !(is_food && m.extra.age == 0 && m.extra.in_love <= 0) => { m.extra.sitting = !m.extra.sitting; self.world.modified.insert(( @@ -2951,7 +2963,7 @@ impl Game<'_> { let tamed = m.random.next_int_bound(3).unwrap_or(1) == 0; if tamed { m.extra.tame = true; - m.extra.owner = self.level.player_uuid.or(Some([0, 0, 0, 1])); + m.extra.owner = Some(acting); m.extra.sitting = true; } eat = eating_sound(m, &mut self.world.random); diff --git a/crates/horizon-client/src/game/lan_mobs.rs b/crates/horizon-client/src/game/lan_mobs.rs index 6527f1015..f0e7cb4f9 100644 --- a/crates/horizon-client/src/game/lan_mobs.rs +++ b/crates/horizon-client/src/game/lan_mobs.rs @@ -5,7 +5,7 @@ //! (hits, pushes, fire, its projectiles) runs with that guest swapped in. use super::{Game, lan::LanHost}; use horizon_client::{ - mobs::{Mob, MobEvent, PlayerView, Who}, + mobs::{Mob, MobEvent, PlayerView, Species, Who}, projectiles::{Hit, Projectile}, }; use horizon_core::geometry::{Aabb, Vec3}; @@ -26,6 +26,19 @@ pub(super) fn player_for( guests: &GuestViews, bound: Option, ) -> Option { + // A tame wolf or cat sees its owner (`TamableAnimal.getOwner`), while they + // are in play, whoever is nearer. + if matches!(m.species(), Species::Wolf | Species::Cat) + && m.extra.tame + && let Some(owner) = m.extra.owner + { + if host.is_some_and(|v| v.alive && v.uuid == owner) { + return None; + } + if let Some((conn, _)) = guests.iter().find(|(_, v)| v.alive && v.uuid == owner) { + return Some(*conn); + } + } let targeting = m.ai.target == Some(Who::Player) || m.ai.last_hurt_by == Some(Who::Player) && m.age as i32 - m.ai.last_hurt_by_time <= 100; choose(m.position, targeting, host, guests, bound) diff --git a/crates/horizon-client/src/mobs/tame.rs b/crates/horizon-client/src/mobs/tame.rs index 1e725df80..85d8a3cd0 100644 --- a/crates/horizon-client/src/mobs/tame.rs +++ b/crates/horizon-client/src/mobs/tame.rs @@ -2,7 +2,7 @@ //! sitting, following and defending the owner, begging, anger and shaking //! off water (`Wolf`, `WolfModel`). use super::{ - Damage, Mob, MobEvent, MobWorld, Species, Who, + Damage, Mob, MobEvent, MobWorld, PlayerView, Species, Who, anim::{Poses, State}, goals::{ Breed, Cx, Float, Goal, HurtByTarget, JUMP, LOOK, LeapAtTarget, LookAtPlayer, MOVE, @@ -124,17 +124,23 @@ pub fn set_tame(m: &mut Mob, tame: bool) { m.attrs.max_health = 8.0; } } -/// The owner (the local player) when tame. -fn owner(m: &Mob, w: &MobWorld) -> Option<(Vec3, f64, bool)> { +/// `TamableAnimal.getOwner`: the player the saved owner UUID names, when it +/// is the one this mob sees; anyone else nearby is not its owner. +fn owner_view<'a>(m: &Mob, w: &'a MobWorld) -> Option<&'a PlayerView> { if !m.extra.tame { return None; } let p = w.player.as_ref()?; + (m.extra.owner == Some(p.uuid)).then_some(p) +} +/// The owner's position, eye height and spectator flag when tame. +fn owner(m: &Mob, w: &MobWorld) -> Option<(Vec3, f64, bool)> { + let p = owner_view(m, w)?; Some((p.position, p.eye[1], p.spectator)) } /// `TamableAnimal.unableToMoveToOwner`. fn unable_to_move_to_owner(m: &Mob, w: &MobWorld) -> bool { - m.extra.sitting || w.player.as_ref().is_some_and(|p| p.spectator) + m.extra.sitting || owner_view(m, w).is_some_and(|p| p.spectator) } /// `TamableAnimal.tryToTeleportToOwner`: ten tries around the owner. fn teleport_to_owner(m: &mut Mob, w: &MobWorld) { @@ -240,7 +246,7 @@ impl Goal for SitWhenOrdered { match owner_distance_sqr(m, cx.w) { None => true, Some(d) => { - let attacked = cx.w.player.as_ref().is_some_and(|p| p.hurt_by.is_some()); + let attacked = owner_view(m, cx.w).is_some_and(|p| p.hurt_by.is_some()); !(d < 144.0 && attacked) && m.extra.sitting } } @@ -388,7 +394,7 @@ impl Goal for OwnerHurtBy { if !m.extra.tame || m.extra.sitting { return false; } - let Some((who, at)) = cx.w.player.as_ref().and_then(|p| p.hurt_by) else { + let Some((who, at)) = owner_view(m, cx.w).and_then(|p| p.hurt_by) else { return false; }; at != self.timestamp && wants_to_attack(m, cx.w, who) @@ -399,7 +405,7 @@ impl Goal for OwnerHurtBy { .is_some_and(|t| t.alive) } fn start(&mut self, m: &mut Mob, cx: &mut Cx) { - if let Some((who, at)) = cx.w.player.as_ref().and_then(|p| p.hurt_by) { + if let Some((who, at)) = owner_view(m, cx.w).and_then(|p| p.hurt_by) { m.ai.target = Some(who); self.timestamp = at; } @@ -422,7 +428,7 @@ impl Goal for OwnerHurt { if !m.extra.tame || m.extra.sitting { return false; } - let Some((who, at)) = cx.w.player.as_ref().and_then(|p| p.last_hurt) else { + let Some((who, at)) = owner_view(m, cx.w).and_then(|p| p.last_hurt) else { return false; }; at != self.timestamp && wants_to_attack(m, cx.w, who) @@ -433,7 +439,7 @@ impl Goal for OwnerHurt { .is_some_and(|t| t.alive) } fn start(&mut self, m: &mut Mob, cx: &mut Cx) { - if let Some((who, at)) = cx.w.player.as_ref().and_then(|p| p.last_hurt) { + if let Some((who, at)) = owner_view(m, cx.w).and_then(|p| p.last_hurt) { m.ai.target = Some(who); self.timestamp = at; } From 2929bb6dbabbcd337753febc0c69d0055c5c08f4 Mon Sep 17 00:00:00 2001 From: Ludovic Marie <136255825+ludovic111@users.noreply.github.com> Date: Mon, 26 Oct 2026 22:00:23 +0100 Subject: [PATCH 28/36] open_url: accept the http and https schemes in any case Util.parseAndValidateUntrustedUri lowercases the scheme before checking it. Co-Authored-By: Claude Opus 5.5 --- crates/horizon-client/src/component.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/crates/horizon-client/src/component.rs b/crates/horizon-client/src/component.rs index cfb15bf0d..64d79f274 100644 --- a/crates/horizon-client/src/component.rs +++ b/crates/horizon-client/src/component.rs @@ -173,9 +173,14 @@ fn object_style(o: &serde_json::Map) -> Style { if let Some(e) = o.get("click_event").and_then(Value::as_object) { let text = |k: &str| e.get(k).and_then(Value::as_str).map(str::to_owned); style.click = match e.get("action").and_then(Value::as_str) { - // ClickEvent.OpenUrl.CODEC: ExtraCodecs.UNTRUSTED_URI allows http and https only. + // ClickEvent.OpenUrl.CODEC: ExtraCodecs.UNTRUSTED_URI allows http and + // https only, the scheme in any case (Util.parseAndValidateUntrustedUri). Some("open_url") => text("url") - .filter(|u| u.starts_with("http://") || u.starts_with("https://")) + .filter(|u| { + u.split_once(':').is_some_and(|(scheme, _)| { + scheme.eq_ignore_ascii_case("http") || scheme.eq_ignore_ascii_case("https") + }) + }) .map(crate::text::ClickEvent::OpenUrl), // ClickEvent.ChangePage.CODEC: ExtraCodecs.POSITIVE_INT. Some("change_page") => e From d2a8cf3bdfffbca0f77f897db5a03fa2b13ced1a Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Mon, 26 Oct 2026 22:05:02 +0100 Subject: [PATCH 29/36] Keep a hurt pet's attacker as its player instead of swapping in the owner --- crates/horizon-client/src/game/lan_mobs.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/crates/horizon-client/src/game/lan_mobs.rs b/crates/horizon-client/src/game/lan_mobs.rs index f0e7cb4f9..75b56ae7b 100644 --- a/crates/horizon-client/src/game/lan_mobs.rs +++ b/crates/horizon-client/src/game/lan_mobs.rs @@ -26,9 +26,14 @@ pub(super) fn player_for( guests: &GuestViews, bound: Option, ) -> Option { + let targeting = m.ai.target == Some(Who::Player) + || m.ai.last_hurt_by == Some(Who::Player) && m.age as i32 - m.ai.last_hurt_by_time <= 100; // A tame wolf or cat sees its owner (`TamableAnimal.getOwner`), while they - // are in play, whoever is nearer. - if matches!(m.species(), Species::Wolf | Species::Cat) + // are in play, whoever is nearer. Not while it targets or was just hurt by + // a player: then `Who::Player` is that attacker, whoever it is, and the + // owner goals ignore it until the wolf lets go. + if !targeting + && matches!(m.species(), Species::Wolf | Species::Cat) && m.extra.tame && let Some(owner) = m.extra.owner { @@ -39,8 +44,6 @@ pub(super) fn player_for( return Some(*conn); } } - let targeting = m.ai.target == Some(Who::Player) - || m.ai.last_hurt_by == Some(Who::Player) && m.age as i32 - m.ai.last_hurt_by_time <= 100; choose(m.position, targeting, host, guests, bound) } From c352c80c9645bd333f630a28dceda2e9035117fc Mon Sep 17 00:00:00 2001 From: Ludovic Marie <136255825+ludovic111@users.noreply.github.com> Date: Tue, 27 Oct 2026 02:11:32 +0100 Subject: [PATCH 30/36] Books: save a plain page as a string, as ComponentSerialization does Pages kept as components for their click events wrote a plain text page as {text:"p"}; vanilla's codec writes a component with no style or siblings as its string (the hotbar harness). Co-Authored-By: Claude Opus 5.5 --- crates/horizon-client/src/item_data.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/crates/horizon-client/src/item_data.rs b/crates/horizon-client/src/item_data.rs index 856eb2af3..68cb6e299 100644 --- a/crates/horizon-client/src/item_data.rs +++ b/crates/horizon-client/src/item_data.rs @@ -296,6 +296,21 @@ fn read_levels(t: Option<&Tag>) -> Levels { } /// A text component as stored by vanilla: a plain string or `{"text": ...}`. /// A `Filterable`: the value itself or `{raw: value}`. +/// `ComponentSerialization.CODEC`'s short form: a plain text component with +/// no style and no siblings is written as its string. +fn plain_component(t: &Tag) -> Tag { + if let Tag::Compound(c) = t + && let Some(text @ Tag::String(_)) = c.get(&"text".into()) + && c.iter().all(|(k, v)| { + k.to_string_lossy() == "text" + || (k.to_string_lossy() == "type" + && matches!(v, Tag::String(s) if s.to_string_lossy() == "text")) + }) + { + return text.clone(); + } + t.clone() +} fn filterable_text(t: &Tag) -> Option { match t.get("raw") { Some(raw) => read_text(raw), @@ -716,7 +731,7 @@ pub fn decode_components(components: Option<&Tag>) -> (u32, Option pages .iter() - .map(|p| p.get("raw").unwrap_or(p).clone()) + .map(|p| plain_component(p.get("raw").unwrap_or(p))) .collect(), _ => Vec::new(), }, From 79fca908869c1a6a2e44f5a5e1a56de083db644f Mon Sep 17 00:00:00 2001 From: Ludovic Marie <136255825+ludovic111@users.noreply.github.com> Date: Tue, 27 Oct 2026 06:29:42 +0100 Subject: [PATCH 31/36] Tame a pet to the player's real UUID, not an unset placeholder acting_uuid() falls back to [0, 0, 0, 0] while level.player_uuid is unset (a new world before its first save); the owner saved then never matches the UUID the world gets, so the player could no longer command the pet after a reload. acting_player_uuid() assigns the world's player UUID first, as dropped items do. Co-Authored-By: Claude Opus 5.5 --- crates/horizon-client/src/game/creatures.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/horizon-client/src/game/creatures.rs b/crates/horizon-client/src/game/creatures.rs index 68964a3fd..aaef37a64 100644 --- a/crates/horizon-client/src/game/creatures.rs +++ b/crates/horizon-client/src/game/creatures.rs @@ -2739,7 +2739,7 @@ impl Game<'_> { .items() .get(&item) .is_some_and(|i| i.max_damage > 0); - let acting = self.acting_uuid(); + let acting = self.acting_player_uuid(); let m = &mut self.mobs[index]; if !m.alive() { return Ok(false); From 84c631a88b15a0f3fca6613c297dcad2addb1457 Mon Sep 17 00:00:00 2001 From: Ludovic Marie <136255825+ludovic111@users.noreply.github.com> Date: Tue, 27 Oct 2026 12:11:26 +0100 Subject: [PATCH 32/36] refactor: the villager Poi enum lives in poi_sections.rs World's POI sections are typed by mobs::villager_brain::Poi, which made world depend on mobs, one of the edges that keep the client lib in a single cycle. The enum moves to poi_sections.rs; villager_brain re-exports it and keeps its methods. No behaviour change. Co-Authored-By: Claude Opus 5.5 --- crates/horizon-client/src/mobs/villager_brain.rs | 9 +-------- crates/horizon-client/src/poi_sections.rs | 9 +++++++++ crates/horizon-client/src/world.rs | 2 +- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/crates/horizon-client/src/mobs/villager_brain.rs b/crates/horizon-client/src/mobs/villager_brain.rs index 2052eef4c..724829354 100644 --- a/crates/horizon-client/src/mobs/villager_brain.rs +++ b/crates/horizon-client/src/mobs/villager_brain.rs @@ -789,14 +789,7 @@ pub fn golem_detected(m: &mut Mob, now: i64) { // ---- Behaviours --------------------------------------------------------- -/// The POI types villagers use. -#[derive(Clone, Copy, Debug, PartialEq, Eq)] -pub enum Poi { - /// A job site, by profession index. - Job(u8), - Home, - Meeting, -} +pub use crate::poi_sections::Poi; impl Poi { fn max_tickets(self) -> usize { match self { diff --git a/crates/horizon-client/src/poi_sections.rs b/crates/horizon-client/src/poi_sections.rs index 79ff0441d..a806706a1 100644 --- a/crates/horizon-client/src/poi_sections.rs +++ b/crates/horizon-client/src/poi_sections.rs @@ -79,6 +79,15 @@ impl PoiSections { } } +/// The POI types villagers use. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub enum Poi { + /// A job site, by profession index. + Job(u8), + Home, + Meeting, +} + #[cfg(test)] mod tests { use super::*; diff --git a/crates/horizon-client/src/world.rs b/crates/horizon-client/src/world.rs index 00ff04ac5..9eb8946df 100644 --- a/crates/horizon-client/src/world.rs +++ b/crates/horizon-client/src/world.rs @@ -92,7 +92,7 @@ pub struct World { /// (`ChunkHolder.sectionLightChanged`). pub light_log: Option>, /// The villager POIs of each section (`PoiManager`'s sections). - pub pois: crate::poi_sections::PoiSections, + pub pois: crate::poi_sections::PoiSections, /// Moving-piston states removed during the last tick; retained until the /// final block mesh is visible. pub moving_piston_fallback: Vec<([i32; 3], horizon_world::piston_shape::MovingPistonState)>, From 90a3fc82aa56d764e6a988e706c9cce1ff80571c Mon Sep 17 00:00:00 2001 From: Ludovic Marie <136255825+ludovic111@users.noreply.github.com> Date: Tue, 27 Oct 2026 12:11:14 +0100 Subject: [PATCH 33/36] refactor: HealthRules lives in world.rs World holds the health rules but they were defined in health.rs, which made world depend on health, one of the edges that keep the client lib in a single cycle. The plain data type (and its Default) moves to world.rs and health re-exports it. No behaviour change. Co-Authored-By: Claude Opus 5.5 --- crates/horizon-client/src/health.rs | 24 +---------------------- crates/horizon-client/src/world.rs | 30 +++++++++++++++++++++++++++-- 2 files changed, 29 insertions(+), 25 deletions(-) diff --git a/crates/horizon-client/src/health.rs b/crates/horizon-client/src/health.rs index 31e4e8104..2cee71a31 100644 --- a/crates/horizon-client/src/health.rs +++ b/crates/horizon-client/src/health.rs @@ -25,29 +25,7 @@ use std::{fs, io, path::Path}; pub(crate) type Attributes = LiveAttributes i32>>; pub(crate) type State = HurtState; -#[derive(Clone, Copy, Debug)] -pub struct HealthRules { - pub difficulty: Difficulty, - pub natural_regeneration: bool, - /// The `drowning_damage`, `fall_damage`, `fire_damage` and - /// `freeze_damage` rules `Player.isInvulnerableTo` reads. - pub drowning_damage: bool, - pub fall_damage: bool, - pub fire_damage: bool, - pub freeze_damage: bool, -} -impl Default for HealthRules { - fn default() -> Self { - Self { - difficulty: Difficulty::Normal, - natural_regeneration: true, - drowning_damage: true, - fall_damage: true, - fire_damage: true, - freeze_damage: true, - } - } -} +pub use crate::world::HealthRules; pub struct HealthResources { pub damage: Catalog, pub ids: PlayerFloatIds, diff --git a/crates/horizon-client/src/world.rs b/crates/horizon-client/src/world.rs index 00ff04ac5..9fe83bba2 100644 --- a/crates/horizon-client/src/world.rs +++ b/crates/horizon-client/src/world.rs @@ -53,7 +53,7 @@ pub struct World { pub chunks: crate::chunk_map::ChunkMap, pub random: LegacyRandom, pub revision: u64, - pub health_rules: crate::health::HealthRules, + pub health_rules: HealthRules, pub air: BlockStateId, /// Sections whose geometry changed and need remeshing. pub dirty_sections: DirtySections, @@ -170,7 +170,7 @@ impl World { chunks: Default::default(), random: LegacyRandom::new(seed), revision: 0, - health_rules: crate::health::HealthRules::default(), + health_rules: HealthRules::default(), air, fast_lava: false, dirty_sections: Default::default(), @@ -377,6 +377,32 @@ impl World { } } +/// The game rules and difficulty a player's health reads (`Player.isInvulnerableTo`, +/// natural regeneration), kept with the world they belong to. +#[derive(Clone, Copy, Debug)] +pub struct HealthRules { + pub difficulty: horizon_world::food::Difficulty, + pub natural_regeneration: bool, + /// The `drowning_damage`, `fall_damage`, `fire_damage` and + /// `freeze_damage` rules `Player.isInvulnerableTo` reads. + pub drowning_damage: bool, + pub fall_damage: bool, + pub fire_damage: bool, + pub freeze_damage: bool, +} +impl Default for HealthRules { + fn default() -> Self { + Self { + difficulty: horizon_world::food::Difficulty::Normal, + natural_regeneration: true, + drowning_damage: true, + fall_damage: true, + fire_damage: true, + freeze_damage: true, + } + } +} + #[cfg(test)] mod tests { use super::World; From 35fddca7e656ea44213a9a7922436ec263ae18dd Mon Sep 17 00:00:00 2001 From: Ludovic Marie <136255825+ludovic111@users.noreply.github.com> Date: Tue, 27 Oct 2026 12:15:36 +0100 Subject: [PATCH 34/36] refactor: the options screen's Opt enum lives in settings.rs graphics_ui named options_ui::Opt for its rows, which made it depend on options_ui, one of the edges that keep the client lib in a single cycle. The enum (the option ids) moves to settings.rs; options_ui re-exports it and keeps its methods. No behaviour change. Co-Authored-By: Claude Opus 5.5 --- crates/horizon-client/src/graphics_ui.rs | 3 +- crates/horizon-client/src/options_ui.rs | 91 +----------------------- crates/horizon-client/src/settings.rs | 90 +++++++++++++++++++++++ 3 files changed, 93 insertions(+), 91 deletions(-) diff --git a/crates/horizon-client/src/graphics_ui.rs b/crates/horizon-client/src/graphics_ui.rs index d55e44d99..cb097c114 100644 --- a/crates/horizon-client/src/graphics_ui.rs +++ b/crates/horizon-client/src/graphics_ui.rs @@ -5,8 +5,7 @@ use crate::{ graphics::{FarDetail, GraphicsApi, Overlay, Pacing, PresentMode, Preset}, graphics_style::{Cost, STYLE}, hud::{HudAtlas, HudBatch}, - options_ui::Opt, - settings::Settings, + settings::{Opt, Settings}, text::Text, ui, }; diff --git a/crates/horizon-client/src/options_ui.rs b/crates/horizon-client/src/options_ui.rs index 85882009f..d4793be85 100644 --- a/crates/horizon-client/src/options_ui.rs +++ b/crates/horizon-client/src/options_ui.rs @@ -4,6 +4,8 @@ //! OptionsList screens and drawn with the shared widgets. use std::time::Instant; +pub use crate::settings::Opt; + use crate::{ gamepad::{self, GlyphStyle}, hud::{HudAtlas, HudBatch, rgba}, @@ -14,95 +16,6 @@ use crate::{ ui, }; -/// One option instance. -#[derive(Clone, Copy, Debug, PartialEq, Eq)] -pub enum Opt { - Fov, - RenderDistance, - SimulationDistance, - Sensitivity, - WheelSensitivity, - InvertY, - DiscreteScroll, - Volume(usize), - GuiScale, - ViewBobbing, - Gamma, - MaxFps, - Vsync, - Fullscreen, - SmoothLighting, - Clouds, - CloudRange, - Particles, - EntityDistance, - EntityShadows, - BiomeBlend, - Preset, - Mipmaps, - WeatherRadius, - ChunkFade, - Vignette, - Autosave, - CutoutLeaves, - ImprovedTransparency, - AttackIndicator, - InactivityFps, - ChunkBuilder, - MenuBlur, - ToggleCrouch, - ToggleSprint, - AutoJump, - ChatVisibility, - ChatColors, - ChatLinks, - ChatLinksPrompt, - ChatOpacity, - TextBackgroundOpacity, - ChatScale, - ChatWidth, - ChatHeightFocused, - ChatHeightUnfocused, - ChatLineSpacing, - AutoSuggestions, - ReducedDebugInfo, - HighContrast, - ShowSubtitles, - MusicFrequency, - NotificationDisplayTime, - Narrator, - TextBackground, - ChatDelay, - DistortionEffects, - FovEffects, - DarknessPulsing, - DamageTilt, - GlintSpeed, - GlintStrength, - HideLightningFlashes, - MonochromeLogo, - PanoramaSpeed, - HideSplashTexts, - NarratorHotkey, - RotateWithMinecarts, - HighContrastBlockOutlines, - ForceUnicode, - JapaneseGlyphs, - /// Horizon's controller settings (`horizon-controller.txt`). - PadEnabled, - PadVibration, - PadAdaptiveTriggers, - PadLightbar, - PadLookSensitivity, - PadInvertX, - PadInvertY, - PadToggleSneak, - PadMoveDeadzone, - PadLookDeadzone, - PadGlyphs, - PadMenuNav, - PadKeyboard, -} fn tr(key: &str) -> Text { Text::translate(key, &[]) } diff --git a/crates/horizon-client/src/settings.rs b/crates/horizon-client/src/settings.rs index 09d7ae3ff..0c59c18f9 100644 --- a/crates/horizon-client/src/settings.rs +++ b/crates/horizon-client/src/settings.rs @@ -608,6 +608,96 @@ impl Settings { } } +/// One option instance. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub enum Opt { + Fov, + RenderDistance, + SimulationDistance, + Sensitivity, + WheelSensitivity, + InvertY, + DiscreteScroll, + Volume(usize), + GuiScale, + ViewBobbing, + Gamma, + MaxFps, + Vsync, + Fullscreen, + SmoothLighting, + Clouds, + CloudRange, + Particles, + EntityDistance, + EntityShadows, + BiomeBlend, + Preset, + Mipmaps, + WeatherRadius, + ChunkFade, + Vignette, + Autosave, + CutoutLeaves, + ImprovedTransparency, + AttackIndicator, + InactivityFps, + ChunkBuilder, + MenuBlur, + ToggleCrouch, + ToggleSprint, + AutoJump, + ChatVisibility, + ChatColors, + ChatLinks, + ChatLinksPrompt, + ChatOpacity, + TextBackgroundOpacity, + ChatScale, + ChatWidth, + ChatHeightFocused, + ChatHeightUnfocused, + ChatLineSpacing, + AutoSuggestions, + ReducedDebugInfo, + HighContrast, + ShowSubtitles, + MusicFrequency, + NotificationDisplayTime, + Narrator, + TextBackground, + ChatDelay, + DistortionEffects, + FovEffects, + DarknessPulsing, + DamageTilt, + GlintSpeed, + GlintStrength, + HideLightningFlashes, + MonochromeLogo, + PanoramaSpeed, + HideSplashTexts, + NarratorHotkey, + RotateWithMinecarts, + HighContrastBlockOutlines, + ForceUnicode, + JapaneseGlyphs, + /// Horizon's controller settings (`horizon-controller.txt`). + PadEnabled, + PadVibration, + PadAdaptiveTriggers, + PadLightbar, + PadLookSensitivity, + PadInvertX, + PadInvertY, + PadToggleSneak, + PadMoveDeadzone, + PadLookDeadzone, + PadGlyphs, + PadMenuNav, + PadKeyboard, +} + #[cfg(test)] mod tests { use super::*; From cf9fb96efac3f396b5d536241a68a2ed96212575 Mon Sep 17 00:00:00 2001 From: Ludovic Marie <136255825+ludovic111@users.noreply.github.com> Date: Tue, 27 Oct 2026 12:26:41 +0100 Subject: [PATCH 35/36] launcher: a vertical Sculk card for the sidebar, readable at any size The sidebar showed Sculk's wide banner shrunk to 228 px, and its baked-in text could not be read. It now shows a card made for the sidebar: Sculk's characters and logo cropped from its banner, and the headline, "Ready in under a minute", a "Get my server" button and the HORIZON15 code drawn by the launcher, so they stay sharp and follow its language (French and Russian added). Where the window is too short for the tall card, a compact one puts the characters beside the text. The Partner label, the 180 s before Hide, the link and the hover lift stay; the Servers page keeps the wide banner. Co-Authored-By: Claude Opus 5.5 --- docs/design-system.md | 9 +- launcher/assets/sculk-card-art.webp | Bin 0 -> 20598 bytes launcher/assets/sculk-logo.webp | Bin 0 -> 5140 bytes launcher/lang/fr.json | 5 + launcher/lang/ru.json | 5 + launcher/src/main.rs | 24 ++- launcher/src/partner.rs | 261 +++++++++++++++++++++++++++- 7 files changed, 290 insertions(+), 14 deletions(-) create mode 100644 launcher/assets/sculk-card-art.webp create mode 100644 launcher/assets/sculk-logo.webp diff --git a/docs/design-system.md b/docs/design-system.md index 0b171d4c2..aec060457 100644 --- a/docs/design-system.md +++ b/docs/design-system.md @@ -170,9 +170,12 @@ of the main action. The game's menus keep `LIGHT` and `DARK`. all rights reserved, so it is not shown. - **Partner banner**: the one exception to shipping no third-party pictures. Sculk, a server host, sponsors Horizon: its banner (`launcher/assets/sculk-banner.webp`, `launcher/src/partner.rs`) sits - under a muted mono "Partner" label at the end of the Servers page and of Home, below Play, and opens - Sculk's page in the browser. The website shows the same banner the same way on Home and the hosting - docs, as a `rel="sponsored"` link. + under a muted mono "Partner" label at the end of the Servers page and opens Sculk's page in the + browser. The sidebar of the other pages shows a card made for its width instead: Sculk's characters + and logo cropped from the same banner, and the text drawn by the launcher in its language, so it + stays readable; it keeps Sculk's dark card, cyan and rounded corners in both themes, as an ad does, + and turns compact (characters beside the text) when the window is too short. The website shows the + banner the same way on Home and the hosting docs, as a `rel="sponsored"` link. - **Pixel art drawn in code.** The stone behind the pages is close shades of the page colour (`TILE_SHADES`), never Minecraft's stone; the landscape is a banded sky, a sun cut in slices like the mark, hills and square trees (a sunset in dark, a dawn in light). The launcher bakes them in diff --git a/launcher/assets/sculk-card-art.webp b/launcher/assets/sculk-card-art.webp new file mode 100644 index 0000000000000000000000000000000000000000..13b9e10e441e9fff40006be94b837c07f954dbe0 GIT binary patch literal 20598 zcmb4~<8mg95`<&h+Ss2qi>*}s_7mjNii`y1t1`G zQ6U921x^hZARr*5|8@)*$Ql?(P)0$53mgat7`Zi;luGH3@-OrrUx&Tuvp+}y!(^P2 zy}h&M?9|Wsl0Q_q#8%nU-Pb)QaZ+nEmmR5OqSb;w>K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jiqI(k|b+e_wnE`sa8tnnkye%zxR2(tVOj8xShq6Sq&rXUHRoq7waAfL@ zNIU{^`U5D73HsLgdB6}D?iwTiSFIoI;*Q^fc0p8gfh;i&0(PnW(=)P!Zcip}(lx5em^D7vr% zYwQ{$y^dW`#-GPEt9x_l4jps1LD!lxT&?%g^YMziol>Y^f%Ps1jQj}D!@mUlPi;7j zYR`N}87sH)kU@^h)GU<&#`pS_Mj>MG!OI6G=+7olWfS3d^om%xjoP_YbSy|v6@KqP z00HzQMY?g`adM6WI(fYo%*f;b3i1-(R{#J3c>#~R?IdbZ?BbJIQa}IzAz^Y^2R&&@ N7*84k629<&001G5VaEUf literal 0 HcmV?d00001 diff --git a/launcher/assets/sculk-logo.webp b/launcher/assets/sculk-logo.webp new file mode 100644 index 0000000000000000000000000000000000000000..8877cd1d9638e2ebaf55aa2f4f8e1698bc9786ba GIT binary patch literal 5140 zcmV+v6zl6!Nk&Et6aWBMMM6+kP&iEg6951&zQ70&RRe>zjU>hVVeh>~5D^nlXxinF z+dV#jt&eZoy@;I-nxODh8r>S75x&OcZ z?yY9-WoD*2^Ve73Up3Mx`w>{Oev!LJKBpj4R;N&rbVM^5d?9oQP4U=^D+`a)kS8FK*#69P1Iib#&pKi@~S_)zHj}$Ht zj9vXLg#gSx;f^cj{K6?12;Nk9f!m z#lI>>J5Ir7#VXYfA?l$V{goNw-1h%ULcqF*7cB4EK}0k~IVC)HRH?S3+Oc8>RqXTP z*qgWH7=4BLM1gK%=0Z6?uuD~oEM~(ZO&9W&-XRj`z|&F~TH?WQX@B#MF3b;bmu9Lw_;U2M zle3hu%m1st$dhv;nXuN#`;gg^Hu)xxC(e?Jt7g%^7rKt<&HEXnKNyWEs6D|G4@t0wWPyBHvH( zIgqAqqsC$eLhS4E95xQs4iKfQB@hN5r;|pcxbRdC1O$+TJYJ`X4sph&_FG4U{5@*{ zFN^*qa+9WqG)y@iOuz!sYVCjRP z)E`dbwG)t(LjProUtg&AzHTgI8M7=%eL9}~la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!nIA zLo=f*A$(K!V?`_EA8A`yRF5jcAi&_xrz7N_X}NEZWSTtpH&GdBc;tU(Ob^(D&+h)( z*mEBpYCuF(A!v4(bmqKP8&I@82rv**x0TD^U8Gz6;+#~irnnaiiC%7 zc(MBaW3o`)Uyvu;6(L;qX_^(SnA~%Yh#=OS&fQ5;7 zjnKg2g9%~Tp-KI-GLr2!#<@S{ucDohT*3%1ymykGDUS zxBmA-aqE8+FMI8tuf8j84aLo&^m=oyDfjqK`Kf>W<0f3i{_&4Ha7A?{SReM1U>9Jw z<+9ElPCXH841xj{NPhF??F&7Dq0X)!HAPHT;Mr0*DniJSiMQ-Shh2xT^Sz5WHUd(+5NRj13cS zLG9$BHcP9u8w@;fp*k8u83=Y!uxvf4&;QGKwlbDkyrA#%;#>lRy!ggF zQd$^q83_qmJqpvU@KEFWl^k>_E?ljBqr@i-6 literal 0 HcmV?d00001 diff --git a/launcher/lang/fr.json b/launcher/lang/fr.json index 68ef9f744..189577fb3 100644 --- a/launcher/lang/fr.json +++ b/launcher/lang/fr.json @@ -151,6 +151,11 @@ "Not played yet": "Pas encore joué", "under a minute": "moins d'une minute", "PARTNER": "PARTENAIRE", + "Your Minecraft server, {online}.": "Votre serveur Minecraft, {online}.", + "24/7 online": "en ligne 24h/24", + "Ready in under a minute": "Prêt en moins d'une minute", + "Get my server": "Obtenir mon serveur", + "15% off": "-15 %", "Not prepared. Horizon needs the files of your own Minecraft {version}.": "Pas préparé. Horizon a besoin des fichiers de votre propre Minecraft {version}.", "Prepared for Minecraft {version}": "Préparé pour Minecraft {version}", "Prepared for Minecraft {version}, without its sounds: the game will be silent. Prepare again to copy them from your Minecraft install.": "Préparé pour Minecraft {version}, sans ses sons : le jeu sera muet. Préparez à nouveau pour les copier depuis votre installation de Minecraft." diff --git a/launcher/lang/ru.json b/launcher/lang/ru.json index 48051bfac..a992ef819 100644 --- a/launcher/lang/ru.json +++ b/launcher/lang/ru.json @@ -151,6 +151,11 @@ "Not played yet": "Ещё не запускалась", "under a minute": "меньше минуты", "PARTNER": "ПАРТНЁР", + "Your Minecraft server, {online}.": "Ваш сервер Minecraft, {online}.", + "24/7 online": "онлайн 24/7", + "Ready in under a minute": "Готов меньше чем за минуту", + "Get my server": "Получить сервер", + "15% off": "скидка 15%", "Not prepared. Horizon needs the files of your own Minecraft {version}.": "Не подготовлено. Horizon нужны файлы вашего собственного Minecraft {version}.", "Prepared for Minecraft {version}": "Подготовлено для Minecraft {version}", "Prepared for Minecraft {version}, without its sounds: the game will be silent. Prepare again to copy them from your Minecraft install.": "Подготовлено для Minecraft {version}, но без звуков: игра будет беззвучной. Подготовьте заново, чтобы скопировать их из вашей установки Minecraft." diff --git a/launcher/src/main.rs b/launcher/src/main.rs index 1bb96fc0d..2cb1bb775 100644 --- a/launcher/src/main.rs +++ b/launcher/src/main.rs @@ -1702,7 +1702,7 @@ impl Launcher { /// The sidebar: Horizon and the imported modpacks, the player's servers, then the /// launcher's own update, the community links and its version. - fn sidebar(&mut self, cx: &mut Context) -> Stateful
{ + fn sidebar(&mut self, window: &Window, cx: &mut Context) -> Stateful
{ let t = self.theme; self.load_packs(); let heading = |label: String| { @@ -1751,12 +1751,14 @@ impl Launcher { this.open_instance_dialog(None); cx.notify(); })); + let items = self.instance_items(heading, cx); + let mut rows = items.len(); let list = div() .flex() .flex_col() .gap(px(4.)) .child(heading(tr("INSTANCES").into()).child(add)) - .children(self.instance_items(heading, cx)); + .children(items); let servers: Vec<_> = self .servers .sidebar_list() @@ -1766,6 +1768,8 @@ impl Launcher { if !servers.is_empty() { list = list.child(heading(tr("SERVERS").into())); } + rows += servers.len(); + let headings = 1 + usize::from(!servers.is_empty()); for e in servers { let up = self.servers.is_up(&e.dir); let open = self.page == Page::Servers && self.servers.open.as_ref() == Some(&e.dir); @@ -1855,12 +1859,20 @@ impl Launcher { } _ => {} } - // Sculk's banner, small, above the links: seen without scrolling, on every page but Servers, which - // shows it large. After a while on screen a "Hide" beside its label puts it away for good. + // Sculk's card above the links: seen without scrolling, on every page but Servers, which shows + // its wide banner. Tall where the sidebar has the height for it besides its rows (about 60 + // high each, under headings of about 40) and the links, compact otherwise. After a while on + // screen a "Hide" beside its label puts it away for good. if self.page != Page::Servers && !self.settings.partner_hidden { - let mut side = div().relative().mb(px(8.)).child(partner::banner( + let free = f32::from(window.viewport_size().height) + - theme::TOPBAR + - 40. * headings as f32 + - 60. * rows as f32 + - 110.; + let mut side = div().relative().mb(px(8.)).child(partner::card( "partner-side", theme::SIDEBAR - 20., + free < partner::TALL_HEIGHT, &t, )); if self.settings.partner_seen_secs >= partner::SEEN_BEFORE_HIDE { @@ -3659,7 +3671,7 @@ impl Render for Launcher { } let stone = self.art.stone(t.page_rgb, t.dark, window.scale_factor()); let topbar = self.topbar(window, cx); - let sidebar = self.sidebar(cx); + let sidebar = self.sidebar(window, cx); let mut root = div() .id("root") .track_focus(&self.root_focus) diff --git a/launcher/src/partner.rs b/launcher/src/partner.rs index 6242f9228..ae82ebd7f 100644 --- a/launcher/src/partner.rs +++ b/launcher/src/partner.rs @@ -1,8 +1,12 @@ -//! Sculk's banner: a server host that sponsors Horizon (Ludovic, 2026-10-26), large on the Servers page -//! and small at the foot of the sidebar on the other pages, where it shows without scrolling. The picture is in the binary, never fetched; a click opens Sculk's page in -//! the browser. A "Partner" label above it says it is an ad. +//! Sculk, a server host that sponsors Horizon (Ludovic, 2026-10-26): its wide banner on the Servers +//! page, and a card made for the sidebar on the other pages, where the banner's baked-in text was too +//! small to read. The pictures are in the binary, never fetched; a click opens Sculk's page in the +//! browser. A "Partner" label above each says it is an ad. use crate::theme::Theme; -use gpui::{div, img, prelude::*, px, ClickEvent, Div, Image, ImageFormat, Stateful}; +use gpui::{ + div, img, prelude::*, px, rgb, ClickEvent, Div, FontWeight, HighlightStyle, Image, ImageFormat, + Rgba, SharedString, Stateful, StyledText, +}; use std::sync::{Arc, LazyLock}; pub const URL: &str = "https://my.sculkhosting.com/ref/horizon"; @@ -51,9 +55,256 @@ pub fn banner(id: &'static str, width: f32, t: &Theme) -> Stateful
{ crate::keyboard(el, &t) } +/// Sculk's characters (Steve, Alex and the wolf) cropped from its banner at 2x the card's width. +/// Above `ART_TOP` (in the card's 228 logical pixels) the picture is transparent but for their heads +/// and the pickaxe, which stand out of the card; its foot and right edge fade into `CARD`. +const ART_WIDTH: f32 = 456.; +const ART_HEIGHT: f32 = 364.; +const ART_TOP: f32 = 11.; +static ART: LazyLock> = LazyLock::new(|| { + Arc::new(Image::from_bytes( + ImageFormat::Webp, + include_bytes!("../assets/sculk-card-art.webp").to_vec(), + )) +}); + +/// Sculk's mark and name, cropped from its banner, 2x for a 18 pixel height. +const LOGO_WIDTH: f32 = 191.; +const LOGO_HEIGHT: f32 = 36.; +static LOGO: LazyLock> = LazyLock::new(|| { + Arc::new(Image::from_bytes( + ImageFormat::Webp, + include_bytes!("../assets/sculk-logo.webp").to_vec(), + )) +}); + +/// Sculk's colours, taken from its banner: the card is Sculk's in both themes, as an ad is. +const CARD: u32 = 0x0b0d12; +const CYAN: u32 = 0x5dd4fb; +const CYAN_HOVER: u32 = 0x8fe3fd; +const WHITE: u32 = 0xf1f5f9; +const GREY: u32 = 0x9aa6b2; +const ON_CYAN: u32 = 0x062330; + +/// The promo code: Sculk's, never translated. +const CODE: &str = "HORIZON15"; + +/// What the tall card needs of the sidebar's height, label included, with room for a third line of +/// headline: below it the sidebar shows the compact card. +pub const TALL_HEIGHT: f32 = 410.; + +/// "Your Minecraft server, 24/7 online." with "24/7 online" in Sculk's cyan, in the launcher's +/// language. +fn headline() -> StyledText { + let online = horizon_launcher::i18n::tr("24/7 online"); + let line = horizon_launcher::i18n::tr("Your Minecraft server, {online}."); + let (before, after) = line.split_once("{online}").unwrap_or((line, "")); + let text = format!("{before}{online}{after}"); + let lit = before.len()..before.len() + online.len(); + StyledText::new(SharedString::from(text)).with_highlights([( + lit, + HighlightStyle { + color: Some(rgb(CYAN).into()), + ..Default::default() + }, + )]) +} + +/// "HORIZON15 · 15% off" in a dashed cyan frame, as on Sculk's banner. +fn code_chip(size: f32, height: f32) -> Div { + div() + .flex() + .items_center() + .justify_center() + .gap(px(6.)) + .h(px(height)) + .px(px(10.)) + .border_1() + .border_dashed() + .border_color(rgba(CYAN, 0.7)) + .rounded(px(6.)) + .font_family(crate::theme::MONO) + .text_size(px(size)) + .whitespace_nowrap() + .child( + div() + .text_color(rgb(WHITE)) + .font_weight(FontWeight::SEMIBOLD) + .child(CODE), + ) + .child(div().text_color(rgb(GREY)).child("·")) + .child( + div() + .text_color(rgb(CYAN)) + .child(horizon_launcher::i18n::tr("15% off")), + ) +} + +fn rgba(hex: u32, alpha: f32) -> Rgba { + Rgba { + a: alpha, + ..rgb(hex) + } +} + +/// Sculk's card for the sidebar, `width` logical pixels wide: its characters standing out of the top, +/// then its name, the headline, a line, a "Get my server" button and the promo code, all drawn by +/// the launcher so they stay sharp and follow its language. `compact` puts the characters beside a +/// shorter text, for windows too short for the tall card. Hovering lifts it a little. +pub fn card(id: &'static str, width: f32, compact: bool, t: &Theme) -> Stateful
{ + let t = *t; + let label = crate::text(crate::theme::MICRO) + .text_color(t.muted) + .group_hover(id, move |s| s.text_color(t.ink)) + .child(horizon_launcher::i18n::tr("PARTNER")); + let face = div() + .relative() + .flex() + .flex_none() + .w(px(width)) + .bg(rgb(CARD)) + .border_1() + .border_color(rgba(CYAN, 0.22)) + .rounded(px(10.)) + .group_hover(id, |s| s.top(px(-2.)).border_color(rgba(CYAN, 0.5))); + let logo = |height: f32| { + img(LOGO.clone()) + .flex_none() + .w(px(height * LOGO_WIDTH / LOGO_HEIGHT)) + .h(px(height)) + }; + let face = if compact { + // The characters beside the text, their faded foot melting into the card, the code under both. + let art_w = 104.; + face.flex_col() + .child( + div() + .flex() + .items_end() + .child( + div() + .flex() + .flex_col() + .flex_1() + .min_w_0() + .gap(px(8.)) + .pl(px(12.)) + .pt(px(12.)) + .child(logo(13.)) + .child( + div() + .text_size(px(15.)) + .line_height(px(19.)) + .font_weight(FontWeight::SEMIBOLD) + .text_color(rgb(WHITE)) + .child(headline()), + ), + ) + .child( + img(ART.clone()) + .flex_none() + .w(px(art_w)) + .h(px(art_w * ART_HEIGHT / ART_WIDTH)), + ), + ) + .child( + div() + .flex() + .px(px(12.)) + .pt(px(6.)) + .pb(px(12.)) + .child(code_chip(11., 26.).flex_1()), + ) + } else { + let art_h = width * ART_HEIGHT / ART_WIDTH; + let button = div() + .flex() + .items_center() + .justify_center() + .h(px(36.)) + .rounded(px(8.)) + .bg(rgb(CYAN)) + .group_hover(id, |s| s.bg(rgb(CYAN_HOVER))) + .text_color(rgb(ON_CYAN)) + .text_size(px(14.)) + .font_weight(FontWeight::SEMIBOLD) + .child(horizon_launcher::i18n::tr("Get my server")); + // The art stands out of the card's top; the text starts over its faded foot. + face.mt(px(ART_TOP)) + .flex_col() + .child( + img(ART.clone()) + .absolute() + .top(px(-ART_TOP)) + .left_0() + .w(px(width)) + .h(px(art_h)), + ) + .child( + div() + .flex() + .flex_col() + .pt(px(art_h - ART_TOP - 14.)) + .px(px(16.)) + .pb(px(16.)) + .child(logo(16.)) + .child( + div() + .mt(px(12.)) + .text_size(px(19.)) + .line_height(px(23.)) + .font_weight(FontWeight::SEMIBOLD) + .text_color(rgb(WHITE)) + .child(headline()), + ) + .child( + div() + .mt(px(6.)) + .text_size(px(13.)) + .line_height(px(18.)) + .text_color(rgb(GREY)) + .child(horizon_launcher::i18n::tr("Ready in under a minute")), + ) + .child(div().mt(px(16.)).child(button)) + .child(div().mt(px(8.)).flex().child(code_chip(12., 30.).flex_1())), + ) + }; + let el = div() + .id(id) + .group(id) + .flex() + .flex_col() + .gap(px(8.)) + .w(px(width)) + .cursor_pointer() + .child(label) + .child(face) + .on_click(|_: &ClickEvent, _, cx| cx.open_url(URL)); + crate::keyboard(el, &t) +} + #[cfg(test)] mod tests { - use super::{HEIGHT, WIDTH}; + use super::{ART_HEIGHT, ART_WIDTH, HEIGHT, LOGO_HEIGHT, LOGO_WIDTH, WIDTH}; + + /// Each bundled picture decodes as a WebP of the size the code lays it out at. + #[test] + fn the_card_pictures_decode() { + for (bytes, size) in [ + ( + &include_bytes!("../assets/sculk-card-art.webp")[..], + (ART_WIDTH, ART_HEIGHT), + ), + ( + &include_bytes!("../assets/sculk-logo.webp")[..], + (LOGO_WIDTH, LOGO_HEIGHT), + ), + ] { + let pic = image::load_from_memory_with_format(bytes, image::ImageFormat::WebP) + .expect("a WebP"); + assert_eq!((pic.width(), pic.height()), (size.0 as u32, size.1 as u32)); + } + } #[test] fn the_bundled_banner_decodes() { From bc0c0fdf4a2911594008f386260177f08138bede Mon Sep 17 00:00:00 2001 From: Ludovic Marie <136255825+ludovic111@users.noreply.github.com> Date: Tue, 27 Oct 2026 12:13:32 +0100 Subject: [PATCH 36/36] refactor: the MobEffects and Potions tables live in horizon-client-core effects.rs and hud_overlays.rs read the effect and potion tables from brewing, which made them depend on brewing (and through it on containers and items), edges that keep the client lib in a single cycle. The tables have no dependencies, so they move to horizon-client-core; brewing re-exports them. No behaviour change. Co-Authored-By: Claude Opus 5.5 --- crates/horizon-client-core/src/lib.rs | 1 + crates/horizon-client-core/src/potions.rs | 249 +++++++++++++++++++++ crates/horizon-client/src/brewing.rs | 255 +--------------------- crates/horizon-client/src/effects.rs | 10 +- crates/horizon-client/src/hud_overlays.rs | 5 +- 5 files changed, 263 insertions(+), 257 deletions(-) create mode 100644 crates/horizon-client-core/src/potions.rs diff --git a/crates/horizon-client-core/src/lib.rs b/crates/horizon-client-core/src/lib.rs index 2030165c5..7721668ca 100644 --- a/crates/horizon-client-core/src/lib.rs +++ b/crates/horizon-client-core/src/lib.rs @@ -16,6 +16,7 @@ pub mod lang; pub mod nbt_path; pub mod particle_type; pub mod pattern; +pub mod potions; pub mod registries; pub mod scoreboard; pub mod snbt; diff --git a/crates/horizon-client-core/src/potions.rs b/crates/horizon-client-core/src/potions.rs new file mode 100644 index 000000000..044b25e3a --- /dev/null +++ b/crates/horizon-client-core/src/potions.rs @@ -0,0 +1,249 @@ +//! The `MobEffects` and `Potions` registries (code in vanilla, ported as +//! tables): each effect's colour and category, each potion's effects, and the +//! potion colour mix. horizon-client re-exports them from `brewing`. +use std::{collections::HashMap, sync::OnceLock}; + +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub enum Category { + Beneficial, + Harmful, + Neutral, +} +/// A `MobEffect`: id (without namespace), colour, category, instantaneous. +#[derive(Clone, Copy, Debug)] +pub struct EffectDef { + pub id: &'static str, + pub color: u32, + pub category: Category, + pub instant: bool, +} +const fn fx(id: &'static str, color: u32, category: Category) -> EffectDef { + EffectDef { + id, + color, + category, + instant: false, + } +} +use Category::{Beneficial as B, Harmful as H, Neutral as N}; +/// `MobEffects` in registration order. +pub const EFFECTS: &[EffectDef] = &[ + fx("speed", 3402751, B), + fx("slowness", 9154528, H), + fx("haste", 14270531, B), + fx("mining_fatigue", 4866583, H), + fx("strength", 16762624, B), + EffectDef { + id: "instant_health", + color: 16262179, + category: B, + instant: true, + }, + EffectDef { + id: "instant_damage", + color: 11101546, + category: H, + instant: true, + }, + fx("jump_boost", 16646020, B), + fx("nausea", 5578058, H), + fx("regeneration", 13458603, B), + fx("resistance", 9520880, B), + fx("fire_resistance", 16750848, B), + fx("water_breathing", 10017472, B), + fx("invisibility", 16185078, B), + fx("blindness", 2039587, H), + fx("night_vision", 12779366, B), + fx("hunger", 5797459, H), + fx("weakness", 4738376, H), + fx("poison", 8889187, H), + fx("wither", 7561558, H), + fx("health_boost", 16284963, B), + fx("absorption", 2445989, B), + EffectDef { + id: "saturation", + color: 16262179, + category: B, + instant: true, + }, + fx("glowing", 9740385, N), + fx("levitation", 13565951, H), + fx("luck", 5882118, B), + fx("unluck", 12624973, H), + fx("slow_falling", 15978425, B), + fx("conduit_power", 1950417, B), + fx("dolphins_grace", 8954814, B), + fx("bad_omen", 745784, N), + fx("hero_of_the_village", 4521796, B), + fx("darkness", 2696993, H), + fx("trial_omen", 1484454, N), + fx("raid_omen", 14565464, N), + fx("wind_charged", 12438015, H), + fx("weaving", 7891290, H), + fx("oozing", 10092451, H), + fx("infested", 9214860, H), + fx("breath_of_the_nautilus", 65518, B), +]; +pub fn effect(id: &str) -> Option<&'static EffectDef> { + let id = id.trim_start_matches("minecraft:"); + EFFECTS.iter().find(|e| e.id == id) +} +/// Namespaced effect ids for mob effect storage. +pub fn namespaced(id: &'static str) -> &'static str { + static IDS: OnceLock> = OnceLock::new(); + IDS.get_or_init(|| { + EFFECTS + .iter() + .map(|e| { + ( + e.id, + &*Box::leak(format!("minecraft:{}", e.id).into_boxed_str()), + ) + }) + .collect() + }) + .get(id) + .copied() + .unwrap_or(id) +} +/// A `Potion`: id, name suffix (`item.minecraft.potion.effect.`) and +/// effects as (effect, duration ticks, amplifier). +#[derive(Clone, Copy, Debug)] +pub struct PotionDef { + pub id: &'static str, + pub name: &'static str, + pub effects: &'static [(&'static str, i32, i32)], +} +const fn p( + id: &'static str, + name: &'static str, + effects: &'static [(&'static str, i32, i32)], +) -> PotionDef { + PotionDef { id, name, effects } +} +/// `Potions` in registration order. +pub const POTIONS: &[PotionDef] = &[ + p("water", "water", &[]), + p("mundane", "mundane", &[]), + p("thick", "thick", &[]), + p("awkward", "awkward", &[]), + p("night_vision", "night_vision", &[("night_vision", 3600, 0)]), + p( + "long_night_vision", + "night_vision", + &[("night_vision", 9600, 0)], + ), + p("invisibility", "invisibility", &[("invisibility", 3600, 0)]), + p( + "long_invisibility", + "invisibility", + &[("invisibility", 9600, 0)], + ), + p("leaping", "leaping", &[("jump_boost", 3600, 0)]), + p("long_leaping", "leaping", &[("jump_boost", 9600, 0)]), + p("strong_leaping", "leaping", &[("jump_boost", 1800, 1)]), + p( + "fire_resistance", + "fire_resistance", + &[("fire_resistance", 3600, 0)], + ), + p( + "long_fire_resistance", + "fire_resistance", + &[("fire_resistance", 9600, 0)], + ), + p("swiftness", "swiftness", &[("speed", 3600, 0)]), + p("long_swiftness", "swiftness", &[("speed", 9600, 0)]), + p("strong_swiftness", "swiftness", &[("speed", 1800, 1)]), + p("slowness", "slowness", &[("slowness", 1800, 0)]), + p("long_slowness", "slowness", &[("slowness", 4800, 0)]), + p("strong_slowness", "slowness", &[("slowness", 400, 3)]), + p( + "turtle_master", + "turtle_master", + &[("slowness", 400, 3), ("resistance", 400, 2)], + ), + p( + "long_turtle_master", + "turtle_master", + &[("slowness", 800, 3), ("resistance", 800, 2)], + ), + p( + "strong_turtle_master", + "turtle_master", + &[("slowness", 400, 5), ("resistance", 400, 3)], + ), + p( + "water_breathing", + "water_breathing", + &[("water_breathing", 3600, 0)], + ), + p( + "long_water_breathing", + "water_breathing", + &[("water_breathing", 9600, 0)], + ), + p("healing", "healing", &[("instant_health", 1, 0)]), + p("strong_healing", "healing", &[("instant_health", 1, 1)]), + p("harming", "harming", &[("instant_damage", 1, 0)]), + p("strong_harming", "harming", &[("instant_damage", 1, 1)]), + p("poison", "poison", &[("poison", 900, 0)]), + p("long_poison", "poison", &[("poison", 1800, 0)]), + p("strong_poison", "poison", &[("poison", 432, 1)]), + p("regeneration", "regeneration", &[("regeneration", 900, 0)]), + p( + "long_regeneration", + "regeneration", + &[("regeneration", 1800, 0)], + ), + p( + "strong_regeneration", + "regeneration", + &[("regeneration", 450, 1)], + ), + p("strength", "strength", &[("strength", 3600, 0)]), + p("long_strength", "strength", &[("strength", 9600, 0)]), + p("strong_strength", "strength", &[("strength", 1800, 1)]), + p("weakness", "weakness", &[("weakness", 1800, 0)]), + p("long_weakness", "weakness", &[("weakness", 4800, 0)]), + p("luck", "luck", &[("luck", 6000, 0)]), + p("slow_falling", "slow_falling", &[("slow_falling", 1800, 0)]), + p( + "long_slow_falling", + "slow_falling", + &[("slow_falling", 4800, 0)], + ), + p("wind_charged", "wind_charged", &[("wind_charged", 3600, 0)]), + p("weaving", "weaving", &[("weaving", 3600, 0)]), + p("oozing", "oozing", &[("oozing", 3600, 0)]), + p("infested", "infested", &[("infested", 3600, 0)]), +]; +pub fn potion(id: &str) -> Option<&'static PotionDef> { + let id = id.trim_start_matches("minecraft:"); + POTIONS.iter().find(|p| p.id == id) +} +/// `PotionContents.BASE_POTION_COLOR` (ARGB -13083194) as RGB. +pub const BASE_POTION_COLOR: u32 = 0x385DC6; +/// `PotionContents.getColor`: amplifier-weighted mix of visible effect colours. +pub fn potion_color(id: Option<&str>) -> u32 { + let Some(def) = id.and_then(potion) else { + return BASE_POTION_COLOR; + }; + let (mut r, mut g, mut b, mut total) = (0u32, 0u32, 0u32, 0u32); + for (e, _, amp) in def.effects { + let Some(e) = effect(e) else { continue }; + let w = *amp as u32 + 1; + r += w * (e.color >> 16 & 255); + g += w * (e.color >> 8 & 255); + b += w * (e.color & 255); + total += w; + } + match ( + r.checked_div(total), + g.checked_div(total), + b.checked_div(total), + ) { + (Some(r), Some(g), Some(b)) => (r << 16) | (g << 8) | b, + _ => BASE_POTION_COLOR, + } +} diff --git a/crates/horizon-client/src/brewing.rs b/crates/horizon-client/src/brewing.rs index cdd988a7a..b3cda5f90 100644 --- a/crates/horizon-client/src/brewing.rs +++ b/crates/horizon-client/src/brewing.rs @@ -7,257 +7,12 @@ use crate::{ items::{ItemStack, Items}, }; use serde_json::Value; -use std::{ - collections::{HashMap, HashSet}, - fs, - path::Path, - sync::{Arc, OnceLock}, -}; +use std::{collections::HashSet, fs, path::Path, sync::Arc}; -#[derive(Clone, Copy, Debug, PartialEq, Eq)] -pub enum Category { - Beneficial, - Harmful, - Neutral, -} -/// A `MobEffect`: id (without namespace), colour, category, instantaneous. -#[derive(Clone, Copy, Debug)] -pub struct EffectDef { - pub id: &'static str, - pub color: u32, - pub category: Category, - pub instant: bool, -} -const fn fx(id: &'static str, color: u32, category: Category) -> EffectDef { - EffectDef { - id, - color, - category, - instant: false, - } -} -use Category::{Beneficial as B, Harmful as H, Neutral as N}; -/// `MobEffects` in registration order. -pub const EFFECTS: &[EffectDef] = &[ - fx("speed", 3402751, B), - fx("slowness", 9154528, H), - fx("haste", 14270531, B), - fx("mining_fatigue", 4866583, H), - fx("strength", 16762624, B), - EffectDef { - id: "instant_health", - color: 16262179, - category: B, - instant: true, - }, - EffectDef { - id: "instant_damage", - color: 11101546, - category: H, - instant: true, - }, - fx("jump_boost", 16646020, B), - fx("nausea", 5578058, H), - fx("regeneration", 13458603, B), - fx("resistance", 9520880, B), - fx("fire_resistance", 16750848, B), - fx("water_breathing", 10017472, B), - fx("invisibility", 16185078, B), - fx("blindness", 2039587, H), - fx("night_vision", 12779366, B), - fx("hunger", 5797459, H), - fx("weakness", 4738376, H), - fx("poison", 8889187, H), - fx("wither", 7561558, H), - fx("health_boost", 16284963, B), - fx("absorption", 2445989, B), - EffectDef { - id: "saturation", - color: 16262179, - category: B, - instant: true, - }, - fx("glowing", 9740385, N), - fx("levitation", 13565951, H), - fx("luck", 5882118, B), - fx("unluck", 12624973, H), - fx("slow_falling", 15978425, B), - fx("conduit_power", 1950417, B), - fx("dolphins_grace", 8954814, B), - fx("bad_omen", 745784, N), - fx("hero_of_the_village", 4521796, B), - fx("darkness", 2696993, H), - fx("trial_omen", 1484454, N), - fx("raid_omen", 14565464, N), - fx("wind_charged", 12438015, H), - fx("weaving", 7891290, H), - fx("oozing", 10092451, H), - fx("infested", 9214860, H), - fx("breath_of_the_nautilus", 65518, B), -]; -pub fn effect(id: &str) -> Option<&'static EffectDef> { - let id = id.trim_start_matches("minecraft:"); - EFFECTS.iter().find(|e| e.id == id) -} -/// Namespaced effect ids for mob effect storage. -pub fn namespaced(id: &'static str) -> &'static str { - static IDS: OnceLock> = OnceLock::new(); - IDS.get_or_init(|| { - EFFECTS - .iter() - .map(|e| { - ( - e.id, - &*Box::leak(format!("minecraft:{}", e.id).into_boxed_str()), - ) - }) - .collect() - }) - .get(id) - .copied() - .unwrap_or(id) -} -/// A `Potion`: id, name suffix (`item.minecraft.potion.effect.`) and -/// effects as (effect, duration ticks, amplifier). -#[derive(Clone, Copy, Debug)] -pub struct PotionDef { - pub id: &'static str, - pub name: &'static str, - pub effects: &'static [(&'static str, i32, i32)], -} -const fn p( - id: &'static str, - name: &'static str, - effects: &'static [(&'static str, i32, i32)], -) -> PotionDef { - PotionDef { id, name, effects } -} -/// `Potions` in registration order. -pub const POTIONS: &[PotionDef] = &[ - p("water", "water", &[]), - p("mundane", "mundane", &[]), - p("thick", "thick", &[]), - p("awkward", "awkward", &[]), - p("night_vision", "night_vision", &[("night_vision", 3600, 0)]), - p( - "long_night_vision", - "night_vision", - &[("night_vision", 9600, 0)], - ), - p("invisibility", "invisibility", &[("invisibility", 3600, 0)]), - p( - "long_invisibility", - "invisibility", - &[("invisibility", 9600, 0)], - ), - p("leaping", "leaping", &[("jump_boost", 3600, 0)]), - p("long_leaping", "leaping", &[("jump_boost", 9600, 0)]), - p("strong_leaping", "leaping", &[("jump_boost", 1800, 1)]), - p( - "fire_resistance", - "fire_resistance", - &[("fire_resistance", 3600, 0)], - ), - p( - "long_fire_resistance", - "fire_resistance", - &[("fire_resistance", 9600, 0)], - ), - p("swiftness", "swiftness", &[("speed", 3600, 0)]), - p("long_swiftness", "swiftness", &[("speed", 9600, 0)]), - p("strong_swiftness", "swiftness", &[("speed", 1800, 1)]), - p("slowness", "slowness", &[("slowness", 1800, 0)]), - p("long_slowness", "slowness", &[("slowness", 4800, 0)]), - p("strong_slowness", "slowness", &[("slowness", 400, 3)]), - p( - "turtle_master", - "turtle_master", - &[("slowness", 400, 3), ("resistance", 400, 2)], - ), - p( - "long_turtle_master", - "turtle_master", - &[("slowness", 800, 3), ("resistance", 800, 2)], - ), - p( - "strong_turtle_master", - "turtle_master", - &[("slowness", 400, 5), ("resistance", 400, 3)], - ), - p( - "water_breathing", - "water_breathing", - &[("water_breathing", 3600, 0)], - ), - p( - "long_water_breathing", - "water_breathing", - &[("water_breathing", 9600, 0)], - ), - p("healing", "healing", &[("instant_health", 1, 0)]), - p("strong_healing", "healing", &[("instant_health", 1, 1)]), - p("harming", "harming", &[("instant_damage", 1, 0)]), - p("strong_harming", "harming", &[("instant_damage", 1, 1)]), - p("poison", "poison", &[("poison", 900, 0)]), - p("long_poison", "poison", &[("poison", 1800, 0)]), - p("strong_poison", "poison", &[("poison", 432, 1)]), - p("regeneration", "regeneration", &[("regeneration", 900, 0)]), - p( - "long_regeneration", - "regeneration", - &[("regeneration", 1800, 0)], - ), - p( - "strong_regeneration", - "regeneration", - &[("regeneration", 450, 1)], - ), - p("strength", "strength", &[("strength", 3600, 0)]), - p("long_strength", "strength", &[("strength", 9600, 0)]), - p("strong_strength", "strength", &[("strength", 1800, 1)]), - p("weakness", "weakness", &[("weakness", 1800, 0)]), - p("long_weakness", "weakness", &[("weakness", 4800, 0)]), - p("luck", "luck", &[("luck", 6000, 0)]), - p("slow_falling", "slow_falling", &[("slow_falling", 1800, 0)]), - p( - "long_slow_falling", - "slow_falling", - &[("slow_falling", 4800, 0)], - ), - p("wind_charged", "wind_charged", &[("wind_charged", 3600, 0)]), - p("weaving", "weaving", &[("weaving", 3600, 0)]), - p("oozing", "oozing", &[("oozing", 3600, 0)]), - p("infested", "infested", &[("infested", 3600, 0)]), -]; -pub fn potion(id: &str) -> Option<&'static PotionDef> { - let id = id.trim_start_matches("minecraft:"); - POTIONS.iter().find(|p| p.id == id) -} -/// `PotionContents.BASE_POTION_COLOR` (ARGB -13083194) as RGB. -pub const BASE_POTION_COLOR: u32 = 0x385DC6; -/// `PotionContents.getColor`: amplifier-weighted mix of visible effect colours. -pub fn potion_color(id: Option<&str>) -> u32 { - let Some(def) = id.and_then(potion) else { - return BASE_POTION_COLOR; - }; - let (mut r, mut g, mut b, mut total) = (0u32, 0u32, 0u32, 0u32); - for (e, _, amp) in def.effects { - let Some(e) = effect(e) else { continue }; - let w = *amp as u32 + 1; - r += w * (e.color >> 16 & 255); - g += w * (e.color >> 8 & 255); - b += w * (e.color & 255); - total += w; - } - match ( - r.checked_div(total), - g.checked_div(total), - b.checked_div(total), - ) { - (Some(r), Some(g), Some(b)) => (r << 16) | (g << 8) | b, - _ => BASE_POTION_COLOR, - } -} +pub use horizon_client_core::potions::{ + BASE_POTION_COLOR, Category, EFFECTS, EffectDef, POTIONS, PotionDef, effect, namespaced, + potion, potion_color, +}; /// `MobEffectUtil.formatDuration` at 20 TPS: m:ss or h:mm:ss. pub fn format_duration(ticks: i32) -> String { let secs = ticks / 20; diff --git a/crates/horizon-client/src/effects.rs b/crates/horizon-client/src/effects.rs index 387de78b6..9511fd112 100644 --- a/crates/horizon-client/src/effects.rs +++ b/crates/horizon-client/src/effects.rs @@ -2,7 +2,7 @@ //! add/update with hidden effects, per-tick application of the periodic //! effects (regeneration, poison, wither, hunger, saturation, instant //! effects), and the derived flags the movement and damage code read. -use crate::brewing; +use horizon_client_core::potions; #[derive(Clone, Debug, PartialEq)] pub struct EffectInstance { @@ -183,7 +183,7 @@ impl PlayerEffects { pub fn from_saved(saved: &[(String, i32, i32, bool, bool)]) -> Self { let mut effects = Self::default(); for (id, duration, amplifier, ambient, particles) in saved { - if let Some(def) = brewing::effect(id) { + if let Some(def) = potions::effect(id) { let mut e = EffectInstance::new(def.id, *duration, *amplifier); e.ambient = *ambient; e.visible = *particles; @@ -306,10 +306,10 @@ impl PlayerEffects { ) -> (Vec, Vec) { let mut lasting = Vec::new(); let mut now = Vec::new(); - if let Some(def) = potion.and_then(brewing::potion) { + if let Some(def) = potion.and_then(potions::potion) { for (id, duration, amp) in def.effects { - let id = brewing::effect(id).map_or("speed", |e| e.id); - if brewing::effect(id).is_some_and(|e| e.instant) { + let id = potions::effect(id).map_or("speed", |e| e.id); + if potions::effect(id).is_some_and(|e| e.instant) { now.extend(instant(id, *amp, 1.0)); } else { // withScaledDuration: max(floor(d * scale), 1). diff --git a/crates/horizon-client/src/hud_overlays.rs b/crates/horizon-client/src/hud_overlays.rs index c6b098f75..8af2c2a0d 100644 --- a/crates/horizon-client/src/hud_overlays.rs +++ b/crates/horizon-client/src/hud_overlays.rs @@ -107,10 +107,11 @@ pub struct EffectIcon { impl From<&crate::effects::EffectInstance> for EffectIcon { fn from(effect: &crate::effects::EffectInstance) -> Self { - let def = crate::brewing::effect(effect.id); + let def = horizon_client_core::potions::effect(effect.id); Self { id: effect.id.to_owned(), - beneficial: def.is_some_and(|d| d.category == crate::brewing::Category::Beneficial), + beneficial: def + .is_some_and(|d| d.category == horizon_client_core::potions::Category::Beneficial), color: def.map_or(0, |d| d.color as i32), ambient: effect.ambient, duration: effect.duration,