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

Fix some namespace parsing issues

Dieser Commit ist enthalten in:
Nassim Jahnke 2024-04-26 13:31:14 +02:00
Ursprung be742fc493
Commit b3115ea71d
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: EF6771C01F6EF02F
3 geänderte Dateien mit 12 neuen und 5 gelöschten Zeilen

Datei anzeigen

@ -48,6 +48,7 @@ public class EntityPackets1_16 extends EntityRewriter<ClientboundPackets1_16, Pr
private final ValueTransformer<String, Integer> dimensionTransformer = new ValueTransformer<String, Integer>(Type.STRING, Type.INT) {
@Override
public Integer transform(PacketWrapper wrapper, String input) {
input = Key.namespaced(input);
switch (input) {
case "minecraft:the_nether":
return -1;

Datei anzeigen

@ -35,6 +35,7 @@ import com.viaversion.viaversion.libs.opennbt.tag.builtin.NumberTag;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
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.Key;
import com.viaversion.viaversion.util.TagUtil;
import java.util.Set;
@ -114,7 +115,7 @@ public class EntityPackets1_16_2 extends EntityRewriter<ClientboundPackets1_16_2
private String getDimensionFromData(CompoundTag dimensionData) {
// This may technically break other custom dimension settings for 1.16/1.16.1 clients, so those cases are considered semi "unsupported" here
StringTag effectsLocation = dimensionData.getStringTag("effects");
return effectsLocation != null && oldDimensions.contains(effectsLocation.getValue()) ?
return effectsLocation != null && oldDimensions.contains(Key.namespaced(effectsLocation.getValue())) ?
effectsLocation.getValue() : "minecraft:overworld";
}

Datei anzeigen

@ -37,9 +37,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_18to1_17_1.ClientboundPackets1_18;
import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.ClientboundPackets1_19;
import com.viaversion.viaversion.util.Key;
import com.viaversion.viaversion.util.TagUtil;
public final class EntityPackets1_19 extends EntityRewriter<ClientboundPackets1_19, Protocol1_18_2To1_19> {
@ -130,7 +130,7 @@ public final class EntityPackets1_19 extends EntityRewriter<ClientboundPackets1_
dimensionRegistryStorage.clear();
// Cache dimensions and find current dimension
final String dimensionKey = wrapper.read(Type.STRING);
final String dimensionKey = Key.stripMinecraftNamespace(wrapper.read(Type.STRING));
final CompoundTag registry = wrapper.get(Type.NAMED_COMPOUND_TAG, 0);
final ListTag<CompoundTag> dimensions = TagUtil.getRegistryEntries(registry, "dimension_type");
boolean found = false;
@ -139,7 +139,7 @@ public final class EntityPackets1_19 extends EntityRewriter<ClientboundPackets1_
final CompoundTag dimensionData = dimension.getCompoundTag("element");
dimensionRegistryStorage.addDimension(nameTag.getValue(), dimensionData.copy());
if (!found && nameTag.getValue().equals(dimensionKey)) {
if (!found && Key.stripMinecraftNamespace(nameTag.getValue()).equals(dimensionKey)) {
wrapper.write(Type.NAMED_COMPOUND_TAG, dimensionData);
found = true;
}
@ -157,7 +157,12 @@ public final class EntityPackets1_19 extends EntityRewriter<ClientboundPackets1_
tracker(wrapper.user()).setBiomesSent(biomes.size());
// Cache and remove chat types
final ListTag<CompoundTag> chatTypes = ((CompoundTag) registry.remove("minecraft:chat_type")).getListTag("value", CompoundTag.class);
CompoundTag chatTypeRegistry = (CompoundTag) registry.remove("minecraft:chat_type");
if (chatTypeRegistry == null) {
chatTypeRegistry = (CompoundTag) registry.remove("chat_type");
}
final ListTag<CompoundTag> chatTypes = chatTypeRegistry.getListTag("value", CompoundTag.class);
for (final CompoundTag chatType : chatTypes) {
final NumberTag idTag = chatType.getNumberTag("id");
dimensionRegistryStorage.addChatType(idTag.asInt(), chatType);