Record Class PlaySoundVolumeEffect
java.lang.Object
java.lang.Record
johnsmith.enchantmentcore.api.enchantment.spellfield.effect.audio.PlaySoundVolumeEffect
- Record Components:
sound- The registryHolderof theSoundEventto play.source- TheSoundSourcecategory channel through which the sound is played.volume- TheLevelBasedValuegoverning the sound volume multiplier.pitch- TheLevelBasedValuegoverning the sound pitch multiplier.
- All Implemented Interfaces:
SpellFieldEffect, SpellFieldVolumeEffect
public record PlaySoundVolumeEffect(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 SpellFieldVolumeEffect
A
SpellFieldVolumeEffect that broadcasts a single SoundEvent at the primary
epicenter of the spell field once per evaluation cycle.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.serialization.MapCodec<PlaySoundVolumeEffect> MapCodec for serializing and deserializingPlaySoundVolumeEffectinstances from JSON.static final StringRegistry path identifier for this spell field volume 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 sound volume. -
Constructor Summary
ConstructorsConstructorDescriptionPlaySoundVolumeEffect(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 aPlaySoundVolumeEffectrecord 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 target, net.minecraft.world.phys.Vec3 epicenter, List<GlobalVolume> volumes) Broadcasts the configured sound event at the spell fieldepicenterif the calculated volume exceeds0.01F.com.mojang.serialization.MapCodec<? extends SpellFieldVolumeEffect> 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 volume 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 deserializingPlaySoundVolumeEffectinstances from JSON.
-
-
Constructor Details
-
PlaySoundVolumeEffect
public PlaySoundVolumeEffect(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 aPlaySoundVolumeEffectrecord 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 target, net.minecraft.world.phys.Vec3 epicenter, List<GlobalVolume> volumes) Broadcasts the configured sound event at the spell fieldepicenterif the calculated volume exceeds0.01F.- Specified by:
applyin interfaceSpellFieldVolumeEffect- Parameters:
level- The executing server level.enchantmentLevel- The active level of the spell field enchantment.context- The item usage context triggering the spell field.target- The anchor entity or focal point of the spell field.epicenter- The exact spatial origin vector of the spell field.volumes- The list of evaluated world-spaceGlobalVolumes defining the spell field geometry.
-
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
-