Record Class DamageEffect
java.lang.Object
java.lang.Record
johnsmith.enchantmentcore.api.enchantment.spellfield.effect.entity.DamageEffect
- Record Components:
damageType- The registryResourceKeyof theDamageTypeto inflict.amount- TheLevelBasedValuebase damage amount before topological scaling.entityFilter- OptionalContextAwarePredicaterestricting which entities take damage.
- All Implemented Interfaces:
SpellFieldEffect, SpellFieldEntityEffect
public record DamageEffect(net.minecraft.resources.ResourceKey<net.minecraft.world.damagesource.DamageType> damageType, net.minecraft.world.item.enchantment.LevelBasedValue amount, Optional<net.minecraft.advancements.predicates.ContextAwarePredicate> entityFilter)
extends Record
implements SpellFieldEntityEffect
A
SpellFieldEntityEffect that inflicts damage of a specified DamageType to targeted
entities within a spell field volume, scaled by each target's local topological multiplier.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringJSON field key for the base damage amount.static final com.mojang.serialization.MapCodec<DamageEffect> MapCodec for serializing and deserializingDamageEffectinstances from JSON.static final StringJSON field key for the damage type resource key.static final StringJSON field key for the optional entity filter predicate.static final StringRegistry path identifier for this spell field entity effect.static final LevelBasedKeyProviderSupplies the JSON property keys holdingLevelBasedValuedefinitions for data transformation. -
Constructor Summary
ConstructorsConstructorDescriptionDamageEffect(net.minecraft.resources.ResourceKey<net.minecraft.world.damagesource.DamageType> damageType, net.minecraft.world.item.enchantment.LevelBasedValue amount) Constructs an unfilteredDamageEffect.DamageEffect(net.minecraft.resources.ResourceKey<net.minecraft.world.damagesource.DamageType> damageType, net.minecraft.world.item.enchantment.LevelBasedValue amount, Optional<net.minecraft.advancements.predicates.ContextAwarePredicate> entityFilter) Creates an instance of aDamageEffectrecord class.DamageEffect(net.minecraft.resources.ResourceKey<net.minecraft.world.damagesource.DamageType> damageType, net.minecraft.world.item.enchantment.LevelBasedValue amount, net.minecraft.advancements.predicates.ContextAwarePredicate entityFilter) Constructs aDamageEffectrestricted by the given entity predicate filter. -
Method Summary
Modifier and TypeMethodDescriptionnet.minecraft.world.item.enchantment.LevelBasedValueamount()Returns the value of theamountrecord component.voidapply(net.minecraft.server.level.ServerLevel level, int enchantmentLevel, net.minecraft.world.item.enchantment.EnchantedItemInUse context, net.minecraft.world.entity.Entity spatialReference, net.minecraft.world.phys.Vec3 epicenter, net.minecraft.world.entity.Entity victim, float volumeScalar) Inflicts $\text{amount} \cdot \text{volumeScalar}$ damage of typedamageType()tovictim, attributingspatialReferenceas the direct entity andcontext.owner()as the causing entity.com.mojang.serialization.MapCodec<? extends SpellFieldEntityEffect> codec()Retrieves theMapCodecresponsible for serializing and deserializing this effect.net.minecraft.resources.ResourceKey<net.minecraft.world.damagesource.DamageType> Returns the value of thedamageTyperecord component.Optional<net.minecraft.advancements.predicates.ContextAwarePredicate> Returns the value of theentityFilterrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.final StringtoString()Returns a string representation of this record class.
-
Field Details
-
DAMAGE_TYPE
-
AMOUNT
-
ENTITY_FILTER
JSON field key for the optional entity filter predicate.- See Also:
-
KEY
Registry path identifier for this spell field entity effect.- See Also:
-
KEY_PROVIDER
Supplies the JSON property keys holdingLevelBasedValuedefinitions for data transformation. -
CODEC
MapCodec for serializing and deserializingDamageEffectinstances from JSON.
-
-
Constructor Details
-
DamageEffect
public DamageEffect(net.minecraft.resources.ResourceKey<net.minecraft.world.damagesource.DamageType> damageType, net.minecraft.world.item.enchantment.LevelBasedValue amount) Constructs an unfilteredDamageEffect.- Parameters:
damageType- TheDamageTyperesource key.amount- TheLevelBasedValuebase damage amount.
-
DamageEffect
public DamageEffect(net.minecraft.resources.ResourceKey<net.minecraft.world.damagesource.DamageType> damageType, net.minecraft.world.item.enchantment.LevelBasedValue amount, net.minecraft.advancements.predicates.ContextAwarePredicate entityFilter) Constructs aDamageEffectrestricted by the given entity predicate filter.- Parameters:
damageType- TheDamageTyperesource key.amount- TheLevelBasedValuebase damage amount.entityFilter- The predicate filter to match against candidate entities.
-
DamageEffect
public DamageEffect(net.minecraft.resources.ResourceKey<net.minecraft.world.damagesource.DamageType> damageType, net.minecraft.world.item.enchantment.LevelBasedValue amount, Optional<net.minecraft.advancements.predicates.ContextAwarePredicate> entityFilter) Creates an instance of aDamageEffectrecord class.- Parameters:
damageType- the value for thedamageTyperecord componentamount- the value for theamountrecord componententityFilter- the value for theentityFilterrecord component
-
-
Method Details
-
apply
public void apply(net.minecraft.server.level.ServerLevel level, int enchantmentLevel, net.minecraft.world.item.enchantment.EnchantedItemInUse context, net.minecraft.world.entity.Entity spatialReference, net.minecraft.world.phys.Vec3 epicenter, net.minecraft.world.entity.Entity victim, float volumeScalar) Inflicts $\text{amount} \cdot \text{volumeScalar}$ damage of typedamageType()tovictim, attributingspatialReferenceas the direct entity andcontext.owner()as the causing entity.- Specified by:
applyin interfaceSpellFieldEntityEffect- Parameters:
level- The executing server level.enchantmentLevel- The active level of the spell field enchantment.context- The item usage context triggering the spell field.spatialReference- The anchor entity or focal point of the spell field.epicenter- The exact spatial origin vector of the spell field.victim- The target entity intersecting the spell field.volumeScalar- The active topological multiplier forvictim.
-
codec
Description copied from interface:SpellFieldEffectRetrieves theMapCodecresponsible for serializing and deserializing this effect.- Specified by:
codecin interfaceSpellFieldEffect- Returns:
- The registered
MapCodecinstance.
-
toString
-
hashCode
-
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). -
damageType
public net.minecraft.resources.ResourceKey<net.minecraft.world.damagesource.DamageType> damageType()Returns the value of thedamageTyperecord component.- Returns:
- the value of the
damageTyperecord component
-
amount
-
entityFilter
Returns the value of theentityFilterrecord component.- Returns:
- the value of the
entityFilterrecord component
-