当前位置: 首页>>代码示例>>Java>>正文


Java IForgeRegistryEntry类代码示例

本文整理汇总了Java中net.minecraftforge.fml.common.registry.IForgeRegistryEntry的典型用法代码示例。如果您正苦于以下问题:Java IForgeRegistryEntry类的具体用法?Java IForgeRegistryEntry怎么用?Java IForgeRegistryEntry使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


IForgeRegistryEntry类属于net.minecraftforge.fml.common.registry包,在下文中一共展示了IForgeRegistryEntry类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: register

import net.minecraftforge.fml.common.registry.IForgeRegistryEntry; //导入依赖的package包/类
/**
 * 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);
            }
        }
    }
}
 
开发者ID:sedlak477,项目名称:MrglgaghCore,代码行数:20,代码来源:FeatureLoader.java

示例2: register

import net.minecraftforge.fml.common.registry.IForgeRegistryEntry; //导入依赖的package包/类
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));
    }
}
 
开发者ID:Guichaguri,项目名称:ProjectEon,代码行数:9,代码来源:CommonProxy.java

示例3: getModName

import net.minecraftforge.fml.common.registry.IForgeRegistryEntry; //导入依赖的package包/类
/**
 * 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";
}
 
开发者ID:MinecraftModDevelopmentMods,项目名称:MMDLib-old,代码行数:13,代码来源:ModUtils.java


注:本文中的net.minecraftforge.fml.common.registry.IForgeRegistryEntry类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。