From 2b2aecd9757305af6e124daeaf55b5327440c02e Mon Sep 17 00:00:00 2001 From: mahirsn Date: Mon, 26 Oct 2026 21:40:03 +0300 Subject: [PATCH 1/2] fix(client): send sign editor text like vanilla A new editor or a removed sign closes the open editor (Minecraft.setScreen, AbstractSignEditScreen.tick), and closing sends ServerboundSignUpdatePacket with the lines it opened with when the sign is gone. Sign lines resolve key binds and translations (Component.getString) instead of keeping only plain text. --- crates/horizon-client/src/game/remote.rs | 9 +++++++ crates/horizon-client/src/game/sign_edit.rs | 29 +++++++++++++++------ crates/horizon-client/src/signs.rs | 8 +++--- 3 files changed, 34 insertions(+), 12 deletions(-) diff --git a/crates/horizon-client/src/game/remote.rs b/crates/horizon-client/src/game/remote.rs index 3cfbd15e3..4e279de6c 100644 --- a/crates/horizon-client/src/game/remote.rs +++ b/crates/horizon-client/src/game/remote.rs @@ -3129,6 +3129,15 @@ impl Game<'_> { fn tick_remote_level(&mut self) -> Result<()> { self.ticks += 1; + // AbstractSignEditScreen.tick: the editor closes once its sign is removed. + if let Some(edit) = &self.sign_edit + && !matches!( + self.world.block_entities.get(&edit.pos), + Some(BlockEntity::Sign(_)) + ) + { + self.close_sign_editor(); + } self.track_experience_display(); // Player.tick's ItemCooldowns.tick: this path replaces `tick_world`'s // for a server's client (multiplayer and the default single player), diff --git a/crates/horizon-client/src/game/sign_edit.rs b/crates/horizon-client/src/game/sign_edit.rs index 2d010f1f5..529e511f2 100644 --- a/crates/horizon-client/src/game/sign_edit.rs +++ b/crates/horizon-client/src/game/sign_edit.rs @@ -20,6 +20,9 @@ pub(super) struct SignEditor { pub line: usize, /// The line being edited (`AbstractSignEditScreen`'s text field). edit: EditBox, + /// `AbstractSignEditScreen.messages`: the lines when it opened, sent if + /// the sign is gone by the time the editor closes. + lines: [String; 4], } fn sign_box() -> EditBox { @@ -33,11 +36,19 @@ fn sign_box() -> EditBox { impl Game<'_> { /// `SignBlock.openTextEdit` for the front side after placement. pub(super) fn open_sign_editor(&mut self, pos: (i32, i32, i32), front: bool) { + // Minecraft.setScreen: the editor already open is removed first. + self.close_sign_editor(); + let lines = match self.world.block_entities.get(&pos) { + Some(BlockEntity::Sign(sign)) if front => sign.front.lines.clone(), + Some(BlockEntity::Sign(sign)) => sign.back.lines.clone(), + _ => Default::default(), + }; self.sign_edit = Some(SignEditor { pos, front, line: 0, edit: sign_box(), + lines, }); self.sign_load(); self.keys.clear(); @@ -50,14 +61,16 @@ impl Game<'_> { pub(super) fn close_sign_editor(&mut self) { if let Some(edit) = self.sign_edit.take() { if self.remote.is_some() { - if let Some(BlockEntity::Sign(sign)) = self.world.block_entities.get(&edit.pos) { - let side = if edit.front { &sign.front } else { &sign.back }; - self.send(S::SignUpdate(play::SignUpdate { - pos: [edit.pos.0, edit.pos.1, edit.pos.2], - lines: side.lines.clone(), - front: edit.front, - })); - } + let lines = match self.world.block_entities.get(&edit.pos) { + Some(BlockEntity::Sign(sign)) if edit.front => sign.front.lines.clone(), + Some(BlockEntity::Sign(sign)) => sign.back.lines.clone(), + _ => edit.lines, + }; + self.send(S::SignUpdate(play::SignUpdate { + pos: [edit.pos.0, edit.pos.1, edit.pos.2], + lines, + front: edit.front, + })); } else { self.mark_block_entity_updated(edit.pos); } diff --git a/crates/horizon-client/src/signs.rs b/crates/horizon-client/src/signs.rs index 07217ed79..799210797 100644 --- a/crates/horizon-client/src/signs.rs +++ b/crates/horizon-client/src/signs.rs @@ -147,10 +147,10 @@ fn component_text(tag: &Tag) -> String { _ => s, } } - Tag::Compound(_) => match tag.get("text") { - Some(Tag::String(t)) => t.to_string_lossy(), - _ => String::new(), - }, + // Component.getString: translations and key binds resolved. + Tag::Compound(_) => { + crate::scoreboard::comp_text(&crate::scoreboard::tag_to_json(tag)).plain() + } _ => String::new(), } } From 03d8ffe2c6f6cd7f379485900e4d818b7db0ce5a Mon Sep 17 00:00:00 2001 From: Ludovic Marie <136255825+ludovic111@users.noreply.github.com> Date: Tue, 27 Oct 2026 06:22:28 +0100 Subject: [PATCH 2/2] Sign editor: send the lines as edited, sign or not AbstractSignEditScreen.setMessage writes messages[line] and the sign; removed() sends messages. The editor keeps its lines up to date, so a sign removed while it is open still gets the player's text (review by rdbt's agent). Co-Authored-By: Claude Opus 5.5 --- crates/horizon-client/src/game/sign_edit.rs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/crates/horizon-client/src/game/sign_edit.rs b/crates/horizon-client/src/game/sign_edit.rs index 529e511f2..cd82c542b 100644 --- a/crates/horizon-client/src/game/sign_edit.rs +++ b/crates/horizon-client/src/game/sign_edit.rs @@ -20,8 +20,8 @@ pub(super) struct SignEditor { pub line: usize, /// The line being edited (`AbstractSignEditScreen`'s text field). edit: EditBox, - /// `AbstractSignEditScreen.messages`: the lines when it opened, sent if - /// the sign is gone by the time the editor closes. + /// `AbstractSignEditScreen.messages`: the side's lines as edited, sent + /// when the editor closes, even if the sign is gone by then. lines: [String; 4], } @@ -61,14 +61,9 @@ impl Game<'_> { pub(super) fn close_sign_editor(&mut self) { if let Some(edit) = self.sign_edit.take() { if self.remote.is_some() { - let lines = match self.world.block_entities.get(&edit.pos) { - Some(BlockEntity::Sign(sign)) if edit.front => sign.front.lines.clone(), - Some(BlockEntity::Sign(sign)) => sign.back.lines.clone(), - _ => edit.lines, - }; self.send(S::SignUpdate(play::SignUpdate { pos: [edit.pos.0, edit.pos.1, edit.pos.2], - lines, + lines: edit.lines, front: edit.front, })); } else { @@ -219,7 +214,8 @@ impl Game<'_> { edit.edit.set_value(&text); } } - /// The box's text onto the sign, when it still fits the line. + /// The box's text onto the editor's lines and the sign + /// (`AbstractSignEditScreen.setMessage`), when it still fits the line. fn sign_write(&mut self) { let Some(edit) = self.sign_edit.as_ref() else { return; @@ -228,6 +224,9 @@ impl Game<'_> { if !self.sign_fits(&value) { return; } + if let Some(edit) = self.sign_edit.as_mut() { + edit.lines[line].clone_from(&value); + } let Some(BlockEntity::Sign(sign)) = self.world.block_entities.get_mut(&pos) else { return; };