Class SpellFieldEventDispatcher

java.lang.Object
johnsmith.enchantmentcore.api.enchantment.spellfield.event.SpellFieldEventDispatcher

public class SpellFieldEventDispatcher extends Object
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).

  • Constructor Details

    • SpellFieldEventDispatcher

      public SpellFieldEventDispatcher()
  • Method Details

    • registerApplyInterceptor

      public static void registerApplyInterceptor(SpellFieldEventDispatcher.ApplyInterceptor interceptor)
      Registers a global spell field application interceptor.
      Parameters:
      interceptor - The SpellFieldEventDispatcher.ApplyInterceptor implementation to register.
    • registerEntityTargetInterceptor

      public static void registerEntityTargetInterceptor(SpellFieldEventDispatcher.EntityTargetInterceptor interceptor)
      Registers a global entity target interceptor.
      Parameters:
      interceptor - The SpellFieldEventDispatcher.EntityTargetInterceptor implementation to register.
    • registerBlockTargetInterceptor

      public static void registerBlockTargetInterceptor(SpellFieldEventDispatcher.BlockTargetInterceptor interceptor)
      Registers a global block target interceptor.
      Parameters:
      interceptor - The SpellFieldEventDispatcher.BlockTargetInterceptor implementation 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 registered SpellFieldEventDispatcher.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:
      true if all interceptors permit execution, or false if 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 registered SpellFieldEventDispatcher.EntityTargetInterceptors, short-circuiting if the scalar drops to or below 0.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 registered SpellFieldEventDispatcher.BlockTargetInterceptors, short-circuiting if the scalar drops to or below 0.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.