Class LodestoneEnchantmentEffectActivator<T>
java.lang.Object
team.lodestar.lodestone.systems.enchanting.LodestoneEnchantmentEffectActivator<T>
A helper class to activate enchantment effects in a more convenient way than through the use of
EnchantmentHelper.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfacestatic interface -
Method Summary
Modifier and TypeMethodDescriptionvoidapplyEffects(LodestoneEnchantmentEffectActivator.EnchantmentEffectAcceptor<T> acceptor, net.minecraft.world.entity.LivingEntity target) Triggers all enchantment effects available to the given entity.voidapplyEffects(LodestoneEnchantmentEffectActivator.EnchantmentEffectAcceptor<T> acceptor, net.minecraft.world.item.ItemStack enchantedItem, net.minecraft.world.entity.Entity target) Triggers enchantment effects present on a specified item.floatcountValue(net.minecraft.world.entity.LivingEntity target) Modifies the value provided using allEnchantmentValueEffectinstances on the given item for the given target.floatcountValue(net.minecraft.world.item.ItemStack enchantedItem, net.minecraft.world.entity.Entity target) Modifies the value provided using allEnchantmentValueEffectinstances on the given item for the given target.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.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.static net.minecraft.world.level.storage.loot.LootContextdamageContext(net.minecraft.server.level.ServerLevel level, int enchantmentLevel, net.minecraft.world.entity.Entity entity, net.minecraft.world.damagesource.DamageSource damageSource, net.minecraft.world.item.ItemStack tool) static net.minecraft.world.level.storage.loot.LootContextentityContext(net.minecraft.server.level.ServerLevel level, int enchantmentLevel, net.minecraft.world.entity.Entity entity, net.minecraft.world.phys.Vec3 origin, net.minecraft.world.item.ItemStack tool) booleanhasEffect(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.floatmodifyValue(net.minecraft.world.entity.LivingEntity target, float baseValue) Modifies the value provided using allEnchantmentValueEffectinstances on the given item for the given target.floatmodifyValue(net.minecraft.world.item.ItemStack enchantedItem, net.minecraft.world.entity.Entity target, float baseValue) Modifies the value provided using allEnchantmentValueEffectinstances on the given item for the given target.setContext(LodestoneEnchantmentEffectActivator.ContextSupplier contextSupplier) setDamageContext(net.minecraft.server.level.ServerLevel level, net.minecraft.world.entity.Entity attackedEntity, net.minecraft.world.damagesource.DamageSource damageSource) setEntityContext(net.minecraft.server.level.ServerLevel level, net.minecraft.world.entity.Entity entity) setEntityContext(net.minecraft.server.level.ServerLevel level, net.minecraft.world.entity.Entity entity, net.minecraft.world.phys.Vec3 origin) setTargetLimit(net.minecraft.world.item.enchantment.EnchantmentTarget targetLimit) voidtriggerEntityEffects(net.minecraft.world.item.enchantment.EnchantedItemInUse enchantedItem, net.minecraft.world.entity.Entity target) voidtriggerEntityEffects(net.minecraft.world.item.ItemStack enchantedItem, net.minecraft.world.entity.LivingEntity target) voidtriggerEntityEffects(net.minecraft.world.item.ItemStack enchantedItem, net.minecraft.world.entity.LivingEntity enchanted, net.minecraft.world.entity.Entity target)
-
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- AServerLevelinstance.- 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- AServerLevelinstance.- Returns:
- The created effect activator.
-
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
public LodestoneEnchantmentEffectActivator<T> setContext(LodestoneEnchantmentEffectActivator.ContextSupplier contextSupplier) -
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 allEnchantmentValueEffectinstances 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 allEnchantmentValueEffectinstances 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 allEnchantmentValueEffectinstances 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 allEnchantmentValueEffectinstances 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 acceptorenchantedItem- 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)
-