Skip to content

4. Spells JSON Formats

CAS_ual_TY edited this page Nov 14, 2023 · 3 revisions

Spells JSON Formats

Overview

File Location
Spell
Spell Icon
Variable
Events

Spell actions have their own page in this wiki.


File Location

All spells go into the data/spells_and_shields/spells folder.


Spell

JSON Format:

{
  "s1/title": Component,
  "s2/icon": Spell Icon,
  "s3/mana_cost": 0.0,
  "s4/tooltip": [
    Components...
  ],
  "s5/spell_events": [
    Strings...
  ],
  "s6/spell_parameters": [
    Variables...
  ],
  "s7/spell_actions": [
    Spell Actions...
  ]
}

Elements:

  • s1/title: The name of the spell.
  • s2/icon: The icon of the spell.
  • s3/mana_cost: The mana cost of the spell. This is only the shown mana cost in the tooltip and may or may not reflect the actual mana cost of the magic.
  • s4/tooltip: The description of the spell when hovering over it. The title is already included in the tooltip.
  • s5/spell_events: All events this spell hooks into.
  • s6/spell_parameters: All variables that are set before a new event is fired. These allow easy spell configuration or can be overridden by each entry in a spell tree.
  • s7/spell_actions: The spell actions to sequentially execute on an event.

Spell Icon


default Type

Set the texture to any 18x18 texture.

JSON Format:

{
  "type": "spells_and_shields:default",
  "texture": String
}

Elements:

  • texture: The namespace and path to the texture.

sized type

Set the texture to any texture where width and height are equal to a chosen number.

JSON Format:

{
  "type": "spells_and_shields:sized",
  "texture": String,
  "size": Integer
}

Elements:

  • texture: The namespace and path to the texture.
  • size: The width and height of the texture.

advanced Type

Use any part of any size of any texture for the spell.

JSON Format:

{
  "type": "spells_and_shields:advanced",
  "texture": String,
  "width": Integer,
  "height": Integer,
  "u": Integer,
  "v": Integer,
  "textureWidth": Integer,
  "textureHeight": Integer,
  "offsetX": Optional Integer,
  "offsetY": Optional Integer
}

Elements:

  • texture: The namespace and path to the texture.
  • width: The width (on the texture file) of the part to render.
  • height: The height (on the texture file) of the part to render.
  • u: The x position (on the texture file) of the part to render.
  • v: The y position (on the texture file) of the part to render.
  • textureWidth: The total width of the texture file.
  • textureHeight: The total height of the texture file.
  • offsetX (Optional): Additional offset to apply to the x coordinate for rendering. This is optional and can be left out entirely.
  • offsetY (Optional): Additional offset to apply to the y coordinate for rendering. This is optional and can be left out entirely.

layered Type

JSON Format:

{
  "type": "spells_and_shields:layered",
  "icons_list": [
    Spell Icons...
  ]
}

Elements:

  • icons_list: The spell icons to render with the top ones in the json being rendered first (this means that the last spell icon you list here will be at the front while the first one here will be at the back in the game).

Variable

{
  "type": Variable Type,
  "value": Variable Value,
  "var_name": String
}

Elements:

  • type: See wiki section about variable types
  • value: An appropriate value for the chosen type
  • var_name: The name of the variable

Events

The (...) brackets contain the type of the variables or targets.

The following variables always exist, no matter the event:

  • mana_cost (double): Contains the set mana cost of a spell.
  • min_block_height (int): The minimum block height of the dimension.
  • max_block_height (int): The maximum block height of the dimension.

Hook events

These events hook into other mechanics of the game like when a player takes damage.

They contain the following target for equipped spells:

  • owner (player): The player that has the spell equipped.

They contain the following target for delayed spells:

  • holder (player): The player that holds this delayed spell.

Cancelable events

