The IEventManager is what you're gonna need when dealing with event handlers.

Diese Klasse importieren

Link to diese-klasse-importieren

It might be required for you to import the class if you encounter any issues.
import crafttweaker.events.IEventManager;

Calling the event manager

Link to calling-the-event-manager

You can access the event manager using the global events field

How do events work?

Link to how-do-events-work

You can add a function that represents the event and from there on you can decide what you want CrT to do if such an event occurs.
The most important thing to remember is that you need to CAST THE EVENT TO IT'S TYPE! as otherwise you will not be able to access any if it's ZenGetters.
If you simply want to print something where you don't need to access the event, then it's fine.

ZenScript
Copy
events.onPlayerCrafted(function(event as crafttweaker.event.PlayerCraftedEvent){
    print("event".length);
    print(event.player.name);
    event.player.xp += 1;
});


events.onPlayerLoggedIn(function(event) {
    //event instanceof Object -> No way of accessing it, so better cast!
    print("SOMEONE HAS LOGGED IN!!!");
});

What events are available?

Link to what-events-are-available

The ZenMethods would be what you'll need to call on events, the Event Class would be what you need to cast the event as.

ZenMethodEvent-Klasse
ZenMethod
onAllowDespawn
Event-Klasse
crafttweaker.event.EntityLivingSpawnEvent
ZenMethod
onArrowLoose
Event-Klasse
crafttweaker.event.ArrowLooseEvent
ZenMethod
onArrowNock
Event-Klasse
crafttweaker.event.ArrowNockEvent
ZenMethod
onAnimalTame
Event-Klasse
crafttweaker.event.AnimalTameEvent
ZenMethod
onBlockBreak
Event-Klasse
crafttweaker.event.BlockBreakEvent
ZenMethod
onBlockHarvestDrops
Event-Klasse
crafttweaker.event.BlockHarvestDrops
ZenMethod
onBlockNeighborNotify
Event-Klasse
crafttweaker.event.BlockNeighborNotifyEvent
ZenMethod
onBlockPlace
Event-Klasse
crafttweaker.event.BlockPlaceEvent
ZenMethod
onCheckSpawn
Event-Klasse
crafttweaker.event.EntityLivingExtendedSpawnEvent
ZenMethod
onClientTick
Event-Klasse
crafttweaker.event.ClientTickEvent
ZenMethod
onCommand
Event-Klasse
crafttweaker.event.CommandEvent
ZenMethod
onCriticalHit
Event-Klasse
crafttweaker.event.CriticalHitEvent
ZenMethod
onCropGrowPost
Event-Klasse
crafttweaker.event.CropGrowPostEvent
ZenMethod
onCropGrowPre
Event-Klasse
crafttweaker.event.CropGrowPreEvent
ZenMethod
onEnchantmentLevelSet
Event-Klasse
crafttweaker.event.EnchantmentLevelSetEvent
ZenMethod
onEnderTeleport
Event-Klasse
crafttweaker.event.EnderTeleportEvent
ZenMethod
onEntityLivingAttacked
Event-Klasse
crafttweaker.event.EntityLivingAttackedEvent
ZenMethod
onEntityLivingDamage
Event-Klasse
crafttweaker.event.EntityLivingDamageEvent
ZenMethod
onEntityLivingDeath
Event-Klasse
crafttweaker.event.EntityLivingDeathEvent
ZenMethod
onEntityLivingDeathDrops
Event-Klasse
crafttweaker.event.EntityLivingDeathDropsEvent
ZenMethod
onEntityLivingEquipmentChange
Event-Klasse
crafttweaker.event.EntityLivingEquipmentChangeEvent
ZenMethod
onEntityLivingFall
Event-Klasse
crafttweaker.event.EntityLivingFallEvent
ZenMethod
onEntityLivingHeal
Event-Klasse
crafttweaker.event.EntityLivingHealEvent
ZenMethod
onEntityLivingHurt
Event-Klasse
crafttweaker.event.EntityLivingHurtEvent
ZenMethod
onEntityLivingJump
Event-Klasse
crafttweaker.event.EntityLivingJumpEvent
ZenMethod
onEntityLivingUpdate
Event-Klasse
crafttweaker.event.EntityLivingUpdateEvent
ZenMethod
onEntityLivingUseItem
Event-Klasse
crafttweaker.event.EntityLivingUseItemEvent.All
ZenMethod
onEntityLivingUseItemFinish
Event-Klasse
crafttweaker.event.EntityLivingUseItemEvent.Finish
ZenMethod
onEntityLivingUseItemStart
Event-Klasse
crafttweaker.event.EntityLivingUseItemEvent.Start
ZenMethod
onEntityLivingUseItemStop
Event-Klasse
crafttweaker.event.EntityLivingUseItemEvent.Stop
ZenMethod
onEntityLivingUseItemTick
Event-Klasse
crafttweaker.event.EntityLivingUseItemEvent.Tick
ZenMethod
onEntityJoinWorld
Event-Klasse
crafttweaker.event.EntityJoinWorldEvent
ZenMethod
onEntityMount
Event-Klasse
crafttweaker.event.EntityMountEvent
ZenMethod
onEntityTravelToDimension
Event-Klasse
crafttweaker.event.EntityTravelToDimensionEvent
ZenMethod
onEntityStruckByLightning
Event-Klasse
crafttweaker.event.EntityStruckByLightningEvent
ZenMethod
onExplosionDetonate
Event-Klasse
crafttweaker.event.ExplosionDetonateEvent
ZenMethod
onExplosionStart
Event-Klasse
crafttweaker.event.ExplosionStartEvent
ZenMethod
onFarmlandTrample
Event-Klasse
crafttweaker.event.FarmlandTrampleEvent
ZenMethod
onItemExpire
Event-Klasse
crafttweaker.event.ItemExpireEvent
ZenMethod
onItemFished
Event-Klasse
crafttweaker.event.ItemFishedEvent
ZenMethod
onItemToss
Event-Klasse
crafttweaker.event.ItemTossEvent
ZenMethod
onLivingDestroyBlock
Event-Klasse
crafttweaker.event.LivingDestroyBlockEvent
ZenMethod
onLivingExperienceDrop
Event-Klasse
crafttweaker.event.LivingExperienceDropEvent
ZenMethod
onLivingKnockBack
Event-Klasse
crafttweaker.event.LivingKnockBackEvent
ZenMethod
onLootingLevel
Event-Klasse
crafttweaker.event.LootingLevelEvent
ZenMethod
onMinecartCollision
Event-Klasse
crafttweaker.event.MinecartCollisionEvent
ZenMethod
onMinecartInteract
Event-Klasse
crafttweaker.event.MinecartInteractEvent
ZenMethod
onMobGriefing
Event-Klasse
crafttweaker.event.MobGriefingEvent
ZenMethod
onPlayerAdvancement
Event-Klasse
crafttweaker.event.PlayerAdvancement
ZenMethod
onPlayerAnvilRepair
Event-Klasse
crafttweaker.event.PlayerAnvilRepairEvent
ZenMethod
onPlayerAnvilUpdate
Event-Klasse
crafttweaker.event.PlayerAnvilUpdateEvent
ZenMethod
onPlayerAttackEntity
Event-Klasse
crafttweaker.event.PlayerAttackEntityEvent
ZenMethod
onPlayerBonemeal
Event-Klasse
crafttweaker.event.PlayerBonemealEvent
ZenMethod
onPlayerBreakSpeed
Event-Klasse
crafttweaker.event.PlayerBreakSpeed
ZenMethod
onPlayerBrewedPotion
Event-Klasse
crafttweaker.event.PlayerBrewedPotion
ZenMethod
onPlayerChangedDimension
Event-Klasse
crafttweaker.event.PlayerChangedDimensionEvent
ZenMethod
onPlayerClone
Event-Klasse
crafttweaker.event.PlayerCloneEvent
ZenMethod
onPlayerCloseContainer
Event-Klasse
crafttweaker.event.PlayerCloseContainerEvent
ZenMethod
onPlayerCrafted
Event-Klasse
crafttweaker.event.PlayerCraftedEvent
ZenMethod
onPlayerDeathDrops
Event-Klasse
crafttweaker.event.PlayerDeathDropsEvent
ZenMethod
onPlayerDestroyItem
Event-Klasse
crafttweaker.event.PlayerDestroyItem
ZenMethod
onPlayerFillBucket
Event-Klasse
crafttweaker.event.PlayerFillBucketEvent
ZenMethod
onPlayerInteract
Event-Klasse
crafttweaker.event.PlayerInteractEvent
ZenMethod
onPlayerInteractBlock
Event-Klasse
crafttweaker.event.PlayerInteractBlockEvent
ZenMethod
onPlayerInteractEntity
Event-Klasse
crafttweaker.event.PlayerInteractEntityEvent
ZenMethod
onPlayerItemPickup
Event-Klasse
crafttweaker.event.PlayerItemPickupEvent
ZenMethod
onPlayerLeftClickBlock
Event-Klasse
crafttweaker.event.PlayerLeftClickBlockEvent
ZenMethod
onPlayerLoggedIn
Event-Klasse
crafttweaker.event.PlayerLoggedInEvent
ZenMethod
onPlayerLoggedOut
Event-Klasse
crafttweaker.event.PlayerLoggedOutEvent
ZenMethod
onPlayerOpenContainer
Event-Klasse
crafttweaker.event.PlayerOpenContainerEvent
ZenMethod
onPlayerPickupItem
Event-Klasse
crafttweaker.event.PlayerPickupItemEvent
ZenMethod
onPlayerPickupXp
Event-Klasse
crafttweaker.event.PlayerPickupXpEvent
ZenMethod
onPlayerRespawn
Event-Klasse
crafttweaker.event.PlayerRespawnEvent
ZenMethod
onPlayerRightClickItem
Event-Klasse
crafttweaker.event.PlayerRightClickItemEvent
ZenMethod
onPlayerSetSpawn
Event-Klasse
crafttweaker.event.PlayerSetSpawn
ZenMethod
onPlayerSleepInBed
Event-Klasse
crafttweaker.event.PlayerSleepInBedEvent
ZenMethod
onPlayerSmelted
Event-Klasse
crafttweaker.event.PlayerSmeltedEvent
ZenMethod
onPlayerTick
Event-Klasse
crafttweaker.event.PlayerTickEvent
ZenMethod
onPlayerUseHoe
Event-Klasse
crafttweaker.event.PlayerUseHoeEvent
ZenMethod
onPlayerVisibility
Event-Klasse
crafttweaker.event.PlayerVisibilityEvent
ZenMethod
onPortalSpawn
Event-Klasse
crafttweaker.event.PortalSpawnEvent
ZenMethod
onPotionBrewPost
Event-Klasse
crafttweaker.event.PotionBrewPostEvent
ZenMethod
onPotionBrewPre
Event-Klasse
crafttweaker.event.PotionBrewPreEvent
ZenMethod
onProjectileImpactArrow
Event-Klasse
crafttweaker.event.ProjectileImpactArrowEvent
ZenMethod
onProjectileImpactFireball
Event-Klasse
crafttweaker.event.ProjectileImpactFireballEvent
ZenMethod
onProjectileImpactThrowable
Event-Klasse
crafttweaker.event.ProjectileImpactThrowableEvent
ZenMethod
onRenderTick
Event-Klasse
crafttweaker.event.RenderTickEvent
ZenMethod
onServerTick
Event-Klasse
crafttweaker.event.ServerTickEvent
ZenMethod
onSleepingLocationCheck
Event-Klasse
crafttweaker.event.SleepingLocationCheckEvent
ZenMethod
onSleepingTimeCheck
Event-Klasse
crafttweaker.event.SleepingTimeCheckEvent
ZenMethod
onSpecialSpawn
Event-Klasse
crafttweaker.event.EntityLivingExtendedSpawnEvent
ZenMethod
onWorldTick
Event-Klasse
crafttweaker.event.WorldTickEvent

Clear all event handlers

Link to clear-all-event-handlers

ZenScript
Copy
events.clear();