Record Class PlaySoundEffect

java.lang.Object
java.lang.Record
net.minecraft.world.item.enchantment.effects.PlaySoundEffect
All Implemented Interfaces:
EnchantmentEntityEffect, EnchantmentLocationBasedEffect

public record PlaySoundEffect(Holder<SoundEvent> soundEvent, FloatProvider volume, FloatProvider pitch) extends Record implements EnchantmentEntityEffect
  • Field Details

    • soundEvent

      private final Holder<SoundEvent> soundEvent
      The field for the soundEvent record component.
    • volume

      private final FloatProvider volume
      The field for the volume record component.
    • pitch

      private final FloatProvider pitch
      The field for the pitch record component.
    • CODEC

      public static final com.mojang.serialization.MapCodec<PlaySoundEffect> CODEC
  • Constructor Details

    • PlaySoundEffect

      public PlaySoundEffect(Holder<SoundEvent> soundEvent, FloatProvider volume, FloatProvider pitch)
      Creates an instance of a PlaySoundEffect record class.
      Parameters:
      soundEvent - the value for the soundEvent record component
      volume - the value for the volume record component
      pitch - the value for the pitch record component
  • Method Details

    • apply

      public void apply(ServerLevel p_342634_, int p_344633_, EnchantedItemInUse p_344196_, Entity p_344269_, Vec3 p_343993_)
      Specified by:
      apply in interface EnchantmentEntityEffect
    • codec

      public com.mojang.serialization.MapCodec<PlaySoundEffect> codec()
      Specified by:
      codec in interface EnchantmentEntityEffect
      Specified by:
      codec in interface EnchantmentLocationBasedEffect
    • 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.
    • soundEvent

      public Holder<SoundEvent> soundEvent()
      Returns the value of the soundEvent record component.
      Returns:
      the value of the soundEvent record component
    • volume

      public FloatProvider volume()
      Returns the value of the volume record component.
      Returns:
      the value of the volume record component
    • pitch

      public FloatProvider pitch()
      Returns the value of the pitch record component.
      Returns:
      the value of the pitch record component