本文整理汇总了Java中cpw.mods.fml.common.eventhandler.EventBus类的典型用法代码示例。如果您正苦于以下问题:Java EventBus类的具体用法?Java EventBus怎么用?Java EventBus使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EventBus类属于cpw.mods.fml.common.eventhandler包,在下文中一共展示了EventBus类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getBusID
import cpw.mods.fml.common.eventhandler.EventBus; //导入依赖的package包/类
private int getBusID(EventBus a) {
try {
Field declaredField = EventBus.class.getDeclaredField("busID");
declaredField.setAccessible(true);
return declaredField.getInt(a);
} catch (Exception ex) {
return 0;
}
}
示例2: fireNetRegistrationEvent
import cpw.mods.fml.common.eventhandler.EventBus; //导入依赖的package包/类
@Override
public void fireNetRegistrationEvent(EventBus bus, NetworkManager manager, Set<String> channelSet, String channel, Side side)
{
if (side == Side.CLIENT)
{
waitForPlayClient();
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));
}
}
示例3: MEItemAspectBridgeContainer
import cpw.mods.fml.common.eventhandler.EventBus; //导入依赖的package包/类
/**
* Constructs a pseudo container that TC can use to 'see' the items in the
* ME network.
*
* @param inventorySize
* @throws Exception
* When the TC rendering code can not be found, the bridge will not
* construct.
*/
public MEItemAspectBridgeContainer( final int inventorySize ) throws Exception
{
// Create the inventory
this.internalInventory = new TheInternalInventory( "TC Inventory Bridge", inventorySize, 1 );
// Have we hooked to TC's event handler?
if( thaumcraftClientEvents.get() == null )
{
// Access the listenerOwners field
Field loField = EventBus.class.getDeclaredField( "listenerOwners" );
loField.setAccessible( true );
// Get the owners
Map<Object, ModContainer> owners = (Map<Object, ModContainer>)loField.get( FMLCommonHandler.instance().bus() );
// Attempt to locate TC's event handler
for( Entry<Object, ModContainer> set : owners.entrySet() )
{
Object Owner = set.getKey();
if( Owner instanceof thaumcraft.client.lib.ClientTickEventsFML )
{
thaumcraftClientEvents = new WeakReference<ClientTickEventsFML>( (ClientTickEventsFML)Owner );
break;
}
}
// Get rid of the references, cause I'm paranoid.
owners = null;
loField = null;
// Did we locate it?
if( thaumcraftClientEvents == null )
{
throw new Exception( "Unable to find TC event handler" );
}
}
}
示例4: register
import cpw.mods.fml.common.eventhandler.EventBus; //导入依赖的package包/类
public void register(IEventListener listener, EventBus bus, Class<? extends Event> clazz) {
try {
clazz.newInstance().getListenerList().register(getBusID(bus), EventPriority.NORMAL, listener);
} catch (Exception e) {
}
}
示例5: unregister
import cpw.mods.fml.common.eventhandler.EventBus; //导入依赖的package包/类
public void unregister(IEventListener listener, EventBus bus, Class<? extends Event> clazz) {
try {
clazz.newInstance().getListenerList().unregister(getBusID(bus), listener);
} catch (Exception e) {
}
}
示例6: fireNetRegistrationEvent
import cpw.mods.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));
}
示例7: FMLEventChannel
import cpw.mods.fml.common.eventhandler.EventBus; //导入依赖的package包/类
FMLEventChannel(String name)
{
this.channels = NetworkRegistry.INSTANCE.newChannel(name, new NetworkEventFiringHandler(this));
this.eventBus = new EventBus();
}
示例8: HandlerType
import cpw.mods.fml.common.eventhandler.EventBus; //导入依赖的package包/类
private HandlerType(String eventIdentifier, EventBus bus) {
this.eventIdentifier = eventIdentifier;
this.bus = bus;
}
示例9: listen
import cpw.mods.fml.common.eventhandler.EventBus; //导入依赖的package包/类
public void listen(EventBus eventBus)
{
eventBus.register(this);
}
示例10: registerEventHandlers
import cpw.mods.fml.common.eventhandler.EventBus; //导入依赖的package包/类
@Override
public void registerEventHandlers(EventBus bus) {
MinecraftForge.EVENT_BUS.register(DrawBlockHighlightEventHandler.getInstance());
}
示例11: bus
import cpw.mods.fml.common.eventhandler.EventBus; //导入依赖的package包/类
/**
* The FML event bus. Subscribe here for FML related events
*
* @return the event bus
*/
public EventBus bus()
{
return eventBus;
}
示例12: registerEventHandlers
import cpw.mods.fml.common.eventhandler.EventBus; //导入依赖的package包/类
@Override
public void registerEventHandlers(EventBus bus) {
bus.register(TickEventHandler.getInstance());
}
示例13: fireNetRegistrationEvent
import cpw.mods.fml.common.eventhandler.EventBus; //导入依赖的package包/类
void fireNetRegistrationEvent(EventBus bus, NetworkManager manager, Set<String> channelSet, String channel, Side side);
示例14: registerEventHandlers
import cpw.mods.fml.common.eventhandler.EventBus; //导入依赖的package包/类
void registerEventHandlers(EventBus bus);