Java 类net.minecraftforge.fml.common.registry.IForgeRegistryEntry 实例源码

项目:MrglgaghCore    文件:FeatureLoader.java   
/**
 * Register IForgeRegistryEntries in registry
 * @param features Class with IForgeRegistryEntries
 * @param registry Registry to where the entries should get registered
 * @param <T> IForgeRegistryEntry<T>
 */
public static <T extends IForgeRegistryEntry<T>> void register(Class features, IForgeRegistry<T> registry){
    Field[] fields = features.getDeclaredFields();
    for (Field field : fields) {
        if (field.isAnnotationPresent(Feature.class) && registry.getRegistrySuperType().isAssignableFrom(field.getType())){
            try {
                registry.register((T) field.get(null));
                MrglgaghCore.logger.info(field.getName() + " registered!");
            } catch (IllegalAccessException | IllegalArgumentException e) {
                MrglgaghCore.logger.error("Can't access feature field: " + field.getName() + ". Make sure it is public static!", e);
            }
        }
    }
}
项目:ProjectEon    文件:CommonProxy.java   
protected void register(IForgeRegistryEntry item, String name) {
    ResourceLocation loc = getName(name);
    GameRegistry.register(item, loc);

    if(item instanceof Block) {
        GameRegistry.register(new ItemBlock((Block)item).setRegistryName(loc));
    }
}
项目:MMDLib-old    文件:ModUtils.java   
/**
 * Attempts to get the name of the mod which registered the passed object. Minecraft will
 * be returned for vanilla content while Unknown will be used for invalid cases.
 *
 * @param registerable The object to get the mod name for.
 * @return The name of the mod which registered the object.
 */
public static String getModName (IForgeRegistryEntry.Impl<?> registerable) {
    final String modID = registerable.getRegistryName().getResourceDomain();
    final ModContainer mod = getModContainer(modID);
    return mod != null ? mod.getName() : modID.equalsIgnoreCase("minecraft") ? "Minecraft" : "Unknown";
}