Class LodestoneEnchantmentEffectActivator<T>

java.lang.Object
team.lodestar.lodestone.modules.toolkit.enchanting.LodestoneEnchantmentEffectActivator<T>

public class LodestoneEnchantmentEffectActivator<T> extends Object
A helper class to activate enchantment effects in a more convenient way than through the use of EnchantmentHelper.
  • Method Details

    • createEffectActivator

      public static <T> LodestoneEnchantmentEffectActivator<T> createEffectActivator(net.minecraft.core.component.DataComponentType<List<net.minecraft.world.item.enchantment.ConditionalEffect<T>>> componentType, net.minecraft.server.level.ServerLevel level)
      Creates an effect activator for non-targeted conditional effects.
      Parameters:
      componentType - The data component type to activate.
      level - A ServerLevel instance.
      Returns:
      The created effect activator.
    • createTargetedEffectActivator

      public static <T> LodestoneEnchantmentEffectActivator<T> createTargetedEffectActivator(net.minecraft.core.component.DataComponentType<List<net.minecraft.world.item.enchantment.TargetedConditionalEffect<T>>> componentType, net.minecraft.server.level.ServerLevel level)
      Creates an effect activator for targeted conditional effects.
      Parameters:
      componentType - The data component type to activate.
      level - A ServerLevel instance.
      Returns:
      The created effect activator.
    • setItemContext

      public LodestoneEnchantmentEffectActivator<T> setItemContext()
    • setDamageContext

      public LodestoneEnchantmentEffectActivator<T> setDamageContext(net.minecraft.server.level.ServerLevel level, net.minecraft.world.entity.Entity attackedEntity, net.minecraft.world.damagesource.DamageSource damageSource)
    • setEntityContext

      public LodestoneEnchantmentEffectActivator<T> setEntityContext(net.minecraft.server.level.ServerLevel level, net.minecraft.world.entity.Entity entity)
    • setEntityContext

      public LodestoneEnchantmentEffectActivator<T> setEntityContext(net.minecraft.server.level.ServerLevel level, net.minecraft.world.entity.Entity entity, net.minecraft.world.phys.Vec3 origin)
    • setContext

    • setTargetLimit

      public LodestoneEnchantmentEffectActivator<T> setTargetLimit(net.minecraft.world.item.enchantment.EnchantmentTarget targetLimit)
    • triggerEntityEffects

      public void triggerEntityEffects(net.minecraft.world.item.ItemStack enchantedItem, net.minecraft.world.entity.LivingEntity target)
    • triggerEntityEffects

      public void triggerEntityEffects(net.minecraft.world.item.ItemStack enchantedItem, net.minecraft.world.entity.LivingEntity enchanted, net.minecraft.world.entity.Entity target)
    • triggerEntityEffects

      public void triggerEntityEffects(net.minecraft.world.item.enchantment.EnchantedItemInUse enchantedItem, net.minecraft.world.entity.Entity target)
    • countValue

      public float countValue(net.minecraft.world.item.ItemStack enchantedItem, net.minecraft.world.entity.Entity target)
      Modifies the value provided using all EnchantmentValueEffect instances on the given item for the given target.
      Parameters:
      enchantedItem - The enchanted item.
      target - The entity the item belongs to.
      Returns:
      The total value of the enchantment value effect provided by the given item.
    • modifyValue

      public float modifyValue(net.minecraft.world.item.ItemStack enchantedItem, net.minecraft.world.entity.Entity target, float baseValue)
      Modifies the value provided using all EnchantmentValueEffect instances on the given item for the given target.
      Parameters:
      enchantedItem - The enchanted item.
      target - The entity the item belongs to.
      baseValue - The base value to modify.
      Returns:
      The total value of the enchantment value effect provided by the given item.
    • countValue

      public float countValue(net.minecraft.world.entity.LivingEntity target)
      Modifies the value provided using all EnchantmentValueEffect instances on the given item for the given target.
      Parameters:
      target - The entity the item belongs to.
      Returns:
      The total value of the enchantment value effect based on all items influencing the target entity.
    • modifyValue

      public float modifyValue(net.minecraft.world.entity.LivingEntity target, float baseValue)
      Modifies the value provided using all EnchantmentValueEffect instances on the given item for the given target.
      Parameters:
      target - The entity the item belongs to.
      baseValue - The base value to modify.
      Returns:
      The total value of the enchantment value effect based on all items influencing the target entity.
    • hasEffect

      public boolean hasEffect(net.minecraft.world.item.ItemStack enchantedItem, net.minecraft.world.entity.Entity target)
      Checks whether the given item has any effect instance of the type handled by this activator.
      Parameters:
      enchantedItem - The enchanted item.
      target - The entity the item belongs to.
      Returns:
      True if at least one effect is present, false otherwise.
    • applyEffects

      public void applyEffects(LodestoneEnchantmentEffectActivator.EnchantmentEffectAcceptor<T> acceptor, net.minecraft.world.item.ItemStack enchantedItem, net.minecraft.world.entity.Entity target)
      Triggers enchantment effects present on a specified item.
      Parameters:
      acceptor - The effect acceptor
      enchantedItem - The enchanted item.
      target - The entity to affect. In case of targeted effects, this ends up being the victim.
    • applyEffects

      public void applyEffects(LodestoneEnchantmentEffectActivator.EnchantmentEffectAcceptor<T> acceptor, net.minecraft.world.entity.LivingEntity target)
      Triggers all enchantment effects available to the given entity.
      Parameters:
      acceptor - The effect acceptor.
      target - The entity to affect. In case of targeted effects, this ends up being the victim.
    • entityContext

      public static net.minecraft.world.level.storage.loot.LootContext entityContext(net.minecraft.server.level.ServerLevel level, int enchantmentLevel, net.minecraft.world.entity.Entity entity, net.minecraft.world.phys.Vec3 origin, @Nullable net.minecraft.world.item.ItemStack tool)
    • damageContext

      public static net.minecraft.world.level.storage.loot.LootContext damageContext(net.minecraft.server.level.ServerLevel level, int enchantmentLevel, net.minecraft.world.entity.Entity entity, net.minecraft.world.damagesource.DamageSource damageSource, @Nullable net.minecraft.world.item.ItemStack tool)