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.
It also keeps track of which modifiers need to be synced to the client, so that only those are sent over the network.
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 the wand charge-up modifier.static final StringConstant string identifier for the mana cost modifier.static final StringConstant string identifier for the potency modifier.static final StringConstant string identifier for the wand progression modifier. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncombine(SpellModifiers modifiers) Combines thisSpellModifiersinstance with another by multiplying their corresponding modifier values.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.floatget(net.minecraft.world.item.Item upgrade) Gets the multiplier for a specific upgrade identified by the given item.Retrieves the complete map of all multipliers, including those that do not require syncing.Retrieves the map of multipliers that need to be synced to the client.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, along with its syncing status.set(net.minecraft.world.item.Item upgrade, float multiplier, boolean needsSyncing) Sets the multiplier for a specific upgrade identified by the given item, along with its syncing status.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:
-
-
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
public SpellModifiers set(net.minecraft.world.item.Item upgrade, float multiplier, boolean needsSyncing) Sets the multiplier for a specific upgrade identified by the given item, along with its syncing status. The item is converted to its string identifier usingWandUpgrades.getIdentifier(Item)in order to store the multiplier.- Parameters:
upgrade- The item representing the upgrade.multiplier- The multiplier value to set.needsSyncing- Whether this modifier needs to be synced to the client.- Returns:
- This
SpellModifiersinstance after setting the multiplier.
-
set
Sets the multiplier for a specific upgrade identified by the given key, along with its syncing status.- Parameters:
key- The string identifier for the upgrade.multiplier- The multiplier value to set.needsSyncing- Whether this modifier needs to be synced to the client.- Returns:
- This
SpellModifiersinstance after setting the multiplier.
-
get
public float get(net.minecraft.world.item.Item upgrade) Gets the multiplier for a specific upgrade identified by the given item. The item is converted to its string identifier usingWandUpgrades.getIdentifier(Item)in order to retrieve the multiplier.- Parameters:
upgrade- The item representing the upgrade.- Returns:
- The multiplier value for the specified upgrade, or 1 if not set.
-
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.
-
getSyncedMultipliers
Retrieves the map of multipliers that need to be synced to the client.- Returns:
- A map containing modifier identifiers and their corresponding multiplier values that require syncing.
-
reset
public void reset()Resets all multipliers and synced multipliers, clearing all stored values, including those that do not require syncing.
-