Skip to content
ricochet1k edited this page Jun 13, 2012 · 31 revisions

An event is something that happens at some instant of time. In MD, event routines are executed when a specific event occurs.

Listed here underneath each event are the names of the different "things" available to the routines in that event. In the various routine pages, when you see placeholders in the code like {entity}, the things named in each event are the things you can pick from to fill the placeholders.

Entities are anything in Minecraft that moves. This includes, players, pigs, arrows, primed-and-flashing-TNT-about-to-explode-in-your-face, etc.

Projectiles are arrows, eggs, snowballs, etc. They are also entities, and can be used anywhere an entity reference is needed.

Item Stacks are a stack of items. They have a type, a data integer, a durability, and an amount.

Integers are integer variables that relate directly to the event. The one marked (default) is the one that will be altered by change value routines.

All Entities and Projectiles can be used with the Type conditional to check what type they are.

Events

Damage

Entities: attacker, target
Projectiles: projectile
Damage Type: damage
Integers: damage (default)

This is the event ModDamage was originally created for. It happens any time an entity takes damage, whether from an arrow, mob attacking, fire, cactus, starving, etc.

Death

Entities: attacker, target
Projectiles: projectile
Damage Type: damage
Integers: damage, experience (default)

This happens when a living entity is killed. All the things are from the Damage event that caused the death, except the experience Integer.

Heal

Entities: entity
Integers: heal_amount (default)

Whenever an entity gains health, this is fired.

ProjectileHit

Entities: shooter
Projectiles: projectile

This is fired when a projectile hits a block, NEVER when it hits an entity.

Spawn

Entities: entity
Integers: health (default)

This is fired whenever an entity spawns. Setting the health to 0 will cause the spawn to be canceled by Bukkit.

Tame

Entities: target, tamer

Whenever an entity is tamed, currently Wolves and Ocelots.

PickupExp

Entities: player
Integers: experience (default)

This is fired whenever a player picks up experience orbs.

PrepareEnchant

Entities: player
Item Stacks: item
Integers: bonus, level_1, level_2, level_3

This happens when a player places an item into the enchantment table. Bonus is the number of bookshelves nearby, and the levels are the numbers that will be displayed in each slot of the enchantment GUI. Please beware that this event is sent multiple times by Bukkit. It seems to be twice when the item is placed, and once when it is picked up, but be careful about relying on that behavior. Also note that MC will occasionally throw an exception if you set one of the levels above 50 and a player picks one of them.

Enchant

Entities: player
Item Stacks: item
Integers: level

This happens when the player chooses an enchantment from the enchantment table. Changing level will affect the number of levels subtracted from the player.

Interact

Entities: player
Item Stacks: item
Conditionals: interact_left, interact_right, interact_air, interact_block

This happens when a player left or right clicks and doesn't happen to hit an entity. If the player does hit an entity, then left clicks become the Damage event, and right clicks become the InteractEntity event.

InteractEntity

Entities: player, target

This happens when a player right clicks an entity.

ItemHeld

Entities: player
Integers: prevslot, newslot

This happens when a player switches which item slot in their inventory is active. prevslot is the number of the previous slot they had active, newslot is the new, current one.

Join

Entities: player

This happens when a player joins the server.

Quit

Entities: player

This happens when a player leaves the server. Be careful about relying on this for things like removing tags, because if the server crashes this won't be run.

Target

Entities: player, target

This happens when an entity changes what it is targeting. There is also a special reason value that can be tested with a reason.is.{reason} conditional, where {reason} is one of these:

  • TARGET_DIED - The entity's target has died.
  • CLOSEST_PLAYER - The entity doesn't have a target, so it attacks the nearest player.
  • TARGET_ATTACKED_ENTITY - The target attacked the entity.
  • PIG_ZOMBIE_TARGET - The target attacked a fellow pig zombie, so the whole group will target him with this reason.
  • FORGOT_TARGET - The target is forgotten for whatever reason. Currently only occurs with spiders when there is a high brightness.
  • TARGET_ATTACKED_OWNER - The target attacked the owner of the entity.
  • OWNER_ATTACKED_TARGET - The owner of the entity attacked the target.
  • RANDOM_TARGET -The entity has no target, so it randomly chose one.
  • DEFEND_VILLAGE - When an entity selects a target while defending a village.
  • CUSTOM - For custom calls to the event.

Combust

Entities: player, combustor Integers: block_type, block_data

This happens when an entity is lit on fire. If an entity, such as a WeatherStorm, Blaze, or player holding a FIRE_ASPECT enchanted item, is responsible, combustor will refer to them. Otherwise, block_type and block_data will refer to the type of block that caused the fire.

Clone this wiki locally