Skip to content

Modifiers

MomoPewpew edited this page Nov 25, 2024 · 60 revisions

Modifiers:

Modifiers allow an action to take place when a condition is met upon a spell being cast. For example, spells can require a condition to pass to be cast successfully.

Source Code

Configuration:

There are two types of modifier configurations:

  • Single - Action done based on one condition.
  • Modifier collections - Action to do based on multiple conditions. A pass condition can be specified where you can decide if the collection passes when ALL conditions pass or if ANY of the listed conditions passing is enough for the whole collection to pass. XOR defines that the collection can pass only if one of the listed conditions passes.

You can take a closer look at modifier collections on this guide, but on this page, we will only cover modifiers that are paired with a condition and an action for the condition.

Modifiers are a general spell option that contains a list of strings. Each of these strings contains a modifier, a pair with one condition and one action. The format for a modifier can be seen below. What's specified in round brackets is always required, what's specified in square brackets is only required if the condition or action expects a var value - more about these variables will be covered on the Modifier Conditions and Modifier Actions pages.

(condition) [condition var] (action) [action var]

You can specify a string to be sent to the caster of the spell if all modifiers fail to cast using the option str-modifier-failed. You can also send a string if a specific modifier fails by separating the message from the modifier with $$. Here's an example:

modifiers:
    - onground require$$You must be on the ground to cast this spell!
    # Color code supported
    - day required$$&4It must be &6day &4for this spell to cast successfully.

If you prepend the character ! (and surround the modifier string in quotes because YAML will screech at you), the condition outcome would be inverted. Say your modifier is day require. An inverted version, a condition that would only pass if it's nighttime, could be day deny and night require, but it can also be "!day require".

You might ask what the point of this is. There is a modifier action castinstead (spell) that will cast a different specified spell if the condition passes. So you could have something like day castinstead setNight.

Some conditions do not have a dualistic sibling (e.g. night and day), an inverted version of the condition. Say you configured the modifier facing to cast a spell if you're facing west - you would use facing west castinstead (spell). Now, if you want this other spell to only be cast if the caster is not facing west but some other direction, you can use "!facing west castinstead (spell)".

Conditions:

Some conditions don't require a condition variable. If they do it will be specified throughout this documentation as "ConditionVar".

