After analyzing the Minecraft 1.16.1 client code, I found that the bug is indeed in the client and caused by the rework of how lines are stored in net.minecraft.client.gui.screens.inventory.SignEditScreen.
In Minecraft 1.15.2, the previous major version, SignEditScreen used a single source of truth for the lines of the sign: net.minecraft.world.level.block.entity.SignBlockEntity.
In Minecraft 1.16.1, there is a new String[] messages field that gets initialized with 4 empty strings and never imports lines from the SignBlockEntity passed into the constructor. The corresponding TextFieldHelper (created in SignEditScreen.init()) then accesses those empty strings.
To fix the bug, the String[] messages field in SignEditScreen needs to import the sign lines from the SignBlockEntity sign field either in the constructor (better place) or early in the SignEditScreen.init() method (worse place). Alternatively, for cleaner code, the introduction of String[] messages should be reverted. Minecraft 1.15.2 had a working getter (SignBlockEntity.getMessage()) and setter (SignBlockEntity.setMessage()), so why not keep using them?
The members and constructor as they are in Minecraft 1.16.1:
The quickest way to fix the bug (assuming that SignBlockEntity.getMessage() still returns a net.minecraft.network.chat.Component like in Minecraft 1.15.2) should be to change the constructor to this:
public SignEditScreen(SignBlockEntity var1) {
super(new TranslatableComponent("sign.edit"));
this.sign = var1;
Arrays.setAll(messages, i -> sign.getMessage(i).getString());
}
After analyzing the Minecraft 1.16.1 client code, I found that the bug is indeed in the client and caused by the rework of how lines are stored in
net.minecraft.client.gui.screens.inventory.SignEditScreen
.In Minecraft 1.15.2, the previous major version,
SignEditScreen
used a single source of truth for the lines of the sign:net.minecraft.world.level.block.entity.SignBlockEntity
.In Minecraft 1.16.1, there is a new
String[] messages
field that gets initialized with 4 empty strings and never imports lines from theSignBlockEntity
passed into the constructor. The correspondingTextFieldHelper
(created inSignEditScreen.init()
) then accesses those empty strings.To fix the bug, the
String[] messages
field inSignEditScreen
needs to import the sign lines from theSignBlockEntity sign
field either in the constructor (better place) or early in theSignEditScreen.init()
method (worse place). Alternatively, for cleaner code, the introduction ofString[] messages
should be reverted. Minecraft 1.15.2 had a working getter (SignBlockEntity.getMessage()
) and setter (SignBlockEntity.setMessage()
), so why not keep using them?The members and constructor as they are in Minecraft 1.16.1:
The quickest way to fix the bug (assuming that
SignBlockEntity.getMessage()
still returns anet.minecraft.network.chat.Component
like in Minecraft 1.15.2) should be to change the constructor to this: