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_345356_, LootContext p_343574_, Consumer<T> p_343387_) static boolean
areCompatible
(Holder<Enchantment> p_345028_, Holder<Enchantment> p_342568_) private static LootContext
blockHitContext
(ServerLevel p_342041_, int p_344013_, Entity p_345496_, Vec3 p_343741_, BlockState p_342321_) boolean
canEnchant
(ItemStack p_44689_) static Enchantment.Cost
constantCost
(int p_334530_) static LootContext
damageContext
(ServerLevel p_342651_, int p_344201_, Entity p_345425_, DamageSource p_343766_) Returns the value of thedefinition
record 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 thedescription
record component.void
doPostAttack
(ServerLevel p_342826_, int p_343675_, EnchantedItemInUse p_343641_, EnchantmentTarget p_342372_, Entity p_344548_, DamageSource p_342692_) static void
doPostAttack
(TargetedConditionalEffect<EnchantmentEntityEffect> p_344913_, ServerLevel p_344428_, int p_44688_, EnchantedItemInUse p_344260_, Entity p_44687_, DamageSource p_344028_) static Enchantment.Cost
dynamicCost
(int p_334326_, int p_335507_) effects()
Returns the value of theeffects
record component.static Enchantment.Builder
enchantment
(Enchantment.EnchantmentDefinition p_342298_) private static LootContext
entityContext
(ServerLevel p_342654_, int p_343984_, Entity p_342853_, Vec3 p_343585_) 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_344699_) static Component
getFullname
(Holder<Enchantment> p_342825_, 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_344493_, int p_345313_, Entity p_342613_, DamageSource p_345401_) boolean
isPrimaryItem
(ItemStack p_334183_) boolean
isSupportedItem
(ItemStack p_343312_) private static LootContext
itemContext
(ServerLevel p_344430_, int p_344526_, ItemStack p_343134_) private static LootContext
locationContext
(ServerLevel p_342658_, int p_342243_, Entity p_345215_, boolean p_342535_) boolean
matchingSlot
(EquipmentSlot p_344889_) void
modifyAmmoCount
(ServerLevel p_342942_, int p_342884_, ItemStack p_344742_, org.apache.commons.lang3.mutable.MutableFloat p_343607_) 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_) void
modifyBlockExperience
(ServerLevel p_342072_, int p_343543_, ItemStack p_343319_, org.apache.commons.lang3.mutable.MutableFloat p_342766_) void
modifyCrossbowChargeTime
(RandomSource p_345467_, int p_343593_, org.apache.commons.lang3.mutable.MutableFloat p_343046_) 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_) 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_) 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_) void
modifyDurabilityChange
(ServerLevel p_342774_, int p_345090_, ItemStack p_343700_, org.apache.commons.lang3.mutable.MutableFloat p_343591_) void
modifyDurabilityToRepairFromXp
(ServerLevel p_343302_, int p_343123_, ItemStack p_343007_, org.apache.commons.lang3.mutable.MutableFloat p_342327_) 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_) 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_) void
modifyFishingLuckBonus
(ServerLevel p_342216_, int p_343343_, ItemStack p_344550_, Entity p_343347_, org.apache.commons.lang3.mutable.MutableFloat p_345240_) void
modifyFishingTimeReduction
(ServerLevel p_343004_, int p_344690_, ItemStack p_342235_, Entity p_344564_, org.apache.commons.lang3.mutable.MutableFloat p_345086_) 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_) 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_) void
modifyMobExperience
(ServerLevel p_343695_, int p_342521_, ItemStack p_344064_, Entity p_342215_, org.apache.commons.lang3.mutable.MutableFloat p_345517_) void
modifyPiercingCount
(ServerLevel p_342338_, int p_344838_, ItemStack p_343994_, org.apache.commons.lang3.mutable.MutableFloat p_342065_) void
modifyProjectileCount
(ServerLevel p_344710_, int p_344927_, ItemStack p_343332_, Entity p_344173_, org.apache.commons.lang3.mutable.MutableFloat p_345307_) void
modifyProjectileSpread
(ServerLevel p_342398_, int p_342291_, ItemStack p_345308_, Entity p_343809_, org.apache.commons.lang3.mutable.MutableFloat p_343769_) void
modifyTridentReturnToOwnerAcceleration
(ServerLevel p_344014_, int p_345042_, ItemStack p_343051_, Entity p_342961_, org.apache.commons.lang3.mutable.MutableFloat p_343498_) void
modifyTridentSpinAttackStrength
(RandomSource p_343013_, int p_342342_, org.apache.commons.lang3.mutable.MutableFloat p_342582_) void
modifyUnfilteredValue
(DataComponentType<EnchantmentValueEffect> p_342685_, RandomSource p_344622_, int p_343957_, org.apache.commons.lang3.mutable.MutableFloat p_342813_) void
onHitBlock
(ServerLevel p_343964_, int p_343622_, EnchantedItemInUse p_344872_, Entity p_342891_, Vec3 p_344312_, BlockState p_345016_) void
onProjectileSpawned
(ServerLevel p_344400_, int p_344273_, EnchantedItemInUse p_342998_, Entity p_344540_) void
runLocationChangedEffects
(ServerLevel p_343889_, int p_344660_, EnchantedItemInUse p_344903_, LivingEntity p_342969_) void
stopLocationBasedEffects
(int p_342505_, EnchantedItemInUse p_342723_, LivingEntity p_345268_) void
tick
(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 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_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 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
-