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

项目:Progression    文件:EventsManager.java   
public void onAdded(IRule eventType) {
    active.add(getGenericFromType(eventType));
    HashSet activeTypes = new HashSet();
    for (IRule existing: active) {
        activeTypes.add(existing.getProvider().getUnlocalisedName());
    }

    for (IRuleProvider provider: getCollectionFromType(eventType)) {
        if (activeTypes.contains(provider.getUnlocalisedName())) {
            try {
                IRule type = provider.getProvided();
                if (type instanceof IHasEventBus) {
                    EventBus bus = ((IHasEventBus) type).getEventBus();
                    if (bus != null) {
                        bus.register(type);
                    }
                }
            } catch (Exception e) {}
        }
    }

    if (eventType instanceof IReward) {
        ((IReward)eventType).onAdded(this == client);
    }
}
项目:Progression    文件:EventsManager.java   
public void onRemoved(IRule eventType) {
    active.remove(getGenericFromType(eventType));
    HashSet activeTypes = new HashSet();
    for (IRule existing: active) {
        activeTypes.add(existing.getProvider().getUnlocalisedName());
    }

    for (IRuleProvider provider: getCollectionFromType(eventType)) {
        if (!activeTypes.contains(provider.getUnlocalisedName())) {
            try {
                IRule type = provider.getProvided();
                if (type instanceof IHasEventBus) {
                    EventBus bus = ((IHasEventBus) type).getEventBus();
                    if (bus != null) {
                        bus.unregister(type);
                    }
                }
            } catch (Exception e) {}
        }
    }

    if (eventType instanceof IReward) {
        ((IReward)eventType).onRemoved();
    }
}
项目:McMod-CubicVillager    文件:CubicVillager.java   
@Mod.EventHandler
public void forgePreInitialization(FMLPreInitializationEvent event)
{
    // RegistryEvent.Register(registerItems、registerBlocks)が呼ばれるようにする。
    EventBus bus = MinecraftForge.EVENT_BUS;
    bus.register(this);

    config = new ModConfig(event.getSuggestedConfigurationFile());
    config.syncConfig();

    this.meta.description = "Make your auto-trading system!!\n自動的に取引を行えるシステムを作るためのMODです。";
    this.meta.url = "https://a1lic.net/";
    this.meta.authorList.add("alice");
    this.meta.credits = "alice";
    // falseにしないとMod listで情報が出ない。
    this.meta.autogenerated = false;

    proxy.preInit();
}
项目:VoidApi    文件:VoidClient.java   
@Override
public void subscribeClient(String classname, EventBus bus)
{
    try
    {
        bus.register(Class.forName(classname).newInstance());
    }
    catch (Exception ex)
    {
        VCLoggers.loggerErrors.log(LogLevel.Error, "Could not subscribe %s to %s on client-only side!!", ex, classname, bus.toString());
    }
}
项目:CustomWorldGen    文件:FMLClientHandler.java   
@Override
public void fireNetRegistrationEvent(EventBus bus, NetworkManager manager, Set<String> channelSet, String channel, Side side)
{
    if (side == Side.CLIENT)
    {
        bus.post(new FMLNetworkEvent.CustomPacketRegistrationEvent<NetHandlerPlayClient>(manager, channelSet, channel, side, NetHandlerPlayClient.class));
    }
    else
    {
        bus.post(new FMLNetworkEvent.CustomPacketRegistrationEvent<NetHandlerPlayServer>(manager, channelSet, channel, side, NetHandlerPlayServer.class));
    }
}
项目:AdditionalLootTables    文件:AdditionalLootTables.java   
private static Object hackDisableEventBus() throws NoSuchFieldException, IllegalAccessException {
    Object cache = MinecraftForge.EVENT_BUS;
    Field busField = MinecraftForge.class.getDeclaredField(fieldName_EVENT_BUS);
    busField.setAccessible(true);
    removeFinalModifierFromField(busField);
    busField.set(null,new EventBus());

    return cache;
}
项目:morecommands    文件:EventHandler.java   
/**
 * Gets the private "internal" register method of the {@link EventBus}
 * @see ForgeEventHandler#register
 */
