-
Notifications
You must be signed in to change notification settings - Fork 0
Volumes & Topologies
The behavior and targeting scope of a Spell Field is defined by its volumes array. A SpellFieldVolume dictates the spatial boundaries (where the field exists) and the topology (how the field strength behaves inside those boundaries).
Before understanding volumes, it is crucial to understand SpatialVector. A SpatialVector is a composite offset used to translate coordinates. It combines:
-
Absolute Cartesian Coordinates (
x,y,z): Standard global world offsets. -
Relative Orientational Coordinates (
forward,up,right): Local offsets based on the caster's line of sight and rotation.
Example: Setting forward: 5.0 will shift the epicenter 5 blocks in whatever direction the caster is currently looking.
A SpellFieldShape defines a strict, boolean bounding box (AABB). Targets inside the shape are processed; targets outside are ignored.
-
cube: Uniform expansion in all axes. -
cuboid: Explicit and independentx,y, andzradii. -
deep_cuboid: Extends a box forward along the caster's line of sight (depth_radius) and outwards perpendicular to it (height_width_radius). -
wide_cuboid: Extends a box laterally based on the caster's horizontal facing.
Every property within a SpellFieldVolume (shape, offset, topology) is technically optional. If you omit an explicit shape but define a topology, the API will automatically calculate and generate a bounding box perfectly fitted to the outer limits of that topology (e.g., deriving bounds from the origin_range). If both shape and topology are omitted, the volume collapses into a single-point AABB.
shape (like a cube). While this auto-fitting allows for highly creative and dynamic enchantment implementations, it should be used with caution. Always use the in-game Debug Renderer to verify that your implicit bounding boxes aren't evaluating unnecessarily large areas of the world, which could lead to severe server lag during target scanning.
While Shapes dictate where the field evaluates, Topologies dictate how strong the field is at a given point. Topologies return a scalar multiplier between 0.0 and 1.0.
A FieldTopology is defined by:
-
Ranges:
origin_range,axial_range, andradial_rangedefine the maximum evaluation distances. -
Metric: The mathematical distance calculation.
-
euclidean: Standard straight-line spherical distance. -
manhattan: Grid-based, diamond-shaped distance calculation.
-
-
Axes: The
axisparameter (aSpatialVector) establishes a directional orientation for the field, allowing you to create cylinders or cones of influence instead of just spheres. - Scaling Functions: Dictate how the multiplier degrades as distance increases.
Scaling functions calculate the drop-off from the center (1.0) to the defined range edge (0.0).
-
constant: No drop-off. The multiplier is exactly1.0everywhere within range. -
linear: Smooth, straight-line degradation toward the edge. -
polynomial: Scaled by adegreecurve (e.g., quadratic or cubic falloff). -
exponential: Rapid drop-off dictated by adecay_rate. -
logarithmic: Compressed curve mapped by asteepnessfactor. -
sigmoid: An S-curve that crosses the 50% power threshold at a definedmidpoint_ratio.
By combining an axial_scaling function and a radial_scaling function on a specific axis, you can create highly complex shapes, such as a beam that maintains full strength along its length but decays exponentially at its edges.
Certain effects (like impulses or particle vectors) need to know which direction to flow. The FieldAxis enumeration defines geometric vectors relative to the entity:
-
Standard Axes:
vertical(Up),longitudinal(Forward/Line of Sight),lateral(Right/Horizontal Plane). -
Relative Axes:
radial(Flowing outward from the epicenter). -
Orbital Axes:
azimuthal(Horizontal orbit),nutational(Pitching orbit),torsional(Rolling orbit).
Effects that implement DirectionalSpellFieldEffect will broadcast their chosen FieldAxis to the visual rendering engine, ensuring particles automatically flow in the correct direction.
Want to learn more about the configuration engine powering Enchantment Core?
Check out Config Understood, the official wiki for Config Overhauled, for a deep dive into dynamic property generation and state synchronization!