Class RegistryHelper
java.lang.Object
com.pixelmonmod.pixelmon.api.util.helpers.RegistryHelper
Utility class for registry related operations.
To access the registries for a specific side you can use
To access the registries for a specific side you can use
ClientRegistryHelper.getRegistryAccess()
or ServerRegistryHelper.getRegistryAccess(). However, if you want to obtain registry access
and cannot be certain which side you are on then you should always use registryAccess().-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleancompareKeys(net.minecraft.resources.ResourceKey<?> a, net.minecraft.resources.ResourceKey<?> b) Compares twoResourceKeys to check if they are equal.static <T> Tget(net.minecraft.resources.ResourceKey<net.minecraft.core.Registry<T>> registryKey, net.minecraft.resources.ResourceKey<T> location) Gets the element for the givenResourceKeyin the given registry.static <T> Tget(net.minecraft.resources.ResourceKey<net.minecraft.core.Registry<T>> registryKey, net.minecraft.resources.ResourceLocation location) Gets the element for the givenResourceLocationin the given registry.static <T> Collection<T> getAll(net.minecraft.resources.ResourceKey<net.minecraft.core.Registry<T>> registry) Gets all elements for the registry defined by the givenResourceKey.static <T> net.minecraft.core.Holder<T> getHolder(net.minecraft.resources.ResourceKey<net.minecraft.core.Registry<T>> registryKey, net.minecraft.resources.ResourceKey<T> location) Gets theResourceKeyfor the given element in the given registry.static <T> net.minecraft.core.Holder<T> getHolder(net.minecraft.resources.ResourceKey<net.minecraft.core.Registry<T>> registryKey, net.minecraft.resources.ResourceLocation location) Gets theResourceLocationfor the given element in the given registry.static <T> net.minecraft.core.Holder<T> getHolder(net.minecraft.resources.ResourceKey<net.minecraft.core.Registry<T>> registryKey, T element) Gets theHolderfor the given element in the given registry.static <T> net.minecraft.resources.ResourceKey<T> getKey(net.minecraft.resources.ResourceKey<net.minecraft.core.Registry<T>> registry, String resourceLocation) Gets theResourceKeyfor the given element at the resource location in the given registrystatic <T> net.minecraft.resources.ResourceKey<T> getKey(net.minecraft.resources.ResourceKey<net.minecraft.core.Registry<T>> registry, net.minecraft.resources.ResourceLocation resourceLocation) Gets theResourceKeyfor the given element at the resource location in the given registrystatic <T> net.minecraft.resources.ResourceLocationgetKey(net.minecraft.resources.ResourceKey<net.minecraft.core.Registry<T>> registry, T element) Gets theResourceLocationfor the given element in the given registry.static <T> net.minecraft.core.HolderSet<T> getTag(net.minecraft.resources.ResourceKey<net.minecraft.core.Registry<T>> registryKey, net.minecraft.tags.TagKey<T> location) Converts aTagKeyto aHolderSetof the elements in the tag.static <T> net.minecraft.network.chat.MutableComponentgetTranslated(net.minecraft.core.Holder<T> holder) Converts the givenHolderto aMutableComponentwith the translation key of the holder.static <T> net.minecraft.network.chat.MutableComponentgetTranslated(net.minecraft.resources.ResourceKey<T> resourceKey) Converts the givenResourceKeyto aMutableComponentwith the translation key of the key.static <T> StringgetTranslationKey(net.minecraft.core.Holder<T> holder) Converts the givenHolderto aStringof the translation key of the holder.static <T> StringgetTranslationKey(net.minecraft.resources.ResourceKey<T> resourceKey) Converts the givenResourceKeyto aStringof the translation key of the key.static net.minecraft.core.RegistryAccess.FrozenGets the correctRegistryAccessfor the current side
-
Constructor Details
-
RegistryHelper
public RegistryHelper()
-
-
Method Details
-
compareKeys
public static boolean compareKeys(net.minecraft.resources.ResourceKey<?> a, net.minecraft.resources.ResourceKey<?> b) Compares twoResourceKeys to check if they are equal.- Parameters:
a- The first keyb- The second key- Returns:
- True if the keys are equal, false otherwise
-
getAll
public static <T> Collection<T> getAll(net.minecraft.resources.ResourceKey<net.minecraft.core.Registry<T>> registry) Gets all elements for the registry defined by the givenResourceKey.- Type Parameters:
T- The type of the registry- Parameters:
registry- The registry key- Returns:
- A collection of all elements in the registry
-
getKey
public static <T> net.minecraft.resources.ResourceLocation getKey(net.minecraft.resources.ResourceKey<net.minecraft.core.Registry<T>> registry, T element) Gets theResourceLocationfor the given element in the given registry.- Type Parameters:
T- The type of the registry- Parameters:
registry- The registry key of the registryelement- The element- Returns:
- The
ResourceLocationof the element
-
getKey
public static <T> net.minecraft.resources.ResourceKey<T> getKey(net.minecraft.resources.ResourceKey<net.minecraft.core.Registry<T>> registry, String resourceLocation) Gets theResourceKeyfor the given element at the resource location in the given registry- Type Parameters:
T- The type of the registry- Parameters:
registry- The registry key of the registryresourceLocation- The resource location of the element- Returns:
- The
ResourceKeyof the element
-
getKey
public static <T> net.minecraft.resources.ResourceKey<T> getKey(net.minecraft.resources.ResourceKey<net.minecraft.core.Registry<T>> registry, net.minecraft.resources.ResourceLocation resourceLocation) Gets theResourceKeyfor the given element at the resource location in the given registry- Type Parameters:
T- The type of the registry- Parameters:
registry- The registry key of the registryresourceLocation- The resource location of the element- Returns:
- The
ResourceKeyof the element
-
getTranslated
public static <T> net.minecraft.network.chat.MutableComponent getTranslated(net.minecraft.core.Holder<T> holder) Converts the givenHolderto aMutableComponentwith the translation key of the holder.- Type Parameters:
T- The type of the holder- Parameters:
holder- The holder to translate- Returns:
- The translated component
-
getTranslated
public static <T> net.minecraft.network.chat.MutableComponent getTranslated(net.minecraft.resources.ResourceKey<T> resourceKey) Converts the givenResourceKeyto aMutableComponentwith the translation key of the key.- Type Parameters:
T- The type of the holder- Parameters:
resourceKey- The key to translate- Returns:
- The translated component
-
getTranslationKey
Converts the givenHolderto aStringof the translation key of the holder.- Type Parameters:
T- The type of the holder- Parameters:
holder- The holder to translate- Returns:
- The translation key
-
getTranslationKey
Converts the givenResourceKeyto aStringof the translation key of the key.- Type Parameters:
T- The type of the holder- Parameters:
resourceKey- The key to translate- Returns:
- The translation key
-
get
public static <T> T get(net.minecraft.resources.ResourceKey<net.minecraft.core.Registry<T>> registryKey, net.minecraft.resources.ResourceLocation location) Gets the element for the givenResourceLocationin the given registry.
Note: Can return null if no element is found.- Type Parameters:
T- The type of the registry- Parameters:
registryKey- The registry key of the registrylocation- The resource location of the element- Returns:
- The element
-
get
public static <T> T get(net.minecraft.resources.ResourceKey<net.minecraft.core.Registry<T>> registryKey, net.minecraft.resources.ResourceKey<T> location) Gets the element for the givenResourceKeyin the given registry.
Note: Can return null if no element is found.- Type Parameters:
T- The type of the registry- Parameters:
registryKey- The registry key of the registrylocation- The resource location of the element- Returns:
- The element
-
getHolder
public static <T> net.minecraft.core.Holder<T> getHolder(net.minecraft.resources.ResourceKey<net.minecraft.core.Registry<T>> registryKey, T element) Gets theHolderfor the given element in the given registry.
Note: Can return null if no element is found.- Type Parameters:
T- The type of the registry- Parameters:
registryKey- The registry key of the registryelement- The element- Returns:
- The holder
-
getHolder
public static <T> net.minecraft.core.Holder<T> getHolder(net.minecraft.resources.ResourceKey<net.minecraft.core.Registry<T>> registryKey, net.minecraft.resources.ResourceLocation location) Gets theResourceLocationfor the given element in the given registry.
Note: Can return null if no element is found.- Type Parameters:
T- The type of the registry- Parameters:
registryKey- The registry key of the registrylocation- The location of the element- Returns:
- The holder
-
getHolder
public static <T> net.minecraft.core.Holder<T> getHolder(net.minecraft.resources.ResourceKey<net.minecraft.core.Registry<T>> registryKey, net.minecraft.resources.ResourceKey<T> location) Gets theResourceKeyfor the given element in the given registry.
Note: Can return null if no element is found.- Type Parameters:
T- The type of the registry- Parameters:
registryKey- The registry key of the registrylocation- The location of the element- Returns:
- The holder
-
getTag
public static <T> net.minecraft.core.HolderSet<T> getTag(net.minecraft.resources.ResourceKey<net.minecraft.core.Registry<T>> registryKey, net.minecraft.tags.TagKey<T> location) Converts aTagKeyto aHolderSetof the elements in the tag.- Type Parameters:
T- The type of the registry- Parameters:
registryKey- The registry key of the registrylocation- The tag key- Returns:
- The holder set
-
registryAccess
public static net.minecraft.core.RegistryAccess.Frozen registryAccess()Gets the correctRegistryAccessfor the current side- Returns:
- The registry access
-