3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-27 08:30:09 +01:00

Remove empty lock item components in 1.21->1.21.2 (#4228)

* Fix protocol error when an empty lock is sent

* Cleanup code

---------

Co-authored-by: FlorianMichael <florian.michael07@gmail.com>
Dieser Commit ist enthalten in:
Valaphee The Meerkat 2024-10-31 19:27:49 +01:00 committet von GitHub
Ursprung f08a412db5
Commit bc4ad7faa3
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: B5690EEEBB952194

Datei anzeigen

@ -563,11 +563,17 @@ public final class BlockItemPacketRewriter1_21_2 extends StructuredItemRewriter<
dataContainer.replaceKey(StructuredDataKey.BUNDLE_CONTENTS1_21, StructuredDataKey.BUNDLE_CONTENTS1_21_2); dataContainer.replaceKey(StructuredDataKey.BUNDLE_CONTENTS1_21, StructuredDataKey.BUNDLE_CONTENTS1_21_2);
dataContainer.replaceKey(StructuredDataKey.POTION_CONTENTS1_20_5, StructuredDataKey.POTION_CONTENTS1_21_2); dataContainer.replaceKey(StructuredDataKey.POTION_CONTENTS1_20_5, StructuredDataKey.POTION_CONTENTS1_21_2);
dataContainer.replace(StructuredDataKey.FIRE_RESISTANT, StructuredDataKey.DAMAGE_RESISTANT, fireResistant -> new DamageResistant("minecraft:is_fire")); dataContainer.replace(StructuredDataKey.FIRE_RESISTANT, StructuredDataKey.DAMAGE_RESISTANT, fireResistant -> new DamageResistant("minecraft:is_fire"));
dataContainer.replace(StructuredDataKey.LOCK, lock -> { dataContainer.replace(StructuredDataKey.LOCK, tag -> {
final String lock = ((StringTag) tag).getValue();
if (lock.isEmpty()) {
// Previously ignored empty values since the data was arbitrary, custom_name doesn't accept empty values
return null;
}
final CompoundTag predicateTag = new CompoundTag(); final CompoundTag predicateTag = new CompoundTag();
final CompoundTag itemComponentsTag = new CompoundTag(); final CompoundTag itemComponentsTag = new CompoundTag();
predicateTag.put("components", itemComponentsTag); predicateTag.put("components", itemComponentsTag);
itemComponentsTag.put("custom_name", lock); itemComponentsTag.put("custom_name", tag);
return predicateTag; return predicateTag;
}); });
} }