PhaseSpell - TheComputerGeek2/MagicSpells GitHub Wiki

Source Code

spell-class: ".instant.PhaseSpell"

Description:

Allows the caster to teleport through phase-able blocks.

Mechanics:

  • The spell searches blocks along the player's line of sight.
  • Firstly, it searches for a block to "enter" through, by going through range until it finds a block that isn't air.
    • This means that a valid entry can be a passable block (without collision, like cobweb, plants, etc.), and the caster will phase past it.
  • Lastly, it searches for an "exit" location within max-distance (from original location), where the block and the block above are air. This means that:
    • The spell assumes the caster's height is > 1 and <= 2.
    • Passable blocks are not valid exit locations.
  • It checks that all blocks the player will phase through are not in the non-phasable-blocks list. The phasable-blocks list restricts which blocks are phase-able, and if empty, all other blocks are.
  • Since the search begins at eye height of the caster, the exit location is at eye height, which matters most when phasing horizontally - the caster exits 1 block higher if at 0 pitch, and fall 1 block down.

Configuration:

Since 4.0 Beta 13 some of these options support dynamic values through numeric or string expressions.

Option Description Type Default Supports expressions
phasable-blocks A list of block types that can be phased through. If this option is empty or left out, all blocks can be phased through. String List false
non-phasable-blocks A list of block types that cannot be phased through. String List false
max-distance The maximum distance the caster can travel through solid matter to reach open air. This includes the distance leading up to the wall (the range). Integer 15 true
power-affects-max-distance Since 4.0 Beta 13. Boolean true true
str-cant-phase The message that appears if the spell fails. Rich Text "Unable to find a place to phase to." true

Example:

phase:
    spell-class: ".instant.PhaseSpell"
    name: phase
    spell-icon: diamond
    description: Phase through solid matter.
    cast-item: stick
    cooldown: 10
    range: 5
    max-distance: 15
    phasable-blocks: []
    cost:
        - mana 15
    str-cost: 15 mana
    str-cant-phase: Unable to find place to phase to.