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
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
compareKeys
(net.minecraft.resources.ResourceKey<?> a, net.minecraft.resources.ResourceKey<?> b) Compares twoResourceKey
s to check if they are equal.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 givenResourceKey
in the given registry.static <T> T
get
(net.minecraft.resources.ResourceKey<net.minecraft.core.Registry<T>> registryKey, net.minecraft.resources.ResourceLocation location) Gets the element for the givenResourceLocation
in 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 theResourceKey
for 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 theResourceLocation
for 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 theHolder
for 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 theResourceKey
for 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 theResourceKey
for the given element at the resource location in the given registrystatic <T> net.minecraft.resources.ResourceLocation
getKey
(net.minecraft.resources.ResourceKey<net.minecraft.core.Registry<T>> registry, T element) Gets theResourceLocation
for 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 aTagKey
to aHolderSet
of the elements in the tag.static <T> net.minecraft.network.chat.MutableComponent
getTranslated
(net.minecraft.core.Holder<T> holder) Converts the givenHolder
to aMutableComponent
with the translation key of the holder.static <T> net.minecraft.network.chat.MutableComponent
getTranslated
(net.minecraft.resources.ResourceKey<T> resourceKey) Converts the givenResourceKey
to aMutableComponent
with the translation key of the key.static <T> String
getTranslationKey
(net.minecraft.core.Holder<T> holder) Converts the givenHolder
to aString
of the translation key of the holder.static <T> String
getTranslationKey
(net.minecraft.resources.ResourceKey<T> resourceKey) Converts the givenResourceKey
to aString
of the translation key of the key.static net.minecraft.core.RegistryAccess.Frozen
Gets the correctRegistryAccess
for 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 twoResourceKey
s 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 theResourceLocation
for 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
ResourceLocation
of 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 theResourceKey
for 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
ResourceKey
of 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 theResourceKey
for 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
ResourceKey
of the element
-
getTranslated
public static <T> net.minecraft.network.chat.MutableComponent getTranslated(net.minecraft.core.Holder<T> holder) Converts the givenHolder
to aMutableComponent
with 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 givenResourceKey
to aMutableComponent
with 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 givenHolder
to aString
of 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 givenResourceKey
to aString
of 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 givenResourceLocation
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 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 givenResourceKey
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 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 theHolder
for 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 theResourceLocation
for 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 theResourceKey
for 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 aTagKey
to aHolderSet
of 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 correctRegistryAccess
for the current side- Returns:
- The registry access
-