Java 类net.minecraftforge.fml.common.eventhandler.IEventListener 实例源码

项目:TaleCraft    文件:ReflectionUtil.java   
@SuppressWarnings("unchecked")
public static List<IEventListener> getEventListeners(World world){
    if(eventlisteners.containsKey(world)) return eventlisteners.get(world);
    try{
        List<IEventListener> list = null;
        for(Field field : World.class.getDeclaredFields()){
            if(field.getType() == World.class){
                field.setAccessible(true);
                list = (List<IEventListener>) field.get(world);
                break;
            }
        }

        eventlisteners.put(world, list);
        return list;
    }catch(Exception e){
        e.printStackTrace();
    }
    return null;
}
项目:PixelmonTechnicFix    文件:Main.java   
public static void fix() throws Exception
{
    Field f = MinecraftForge.EVENT_BUS.getClass().getDeclaredField("listeners");
    f.setAccessible(true);
    ConcurrentHashMap<Object, ArrayList<IEventListener>> listeners = (ConcurrentHashMap<Object, ArrayList<IEventListener>>) f.get(MinecraftForge.EVENT_BUS);
    for(Map.Entry<Object, ArrayList<IEventListener>> entry : listeners.entrySet())
    {
        if (entry.getKey().getClass().equals(SensitiveCode.class))
        {
            MinecraftForge.EVENT_BUS.unregister(entry.getKey());
            Pixelmon.EVENT_BUS.unregister(entry.getKey());
            SpawnerBase.SPAWN_DENIAL_BUS.unregister(entry.getKey());
            return;
        }
    }
}
项目:airbreathercore    文件:ModLifecycleManager.java   
@Override
public void OnPreInit(FMLPreInitializationEvent event)
{
    checkNotNull(event, "event");
    this.configuration.Initialize(event.getSuggestedConfigurationFile());

    // Register all the new items
    // (do this before registering the things that may depend on them)
    ItemConfiguration itemConfiguration = this.configuration.GetItemConfiguration();
    this.itemRegistrar.RegisterNewItems(itemConfiguration, this.itemRegistry);

    // Register all the event handlers.
    this.eventSubscriber.Initialize();
    EventConfiguration eventConfiguration = this.configuration.GetEventConfiguration();
    for (EventType eventType : eventConfiguration.GetRecognizedEventTypes())
    {
        for (IEventListener handler : eventConfiguration.GetEventHandlers(eventType))
        {
            this.eventSubscriber.SubscribeToEvent(eventType, handler);
        }
    }
}
项目:airbreathercore    文件:ForgeEventSubscriber.java   
@Override
public void SubscribeToEvent(EventType eventType, IEventListener handler)
{
    checkNotNull(handler, "handler");
    synchronized(this.eventListenerMap)
    {
        this.eventListenerMap.put(eventType, handler);
    }
}
项目:airbreathercore    文件:ForgeEventSubscriber.java   
@SubscribeEvent
public void OnLivingDropsEvent(LivingDropsEvent event)
{
    checkNotNull(event, "event");
    for (IEventListener handler : eventListenerMap.get(EventType.LivingDrops))
    {
        handler.invoke(event);
    }
}
项目:airbreathercore    文件:ForgeEventSubscriber.java   
@SubscribeEvent
public void OnLivingUpdateEvent(LivingUpdateEvent event)
{
    checkNotNull(event, "event");
    for (IEventListener handler : eventListenerMap.get(EventType.LivingUpdate))
    {
        handler.invoke(event);
    }
}
项目:airbreathercore    文件:ForgeEventSubscriber.java   
@SubscribeEvent
public void OnEntityConstructingEvent(EntityConstructing event)
{
    checkNotNull(event, "event");
    for (IEventListener handler : eventListenerMap.get(EventType.EntityConstructing))
    {
        handler.invoke(event);
    }
}
项目:Alchemy    文件:EventHelper.java   
static IEventListener[] getAllHandler(Class<? extends Event> clazz, int busId) {
    ListenerList list = ReflectionHelper.allocateInstance(clazz).getListenerList();
    return list == null ? new IEventListener[0] : list.lists[busId].getListeners();
}
项目:airbreathercore    文件:EmptyEventConfiguration.java   
@Override
public Iterable<IEventListener> GetEventHandlers(EventType eventType)
{
    return ImmutableList.of();
}
项目:airbreathercore    文件:EventConfiguration.java   
Iterable<IEventListener> GetEventHandlers(EventType eventType);
项目:airbreathercore    文件:EventSubscriber.java   
void SubscribeToEvent(EventType eventType, IEventListener handler);