Interface SpellHelper
public interface SpellHelper
Helper for spell-related operations.
-
Method Summary
Modifier and TypeMethodDescriptioncast(Spell spell, net.minecraft.world.level.Level level, @Nullable net.minecraft.world.entity.LivingEntity caster, boolean consume, boolean awardXp) Casts the givenSpell.castGrammar(SpellCastContext context) Casts the givenSpell's grammar.castPrimary(SpellCastContext context) Casts the givenSpell's primary shape.castSecondary(SpellCastContext context) Casts the givenSpell's secondary shape.castSecondaryOrGrammar(SpellCastContext context) If present, casts the givenSpell's secondary shape.intgetColor(List<SpellModifier> modifiers, Spell spell, int shapeGroupIndex) getFlatRecipe(Spell spell, net.minecraft.core.RegistryAccess registryAccess) Calculates aSpell's recipe and combines the ingredients where possible.net.minecraft.tags.TagKey<net.minecraft.world.level.block.Block> getIncorrectTagForToolTier(int toolTier) doubleintgetMaxSummons(net.minecraft.world.entity.LivingEntity entity) doublegetModifiedStat(double base, SpellStat stat, List<SpellModifier> modifiers, SpellCastContext context) Calculates the modifier-changed value from the base value.getModifiers(SpellPart part) Calculates aSpell's recipe.voidsetContingency(net.minecraft.world.entity.LivingEntity entity, net.minecraft.resources.Identifier contingency, Spell spell) Sets a contingencySpell.voidspawnParticles(net.minecraft.resources.Identifier part, List<SpellModifier> modifiers, SpellCastContext context) On the client, spawns particles for the givenSpellPart.voidtriggerContingency(net.minecraft.world.entity.LivingEntity entity, net.minecraft.resources.Identifier contingency) Triggers a contingency.
-
Method Details
-
cast
SpellCastResult cast(Spell spell, net.minecraft.world.level.Level level, @Nullable net.minecraft.world.entity.LivingEntity caster, boolean consume, boolean awardXp) Casts the givenSpell. -
castPrimary
Casts the givenSpell's primary shape. Note thatSpellCastContext.directEntity()andSpellCastContext.hitResult()are guaranteed to return null here.- Parameters:
context- TheSpellCastContextto use.- Returns:
- A
SpellCastResultrepresenting the result of the cast. - See Also:
-
castSecondary
Casts the givenSpell's secondary shape.- Parameters:
context- TheSpellCastContextto use.- Returns:
- A
SpellCastResultrepresenting the result of the cast. - See Also:
-
castGrammar
Casts the givenSpell's grammar.- Parameters:
context- TheSpellCastContextto use.- Returns:
- A
SpellCastResultrepresenting the result of the cast.
-
castSecondaryOrGrammar
- Parameters:
context- TheSpellCastContextto use.- Returns:
- A
SpellCastResultrepresenting the result of the cast.
-
getModifiedStat
double getModifiedStat(double base, SpellStat stat, List<SpellModifier> modifiers, SpellCastContext context) Calculates the modifier-changed value from the base value.- Parameters:
base- The base value to use.stat- TheSpellStatthat is modified.modifiers- TheSpellModifiers to check.context- TheSpellCastContextto use.- Returns:
- A modifier-changed value.
-
getColor
- Parameters:
modifiers- TheSpellModifiers to check.spell- TheSpellto cast.shapeGroupIndex- The index of the shape group to query the data components for. Pass a negative to use the grammar's data components instead.- Returns:
- The color of the
Spell's visual effects.
-
getModifiers
- Parameters:
part- TheSpellPartto query.- Returns:
- A list of
SpellModifierthat can modify the given part.
-
setContingency
-
triggerContingency
void triggerContingency(net.minecraft.world.entity.LivingEntity entity, net.minecraft.resources.Identifier contingency) Triggers a contingency.- Parameters:
entity- TheLivingEntityto trigger the contingency for.contingency- The name of the contingency to trigger.
-
getIncorrectTagForToolTier
net.minecraft.tags.TagKey<net.minecraft.world.level.block.Block> getIncorrectTagForToolTier(int toolTier) - Parameters:
toolTier- The tool tier to get the incorrect block tag for.- Returns:
- A tag specifying which blocks are not breakable by the given tool tier.
-
getMaxSummons
int getMaxSummons(net.minecraft.world.entity.LivingEntity entity) - Parameters:
entity- TheLivingEntityto get the max summons for.- Returns:
- The maximum amount of summoned minions for the given
LivingEntity.
-
getManaToBurnoutRatio
double getManaToBurnoutRatio()- Returns:
- The mana to burnout conversion ratio, used in spell cost calculation.
-
getRecipe
-
getFlatRecipe
Calculates aSpell's recipe and combines the ingredients where possible. -
spawnParticles
void spawnParticles(net.minecraft.resources.Identifier part, List<SpellModifier> modifiers, SpellCastContext context) On the client, spawns particles for the givenSpellPart. On the server, does nothing.- Parameters:
part- The id of the spell part to spawn the particles for.modifiers- TheSpellModifiers to consider.context- TheSpellCastContextto use.
-