Class ArrowSpell<T extends MagicArrowEntity>
java.lang.Object
com.binaris.wizardry.api.content.spell.Spell
com.binaris.wizardry.content.spell.abstr.ArrowSpell<T>
- Type Parameters:
T- The type ofMagicArrowEntitythis spell launches.
- Direct Known Subclasses:
ForceArrowSpell
Represents a spell that launches a
MagicArrowEntity-based projectile.
This class abstracts the logic of casting spells that behave like arrows, handling all the core steps such as entity creation, aiming, velocity calculation, and launch.
Check Spells#Dart
- Spells#MagicMissile for some examples
-
Field Summary
FieldsModifier and TypeFieldDescriptionA factory function to create instances of the projectile entity.Fields inherited from class com.binaris.wizardry.api.content.spell.Spell
pitch, pitchVariation, volume -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddArrowExtras(T arrow, CastContext ctx) Makes changes to arrows before it's spawned.floatcalculateVelocity(CastContext ctx, MagicArrowEntity projectile, float launchHeight) Calculates the velocity of the projectile based on gravity and range.booleanbooleanbooleancast(EntityCastContext ctx) booleancast(LocationCastContext ctx) booleancast(PlayerCastContext ctx) protected @NotNull SpellPropertiesbooleanWhether this spell requires a packet to be sent when it is cast.Methods inherited from class com.binaris.wizardry.api.content.spell.Spell
assignProperties, endCast, getAction, getCharge, getCooldown, getCost, getDesc, getDescriptionFormatted, getDescriptionId, getElement, getIcon, getLocation, getLoopSounds, getOrCreateDescriptionId, getOrCreateLocation, getPitch, getPitchVariation, getProperties, getTier, getType, getVolume, hasEnded, is, is, is, isEmpty, isEnabled, isInstantCast, onCharge, playSound, playSound, playSound, playSoundLoop, playSoundLoop, property, setProperties, soundValues, toString
-
Field Details
-
arrowFactory
A factory function to create instances of the projectile entity.
-
-
Constructor Details
-
ArrowSpell
-
-
Method Details
-
canCastByEntity
public boolean canCastByEntity()- Overrides:
canCastByEntityin classSpell
-
canCastByLocation
public boolean canCastByLocation()- Overrides:
canCastByLocationin classSpell
-
cast
-
cast
-
cast
-
calculateVelocity
Calculates the velocity of the projectile based on gravity and range.- Parameters:
ctx- Cast Context about how the spell is castprojectile- The projectile entity.launchHeight- The vertical height from which the projectile is launched.- Returns:
- The velocity value to be used when launching the projectile.
-
addArrowExtras
Makes changes to arrows before it's spawned. Override this is subclasses to apply special effects- Parameters:
arrow- The arrow instance to modify.ctx- The context of the spell cast, which may contain useful information for modifying the arrow.
-
requiresPacket
public boolean requiresPacket()Description copied from class:SpellWhether this spell requires a packet to be sent when it is cast. Returns true by default, but can be overridden to return false if the spell's cast() method does not use any code that must be executed client-side (i.e. particle spawning). This is not checked for continuous spells, because they never need to send packets.If in doubt, leave this method as is; it is purely an optimisation.
- Overrides:
requiresPacketin classSpell- Returns:
- true if the spell code should be run on the server and all clients in the dimension, false if the spell code should only be run on the server and the client of the player casting it.
-
properties
- Specified by:
propertiesin classSpell
-