Record Class PlaySoundEntityEffect
java.lang.Object
java.lang.Record
johnsmith.enchantmentcore.api.enchantment.spellfield.effect.audio.PlaySoundEntityEffect
- Record Components:
sound- The registryHolderof theSoundEventto play.source- TheSoundSourcecategory channel through which the sound is played.volume- TheLevelBasedValuebase volume multiplier (further attenuated by the entity's topological scalar).pitch- TheLevelBasedValuepitch multiplier applied to the sound event.
- All Implemented Interfaces:
SpellFieldEffect, SpellFieldEntityEffect
public record PlaySoundEntityEffect(net.minecraft.core.Holder<net.minecraft.sounds.SoundEvent> sound, net.minecraft.sounds.SoundSource source, net.minecraft.world.item.enchantment.LevelBasedValue volume, net.minecraft.world.item.enchantment.LevelBasedValue pitch)
extends Record
implements SpellFieldEntityEffect
A
SpellFieldEntityEffect that broadcasts a configured SoundEvent at the position of
each targeted entity within a spell field volume, scaling the output volume by the entity's local
topological multiplier.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.serialization.MapCodec<PlaySoundEntityEffect> MapCodec for serializing and deserializingPlaySoundEntityEffectinstances from JSON.static final StringRegistry path identifier for this spell field entity effect.static final LevelBasedKeyProviderSupplies the JSON property keys holdingLevelBasedValuedefinitions for data transformation.static final StringJSON field key for the sound pitch multiplier.static final StringJSON field key for the sound event identifier.static final StringJSON field key for the sound source category.static final com.mojang.serialization.Codec<net.minecraft.sounds.SoundSource> Case-insensitive string codec for resolvingSoundSourceconstants by name, defaulting toSoundSource.PLAYERSif unrecognized.static final StringJSON field key for the base sound volume. -
Constructor Summary
ConstructorsConstructorDescriptionPlaySoundEntityEffect(net.minecraft.core.Holder<net.minecraft.sounds.SoundEvent> sound, net.minecraft.sounds.SoundSource source, net.minecraft.world.item.enchantment.LevelBasedValue volume, net.minecraft.world.item.enchantment.LevelBasedValue pitch) Creates an instance of aPlaySoundEntityEffectrecord class. -
Method Summary
Modifier and TypeMethodDescriptionvoidapply(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 scalar) Broadcasts the configured sound event atvictim's position if the effective volume ($\text{volume} \cdot \text{scalar}$) exceeds0.01F.com.mojang.serialization.MapCodec<? extends SpellFieldEntityEffect> codec()Retrieves theMapCodecresponsible for serializing and deserializing this effect.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.net.minecraft.world.item.enchantment.LevelBasedValuepitch()Returns the value of thepitchrecord component.net.minecraft.core.Holder<net.minecraft.sounds.SoundEvent> sound()Returns the value of thesoundrecord component.net.minecraft.sounds.SoundSourcesource()Returns the value of thesourcerecord component.final StringtoString()Returns a string representation of this record class.net.minecraft.world.item.enchantment.LevelBasedValuevolume()Returns the value of thevolumerecord component.
-
Field Details
-
SOUND
-
SOURCE
-
VOLUME
-
PITCH
-
KEY
Registry path identifier for this spell field entity effect.- See Also:
-
KEY_PROVIDER
Supplies the JSON property keys holdingLevelBasedValuedefinitions for data transformation. -
SOURCE_CODEC
public static final com.mojang.serialization.Codec<net.minecraft.sounds.SoundSource> SOURCE_CODECCase-insensitive string codec for resolvingSoundSourceconstants by name, defaulting toSoundSource.PLAYERSif unrecognized. -
CODEC
MapCodec for serializing and deserializingPlaySoundEntityEffectinstances from JSON.
-
-
Constructor Details
-
PlaySoundEntityEffect
public PlaySoundEntityEffect(net.minecraft.core.Holder<net.minecraft.sounds.SoundEvent> sound, net.minecraft.sounds.SoundSource source, net.minecraft.world.item.enchantment.LevelBasedValue volume, net.minecraft.world.item.enchantment.LevelBasedValue pitch) Creates an instance of aPlaySoundEntityEffectrecord class.
-
-
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 scalar) Broadcasts the configured sound event atvictim's position if the effective volume ($\text{volume} \cdot \text{scalar}$) exceeds0.01F.- 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.scalar- 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). -
sound
-
source
-
volume
-
pitch
-