Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-11-19 14:30:16 +01:00
Handle Slot tag inside CONTAINER tag in 1.20.3->1.20.5
Fixes shulker box tooltips not showing all items for 1.20.3 clients on 1.20.5+ servers. TODO find out if we should backup the Slot tag in VV as well (it seems the server resyncs it, but I'm not sure if there are cases were that breaks) for creative mode. Closes https://github.com/ViaVersion/ViaBackwards/issues/803 Closes https://github.com/ViaVersion/ViaVersion/issues/3903
Dieser Commit ist enthalten in:
Ursprung
dc503cd613
Commit
df0572e570
@ -18,6 +18,7 @@
|
|||||||
package com.viaversion.viaversion.protocols.v1_20_3to1_20_5.rewriter;
|
package com.viaversion.viaversion.protocols.v1_20_3to1_20_5.rewriter;
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
|
import com.viaversion.nbt.tag.ByteTag;
|
||||||
import com.viaversion.nbt.tag.CompoundTag;
|
import com.viaversion.nbt.tag.CompoundTag;
|
||||||
import com.viaversion.nbt.tag.FloatTag;
|
import com.viaversion.nbt.tag.FloatTag;
|
||||||
import com.viaversion.nbt.tag.IntArrayTag;
|
import com.viaversion.nbt.tag.IntArrayTag;
|
||||||
@ -798,30 +799,39 @@ public final class StructuredDataConverter {
|
|||||||
|
|
||||||
private void convertItemList(final UserConnection connection, final Item[] items, final CompoundTag tag, final String key) {
|
private void convertItemList(final UserConnection connection, final Item[] items, final CompoundTag tag, final String key) {
|
||||||
final ListTag<CompoundTag> itemsTag = new ListTag<>(CompoundTag.class);
|
final ListTag<CompoundTag> itemsTag = new ListTag<>(CompoundTag.class);
|
||||||
for (final Item item : items) {
|
for (int i = 0; i < items.length; i++) {
|
||||||
final CompoundTag savedItem = new CompoundTag();
|
final Item item = items[i];
|
||||||
if (item != null) {
|
final CompoundTag savedItem = itemToTag(connection, item);
|
||||||
final String name = toMappedItemName(item.identifier());
|
// 1.20.4 clients need the Slot to display the item correctly
|
||||||
savedItem.putString("id", name);
|
if (backupInconvertibleData) {
|
||||||
if (backupInconvertibleData && name.isEmpty()) {
|
savedItem.putByte("Slot", (byte) i);
|
||||||
savedItem.putInt(ITEM_BACKUP_TAG_KEY, item.identifier());
|
|
||||||
}
|
|
||||||
savedItem.putByte("Count", (byte) item.amount());
|
|
||||||
|
|
||||||
final CompoundTag itemTag = new CompoundTag();
|
|
||||||
for (final StructuredData<?> data : item.dataContainer().data().values()) {
|
|
||||||
writeToTag(connection, data, itemTag);
|
|
||||||
}
|
|
||||||
savedItem.put("tag", itemTag);
|
|
||||||
} else {
|
|
||||||
savedItem.putString("id", "air");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
itemsTag.add(savedItem);
|
itemsTag.add(savedItem);
|
||||||
}
|
}
|
||||||
tag.put(key, itemsTag);
|
tag.put(key, itemsTag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private CompoundTag itemToTag(final UserConnection connection, final Item item) {
|
||||||
|
final CompoundTag savedItem = new CompoundTag();
|
||||||
|
if (item != null) {
|
||||||
|
final String name = toMappedItemName(item.identifier());
|
||||||
|
savedItem.putString("id", name);
|
||||||
|
if (backupInconvertibleData && name.isEmpty()) {
|
||||||
|
savedItem.putInt(ITEM_BACKUP_TAG_KEY, item.identifier());
|
||||||
|
}
|
||||||
|
savedItem.putByte("Count", (byte) item.amount());
|
||||||
|
|
||||||
|
final CompoundTag itemTag = new CompoundTag();
|
||||||
|
for (final StructuredData<?> data : item.dataContainer().data().values()) {
|
||||||
|
writeToTag(connection, data, itemTag);
|
||||||
|
}
|
||||||
|
savedItem.put("tag", itemTag);
|
||||||
|
} else {
|
||||||
|
savedItem.putString("id", "air");
|
||||||
|
}
|
||||||
|
return savedItem;
|
||||||
|
}
|
||||||
|
|
||||||
private void convertEnchantments(final Enchantments data, final CompoundTag tag, final boolean storedEnchantments) {
|
private void convertEnchantments(final Enchantments data, final CompoundTag tag, final boolean storedEnchantments) {
|
||||||
final ListTag<CompoundTag> enchantments = new ListTag<>(CompoundTag.class);
|
final ListTag<CompoundTag> enchantments = new ListTag<>(CompoundTag.class);
|
||||||
for (final Int2IntMap.Entry entry : data.enchantments().int2IntEntrySet()) {
|
for (final Int2IntMap.Entry entry : data.enchantments().int2IntEntrySet()) {
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren