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


Java FMLEvent类代码示例

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


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

示例1: handleModStateEvent

import cpw.mods.fml.common.event.FMLEvent; //导入依赖的package包/类
@Subscribe
public void handleModStateEvent(FMLEvent event)
{
    if (!eventMethods.containsKey(event.getClass()))
    {
        return;
    }
    try
    {
        for (Method m : eventMethods.get(event.getClass()))
        {
            m.invoke(modInstance, event);
        }
    }
    catch (Throwable t)
    {
        controller.errorOccurred(this, t);
    }
}
 
开发者ID:SchrodingersSpy,项目名称:TRHS_Club_Mod_2016,代码行数:20,代码来源:FMLModContainer.java

示例2: propogateStateMessage

import cpw.mods.fml.common.event.FMLEvent; //导入依赖的package包/类
@Subscribe
public void propogateStateMessage(FMLEvent stateEvent)
{
    if (stateEvent instanceof FMLPreInitializationEvent)
    {
        modObjectList = buildModObjectList();
    }
    ProgressBar bar = ProgressManager.push(stateEvent.description(), activeModList.size());
    for (ModContainer mc : activeModList)
    {
        bar.step(mc.getName());
        sendEventToModContainer(stateEvent, mc);
    }
    ProgressManager.pop(bar);
}
 
开发者ID:SchrodingersSpy,项目名称:TRHS_Club_Mod_2016,代码行数:16,代码来源:LoadController.java

示例3: sendEventToModContainer

import cpw.mods.fml.common.event.FMLEvent; //导入依赖的package包/类
private void sendEventToModContainer(FMLEvent stateEvent, ModContainer mc)
{
    String modId = mc.getModId();
    Collection<String> requirements =  Collections2.transform(mc.getRequirements(),new ArtifactVersionNameFunction());
    for (ArtifactVersion av : mc.getDependencies())
    {
        if (av.getLabel()!= null && requirements.contains(av.getLabel()) && modStates.containsEntry(av.getLabel(),ModState.ERRORED))
        {
            FMLLog.log(modId, Level.ERROR, "Skipping event %s and marking errored mod %s since required dependency %s has errored", stateEvent.getEventType(), modId, av.getLabel());
            modStates.put(modId, ModState.ERRORED);
            return;
        }
    }
    activeContainer = mc;
    stateEvent.applyModContainer(activeContainer());
    ThreadContext.put("mod", modId);
    FMLLog.log(modId, Level.TRACE, "Sending event %s to mod %s", stateEvent.getEventType(), modId);
    eventChannels.get(modId).post(stateEvent);
    FMLLog.log(modId, Level.TRACE, "Sent event %s to mod %s", stateEvent.getEventType(), modId);
    ThreadContext.remove("mod");
    activeContainer = null;
    if (stateEvent instanceof FMLStateEvent)
    {
        if (!errors.containsKey(modId))
        {
            modStates.put(modId, ((FMLStateEvent)stateEvent).getModState());
        }
        else
        {
            modStates.put(modId, ModState.ERRORED);
        }
    }
}
 
开发者ID:SchrodingersSpy,项目名称:TRHS_Club_Mod_2016,代码行数:34,代码来源:LoadController.java

示例4: gatherAnnotations

import cpw.mods.fml.common.event.FMLEvent; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private Method gatherAnnotations(Class<?> clazz) throws Exception
{
    Method factoryMethod = null;
    for (Method m : clazz.getDeclaredMethods())
    {
        for (Annotation a : m.getAnnotations())
        {
            if (a.annotationType().equals(Mod.EventHandler.class))
            {
                if (m.getParameterTypes().length == 1 && FMLEvent.class.isAssignableFrom(m.getParameterTypes()[0]))
                {
                    m.setAccessible(true);
                    eventMethods.put((Class<? extends FMLEvent>) m.getParameterTypes()[0],m);
                }
                else
                {
                    FMLLog.log(getModId(), Level.ERROR,"The mod %s appears to have an invalid event annotation %s. This annotation can only apply to methods with recognized event arguments - it will not be called", getModId(), a.annotationType().getSimpleName());
                }
            }
            else if (a.annotationType().equals(Mod.InstanceFactory.class))
            {
                if (Modifier.isStatic(m.getModifiers()) && m.getParameterTypes().length == 0 && factoryMethod == null)
                {
                    m.setAccessible(true);
                    factoryMethod = m;
                }
                else if (!(Modifier.isStatic(m.getModifiers()) && m.getParameterTypes().length == 0))
                {
                    FMLLog.log(getModId(),  Level.ERROR, "The InstanceFactory annotation can only apply to a static method, taking zero arguments - it will be ignored on %s(%s)", m.getName(), Arrays.asList(m.getParameterTypes()));
                }
                else if (factoryMethod != null)
                {
                    FMLLog.log(getModId(), Level.ERROR, "The InstanceFactory annotation can only be used once, the application to %s(%s) will be ignored", m.getName(), Arrays.asList(m.getParameterTypes()));
                }
            }
        }
    }
    return factoryMethod;
}
 
开发者ID:SchrodingersSpy,项目名称:TRHS_Club_Mod_2016,代码行数:41,代码来源:FMLModContainer.java

