Cache dimensions without namespace in 1.19->1.18.2 (#744)

This commit is contained in:
EnZaXD 2024-05-10 21:47:45 +02:00 committed by GitHub
parent e45a95c6ec
commit abb1803aaf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 4 deletions

View File

@ -133,11 +133,11 @@ public final class EntityPackets1_19 extends EntityRewriter<ClientboundPackets1_
final ListTag<CompoundTag> 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;
}

View File

@ -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<CompoundTag> 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;
}