Skip to content

3. Getting Started: Custom Spells & Spell Trees

CAS_ual_TY edited this page Oct 9, 2023 · 9 revisions

Getting Started: Custom Spells & Spell Trees

Custom Data Pack

How to get started making a data pack.


Making a Data Pack

Follow these steps (or alternatively check out the wiki https://minecraft.fandom.com/wiki/Tutorials/Creating_a_data_pack):

  1. Pick a namespace (only lowercase, numbers and underscore) for your data pack. Eg. the default data pack has namespace spells_and_shields.
  2. Make a new zip folder. You may name it however you like. The zip folder must have the following structure:
- `<namespace>.zip` ZIP Folder.
| - `pack.mcmeta` file (more about that below).
| - `data` folder
  | - `<namespace>` folder
    | - `spells_and_shields` folder
      | - `spells` folder
      | - `spell_trees` folder
  1. The pack.mcmeta file must have the following contents:
{
  "pack": {
    "pack_format": 10,
    "description": "Your description..."
  }
}

Tips

All kinds of tips and recommendations starting with a general section followed by spell trees and spells specific sections.


General Tips

General tips for data pack making.


Ask for Help

Always ask for help. Do not hesitate! Use the official Discord server for this mod: https://discord.gg/3zXwr2atcY


Custom Resources (Textures, Sounds, and Translation)

By adding your own resource pack with your own assets in addition to your data pack you can use custom textures for spells and spell trees and also add custom sounds and language translation files. You may put these in your own namespace folder again but make sure you reference them correctly in your data pack (<namespace>:... instead of spells_and_shields: for references). This will not be explained here but there is a wiki page explaining it: https://minecraft.fandom.com/wiki/Tutorials/Creating_a_resource_pack


Tips for Spell Trees

These tips specifically apply for making of spell trees.


Tiered Spells

Spell nodes can override the mana cost and the parameters of a spell. If eg. the damage of a spell is set via parameter you can add a spell into a spell tree multiple times with different mana costs and damage for each. This allows you to basically do tiered spells.


Tips for Spells

These tips specifically apply for making of spells.


Enable Debugging for Spells

This is a big one. If you are making your own spells make sure you enable debugging in the common config (set debugSpells = true). This will constantly (between every spell action) print out all information about the current spell context to the console (also viewable in logs) whenever you fire a spell. This will also make it a lot easier to understand the entire system if you are getting started. If you are on a dedicated server the information is only printed to the server.

However, printing to console lags a lot. So make sure you disable it again and never have this option enabled if players are actually playing with this mod.


Reset = Death

If a player has infinitely repeating delayed spell effects on them or a particle emitter that is running for a very long time and this is the result of a mistake do the following:

  • Fix the spell that caused this
  • Kill the player

Killing the player will always make them get rid of any delayed spells and particle emitters on them.

Make sure you read the introduction to spells first.


Advanced Topics (WIP)


UUIDs (WIP)


Delayed Spells

Delayed spells can be attached to entities. They run the spell on a custom event for an entity after a customizable amount of time. This can be used in a lot of ways that will be explained here.

Repeating Effects

To infinitely repeat something you just attach the delayed spell to an entity and have it attach itself again when it fires.

Lets say the activation refire attaches a delayed spell that also fires the refire event when the delay has run out. If refire has been activated once then the delayed spell will be attached, run out and execute, attached again, run out and execute again, etc. infinitely. Add some effect triggered by the same activation and now this effect will be infinitely repeated.

So to start this infinite repetition, simply activate refire whenever the desired event is fired. To remove this infinitely repeating spell you have to give the delayed spell a UUID by which you can remove it without firing its activation.

Toggling Effects (WIP)


Particle Emitters (WIP)


Templates (WIP)

Single Activation + Mana Cost + Item Cost

Activate something once, requiring mana cost and an item cost (customizable amount). This spell adheres to the configuration file; players disabling item costs in there affects this spell.

{
  "s1/title": ...,
  "s2/icon": ...,
  "s3/mana_cost": ...,
  "s4/tooltip": ...,
  "s5/spell_events": [
    "active"
  ],
  "s6/spell_parameters": [
    {
      "type": "spells_and_shields:string",
      "value": ..., // <--- your item ID here, eg. '"minecraft:glowstone_dust"'
      "var/name": "item"
    },
    {
      "type": "spells_and_shields:string",
      "value": ..., // <--- the amount of items required, eg. '1'
      "var/name": "item_amount"
    }
  ],
  "s7/spell_actions": [
    {
      "type": "spells_and_shields:has_mana",
      "activation": "active",
      "amount": "<<mana_cost>>",
      "t/target": "owner"
    },
    {
      "type": "spells_and_shields:boolean_activation",
      "a/to_activate": "consume",
      "activation": "active",
      "d/boolean/activate_if_true": true,
      "d/boolean/deactivate_if_false": false,
      "d/boolean/input": "<< !item_costs() >>"
    },
    {
      "type": "spells_and_shields:player_has_items",
      "activation": "active",
      "d/boolean/creative_bypass": true,
      "d/boolean/must_be_in_hand": true,
      "d/int/amount": "<<item_amount>>",
      "d/string/item": "<<item>>",
      "t/source": "owner"
    },
    {
      "type": "spells_and_shields:activate",
      "a/to_activate": "consume",
      "activation": "active"
    },
    {
      "type": "spells_and_shields:activate",
      "a/to_activate": "shoot",
      "activation": "consume"
    },
    {
      "type": "spells_and_shields:burn_mana",
      "activation": "consume",
      "d/double/mana_amount": "<<mana_cost>>",
      "ts/targets": "owner"
    },
    {
      "type": "spells_and_shields:boolean_activation",
      "a/to_activate": "consume",
      "activation": "consume",
      "d/boolean/activate_if_true": false,
      "d/boolean/deactivate_if_false": true,
      "d/boolean/input": "<< item_costs() >>"
    },
    {
      "type": "spells_and_shields:consume_player_items",
      "activation": "consume",
      "d/boolean/must_be_in_hand": true,
      "d/int/amount": "<<item_amount>>",
      "d/string/item": "<<item>>",
      "t/source": "owner"
    },
    ... // <--- your actions here, the activation if the checks were successfull is "shoot"
  ]
}