mirror of
https://github.com/GeyserMC/Geyser.git
synced 2025-03-22 06:55:33 +01:00
Move identifierToKey out of ItemRegistryPopulator
This commit is contained in:
parent
ff35c6e752
commit
b254594bbf
3 changed files with 9 additions and 9 deletions
|
@ -81,6 +81,7 @@ import org.geysermc.geyser.registry.type.ItemMapping;
|
||||||
import org.geysermc.geyser.registry.type.ItemMappings;
|
import org.geysermc.geyser.registry.type.ItemMappings;
|
||||||
import org.geysermc.geyser.registry.type.NonVanillaItemRegistration;
|
import org.geysermc.geyser.registry.type.NonVanillaItemRegistration;
|
||||||
import org.geysermc.geyser.registry.type.PaletteItem;
|
import org.geysermc.geyser.registry.type.PaletteItem;
|
||||||
|
import org.geysermc.geyser.util.MinecraftKey;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -506,7 +507,7 @@ public class ItemRegistryPopulator {
|
||||||
|
|
||||||
// ComponentItemData - used to register some custom properties
|
// ComponentItemData - used to register some custom properties
|
||||||
componentItemData.add(customMapping.componentItemData());
|
componentItemData.add(customMapping.componentItemData());
|
||||||
customItemDefinitions.put(identifierToKey(customItem.model()), customMapping);
|
customItemDefinitions.put(MinecraftKey.identifierToKey(customItem.model()), customMapping);
|
||||||
registry.put(customMapping.integerId(), customMapping.itemDefinition());
|
registry.put(customMapping.integerId(), customMapping.itemDefinition());
|
||||||
|
|
||||||
customIdMappings.put(customMapping.integerId(), customItemIdentifier.toString());
|
customIdMappings.put(customMapping.integerId(), customItemIdentifier.toString());
|
||||||
|
@ -735,11 +736,6 @@ public class ItemRegistryPopulator {
|
||||||
componentItemData.add(new ComponentItemData("geysermc:furnace_minecart", builder.build()));
|
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:
|
* Compares custom item definitions based on their predicates:
|
||||||
*
|
*
|
||||||
|
|
|
@ -41,7 +41,6 @@ import org.geysermc.geyser.api.util.Identifier;
|
||||||
import org.geysermc.geyser.item.GeyserCustomMappingData;
|
import org.geysermc.geyser.item.GeyserCustomMappingData;
|
||||||
import org.geysermc.geyser.item.Items;
|
import org.geysermc.geyser.item.Items;
|
||||||
import org.geysermc.geyser.level.JavaDimension;
|
import org.geysermc.geyser.level.JavaDimension;
|
||||||
import org.geysermc.geyser.registry.populator.ItemRegistryPopulator;
|
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
import org.geysermc.geyser.session.cache.registry.RegistryEntryData;
|
import org.geysermc.geyser.session.cache.registry.RegistryEntryData;
|
||||||
import org.geysermc.geyser.util.MinecraftKey;
|
import org.geysermc.geyser.util.MinecraftKey;
|
||||||
|
@ -128,11 +127,11 @@ public final class CustomItemTranslator {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
RegistryEntryData<TrimMaterial> registered = session.getRegistryCache().trimMaterials().entryById(trim.material().id());
|
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) {
|
} else if (match.property() == MatchPredicateProperty.CONTEXT_DIMENSION) {
|
||||||
Identifier dimension = (Identifier) match.data();
|
Identifier dimension = (Identifier) match.data();
|
||||||
RegistryEntryData<JavaDimension> registered = session.getRegistryCache().dimensions().entryByValue(session.getDimensionType());
|
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) {
|
} else if (match.property() == MatchPredicateProperty.CUSTOM_MODEL_DATA) {
|
||||||
CustomModelDataString expected = (CustomModelDataString) match.data();
|
CustomModelDataString expected = (CustomModelDataString) match.data();
|
||||||
return expected.value().equals(getSafeCustomModelData(components, CustomModelData::strings, expected.index()));
|
return expected.value().equals(getSafeCustomModelData(components, CustomModelData::strings, expected.index()));
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
package org.geysermc.geyser.util;
|
package org.geysermc.geyser.util;
|
||||||
|
|
||||||
import net.kyori.adventure.key.Key;
|
import net.kyori.adventure.key.Key;
|
||||||
|
import org.geysermc.geyser.api.util.Identifier;
|
||||||
import org.intellij.lang.annotations.Subst;
|
import org.intellij.lang.annotations.Subst;
|
||||||
|
|
||||||
public final class MinecraftKey {
|
public final class MinecraftKey {
|
||||||
|
@ -36,4 +37,8 @@ public final class MinecraftKey {
|
||||||
public static Key key(@Subst("empty") String s) {
|
public static Key key(@Subst("empty") String s) {
|
||||||
return Key.key(s);
|
return Key.key(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Key identifierToKey(Identifier identifier) {
|
||||||
|
return Key.key(identifier.namespace(), identifier.path());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue