Move identifierToKey out of ItemRegistryPopulator

This commit is contained in:
Eclipse 2024-12-19 12:06:28 +00:00
parent ff35c6e752
commit b254594bbf
No known key found for this signature in database
GPG key ID: 95E6998F82EC938A
3 changed files with 9 additions and 9 deletions

View file

@ -81,6 +81,7 @@ import org.geysermc.geyser.registry.type.ItemMapping;
import org.geysermc.geyser.registry.type.ItemMappings;
import org.geysermc.geyser.registry.type.NonVanillaItemRegistration;
import org.geysermc.geyser.registry.type.PaletteItem;
import org.geysermc.geyser.util.MinecraftKey;
import java.io.InputStream;
import java.util.ArrayList;
@ -506,7 +507,7 @@ public class ItemRegistryPopulator {
// ComponentItemData - used to register some custom properties
componentItemData.add(customMapping.componentItemData());
customItemDefinitions.put(identifierToKey(customItem.model()), customMapping);
customItemDefinitions.put(MinecraftKey.identifierToKey(customItem.model()), customMapping);
registry.put(customMapping.integerId(), customMapping.itemDefinition());
customIdMappings.put(customMapping.integerId(), customItemIdentifier.toString());
@ -735,11 +736,6 @@ public class ItemRegistryPopulator {
componentItemData.add(new ComponentItemData("geysermc:furnace_minecart", builder.build()));
}
// TODO this needs to be moved elsewhere
public static Key identifierToKey(Identifier identifier) {
return Key.key(identifier.namespace(), identifier.path());
}
/**
* Compares custom item definitions based on their predicates:
*

View file

@ -41,7 +41,6 @@ import org.geysermc.geyser.api.util.Identifier;
import org.geysermc.geyser.item.GeyserCustomMappingData;
import org.geysermc.geyser.item.Items;
import org.geysermc.geyser.level.JavaDimension;
import org.geysermc.geyser.registry.populator.ItemRegistryPopulator;
import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.session.cache.registry.RegistryEntryData;
import org.geysermc.geyser.util.MinecraftKey;
@ -128,11 +127,11 @@ public final class CustomItemTranslator {
return false;
}
RegistryEntryData<TrimMaterial> registered = session.getRegistryCache().trimMaterials().entryById(trim.material().id());
return ItemRegistryPopulator.identifierToKey(material).equals(registered.key());
return MinecraftKey.identifierToKey(material).equals(registered.key());
} else if (match.property() == MatchPredicateProperty.CONTEXT_DIMENSION) {
Identifier dimension = (Identifier) match.data();
RegistryEntryData<JavaDimension> registered = session.getRegistryCache().dimensions().entryByValue(session.getDimensionType());
return ItemRegistryPopulator.identifierToKey(dimension).equals(registered.key());
return MinecraftKey.identifierToKey(dimension).equals(registered.key());
} else if (match.property() == MatchPredicateProperty.CUSTOM_MODEL_DATA) {
CustomModelDataString expected = (CustomModelDataString) match.data();
return expected.value().equals(getSafeCustomModelData(components, CustomModelData::strings, expected.index()));

View file

@ -26,6 +26,7 @@
package org.geysermc.geyser.util;
import net.kyori.adventure.key.Key;
import org.geysermc.geyser.api.util.Identifier;
import org.intellij.lang.annotations.Subst;
public final class MinecraftKey {
@ -36,4 +37,8 @@ public final class MinecraftKey {
public static Key key(@Subst("empty") String s) {
return Key.key(s);
}
public static Key identifierToKey(Identifier identifier) {
return Key.key(identifier.namespace(), identifier.path());
}
}