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


Java ASMDataTable类代码示例

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


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

示例1: getInstancesOfAnnotation

import net.minecraftforge.fml.common.discovery.ASMDataTable; //导入依赖的package包/类
public static <T> List<T> getInstancesOfAnnotation(ASMDataTable asmDataTable, Class annotationClass, Class<T> instanceClass) {
	String annotationClassName = annotationClass.getCanonicalName();
	Set<ASMDataTable.ASMData> asmDatas = asmDataTable.getAll(annotationClassName);
	List<T> instances = new ArrayList<>();
	for (ASMDataTable.ASMData asmData : asmDatas) {
		try {
			Class<?> asmClass = Class.forName(asmData.getClassName());
			Class<? extends T> asmInstanceClass = asmClass.asSubclass(instanceClass);
			T instance = asmInstanceClass.newInstance();
			instances.add(instance);
		} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | LinkageError e) {
			HarshenCastle.LOGGER.error("Failed to load: {}", asmData.getClassName(), e);
		}
	}
	return instances;
}
 
开发者ID:kenijey,项目名称:harshencastle,代码行数:17,代码来源:HarshenUtils.java

示例2: getPluginInstances

import net.minecraftforge.fml.common.discovery.ASMDataTable; //导入依赖的package包/类
public static List<CustomStuffPlugin> getPluginInstances(ASMDataTable asmDataTable)
{
    String annotationName = CS4Plugin.class.getCanonicalName();
    Set<ASMDataTable.ASMData> asmDatas = asmDataTable.getAll(annotationName);

    List<CustomStuffPlugin> instances = Lists.newArrayList();
    for (ASMDataTable.ASMData asmData : asmDatas)
    {
        try
        {
            Class<?> asmClass = Class.forName(asmData.getClassName());
            if (CustomStuffPlugin.class.isAssignableFrom(asmClass))
            {
                Class<? extends CustomStuffPlugin> instanceClass = asmClass.asSubclass(CustomStuffPlugin.class);
                CustomStuffPlugin instance = instanceClass.newInstance();
                instances.add(instance);
            }
        } catch (ClassNotFoundException | IllegalAccessException | InstantiationException e)
        {
            e.printStackTrace();
        }
    }
    return instances;
}
 
开发者ID:cubex2,项目名称:customstuff4,代码行数:25,代码来源:PluginHelper.java

示例3: loadData