示例5: propogateStateMessage

import cpw.mods.fml.common.event.FMLEvent; //导入依赖的package包/类
@Subscribe
public void propogateStateMessage(FMLEvent stateEvent)
{
    if (stateEvent instanceof FMLPreInitializationEvent)
    {
        modObjectList = buildModObjectList();
    }
    for (ModContainer mc : activeModList)
    {
        sendEventToModContainer(stateEvent, mc);
    }
}
 
开发者ID:alexandrage,项目名称:CauldronGit,代码行数:13,代码来源:LoadController.java

示例6: sendEventToModContainer

import cpw.mods.fml.common.event.FMLEvent; //导入依赖的package包/类
private void sendEventToModContainer(FMLEvent stateEvent, ModContainer mc)
{
    String modId = mc.getModId();
    Collection<String> requirements =  Collections2.transform(mc.getRequirements(),new ArtifactVersionNameFunction());
    for (ArtifactVersion av : mc.getDependencies())
    {
        if (av.getLabel()!= null && requirements.contains(av.getLabel()) && modStates.containsEntry(av.getLabel(),ModState.ERRORED))
        {
            FMLLog.log(modId, Level.SEVERE, "Skipping event %s and marking errored mod %s since required dependency %s has errored", stateEvent.getEventType(), modId, av.getLabel());
            modStates.put(modId, ModState.ERRORED);
            return;
        }
    }
    activeContainer = mc;
    stateEvent.applyModContainer(activeContainer());
    FMLLog.log(modId, Level.FINEST, "Sending event %s to mod %s", stateEvent.getEventType(), modId);
    eventChannels.get(modId).post(stateEvent);
    FMLLog.log(modId, Level.FINEST, "Sent event %s to mod %s", stateEvent.getEventType(), modId);
    activeContainer = null;
    if (stateEvent instanceof FMLStateEvent)
    {
        if (!errors.containsKey(modId))
        {
            modStates.put(modId, ((FMLStateEvent)stateEvent).getModState());
        }
        else
        {
            modStates.put(modId, ModState.ERRORED);
        }
    }
}
 
开发者ID:HATB0T,项目名称:RuneCraftery,代码行数:32,代码来源:LoadController.java

示例7: gatherAnnotations

import cpw.mods.fml.common.event.FMLEvent; //导入依赖的package包/类
private Method gatherAnnotations(Class<?> clazz) throws Exception
{
    Method factoryMethod = null;
    for (Method m : clazz.getDeclaredMethods())
    {
        for (Annotation a : m.getAnnotations())
        {
            if (modTypeAnnotations.containsKey(a.annotationType()))
            {
                Class<?>[] paramTypes = new Class[] { modTypeAnnotations.get(a.annotationType()) };
                if (Arrays.equals(m.getParameterTypes(), paramTypes))
                {
                    m.setAccessible(true);
                    eventMethods.put(modTypeAnnotations.get(a.annotationType()), m);
                }
                else
                {
                    FMLLog.log(getModId(), Level.SEVERE,"The mod %s appears to have an invalid method annotation %s. This annotation can only apply to methods with argument types %s -it will not be called", getModId(), a.annotationType().getSimpleName(), Arrays.toString(paramTypes));
                }
            }
            else if (a.annotationType().equals(Mod.EventHandler.class))
            {
                if (m.getParameterTypes().length == 1 && modAnnotationTypes.containsKey(m.getParameterTypes()[0]))
                {
                    m.setAccessible(true);
                    eventMethods.put((Class<? extends FMLEvent>) m.getParameterTypes()[0],m);
                }
                else
                {
                    FMLLog.log(getModId(), Level.SEVERE,"The mod %s appears to have an invalid event annotation %s. This annotation can only apply to methods with recognized event arguments - it will not be called", getModId(), a.annotationType().getSimpleName());
                }
            }
            else if (a.annotationType().equals(Mod.InstanceFactory.class))
            {
                if (Modifier.isStatic(m.getModifiers()) && m.getParameterTypes().length == 0 && factoryMethod == null)
                {
                    m.setAccessible(true);
                    factoryMethod = m;
                }
                else if (!(Modifier.isStatic(m.getModifiers()) && m.getParameterTypes().length == 0))
                {
                    FMLLog.log(getModId(),  Level.SEVERE, "The InstanceFactory annotation can only apply to a static method, taking zero arguments - it will be ignored on %s(%s)", m.getName(), Arrays.asList(m.getParameterTypes()));
                }
                else if (factoryMethod != null)
                {
                    FMLLog.log(getModId(), Level.SEVERE, "The InstanceFactory annotation can only be used once, the application to %s(%s) will be ignored", m.getName(), Arrays.asList(m.getParameterTypes()));
                }
            }
        }
    }
    return factoryMethod;
}
 
开发者ID:HATB0T,项目名称:RuneCraftery,代码行数:53,代码来源:FMLModContainer.java

示例8: init

import cpw.mods.fml.common.event.FMLEvent; //导入依赖的package包/类
@EventHandler
public void init(FMLEvent event) {

}
 
开发者ID:digital-crafting-habitat,项目名称:dch_hack1ng_d4ys_workshop,代码行数:5,代码来源:HelloWorldOre.java


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