private static Method getRegisterMethod() {
    try {
        Method register = EventBus.class.getDeclaredMethod("register", Class.class, Object.class, Method.class, ModContainer.class);
        register.setAccessible(true);
        return register;
    }
    catch (Exception ex) {ex.printStackTrace(); return null;}
}
项目:McMod-CubicVillager    文件:CubicVillager.java   
@Mod.EventHandler
public void forgeInitialization(FMLInitializationEvent event)
{
    EventBus bus = MinecraftForge.EVENT_BUS;
    bus.register(this.config);
    //bus.register(new CraftingEvent());
    bus.register(new MyPlayerEvent());
    bus.register(new VillagerEvent());

    proxy.init();
}
项目:HardVox    文件:HardVox.java   
@EventHandler
public void construct(FMLConstructionEvent event) {
    EventBus bus = MinecraftForge.EVENT_BUS;
    bus.register(proxy);
    bus.register(new SelectionListener());
}
项目:CustomWorldGen    文件:FMLServerHandler.java   
@Override
public void fireNetRegistrationEvent(EventBus bus, NetworkManager manager, Set<String> channelSet, String channel, Side side)
{
    bus.post(new FMLNetworkEvent.CustomPacketRegistrationEvent<NetHandlerPlayServer>(manager, channelSet, channel, side, NetHandlerPlayServer.class));
}
项目:CustomWorldGen    文件:FMLEventChannel.java   
FMLEventChannel(String name)
{
    this.channels = NetworkRegistry.INSTANCE.newChannel(name, new NetworkEventFiringHandler(this));
    this.eventBus = new EventBus();
}
项目:wizards-of-lua    文件:MinecraftBackdoor.java   
public MinecraftBackdoor(WolTestEnvironment testEnv, EventBus eventBus) {
  this.testEnv = testEnv;
  this.eventBus = eventBus;
  this.player = new PlayerBackdoor(testEnv);
}
项目:Alchemy    文件:EventHelper.java   
static void unregister(EventBus bus, Class<?> hanlder) {
    bus.listenerOwners.keySet().stream().filter(hanlder::isInstance).forEach(bus::unregister);
}
项目:Factorization    文件:MethodSplices.java   
public static boolean net$minecraft$client$multiplayer$WorldClient$init(EventBus bus, WorldEvent.Load event) {
    return HookTargetsClient.abortClientLoadEvent(bus, event);
}
项目:Factorization    文件:MethodSplices.java   
public static boolean bdb$init(EventBus bus, WorldEvent.Load event) {
    // This is me being lazy. Dealing with names is obnoxious. Hopefully we can get this gone when we port to 1.9?
    return HookTargetsClient.abortClientLoadEvent(bus, event);
}
项目:Factorization    文件:HookTargetsClient.java   
public static boolean abortClientLoadEvent(EventBus bus, WorldEvent.Load event) {
    if (clientWorldLoadEventAbort.get() == Boolean.TRUE) return false;
    return bus.post(event);
}
项目:morecommands    文件:EventHandler.java   
private ForgeEventHandler(EventBus bus, Class<T> eventClass, boolean clientOnly) {
    super(eventClass, clientOnly);
    this.bus = bus;
}
项目:morecommands    文件:EventHandler.java   
/**
 * @return The bus on which the handler shall be registered
 */
