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
Modifier and TypeClassDescriptionstatic class
static final record
static final record
-
Field Summary
Modifier and TypeFieldDescriptionstatic final com.mojang.serialization.Codec
<Holder<Enchantment>> private final Enchantment.EnchantmentDefinition
The field for thedefinition
record component.private final Component
The field for thedescription
record component.static final com.mojang.serialization.Codec
<Enchantment> private final DataComponentMap
The field for theeffects
record component.private final HolderSet
<Enchantment> The field for theexclusiveSet
record component.static final int
static final StreamCodec
<RegistryFriendlyByteBuf, Holder<Enchantment>> -
Constructor Summary
ConstructorDescriptionEnchantment
(Component description, Enchantment.EnchantmentDefinition definition, HolderSet<Enchantment> exclusiveSet, DataComponentMap effects) Creates an instance of aEnchantment
record class. -
Method Summary
Modifier and TypeMethodDescriptionprivate static <T> void
applyEffects
(List<ConditionalEffect<T>> p_345860_, LootContext p_345578_, Consumer<T> p_346164_) static boolean
areCompatible
(Holder<Enchantment> p_345800_, Holder<Enchantment> p_346143_) private static LootContext
blockHitContext
(ServerLevel p_350329_, int p_350503_, Entity p_350451_, Vec3 p_350874_, BlockState p_350311_) boolean
canEnchant
(ItemStack p_44689_) static Enchantment.Cost
constantCost
(int p_336195_) static LootContext
damageContext
(ServerLevel p_346018_, int p_345520_, Entity p_345257_, DamageSource p_346340_) Returns the value of thedefinition
record component.definition
(HolderSet<Item> p_345097_, int p_335557_, int p_336051_, Enchantment.Cost p_336176_, Enchantment.Cost p_335380_, int p_335569_, EquipmentSlotGroup... p_345444_) definition
(HolderSet<Item> p_345738_, HolderSet<Item> p_345428_, int p_335506_, int p_335598_, Enchantment.Cost p_336185_, Enchantment.Cost p_335768_, int p_335409_, EquipmentSlotGroup... p_344907_) Returns the value of thedescription
record component.void
doPostAttack
(ServerLevel p_344857_, int p_44688_, EnchantedItemInUse p_345323_, EnchantmentTarget p_345287_, Entity p_44687_, DamageSource p_345177_) static void
doPostAttack
(TargetedConditionalEffect<EnchantmentEntityEffect> p_346387_, ServerLevel p_345844_, int p_344928_, EnchantedItemInUse p_345486_, Entity p_345472_, DamageSource p_345022_) static Enchantment.Cost
dynamicCost
(int p_336066_, int p_336018_) effects()
Returns the value of theeffects
record component.static Enchantment.Builder
enchantment
(Enchantment.EnchantmentDefinition p_345873_) private static LootContext
entityContext
(ServerLevel p_346134_, int p_346059_, Entity p_346146_, Vec3 p_345814_) final boolean
Indicates whether some other object is "equal to" this one.Returns the value of theexclusiveSet
record component.int
<T> List
<T> getEffects
(DataComponentType<List<T>> p_345422_) static Component
getFullname
(Holder<Enchantment> p_345597_, int p_44701_) int
getMaxCost
(int p_44691_) int
int
getMinCost
(int p_44679_) int
getSlotItems
(LivingEntity p_44685_) int
final int
hashCode()
Returns a hash code value for this object.boolean
isImmuneToDamage
(ServerLevel p_345480_, int p_345043_, Entity p_346344_, DamageSource p_344985_) boolean
isPrimaryItem
(ItemStack p_336088_) Deprecated.boolean
isSupportedItem
(ItemStack p_344865_) private static LootContext
itemContext
(ServerLevel p_345514_, int p_345186_, ItemStack p_344997_) private static LootContext
locationContext
(ServerLevel p_345134_, int p_346182_, Entity p_345416_, boolean p_345862_) boolean
matchingSlot
(EquipmentSlot p_345146_) void
modifyAmmoCount
(ServerLevel p_346007_, int p_345438_, ItemStack p_345581_, org.apache.commons.lang3.mutable.MutableFloat p_345594_) void
modifyArmorEffectivness
(ServerLevel p_345449_, int p_346129_, ItemStack p_345436_, Entity p_345815_, DamageSource p_346172_, org.apache.commons.lang3.mutable.MutableFloat p_345265_) void
modifyBlockExperience
(ServerLevel p_344830_, int p_345513_, ItemStack p_344939_, org.apache.commons.lang3.mutable.MutableFloat p_344754_) void
modifyCrossbowChargeTime
(RandomSource p_347712_, int p_345448_, org.apache.commons.lang3.mutable.MutableFloat p_345713_) void
modifyDamage
(ServerLevel p_345743_, int p_345544_, ItemStack p_345269_, Entity p_346011_, DamageSource p_344755_, org.apache.commons.lang3.mutable.MutableFloat p_345551_) private void
modifyDamageFilteredValue
(DataComponentType<List<ConditionalEffect<EnchantmentValueEffect>>> p_345367_, ServerLevel p_345784_, int p_344796_, ItemStack p_345410_, Entity p_345673_, DamageSource p_345768_, org.apache.commons.lang3.mutable.MutableFloat p_345664_) void
modifyDamageProtection
(ServerLevel p_345336_, int p_345347_, ItemStack p_346270_, Entity p_346395_, DamageSource p_345595_, org.apache.commons.lang3.mutable.MutableFloat p_345579_) void
modifyDurabilityChange
(ServerLevel p_345412_, int p_344937_, ItemStack p_345854_, org.apache.commons.lang3.mutable.MutableFloat p_345948_) void
modifyDurabilityToRepairFromXp
(ServerLevel p_346275_, int p_346253_, ItemStack p_346008_, org.apache.commons.lang3.mutable.MutableFloat p_344922_) private void
modifyEntityFilteredValue
(DataComponentType<List<ConditionalEffect<EnchantmentValueEffect>>> p_345986_, ServerLevel p_345473_, int p_345352_, ItemStack p_345076_, Entity p_345170_, org.apache.commons.lang3.mutable.MutableFloat p_345910_) void
modifyFallBasedDamage
(ServerLevel p_345164_, int p_344793_, ItemStack p_345159_, Entity p_345653_, DamageSource p_344870_, org.apache.commons.lang3.mutable.MutableFloat p_346329_) void
modifyFishingLuckBonus
(ServerLevel p_344932_, int p_346280_, ItemStack p_344733_, Entity p_346035_, org.apache.commons.lang3.mutable.MutableFloat p_345897_) void
modifyFishingTimeReduction
(ServerLevel p_344910_, int p_345466_, ItemStack p_345847_, Entity p_346092_, org.apache.commons.lang3.mutable.MutableFloat p_346295_) private void
modifyItemFilteredCount
(DataComponentType<List<ConditionalEffect<EnchantmentValueEffect>>> p_345794_, ServerLevel p_345992_, int p_345038_, ItemStack p_345886_, org.apache.commons.lang3.mutable.MutableFloat p_345188_) void
modifyKnockback
(ServerLevel p_346266_, int p_344905_, ItemStack p_345602_, Entity p_346190_, DamageSource p_345911_, org.apache.commons.lang3.mutable.MutableFloat p_345127_) void
modifyMobExperience
(ServerLevel p_346393_, int p_345762_, ItemStack p_345945_, Entity p_345849_, org.apache.commons.lang3.mutable.MutableFloat p_345252_) void
modifyPiercingCount
(ServerLevel p_346422_, int p_344854_, ItemStack p_345503_, org.apache.commons.lang3.mutable.MutableFloat p_345370_) void
modifyProjectileCount
(ServerLevel p_345353_, int p_344837_, ItemStack p_346382_, Entity p_345611_, org.apache.commons.lang3.mutable.MutableFloat p_344765_) void
modifyProjectileSpread
(ServerLevel p_346170_, int p_345846_, ItemStack p_346147_, Entity p_345832_, org.apache.commons.lang3.mutable.MutableFloat p_345361_) void
modifyTridentReturnToOwnerAcceleration
(ServerLevel p_345534_, int p_345845_, ItemStack p_345558_, Entity p_345333_, org.apache.commons.lang3.mutable.MutableFloat p_344912_) void
modifyTridentSpinAttackStrength
(RandomSource p_347594_, int p_344845_, org.apache.commons.lang3.mutable.MutableFloat p_346377_) void
modifyUnfilteredValue
(DataComponentType<EnchantmentValueEffect> p_347468_, RandomSource p_347513_, int p_347494_, org.apache.commons.lang3.mutable.MutableFloat p_347716_) void
onHitBlock
(ServerLevel p_345175_, int p_346193_, EnchantedItemInUse p_344721_, Entity p_345951_, Vec3 p_344878_, BlockState p_351026_) void
onProjectileSpawned
(ServerLevel p_345440_, int p_346424_, EnchantedItemInUse p_346046_, Entity p_345958_) void
runLocationChangedEffects
(ServerLevel p_345522_, int p_345228_, EnchantedItemInUse p_345521_, LivingEntity p_346133_) void
stopLocationBasedEffects
(int p_345030_, EnchantedItemInUse p_345497_, LivingEntity p_344904_) void
tick
(ServerLevel p_345064_, int p_346148_, EnchantedItemInUse p_345056_, Entity p_345139_) toString()
Returns a string representation of this record class.
-
Field Details
-
description
The field for thedescription
record component. -
definition
The field for thedefinition
record component. -
exclusiveSet
The field for theexclusiveSet
record component. -
effects
The field for theeffects
record 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 aEnchantment
record class.- Parameters:
description
- the value for thedescription
record componentdefinition
- the value for thedefinition
record componentexclusiveSet
- the value for theexclusiveSet
record componenteffects
- the value for theeffects
record component
-
-
Method Details
-
constantCost
-
dynamicCost
-
definition
public static Enchantment.EnchantmentDefinition definition(HolderSet<Item> p_345738_, HolderSet<Item> p_345428_, int p_335506_, int p_335598_, Enchantment.Cost p_336185_, Enchantment.Cost p_335768_, int p_335409_, EquipmentSlotGroup... p_344907_) -
definition
public static Enchantment.EnchantmentDefinition definition(HolderSet<Item> p_345097_, int p_335557_, int p_336051_, Enchantment.Cost p_336176_, Enchantment.Cost p_335380_, int p_335569_, EquipmentSlotGroup... p_345444_) -
getSlotItems
-
getSupportedItems
-
matchingSlot
-
isPrimaryItem
Deprecated. -
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_345480_, int p_345043_, Entity p_346344_, DamageSource p_344985_) -
modifyDamageProtection
public void modifyDamageProtection(ServerLevel p_345336_, int p_345347_, ItemStack p_346270_, Entity p_346395_, DamageSource p_345595_, org.apache.commons.lang3.mutable.MutableFloat p_345579_) -
modifyDurabilityChange
public void modifyDurabilityChange(ServerLevel p_345412_, int p_344937_, ItemStack p_345854_, org.apache.commons.lang3.mutable.MutableFloat p_345948_) -
modifyAmmoCount
public void modifyAmmoCount(ServerLevel p_346007_, int p_345438_, ItemStack p_345581_, org.apache.commons.lang3.mutable.MutableFloat p_345594_) -
modifyPiercingCount
public void modifyPiercingCount(ServerLevel p_346422_, int p_344854_, ItemStack p_345503_, org.apache.commons.lang3.mutable.MutableFloat p_345370_) -
modifyBlockExperience
public void modifyBlockExperience(ServerLevel p_344830_, int p_345513_, ItemStack p_344939_, org.apache.commons.lang3.mutable.MutableFloat p_344754_) -
modifyMobExperience
public void modifyMobExperience(ServerLevel p_346393_, int p_345762_, ItemStack p_345945_, Entity p_345849_, org.apache.commons.lang3.mutable.MutableFloat p_345252_) -
modifyDurabilityToRepairFromXp
public void modifyDurabilityToRepairFromXp(ServerLevel p_346275_, int p_346253_, ItemStack p_346008_, org.apache.commons.lang3.mutable.MutableFloat p_344922_) -
modifyTridentReturnToOwnerAcceleration
public void modifyTridentReturnToOwnerAcceleration(ServerLevel p_345534_, int p_345845_, ItemStack p_345558_, Entity p_345333_, org.apache.commons.lang3.mutable.MutableFloat p_344912_) -
modifyTridentSpinAttackStrength
public void modifyTridentSpinAttackStrength(RandomSource p_347594_, int p_344845_, org.apache.commons.lang3.mutable.MutableFloat p_346377_) -
modifyFishingTimeReduction
public void modifyFishingTimeReduction(ServerLevel p_344910_, int p_345466_, ItemStack p_345847_, Entity p_346092_, org.apache.commons.lang3.mutable.MutableFloat p_346295_) -
modifyFishingLuckBonus
public void modifyFishingLuckBonus(ServerLevel p_344932_, int p_346280_, ItemStack p_344733_, Entity p_346035_, org.apache.commons.lang3.mutable.MutableFloat p_345897_) -
modifyDamage
public void modifyDamage(ServerLevel p_345743_, int p_345544_, ItemStack p_345269_, Entity p_346011_, DamageSource p_344755_, org.apache.commons.lang3.mutable.MutableFloat p_345551_) -
modifyFallBasedDamage
public void modifyFallBasedDamage(ServerLevel p_345164_, int p_344793_, ItemStack p_345159_, Entity p_345653_, DamageSource p_344870_, org.apache.commons.lang3.mutable.MutableFloat p_346329_) -
modifyKnockback
public void modifyKnockback(ServerLevel p_346266_, int p_344905_, ItemStack p_345602_, Entity p_346190_, DamageSource p_345911_, org.apache.commons.lang3.mutable.MutableFloat p_345127_) -
modifyArmorEffectivness
public void modifyArmorEffectivness(ServerLevel p_345449_, int p_346129_, ItemStack p_345436_, Entity p_345815_, DamageSource p_346172_, org.apache.commons.lang3.mutable.MutableFloat p_345265_) -
doPostAttack
public static void doPostAttack(TargetedConditionalEffect<EnchantmentEntityEffect> p_346387_, ServerLevel p_345844_, int p_344928_, EnchantedItemInUse p_345486_, Entity p_345472_, DamageSource p_345022_) -
doPostAttack
public void doPostAttack(ServerLevel p_344857_, int p_44688_, EnchantedItemInUse p_345323_, EnchantmentTarget p_345287_, Entity p_44687_, DamageSource p_345177_) -
modifyProjectileCount
public void modifyProjectileCount(ServerLevel p_345353_, int p_344837_, ItemStack p_346382_, Entity p_345611_, org.apache.commons.lang3.mutable.MutableFloat p_344765_) -
modifyProjectileSpread
public void modifyProjectileSpread(ServerLevel p_346170_, int p_345846_, ItemStack p_346147_, Entity p_345832_, org.apache.commons.lang3.mutable.MutableFloat p_345361_) -
modifyCrossbowChargeTime
public void modifyCrossbowChargeTime(RandomSource p_347712_, int p_345448_, org.apache.commons.lang3.mutable.MutableFloat p_345713_) -
modifyUnfilteredValue
public void modifyUnfilteredValue(DataComponentType<EnchantmentValueEffect> p_347468_, RandomSource p_347513_, int p_347494_, org.apache.commons.lang3.mutable.MutableFloat p_347716_) -
tick
public void tick(ServerLevel p_345064_, int p_346148_, EnchantedItemInUse p_345056_, Entity p_345139_) -
onProjectileSpawned
public void onProjectileSpawned(ServerLevel p_345440_, int p_346424_, EnchantedItemInUse p_346046_, Entity p_345958_) -
onHitBlock
public void onHitBlock(ServerLevel p_345175_, int p_346193_, EnchantedItemInUse p_344721_, Entity p_345951_, Vec3 p_344878_, BlockState p_351026_) -
modifyItemFilteredCount
private void modifyItemFilteredCount(DataComponentType<List<ConditionalEffect<EnchantmentValueEffect>>> p_345794_, ServerLevel p_345992_, int p_345038_, ItemStack p_345886_, org.apache.commons.lang3.mutable.MutableFloat p_345188_) -
modifyEntityFilteredValue
private void modifyEntityFilteredValue(DataComponentType<List<ConditionalEffect<EnchantmentValueEffect>>> p_345986_, ServerLevel p_345473_, int p_345352_, ItemStack p_345076_, Entity p_345170_, org.apache.commons.lang3.mutable.MutableFloat p_345910_) -
modifyDamageFilteredValue
private void modifyDamageFilteredValue(DataComponentType<List<ConditionalEffect<EnchantmentValueEffect>>> p_345367_, ServerLevel p_345784_, int p_344796_, ItemStack p_345410_, Entity p_345673_, DamageSource p_345768_, org.apache.commons.lang3.mutable.MutableFloat p_345664_) -
damageContext
public static LootContext damageContext(ServerLevel p_346018_, int p_345520_, Entity p_345257_, DamageSource p_346340_) -
itemContext
-
locationContext
private static LootContext locationContext(ServerLevel p_345134_, int p_346182_, Entity p_345416_, boolean p_345862_) -
entityContext
private static LootContext entityContext(ServerLevel p_346134_, int p_346059_, Entity p_346146_, Vec3 p_345814_) -
blockHitContext
private static LootContext blockHitContext(ServerLevel p_350329_, int p_350503_, Entity p_350451_, Vec3 p_350874_, BlockState p_350311_) -
applyEffects
private static <T> void applyEffects(List<ConditionalEffect<T>> p_345860_, LootContext p_345578_, Consumer<T> p_346164_) -
runLocationChangedEffects
public void runLocationChangedEffects(ServerLevel p_345522_, int p_345228_, EnchantedItemInUse p_345521_, LivingEntity p_346133_) -
stopLocationBasedEffects
public void stopLocationBasedEffects(int p_345030_, EnchantedItemInUse p_345497_, LivingEntity p_344904_) -
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 thedescription
record component.- Returns:
- the value of the
description
record component
-
definition
Returns the value of thedefinition
record component.- Returns:
- the value of the
definition
record component
-
exclusiveSet
Returns the value of theexclusiveSet
record component.- Returns:
- the value of the
exclusiveSet
record component
-
effects
Returns the value of theeffects
record component.- Returns:
- the value of the
effects
record component
-
IItemStackExtension.isPrimaryItemFor(Holder)