Interface AbilityHelper
public interface AbilityHelper
Helper for operations related to a
Player's Abilitys.-
Method Summary
Modifier and TypeMethodDescriptiongetActiveAbilities(net.minecraft.world.entity.player.Player player) <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) voidonMagicChange(net.minecraft.world.entity.player.Player player, MagicAttachment oldData, MagicAttachment newData) Called when thePlayer'sMagicAttachmentchanges.doublescaleToDepth(net.minecraft.world.entity.player.Player player, Ability ability, double min, double max) Linearly scales the givenAbility's range to the min and max provided, depending on thePlayer's depth.<T extends net.neoforged.bus.api.Event>
voidtriggerEventEffect(T event, net.minecraft.world.entity.player.Player player, com.mojang.serialization.MapCodec<? extends EventTriggeredAbilityEffect<T>> codec) Triggers anEventTriggeredAbilityEffect.
-
Method Details
-
onMagicChange
void onMagicChange(net.minecraft.world.entity.player.Player player, MagicAttachment oldData, MagicAttachment newData) - Parameters:
player- ThePlayerwhoseMagicAttachmentchanges.oldData- The oldMagicAttachment.newData- The newMagicAttachment.
-
getActiveAbilities
-
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 exactAbilityEffecttype.- Parameters:
player- ThePlayerto query.effectCodec- TheAbilityEffecttype to filter for.- Returns:
- A
StreamofPairs, each representing aAbilityand its associatedAbilityEffects.
-
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) Triggers anEventTriggeredAbilityEffect.- Type Parameters:
T- The exactEventtype.- Parameters:
event- TheEventto trigger theEventTriggeredAbilityEffectfrom.player- ThePlayercausing theEvent.codec- TheAbilityEffecttype.
-
scaleToDepth
double scaleToDepth(net.minecraft.world.entity.player.Player player, Ability ability, double min, double max) Linearly scales the givenAbility's range to the min and max provided, depending on thePlayer'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- ThePlayerto query.ability- TheAbilityto get the range from.min- The min value to use.max- The max value to use.- Returns:
- A scaled value.
-