Class EnchantmentHelper
java.lang.Object
net.minecraft.world.item.enchantment.EnchantmentHelper
-
Nested Class Summary
Modifier and TypeClassDescription(package private) static interface
(package private) static interface
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
canStoreEnchantments
(ItemStack p_330666_) static void
doPostAttackEffects
(ServerLevel p_345941_, Entity p_345661_, DamageSource p_345580_) static void
doPostAttackEffectsWithItemSource
(ServerLevel p_348463_, Entity p_348545_, DamageSource p_348552_, ItemStack p_348507_) static ItemStack
enchantItem
(RandomSource p_220293_, ItemStack p_220294_, int p_220295_, Stream<Holder<Enchantment>> p_345380_) static ItemStack
enchantItem
(RandomSource p_346328_, ItemStack p_346267_, int p_345272_, RegistryAccess p_345660_, Optional<? extends HolderSet<Enchantment>> p_345161_) static void
enchantItemFromProvider
(ItemStack p_345172_, RegistryAccess p_348593_, ResourceKey<EnchantmentProvider> p_345876_, DifficultyInstance p_348599_, RandomSource p_345717_) static void
filterCompatibleEnchantments
(List<EnchantmentInstance> p_44863_, EnchantmentInstance p_44864_) static void
forEachModifier
(ItemStack p_348634_, EquipmentSlotGroup p_348528_, BiConsumer<Holder<Attribute>, AttributeModifier> p_348554_) static void
forEachModifier
(ItemStack p_345685_, EquipmentSlot p_345123_, BiConsumer<Holder<Attribute>, AttributeModifier> p_345061_) static List
<EnchantmentInstance> getAvailableEnchantmentResults
(int p_44818_, ItemStack p_44819_, Stream<Holder<Enchantment>> p_345348_) private static DataComponentType
<ItemEnchantments> getComponentType
(ItemStack p_331909_) static float
getDamageProtection
(ServerLevel p_346015_, LivingEntity p_346118_, DamageSource p_44858_) static int
getEnchantmentCost
(RandomSource p_220288_, int p_220289_, int p_220290_, ItemStack p_220291_) static int
getEnchantmentLevel
(Holder<Enchantment> p_345086_, LivingEntity p_44838_) static ItemEnchantments
getEnchantmentsForCrafting
(ItemStack p_330538_) static int
getFishingLuckBonus
(ServerLevel p_346163_, ItemStack p_44905_, Entity p_345772_) static float
getFishingTimeReduction
(ServerLevel p_345589_, ItemStack p_344902_, Entity p_346054_) static <T> com.mojang.datafixers.util.Pair
<T, Integer> getHighestLevel
(ItemStack p_346269_, DataComponentType<T> p_345899_) static int
getItemEnchantmentLevel
(Holder<Enchantment> p_346179_, ItemStack p_44845_) Deprecated.static int
getPiercingCount
(ServerLevel p_345735_, ItemStack p_344942_, ItemStack p_345766_) static Optional
<EnchantedItemInUse> getRandomItemWith
(DataComponentType<?> p_345509_, LivingEntity p_44841_, Predicate<ItemStack> p_44842_) static int
getTagEnchantmentLevel
(Holder<Enchantment> p_346179_, ItemStack p_44845_) Gets the level of an enchantment from NBT.static int
getTridentReturnToOwnerAcceleration
(ServerLevel p_344814_, ItemStack p_346255_, Entity p_346332_) static float
getTridentSpinAttackStrength
(ItemStack p_352129_, LivingEntity p_345705_) static boolean
has
(ItemStack p_345474_, DataComponentType<?> p_344897_) static boolean
hasAnyEnchantments
(ItemStack p_332657_) static boolean
hasTag
(ItemStack p_345665_, TagKey<Enchantment> p_345928_) static boolean
isEnchantmentCompatible
(Collection<Holder<Enchantment>> p_44860_, Holder<Enchantment> p_345356_) static boolean
isImmuneToDamage
(ServerLevel p_346228_, LivingEntity p_345220_, DamageSource p_345884_) static float
modifyArmorEffectiveness
(ServerLevel p_345426_, ItemStack p_345454_, Entity p_345834_, DamageSource p_345082_, float p_344790_) static float
modifyCrossbowChargingTime
(ItemStack p_352460_, LivingEntity p_347534_, float p_345633_) static float
modifyDamage
(ServerLevel p_345523_, ItemStack p_345856_, Entity p_344995_, DamageSource p_345216_, float p_346025_) static int
modifyDurabilityToRepairFromXp
(ServerLevel p_345119_, ItemStack p_345686_, int p_344847_) static float
modifyFallBasedDamage
(ServerLevel p_345433_, ItemStack p_345368_, Entity p_345047_, DamageSource p_345711_, float p_346245_) static float
modifyKnockback
(ServerLevel p_346221_, ItemStack p_344862_, Entity p_345720_, DamageSource p_345322_, float p_345116_) static void
onHitBlock
(ServerLevel p_346213_, ItemStack p_344826_, LivingEntity p_345015_, Entity p_345210_, EquipmentSlot p_345889_, Vec3 p_345922_, BlockState p_350787_, Consumer<Item> p_348575_) static void
onProjectileSpawned
(ServerLevel p_345062_, ItemStack p_345805_, AbstractArrow p_346298_, Consumer<Item> p_348544_) static <T> Optional
<T> pickHighestLevel
(ItemStack p_345398_, DataComponentType<List<T>> p_346022_) static int
processAmmoUse
(ServerLevel p_344848_, ItemStack p_345072_, ItemStack p_345407_, int p_346289_) static int
processBlockExperience
(ServerLevel p_344948_, ItemStack p_345630_, int p_345026_) static int
processDurabilityChange
(ServerLevel p_345153_, ItemStack p_344889_, int p_345787_) static float
processEquipmentDropChance
(ServerLevel p_346339_, LivingEntity p_345864_, DamageSource p_345060_, float p_346089_) static int
processMobExperience
(ServerLevel p_344940_, Entity p_345838_, Entity p_345369_, int p_344901_) static int
processProjectileCount
(ServerLevel p_345598_, ItemStack p_346421_, Entity p_346006_, int p_346388_) static float
processProjectileSpread
(ServerLevel p_346048_, ItemStack p_345702_, Entity p_346314_, float p_346070_) private static void
runIterationOnEquipment
(LivingEntity p_344744_, EnchantmentHelper.EnchantmentInSlotVisitor p_345709_) private static void
runIterationOnItem
(ItemStack p_44852_, EquipmentSlot p_345566_, LivingEntity p_345792_, EnchantmentHelper.EnchantmentInSlotVisitor p_345683_) private static void
runIterationOnItem
(ItemStack p_345425_, EnchantmentHelper.EnchantmentVisitor p_345023_) static void
runLocationChangedEffects
(ServerLevel p_345674_, LivingEntity p_346396_) static void
runLocationChangedEffects
(ServerLevel p_345755_, ItemStack p_345291_, LivingEntity p_346348_, EquipmentSlot p_345919_) static List
<EnchantmentInstance> selectEnchantment
(RandomSource p_220298_, ItemStack p_220299_, int p_220300_, Stream<Holder<Enchantment>> p_346061_) static void
setEnchantments
(ItemStack p_44867_, ItemEnchantments p_332148_) static void
stopLocationBasedEffects
(LivingEntity p_346034_) static void
stopLocationBasedEffects
(ItemStack p_344726_, LivingEntity p_346085_, EquipmentSlot p_345691_) static void
tickEffects
(ServerLevel p_345788_, LivingEntity p_344873_) static ItemEnchantments
updateEnchantments
(ItemStack p_331034_, Consumer<ItemEnchantments.Mutable> p_332031_)
-
Constructor Details
-
EnchantmentHelper
public EnchantmentHelper()
-
-
Method Details
-
getItemEnchantmentLevel
@Deprecated public static int getItemEnchantmentLevel(Holder<Enchantment> p_346179_, ItemStack p_44845_) Deprecated.Neo: UsegetTagEnchantmentLevel(Holder, ItemStack)
for NBT enchantments, orIItemStackExtension.getEnchantmentLevel(Holder)
for gameplay. -
getTagEnchantmentLevel
Gets the level of an enchantment from NBT. UseIItemStackExtension.getEnchantmentLevel(Holder)
for gameplay logic. -
updateEnchantments
public static ItemEnchantments updateEnchantments(ItemStack p_331034_, Consumer<ItemEnchantments.Mutable> p_332031_) -
canStoreEnchantments
-
setEnchantments
-
getEnchantmentsForCrafting
-
getComponentType
-
hasAnyEnchantments
-
processDurabilityChange
public static int processDurabilityChange(ServerLevel p_345153_, ItemStack p_344889_, int p_345787_) -
processAmmoUse
public static int processAmmoUse(ServerLevel p_344848_, ItemStack p_345072_, ItemStack p_345407_, int p_346289_) -
processBlockExperience
-
processMobExperience
public static int processMobExperience(ServerLevel p_344940_, @Nullable Entity p_345838_, Entity p_345369_, int p_344901_) -
runIterationOnItem
private static void runIterationOnItem(ItemStack p_345425_, EnchantmentHelper.EnchantmentVisitor p_345023_) -
runIterationOnItem
private static void runIterationOnItem(ItemStack p_44852_, EquipmentSlot p_345566_, LivingEntity p_345792_, EnchantmentHelper.EnchantmentInSlotVisitor p_345683_) -
runIterationOnEquipment
private static void runIterationOnEquipment(LivingEntity p_344744_, EnchantmentHelper.EnchantmentInSlotVisitor p_345709_) -
isImmuneToDamage
public static boolean isImmuneToDamage(ServerLevel p_346228_, LivingEntity p_345220_, DamageSource p_345884_) -
getDamageProtection
public static float getDamageProtection(ServerLevel p_346015_, LivingEntity p_346118_, DamageSource p_44858_) -
modifyDamage
public static float modifyDamage(ServerLevel p_345523_, ItemStack p_345856_, Entity p_344995_, DamageSource p_345216_, float p_346025_) -
modifyFallBasedDamage
public static float modifyFallBasedDamage(ServerLevel p_345433_, ItemStack p_345368_, Entity p_345047_, DamageSource p_345711_, float p_346245_) -
modifyArmorEffectiveness
public static float modifyArmorEffectiveness(ServerLevel p_345426_, ItemStack p_345454_, Entity p_345834_, DamageSource p_345082_, float p_344790_) -
modifyKnockback
public static float modifyKnockback(ServerLevel p_346221_, ItemStack p_344862_, Entity p_345720_, DamageSource p_345322_, float p_345116_) -
doPostAttackEffects
public static void doPostAttackEffects(ServerLevel p_345941_, Entity p_345661_, DamageSource p_345580_) -
doPostAttackEffectsWithItemSource
public static void doPostAttackEffectsWithItemSource(ServerLevel p_348463_, Entity p_348545_, DamageSource p_348552_, @Nullable ItemStack p_348507_) -
runLocationChangedEffects
-
runLocationChangedEffects
public static void runLocationChangedEffects(ServerLevel p_345755_, ItemStack p_345291_, LivingEntity p_346348_, EquipmentSlot p_345919_) -
stopLocationBasedEffects
-
stopLocationBasedEffects
public static void stopLocationBasedEffects(ItemStack p_344726_, LivingEntity p_346085_, EquipmentSlot p_345691_) -
tickEffects
-
getEnchantmentLevel
-
processProjectileCount
public static int processProjectileCount(ServerLevel p_345598_, ItemStack p_346421_, Entity p_346006_, int p_346388_) -
processProjectileSpread
public static float processProjectileSpread(ServerLevel p_346048_, ItemStack p_345702_, Entity p_346314_, float p_346070_) -
getPiercingCount
-
onProjectileSpawned
public static void onProjectileSpawned(ServerLevel p_345062_, ItemStack p_345805_, AbstractArrow p_346298_, Consumer<Item> p_348544_) -
onHitBlock
public static void onHitBlock(ServerLevel p_346213_, ItemStack p_344826_, @Nullable LivingEntity p_345015_, Entity p_345210_, @Nullable EquipmentSlot p_345889_, Vec3 p_345922_, BlockState p_350787_, Consumer<Item> p_348575_) -
modifyDurabilityToRepairFromXp
public static int modifyDurabilityToRepairFromXp(ServerLevel p_345119_, ItemStack p_345686_, int p_344847_) -
processEquipmentDropChance
public static float processEquipmentDropChance(ServerLevel p_346339_, LivingEntity p_345864_, DamageSource p_345060_, float p_346089_) -
forEachModifier
public static void forEachModifier(ItemStack p_348634_, EquipmentSlotGroup p_348528_, BiConsumer<Holder<Attribute>, AttributeModifier> p_348554_) -
forEachModifier
public static void forEachModifier(ItemStack p_345685_, EquipmentSlot p_345123_, BiConsumer<Holder<Attribute>, AttributeModifier> p_345061_) -
getFishingLuckBonus
-
getFishingTimeReduction
public static float getFishingTimeReduction(ServerLevel p_345589_, ItemStack p_344902_, Entity p_346054_) -
getTridentReturnToOwnerAcceleration
public static int getTridentReturnToOwnerAcceleration(ServerLevel p_344814_, ItemStack p_346255_, Entity p_346332_) -
modifyCrossbowChargingTime
public static float modifyCrossbowChargingTime(ItemStack p_352460_, LivingEntity p_347534_, float p_345633_) -
getTridentSpinAttackStrength
-
hasTag
-
has
-
pickHighestLevel
public static <T> Optional<T> pickHighestLevel(ItemStack p_345398_, DataComponentType<List<T>> p_346022_) -
getHighestLevel
@Nullable public static <T> com.mojang.datafixers.util.Pair<T,Integer> getHighestLevel(ItemStack p_346269_, DataComponentType<T> p_345899_) -
getRandomItemWith
public static Optional<EnchantedItemInUse> getRandomItemWith(DataComponentType<?> p_345509_, LivingEntity p_44841_, Predicate<ItemStack> p_44842_) -
getEnchantmentCost
public static int getEnchantmentCost(RandomSource p_220288_, int p_220289_, int p_220290_, ItemStack p_220291_) -
enchantItem
public static ItemStack enchantItem(RandomSource p_346328_, ItemStack p_346267_, int p_345272_, RegistryAccess p_345660_, Optional<? extends HolderSet<Enchantment>> p_345161_) -
enchantItem
public static ItemStack enchantItem(RandomSource p_220293_, ItemStack p_220294_, int p_220295_, Stream<Holder<Enchantment>> p_345380_) -
selectEnchantment
public static List<EnchantmentInstance> selectEnchantment(RandomSource p_220298_, ItemStack p_220299_, int p_220300_, Stream<Holder<Enchantment>> p_346061_) -
filterCompatibleEnchantments
public static void filterCompatibleEnchantments(List<EnchantmentInstance> p_44863_, EnchantmentInstance p_44864_) -
isEnchantmentCompatible
public static boolean isEnchantmentCompatible(Collection<Holder<Enchantment>> p_44860_, Holder<Enchantment> p_345356_) -
getAvailableEnchantmentResults
public static List<EnchantmentInstance> getAvailableEnchantmentResults(int p_44818_, ItemStack p_44819_, Stream<Holder<Enchantment>> p_345348_) -
enchantItemFromProvider
public static void enchantItemFromProvider(ItemStack p_345172_, RegistryAccess p_348593_, ResourceKey<EnchantmentProvider> p_345876_, DifficultyInstance p_348599_, RandomSource p_345717_)
-
getTagEnchantmentLevel(Holder, ItemStack)
for NBT enchantments, orIItemStackExtension.getEnchantmentLevel(Holder)
for gameplay.