Interface AbilityHelper


public interface AbilityHelper
Helper for operations related to a Player's Abilitys.
  • Method Details

    • onMagicChange

      void onMagicChange(net.minecraft.world.entity.player.Player player, MagicAttachment oldData, MagicAttachment newData)
      Called when the Player's MagicAttachment changes. Updates the Abilitys accordingly.
      Parameters:
      player - The Player whose MagicAttachment changes.
      oldData - The old MagicAttachment.
      newData - The new MagicAttachment.
    • getActiveAbilities

      Stream<? extends net.minecraft.core.Holder<Ability>> getActiveAbilities(net.minecraft.world.entity.player.Player player)
      Parameters:
      player - The Player to query.
      Returns:
      The active Abilitys of the given Player.
    • getActiveAbilitiesWithEffect

      <T extends AbilityEffect> Stream<? extends com.mojang.datafixers.util.Pair<? extends net.minecraft.core.Holder<Ability>, List<T>>> getActiveAbilitiesWithEffect(net.minecraft.world.entity.player.Player player, com.mojang.serialization.MapCodec<T> effectCodec)
      Type Parameters:
      T - The exact AbilityEffect type.
      Parameters:
      player - The Player to query.
      effectCodec - The AbilityEffect type to filter for.
      Returns:
      A Stream of Pairs, each representing a Ability and its associated AbilityEffects.
    • triggerEventEffect

      <T extends net.neoforged.bus.api.Event> void triggerEventEffect(T event, net.minecraft.world.entity.player.Player player, com.mojang.serialization.MapCodec<? extends EventTriggeredAbilityEffect<T>> codec)
      Type Parameters:
      T - The exact Event type.
      Parameters:
      event - The Event to trigger the EventTriggeredAbilityEffect from.
      player - The Player causing the Event.
      codec - The AbilityEffect type.
    • scaleToDepth

      double scaleToDepth(net.minecraft.world.entity.player.Player player, Ability ability, double min, double max)
      Linearly scales the given Ability's range to the min and max provided, depending on the Player's depth. If the depth is at the minimum bound, returns the min value. If the depth is at the maximum bound, returns the max value. If the ability is somewhere in between, linear interpolation is performed.
      Parameters:
      player - The Player to query.
      ability - The Ability to get the range from.
      min - The min value to use.
      max - The max value to use.
      Returns:
      A scaled value.