Skip to content

Commit

Permalink
Cache dimensions without namespace in 1.19->1.18.2 (#744)
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianMichael committed May 10, 2024
1 parent e45a95c commit abb1803
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,11 @@ public void register() {
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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
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 {
Expand All @@ -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;
}

Expand Down

0 comments on commit abb1803

Please sign in to comment.