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


Java EventBus类代码示例

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


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

示例1: onAdded

import net.minecraftforge.fml.common.eventhandler.EventBus; //导入依赖的package包/类
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);
    }
}
 
开发者ID:joshiejack,项目名称:Progression,代码行数:26,代码来源:EventsManager.java

示例2: onRemoved

import net.minecraftforge.fml.common.eventhandler.EventBus; //导入依赖的package包/类
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();
    }
}
 
开发者ID:joshiejack,项目名称:Progression,代码行数:26,代码来源:EventsManager.java

示例3: forgePreInitialization

import net.minecraftforge.fml.common.eventhandler.EventBus; //导入依赖的package包/类
@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();
}
 
开发者ID:a1lic,项目名称:McMod-CubicVillager,代码行数:20,代码来源:CubicVillager.java

示例4: subscribeClient

import net.minecraftforge.fml.common.eventhandler.EventBus; //导入依赖的package包/类
@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());
	}
}
 
开发者ID:V0idWa1k3r,项目名称:VoidApi,代码行数:13,代码来源:VoidClient.java

示例5: fireNetRegistrationEvent

import net.minecraftforge.fml.common.eventhandler.EventBus; //导入依赖的package包/类
@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));
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:13,代码来源:FMLClientHandler.java

示例6: hackDisableEventBus

import net.minecraftforge.fml.common.eventhandler.EventBus; //导入依赖的package包/类
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;
}
 
开发者ID:cyanobacterium,项目名称:AdditionalLootTables,代码行数:10,代码来源:AdditionalLootTables.java

示例7: getRegisterMethod

import net.minecraftforge.fml.common.eventhandler.EventBus; //导入依赖的package包/类
/**
 * 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;}
}
 
开发者ID:MrNobody98,项目名称:morecommands,代码行数:13,代码来源:EventHandler.java

示例8: forgeInitialization

import net.minecraftforge.fml.common.eventhandler.EventBus; //导入依赖的package包/类
@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();
}
 
开发者ID:a1lic,项目名称:McMod-CubicVillager,代码行数:12,代码来源:CubicVillager.java

示例9: construct

import net.minecraftforge.fml.common.eventhandler.EventBus; //导入依赖的package包/类
@EventHandler
public void construct(FMLConstructionEvent event) {
    EventBus bus = MinecraftForge.EVENT_BUS;
    bus.register(proxy);
    bus.register(new SelectionListener());
}
 
开发者ID:kenzierocks,项目名称:HardVox,代码行数:7,代码来源:HardVox.java

示例10: fireNetRegistrationEvent

import net.minecraftforge.fml.common.eventhandler.EventBus; //导入依赖的package包/类
@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));
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:6,代码来源:FMLServerHandler.java

示例11: FMLEventChannel

import net.minecraftforge.fml.common.eventhandler.EventBus; //导入依赖的package包/类
FMLEventChannel(String name)
{
    this.channels = NetworkRegistry.INSTANCE.newChannel(name, new NetworkEventFiringHandler(this));
    this.eventBus = new EventBus();
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:6,代码来源:FMLEventChannel.java

示例12: MinecraftBackdoor

import net.minecraftforge.fml.common.eventhandler.EventBus; //导入依赖的package包/类
public MinecraftBackdoor(WolTestEnvironment testEnv, EventBus eventBus) {
  this.testEnv = testEnv;
  this.eventBus = eventBus;
  this.player = new PlayerBackdoor(testEnv);
}
 
开发者ID:wizards-of-lua,项目名称:wizards-of-lua,代码行数:6,代码来源:MinecraftBackdoor.java

示例13: unregister

import net.minecraftforge.fml.common.eventhandler.EventBus; //导入依赖的package包/类
static void unregister(EventBus bus, Class<?> hanlder) {
	bus.listenerOwners.keySet().stream().filter(hanlder::isInstance).forEach(bus::unregister);
}
 
开发者ID:NekoCaffeine,项目名称:Alchemy,代码行数:4,代码来源:EventHelper.java

示例14:

import net.minecraftforge.fml.common.eventhandler.EventBus; //导入依赖的package包/类
public static boolean net$minecraft$client$multiplayer$WorldClient$init(EventBus bus, WorldEvent.Load event) {
    return HookTargetsClient.abortClientLoadEvent(bus, event);
}
 
开发者ID:purpleposeidon,项目名称:Factorization,代码行数:4,代码来源:MethodSplices.java

示例15: abortClientLoadEvent

import net.minecraftforge.fml.common.eventhandler.EventBus; //导入依赖的package包/类
public static boolean abortClientLoadEvent(EventBus bus, WorldEvent.Load event) {
    if (clientWorldLoadEventAbort.get() == Boolean.TRUE) return false;
    return bus.post(event);
}
 
开发者ID:purpleposeidon,项目名称:Factorization,代码行数:5,代码来源:HookTargetsClient.java


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