3
0
Mirror von https://github.com/ViaVersion/ViaBackwards.git synchronisiert 2024-12-26 16:12:43 +01:00

Fall back to keys without namespace in registry data

Dieser Commit ist enthalten in:
Nassim Jahnke 2024-04-20 12:12:35 +02:00
Ursprung 471d4acf20
Commit 11286b2162
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: EF6771C01F6EF02F
10 geänderte Dateien mit 21 neuen und 26 gelöschten Zeilen

Datei anzeigen

@ -33,9 +33,9 @@ import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.NumberTag;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.ClientboundPackets1_16_2;
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.packets.EntityPackets;
import com.viaversion.viaversion.util.TagUtil;
import java.util.Set;
public class EntityPackets1_16_2 extends EntityRewriter<ClientboundPackets1_16_2, Protocol1_16_1To1_16_2> {
@ -75,8 +75,7 @@ public class EntityPackets1_16_2 extends EntityRewriter<ClientboundPackets1_16_2
CompoundTag registry = wrapper.read(Type.NAMED_COMPOUND_TAG);
if (wrapper.user().getProtocolInfo().protocolVersion().olderThanOrEqualTo(ProtocolVersion.v1_15_2)) {
// Store biomes for <1.16 client handling
CompoundTag biomeRegistry = registry.getCompoundTag("minecraft:worldgen/biome");
ListTag<CompoundTag> biomes = biomeRegistry.getListTag("value", CompoundTag.class);
ListTag<CompoundTag> biomes = TagUtil.getRegistryEntries(registry, "worldgen/biome");
BiomeStorage biomeStorage = wrapper.user().get(BiomeStorage.class);
biomeStorage.clear();
for (CompoundTag biome : biomes) {

Datei anzeigen

@ -32,6 +32,7 @@ import com.viaversion.viaversion.api.type.types.version.Types1_17;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.*;
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.ClientboundPackets1_16_2;
import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.ClientboundPackets1_17;
import com.viaversion.viaversion.util.TagUtil;
public final class EntityPackets1_17 extends EntityRewriter<ClientboundPackets1_17, Protocol1_16_4To1_17> {
@ -80,8 +81,7 @@ public final class EntityPackets1_17 extends EntityRewriter<ClientboundPackets1_
handler(worldDataTrackerHandler(1));
handler(wrapper -> {
CompoundTag registry = wrapper.get(Type.NAMED_COMPOUND_TAG, 0);
CompoundTag biomeRegistry = registry.getCompoundTag("minecraft:worldgen/biome");
ListTag<CompoundTag> biomes = biomeRegistry.getListTag("value", CompoundTag.class);
ListTag<CompoundTag> biomes = TagUtil.getRegistryEntries(registry, "worldgen/biome");
for (CompoundTag biome : biomes) {
CompoundTag biomeCompound = biome.getCompoundTag("element");
StringTag category = biomeCompound.getStringTag("category");
@ -90,8 +90,7 @@ public final class EntityPackets1_17 extends EntityRewriter<ClientboundPackets1_
}
}
CompoundTag dimensionRegistry = registry.getCompoundTag("minecraft:dimension_type");
ListTag<CompoundTag> dimensions = dimensionRegistry.getListTag("value", CompoundTag.class);
ListTag<CompoundTag> dimensions = TagUtil.getRegistryEntries(registry, "dimension_type");
for (CompoundTag dimension : dimensions) {
CompoundTag dimensionCompound = dimension.getCompoundTag("element");
reduceExtendedHeight(dimensionCompound, false);

Datei anzeigen

@ -32,6 +32,7 @@ import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.ClientboundPackets1_18;
import com.viaversion.viaversion.util.TagUtil;
public final class EntityPackets1_18 extends EntityRewriter<ClientboundPackets1_18, Protocol1_17_1To1_18> {
@ -61,8 +62,7 @@ public final class EntityPackets1_18 extends EntityRewriter<ClientboundPackets1_
handler(worldDataTrackerHandler(1));
handler(wrapper -> {
final CompoundTag registry = wrapper.get(Type.NAMED_COMPOUND_TAG, 0);
final CompoundTag biomeRegistry = registry.getCompoundTag("minecraft:worldgen/biome");
final ListTag<CompoundTag> biomes = biomeRegistry.getListTag("value", CompoundTag.class);
final ListTag<CompoundTag> biomes = TagUtil.getRegistryEntries(registry, "worldgen/biome");
for (final CompoundTag biome : biomes) {
final CompoundTag biomeCompound = biome.getCompoundTag("element");
final StringTag category = biomeCompound.getStringTag("category");

Datei anzeigen

@ -290,9 +290,7 @@ public final class Protocol1_18_2To1_19 extends BackwardsProtocol<ClientboundPac
for (int i = 0; i < properties; i++) {
wrapper.read(Type.STRING); // Name
wrapper.read(Type.STRING); // Value
if (wrapper.read(Type.BOOLEAN)) {
wrapper.read(Type.STRING); // Signature
}
wrapper.read(Type.OPTIONAL_STRING); // Optional signature
}
});
}

Datei anzeigen

@ -40,6 +40,7 @@ import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.ClientboundPackets1_18;
import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.ClientboundPackets1_19;
import com.viaversion.viaversion.util.TagUtil;
public final class EntityPackets1_19 extends EntityRewriter<ClientboundPackets1_19, Protocol1_18_2To1_19> {
@ -131,7 +132,7 @@ public final class EntityPackets1_19 extends EntityRewriter<ClientboundPackets1_
// Cache dimensions and find current dimension
final String dimensionKey = wrapper.read(Type.STRING);
final CompoundTag registry = wrapper.get(Type.NAMED_COMPOUND_TAG, 0);
final ListTag<CompoundTag> dimensions = registry.getCompoundTag("minecraft:dimension_type").getListTag("value", CompoundTag.class);
final ListTag<CompoundTag> dimensions = TagUtil.getRegistryEntries(registry, "dimension_type");
boolean found = false;
for (final CompoundTag dimension : dimensions) {
final StringTag nameTag = dimension.getStringTag("name");
@ -148,8 +149,7 @@ public final class EntityPackets1_19 extends EntityRewriter<ClientboundPackets1_
}
// Add biome category and track biomes
final CompoundTag biomeRegistry = registry.getCompoundTag("minecraft:worldgen/biome");
final ListTag<CompoundTag> biomes = biomeRegistry.getListTag("value", CompoundTag.class);
final ListTag<CompoundTag> biomes = TagUtil.getRegistryEntries(registry, "worldgen/biome");
for (final CompoundTag biome : biomes) {
final CompoundTag biomeCompound = biome.getCompoundTag("element");
biomeCompound.putString("category", "none");

Datei anzeigen

@ -27,9 +27,9 @@ import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.ServerboundPackets1_17;
import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.ClientboundPackets1_18;
import com.viaversion.viaversion.util.TagUtil;
public final class Protocol1_18To1_18_2 extends BackwardsProtocol<ClientboundPackets1_18, ClientboundPackets1_18, ServerboundPackets1_17, ServerboundPackets1_17> {
@ -81,8 +81,7 @@ public final class Protocol1_18To1_18_2 extends BackwardsProtocol<ClientboundPac
map(Type.NAMED_COMPOUND_TAG); // Current dimension data
handler(wrapper -> {
final CompoundTag registry = wrapper.get(Type.NAMED_COMPOUND_TAG, 0);
final CompoundTag dimensionsHolder = registry.getCompoundTag("minecraft:dimension_type");
final ListTag<CompoundTag> dimensions = dimensionsHolder.getListTag("value", CompoundTag.class);
final ListTag<CompoundTag> dimensions = TagUtil.getRegistryEntries(registry, "dimension_type");
for (final CompoundTag dimension : dimensions) {
removeTagPrefix(dimension.getCompoundTag("element"));
}

Datei anzeigen

@ -35,10 +35,10 @@ import com.viaversion.viaversion.libs.gson.JsonElement;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.NumberTag;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
import com.viaversion.viaversion.protocols.protocol1_19_1to1_19.ClientboundPackets1_19_1;
import com.viaversion.viaversion.protocols.protocol1_19_3to1_19_1.ClientboundPackets1_19_3;
import com.viaversion.viaversion.protocols.protocol1_19_3to1_19_1.ServerboundPackets1_19_3;
import com.viaversion.viaversion.util.TagUtil;
import java.util.BitSet;
import java.util.UUID;
import org.checkerframework.checker.nullness.qual.Nullable;
@ -82,7 +82,7 @@ public final class EntityPackets1_19_3 extends EntityRewriter<ClientboundPackets
final ChatTypeStorage1_19_3 chatTypeStorage = wrapper.user().get(ChatTypeStorage1_19_3.class);
chatTypeStorage.clear();
final CompoundTag registry = wrapper.get(Type.NAMED_COMPOUND_TAG, 0);
final ListTag<CompoundTag> chatTypes = registry.getCompoundTag("minecraft:chat_type").getListTag("value", CompoundTag.class);
final ListTag<CompoundTag> chatTypes = TagUtil.getRegistryEntries(registry, "chat_type");
for (final CompoundTag chatType : chatTypes) {
final NumberTag idTag = chatType.getNumberTag("id");
chatTypeStorage.addChatType(idTag.asInt(), chatType);

Datei anzeigen

@ -31,9 +31,9 @@ import com.viaversion.viaversion.libs.gson.JsonElement;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.NumberTag;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
import com.viaversion.viaversion.protocols.protocol1_19_3to1_19_1.ClientboundPackets1_19_3;
import com.viaversion.viaversion.protocols.protocol1_19_4to1_19_3.ClientboundPackets1_19_4;
import com.viaversion.viaversion.util.TagUtil;
public final class EntityPackets1_19_4 extends EntityRewriter<ClientboundPackets1_19_4, Protocol1_19_3To1_19_4> {
@ -67,8 +67,7 @@ public final class EntityPackets1_19_4 extends EntityRewriter<ClientboundPackets
registry.remove("minecraft:trim_material");
registry.remove("minecraft:damage_type");
final CompoundTag biomeRegistry = registry.getCompoundTag("minecraft:worldgen/biome");
final ListTag<CompoundTag> biomes = biomeRegistry.getListTag("value", CompoundTag.class);
final ListTag<CompoundTag> biomes = TagUtil.getRegistryEntries(registry, "worldgen/biome");
for (final CompoundTag biomeTag : biomes) {
final CompoundTag biomeData = biomeTag.getCompoundTag("element");
final NumberTag hasPrecipitation = biomeData.getNumberTag("has_precipitation");

Datei anzeigen

@ -83,8 +83,8 @@ public final class EntityPackets1_20 extends EntityRewriter<ClientboundPackets1_
final ListTag<CompoundTag> values;
// A 1.20 server can't send this element, and the 1.20 client still works, if the element is missing
// on a 1.19.4 client there is an exception, so in case the 1.20 server doesn't send the element we put in an original 1.20 element
final CompoundTag trimPatternTag = registry.getCompoundTag("minecraft:trim_pattern");
if (trimPatternTag != null) {
CompoundTag trimPatternTag = registry.getCompoundTag("minecraft:trim_pattern");
if (trimPatternTag != null || (trimPatternTag = registry.getCompoundTag("trim_pattern")) != null) {
values = trimPatternTag.getListTag("value", CompoundTag.class);
} else {
final CompoundTag trimPatternRegistry = Protocol1_19_4To1_20.MAPPINGS.getTrimPatternRegistry().copy();

Datei anzeigen

@ -55,6 +55,7 @@ import com.viaversion.viaversion.rewriter.ComponentRewriter;
import com.viaversion.viaversion.util.CipherUtil;
import com.viaversion.viaversion.util.ComponentUtil;
import com.viaversion.viaversion.util.Pair;
import com.viaversion.viaversion.util.TagUtil;
import java.util.List;
import java.util.UUID;
import org.checkerframework.checker.nullness.qual.Nullable;
@ -102,7 +103,7 @@ public final class Protocol1_19To1_19_1 extends BackwardsProtocol<ClientboundPac
chatTypeStorage.clear();
final CompoundTag registry = wrapper.get(Type.NAMED_COMPOUND_TAG, 0);
final ListTag<CompoundTag> chatTypes = registry.getCompoundTag("minecraft:chat_type").getListTag("value", CompoundTag.class);
final ListTag<CompoundTag> chatTypes = TagUtil.getRegistryEntries(registry, "chat_type");
for (final CompoundTag chatType : chatTypes) {
final NumberTag idTag = chatType.getNumberTag("id");
chatTypeStorage.addChatType(idTag.asInt(), chatType);