本文整理汇总了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);
}
}
示例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();
}
}
示例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();
}
示例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());
}
}
示例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));
}
}
示例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;
}
示例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;}
}
示例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();
}
示例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());
}
示例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));
}
示例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();
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}