Class SpellModifiers
java.lang.Object
com.binaris.wizardry.api.content.spell.internal.SpellModifiers
Glorified map for storing and saving spell modifier values such as potency, cost, chargeup and many others. This is
a mutable object that is intended to be modified rather than replaced, for example, inside the
SpellCastEvent.Pre
you would use this object to modify specific parts of the spell ("modifiers") rather making some hacky replacement.
If you try to add a new modifier that's not on the original mod (e.g. custom wand upgrades/modifiers) make sure to mark them as needing syncing if you want the client to be aware of them and of course make the needed implementations on your spell casting code to make use of them.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringConstant string identifier for modifying the area effect of spellsstatic final StringConstant string identifier for the wand charge-up modifier.static final StringConstant string identifier for modifying cooldown of spellsstatic final StringConstant string identifier for the mana cost modifier.static final StringConstant string identifier for modifying the duration effects of spellsstatic final StringConstant string identifier for the potency modifier.static final StringConstant string identifier for the wand progression modifier.static final StringConstant string identifier for modifying the effect range of spells -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdds the value to the given key.combine(SpellModifiers modifiers) Combines thisSpellModifiersinstance with another by multiplying their corresponding modifier values.Divide the value based on the given key.static SpellModifiersfromTag(net.minecraft.nbt.CompoundTag tag) Creates aSpellModifiersinstance from the given NBT tag.floatGets the multiplier for a specific upgrade identified by the given key.Retrieves the complete map of all multipliers, including those that do not require syncing.Multiply the value based on the given key.voidreset()Resets all multipliers and synced multipliers, clearing all stored values, including those that do not require syncing.Sets the multiplier for a specific upgrade identified by the given key.Subtract the value based on the given key.toString()net.minecraft.nbt.CompoundTagtoTag()Converts thisSpellModifiersinstance to an NBT tag.
-
Field Details
-
POTENCY
Constant string identifier for the potency modifier.- See Also:
-
COST
Constant string identifier for the mana cost modifier.- See Also:
-
CHARGEUP
Constant string identifier for the wand charge-up modifier.- See Also:
-
PROGRESSION
Constant string identifier for the wand progression modifier.- See Also:
-
DURATION
Constant string identifier for modifying the duration effects of spells- See Also:
-
BLAST
Constant string identifier for modifying the area effect of spells- See Also:
-
RANGE
Constant string identifier for modifying the effect range of spells- See Also:
-
COOLDOWN
Constant string identifier for modifying cooldown of spells- See Also:
-
-
Constructor Details
-
SpellModifiers
public SpellModifiers()
-
-
Method Details
-
fromTag
Creates aSpellModifiersinstance from the given NBT tag. All entries in the tag are treated as float multipliers with their keys as the modifier identifiers.- Parameters:
tag- The NBT tag containing the modifier data.- Returns:
- A
SpellModifiersinstance populated with the data from the tag.
-
toTag
public net.minecraft.nbt.CompoundTag toTag()Converts thisSpellModifiersinstance to an NBT tag. All entries in the multiplier map are added to the tag as float values with their keys as the modifier identifiers.- Returns:
- A
CompoundTagcontaining the modifier data.
-
combine
Combines thisSpellModifiersinstance with another by multiplying their corresponding modifier values. If a modifier exists in either instance, it will be included in the result. The syncing status of each modifier is preserved if it exists in either instance.- Parameters:
modifiers- The otherSpellModifiersinstance to combine with.- Returns:
- This
SpellModifiersinstance after combining.
-
set
Sets the multiplier for a specific upgrade identified by the given key.- Parameters:
key- The string identifier for the upgrade.multiplier- The multiplier value to set.- Returns:
- This
SpellModifiersinstance after setting the multiplier.
-
add
Adds the value to the given key. In case there's not already a value for this modifier it will be saved as the base.- Parameters:
key- The string identifier for the upgrade.value- The value that's going to be added to the modifier- Returns:
- This
SpellModifiersinstance after setting the multiplier.
-
subtract
Subtract the value based on the given key. In case there's not already a value for this modifier it will be saved as the base.- Parameters:
key- The string identifier for the upgrade.value- The value that's going to be subtracted to the modifier- Returns:
- This
SpellModifiersinstance after setting the multiplier.
-
multiply
Multiply the value based on the given key. In case there's not already a value for this modifier it won't do anything.- Parameters:
key- The string identifier for the upgrade.factor- The value that's going to serve as the factor of the multiply- Returns:
- This
SpellModifiersinstance after setting the multiplier.
-
divide
Divide the value based on the given key. In case there's not already a value for this modifier it won't do anything.- Parameters:
key- The string identifier for the upgrade.divisor- The value that's going to serve as the divisor- Returns:
- This
SpellModifiersinstance after setting the multiplier.
-
get
Gets the multiplier for a specific upgrade identified by the given key.- Parameters:
key- The string identifier for the upgrade.- Returns:
- The multiplier value for the specified upgrade, or 1 if not set.
-
getMultipliers
Retrieves the complete map of all multipliers, including those that do not require syncing.- Returns:
- A map containing all modifier identifiers and their corresponding multiplier values.
-
reset
public void reset()Resets all multipliers and synced multipliers, clearing all stored values, including those that do not require syncing. -
toString
-