Skip to content

Commit

Permalink
Fix incorrect shadow color deserialization/serialization
Browse files Browse the repository at this point in the history
Previously, packetevents expected shadow color to be serialized as a hex string
Vanilla serializes shadow colors as a single integer instead
  • Loading branch information
booky10 committed Jan 18, 2025
1 parent 6507a73 commit e1df407
Showing 1 changed file with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -331,10 +331,8 @@ public AdventureNBTSerializer(boolean downsampleColor) {
if (color != null) style.color(color);
});
if (BackwardCompatUtil.IS_4_18_0_OR_NEWER) {
reader.useUTF("shadow_color", value -> {
ShadowColor color = ShadowColor.fromHexString(value);
if (color != null) style.shadowColor(color);
});
reader.useNumber("shadow_color", num ->
style.shadowColor(ShadowColor.shadowColor(num.intValue())));
}

for (String decorationKey : TextDecoration.NAMES.keys()) {
Expand Down Expand Up @@ -413,7 +411,7 @@ public AdventureNBTSerializer(boolean downsampleColor) {

if (BackwardCompatUtil.IS_4_18_0_OR_NEWER) {
ShadowColor shadowColor = style.shadowColor();
if (shadowColor != null) writer.writeUTF("shadow_color", shadowColor.asHexString());
if (shadowColor != null) writer.writeInt("shadow_color", shadowColor.value());
}

for (TextDecoration decoration : TextDecoration.NAMES.values()) {
Expand Down

0 comments on commit e1df407

Please sign in to comment.