Renamed RegistryContext to RegistryEntryContext

This commit is contained in:
Eclipse 2024-07-09 13:52:26 +00:00
parent db23661b59
commit ef772dcfdb
No known key found for this signature in database
GPG key ID: 95E6998F82EC938A
7 changed files with 15 additions and 15 deletions

View file

@ -32,7 +32,7 @@ import org.cloudburstmc.protocol.bedrock.data.TrimPattern;
import org.cloudburstmc.protocol.bedrock.data.inventory.descriptor.ItemDescriptorWithCount; import org.cloudburstmc.protocol.bedrock.data.inventory.descriptor.ItemDescriptorWithCount;
import org.cloudburstmc.protocol.bedrock.data.inventory.descriptor.ItemTagDescriptor; import org.cloudburstmc.protocol.bedrock.data.inventory.descriptor.ItemTagDescriptor;
import org.geysermc.geyser.registry.type.ItemMapping; import org.geysermc.geyser.registry.type.ItemMapping;
import org.geysermc.geyser.session.cache.registry.RegistryContext; import org.geysermc.geyser.session.cache.registry.RegistryEntryContext;
import org.geysermc.geyser.translator.text.MessageTranslator; import org.geysermc.geyser.translator.text.MessageTranslator;
/** /**
@ -45,7 +45,7 @@ public final class TrimRecipe {
public static final ItemDescriptorWithCount ADDITION = tagDescriptor("minecraft:trim_materials"); public static final ItemDescriptorWithCount ADDITION = tagDescriptor("minecraft:trim_materials");
public static final ItemDescriptorWithCount TEMPLATE = tagDescriptor("minecraft:trim_templates"); public static final ItemDescriptorWithCount TEMPLATE = tagDescriptor("minecraft:trim_templates");
public static TrimMaterial readTrimMaterial(RegistryContext context) { public static TrimMaterial readTrimMaterial(RegistryEntryContext context) {
String key = context.id().asMinimalString(); String key = context.id().asMinimalString();
// Color is used when hovering over the item // Color is used when hovering over the item
@ -65,7 +65,7 @@ public final class TrimRecipe {
return new TrimMaterial(key, legacy.substring(2).trim(), itemMapping.getBedrockIdentifier()); return new TrimMaterial(key, legacy.substring(2).trim(), itemMapping.getBedrockIdentifier());
} }
public static TrimPattern readTrimPattern(RegistryContext context) { public static TrimPattern readTrimPattern(RegistryEntryContext context) {
String key = context.id().asMinimalString(); String key = context.id().asMinimalString();
String itemIdentifier = context.data().getString("template_item"); String itemIdentifier = context.data().getString("template_item");

View file

@ -33,7 +33,7 @@ import org.cloudburstmc.nbt.NbtMap;
import org.geysermc.geyser.inventory.item.BedrockEnchantment; import org.geysermc.geyser.inventory.item.BedrockEnchantment;
import org.geysermc.geyser.item.Items; import org.geysermc.geyser.item.Items;
import org.geysermc.geyser.registry.Registries; import org.geysermc.geyser.registry.Registries;
import org.geysermc.geyser.session.cache.registry.RegistryContext; import org.geysermc.geyser.session.cache.registry.RegistryEntryContext;
import org.geysermc.geyser.translator.text.MessageTranslator; import org.geysermc.geyser.translator.text.MessageTranslator;
import java.util.HashSet; import java.util.HashSet;
@ -54,7 +54,7 @@ public record Enchantment(String identifier,
HolderSet exclusiveSet, HolderSet exclusiveSet,
@Nullable BedrockEnchantment bedrockEnchantment) { @Nullable BedrockEnchantment bedrockEnchantment) {
public static Enchantment read(RegistryContext context) { public static Enchantment read(RegistryEntryContext context) {
NbtMap data = context.data(); NbtMap data = context.data();
Set<EnchantmentComponent> effects = readEnchantmentComponents(data.getCompound("effects")); Set<EnchantmentComponent> effects = readEnchantmentComponents(data.getCompound("effects"));

View file

@ -26,7 +26,7 @@
package org.geysermc.geyser.level; package org.geysermc.geyser.level;
import org.cloudburstmc.nbt.NbtMap; import org.cloudburstmc.nbt.NbtMap;
import org.geysermc.geyser.session.cache.registry.RegistryContext; import org.geysermc.geyser.session.cache.registry.RegistryEntryContext;
/** /**
* Represents the information we store from the current Java dimension * Represents the information we store from the current Java dimension
@ -35,7 +35,7 @@ import org.geysermc.geyser.session.cache.registry.RegistryContext;
*/ */
public record JavaDimension(int minY, int maxY, boolean piglinSafe, double worldCoordinateScale) { public record JavaDimension(int minY, int maxY, boolean piglinSafe, double worldCoordinateScale) {
public static JavaDimension read(RegistryContext entry) { public static JavaDimension read(RegistryEntryContext entry) {
NbtMap dimension = entry.data(); NbtMap dimension = entry.data();
int minY = dimension.getInt("min_y"); int minY = dimension.getInt("min_y");
int maxY = dimension.getInt("height"); int maxY = dimension.getInt("height");

View file

@ -27,12 +27,12 @@ package org.geysermc.geyser.level;
import org.cloudburstmc.nbt.NbtMap; import org.cloudburstmc.nbt.NbtMap;
import org.geysermc.geyser.GeyserImpl; import org.geysermc.geyser.GeyserImpl;
import org.geysermc.geyser.session.cache.registry.RegistryContext; import org.geysermc.geyser.session.cache.registry.RegistryEntryContext;
import org.geysermc.geyser.translator.text.MessageTranslator; import org.geysermc.geyser.translator.text.MessageTranslator;
public record JukeboxSong(String soundEvent, String description) { public record JukeboxSong(String soundEvent, String description) {
public static JukeboxSong read(RegistryContext context) { public static JukeboxSong read(RegistryEntryContext context) {
NbtMap data = context.data(); NbtMap data = context.data();
Object soundEventObject = data.get("sound_event"); Object soundEventObject = data.get("sound_event");
String soundEvent; String soundEvent;

View file

@ -45,7 +45,7 @@ import org.geysermc.geyser.level.JukeboxSong;
import org.geysermc.geyser.level.PaintingType; import org.geysermc.geyser.level.PaintingType;
import org.geysermc.geyser.session.GeyserSession; import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.session.cache.registry.JavaRegistry; import org.geysermc.geyser.session.cache.registry.JavaRegistry;
import org.geysermc.geyser.session.cache.registry.RegistryContext; import org.geysermc.geyser.session.cache.registry.RegistryEntryContext;
import org.geysermc.geyser.session.cache.registry.SimpleJavaRegistry; import org.geysermc.geyser.session.cache.registry.SimpleJavaRegistry;
import org.geysermc.geyser.text.TextDecoration; import org.geysermc.geyser.text.TextDecoration;
import org.geysermc.geyser.translator.level.BiomeTranslator; import org.geysermc.geyser.translator.level.BiomeTranslator;
@ -149,7 +149,7 @@ public final class RegistryCache {
* @param reader converts the RegistryEntry NBT into a class file * @param reader converts the RegistryEntry NBT into a class file
* @param <T> the class that represents these entries. * @param <T> the class that represents these entries.
*/ */
private static <T> void register(String registry, Function<RegistryCache, JavaRegistry<T>> localCacheFunction, Function<RegistryContext, T> reader) { private static <T> void register(String registry, Function<RegistryCache, JavaRegistry<T>> localCacheFunction, Function<RegistryEntryContext, T> reader) {
Key registryKey = MinecraftKey.key(registry); Key registryKey = MinecraftKey.key(registry);
REGISTRIES.put(registryKey, (registryCache, entries) -> { REGISTRIES.put(registryKey, (registryCache, entries) -> {
Map<Key, NbtMap> localRegistry = null; Map<Key, NbtMap> localRegistry = null;
@ -175,7 +175,7 @@ public final class RegistryCache {
entry = new RegistryEntry(entry.getId(), localRegistry.get(entry.getId())); entry = new RegistryEntry(entry.getId(), localRegistry.get(entry.getId()));
} }
RegistryContext context = new RegistryContext(entry, entryIdMap, registryCache.session); RegistryEntryContext context = new RegistryEntryContext(entry, entryIdMap, registryCache.session);
// This is what Geyser wants to keep as a value for this registry. // This is what Geyser wants to keep as a value for this registry.
T cacheEntry = reader.apply(context); T cacheEntry = reader.apply(context);
builder.add(i, cacheEntry); builder.add(i, cacheEntry);

View file

@ -38,7 +38,7 @@ import org.geysermc.mcprotocollib.protocol.data.game.RegistryEntry;
* @param keyIdMap a map for each of the resource location's in the registry and their respective network IDs. * @param keyIdMap a map for each of the resource location's in the registry and their respective network IDs.
* @param session the Geyser session. * @param session the Geyser session.
*/ */
public record RegistryContext(RegistryEntry entry, Map<Key, Integer> keyIdMap, GeyserSession session) { public record RegistryEntryContext(RegistryEntry entry, Map<Key, Integer> keyIdMap, GeyserSession session) {
public int getNetworkId(Key registryKey) { public int getNetworkId(Key registryKey) {
return keyIdMap.getOrDefault(registryKey, 0); return keyIdMap.getOrDefault(registryKey, 0);

View file

@ -29,7 +29,7 @@ import net.kyori.adventure.text.format.NamedTextColor;
import net.kyori.adventure.text.format.Style; import net.kyori.adventure.text.format.Style;
import org.cloudburstmc.nbt.NbtMap; import org.cloudburstmc.nbt.NbtMap;
import org.cloudburstmc.nbt.NbtType; import org.cloudburstmc.nbt.NbtType;
import org.geysermc.geyser.session.cache.registry.RegistryContext; import org.geysermc.geyser.session.cache.registry.RegistryEntryContext;
import org.geysermc.mcprotocollib.protocol.data.game.chat.ChatType; import org.geysermc.mcprotocollib.protocol.data.game.chat.ChatType;
import org.geysermc.mcprotocollib.protocol.data.game.chat.ChatTypeDecoration; import org.geysermc.mcprotocollib.protocol.data.game.chat.ChatTypeDecoration;
@ -43,7 +43,7 @@ public record TextDecoration(String translationKey, List<Parameter> parameters,
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
public static ChatType readChatType(RegistryContext context) { public static ChatType readChatType(RegistryEntryContext context) {
// Note: The ID is NOT ALWAYS THE SAME! ViaVersion as of 1.19 adds two registry entries that do NOT match vanilla. // Note: The ID is NOT ALWAYS THE SAME! ViaVersion as of 1.19 adds two registry entries that do NOT match vanilla.
// (This note has been passed around through several classes and iterations. It stays as a warning // (This note has been passed around through several classes and iterations. It stays as a warning
// to anyone that dares to try and hardcode registry IDs.) // to anyone that dares to try and hardcode registry IDs.)