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

Importare la Classe

Link to importare-la-classe

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

Clear all event handlers

Link to clear-all-event-handlers

ZenScript
Copy
events.clear();