Skip to content

Commit 3688810

Browse files
committed
Fix non-empty custom tag backup in 1.20.5->1.20.4
Fixes #1231
1 parent be0f50a commit 3688810

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

common/src/main/java/com/viaversion/viabackwards/protocol/v1_20_5to1_20_3/rewriter/BlockItemPacketRewriter1_20_5.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,12 @@ private void removeEmptyList(final CompoundTag tag, final String key) {
266266
data.set(StructuredDataKey.FIREWORKS, new Fireworks(1, new FireworkExplosion[0]));
267267
}
268268

269-
final CompoundTag customData = data.get(StructuredDataKey.CUSTOM_DATA);
269+
CompoundTag customData = data.get(StructuredDataKey.CUSTOM_DATA);
270+
if (customData != null) {
271+
// Copy original custom data before changes
272+
customData = customData.copy();
273+
}
274+
270275
final Item oldItem = vvProtocol.getItemRewriter().toOldItem(connection, item, DATA_CONVERTER);
271276

272277
if (customData != null) {
@@ -275,7 +280,7 @@ private void removeEmptyList(final CompoundTag tag, final String key) {
275280
if (oldItem.tag() == null) {
276281
oldItem.setTag(new CompoundTag());
277282
}
278-
oldItem.tag().put(nbtTagName(), customData.copy());
283+
oldItem.tag().put(nbtTagName(), customData);
279284
} else if (oldItem.tag() != null && oldItem.tag().isEmpty()) {
280285
// Improve item equality checks by removing empty tags
281286
oldItem.setTag(null);

0 commit comments

Comments
 (0)