Record Class PlaySoundVolumeEffect

java.lang.Object
java.lang.Record
johnsmith.enchantmentcore.api.enchantment.spellfield.effect.audio.PlaySoundVolumeEffect
Record Components:
sound - The registry Holder of the SoundEvent to play.
source - The SoundSource category channel through which the sound is played.
volume - The LevelBasedValue governing the sound volume multiplier.
pitch - The LevelBasedValue governing 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

    Fields
    Modifier and Type
    Field
    Description
    static final com.mojang.serialization.MapCodec<PlaySoundVolumeEffect>
    MapCodec for serializing and deserializing PlaySoundVolumeEffect instances from JSON.
    static final String
    Registry path identifier for this spell field volume effect.
    Supplies the JSON property keys holding LevelBasedValue definitions for data transformation.
    static final String
    JSON field key for the sound pitch multiplier.
    static final String
    JSON field key for the sound event identifier.
    static final String
    JSON field key for the sound source category.
    static final com.mojang.serialization.Codec<net.minecraft.sounds.SoundSource>
    Case-insensitive string codec for resolving SoundSource constants by name, defaulting to SoundSource.PLAYERS if unrecognized.
    static final String
    JSON field key for the sound volume.
  • Constructor Summary

    Constructors
    Constructor
    Description
    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 a PlaySoundVolumeEffect record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    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 field epicenter if the calculated volume exceeds 0.01F.
    com.mojang.serialization.MapCodec<? extends SpellFieldVolumeEffect>
    Retrieves the MapCodec responsible for serializing and deserializing this effect.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    net.minecraft.world.item.enchantment.LevelBasedValue
    Returns the value of the pitch record component.
    net.minecraft.core.Holder<net.minecraft.sounds.SoundEvent>
    Returns the value of the sound record component.
    net.minecraft.sounds.SoundSource
    Returns the value of the source record component.
    final String
    Returns a string representation of this record class.
    net.minecraft.world.item.enchantment.LevelBasedValue
    Returns the value of the volume record component.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • SOUND

      public static final String SOUND
      JSON field key for the sound event identifier.
      See Also:
    • SOURCE

      public static final String SOURCE
      JSON field key for the sound source category.
      See Also:
    • VOLUME

      public static final String VOLUME
      JSON field key for the sound volume.
      See Also:
    • PITCH

      public static final String PITCH
      JSON field key for the sound pitch multiplier.
      See Also:
    • KEY

      public static final String KEY
      Registry path identifier for this spell field volume effect.
      See Also:
    • KEY_PROVIDER

      public static final LevelBasedKeyProvider KEY_PROVIDER
      Supplies the JSON property keys holding LevelBasedValue definitions for data transformation.
    • SOURCE_CODEC

      public static final com.mojang.serialization.Codec<net.minecraft.sounds.SoundSource> SOURCE_CODEC
      Case-insensitive string codec for resolving SoundSource constants by name, defaulting to SoundSource.PLAYERS if unrecognized.
    • CODEC

      public static final com.mojang.serialization.MapCodec<PlaySoundVolumeEffect> CODEC
      MapCodec for serializing and deserializing PlaySoundVolumeEffect instances 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 a PlaySoundVolumeEffect record class.
      Parameters:
      sound - the value for the sound record component
      source - the value for the source record component
      volume - the value for the volume record component
      pitch - the value for the pitch record 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 target, net.minecraft.world.phys.Vec3 epicenter, List<GlobalVolume> volumes)
      Broadcasts the configured sound event at the spell field epicenter if the calculated volume exceeds 0.01F.
      Specified by:
      apply in interface SpellFieldVolumeEffect
      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-space GlobalVolumes defining the spell field geometry.
    • codec

      public com.mojang.serialization.MapCodec<? extends SpellFieldVolumeEffect> codec()
      Description copied from interface: SpellFieldEffect
      Retrieves the MapCodec responsible for serializing and deserializing this effect.
      Specified by:
      codec in interface SpellFieldEffect
      Returns:
      The registered MapCodec instance.
    • toString

      public final String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • sound

      public net.minecraft.core.Holder<net.minecraft.sounds.SoundEvent> sound()
      Returns the value of the sound record component.
      Returns:
      the value of the sound record component
    • source

      public net.minecraft.sounds.SoundSource source()
      Returns the value of the source record component.
      Returns:
      the value of the source record component
    • volume

      public net.minecraft.world.item.enchantment.LevelBasedValue volume()
      Returns the value of the volume record component.
      Returns:
      the value of the volume record component
    • pitch

      public net.minecraft.world.item.enchantment.LevelBasedValue pitch()
      Returns the value of the pitch record component.
      Returns:
      the value of the pitch record component