3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-26 08:10:09 +01:00
Dieser Commit ist enthalten in:
Nassim Jahnke 2024-03-07 12:08:27 +01:00
Ursprung cad78ea68f
Commit f868dfa125
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: EF6771C01F6EF02F
27 geänderte Dateien mit 147 neuen und 205 gelöschten Zeilen

Datei anzeigen

@ -25,6 +25,7 @@ package com.viaversion.viaversion.api.data;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag; import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.github.steveice10.opennbt.tag.builtin.IntArrayTag; import com.github.steveice10.opennbt.tag.builtin.IntArrayTag;
import com.github.steveice10.opennbt.tag.builtin.ListTag; import com.github.steveice10.opennbt.tag.builtin.ListTag;
import com.github.steveice10.opennbt.tag.builtin.StringTag;
import com.github.steveice10.opennbt.tag.builtin.Tag; import com.github.steveice10.opennbt.tag.builtin.Tag;
import com.viaversion.viaversion.api.Via; import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.minecraft.RegistryType; import com.viaversion.viaversion.api.minecraft.RegistryType;
@ -83,8 +84,8 @@ public class MappingDataBase implements MappingData {
entityMappings = loadFullMappings(data, unmappedIdentifierData, mappedIdentifierData, "entities"); entityMappings = loadFullMappings(data, unmappedIdentifierData, mappedIdentifierData, "entities");
argumentTypeMappings = loadFullMappings(data, unmappedIdentifierData, mappedIdentifierData, "argumenttypes"); argumentTypeMappings = loadFullMappings(data, unmappedIdentifierData, mappedIdentifierData, "argumenttypes");
final ListTag unmappedParticles = unmappedIdentifierData.get("particles"); final ListTag<StringTag> unmappedParticles = unmappedIdentifierData.getListTag("particles", StringTag.class);
final ListTag mappedParticles = mappedIdentifierData.get("particles"); final ListTag<StringTag> mappedParticles = mappedIdentifierData.getListTag("particles", StringTag.class);
if (unmappedParticles != null && mappedParticles != null) { if (unmappedParticles != null && mappedParticles != null) {
Mappings particleMappings = loadMappings(data, "particles"); Mappings particleMappings = loadMappings(data, "particles");
if (particleMappings == null) { if (particleMappings == null) {

Datei anzeigen

@ -27,6 +27,7 @@ import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.github.steveice10.opennbt.tag.builtin.IntArrayTag; import com.github.steveice10.opennbt.tag.builtin.IntArrayTag;
import com.github.steveice10.opennbt.tag.builtin.IntTag; import com.github.steveice10.opennbt.tag.builtin.IntTag;
import com.github.steveice10.opennbt.tag.builtin.ListTag; import com.github.steveice10.opennbt.tag.builtin.ListTag;
import com.github.steveice10.opennbt.tag.builtin.StringTag;
import com.github.steveice10.opennbt.tag.io.NBTIO; import com.github.steveice10.opennbt.tag.io.NBTIO;
import com.github.steveice10.opennbt.tag.io.TagReader; import com.github.steveice10.opennbt.tag.io.TagReader;
import com.google.common.annotations.Beta; import com.google.common.annotations.Beta;
@ -227,8 +228,8 @@ public final class MappingDataLoader {
} }
public static FullMappings loadFullMappings(final CompoundTag mappingsTag, final CompoundTag unmappedIdentifiers, final CompoundTag mappedIdentifiers, final String key) { public static FullMappings loadFullMappings(final CompoundTag mappingsTag, final CompoundTag unmappedIdentifiers, final CompoundTag mappedIdentifiers, final String key) {
final ListTag unmappedElements = unmappedIdentifiers.get(key); final ListTag<StringTag> unmappedElements = unmappedIdentifiers.getListTag(key, StringTag.class);
final ListTag mappedElements = mappedIdentifiers.get(key); final ListTag<StringTag> mappedElements = mappedIdentifiers.getListTag(key, StringTag.class);
if (unmappedElements == null || mappedElements == null) { if (unmappedElements == null || mappedElements == null) {
return null; return null;
} }
@ -239,8 +240,8 @@ public final class MappingDataLoader {
} }
return new FullMappingsBase( return new FullMappingsBase(
unmappedElements.getValue().stream().map(t -> (String) t.getValue()).collect(Collectors.toList()), unmappedElements.getValue().stream().map(StringTag::getValue).collect(Collectors.toList()),
mappedElements.getValue().stream().map(t -> (String) t.getValue()).collect(Collectors.toList()), mappedElements.getValue().stream().map(StringTag::getValue).collect(Collectors.toList()),
mappings mappings
); );
} }

Datei anzeigen

@ -22,6 +22,7 @@ import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.github.steveice10.opennbt.tag.builtin.IntArrayTag; import com.github.steveice10.opennbt.tag.builtin.IntArrayTag;
import com.github.steveice10.opennbt.tag.builtin.ListTag; import com.github.steveice10.opennbt.tag.builtin.ListTag;
import com.github.steveice10.opennbt.tag.builtin.NumberTag; import com.github.steveice10.opennbt.tag.builtin.NumberTag;
import com.github.steveice10.opennbt.tag.builtin.StringTag;
import com.github.steveice10.opennbt.tag.builtin.Tag; import com.github.steveice10.opennbt.tag.builtin.Tag;
import com.viaversion.viaversion.api.Via; import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.connection.UserConnection;
@ -166,9 +167,9 @@ public final class ConnectionData {
} }
Via.getPlatform().getLogger().info("Loading block connection mappings ..."); Via.getPlatform().getLogger().info("Loading block connection mappings ...");
ListTag blockStates = MappingDataLoader.loadNBT("blockstates-1.13.nbt").getListTag("blockstates"); ListTag<StringTag> blockStates = MappingDataLoader.loadNBT("blockstates-1.13.nbt").getListTag("blockstates", StringTag.class);
for (int id = 0; id < blockStates.size(); id++) { for (int id = 0; id < blockStates.size(); id++) {
String key = (String) blockStates.get(id).getValue(); String key = blockStates.get(id).getValue();
KEY_TO_ID.put(key, id); KEY_TO_ID.put(key, id);
} }
@ -177,11 +178,10 @@ public final class ConnectionData {
if (!Via.getConfig().isReduceBlockStorageMemory()) { if (!Via.getConfig().isReduceBlockStorageMemory()) {
blockConnectionData = new Int2ObjectOpenHashMap<>(2048); blockConnectionData = new Int2ObjectOpenHashMap<>(2048);
ListTag blockConnectionMappings = MappingDataLoader.loadNBT("blockConnections.nbt").getListTag("data"); ListTag<CompoundTag> blockConnectionMappings = MappingDataLoader.loadNBT("blockConnections.nbt").getListTag("data", CompoundTag.class);
for (Tag blockTag : blockConnectionMappings) { for (CompoundTag blockTag : blockConnectionMappings) {
CompoundTag blockCompoundTag = (CompoundTag) blockTag;
BlockData blockData = new BlockData(); BlockData blockData = new BlockData();
for (Entry<String, Tag> entry : blockCompoundTag.entrySet()) { for (Entry<String, Tag> entry : blockTag.entrySet()) {
String key = entry.getKey(); String key = entry.getKey();
if (key.equals("id") || key.equals("ids")) { if (key.equals("id") || key.equals("ids")) {
continue; continue;
@ -198,11 +198,11 @@ public final class ConnectionData {
blockData.put(connectionTypeId, attachingFaces); blockData.put(connectionTypeId, attachingFaces);
} }
NumberTag idTag = blockCompoundTag.getNumberTag("id"); NumberTag idTag = blockTag.getNumberTag("id");
if (idTag != null) { if (idTag != null) {
blockConnectionData.put(idTag.asInt(), blockData); blockConnectionData.put(idTag.asInt(), blockData);
} else { } else {
IntArrayTag idsTag = blockCompoundTag.getIntArrayTag("ids"); IntArrayTag idsTag = blockTag.getIntArrayTag("ids");
for (int id : idsTag.getValue()) { for (int id : idsTag.getValue()) {
blockConnectionData.put(id, blockData); blockConnectionData.put(id, blockData);
} }

Datei anzeigen

@ -295,21 +295,16 @@ public class InventoryPackets extends ItemRewriter<ClientboundPackets1_12_1, Ser
blockEntityTag.putInt("Base", 15 - baseTag.asInt()); blockEntityTag.putInt("Base", 15 - baseTag.asInt());
} }
ListTag patternsTag = blockEntityTag.getListTag("Patterns"); ListTag<CompoundTag> patternsTag = blockEntityTag.getListTag("Patterns", CompoundTag.class);
if (patternsTag != null) { if (patternsTag != null) {
for (Tag pattern : patternsTag) { for (CompoundTag pattern : patternsTag) {
if (!(pattern instanceof CompoundTag)) { NumberTag colorTag = pattern.getNumberTag("Color");
continue;
}
CompoundTag patternTag = (CompoundTag) pattern;
NumberTag colorTag = patternTag.getNumberTag("Color");
if (colorTag == null) { if (colorTag == null) {
continue; continue;
} }
// Invert color id // Invert color id
patternTag.putInt("Color", 15 - colorTag.asInt()); pattern.putInt("Color", 15 - colorTag.asInt());
} }
} }
} }
@ -324,16 +319,11 @@ public class InventoryPackets extends ItemRewriter<ClientboundPackets1_12_1, Ser
} }
} }
// ench is now Enchantments and now uses identifiers // ench is now Enchantments and now uses identifiers
ListTag ench = tag.getListTag("ench"); ListTag<CompoundTag> ench = tag.getListTag("ench", CompoundTag.class);
if (ench != null) { if (ench != null) {
ListTag enchantments = new ListTag(CompoundTag.class); ListTag<CompoundTag> enchantments = new ListTag<>(CompoundTag.class);
for (Tag enchEntry : ench) { for (CompoundTag enchEntry : ench) {
if (!(enchEntry instanceof CompoundTag)) { NumberTag idTag = enchEntry.getNumberTag("id");
continue;
}
CompoundTag entryTag = (CompoundTag) enchEntry;
NumberTag idTag = entryTag.getNumberTag("id");
if (idTag == null) { if (idTag == null) {
continue; continue;
} }
@ -346,7 +336,7 @@ public class InventoryPackets extends ItemRewriter<ClientboundPackets1_12_1, Ser
} }
enchantmentEntry.putString("id", newId); enchantmentEntry.putString("id", newId);
NumberTag levelTag = entryTag.getNumberTag("lvl"); NumberTag levelTag = enchEntry.getNumberTag("lvl");
if (levelTag != null) { if (levelTag != null) {
enchantmentEntry.putShort("lvl", levelTag.asShort()); enchantmentEntry.putShort("lvl", levelTag.asShort());
} }
@ -357,16 +347,11 @@ public class InventoryPackets extends ItemRewriter<ClientboundPackets1_12_1, Ser
tag.put("Enchantments", enchantments); tag.put("Enchantments", enchantments);
} }
ListTag storedEnch = tag.getListTag("StoredEnchantments"); ListTag<CompoundTag> storedEnch = tag.getListTag("StoredEnchantments", CompoundTag.class);
if (storedEnch != null) { if (storedEnch != null) {
ListTag newStoredEnch = new ListTag(CompoundTag.class); ListTag<CompoundTag> newStoredEnch = new ListTag<>(CompoundTag.class);
for (Tag enchEntry : storedEnch) { for (CompoundTag enchEntry : storedEnch) {
if (!(enchEntry instanceof CompoundTag)) { NumberTag idTag = enchEntry.getNumberTag("id");
continue;
}
CompoundTag entryTag = (CompoundTag) enchEntry;
NumberTag idTag = entryTag.getNumberTag("id");
if (idTag == null) { if (idTag == null) {
continue; continue;
} }
@ -379,7 +364,7 @@ public class InventoryPackets extends ItemRewriter<ClientboundPackets1_12_1, Ser
} }
enchantmentEntry.putString("id", newId); enchantmentEntry.putString("id", newId);
NumberTag levelTag = entryTag.getNumberTag("lvl"); NumberTag levelTag = enchEntry.getNumberTag("lvl");
if (levelTag != null) { if (levelTag != null) {
enchantmentEntry.putShort("lvl", levelTag.asShort()); enchantmentEntry.putShort("lvl", levelTag.asShort());
} }
@ -389,9 +374,9 @@ public class InventoryPackets extends ItemRewriter<ClientboundPackets1_12_1, Ser
tag.put("StoredEnchantments", newStoredEnch); tag.put("StoredEnchantments", newStoredEnch);
} }
ListTag canPlaceOnTag = tag.getListTag("CanPlaceOn"); ListTag<?> canPlaceOnTag = tag.getListTag("CanPlaceOn");
if (canPlaceOnTag != null) { if (canPlaceOnTag != null) {
ListTag newCanPlaceOn = new ListTag(StringTag.class); ListTag<StringTag> newCanPlaceOn = new ListTag<>(StringTag.class);
tag.put(NBT_TAG_NAME + "|CanPlaceOn", canPlaceOnTag.copy()); tag.put(NBT_TAG_NAME + "|CanPlaceOn", canPlaceOnTag.copy());
for (Tag oldTag : canPlaceOnTag) { for (Tag oldTag : canPlaceOnTag) {
Object value = oldTag.getValue(); Object value = oldTag.getValue();
@ -412,9 +397,9 @@ public class InventoryPackets extends ItemRewriter<ClientboundPackets1_12_1, Ser
tag.put("CanPlaceOn", newCanPlaceOn); tag.put("CanPlaceOn", newCanPlaceOn);
} }
ListTag canDestroyTag = tag.getListTag("CanDestroy"); ListTag<?> canDestroyTag = tag.getListTag("CanDestroy");
if (canDestroyTag != null) { if (canDestroyTag != null) {
ListTag newCanDestroy = new ListTag(StringTag.class); ListTag<StringTag> newCanDestroy = new ListTag<>(StringTag.class);
tag.put(NBT_TAG_NAME + "|CanDestroy", canDestroyTag.copy()); tag.put(NBT_TAG_NAME + "|CanDestroy", canDestroyTag.copy());
for (Tag oldTag : canDestroyTag) { for (Tag oldTag : canDestroyTag) {
Object value = oldTag.getValue(); Object value = oldTag.getValue();
@ -594,16 +579,11 @@ public class InventoryPackets extends ItemRewriter<ClientboundPackets1_12_1, Ser
blockEntityTag.putInt("Base", 15 - baseTag.asInt()); // invert color id blockEntityTag.putInt("Base", 15 - baseTag.asInt()); // invert color id
} }
ListTag patternsTag = blockEntityTag.getListTag("Patterns"); ListTag<CompoundTag> patternsTag = blockEntityTag.getListTag("Patterns", CompoundTag.class);
if (patternsTag != null) { if (patternsTag != null) {
for (Tag pattern : patternsTag) { for (CompoundTag pattern : patternsTag) {
if (!(pattern instanceof CompoundTag)) { NumberTag colorTag = pattern.getNumberTag("Color");
continue; pattern.putInt("Color", 15 - colorTag.asInt()); // Invert color id
}
CompoundTag patternTag = (CompoundTag) pattern;
NumberTag colorTag = patternTag.getNumberTag("Color");
patternTag.putInt("Color", 15 - colorTag.asInt()); // Invert color id
} }
} }
} }
@ -619,16 +599,11 @@ public class InventoryPackets extends ItemRewriter<ClientboundPackets1_12_1, Ser
} }
// ench is now Enchantments and now uses identifiers // ench is now Enchantments and now uses identifiers
ListTag enchantments = tag.getListTag("Enchantments"); ListTag<CompoundTag> enchantments = tag.getListTag("Enchantments", CompoundTag.class);
if (enchantments != null) { if (enchantments != null) {
ListTag ench = new ListTag(CompoundTag.class); ListTag<CompoundTag> ench = new ListTag<>(CompoundTag.class);
for (Tag enchantmentEntry : enchantments) { for (CompoundTag enchantmentEntry : enchantments) {
if (!(enchantmentEntry instanceof CompoundTag)) { StringTag idTag = enchantmentEntry.getStringTag("id");
continue;
}
CompoundTag entryTag = (CompoundTag) enchantmentEntry;
StringTag idTag = entryTag.getStringTag("id");
if (idTag == null) { if (idTag == null) {
continue; continue;
} }
@ -641,7 +616,7 @@ public class InventoryPackets extends ItemRewriter<ClientboundPackets1_12_1, Ser
} }
if (oldId != null) { if (oldId != null) {
enchEntry.putShort("id", oldId); enchEntry.putShort("id", oldId);
NumberTag levelTag = entryTag.getNumberTag("lvl"); NumberTag levelTag = enchantmentEntry.getNumberTag("lvl");
if (levelTag != null) { if (levelTag != null) {
enchEntry.putShort("lvl", levelTag.asShort()); enchEntry.putShort("lvl", levelTag.asShort());
} }
@ -653,16 +628,11 @@ public class InventoryPackets extends ItemRewriter<ClientboundPackets1_12_1, Ser
} }
ListTag storedEnch = tag.getListTag("StoredEnchantments"); ListTag<CompoundTag> storedEnch = tag.getListTag("StoredEnchantments", CompoundTag.class);
if (storedEnch != null) { if (storedEnch != null) {
ListTag newStoredEnch = new ListTag(CompoundTag.class); ListTag<CompoundTag> newStoredEnch = new ListTag<>(CompoundTag.class);
for (Tag enchantmentEntry : storedEnch) { for (CompoundTag enchantmentEntry : storedEnch) {
if (!(enchantmentEntry instanceof CompoundTag)) { StringTag idTag = enchantmentEntry.getStringTag("id");
continue;
}
CompoundTag entryTag = (CompoundTag) enchantmentEntry;
StringTag idTag = entryTag.getStringTag("id");
if (idTag == null) { if (idTag == null) {
continue; continue;
} }
@ -679,7 +649,7 @@ public class InventoryPackets extends ItemRewriter<ClientboundPackets1_12_1, Ser
} }
enchEntry.putShort("id", oldId); enchEntry.putShort("id", oldId);
NumberTag levelTag = entryTag.getNumberTag("lvl"); NumberTag levelTag = enchantmentEntry.getNumberTag("lvl");
if (levelTag != null) { if (levelTag != null) {
enchEntry.putShort("lvl", levelTag.asShort()); enchEntry.putShort("lvl", levelTag.asShort());
} }
@ -690,8 +660,8 @@ public class InventoryPackets extends ItemRewriter<ClientboundPackets1_12_1, Ser
if (tag.getListTag(NBT_TAG_NAME + "|CanPlaceOn") != null) { if (tag.getListTag(NBT_TAG_NAME + "|CanPlaceOn") != null) {
tag.put("CanPlaceOn", tag.remove(NBT_TAG_NAME + "|CanPlaceOn")); tag.put("CanPlaceOn", tag.remove(NBT_TAG_NAME + "|CanPlaceOn"));
} else if (tag.getListTag("CanPlaceOn") != null) { } else if (tag.getListTag("CanPlaceOn") != null) {
ListTag old = tag.getListTag("CanPlaceOn"); ListTag<?> old = tag.getListTag("CanPlaceOn");
ListTag newCanPlaceOn = new ListTag(StringTag.class); ListTag<StringTag> newCanPlaceOn = new ListTag<>(StringTag.class);
for (Tag oldTag : old) { for (Tag oldTag : old) {
Object value = oldTag.getValue(); Object value = oldTag.getValue();
String[] newValues = BlockIdData.fallbackReverseMapping.get(value instanceof String String[] newValues = BlockIdData.fallbackReverseMapping.get(value instanceof String
@ -702,7 +672,7 @@ public class InventoryPackets extends ItemRewriter<ClientboundPackets1_12_1, Ser
newCanPlaceOn.add(new StringTag(newValue)); newCanPlaceOn.add(new StringTag(newValue));
} }
} else { } else {
newCanPlaceOn.add(oldTag); newCanPlaceOn.add(new StringTag(value.toString()));
} }
} }
tag.put("CanPlaceOn", newCanPlaceOn); tag.put("CanPlaceOn", newCanPlaceOn);
@ -710,8 +680,8 @@ public class InventoryPackets extends ItemRewriter<ClientboundPackets1_12_1, Ser
if (tag.getListTag(NBT_TAG_NAME + "|CanDestroy") != null) { if (tag.getListTag(NBT_TAG_NAME + "|CanDestroy") != null) {
tag.put("CanDestroy", tag.remove(NBT_TAG_NAME + "|CanDestroy")); tag.put("CanDestroy", tag.remove(NBT_TAG_NAME + "|CanDestroy"));
} else if (tag.getListTag("CanDestroy") != null) { } else if (tag.getListTag("CanDestroy") != null) {
ListTag old = tag.getListTag("CanDestroy"); ListTag<?> old = tag.getListTag("CanDestroy");
ListTag newCanDestroy = new ListTag(StringTag.class); ListTag<StringTag> newCanDestroy = new ListTag<>(StringTag.class);
for (Tag oldTag : old) { for (Tag oldTag : old) {
Object value = oldTag.getValue(); Object value = oldTag.getValue();
String[] newValues = BlockIdData.fallbackReverseMapping.get(value instanceof String String[] newValues = BlockIdData.fallbackReverseMapping.get(value instanceof String
@ -722,7 +692,7 @@ public class InventoryPackets extends ItemRewriter<ClientboundPackets1_12_1, Ser
newCanDestroy.add(new StringTag(newValue)); newCanDestroy.add(new StringTag(newValue));
} }
} else { } else {
newCanDestroy.add(oldTag); newCanDestroy.add(new StringTag(oldTag.getValue().toString()));
} }
} }
tag.put("CanDestroy", newCanDestroy); tag.put("CanDestroy", newCanDestroy);

Datei anzeigen

@ -60,17 +60,12 @@ public class BannerHandler implements BlockEntityProvider.BlockEntityHandler {
Via.getPlatform().getLogger().warning("Why does this block have the banner block entity? :(" + tag); Via.getPlatform().getLogger().warning("Why does this block have the banner block entity? :(" + tag);
} }
ListTag patterns = tag.getListTag("Patterns"); ListTag<CompoundTag> patterns = tag.getListTag("Patterns", CompoundTag.class);
if (patterns != null) { if (patterns != null) {
for (Tag pattern : patterns) { for (CompoundTag pattern : patterns) {
if (!(pattern instanceof CompoundTag)) { NumberTag colorTag = pattern.getNumberTag("Color");
continue;
}
CompoundTag patternTag = (CompoundTag) pattern;
NumberTag colorTag = patternTag.getNumberTag("Color");
if (colorTag != null) { if (colorTag != null) {
patternTag.putInt("Color", 15 - colorTag.asInt()); // Invert color id pattern.putInt("Color", 15 - colorTag.asInt()); // Invert color id
} }
} }
} }

Datei anzeigen

@ -244,14 +244,12 @@ public class InventoryPackets extends ItemRewriter<ClientboundPackets1_13, Serve
// Display Lore now uses JSON // Display Lore now uses JSON
CompoundTag display = item.tag().getCompoundTag("display"); CompoundTag display = item.tag().getCompoundTag("display");
if (display != null) { if (display != null) {
ListTag lore = display.getListTag("Lore"); ListTag<StringTag> lore = display.getListTag("Lore", StringTag.class);
if (lore != null) { if (lore != null) {
display.put(NBT_TAG_NAME + "|Lore", new ListTag(lore.copy().getValue())); // Save old lore display.put(NBT_TAG_NAME + "|Lore", new ListTag<>(lore.copy().getValue())); // Save old lore
for (Tag loreEntry : lore) { for (StringTag loreEntry : lore) {
if (loreEntry instanceof StringTag) { String jsonText = ComponentUtil.legacyToJsonString(loreEntry.getValue(), true);
String jsonText = ComponentUtil.legacyToJsonString(((StringTag) loreEntry).getValue(), true); loreEntry.setValue(jsonText);
((StringTag) loreEntry).setValue(jsonText);
}
} }
} }
} }
@ -268,16 +266,14 @@ public class InventoryPackets extends ItemRewriter<ClientboundPackets1_13, Serve
// Display Name now uses JSON // Display Name now uses JSON
CompoundTag display = item.tag().getCompoundTag("display"); CompoundTag display = item.tag().getCompoundTag("display");
if (display != null) { if (display != null) {
ListTag lore = display.getListTag("Lore"); ListTag<StringTag> lore = display.getListTag("Lore", StringTag.class);
if (lore != null) { if (lore != null) {
Tag savedLore = display.remove(NBT_TAG_NAME + "|Lore"); Tag savedLore = display.remove(NBT_TAG_NAME + "|Lore");
if (savedLore instanceof ListTag) { if (savedLore instanceof ListTag) {
display.put("Lore", new ListTag(((ListTag) savedLore).getValue())); display.put("Lore", new ListTag<>(((ListTag<?>) savedLore).getValue()));
} else { } else {
for (Tag loreEntry : lore) { for (StringTag loreEntry : lore) {
if (loreEntry instanceof StringTag) { loreEntry.setValue(ComponentUtil.jsonToLegacy(loreEntry.getValue()));
((StringTag) loreEntry).setValue(ComponentUtil.jsonToLegacy(((StringTag) loreEntry).getValue()));
}
} }
} }
} }

Datei anzeigen

@ -57,15 +57,18 @@ public class PlayerPackets {
CompoundTag tag = item.tag(); CompoundTag tag = item.tag();
if (tag == null) return; if (tag == null) return;
ListTag pages = tag.getListTag("pages"); ListTag<StringTag> pages = tag.getListTag("pages", StringTag.class);
// Fix for https://github.com/ViaVersion/ViaVersion/issues/2660 // Fix for https://github.com/ViaVersion/ViaVersion/issues/2660
if (pages == null) { if (pages == null) {
tag.put("pages", new ListTag(Collections.singletonList(new StringTag()))); pages = new ListTag<>(StringTag.class);
pages.add(new StringTag());
tag.put("pages", pages);
return;
} }
// Client limit when editing a book was upped from 50 to 100 in 1.14, but some anti-exploit plugins ban with a size higher than the old client limit // Client limit when editing a book was upped from 50 to 100 in 1.14, but some anti-exploit plugins ban with a size higher than the old client limit
if (Via.getConfig().isTruncate1_14Books() && pages != null) { if (Via.getConfig().isTruncate1_14Books()) {
if (pages.size() > 50) { if (pages.size() > 50) {
pages.setValue(pages.getValue().subList(0, 50)); pages.setValue(pages.getValue().subList(0, 50));
} }

Datei anzeigen

@ -38,12 +38,11 @@ public class MappingData extends MappingDataBase {
dimensionRegistry = MappingDataLoader.loadNBTFromFile("dimension-registry-1.16.2.nbt"); dimensionRegistry = MappingDataLoader.loadNBTFromFile("dimension-registry-1.16.2.nbt");
// Data of each dimension // Data of each dimension
final ListTag dimensions = dimensionRegistry.getCompoundTag("minecraft:dimension_type").get("value"); final ListTag<CompoundTag> dimensions = dimensionRegistry.getCompoundTag("minecraft:dimension_type").getListTag("value", CompoundTag.class);
for (final Tag dimension : dimensions) { for (final CompoundTag dimension : dimensions) {
final CompoundTag dimensionCompound = (CompoundTag) dimension;
// Copy with an empty name // Copy with an empty name
final CompoundTag dimensionData = dimensionCompound.getCompoundTag("element").copy(); final CompoundTag dimensionData = dimension.getCompoundTag("element").copy();
dimensionDataMap.put(dimensionCompound.getStringTag("name").getValue(), dimensionData); dimensionDataMap.put(dimension.getStringTag("name").getValue(), dimensionData);
} }
} }

Datei anzeigen

@ -79,7 +79,7 @@ public class EntityPackets {
private static final String[] WORLD_NAMES = {"minecraft:overworld", "minecraft:the_nether", "minecraft:the_end"}; private static final String[] WORLD_NAMES = {"minecraft:overworld", "minecraft:the_nether", "minecraft:the_end"};
static { static {
ListTag list = new ListTag(CompoundTag.class); ListTag<CompoundTag> list = new ListTag<>(CompoundTag.class);
list.add(createOverworldEntry()); list.add(createOverworldEntry());
list.add(createOverworldCavesEntry()); list.add(createOverworldCavesEntry());
list.add(createNetherEntry()); list.add(createNetherEntry());

Datei anzeigen

@ -155,15 +155,10 @@ public class InventoryPackets extends ItemRewriter<ClientboundPackets1_15, Serve
} }
} }
} else if (item.identifier() == 759 && tag != null) { } else if (item.identifier() == 759 && tag != null) {
ListTag pages = tag.getListTag("pages"); ListTag<StringTag> pages = tag.getListTag("pages", StringTag.class);
if (pages != null) { if (pages != null) {
for (Tag pageTag : pages) { for (StringTag pageTag : pages) {
if (!(pageTag instanceof StringTag)) { pageTag.setValue(protocol.getComponentRewriter().processText(pageTag.getValue()).toString());
continue;
}
StringTag page = (StringTag) pageTag;
page.setValue(protocol.getComponentRewriter().processText(page.getValue()).toString());
} }
} }
} }
@ -198,13 +193,10 @@ public class InventoryPackets extends ItemRewriter<ClientboundPackets1_15, Serve
public static void oldToNewAttributes(Item item) { public static void oldToNewAttributes(Item item) {
if (item.tag() == null) return; if (item.tag() == null) return;
ListTag attributes = item.tag().getListTag("AttributeModifiers"); ListTag<CompoundTag> attributes = item.tag().getListTag("AttributeModifiers", CompoundTag.class);
if (attributes == null) return; if (attributes == null) return;
for (Tag tag : attributes) { for (CompoundTag attribute : attributes) {
if (!(tag instanceof CompoundTag)) continue;
CompoundTag attribute = (CompoundTag) tag;
rewriteAttributeName(attribute, "AttributeName", false); rewriteAttributeName(attribute, "AttributeName", false);
rewriteAttributeName(attribute, "Name", false); rewriteAttributeName(attribute, "Name", false);
NumberTag leastTag = attribute.getNumberTag("UUIDLeast"); NumberTag leastTag = attribute.getNumberTag("UUIDLeast");
@ -219,13 +211,10 @@ public class InventoryPackets extends ItemRewriter<ClientboundPackets1_15, Serve
public static void newToOldAttributes(Item item) { public static void newToOldAttributes(Item item) {
if (item.tag() == null) return; if (item.tag() == null) return;
ListTag attributes = item.tag().getListTag("AttributeModifiers"); ListTag<CompoundTag> attributes = item.tag().getListTag("AttributeModifiers", CompoundTag.class);
if (attributes == null) return; if (attributes == null) return;
for (Tag tag : attributes) { for (CompoundTag attribute : attributes) {
if (!(tag instanceof CompoundTag)) continue;
CompoundTag attribute = (CompoundTag) tag;
rewriteAttributeName(attribute, "AttributeName", true); rewriteAttributeName(attribute, "AttributeName", true);
rewriteAttributeName(attribute, "Name", true); rewriteAttributeName(attribute, "Name", true);
IntArrayTag uuidTag = attribute.getIntArrayTag("UUID"); IntArrayTag uuidTag = attribute.getIntArrayTag("UUID");

Datei anzeigen

@ -88,14 +88,14 @@ public final class Protocol1_17_1To1_17 extends AbstractProtocol<ClientboundPack
// Save pages to tag // Save pages to tag
int pages = wrapper.read(Type.VAR_INT); int pages = wrapper.read(Type.VAR_INT);
ListTag pagesTag = new ListTag(StringTag.class); ListTag<StringTag> pagesTag = new ListTag<>(StringTag.class);
for (int i = 0; i < pages; i++) { for (int i = 0; i < pages; i++) {
String page = wrapper.read(PAGE_STRING_TYPE); String page = wrapper.read(PAGE_STRING_TYPE);
pagesTag.add(new StringTag(page)); pagesTag.add(new StringTag(page));
} }
// Legacy servers don't like an empty pages list // Legacy servers don't like an empty pages list
if (pagesTag.size() == 0) { if (pagesTag.isEmpty()) {
pagesTag.add(new StringTag("")); pagesTag.add(new StringTag(""));
} }

Datei anzeigen

@ -78,9 +78,9 @@ public final class EntityPackets extends EntityRewriter<ClientboundPackets1_16_2
handler(wrapper -> { handler(wrapper -> {
// Add new dimension fields // Add new dimension fields
CompoundTag dimensionRegistry = wrapper.get(Type.NAMED_COMPOUND_TAG, 0).get("minecraft:dimension_type"); CompoundTag dimensionRegistry = wrapper.get(Type.NAMED_COMPOUND_TAG, 0).get("minecraft:dimension_type");
ListTag dimensions = dimensionRegistry.get("value"); ListTag<CompoundTag> dimensions = dimensionRegistry.getListTag("value", CompoundTag.class);
for (Tag dimension : dimensions) { for (CompoundTag dimension : dimensions) {
CompoundTag dimensionCompound = ((CompoundTag) dimension).get("element"); CompoundTag dimensionCompound = dimension.get("element");
addNewDimensionData(dimensionCompound); addNewDimensionData(dimensionCompound);
} }

Datei anzeigen

@ -70,9 +70,9 @@ public final class Protocol1_18_2To1_18 extends AbstractProtocol<ClientboundPack
handler(wrapper -> { handler(wrapper -> {
final CompoundTag registry = wrapper.get(Type.NAMED_COMPOUND_TAG, 0); final CompoundTag registry = wrapper.get(Type.NAMED_COMPOUND_TAG, 0);
final CompoundTag dimensionsHolder = registry.get("minecraft:dimension_type"); final CompoundTag dimensionsHolder = registry.get("minecraft:dimension_type");
final ListTag dimensions = dimensionsHolder.get("value"); final ListTag<CompoundTag> dimensions = dimensionsHolder.getListTag("value", CompoundTag.class);
for (final Tag dimension : dimensions) { for (final CompoundTag dimension : dimensions) {
addTagPrefix(((CompoundTag) dimension).get("element")); addTagPrefix(dimension.get("element"));
} }
addTagPrefix(wrapper.get(Type.NAMED_COMPOUND_TAG, 1)); addTagPrefix(wrapper.get(Type.NAMED_COMPOUND_TAG, 1));

Datei anzeigen

@ -222,11 +222,10 @@ public final class Protocol1_19_1To1_19 extends AbstractProtocol<ClientboundPack
chatTypeStorage.clear(); chatTypeStorage.clear();
final CompoundTag registry = wrapper.passthrough(Type.NAMED_COMPOUND_TAG); final CompoundTag registry = wrapper.passthrough(Type.NAMED_COMPOUND_TAG);
final ListTag chatTypes = registry.getCompoundTag("minecraft:chat_type").get("value"); final ListTag<CompoundTag> chatTypes = registry.getCompoundTag("minecraft:chat_type").getListTag("value", CompoundTag.class);
for (final Tag chatType : chatTypes) { for (final CompoundTag chatType : chatTypes) {
final CompoundTag chatTypeCompound = (CompoundTag) chatType; final NumberTag idTag = chatType.get("id");
final NumberTag idTag = chatTypeCompound.get("id"); chatTypeStorage.addChatType(idTag.asInt(), chatType);
chatTypeStorage.addChatType(idTag.asInt(), chatTypeCompound);
} }
// Replace chat types - they won't actually be used // Replace chat types - they won't actually be used
@ -405,12 +404,12 @@ public final class Protocol1_19_1To1_19 extends AbstractProtocol<ClientboundPack
} }
// Add the replacements // Add the replacements
final ListTag parameters = tag.getListTag("parameters"); final ListTag<StringTag> parameters = tag.getListTag("parameters", StringTag.class);
final List<ATextComponent> arguments = new ArrayList<>(); final List<ATextComponent> arguments = new ArrayList<>();
if (parameters != null) { if (parameters != null) {
for (final Tag element : parameters) { for (final StringTag element : parameters) {
JsonElement argument = null; JsonElement argument = null;
switch ((String) element.getValue()) { switch (element.getValue()) {
case "sender": case "sender":
argument = senderName; argument = senderName;
break; break;

Datei anzeigen

@ -64,9 +64,9 @@ public final class EntityPackets extends EntityRewriter<ClientboundPackets1_19_3
registry.put("minecraft:damage_type", damageTypeRegistry); registry.put("minecraft:damage_type", damageTypeRegistry);
final CompoundTag biomeRegistry = registry.get("minecraft:worldgen/biome"); final CompoundTag biomeRegistry = registry.get("minecraft:worldgen/biome");
final ListTag biomes = biomeRegistry.get("value"); final ListTag<CompoundTag> biomes = biomeRegistry.getListTag("value", CompoundTag.class);
for (final Tag biomeTag : biomes) { for (final CompoundTag biomeTag : biomes) {
final CompoundTag biomeData = ((CompoundTag) biomeTag).get("element"); final CompoundTag biomeData = biomeTag.get("element");
final StringTag precipitation = biomeData.get("precipitation"); final StringTag precipitation = biomeData.get("precipitation");
final byte precipitationByte = precipitation.getValue().equals("none") ? (byte) 0 : 1; final byte precipitationByte = precipitation.getValue().equals("none") ? (byte) 0 : 1;
biomeData.put("has_precipitation", new ByteTag(precipitationByte)); biomeData.put("has_precipitation", new ByteTag(precipitationByte));

Datei anzeigen

@ -37,11 +37,10 @@ public final class MappingData extends MappingDataBase {
@Override @Override
protected void loadExtras(final CompoundTag daata) { protected void loadExtras(final CompoundTag daata) {
final ListTag chatTypes = MappingDataLoader.loadNBTFromFile("chat-types-1.19.nbt").get("values"); final ListTag<CompoundTag> chatTypes = MappingDataLoader.loadNBTFromFile("chat-types-1.19.nbt").getListTag("values", CompoundTag.class);
for (final Tag chatType : chatTypes) { for (final CompoundTag chatType : chatTypes) {
final CompoundTag chatTypeCompound = (CompoundTag) chatType; final NumberTag idTag = chatType.get("id");
final NumberTag idTag = chatTypeCompound.get("id"); defaultChatTypes.put(idTag.asInt(), chatType);
defaultChatTypes.put(idTag.asInt(), chatTypeCompound);
} }
} }

Datei anzeigen

@ -209,13 +209,12 @@ public final class EntityPackets extends EntityRewriter<ClientboundPackets1_18,
tag.put("minecraft:chat_type", CHAT_REGISTRY.copy()); tag.put("minecraft:chat_type", CHAT_REGISTRY.copy());
// Cache a whole lot of data // Cache a whole lot of data
final ListTag dimensions = tag.getCompoundTag("minecraft:dimension_type").get("value"); final ListTag<CompoundTag> dimensions = tag.getCompoundTag("minecraft:dimension_type").getListTag("value", CompoundTag.class);
final Map<String, DimensionData> dimensionDataMap = new HashMap<>(dimensions.size()); final Map<String, DimensionData> dimensionDataMap = new HashMap<>(dimensions.size());
final Map<CompoundTag, String> dimensionsMap = new HashMap<>(dimensions.size()); final Map<CompoundTag, String> dimensionsMap = new HashMap<>(dimensions.size());
for (final Tag dimension : dimensions) { for (final CompoundTag dimension : dimensions) {
final CompoundTag dimensionCompound = (CompoundTag) dimension; final CompoundTag element = dimension.get("element");
final CompoundTag element = dimensionCompound.get("element"); final String name = dimension.getStringTag("name").getValue();
final String name = (String) dimensionCompound.get("name").getValue();
addMonsterSpawnData(element); addMonsterSpawnData(element);
dimensionDataMap.put(name, new DimensionDataImpl(element)); dimensionDataMap.put(name, new DimensionDataImpl(element));
dimensionsMap.put(element.copy(), name); dimensionsMap.put(element.copy(), name);

Datei anzeigen

@ -372,7 +372,7 @@ public final class BlockItemPacketRewriter1_20_2 extends ItemRewriter<Clientboun
public static void to1_20_2Effects(final Item item) { public static void to1_20_2Effects(final Item item) {
final Tag customPotionEffectsTag = item.tag().remove("CustomPotionEffects"); final Tag customPotionEffectsTag = item.tag().remove("CustomPotionEffects");
if (customPotionEffectsTag instanceof ListTag) { if (customPotionEffectsTag instanceof ListTag) {
final ListTag effectsTag = (ListTag) customPotionEffectsTag; final ListTag<?> effectsTag = (ListTag<?>) customPotionEffectsTag;
item.tag().put("custom_potion_effects", customPotionEffectsTag); item.tag().put("custom_potion_effects", customPotionEffectsTag);
for (final Tag tag : effectsTag) { for (final Tag tag : effectsTag) {
@ -403,7 +403,7 @@ public final class BlockItemPacketRewriter1_20_2 extends ItemRewriter<Clientboun
public static void to1_20_1Effects(final Item item) { public static void to1_20_1Effects(final Item item) {
final Tag customPotionEffectsTag = item.tag().remove("custom_potion_effects"); final Tag customPotionEffectsTag = item.tag().remove("custom_potion_effects");
if (customPotionEffectsTag instanceof ListTag) { if (customPotionEffectsTag instanceof ListTag) {
final ListTag effectsTag = (ListTag) customPotionEffectsTag; final ListTag<?> effectsTag = (ListTag<?>) customPotionEffectsTag;
item.tag().put("CustomPotionEffects", effectsTag); item.tag().put("CustomPotionEffects", effectsTag);
for (final Tag tag : effectsTag) { for (final Tag tag : effectsTag) {

Datei anzeigen

@ -150,20 +150,15 @@ public final class BlockItemPacketRewriter1_20_3 extends ItemRewriter<Clientboun
} }
private void updatePages(final CompoundTag tag, final String key) { private void updatePages(final CompoundTag tag, final String key) {
final ListTag pages = tag.getListTag(key); final ListTag<StringTag> pages = tag.getListTag(key, StringTag.class);
if (pages == null) { if (pages == null) {
return; return;
} }
for (final Tag pageTag : pages) { for (final StringTag pageTag : pages) {
if (!(pageTag instanceof StringTag)) {
continue;
}
final StringTag stringTag = (StringTag) pageTag;
try { try {
final JsonElement updatedComponent = ComponentUtil.convertJson(stringTag.getValue(), ComponentUtil.SerializerVersion.V1_19_4, ComponentUtil.SerializerVersion.V1_20_3); final JsonElement updatedComponent = ComponentUtil.convertJson(pageTag.getValue(), ComponentUtil.SerializerVersion.V1_19_4, ComponentUtil.SerializerVersion.V1_20_3);
stringTag.setValue(updatedComponent.toString()); pageTag.setValue(updatedComponent.toString());
} catch (final Exception e) { } catch (final Exception e) {
Via.getManager().debugHandler().error("Error during book conversion", e); Via.getManager().debugHandler().error("Error during book conversion", e);
} }

Datei anzeigen

@ -77,10 +77,10 @@ public final class EntityPackets extends EntityRewriter<ClientboundPackets1_19_4
handler(wrapper -> { handler(wrapper -> {
final CompoundTag registry = wrapper.get(Type.NAMED_COMPOUND_TAG, 0); final CompoundTag registry = wrapper.get(Type.NAMED_COMPOUND_TAG, 0);
final CompoundTag damageTypeRegistry = registry.get("minecraft:damage_type"); final CompoundTag damageTypeRegistry = registry.get("minecraft:damage_type");
final ListTag damageTypes = damageTypeRegistry.get("value"); final ListTag<CompoundTag> damageTypes = damageTypeRegistry.get("value");
int highestId = -1; int highestId = -1;
for (final Tag damageType : damageTypes) { for (final CompoundTag damageType : damageTypes) {
final IntTag id = ((CompoundTag) damageType).get("id"); final IntTag id = damageType.get("id");
highestId = Math.max(highestId, id.asInt()); highestId = Math.max(highestId, id.asInt());
} }

Datei anzeigen

@ -170,16 +170,16 @@ public final class InventoryPackets extends ItemRewriter<ClientboundPackets1_19_
final CompoundTag frontText = new CompoundTag(); final CompoundTag frontText = new CompoundTag();
tag.put("front_text", frontText); tag.put("front_text", frontText);
final ListTag messages = new ListTag(StringTag.class); final ListTag<StringTag> messages = new ListTag<>(StringTag.class);
for (int i = 1; i < 5; i++) { for (int i = 1; i < 5; i++) {
final Tag text = tag.remove("Text" + i); final StringTag text = tag.remove("Text" + i);
messages.add(text != null ? text : new StringTag(ComponentUtil.emptyJsonComponentString())); messages.add(text != null ? text : new StringTag(ComponentUtil.emptyJsonComponentString()));
} }
frontText.put("messages", messages); frontText.put("messages", messages);
final ListTag filteredMessages = new ListTag(StringTag.class); final ListTag<StringTag> filteredMessages = new ListTag<>(StringTag.class);
for (int i = 1; i < 5; i++) { for (int i = 1; i < 5; i++) {
final Tag text = tag.remove("FilteredText" + i); final StringTag text = tag.remove("FilteredText" + i);
filteredMessages.add(text != null ? text : messages.get(i - 1)); filteredMessages.add(text != null ? text : messages.get(i - 1));
} }
if (!filteredMessages.equals(messages)) { if (!filteredMessages.equals(messages)) {

Datei anzeigen

@ -221,24 +221,20 @@ public class ItemRewriter {
} }
CompoundTag tag = item.tag(); CompoundTag tag = item.tag();
ListTag pages = tag.getListTag("pages"); ListTag<StringTag> pages = tag.getListTag("pages", StringTag.class);
if (pages == null) { if (pages == null) {
return; return;
} }
for (int i = 0; i < pages.size(); i++) { for (int i = 0; i < pages.size(); i++) {
Tag pageTag = pages.get(i); StringTag pageTag = pages.get(i);
if (!(pageTag instanceof StringTag)) { String value = pageTag.getValue();
continue;
}
StringTag stag = (StringTag) pageTag;
String value = stag.getValue();
if (value.replaceAll(" ", "").isEmpty()) { if (value.replaceAll(" ", "").isEmpty()) {
value = "\"" + fixBookSpaceChars(value) + "\""; value = "\"" + fixBookSpaceChars(value) + "\"";
} else { } else {
value = fixBookSpaceChars(value); value = fixBookSpaceChars(value);
} }
stag.setValue(value); pageTag.setValue(value);
} }
} }
@ -289,17 +285,15 @@ public class ItemRewriter {
tag = new CompoundTag(); tag = new CompoundTag();
} }
ListTag pages = tag.getListTag("pages"); ListTag<StringTag> pages = tag.getListTag("pages", StringTag.class);
if (pages == null) { if (pages == null) {
pages = new ListTag(Collections.singletonList(new StringTag(Protocol1_9To1_8.fixJson("").toString()))); pages = new ListTag<>(Collections.singletonList(new StringTag(Protocol1_9To1_8.fixJson("").toString())));
tag.put("pages", pages); tag.put("pages", pages);
item.setTag(tag); item.setTag(tag);
return; return;
} }
for (int i = 0; i < pages.size(); i++) { for (int i = 0; i < pages.size(); i++) {
if (!(pages.get(i) instanceof StringTag))
continue;
StringTag page = pages.get(i); StringTag page = pages.get(i);
page.setValue(Protocol1_9To1_8.fixJson(page.getValue()).toString()); page.setValue(Protocol1_9To1_8.fixJson(page.getValue()).toString());
} }

Datei anzeigen

@ -254,13 +254,13 @@ public class ComponentRewriter<C extends ClientboundPacketType> {
} }
if (tag instanceof ListTag) { if (tag instanceof ListTag) {
processListTag((ListTag) tag); processListTag((ListTag<?>) tag);
} else if (tag instanceof CompoundTag) { } else if (tag instanceof CompoundTag) {
processCompoundTag((CompoundTag) tag); processCompoundTag((CompoundTag) tag);
} }
} }
private void processListTag(final ListTag tag) { private void processListTag(final ListTag<?> tag) {
for (final Tag entry : tag) { for (final Tag entry : tag) {
processTag(entry); processTag(entry);
} }
@ -271,13 +271,13 @@ public class ComponentRewriter<C extends ClientboundPacketType> {
if (translate != null) { if (translate != null) {
handleTranslate(tag, translate); handleTranslate(tag, translate);
final ListTag with = tag.getListTag("with"); final ListTag<?> with = tag.getListTag("with");
if (with != null) { if (with != null) {
processListTag(with); processListTag(with);
} }
} }
final ListTag extra = tag.getListTag("extra"); final ListTag<?> extra = tag.getListTag("extra");
if (extra != null) { if (extra != null) {
processListTag(extra); processListTag(extra);
} }

Datei anzeigen

@ -449,7 +449,7 @@ public abstract class EntityRewriter<C extends ClientboundPacketType, T extends
public void trackBiomeSize(final UserConnection connection, final CompoundTag registry) { public void trackBiomeSize(final UserConnection connection, final CompoundTag registry) {
final CompoundTag biomeRegistry = registry.get("minecraft:worldgen/biome"); final CompoundTag biomeRegistry = registry.get("minecraft:worldgen/biome");
final ListTag biomes = biomeRegistry.get("value"); final ListTag<?> biomes = biomeRegistry.get("value");
tracker(connection).setBiomesSent(biomes.size()); tracker(connection).setBiomesSent(biomes.size());
} }
@ -465,12 +465,11 @@ public abstract class EntityRewriter<C extends ClientboundPacketType, T extends
* Caches dimension data, later used to get height values and other important info. * Caches dimension data, later used to get height values and other important info.
*/ */
public void cacheDimensionData(final UserConnection connection, final CompoundTag registry) { public void cacheDimensionData(final UserConnection connection, final CompoundTag registry) {
final ListTag dimensions = registry.getCompoundTag("minecraft:dimension_type").get("value"); final ListTag<CompoundTag> dimensions = registry.getCompoundTag("minecraft:dimension_type").getListTag("value", CompoundTag.class);
final Map<String, DimensionData> dimensionDataMap = new HashMap<>(dimensions.size()); final Map<String, DimensionData> dimensionDataMap = new HashMap<>(dimensions.size());
for (final Tag dimension : dimensions) { for (final CompoundTag dimension : dimensions) {
final CompoundTag dimensionCompound = (CompoundTag) dimension; final CompoundTag element = dimension.get("element");
final CompoundTag element = dimensionCompound.get("element"); final String name = dimension.getStringTag("name").getValue();
final String name = dimensionCompound.getStringTag("name").getValue();
dimensionDataMap.put(name, new DimensionDataImpl(element)); dimensionDataMap.put(name, new DimensionDataImpl(element));
} }
tracker(connection).setDimensions(dimensionDataMap); tracker(connection).setDimensions(dimensionDataMap);

Datei anzeigen

@ -78,7 +78,7 @@ public final class ComponentUtil {
private static Tag trimStrings(final Tag input) { private static Tag trimStrings(final Tag input) {
// Dirty fix for https://github.com/ViaVersion/ViaVersion/issues/3650 // Dirty fix for https://github.com/ViaVersion/ViaVersion/issues/3650
// Usually tripped by hover event data being too long, e.g. book or shulker box contents // Usually tripped by hover event data being too long, e.g. book or shulker box contents, which have to be held in full as SNBT
if (input == null) { if (input == null) {
return null; return null;
} }

Datei anzeigen

@ -37,12 +37,15 @@ public final class TagUtil {
entry.setValue(updatedTag); entry.setValue(updatedTag);
} }
} else if (tag instanceof ListTag) { } else if (tag instanceof ListTag) {
final ListTag listTag = (ListTag) tag; handleListTag((ListTag<?>) tag, consumer);
listTag.getValue().replaceAll(t -> handleDeep(null, t, consumer));
} }
return consumer.update(key, tag); return consumer.update(key, tag);
} }
private static <T extends Tag> void handleListTag(final ListTag<T> listTag, final TagUpdater consumer) {
listTag.getValue().replaceAll(t -> (T) handleDeep(null, t, consumer));
}
@FunctionalInterface @FunctionalInterface
public interface TagUpdater { public interface TagUpdater {

Datei anzeigen

@ -5,8 +5,8 @@ metadata.format.version = "1.1"
gson = "2.10.1" gson = "2.10.1"
fastutil = "8.5.12" fastutil = "8.5.12"
flare = "2.0.1" flare = "2.0.1"
vianbt = "4.2.0" vianbt = "4.4.0"
mcstructs = "2.4.2-SNAPSHOT" mcstructs = "2.4.2"
# Common provided # Common provided
netty = "4.0.20.Final" netty = "4.0.20.Final"