Record Class PlaySoundBlockEffect

java.lang.Object
java.lang.Record
johnsmith.enchantmentcore.api.enchantment.spellfield.effect.audio.PlaySoundBlockEffect
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 base volume multiplier (further attenuated by the block's topological scalar).
pitch - The LevelBasedValue pitch multiplier applied to the sound event.
All Implemented Interfaces:
SpellFieldBlockEffect, SpellFieldEffect

public record PlaySoundBlockEffect(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 SpellFieldBlockEffect
A SpellFieldBlockEffect that broadcasts a configured SoundEvent centered at each evaluated block coordinate within a spell field volume, scaling the output volume by the block's local topological multiplier.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final com.mojang.serialization.MapCodec<PlaySoundBlockEffect>
    MapCodec for serializing and deserializing PlaySoundBlockEffect instances from JSON.
    static final String
    Registry path identifier for this spell field block 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 base sound volume.
  • Constructor Summary

    Constructors
    Constructor
    Description
    PlaySoundBlockEffect(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 PlaySoundBlockEffect 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 spatialReference, net.minecraft.world.phys.Vec3 epicenter, net.minecraft.core.BlockPos pos, float scalar, Set<net.minecraft.core.BlockPos> modifiedBlocks)
    Broadcasts the configured sound event at the center of pos if the effective volume ($\text{volume} \cdot \text{scalar}$) exceeds 0.01F.
    com.mojang.serialization.MapCodec<? extends SpellFieldBlockEffect>
    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

    Methods inherited from interface johnsmith.enchantmentcore.api.enchantment.spellfield.effect.SpellFieldBlockEffect

    getPriority
  • 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 base 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 block 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<PlaySoundBlockEffect> CODEC
      MapCodec for serializing and deserializing PlaySoundBlockEffect instances from JSON.
  • Constructor Details

    • PlaySoundBlockEffect

      public PlaySoundBlockEffect(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 PlaySoundBlockEffect 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 spatialReference, net.minecraft.world.phys.Vec3 epicenter, net.minecraft.core.BlockPos pos, float scalar, Set<net.minecraft.core.BlockPos> modifiedBlocks)
      Broadcasts the configured sound event at the center of pos if the effective volume ($\text{volume} \cdot \text{scalar}$) exceeds 0.01F.
      Specified by:
      apply in interface SpellFieldBlockEffect
      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.
      pos - The target block coordinate.
      scalar - The active topological multiplier at pos.
      modifiedBlocks - A mutable set tracking block coordinates modified during this evaluation cycle.
    • codec

      public com.mojang.serialization.MapCodec<? extends SpellFieldBlockEffect> 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