3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-11-16 04:50:08 +01:00

Move VV specific item handling out of component<->nbt conversion in 1.20.3->1.20.5 (#4094)

The current code backups the tag in CUSTOM_DATA inside the toStructuredItem function which in VB is used for to server packets which causes bad data, this PR moves the backup logic out to the VV specific handler and also prevents toOldItem logic for using the backup to ever get executed in VB. The counterpart PR will add proper handling for CUSTOM_DATA.

Fixes https://github.com/ViaVersion/ViaVersion/issues/4092
Dieser Commit ist enthalten in:
EnZaXD 2024-08-14 09:31:27 +02:00 committet von GitHub
Ursprung fcd91bb855
Commit 1b03e24160
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: B5690EEEBB952194

Datei anzeigen

@ -376,13 +376,15 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
return StructuredItem.empty(); return StructuredItem.empty();
} }
// Add the original as custom data, to be re-used for creative clients as well
final CompoundTag tag = item.tag(); final CompoundTag tag = item.tag();
final Item structuredItem = toStructuredItem(connection, item);
// Add the original as custom data, to be re-used for creative clients as well
if (tag != null) { if (tag != null) {
tag.putBoolean(nbtTagName(), true); tag.putBoolean(nbtTagName(), true);
structuredItem.dataContainer().set(StructuredDataKey.CUSTOM_DATA, tag);
} }
final Item structuredItem = toStructuredItem(connection, item);
// Add data components to fix issues in older protocols // Add data components to fix issues in older protocols
appendItemDataFixComponents(connection, structuredItem); appendItemDataFixComponents(connection, structuredItem);
@ -415,7 +417,8 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
final StructuredData<CompoundTag> customData = data.getNonEmpty(StructuredDataKey.CUSTOM_DATA); final StructuredData<CompoundTag> customData = data.getNonEmpty(StructuredDataKey.CUSTOM_DATA);
final CompoundTag tag = customData != null ? customData.value() : new CompoundTag(); final CompoundTag tag = customData != null ? customData.value() : new CompoundTag();
final DataItem dataItem = new DataItem(item.identifier(), (byte) item.amount(), tag); final DataItem dataItem = new DataItem(item.identifier(), (byte) item.amount(), tag);
if (customData != null && tag.remove(nbtTagName()) != null) { if (!dataConverter.backupInconvertibleData() && customData != null && tag.remove(nbtTagName()) != null) {
// Skip for VB since it's used for incoming item data
return dataItem; return dataItem;
} }
@ -605,8 +608,6 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
// Restore original data components // Restore original data components
restoreFromBackupTag(backupTag, data); restoreFromBackupTag(backupTag, data);
} }
data.set(StructuredDataKey.CUSTOM_DATA, tag);
return item; return item;
} }