Skip to content

Commit bc4ad7f

Browse files
Remove empty lock item components in 1.21->1.21.2 (ViaVersion#4228)
* Fix protocol error when an empty lock is sent * Cleanup code --------- Co-authored-by: FlorianMichael <[email protected]>
1 parent f08a412 commit bc4ad7f

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

common/src/main/java/com/viaversion/viaversion/protocols/v1_21to1_21_2/rewriter/BlockItemPacketRewriter1_21_2.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -563,11 +563,17 @@ public static void updateItemData(final Item item) {
563563
dataContainer.replaceKey(StructuredDataKey.BUNDLE_CONTENTS1_21, StructuredDataKey.BUNDLE_CONTENTS1_21_2);
564564
dataContainer.replaceKey(StructuredDataKey.POTION_CONTENTS1_20_5, StructuredDataKey.POTION_CONTENTS1_21_2);
565565
dataContainer.replace(StructuredDataKey.FIRE_RESISTANT, StructuredDataKey.DAMAGE_RESISTANT, fireResistant -> new DamageResistant("minecraft:is_fire"));
566-
dataContainer.replace(StructuredDataKey.LOCK, lock -> {
566+
dataContainer.replace(StructuredDataKey.LOCK, tag -> {
567+
final String lock = ((StringTag) tag).getValue();
568+
if (lock.isEmpty()) {
569+
// Previously ignored empty values since the data was arbitrary, custom_name doesn't accept empty values
570+
return null;
571+
}
572+
567573
final CompoundTag predicateTag = new CompoundTag();
568574
final CompoundTag itemComponentsTag = new CompoundTag();
569575
predicateTag.put("components", itemComponentsTag);
570-
itemComponentsTag.put("custom_name", lock);
576+
itemComponentsTag.put("custom_name", tag);
571577
return predicateTag;
572578
});
573579
}

0 commit comments

Comments
 (0)