Condition Description
absorption ConditionVar format: [operator][number]
advancement Passes if the entity has the advancement defined in ConditionVar. Remember that Minecraft advancements must start with the minecraft: namespace key.
age ConditionVar accepts baby or adult
alive Player's time since last death, specified in ticks. ConditionVar format: [operator][number]
always Passes always, just like chance 100, but without any extra processing and math. These mechanics are useful when you don't care about the condition but want to perform a modifier action directly.
angle Passes if the entity's location angle is equal/less/more than the defined value to the other location. ConditionVar format: [operator][number]
beneficial Passes if the spell was marked as a beneficial spell.
biome Passes if the entity is in the biome. The value can be one biome or multiple separated by a comma, but no space.
blocking Passes if the player is blocking with a shield.
buffactive Passes if an entity has an active buff spell. ConditionVar accepts the internal name of a buff spell.
canpickupitems If the target can pick up items.
casting Passes if the entity is currently casting a spell with a cast-time. ConditionVar can be used to specify a specific spell.
chance This generates a random number below 100. If the ConditionVar is lower than this number, the condition passes. This condition is in that way random. This ConditionVar supports expressions.
charactertag Requires SneakyCharacterManager. Checks whether the player's current character has the tag specified in ConditionVar.
chestcontains Passes if the chest at the defined location contains the defined magic item. ConditionVar format: world,x,y,z,itme. item should be written using the Cast Items format.
collection ConditionVar should be the modifier collection name.
customname Passes if the entity's custom name is equal to the ConditionVar. This does not work with players. Spaces must be replaced by "__" or you can check it matches the value of an ms string variable value with %var:stringVar%.
customnamevisible Passes if the entity's custom name is visible.
data Checks if the specified data element is lesser than, greater than or equal to the value supplied. __ can be used to substitute for spaces in the value. Supports variable replacement, including targeted variable replacement using %castervar and %targetvar.
day Passes if time is greater than 0 and less than 13000.
displayname Passes if the target's display name is equal to ConditionVar - case insensitive and it supports color codes.
distance Calculates the block distance between the entity and the targeted entity/location. ConditionVar format: [operator][number]
durability Valid slots: helm, helmet, chestplate, leggings, boots, offhand, hand, mainhand. ConditionVar format: [slot][operator][number],[slot][operator][number]...
elevation The entity's Y level. ConditionVar format: [operator][number]
entitytype If the entity's type matches ConditionVar (or if it's a list then at least one element in the list). Valid element (types): player, monster, animal, or an entity type.
expression Compares two expressions using the ConditionVar format: [expression][operator][expression]. E.g. expression 5*%papi:sneakydispatch_dispatch_frozen_milis%>rand(0,10) required
expressionstringcontains Passes if the left expression string value contains the right expression string value. ConditionVar format: [expression]:[expression]. If you want to compare an expression to a raw string, then the raw string must be surrounded by quotation marks. E.g. expressionstringcontains %papi:sneakycharacters_character_name%:"Willakers" required
expressionstringequals Passes if the left expression string value equals the right expression string value. ConditionVar format: [expression]:[expression]. If you want to compare an expression to a raw string, then the raw string must be surrounded by quotation marks. E.g. expressionstringequals %papi:sneakycharacters_character_name%:"Old Man Willakers" required
facing If the entity is facing one of the valid directions specified by the ConditionVar. Valid directions: south, west, north, east.
falling If the entity is falling.
flying If the player is flying.
food ConditionVar format: [operator][number]
gamemode Use this for ConditionVar reference.
gliding If the entity is gliding (elytra flight can be enabled without them being equipped).
griefpreventionisowner If the claim the player is in recognises them as its owner.
hasitem Passes if the entity is holding the item specified in ConditionVar. Format: material:durability|customName. material refers to Material, durability can be omitted or you can put *. If customName has spaces, replace them with __.
hasitemamount Checks the entity's item quantity of an item using the Cast Items format specified in ConditionVar. Format: [operator][number];[magicItem].
hasitemprecise If the entity has the Cast Items specified in ConditionVar in their inventory.
hasmark If the player has a mark set specified in ConditionVar as the mark's internal spell name.
hasscoreboardtag Passes if the entity has the scoreboard tag specified in ConditionVar - supports variable replacement.
hasspell Passes if the player has the spell defined by its internal name in ConditionVar.
hastarget Passes if the entity has a target.
health Checks the entity's health with ConditionVar's format: [operator][number](%).
holding Passes if the entity is holding the items specified in ConditionVar. ConditionVar's format itemFormat,itemFormat,..., where itemFormat follows format: material:durability|customName. material refers to Material, durability can be omitted or you can put *. If customName has spaces, replace them with __.
holdingprecise Passes if the entity is holding the item specified with the Cast Items format in ConditionVar.
hoveringwith Passes if the entity is hovering with an item using the Cast Items format specified in ConditionVar in an open inventory.
inblock If the entity is inside the block or blocks specified in ConditionVar. This can be one or multiple blocks, separated by a comma, with no space after.
incuboid Passes if the entity is inside the cuboid location specified in ConditionVar. A cuboid region is a region between two opposite corner locations defined by this format: world,x1,y1,z1,x2,y2,z2
innomagiczone Passes if the entity is inside the No Magic Zone specified in ConditionVar.
inregion Passes if the entity is inside the WorldGuard region specified in ConditionVar with the format: world:regionName
isnpc Passes if the target is an NPC.
lastdamagetype Passes if the entity's last Damage Type matches the one specified in ConditionVar.
lastlife Checks the alive time of the previous life, which is specified in ticks using the ConditionVar format: [operator][number]
leaping Passes if the entity is in air because its velocity was changed by the leap spell specified in ConditionVar (the internal name).
level Checks the user's level using the ConditionVar format: [operator][number]
lightlevel Checks the entity's light level using the ConditionVar format: [operator][number]
locationmatchesschematic Checks if the location matches the worldedit schematic specified in the ConditionVar. The ConditionVar must include the file extension. The schematic must be saved in plugins/MagicSpells/schematics. The tested block location will be matched against the origin point of the schematic (the coordinates that you were standing in when you copied the location). Air blocks in the schematic will be ignored, unless you add ;true to the end of the ConditionVar.
loopactive Checks if the target currently has a loop active in the spell specified in the ConditionVar.
lookingatblock If the entity is looking at the block specified in ConditionVar. This can be one block or multiple separated by a comma, with no space after.
mana Checks the player's mana using the ConditionVar format: [operator][number](%)
maxmana Checks the player's max mana using the ConditionVar format: [operator][number](%)
money Checks the player's money using the ConditionVar format: [operator][number]
moonphase Passes if the entity's location present moon phase matches the one specified in ConditionVar. Valid phases: full, new, waning, waxing, waning_gibbous, last_quarter, waning_crescent, waxing_crescent, first_quarter, waxing_gibbous.
name Passes if the player's username or display name is equal to the ConditionVar. This does work with other entities and it does not support the space character - use the customname condition instead.
namepattern Passes if the entity's name, or the player's username or display name matches the regex pattern specified in the ConditionVar.
night Passes if time is greater than 13000 and less than 23000.
offhand Passes if the entity is holding, in the offhand slot, the item specified in ConditionVar using the format: type:durability|name - where __ can be used to replace spaces. Multiple items like these can be specified, separated by a comma.
offhandprecise Passes if the entity is holding, in the offhand slot, the item specified in ConditionVar using the Cast Items format. This can be one item or multiple separated by a comma, with no space after.
onblock Passes if the entity is standing on the block or blocks specified in ConditionVar. This can be one item or multiple separated by a comma, with no space after.
oncooldown Passes if the player has the spell specified in ConditionVar is currently on cooldown.
onfire Passes if the entity is presently on fire.
onground Passes if the entity is on the ground.
onleash Passes if the entity is leashed.
onsameteam Passes if the player is in the same scoreboard team as the targeted player.
onteam Passes if the player is in the scoreboard team that matches ConditionVar.
openslots Check the player's empty inventory slots using the ConditionVar format: [operator][number]
outside Passes if the entity or location has no blocks above it.
overblock Passes if the entity or location has blocks specified in ConditionVar using the format: block;height. block refers to block data, and it can be multiple block types separated by a comma, no space after. If the height is negative, it will check the blocks above you instead.
ownedbuffactive Passes if the entity has a buff spell active cast by the caster of this modifier. ConditionVar accepts an internal name of a buff spell.
ownedloopactive Checks if the target currently has a loop active that was cast by the caster in the spell specified in the ConditionVar.
oxygen Check's the entity's oxygen level using the ConditionVar format: [operator][number]
permission Passes if the player has the permission specified in ConditionVar. This passes anyway if they have the wildcard permission.
pathfinding Passes if the player is currently pathfinding with the GPS-PathFinder plugin.
pitch Checks the entity's pitch using the ConditionVar format: [operator][number]
playercount Checks the server's player count using the ConditionVar format: [operator][number]
playeronline Passes if an online player's username matches the ConditionVar.
pluginenabled Passes if a presently enabled plugin's name matches ConditionVar.
potioneffect Passes if the entity has an active potion effect that matches the ConditionVar's format: effectType or effectType:potency
power Checks the spell's power using the ConditionVar format: [operator][number]
raining Passes if it's raining at the entity's location or targeted location.
receivingredstone Checks the targeted location's redstone signal of power using the ConditionVar format: [operator][number]
richerthan Passes if the player is richer than the targeted player.
riding Passes if the entity is riding the entity type specified in ConditionVar.
riptiding Passes if the entity is in the Riptide animation. Only available in Beta-11+
roof Passes if the entity has a block, that isn't air, above them. You can specify a height to check for in ConditionVar, the default is 10.
rotation Check's player's yaw (but supports negative degrees) using the ConditionVar format: [operator][number]
saturation Checks the player's saturation level using the ConditionVar format: [operator][number]
signtext Passes if the sign at the defined location contains the defined text. ConditionVar format: world,x,y,z,signLines, where signLines is a list of lines connected by \n, with spaces replaced by __. Example: world,0,1,0,&6line1\nline__2
slotselected ConditionVar format: [operator][number]
sneaking Passes if the player is sneaking.
spellcaststate Passes if this spell's cast state matches ConditionVar.
spellselected Passes if the currently selected spell of the player's cast/bound item passes the string-based Spell Filter.
spelltag Passes if this spell's tag matches ConditionVar.
sprinting Passes if the player is sprinting.
storm Passes if there's a storm at the entity's location or at the targeted location.
swimming Passes if the player is swimming.
targetmaxhealth Checks the targeted entity's max health using the ConditionVar format: [operator][number]
targeting Passes if the spell is targeting an entity type that matches at least one element of ConditionVar. Valid list: caster or an entity type. One type or multiple separated by a comma, with no space after. If nothing is specified it will assume that all types are allowed.
testforblock Passes if the location specified has a block, all specified using ConditionVar's format: world,x,y,z=block. block supports block data.
thundering Passes if the weather is currently "thunder" at the entity's location or the targeted location.
time Passes if time at the entity's location or the targeted location is within the range specified with ConditionVar's format: startTime-endTime
underblock Passes if the entity or location is under a block. ConditionVar format: block;height. block refers to block data, and it can be multiple blocks separated by a comma, with no space after.
underwater Passes if the entity is underwater.
uptime Passes if the time in seconds since the server started is greater than the amount specified in ConditionVar.
variable Checks the player's variable using the ConditionVar format: [varName][operator][number/variableName]
variablematches Passes if the player's value of the variable matches the value of the target's variable. The ConditionVar must be the variable name.
variablestringequals Passes if the player's string variable value matches the one specified. ConditionVar format: varName:value . The value must be a string, with no space character. Value can be "null" to check for empty values.
wearing Passes if the player has any of the items specified in ConditionVar in any wearable slots. ConditionVar's format itemFormat,itemFormat,..., where itemFormat follows format: material:durability|customName. material refers to Material, durability can be omitted or you can put *. If customName has spaces, replace them with __.
wearinginslot Passes if the player has the item specified in the specific wearable slot. ConditionVar format: slot=itemType. Valid slot types: helm (hat, head), chest (tunic), leg (pant), boot (shoe, feet). itemType refers to material.
wearingprecise Passes if the player is wearing the item specified in ConditionVar using the Cast Items format in any of their wearable slots.
world Passes if the entity or targeted location is in the world specified in ConditionVar.
worldguardbooleanflag Passes if the top-level region the player is standing in has the boolean flag specified in ConditionVar set to TRUE.
worldguardmembership Passes if the player has membership status in the top-level region the player is standing in. The type of membership must be specified in ConditionVar as one of: owner, member, or member_only.
worldguardstateflag Passes if the top-level region the player is standing in has the state flag specified in ConditionVar set to ALLOW.
yaw Checks the entity's yaw value using the ConditionVar format: [operator][number]

