Record Class AmbientLeavesBlockSoundPlayer

java.lang.Object
java.lang.Record
net.minecraft.world.level.block.sounds.AmbientLeavesBlockSoundPlayer

public record AmbientLeavesBlockSoundPlayer(Optional<Holder<SoundEvent>> ambientSound, int chance, Optional<TagKey<Block>> satisfyingBlocks, int nearbySatisfyingBlocksRequired, int nearbySameLeavesRequired) extends Record
  • Field Details

    • ambientSound

      private final Optional<Holder<SoundEvent>> ambientSound
      The field for the ambientSound record component.
    • chance

      private final int chance
      The field for the chance record component.
    • satisfyingBlocks

      private final Optional<TagKey<Block>> satisfyingBlocks
      The field for the satisfyingBlocks record component.
    • nearbySatisfyingBlocksRequired

      private final int nearbySatisfyingBlocksRequired
      The field for the nearbySatisfyingBlocksRequired record component.
    • nearbySameLeavesRequired

      private final int nearbySameLeavesRequired
      The field for the nearbySameLeavesRequired record component.
    • AMBIENT_SOUND_CHANCE

      private static final int AMBIENT_SOUND_CHANCE
      See Also:
    • NEARBY_SATISFYING_BLOCKS_REQUIRED

      private static final int NEARBY_SATISFYING_BLOCKS_REQUIRED
      See Also:
    • NEARBY_SAME_LEAVES_REQUIRED

      private static final int NEARBY_SAME_LEAVES_REQUIRED
      See Also:
    • CODEC

      public static final com.mojang.serialization.Codec<AmbientLeavesBlockSoundPlayer> CODEC
    • NO_SOUND

      private static final AmbientLeavesBlockSoundPlayer NO_SOUND
  • Constructor Details

    • AmbientLeavesBlockSoundPlayer

      public AmbientLeavesBlockSoundPlayer(Optional<Holder<SoundEvent>> ambientSound, int chance, Optional<TagKey<Block>> satisfyingBlocks, int nearbySatisfyingBlocksRequired, int nearbySameLeavesRequired)
      Creates an instance of a AmbientLeavesBlockSoundPlayer record class.
      Parameters:
      ambientSound - the value for the ambientSound record component
      chance - the value for the chance record component
      satisfyingBlocks - the value for the satisfyingBlocks record component
      nearbySatisfyingBlocksRequired - the value for the nearbySatisfyingBlocksRequired record component
      nearbySameLeavesRequired - the value for the nearbySameLeavesRequired record component
  • Method Details

    • of

      public static AmbientLeavesBlockSoundPlayer of(Holder<SoundEvent> ambientSound, TagKey<Block> satisfyingBlocks)
    • noAmbientSound

      public static AmbientLeavesBlockSoundPlayer noAmbientSound()
    • playAmbientLeavesSounds

      public void playAmbientLeavesSounds(Level level, BlockPos pos, Block block, RandomSource random)
    • 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. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      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.
    • ambientSound

      public Optional<Holder<SoundEvent>> ambientSound()
      Returns the value of the ambientSound record component.
      Returns:
      the value of the ambientSound record component
    • chance

      public int chance()
      Returns the value of the chance record component.
      Returns:
      the value of the chance record component
    • satisfyingBlocks

      public Optional<TagKey<Block>> satisfyingBlocks()
      Returns the value of the satisfyingBlocks record component.
      Returns:
      the value of the satisfyingBlocks record component
    • nearbySatisfyingBlocksRequired

      public int nearbySatisfyingBlocksRequired()
      Returns the value of the nearbySatisfyingBlocksRequired record component.
      Returns:
      the value of the nearbySatisfyingBlocksRequired record component
    • nearbySameLeavesRequired

      public int nearbySameLeavesRequired()
      Returns the value of the nearbySameLeavesRequired record component.
      Returns:
      the value of the nearbySameLeavesRequired record component