Class SpellFieldEventDispatcher
java.lang.Object
johnsmith.enchantmentcore.api.enchantment.spellfield.event.SpellFieldEventDispatcher
Thread-safe event bus managing the registration and execution of global spell field interception hooks.
Allows external mods to cancel spell field activations globally or dynamically attenuate/nullify topological multipliers for specific entity or block targets (e.g., for party/claim protection).
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceFunctional listener that intercepts the initial activation of aSpellFieldComponent.static interfaceFunctional listener that intercepts and modifies the topological scalar for individual block coordinates targeted within a spell field volume.static interfaceFunctional listener that intercepts and modifies the topological scalar for individual entities targeted within a spell field volume. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleandispatchApply(net.minecraft.server.level.ServerLevel level, int enchantmentLevel, net.minecraft.world.item.enchantment.EnchantedItemInUse context, net.minecraft.world.entity.Entity target, net.minecraft.world.phys.Vec3 epicenter) Dispatches the initial spell field application event to all registeredSpellFieldEventDispatcher.ApplyInterceptors.static floatdispatchBlockTarget(net.minecraft.server.level.ServerLevel level, int enchantmentLevel, net.minecraft.world.item.enchantment.EnchantedItemInUse context, net.minecraft.world.entity.Entity target, net.minecraft.core.BlockPos pos, float scalar) Dispatches the block target evaluation event sequentially to all registeredSpellFieldEventDispatcher.BlockTargetInterceptors, short-circuiting if the scalar drops to or below0.0001F.static floatdispatchEntityTarget(net.minecraft.server.level.ServerLevel level, int enchantmentLevel, net.minecraft.world.item.enchantment.EnchantedItemInUse context, net.minecraft.world.entity.Entity target, net.minecraft.world.entity.Entity victim, float scalar) Dispatches the entity target evaluation event sequentially to all registeredSpellFieldEventDispatcher.EntityTargetInterceptors, short-circuiting if the scalar drops to or below0.0001F.static voidRegisters a global spell field application interceptor.static voidRegisters a global block target interceptor.static voidRegisters a global entity target interceptor.
-
Constructor Details
-
SpellFieldEventDispatcher
public SpellFieldEventDispatcher()
-
-
Method Details
-
registerApplyInterceptor
Registers a global spell field application interceptor.- Parameters:
interceptor- TheSpellFieldEventDispatcher.ApplyInterceptorimplementation to register.
-
registerEntityTargetInterceptor
public static void registerEntityTargetInterceptor(SpellFieldEventDispatcher.EntityTargetInterceptor interceptor) Registers a global entity target interceptor.- Parameters:
interceptor- TheSpellFieldEventDispatcher.EntityTargetInterceptorimplementation to register.
-
registerBlockTargetInterceptor
public static void registerBlockTargetInterceptor(SpellFieldEventDispatcher.BlockTargetInterceptor interceptor) Registers a global block target interceptor.- Parameters:
interceptor- TheSpellFieldEventDispatcher.BlockTargetInterceptorimplementation to register.
-
dispatchApply
public static boolean dispatchApply(net.minecraft.server.level.ServerLevel level, int enchantmentLevel, net.minecraft.world.item.enchantment.EnchantedItemInUse context, net.minecraft.world.entity.Entity target, net.minecraft.world.phys.Vec3 epicenter) Dispatches the initial spell field application event to all registeredSpellFieldEventDispatcher.ApplyInterceptors.- Parameters:
level- The executing server level.enchantmentLevel- The level of the spell field enchantment.context- The item usage context triggering the spell field.target- The anchor entity or focal point of the spell field.epicenter- The exact spatial origin vector of the spell field.- Returns:
trueif all interceptors permit execution, orfalseif any interceptor cancels it.
-
dispatchEntityTarget
public static float dispatchEntityTarget(net.minecraft.server.level.ServerLevel level, int enchantmentLevel, net.minecraft.world.item.enchantment.EnchantedItemInUse context, net.minecraft.world.entity.Entity target, net.minecraft.world.entity.Entity victim, float scalar) Dispatches the entity target evaluation event sequentially to all registeredSpellFieldEventDispatcher.EntityTargetInterceptors, short-circuiting if the scalar drops to or below0.0001F.- Parameters:
level- The executing server level.enchantmentLevel- The level of the spell field enchantment.context- The item usage context triggering the spell field.target- The anchor entity or focal point of the spell field.victim- The entity targeted by the spell field.scalar- The initial topological multiplier.- Returns:
- The final modified scalar value after all interceptors execute.
-
dispatchBlockTarget
public static float dispatchBlockTarget(net.minecraft.server.level.ServerLevel level, int enchantmentLevel, net.minecraft.world.item.enchantment.EnchantedItemInUse context, net.minecraft.world.entity.Entity target, net.minecraft.core.BlockPos pos, float scalar) Dispatches the block target evaluation event sequentially to all registeredSpellFieldEventDispatcher.BlockTargetInterceptors, short-circuiting if the scalar drops to or below0.0001F.- Parameters:
level- The executing server level.enchantmentLevel- The level of the spell field enchantment.context- The item usage context triggering the spell field.target- The anchor entity or focal point of the spell field.pos- The block coordinate targeted by the spell field.scalar- The initial topological multiplier.- Returns:
- The final modified scalar value after all interceptors execute.
-