Spell Effects - TheComputerGeek2/MagicSpells GitHub Wiki

Description:

Spell effects can be played at selected positions to make the effect play at the start, during or after a spell is cast. For example, you could make lightning strike you when you cast a particle projectile, you could make it cast at the position of the projectile throughout its flight at a set interval, you could make it strike where the projectile lands, etc.

You can define spell effects in the spell option effects. This is not where the effect options go, but the effect name section includes all the effect options.

spell:
    spell-class: ".targeted.DummySpell"
    effects: # <-- Here
      1:
        position: target
        effect: lightning
      2:
        position: caster
        effect: particles
        particle-name: end_rod
        horiz-spread: .5
        vert-spread: .5
        speed: .1
        count: 10

The map keys 1 and 2 are the names of the effects. The name of the effect does not matter. You could use them to describe the effect - you could rename 2 to Particles if you want. It's just important you don't have two same map keys in a map.

Configuration:

For a spell effect to load successfully, it needs to have at least a defined position and effect with valid values.

Source Code

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

General Configuration:

Option Description Type Default Supports expressions
delay Defines delay in ticks before the effect is played. Integer 0 true
chance Defines the chance of the effect playing, ranging from (0, 1). Double true
z-offset Defines offset of the effect location on the Z axis. Double 0 true
height-offset Same as above, but for the Y axis. Double 0 true
forward-offset Same as above, but for the X-axis. Double 0 true
offset Vector offset instead of the above properties. Vector "0,0,0" true
relative-offset Same as above, but it's relative. Vector "0,0,0" true
modifiers Modifiers which determine whether the spell effect should be played or not. false
caster-modifiers Same as above, but it exclusively checks against the caster of the spell. false
target-modifiers Same as above, but it exclusively checks against the target of the spell. false
location-modifiers Same as above, but it exclusively checks against the targeted location of the spell. false

Effect Positions:

  • General positions:
Position Description
start or startcast Plays when the spell starts casting. This position does not wait for cast-time to finish.
caster or actor Plays the effect at the caster's position on the successful cast.
target Plays the effect at the target's position or targeted location if either is found.
startposition, startpos, pos1, position1 Start the position of a spell which might not be the caster's location.
endposition, endpos, pos2, position2 Start the position of a spell which might not be the target's location.
line or trail (Options) If a target or targeted location is present, this position plays the effect as a trail between the caster and the target (or targeted location) in that order.
reverse_line, reverseline or rline (Options) A reverse version of the above.
buff or active (Options) Plays the effect at the affected entity until the buff ends.
buffeffectlib For EffectLib effect types, using this position instead of the one above is highly recommended because instead of recreating the effect every iteration, it asynchronously creates the effect once and updates its location.
orbit (Options) Plays the effect at the orbit's location until the buff ends.
orbiteffectlib For EffectLib effect types, using this position instead of the one above is highly recommended because instead of recreating the effect every iteration, it asynchronously creates the effect once and updates its location.
cooldown Played if the spell is on cooldown.
missingreagents Played if the caster is missing reagents for the spell.
chargeuse Played when the spell's charges are consumed.
  • Spell-specific positions (supported ones are listed on spell pages):
    • disabled
    • delayed
    • special
    • projectile
    • casterprojectile/casterprojectileline - This position only works with the effectlibline effect.
    • blockdestroy/blockdestruction

Line position-specific options:

Options Description Type Default Supports expressions
max-distance If the distance between the two points is greater than the distance defined by this option the effect will not play. Double 100 true
distance-between Defines the distance before the next effect should be played - until the second point is reached. Double 1 true
start-location-height-offset Since 4.0 Beta 13. Double 0 true
end-location-height-offset Since 4.0 Beta 13. Double 0 true

Buff position-specific options:

Options Description Type Default Supports expressions
effect-interval The interval in ticks for the effect - the delay to wait before playing it again until the buff ends. Integer 20 true
drag-entity Since 4.0 Beta 13. When using effect: entity, it will spawn the entity for each defined tick. If you set this to true, it will spawn the entity once and then teleport it until the buff ends. Boolean false true

Orbit position-specific options:

These options extend Buff position options.

Options Description Type Default Supports expressions
orbit-x-axis Rotate the orbit around this angle on the x-axis. Float 0 true
orbit-y-axis Rotate the orbit around this angle on the y-axis. Float 0 true
orbit-z-axis Rotate the orbit around this angle on the z-axis. Float 0 true
orbit-radius The starting radius of the orbit. Float 1 true
orbit-y-offset The starting height offset. Float 0 true
orbit-horiz-offset The starting horizontal offset. Float 0 true
orbit-horiz-expand-radius The horizontal radius to expand on interval defined by orbit-horiz-expand-delay. Float 0 true
orbit-horiz-expand-delay The interval in ticks at which to expand the horizontal radius of the orbit - distance is defined by orbit-horiz-expand-radius. Integer 0 true
orbit-vert-expand-radius The vertical radius to expand on interval defined by orbit-vert-expand-delay. Float 0 true
orbit-vert-expand-delay The interval in ticks at which to expand the vertical radius of the orbit. Distance is defined by orbit-vert-expand-radius. Integer 0 true
orbit-seconds-per-revolution Duration of one full cycle of the orbit defined in seconds. Float 3 true

Effect Types: