本文整理汇总了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);
}
}
}
}
示例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));
}
}
示例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";
}