# Events

Same idea as actions but seperated to make more sense.

```yml
DamageEvent:
  Special variables:
    attacker -> Player who attacked
    victim -> Entity that got damaged
    cause -> DamageCause of the event
    event -> The event itself (you can do core.cancelEvent(event) to cancel it like it never happened)
    damage -> The amount of damage dealt item -> Item used to damage
    item -> Item used to attack
  Usage:
    item.setDamageEvent(core.createRunnable("<code>"))

ProjectileHitEntityEvent (Called when the projectile from core.shootProjectile() hits an entity):
  Special variables:
    shooter -> Player that shot the projectile
    victim -> Entity that got hit
    lastLocation -> Last location of the projectile (Entity location for this event)
    event -> The event itself (you can do core.cancelEvent(event) to cancel it like it never happened)
    item -> Item used to shoot
  Usage:
    item.setParticleHitEvent(core.createRunnable("<code>"))
  
ProjectileHitBlockEvent (Called when the projectile from core.shootProjectile() hits a block):
  Special variables:
    shooter -> Player that shot the projectile
    lastLocation -> The last location of the projectile before he got destroyed
    event -> The event itself (you can do core.cancelEvent(event) to cancel it like it never happened)
    item -> Item used to shoot
  Usage:
    item.setParticleHitEvent(core.createRunnable("<code>"))

ArmorEquipEvent (Called when the player equips an armor piece):
  Special variables:
    player -> Player who equipped the armor
    item -> Equipped item
    event -> The event itself (you can do core.cancelEvent(event) to cancel it like it never happened)
  Usage:
    item.setArmorEquipEvent(core.createRunnable("<code>"))

ArmorUnEquipEvent (Called when the player un-equips an armor piece):
  Special variables:
    player -> Player who un-equipped the armor
    item -> Un-Equipped item
    event -> The event itself (you can do core.cancelEvent(event) to cancel it like it never happened)
  Usage:
    item.setArmorUnEquipEvent(core.createRunnable("<code>"))

PlayerMoveEvent (Called when the player moves while holding the item or when equipped as his armor):
  Special Variables:
    player -> The player who moved
    item -> Held item / Equipped item
    event -> The event itself (you can do core.cancelEvent(event) to cancel it like it never happened)
  Usage:
    item.setPlayerMoveEvent(core.createRunnable("<code>"))

PlayerDamageEvent (Called when the player gets damaged, called for the item the player holds and for each armor piece he has equipped):
  Special Variables:
      player-> The player that got damaged
      item -> The item the player has (held item & armor pieces)
      cause -> The damage cause
      causeName -> The name of the damage cause (just cause.getName() used for the ingame editor)
      damage -> The amount of damage taken
      event -> The event itself (you can do core.cancelEvent(event) to cancel it like it never happened)
    Usage:
      item.setPlayerDamageEvent(core.createRunnable("<code>"))
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://tastycake.gitbook.io/itemscore/how-to-use/the-code/events.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