import net.minecraftforge.fml.common.discovery.ASMDataTable; //导入依赖的package包/类
public static void loadData(ASMDataTable data)
{
    FMLLog.fine("Loading @Config anotation data");
    for (ASMData target : data.getAll(Config.class.getName()))
    {
        String modid = (String)target.getAnnotationInfo().get("modid");
        Multimap<Config.Type, ASMData> map = asm_data.get(modid);
        if (map == null)
        {
            map = ArrayListMultimap.create();
            asm_data.put(modid, map);
        }

        EnumHolder tholder = (EnumHolder)target.getAnnotationInfo().get("type");
        Config.Type type = tholder == null ? Config.Type.INSTANCE : Config.Type.valueOf(tholder.getValue());

        map.put(type, target);
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:20,代码来源:ConfigManager.java

示例4: getClass

import net.minecraftforge.fml.common.discovery.ASMDataTable; //导入依赖的package包/类
/**
 * @param data The ASMData harvested by FML.
 * @return The class referred by this ASMData
 */
public static Class<?> getClass(ASMDataTable.ASMData data)
{
	if (cache == null)
		cache = Maps.newHashMap();
	Class<?> c = null;
	try
	{
		String name = data.getClassName();
		if (cache.containsKey(name))
			c = cache.get(name);
		else
		{
			c = Class.forName(name);
			cache.put(name, c);
		}
	}
	catch (ClassNotFoundException e)
	{
		e.printStackTrace();
	}
	return c;
}
 
开发者ID:InfinityStudio,项目名称:InspiringWorld,代码行数:27,代码来源:ASMDataUtil.java

示例5: getClassSafe

import net.minecraftforge.fml.common.discovery.ASMDataTable; //导入依赖的package包/类
/**
 * @param data The ASMData harvested by FML.
 * @return The class referred by this ASMData
 */
public static Class<?> getClassSafe(ASMDataTable.ASMData data) throws ClassNotFoundException
{
	if (cache == null)
		cache = Maps.newHashMap();
	Class<?> c = null;
	String name = data.getClassName();
	if (cache.containsKey(name))
		c = cache.get(name);
	else
	{
		c = Class.forName(name);
		cache.put(name, c);
	}
	return c;
}
 
开发者ID:InfinityStudio,项目名称:InspiringWorld,代码行数:20,代码来源:ASMDataUtil.java

示例6: scrapeData

import net.minecraftforge.fml.common.discovery.ASMDataTable; //导入依赖的package包/类
public static void scrapeData(ASMDataTable dataTable) {
    ImmutableList.Builder<IConfigureNEI> plugins = ImmutableList.builder();
    for (ASMDataTable.ASMData data : dataTable.getAll(NEIPlugin.class.getName())) {
        try {
            Class<?> pluginClass = Class.forName(data.getClassName());
            if (IConfigureNEI.class.isAssignableFrom(pluginClass)) {
                IConfigureNEI pluginInstance = (IConfigureNEI) pluginClass.newInstance();
                plugins.add(pluginInstance);
            } else {
                LogHelper.error("Found class with annotation @NEIPlugin but class does not implement IConfigureNEI.. Class: " + data.getClassName());
            }

        } catch (Exception e) {
            LogHelper.fatalError("Fatal exception occurred whilst loading a plugin! Class: %s", e, data.getClassName());
        }
    }
    NEIInitialization.plugins = plugins.build();

}
 
开发者ID:TheCBProject,项目名称:NotEnoughItems,代码行数:20,代码来源:NEIInitialization.java

示例7: registerEvents

import net.minecraftforge.fml.common.discovery.ASMDataTable; //导入依赖的package包/类
private static void registerEvents(@Nonnull ASMDataTable dataTable) {
    String className = EventRegister.class.getCanonicalName();
    Set<ASMDataTable.ASMData> dataSet = new HashSet<>(dataTable.getAll(className));
    for (ASMDataTable.ASMData data : dataSet) {
        try {
            Class clazz = Class.forName(data.getClassName());
            if (EventRegister.IOptionalEvent.class.isAssignableFrom(clazz)) {
                EventRegister.IOptionalEvent eventActive = (EventRegister.IOptionalEvent) clazz.newInstance();
                if (eventActive.isActive()) {
                    MinecraftForge.EVENT_BUS.register(clazz.newInstance());
                }
            } else {
                MinecraftForge.EVENT_BUS.register(clazz.newInstance());
            }
        } catch (Exception ignored) {
        }
    }
}
 
开发者ID:GirafiStudios,项目名称:Culinary-Cultivation,代码行数:19,代码来源:CommonProxy.java

示例8: getInstances

import net.minecraftforge.fml.common.discovery.ASMDataTable; //导入依赖的package包/类
/**
 * Loads classes with a specific annotation from an asm data table.
 *
 * Borrowed from JEI's source code, which is licensed under the MIT license.
 *
 * @param <T> The type of class to load.
 * @param asm The asm data table to load classes from.
 * @param anno The annotation marking classes of interest.
 * @param type The class type to load, as to get around Type erasure.
 * @return A list of the loaded classes, instantiated.
 */
private static <T> List<T> getInstances(ASMDataTable asm, Class anno, Class<T> type) {
    List<T> instances = new ArrayList<>();
    for (ASMDataTable.ASMData asmData : asm.getAll(anno.getCanonicalName())) {
        try {
            T instance = Class.forName(asmData.getClassName()).asSubclass(type).newInstance();
            instances.add(instance);
        } catch (ClassNotFoundException | NoClassDefFoundError | IllegalAccessException | InstantiationException e) {
            AgriCore.getLogger("agricraft-plugins").debug(
                    "%nFailed to load AgriPlugin%n\tOf class: {0}!%n\tFor annotation: {1}!%n\tAs Instanceof: {2}!",
                    asmData.getClassName(),
                    anno.getCanonicalName(),
                    type.getCanonicalName()
            );
        }
    }
    return instances;
}
 
开发者ID:AgriCraft,项目名称:AgriCraft,代码行数:29,代码来源:PluginHandler.java

示例9: addModAPITransformer

import net.minecraftforge.fml.common.discovery.ASMDataTable; //导入依赖的package包/类
public ModAPITransformer addModAPITransformer(ASMDataTable dataTable)
{
    mainClassLoader.registerTransformer("net.minecraftforge.fml.common.asm.transformers.ModAPITransformer");
    List<IClassTransformer> transformers = mainClassLoader.getTransformers();
    ModAPITransformer modAPI = (ModAPITransformer) transformers.get(transformers.size()-1);
    modAPI.initTable(dataTable);
    return modAPI;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:9,代码来源:ModClassLoader.java

示例10: sendToTable

import net.minecraftforge.fml.common.discovery.ASMDataTable; //导入依赖的package包/类
public void sendToTable(ASMDataTable table, ModCandidate candidate)
{
    for (ModAnnotation ma : annotations)
    {
        table.addASMData(candidate, ma.asmType.getClassName(), this.asmType.getClassName(), ma.member, ma.values);
    }

    for (String intf : interfaces)
    {
        table.addASMData(candidate, intf, this.asmType.getInternalName(), null, null);
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:13,代码来源:ASMModParser.java

示例11: inject

import net.minecraftforge.fml.common.discovery.ASMDataTable; //导入依赖的package包/类
public static void inject(ModContainer mod, ASMDataTable data, Side side)
{
    FMLLog.fine("Attempting to inject @EventBusSubscriber classes into the eventbus for %s", mod.getModId());
    Set<ASMDataTable.ASMData> targets = data.getAnnotationsFor(mod).get(Mod.EventBusSubscriber.class.getName());
    ClassLoader mcl = Loader.instance().getModClassLoader();

    for (ASMDataTable.ASMData targ : targets)
    {
        try
        {
            //noinspection unchecked
            List<ModAnnotation.EnumHolder> sidesEnum = (List<ModAnnotation.EnumHolder>)targ.getAnnotationInfo().get("value");
            EnumSet<Side> sides = DEFAULT;
            if (sidesEnum != null) {
                sides = EnumSet.noneOf(Side.class);
                for (ModAnnotation.EnumHolder h: sidesEnum) {
                    sides.add(Side.valueOf(h.getValue()));
                }
            }
            if (sides == DEFAULT || sides.contains(side)) {
                FMLLog.fine("Found @EventBusSubscriber class %s", targ.getClassName());
                Class<?> subscriptionTarget = Class.forName(targ.getClassName(), true, mcl);
                MinecraftForge.EVENT_BUS.register(subscriptionTarget);
                FMLLog.fine("Injected @EventBusSubscriber class %s", targ.getClassName());
            }
        }
        catch (Exception e)
        {
            FMLLog.log(Level.ERROR, e, "An error occurred trying to load an EventBusSubscriber %s for modid %s", targ.getClassName(), mod.getModId());
            throw new LoaderException(e);
        }
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:34,代码来源:AutomaticEventSubscriber.java

示例12: setupTestHarness

import net.minecraftforge.fml.common.discovery.ASMDataTable; //导入依赖的package包/类
/**
 * Used to setup a testharness with a single dummy mod instance for use with various testing hooks
 * @param dummycontainer A dummy container that will be returned as "active" for all queries
 */
public void setupTestHarness(ModContainer dummycontainer)
{
    modController = new LoadController(this);
    mods = Lists.newArrayList(dummycontainer);
    modController.transition(LoaderState.LOADING, false);
    modController.transition(LoaderState.CONSTRUCTING, false);
    ObjectHolderRegistry.INSTANCE.findObjectHolders(new ASMDataTable());
    modController.forceActiveContainer(dummycontainer);
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:14,代码来源:Loader.java

示例13: FMLConstructionEvent

import net.minecraftforge.fml.common.discovery.ASMDataTable; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public FMLConstructionEvent(Object... eventData)
{
    this.modClassLoader = (ModClassLoader)eventData[0];
    this.asmData = (ASMDataTable) eventData[1];
    this.reverseDependencies = (ListMultimap<String, String>) eventData[2];
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:8,代码来源:FMLConstructionEvent.java

示例14: initTable

import net.minecraftforge.fml.common.discovery.ASMDataTable; //导入依赖的package包/类
public void initTable(ASMDataTable dataTable)
{
    optionals = ArrayListMultimap.create();
    Set<ASMData> interfaceLists = dataTable.getAll("net.minecraftforge.fml.common.Optional$InterfaceList");
    addData(unpackInterfaces(interfaceLists));
    Set<ASMData> interfaces = dataTable.getAll("net.minecraftforge.fml.common.Optional$Interface");
    addData(interfaces);
    Set<ASMData> methods = dataTable.getAll("net.minecraftforge.fml.common.Optional$Method");
    addData(methods);
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:11,代码来源:ModAPITransformer.java

示例15: getField

import net.minecraftforge.fml.common.discovery.ASMDataTable; //导入依赖的package包/类
public static Field getField(ASMDataTable.ASMData data)
{
	try
	{
		return getClass(data).getField(data.getObjectName());
	}
	catch (NoSuchFieldException e)
	{
		return null;
	}
}
 
开发者ID:InfinityStudio,项目名称:InspiringWorld,代码行数:12,代码来源:ASMDataUtil.java


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