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

Use default dimension data for defaulted registry entry

Dieser Commit ist enthalten in:
Nassim Jahnke 2024-06-20 17:32:19 +02:00
Ursprung 00fedc7656
Commit f5b3799db9
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: EF6771C01F6EF02F
3 geänderte Dateien mit 19 neuen und 1 gelöschten Zeilen

Datei anzeigen

@ -25,6 +25,12 @@ package com.viaversion.viaversion.api.minecraft;
import com.viaversion.nbt.tag.Tag;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Represents an entry in a registry.
*
* @param key key of the registry entry
* @param tag data of the registry entry, or null if the client should use its default
*/
public record RegistryEntry(String key, @Nullable Tag tag) {
public RegistryEntry withKey(final String key) {

Datei anzeigen

@ -48,6 +48,14 @@ public final class DimensionDataImpl implements DimensionData {
this.minY = minY.asInt();
}
public static DimensionData withDefaultsFor(final String key, final int id) {
return switch (key) {
case "overworld", "overworld_caves" -> new DimensionDataImpl(id, -64, 384);
case "the_nether", "the_end" -> new DimensionDataImpl(id, 0, 256);
default -> throw new IllegalArgumentException("Missing registry data for unknown dimension: " + key);
};
}
@Override
public int id() {
return id;

Datei anzeigen

@ -527,7 +527,11 @@ public abstract class EntityRewriter<C extends ClientboundPacketType, T extends
final Map<String, DimensionData> dimensionDataMap = new HashMap<>(entries.length);
for (int i = 0; i < entries.length; i++) {
final RegistryEntry entry = entries[i];
dimensionDataMap.put(Key.stripMinecraftNamespace(entry.key()), new DimensionDataImpl(i, (CompoundTag) entry.tag()));
final String key = Key.stripMinecraftNamespace(entry.key());
final DimensionData dimensionData = entry.tag() != null
? new DimensionDataImpl(i, (CompoundTag) entry.tag())
: DimensionDataImpl.withDefaultsFor(key, i);
dimensionDataMap.put(key, dimensionData);
}
tracker(connection).setDimensions(dimensionDataMap);
}