Example usage for net.minecraftforge.registries IForgeRegistry getValue

List of usage examples for net.minecraftforge.registries IForgeRegistry getValue

Introduction

In this page you can find the example usage for net.minecraftforge.registries IForgeRegistry getValue.

Prototype

@Nullable
    V getValue(ResourceLocation key);

Source Link

Usage

From source file:robmart.rpgmode.common.helper.RegistryHelper.java

License:MIT License

/**
 * Get an entry from the provided registry.
 *
 * @param registry The registry/*from www .j a  v a 2  s  .c o m*/
 * @param name     The NAME of the entry
 * @param <T>      The registry type
 *
 * @return The registry entry
 *
 * @throws NullPointerException When the entry doesn't exist
 */
public static <T extends IForgeRegistryEntry<T>> T getRegistryEntry(final IForgeRegistry<T> registry,
        final String name) {
    final ResourceLocation key = new ResourceLocation(name);
    final T registryEntry = registry.getValue(key);
    return Preconditions.checkNotNull(registryEntry, "%s doesn't exist in registry %s", key,
            RegistryManager.ACTIVE.getName(registry));
}