Record Class BackgroundMusic

java.lang.Object
java.lang.Record
fr.fidorial.world.environment.BackgroundMusic
Record Components:
normal - track played by default, or null for silence — the default field on the wire, renamed here because default is a Java keyword
underwater - track overriding normal while the player is submerged, or null
creative - track overriding normal in Creative mode, or null

public record BackgroundMusic(@Nullable MusicTrack normal, @Nullable MusicTrack underwater, @Nullable MusicTrack creative) extends Record
The minecraft:audio/background_music environment attribute.

Since 1.21.11 this replaced the weighted music list biomes used to carry: instead of picking randomly among several tracks, the client picks the variant matching the player's situation.

Since:
0.1.0
  • Constructor Details

  • Method Details

    • of

      public static BackgroundMusic of(MusicTrack track)
      Creates an attribute carrying a single track for every situation.
      Parameters:
      track - the track
      Returns:
      the background music
    • 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.
    • normal

      public @Nullable MusicTrack normal()
      Returns the value of the normal record component.
      Returns:
      the value of the normal record component
    • underwater

      public @Nullable MusicTrack underwater()
      Returns the value of the underwater record component.
      Returns:
      the value of the underwater record component
    • creative

      public @Nullable MusicTrack creative()
      Returns the value of the creative record component.
      Returns:
      the value of the creative record component