Class ConstructRangedSpell<T extends MagicConstructEntity>
- Type Parameters:
T- The type ofMagicConstructEntitythis spell creates.
- Direct Known Subclasses:
Decay,IceSpickes
ConstructSpell that spawns constructs at a distance from the caster using ray casting.
This spell traces a ray from the caster's position (or from a block face when cast by location) to find the
target spawn position. The range of the ray is determined by the DefaultProperties.RANGE property and
can be modified by range upgrades.
When cast by a player, the construct is spawned at the point where the player's look direction intersects with
a block surface (or at maximum range if no block is hit and ConstructSpell.requiresFloor is false). When cast by an entity,
the construct is spawned at the target entity's position if it is within range and not obstructed by blocks. When cast
by location, the construct is spawned along the direction specified by the block face, at the point where the ray
intersects with a block surface (or at maximum range if no block is hit).
You can configure whether the ray casting should detect liquid blocks by calling hitLiquids(boolean),
and whether it should ignore uncollidable blocks by calling ignoreUncollidables(boolean).
You must override the ConstructSpell.properties() to return an actual instance of SpellProperties
for this spell or use Spell.assignProperties(SpellProperties),
otherwise the spell will have no properties and may not function as intended.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanWhether ray casting should detect liquid blocks as solid surfaces.protected booleanWhether ray casting should ignore uncollidable blocks (e.g., tall grass, flowers).Fields inherited from class com.binaris.wizardry.content.spell.abstr.ConstructSpell
allowOverlap, constructFactory, permanent, requiresFloorFields inherited from class com.binaris.wizardry.api.content.spell.Spell
pitch, pitchVariation, volume -
Constructor Summary
ConstructorsConstructorDescriptionConstructRangedSpell(Function<net.minecraft.world.level.Level, T> constructFactory, boolean permanent) Creates a new ranged construct spell with the specified factory and permanence setting. -
Method Summary
Modifier and TypeMethodDescriptionbooleancast(EntityCastContext ctx) This cast method is meant to be used for spells that are cast by an entity source, like a mob.booleancast(LocationCastContext ctx) This cast method is meant to be used for spells that are not cast by an entity, but rather by a non-entity source, like a command block or a dispenser.booleancast(PlayerCastContext ctx) This cast method is meant to be used for spells that are cast by a player source.hitLiquids(boolean hitLiquids) Sets whether ray casting should detect liquid blocks as solid surfaces.ignoreUncollidables(boolean ignoreUncollidables) Sets whether ray casting should ignore uncollidable blocks (e.g., tall grass, flowers, vines).Methods inherited from class com.binaris.wizardry.content.spell.abstr.ConstructSpell
addConstructExtras, canCastByEntity, canCastByLocation, floor, overlap, properties, requiresPacket, spawnConstructMethods inherited from class com.binaris.wizardry.api.content.spell.Spell
assignProperties, endCast, equals, getAction, getChargeUp, getCooldown, getCost, getDesc, getDescriptionFormatted, getDescriptionId, getElement, getIcon, getLocation, getLoopSounds, getOrCreateDescriptionId, getOrCreateLocation, getPitch, getPitchVariation, getProperties, getTier, getType, getVolume, isEnabled, isInstantCast, onCharge, playSound, playSound, playSound, playSoundLoop, playSoundLoop, property, soundValues, toString
-
Field Details
-
hitLiquids
protected boolean hitLiquidsWhether ray casting should detect liquid blocks as solid surfaces. Defaults to false. -
ignoreUncollidables
protected boolean ignoreUncollidablesWhether ray casting should ignore uncollidable blocks (e.g., tall grass, flowers). Defaults to false.
-
-
Constructor Details
-
ConstructRangedSpell
public ConstructRangedSpell(Function<net.minecraft.world.level.Level, T> constructFactory, boolean permanent) Creates a new ranged construct spell with the specified factory and permanence setting.- Parameters:
constructFactory- A function that creates the construct entity given a worldpermanent- Whether the construct should be permanent (true) or temporary (false)
-
-
Method Details
-
hitLiquids
Sets whether ray casting should detect liquid blocks as solid surfaces.When set to true, the ray cast will stop when it hits water, lava, or other liquid blocks, and the construct will be spawned at that position.
When set to false (default), liquids are treated as air and the ray cast will pass through them.
- Parameters:
hitLiquids- true to detect liquids, false to ignore them- Returns:
- this spell instance for method chaining
-
ignoreUncollidables
Sets whether ray casting should ignore uncollidable blocks (e.g., tall grass, flowers, vines).When set to true, the ray cast will pass through blocks that don't have collision (like plants and decorative blocks), only stopping when it hits a solid block.
When set to false (default), the ray cast will stop at any block, including decorative ones.
- Parameters:
ignoreUncollidables- true to ignore uncollidable blocks, false to detect them- Returns:
- this spell instance for method chaining
-
cast
Description copied from class:SpellThis cast method is meant to be used for spells that are cast by a player source. This is useful for spells that are meant to be cast by players, as it provides more information about the caster and the context of the cast.Override this method to implement the casting behavior for spells that are meant to be cast by players.
- Overrides:
castin classConstructSpell<T extends MagicConstructEntity>- Parameters:
ctx- The context of the spell cast, containing information about the world, caster, hand used, modifiers, etc.- Returns:
- true if the spell was successfully cast, false otherwise. If this returns false, the spell will not be considered as having been cast, so no cooldown will be applied.
-
cast
Description copied from class:SpellThis cast method is meant to be used for spells that are cast by an entity source, like a mob. This is useful for spells that are meant to be cast by entities, as it provides more information about the caster and the context of the cast.Override this method to implement the casting behavior for spells that are meant to be cast by entities.
- Overrides:
castin classConstructSpell<T extends MagicConstructEntity>- Parameters:
ctx- The context of the spell cast, containing information about the world, caster, modifiers, etc.- Returns:
- true if the spell was successfully cast, false otherwise. If this returns false, the spell will not be considered as having been cast, so no cooldown will be applied.
-
cast
Description copied from class:SpellThis cast method is meant to be used for spells that are not cast by an entity, but rather by a non-entity source, like a command block or a dispenser. This is useful for spells that are meant to be cast in a specific location without needing an entity to cast them. By default, this returns false, as most spells are meant to be cast by entities. You can override this to return true if your spell is meant to be cast by non-entity sources and to implement the casting behavior for that case.- Overrides:
castin classConstructSpell<T extends MagicConstructEntity>- Parameters:
ctx- The context of the spell cast, containing information about the world, location, modifiers, etc.- Returns:
- true if the spell was successfully cast, false otherwise. If this returns false, the spell will not be considered as having been cast, so no cooldown will be applied.
-