From abb1803aaf30e0a9d091877a0ce0d35756eff266 Mon Sep 17 00:00:00 2001 From: EnZaXD <60033407+FlorianMichael@users.noreply.github.com> Date: Fri, 10 May 2024 21:47:45 +0200 Subject: [PATCH] Cache dimensions without namespace in 1.19->1.18.2 (#744) --- .../protocol1_18_2to1_19/packets/EntityPackets1_19.java | 6 +++--- .../storage/DimensionRegistryStorage.java | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_18_2to1_19/packets/EntityPackets1_19.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_18_2to1_19/packets/EntityPackets1_19.java index b93e32d2..e0e87e77 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_18_2to1_19/packets/EntityPackets1_19.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_18_2to1_19/packets/EntityPackets1_19.java @@ -133,11 +133,11 @@ public final class EntityPackets1_19 extends EntityRewriter dimensions = TagUtil.getRegistryEntries(registry, "dimension_type"); boolean found = false; for (final CompoundTag dimension : dimensions) { - final StringTag nameTag = dimension.getStringTag("name"); + final String name = Key.stripMinecraftNamespace(dimension.getString("name")); final CompoundTag dimensionData = dimension.getCompoundTag("element"); - dimensionRegistryStorage.addDimension(nameTag.getValue(), dimensionData.copy()); + dimensionRegistryStorage.addDimension(name, dimensionData.copy()); - if (!found && Key.stripMinecraftNamespace(nameTag.getValue()).equals(dimensionKey)) { + if (!found && name.equals(dimensionKey)) { wrapper.write(Type.NAMED_COMPOUND_TAG, dimensionData); found = true; } diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_18_2to1_19/storage/DimensionRegistryStorage.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_18_2to1_19/storage/DimensionRegistryStorage.java index 0708152a..3887f653 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_18_2to1_19/storage/DimensionRegistryStorage.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_18_2to1_19/storage/DimensionRegistryStorage.java @@ -24,6 +24,7 @@ import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectOpenHashMap; import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag; import java.util.HashMap; import java.util.Map; +import com.viaversion.viaversion.util.Key; import org.checkerframework.checker.nullness.qual.Nullable; public final class DimensionRegistryStorage implements StorableObject { @@ -32,7 +33,7 @@ public final class DimensionRegistryStorage implements StorableObject { private final Int2ObjectMap chatTypes = new Int2ObjectOpenHashMap<>(); public @Nullable CompoundTag dimension(final String dimensionKey) { - final CompoundTag compoundTag = dimensions.get(dimensionKey); + final CompoundTag compoundTag = dimensions.get(Key.stripMinecraftNamespace(dimensionKey)); return compoundTag != null ? compoundTag.copy() : null; }