Record Class Enchantment
java.lang.Object
java.lang.Record
net.minecraft.world.item.enchantment.Enchantment
public record Enchantment(Component description, Enchantment.EnchantmentDefinition definition, HolderSet<Enchantment> exclusiveSet, DataComponentMap effects)
extends Record
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic final recordstatic final record -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.serialization.Codec<Holder<Enchantment>> private final Enchantment.EnchantmentDefinitionThe field for thedefinitionrecord component.private final ComponentThe field for thedescriptionrecord component.static final com.mojang.serialization.Codec<Enchantment> private final DataComponentMapThe field for theeffectsrecord component.private final HolderSet<Enchantment> The field for theexclusiveSetrecord component.static final intstatic final StreamCodec<RegistryFriendlyByteBuf, Holder<Enchantment>> -
Constructor Summary
ConstructorsConstructorDescriptionEnchantment(Component description, Enchantment.EnchantmentDefinition definition, HolderSet<Enchantment> exclusiveSet, DataComponentMap effects) Creates an instance of aEnchantmentrecord class. -
Method Summary
Modifier and TypeMethodDescriptionprivate static <T> voidapplyEffects(List<ConditionalEffect<T>> p_345356_, LootContext p_343574_, Consumer<T> p_343387_) static booleanareCompatible(Holder<Enchantment> p_345028_, Holder<Enchantment> p_342568_) private static LootContextblockHitContext(ServerLevel p_342041_, int p_344013_, Entity p_345496_, Vec3 p_343741_, BlockState p_342321_) booleancanEnchant(ItemStack p_44689_) static Enchantment.CostconstantCost(int p_334530_) static LootContextdamageContext(ServerLevel p_342651_, int p_344201_, Entity p_345425_, DamageSource p_343766_) Returns the value of thedefinitionrecord component.definition(HolderSet<Item> p_342934_, int p_329635_, int p_331888_, Enchantment.Cost p_328182_, Enchantment.Cost p_328787_, int p_333931_, EquipmentSlotGroup... p_342587_) definition(HolderSet<Item> p_345362_, HolderSet<Item> p_343516_, int p_328611_, int p_336009_, Enchantment.Cost p_330605_, Enchantment.Cost p_333983_, int p_327771_, EquipmentSlotGroup... p_344843_) Returns the value of thedescriptionrecord component.voiddoPostAttack(ServerLevel p_342826_, int p_343675_, EnchantedItemInUse p_343641_, EnchantmentTarget p_342372_, Entity p_344548_, DamageSource p_342692_) static voiddoPostAttack(TargetedConditionalEffect<EnchantmentEntityEffect> p_344913_, ServerLevel p_344428_, int p_44688_, EnchantedItemInUse p_344260_, Entity p_44687_, DamageSource p_344028_) static Enchantment.CostdynamicCost(int p_334326_, int p_335507_) effects()Returns the value of theeffectsrecord component.static Enchantment.Builderenchantment(Enchantment.EnchantmentDefinition p_342298_) private static LootContextentityContext(ServerLevel p_342654_, int p_343984_, Entity p_342853_, Vec3 p_343585_) final booleanIndicates whether some other object is "equal to" this one.Returns the value of theexclusiveSetrecord component.int<T> List<T> getEffects(DataComponentType<List<T>> p_344699_) static ComponentgetFullname(Holder<Enchantment> p_342825_, int p_44701_) intgetMaxCost(int p_44691_) intintgetMinCost(int p_44679_) intgetSlotItems(LivingEntity p_44685_) intfinal inthashCode()Returns a hash code value for this object.booleanisImmuneToDamage(ServerLevel p_344493_, int p_345313_, Entity p_342613_, DamageSource p_345401_) booleanisPrimaryItem(ItemStack p_334183_) booleanisSupportedItem(ItemStack p_343312_) private static LootContextitemContext(ServerLevel p_344430_, int p_344526_, ItemStack p_343134_) private static LootContextlocationContext(ServerLevel p_342658_, int p_342243_, Entity p_345215_, boolean p_342535_) booleanmatchingSlot(EquipmentSlot p_344889_) voidmodifyAmmoCount(ServerLevel p_342942_, int p_342884_, ItemStack p_344742_, org.apache.commons.lang3.mutable.MutableFloat p_343607_) voidmodifyArmorEffectivness(ServerLevel p_345291_, int p_343247_, ItemStack p_343537_, Entity p_344244_, DamageSource p_344953_, org.apache.commons.lang3.mutable.MutableFloat p_345146_) voidmodifyBlockExperience(ServerLevel p_342072_, int p_343543_, ItemStack p_343319_, org.apache.commons.lang3.mutable.MutableFloat p_342766_) voidmodifyCrossbowChargeTime(RandomSource p_345467_, int p_343593_, org.apache.commons.lang3.mutable.MutableFloat p_343046_) voidmodifyDamage(ServerLevel p_343328_, int p_344751_, ItemStack p_342664_, Entity p_344239_, DamageSource p_345253_, org.apache.commons.lang3.mutable.MutableFloat p_344727_) private voidmodifyDamageFilteredValue(DataComponentType<List<ConditionalEffect<EnchantmentValueEffect>>> p_342460_, ServerLevel p_344318_, int p_343892_, ItemStack p_345407_, Entity p_343559_, DamageSource p_344560_, org.apache.commons.lang3.mutable.MutableFloat p_344658_) voidmodifyDamageProtection(ServerLevel p_344642_, int p_344297_, ItemStack p_345382_, Entity p_342229_, DamageSource p_342824_, org.apache.commons.lang3.mutable.MutableFloat p_345325_) voidmodifyDurabilityChange(ServerLevel p_342774_, int p_345090_, ItemStack p_343700_, org.apache.commons.lang3.mutable.MutableFloat p_343591_) voidmodifyDurabilityToRepairFromXp(ServerLevel p_343302_, int p_343123_, ItemStack p_343007_, org.apache.commons.lang3.mutable.MutableFloat p_342327_) private voidmodifyEntityFilteredValue(DataComponentType<List<ConditionalEffect<EnchantmentValueEffect>>> p_343552_, ServerLevel p_344107_, int p_342319_, ItemStack p_342576_, Entity p_343285_, org.apache.commons.lang3.mutable.MutableFloat p_342059_) voidmodifyFallBasedDamage(ServerLevel p_344377_, int p_342769_, ItemStack p_344741_, Entity p_344920_, DamageSource p_345151_, org.apache.commons.lang3.mutable.MutableFloat p_343049_) voidmodifyFishingLuckBonus(ServerLevel p_342216_, int p_343343_, ItemStack p_344550_, Entity p_343347_, org.apache.commons.lang3.mutable.MutableFloat p_345240_) voidmodifyFishingTimeReduction(ServerLevel p_343004_, int p_344690_, ItemStack p_342235_, Entity p_344564_, org.apache.commons.lang3.mutable.MutableFloat p_345086_) private voidmodifyItemFilteredCount(DataComponentType<List<ConditionalEffect<EnchantmentValueEffect>>> p_342071_, ServerLevel p_342667_, int p_344856_, ItemStack p_343442_, org.apache.commons.lang3.mutable.MutableFloat p_342223_) voidmodifyKnockback(ServerLevel p_345022_, int p_343469_, ItemStack p_343441_, Entity p_345003_, DamageSource p_345200_, org.apache.commons.lang3.mutable.MutableFloat p_345434_) voidmodifyMobExperience(ServerLevel p_343695_, int p_342521_, ItemStack p_344064_, Entity p_342215_, org.apache.commons.lang3.mutable.MutableFloat p_345517_) voidmodifyPiercingCount(ServerLevel p_342338_, int p_344838_, ItemStack p_343994_, org.apache.commons.lang3.mutable.MutableFloat p_342065_) voidmodifyProjectileCount(ServerLevel p_344710_, int p_344927_, ItemStack p_343332_, Entity p_344173_, org.apache.commons.lang3.mutable.MutableFloat p_345307_) voidmodifyProjectileSpread(ServerLevel p_342398_, int p_342291_, ItemStack p_345308_, Entity p_343809_, org.apache.commons.lang3.mutable.MutableFloat p_343769_) voidmodifyTridentReturnToOwnerAcceleration(ServerLevel p_344014_, int p_345042_, ItemStack p_343051_, Entity p_342961_, org.apache.commons.lang3.mutable.MutableFloat p_343498_) voidmodifyTridentSpinAttackStrength(RandomSource p_343013_, int p_342342_, org.apache.commons.lang3.mutable.MutableFloat p_342582_) voidmodifyUnfilteredValue(DataComponentType<EnchantmentValueEffect> p_342685_, RandomSource p_344622_, int p_343957_, org.apache.commons.lang3.mutable.MutableFloat p_342813_) voidonHitBlock(ServerLevel p_343964_, int p_343622_, EnchantedItemInUse p_344872_, Entity p_342891_, Vec3 p_344312_, BlockState p_345016_) voidonProjectileSpawned(ServerLevel p_344400_, int p_344273_, EnchantedItemInUse p_342998_, Entity p_344540_) voidrunLocationChangedEffects(ServerLevel p_343889_, int p_344660_, EnchantedItemInUse p_344903_, LivingEntity p_342969_) voidstopLocationBasedEffects(int p_342505_, EnchantedItemInUse p_342723_, LivingEntity p_345268_) voidtick(ServerLevel p_345036_, int p_344388_, EnchantedItemInUse p_344279_, Entity p_342497_) toString()Returns a string representation of this record class.
-
Field Details
-
description
The field for thedescriptionrecord component. -
definition
The field for thedefinitionrecord component. -
exclusiveSet
The field for theexclusiveSetrecord component. -
effects
The field for theeffectsrecord component. -
MAX_LEVEL
public static final int MAX_LEVEL- See Also:
-
DIRECT_CODEC
-
CODEC
-
STREAM_CODEC
-
-
Constructor Details
-
Enchantment
public Enchantment(Component description, Enchantment.EnchantmentDefinition definition, HolderSet<Enchantment> exclusiveSet, DataComponentMap effects) Creates an instance of aEnchantmentrecord class.- Parameters:
description- the value for thedescriptionrecord componentdefinition- the value for thedefinitionrecord componentexclusiveSet- the value for theexclusiveSetrecord componenteffects- the value for theeffectsrecord component
-
-
Method Details
-
constantCost
-
dynamicCost
-
definition
public static Enchantment.EnchantmentDefinition definition(HolderSet<Item> p_345362_, HolderSet<Item> p_343516_, int p_328611_, int p_336009_, Enchantment.Cost p_330605_, Enchantment.Cost p_333983_, int p_327771_, EquipmentSlotGroup... p_344843_) -
definition
public static Enchantment.EnchantmentDefinition definition(HolderSet<Item> p_342934_, int p_329635_, int p_331888_, Enchantment.Cost p_328182_, Enchantment.Cost p_328787_, int p_333931_, EquipmentSlotGroup... p_342587_) -
getSlotItems
-
getSupportedItems
-
matchingSlot
-
isPrimaryItem
-
isSupportedItem
-
getWeight
public int getWeight() -
getAnvilCost
public int getAnvilCost() -
getMinLevel
public int getMinLevel() -
getMaxLevel
public int getMaxLevel() -
getMinCost
public int getMinCost(int p_44679_) -
getMaxCost
public int getMaxCost(int p_44691_) -
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
areCompatible
-
getFullname
-
canEnchant
-
getEffects
-
isImmuneToDamage
public boolean isImmuneToDamage(ServerLevel p_344493_, int p_345313_, Entity p_342613_, DamageSource p_345401_) -
modifyDamageProtection
public void modifyDamageProtection(ServerLevel p_344642_, int p_344297_, ItemStack p_345382_, Entity p_342229_, DamageSource p_342824_, org.apache.commons.lang3.mutable.MutableFloat p_345325_) -
modifyDurabilityChange
public void modifyDurabilityChange(ServerLevel p_342774_, int p_345090_, ItemStack p_343700_, org.apache.commons.lang3.mutable.MutableFloat p_343591_) -
modifyAmmoCount
public void modifyAmmoCount(ServerLevel p_342942_, int p_342884_, ItemStack p_344742_, org.apache.commons.lang3.mutable.MutableFloat p_343607_) -
modifyPiercingCount
public void modifyPiercingCount(ServerLevel p_342338_, int p_344838_, ItemStack p_343994_, org.apache.commons.lang3.mutable.MutableFloat p_342065_) -
modifyBlockExperience
public void modifyBlockExperience(ServerLevel p_342072_, int p_343543_, ItemStack p_343319_, org.apache.commons.lang3.mutable.MutableFloat p_342766_) -
modifyMobExperience
public void modifyMobExperience(ServerLevel p_343695_, int p_342521_, ItemStack p_344064_, Entity p_342215_, org.apache.commons.lang3.mutable.MutableFloat p_345517_) -
modifyDurabilityToRepairFromXp
public void modifyDurabilityToRepairFromXp(ServerLevel p_343302_, int p_343123_, ItemStack p_343007_, org.apache.commons.lang3.mutable.MutableFloat p_342327_) -
modifyTridentReturnToOwnerAcceleration
public void modifyTridentReturnToOwnerAcceleration(ServerLevel p_344014_, int p_345042_, ItemStack p_343051_, Entity p_342961_, org.apache.commons.lang3.mutable.MutableFloat p_343498_) -
modifyTridentSpinAttackStrength
public void modifyTridentSpinAttackStrength(RandomSource p_343013_, int p_342342_, org.apache.commons.lang3.mutable.MutableFloat p_342582_) -
modifyFishingTimeReduction
public void modifyFishingTimeReduction(ServerLevel p_343004_, int p_344690_, ItemStack p_342235_, Entity p_344564_, org.apache.commons.lang3.mutable.MutableFloat p_345086_) -
modifyFishingLuckBonus
public void modifyFishingLuckBonus(ServerLevel p_342216_, int p_343343_, ItemStack p_344550_, Entity p_343347_, org.apache.commons.lang3.mutable.MutableFloat p_345240_) -
modifyDamage
public void modifyDamage(ServerLevel p_343328_, int p_344751_, ItemStack p_342664_, Entity p_344239_, DamageSource p_345253_, org.apache.commons.lang3.mutable.MutableFloat p_344727_) -
modifyFallBasedDamage
public void modifyFallBasedDamage(ServerLevel p_344377_, int p_342769_, ItemStack p_344741_, Entity p_344920_, DamageSource p_345151_, org.apache.commons.lang3.mutable.MutableFloat p_343049_) -
modifyKnockback
public void modifyKnockback(ServerLevel p_345022_, int p_343469_, ItemStack p_343441_, Entity p_345003_, DamageSource p_345200_, org.apache.commons.lang3.mutable.MutableFloat p_345434_) -
modifyArmorEffectivness
public void modifyArmorEffectivness(ServerLevel p_345291_, int p_343247_, ItemStack p_343537_, Entity p_344244_, DamageSource p_344953_, org.apache.commons.lang3.mutable.MutableFloat p_345146_) -
doPostAttack
public static void doPostAttack(TargetedConditionalEffect<EnchantmentEntityEffect> p_344913_, ServerLevel p_344428_, int p_44688_, EnchantedItemInUse p_344260_, Entity p_44687_, DamageSource p_344028_) -
doPostAttack
public void doPostAttack(ServerLevel p_342826_, int p_343675_, EnchantedItemInUse p_343641_, EnchantmentTarget p_342372_, Entity p_344548_, DamageSource p_342692_) -
modifyProjectileCount
public void modifyProjectileCount(ServerLevel p_344710_, int p_344927_, ItemStack p_343332_, Entity p_344173_, org.apache.commons.lang3.mutable.MutableFloat p_345307_) -
modifyProjectileSpread
public void modifyProjectileSpread(ServerLevel p_342398_, int p_342291_, ItemStack p_345308_, Entity p_343809_, org.apache.commons.lang3.mutable.MutableFloat p_343769_) -
modifyCrossbowChargeTime
public void modifyCrossbowChargeTime(RandomSource p_345467_, int p_343593_, org.apache.commons.lang3.mutable.MutableFloat p_343046_) -
modifyUnfilteredValue
public void modifyUnfilteredValue(DataComponentType<EnchantmentValueEffect> p_342685_, RandomSource p_344622_, int p_343957_, org.apache.commons.lang3.mutable.MutableFloat p_342813_) -
tick
public void tick(ServerLevel p_345036_, int p_344388_, EnchantedItemInUse p_344279_, Entity p_342497_) -
onProjectileSpawned
public void onProjectileSpawned(ServerLevel p_344400_, int p_344273_, EnchantedItemInUse p_342998_, Entity p_344540_) -
onHitBlock
public void onHitBlock(ServerLevel p_343964_, int p_343622_, EnchantedItemInUse p_344872_, Entity p_342891_, Vec3 p_344312_, BlockState p_345016_) -
modifyItemFilteredCount
private void modifyItemFilteredCount(DataComponentType<List<ConditionalEffect<EnchantmentValueEffect>>> p_342071_, ServerLevel p_342667_, int p_344856_, ItemStack p_343442_, org.apache.commons.lang3.mutable.MutableFloat p_342223_) -
modifyEntityFilteredValue
private void modifyEntityFilteredValue(DataComponentType<List<ConditionalEffect<EnchantmentValueEffect>>> p_343552_, ServerLevel p_344107_, int p_342319_, ItemStack p_342576_, Entity p_343285_, org.apache.commons.lang3.mutable.MutableFloat p_342059_) -
modifyDamageFilteredValue
private void modifyDamageFilteredValue(DataComponentType<List<ConditionalEffect<EnchantmentValueEffect>>> p_342460_, ServerLevel p_344318_, int p_343892_, ItemStack p_345407_, Entity p_343559_, DamageSource p_344560_, org.apache.commons.lang3.mutable.MutableFloat p_344658_) -
damageContext
public static LootContext damageContext(ServerLevel p_342651_, int p_344201_, Entity p_345425_, DamageSource p_343766_) -
itemContext
-
locationContext
private static LootContext locationContext(ServerLevel p_342658_, int p_342243_, Entity p_345215_, boolean p_342535_) -
entityContext
private static LootContext entityContext(ServerLevel p_342654_, int p_343984_, Entity p_342853_, Vec3 p_343585_) -
blockHitContext
private static LootContext blockHitContext(ServerLevel p_342041_, int p_344013_, Entity p_345496_, Vec3 p_343741_, BlockState p_342321_) -
applyEffects
private static <T> void applyEffects(List<ConditionalEffect<T>> p_345356_, LootContext p_343574_, Consumer<T> p_343387_) -
runLocationChangedEffects
public void runLocationChangedEffects(ServerLevel p_343889_, int p_344660_, EnchantedItemInUse p_344903_, LivingEntity p_342969_) -
stopLocationBasedEffects
public void stopLocationBasedEffects(int p_342505_, EnchantedItemInUse p_342723_, LivingEntity p_345268_) -
enchantment
-
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
description
Returns the value of thedescriptionrecord component.- Returns:
- the value of the
descriptionrecord component
-
definition
Returns the value of thedefinitionrecord component.- Returns:
- the value of the
definitionrecord component
-
exclusiveSet
Returns the value of theexclusiveSetrecord component.- Returns:
- the value of the
exclusiveSetrecord component
-
effects
Returns the value of theeffectsrecord component.- Returns:
- the value of the
effectsrecord component
-