Operator:

When [operator] is mentioned in the ConditionVar, the following operators have to be specified:

  • Equals: = or :
  • Less than: <
  • Greater than: >

Actions:

Action Description Value
required or require If the condition fails to pass, the spell will fail. None
denied or deny If the condition passes, the spell will fail. None
power or empower or multiply If the condition passes, the Spell Power will be multiplied by the amount specified in Value. Spell Power (Float)
addpower or add If the condition passes, the amount specified in Value will be added to the current Spell Power. Spell Power (Float)
cooldown If the condition passes, the spell's cooldown will be set to the amount specified in Value. Cooldown Seconds (Float)
reagents If the condition passes, the spell's reagent cost quantity will be multiplied by the amount specified in Value. Multiplier (Float)
casttime If the condition passes, the spell's cast-time will be set to the amount specified in Value. Cast Time seconds (Float)
stop If the condition passes, no other modifiers for the spell will be processed. None
continue If the condition fails to pass, no other modifiers for the spell will be processed. None
cast If the condition passes, the spell specified in Value will be cast. Internal Spell Name
castinstead If the condition passes, the spell specified in Value will be cast instead of this spell. Internal Spell Name
variable If the condition passes, the variable modification specified in Value will be done. VarMod
string If the condition passes, the string variable specified in Value will be set to the value also specified there. This action is a shorthand for: variable stringVar;=newValue Format: stringVar newValue.

Source Code

Clone this wiki locally