3
0
Mirror von https://github.com/ViaVersion/ViaBackwards.git synchronisiert 2024-12-27 08:30:10 +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.ListTag;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.NumberTag; 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.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_16_2to1_16_1.ClientboundPackets1_16_2;
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.packets.EntityPackets; import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.packets.EntityPackets;
import com.viaversion.viaversion.util.TagUtil;
import java.util.Set; import java.util.Set;
public class EntityPackets1_16_2 extends EntityRewriter<ClientboundPackets1_16_2, Protocol1_16_1To1_16_2> { 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); CompoundTag registry = wrapper.read(Type.NAMED_COMPOUND_TAG);
if (wrapper.user().getProtocolInfo().protocolVersion().olderThanOrEqualTo(ProtocolVersion.v1_15_2)) { if (wrapper.user().getProtocolInfo().protocolVersion().olderThanOrEqualTo(ProtocolVersion.v1_15_2)) {
// Store biomes for <1.16 client handling // Store biomes for <1.16 client handling
CompoundTag biomeRegistry = registry.getCompoundTag("minecraft:worldgen/biome"); ListTag<CompoundTag> biomes = TagUtil.getRegistryEntries(registry, "worldgen/biome");
ListTag<CompoundTag> biomes = biomeRegistry.getListTag("value", CompoundTag.class);
BiomeStorage biomeStorage = wrapper.user().get(BiomeStorage.class); BiomeStorage biomeStorage = wrapper.user().get(BiomeStorage.class);
biomeStorage.clear(); biomeStorage.clear();
for (CompoundTag biome : biomes) { 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.libs.opennbt.tag.builtin.*;
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.ClientboundPackets1_16_2; 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.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> { 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(worldDataTrackerHandler(1));
handler(wrapper -> { handler(wrapper -> {
CompoundTag registry = wrapper.get(Type.NAMED_COMPOUND_TAG, 0); CompoundTag registry = wrapper.get(Type.NAMED_COMPOUND_TAG, 0);
CompoundTag biomeRegistry = registry.getCompoundTag("minecraft:worldgen/biome"); ListTag<CompoundTag> biomes = TagUtil.getRegistryEntries(registry, "worldgen/biome");
ListTag<CompoundTag> biomes = biomeRegistry.getListTag("value", CompoundTag.class);
for (CompoundTag biome : biomes) { for (CompoundTag biome : biomes) {
CompoundTag biomeCompound = biome.getCompoundTag("element"); CompoundTag biomeCompound = biome.getCompoundTag("element");
StringTag category = biomeCompound.getStringTag("category"); 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 = TagUtil.getRegistryEntries(registry, "dimension_type");
ListTag<CompoundTag> dimensions = dimensionRegistry.getListTag("value", CompoundTag.class);
for (CompoundTag dimension : dimensions) { for (CompoundTag dimension : dimensions) {
CompoundTag dimensionCompound = dimension.getCompoundTag("element"); CompoundTag dimensionCompound = dimension.getCompoundTag("element");
reduceExtendedHeight(dimensionCompound, false); 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.StringTag;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag; 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_18to1_17_1.ClientboundPackets1_18;
import com.viaversion.viaversion.util.TagUtil;
public final class EntityPackets1_18 extends EntityRewriter<ClientboundPackets1_18, Protocol1_17_1To1_18> { 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(worldDataTrackerHandler(1));
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 biomeRegistry = registry.getCompoundTag("minecraft:worldgen/biome"); final ListTag<CompoundTag> biomes = TagUtil.getRegistryEntries(registry, "worldgen/biome");
final ListTag<CompoundTag> biomes = biomeRegistry.getListTag("value", CompoundTag.class);
for (final CompoundTag biome : biomes) { for (final CompoundTag biome : biomes) {
final CompoundTag biomeCompound = biome.getCompoundTag("element"); final CompoundTag biomeCompound = biome.getCompoundTag("element");
final StringTag category = biomeCompound.getStringTag("category"); 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++) { for (int i = 0; i < properties; i++) {
wrapper.read(Type.STRING); // Name wrapper.read(Type.STRING); // Name
wrapper.read(Type.STRING); // Value wrapper.read(Type.STRING); // Value
if (wrapper.read(Type.BOOLEAN)) { wrapper.read(Type.OPTIONAL_STRING); // Optional signature
wrapper.read(Type.STRING); // 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.libs.opennbt.tag.builtin.Tag;
import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.ClientboundPackets1_18; 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.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> { 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 // Cache dimensions and find current dimension
final String dimensionKey = wrapper.read(Type.STRING); final String dimensionKey = wrapper.read(Type.STRING);
final CompoundTag registry = wrapper.get(Type.NAMED_COMPOUND_TAG, 0); 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; boolean found = false;
for (final CompoundTag dimension : dimensions) { for (final CompoundTag dimension : dimensions) {
final StringTag nameTag = dimension.getStringTag("name"); final StringTag nameTag = dimension.getStringTag("name");
@ -148,8 +149,7 @@ public final class EntityPackets1_19 extends EntityRewriter<ClientboundPackets1_
} }
// Add biome category and track biomes // Add biome category and track biomes
final CompoundTag biomeRegistry = registry.getCompoundTag("minecraft:worldgen/biome"); final ListTag<CompoundTag> biomes = TagUtil.getRegistryEntries(registry, "worldgen/biome");
final ListTag<CompoundTag> biomes = biomeRegistry.getListTag("value", CompoundTag.class);
for (final CompoundTag biome : biomes) { for (final CompoundTag biome : biomes) {
final CompoundTag biomeCompound = biome.getCompoundTag("element"); final CompoundTag biomeCompound = biome.getCompoundTag("element");
biomeCompound.putString("category", "none"); 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.CompoundTag;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag; 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.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_17to1_16_4.ServerboundPackets1_17;
import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.ClientboundPackets1_18; 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> { 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 map(Type.NAMED_COMPOUND_TAG); // Current dimension data
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.getCompoundTag("minecraft:dimension_type"); final ListTag<CompoundTag> dimensions = TagUtil.getRegistryEntries(registry, "dimension_type");
final ListTag<CompoundTag> dimensions = dimensionsHolder.getListTag("value", CompoundTag.class);
for (final CompoundTag dimension : dimensions) { for (final CompoundTag dimension : dimensions) {
removeTagPrefix(dimension.getCompoundTag("element")); 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.CompoundTag;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag; 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.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_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.ClientboundPackets1_19_3;
import com.viaversion.viaversion.protocols.protocol1_19_3to1_19_1.ServerboundPackets1_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.BitSet;
import java.util.UUID; import java.util.UUID;
import org.checkerframework.checker.nullness.qual.Nullable; 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); final ChatTypeStorage1_19_3 chatTypeStorage = wrapper.user().get(ChatTypeStorage1_19_3.class);
chatTypeStorage.clear(); chatTypeStorage.clear();
final CompoundTag registry = wrapper.get(Type.NAMED_COMPOUND_TAG, 0); 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) { for (final CompoundTag chatType : chatTypes) {
final NumberTag idTag = chatType.getNumberTag("id"); final NumberTag idTag = chatType.getNumberTag("id");
chatTypeStorage.addChatType(idTag.asInt(), chatType); 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.CompoundTag;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag; 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.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_3to1_19_1.ClientboundPackets1_19_3;
import com.viaversion.viaversion.protocols.protocol1_19_4to1_19_3.ClientboundPackets1_19_4; 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> { 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:trim_material");
registry.remove("minecraft:damage_type"); registry.remove("minecraft:damage_type");
final CompoundTag biomeRegistry = registry.getCompoundTag("minecraft:worldgen/biome"); final ListTag<CompoundTag> biomes = TagUtil.getRegistryEntries(registry, "worldgen/biome");
final ListTag<CompoundTag> biomes = biomeRegistry.getListTag("value", CompoundTag.class);
for (final CompoundTag biomeTag : biomes) { for (final CompoundTag biomeTag : biomes) {
final CompoundTag biomeData = biomeTag.getCompoundTag("element"); final CompoundTag biomeData = biomeTag.getCompoundTag("element");
final NumberTag hasPrecipitation = biomeData.getNumberTag("has_precipitation"); 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; 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 // 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 // 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"); CompoundTag trimPatternTag = registry.getCompoundTag("minecraft:trim_pattern");
if (trimPatternTag != null) { if (trimPatternTag != null || (trimPatternTag = registry.getCompoundTag("trim_pattern")) != null) {
values = trimPatternTag.getListTag("value", CompoundTag.class); values = trimPatternTag.getListTag("value", CompoundTag.class);
} else { } else {
final CompoundTag trimPatternRegistry = Protocol1_19_4To1_20.MAPPINGS.getTrimPatternRegistry().copy(); 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.CipherUtil;
import com.viaversion.viaversion.util.ComponentUtil; import com.viaversion.viaversion.util.ComponentUtil;
import com.viaversion.viaversion.util.Pair; import com.viaversion.viaversion.util.Pair;
import com.viaversion.viaversion.util.TagUtil;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import org.checkerframework.checker.nullness.qual.Nullable; import org.checkerframework.checker.nullness.qual.Nullable;
@ -102,7 +103,7 @@ public final class Protocol1_19To1_19_1 extends BackwardsProtocol<ClientboundPac
chatTypeStorage.clear(); chatTypeStorage.clear();
final CompoundTag registry = wrapper.get(Type.NAMED_COMPOUND_TAG, 0); 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) { for (final CompoundTag chatType : chatTypes) {
final NumberTag idTag = chatType.getNumberTag("id"); final NumberTag idTag = chatType.getNumberTag("id");
chatTypeStorage.addChatType(idTag.asInt(), chatType); chatTypeStorage.addChatType(idTag.asInt(), chatType);