Home Commands Examples Getting Started With Scripts Global Keywords
BracketDumpers BracketHandlers BracketValidators ResourceLocationBracketHandler

EventManager

Importing the class

If you need to reference this type directly, like when casting an Array, or as a parameter, you will need to import it. Simply add the import at the top of the file.

script.zs
import crafttweaker.api.events.EventManager;

Description

Manages the registration and handling of custom handlers for the various events of the game.

You can register event handlers for pretty much everything, but make sure that the class you are referencing is documented as an event, otherwise you're in for a nasty surprise.

Members

register(consumer as function(t as T) as void)
Registers a new event listener.
script.zs
// ZenEventManager.register<T>(consumer as function(t as T) as void);
myZenEventManager.register<T>(myConsumer);

Parameters:

consumer Type: function(t as T) as void - The event handler.
register(phase as ZenEventPhase, consumer as function(t as T) as void)
Registers a new event listener for the specified ZenEventPhase.
script.zs
// ZenEventManager.register<T>(phase as ZenEventPhase, consumer as function(t as T) as void);
myZenEventManager.register<T>(myZenEventPhase, myConsumer);

Parameters:

phase Type: EventPhase - The phase on which the event should be registered.
consumer Type: function(t as T) as void - The event handler.
register(listenToCanceled as bool, consumer as function(t as T) as void)
Registers a new event listener that can listen to cancelled events.
script.zs
// ZenEventManager.register<T>(listenToCanceled as bool, consumer as function(t as T) as void);
myZenEventManager.register<T>(myBool, myConsumer);

Parameters:

listenToCanceled Type: bool - Whether cancelled events should also be listened to or not.
consumer Type: function(t as T) as void - The event handler.
register(phase as ZenEventPhase, listenToCanceled as bool, consumer as function(t as T) as void)
Registers a new event listener for the specified ZenEventPhase that can listen to cancelled events.
script.zs
// ZenEventManager.register<T>(phase as ZenEventPhase, listenToCanceled as bool, consumer as function(t as T) as void);
myZenEventManager.register<T>(myZenEventPhase, myBool, myConsumer);

Parameters:

phase Type: EventPhase - The phase on which the event should be registered.
listenToCanceled Type: bool - Whether cancelled events should also be listened to or not.
consumer Type: function(t as T) as void - The event handler.