public final EventBus getBus() {
    return this.bus;
}
项目:Progression    文件:IHasEventBus.java   
/** Return which event bus this should be returned to **/
public EventBus getEventBus();
项目:Progression    文件:RewardShowTab.java   
@Override
public EventBus getEventBus() {
    return MinecraftForge.EVENT_BUS;
}
项目:Progression    文件:RewardBaseAbility.java   
@Override
public EventBus getEventBus() {
    return MinecraftForge.EVENT_BUS;
}
项目:Progression    文件:TriggerBase.java   
@Override
public EventBus getEventBus() {
    return MinecraftForge.EVENT_BUS;
}
项目:Progression    文件:TriggerPoints.java   
@Override
public EventBus getEventBus() {
    return null;
}
项目:Progression    文件:FilterLastKilledEntity.java   
@Override
public EventBus getEventBus() {
    return MinecraftForge.EVENT_BUS;
}
项目:Progression    文件:FilterLastHitEntity.java   
@Override
public EventBus getEventBus() {
    return MinecraftForge.EVENT_BUS;
}
项目:Progression    文件:FilterPlayerLastBroken.java   
@Override
public EventBus getEventBus() {
    return MinecraftForge.EVENT_BUS;
}
项目:Progression    文件:ActionForgeEvent.java   
@Override
public EventBus getEventBus() {
    return MinecraftForge.EVENT_BUS;
}
项目:Progression    文件:RewardShowLayer.java   
@Override
public EventBus getEventBus() {
    return MinecraftForge.EVENT_BUS;
}
项目:morecommands    文件:EventHandler.java   
/**
 * Directly registers a method to an {@link EventBus} using the private {@link EventBus#register(Object)} method
 * This is useful e.g. for generic methods because their event class can't properly be determined because of type erasure
 * 
 * @param bus the event bus
 * @param eventClass the event class
 * @param target the event listener
 * @param method the listening method
 * @param mod the mod container
 * @return whether the listener was successfully registered
 */
public static <T extends Event> boolean registerMethodToEventBus(EventBus bus, Class<T> eventClass, Object target, Method method, ModContainer mod) {
    if (!method.isAnnotationPresent(SubscribeEvent.class)) return false;

    try {ForgeEventHandler.register.invoke(bus, eventClass, target, method, mod);}
    catch (Exception ex) {ex.printStackTrace(); return false;}

    return true;
}
项目:VoidApi    文件:VoidCommon.java   
public void subscribeClient(String classname, EventBus bus)
{

}
项目:CustomWorldGen    文件:FMLCommonHandler.java   
/**
 * The FML event bus. Subscribe here for FML related events
 *
 * @Deprecated Use {@link MinecraftForge#EVENT_BUS} they're the same thing now
 * @return the event bus
 */
@Deprecated
public EventBus bus()
{
    return eventBus;
}
项目:morecommands    文件:EventHandler.java   
/**
 * Creates a new forge event handler without registering it to the event bus. 
 * Use {@link ForgeEventHandler#registerForgeHandler(ForgeEventHandler, ModContainer)} to do that
 * 
 * @param <T> the event type
 * @param bus the event bus corresponding to the event
 * @param eventClass the event class
 * @param clientOnly whether this event is for client use only
 * @return the forge event handler
 */
public static <T extends Event> ForgeEventHandler<T> newForgeEventHandler(EventBus bus, Class<T> eventClass, boolean clientOnly) {
    ForgeEventHandler<T> handler = new ForgeEventHandler<T>(bus, eventClass, clientOnly);
    putEventHandlers(handler);
    return handler;
}
项目:morecommands    文件:EventHandler.java   
/**
 * Creates a new forge event handler and registers it immediately to the event bus
 * 
 * @param <T> the event type
 * @param bus the event bus corresponding to the event
 * @param eventClass the event class
 * @param clientOnly whether this event is for client use only
 * @param mod the mod container, needed by the event bus to register the event <br>
 * (retrievable via {@link net.minecraftforge.fml.common.Loader#activeModContainer()} or {@link net.minecraftforge.fml.common.Loader#getReversedModObjectList()})
 * @return the forge event handler
 */
public static <T extends Event> ForgeEventHandler<T> newForgeEventHandler(EventBus bus, Class<T> eventClass, boolean clientOnly, ModContainer mod) {
    ForgeEventHandler<T> handler = newForgeEventHandler(bus, eventClass, clientOnly);
    ForgeEventHandler.registerForgeHandler(handler, mod);
    return handler;
}
项目:CustomWorldGen    文件:IFMLSidedHandler.java   
void fireNetRegistrationEvent(EventBus bus, NetworkManager manager, Set<String> channelSet, String channel, Side side);