Some events are cancelable and they contain the following variable:

  • event_is_canceled (boolean): Determines if this event was canceled already by any mod or spell. The end result of this variable will determine if the event is fully canceled or not. It is not advisable to ever un-cancel an event that was already canceled (i.e. to set this variable to false after it was true).

active activation

When the spell in a spell slot of a player is fired by pressing the key bind.

Target groups:

  • owner (player): The player that has this spell equipped.

Variables:

  • spell_slot (int): The integer representing the slot the spell was in starting at 0.

on_equip activation

When a spell is equipped into a spell slot of a player (eg. when equipping a spell in the spell progression menu).

Target groups:

  • owner (player): The player that has equipped this spell.

Variables:

  • spell_slot (int): The integer representing the slot the spell was equipped in starting at 0.

on_unequip activation

When a spell in a spell slot of a player is unequipped or overridden by another spell.

Target groups:

  • owner (player): The player that has unequipped this spell.

Variables:

  • spell_slot (int): The integer representing the slot the spell was equipped in previously starting at 0.

living_attack_attacker activation (hook, cancelable)

When a living entity is attacked by another (from the point of view of the attacker). If this event is canceled the victim will not be attacked at all (which includes no damage being taken). Fired right before the living_hurt_attacker event.

Target groups:

  • victim (living_entity): The entity that is taking the damage.

Variables:

  • damage_type (String): The type of damage.
  • damage_amount (double): The amount of damage. Modifying this value does not change the amount of damage taken (use the living_hurt_attacker event for that).

living_attack_victim activation (hook, cancelable)

When a living entity is attacked by another (from the point of view of the victim). If this event is canceled the victim will not be attacked at all (which includes no damage being taken). Fired right before the living_hurt_victim event.

Target groups:

  • attacker (living_entity): The entity that caused the damage (if it exists) eg. the entity that attacked the victim.

Variables:

  • damage_type (String): The type of damage.
  • damage_amount (double): The amount of damage. Modifying this value does not change the amount of damage taken (use the living_hurt event for that).

living_hurt_attacker activation (hook, cancelable)

When a living entity takes damage (from the point of view of the attacker) and before armor is calculated in. If this event is canceled the victim will not take any damage. Fired right after the living_attack_attacker event (unless said event was canceled) and right before the living_damage_attacker event.

Target groups:

  • victim (living_entity): The entity that is taking the damage.

Variables:

  • damage_type (String): The type of damage.
  • damage_amount (double): The amount of damage. The end result of this variable will be applied unless this event is canceled.

living_hurt_victim activation (hook, cancelable)

When a living entity takes damage (from the point of view of the victim) and before armor is calculated in. If this event is canceled the victim will not take any damage. Fired right after the living_attack_victim event (unless said event was canceled) and right before the living_damage_victim event.

Target groups:

  • attacker (living_entity): The entity that caused the damage (if it exists).

Variables:

  • damage_type (String): The type of damage.
  • damage_amount (double): The amount of damage. The end result of this variable will be applied unless this event is canceled.

living_damage_attacker activation (hook, cancelable)

When a living entity takes damage (from the point of view of the attacker) and after armor is calculated in (this is the final damage that is applied). If this event is canceled the victim will not take any damage. Fired right after the living_damage_attacker event (unless said event was canceled).

Target groups:

  • victim (living_entity): The entity that is taking the damage.

Variables:

  • damage_type (String): The type of damage.
  • damage_amount (double): The amount of damage. The end result of this variable will be applied unless this event is canceled.

living_damage_victim activation (hook, cancelable)

When a living entity takes damage (from the point of view of the victim) and after armor is calculated in (this is the final damage that is applied). If this event is canceled the victim will not take any damage. Fired right after the living_damage_victim event (unless said event was canceled).

Target groups:

  • attacker (living_entity): The entity that caused the damage (if it exists).

Variables:

  • damage_type (String): The type of damage.
  • damage_amount (double): The amount of damage. The end result of this variable will be applied unless this event is canceled.