Fix signs displaying JSON text on Minecraft 1.21.5+ - #3605
Conversation
There was a problem hiding this comment.
Pull request overview
Updates legacy SignBlock NBT serialization to account for Minecraft 1.21.5’s change where sign text NBT strings are treated as literal components (not JSON-in-string), preventing signs placed via commands like //set spruce_sign from showing JSON source on 1.21.5+.
Changes:
- Make
SignBlockwrite JSON-in-string text for < 1.21.5 and literal strings for >= 1.21.5, including version-appropriate empty defaults. - Add regression tests covering multiple data versions around the 1.21.5 boundary and newer versions.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| worldedit-core/src/legacy/java/com/sk89q/worldedit/blocks/SignBlock.java | Switch sign text encoding/empties based on data version to match 1.21.5+ semantics. |
| worldedit-core/src/test/java/com/sk89q/worldedit/blocks/SignBlockTest.java | Add tests validating JSON vs literal sign message serialization across multiple versions. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| this.dataVersion = WorldEdit.getInstance().getPlatformManager() | ||
| int dataVersion = WorldEdit.getInstance().getPlatformManager() | ||
| .queryCapability(Capability.WORLD_EDITING).getDataVersion(); | ||
| this.legacy = dataVersion < Constants.DATA_VERSION_MC_1_20; |
There was a problem hiding this comment.
Not actually sure we support < 1.20 anymore - don't need to support legacy anymore?
There was a problem hiding this comment.
Addressed in f4e1b07 by removing the pre-1.20 Text1-Text4 NBT path. The 1.21.5 JSON/literal text boundary remains, and the pre-1.21.5 test now also covers the minimum supported 1.21 data version.
Overview
Fixes #3379
Description
Minecraft 1.21.5 changed the representation of text components in sign NBT. A string now represents a literal
text component instead of JSON-encoded text.
SignBlockcontinued wrapping each line in JSON inside the NBTstring, which caused commands such as
//set spruce_signto display the JSON source on the sign.This change preserves the JSON-in-string representation before Minecraft 1.21.5 and writes literal strings on
Minecraft 1.21.5 and newer. It also uses the version-appropriate empty value when constructing signs or loading
incomplete sign NBT.
Regression tests cover Minecraft 1.21.4, the 1.21.5 format boundary, 1.21.10, 1.21.11, and 26.1.2.
Testing
./gradlew :worldedit-core:check --no-configure-on-demandSubmitter Checklist
@since TODO.