-
Notifications
You must be signed in to change notification settings - Fork 10
GenericEventManager
youyihj edited this page Feb 21, 2024
·
6 revisions
@since 1.16.0
GenericEventManager is an expansion of CraftTweaker event manager, adds a method to register handler for almost all events. In addition, it adds event priority and receive canceled parameter, making possible to control other mod logic that listen to the same event.
events.register(IEventHandler<T> eventHandler, @Optional EventPriority priority, @Optional bool receiveCanceled)
import crafttweaker.event.EntityLivingAttackedEvent;
import mods.zenutils.EventPriority;
// This event listener is registered at lowest priority and would receive canceled
// It always runs after all other event handlers no matter the event is canceled or not
events.register(function(event as EntityLivingAttackedEvent) {
event.entity.sendMessage("The event is canceled: " ~ event.canceled);
}, EventPriority.lowest(), true);
// Old way
// This event listener is registered at normal priority
events.onEntityLivingAttacked(function(event as EntityLivingAttackedEvent) {
event.cancel();
});
Defines the priority of the event listener
Package: mods.zenutils.EventPriority
5 priorities are available:
highest
high
-
normal
(default) low
lowest
This method directly accesses forge event internal code. Only events that simply delegate forge events can use it.
Known unavailable events:
CraftTweaker:
- PlayerLoggedIn
- PlayerLoggedOut
- PlayerSmelted
ZenUtils:
- EntityRemove
- EntityItemFall
- EntityItemDeath
- GlobalFunctions
- ScriptReloading
- SuppressErrorPreprocessor
- HardFailPreprocessor
- OrderlyMap
- IData Deep Update
- Template String
- Native Method Access
- Mixin
- CrTI18n
- CrTUUID
- CrTItemHandler
- CrTLiquidHandler
- ILiquidTankProperties
- StringList
- HexHelper
- StaticString
- Catenation
- PersistedCatenation
- PlayerStat
- IStatFormatter
- GameRuleHelper
- ZenCommand
- ZenCommandTree
- ZenUtilsCommandSender
- IGetCommandUsage
- ICommandExecute
- IGetTabCompletion
- CommandUtils