Record Class JukeboxSong

java.lang.Object
java.lang.Record
net.minecraft.world.item.JukeboxSong

public record JukeboxSong(Holder<SoundEvent> soundEvent, Component description, float lengthInSeconds, int comparatorOutput) extends Record
  • Field Details

    • soundEvent

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

      private final Component description
      The field for the description record component.
    • lengthInSeconds

      private final float lengthInSeconds
      The field for the lengthInSeconds record component.
    • comparatorOutput

      private final int comparatorOutput
      The field for the comparatorOutput record component.
    • DIRECT_CODEC

      public static final com.mojang.serialization.Codec<JukeboxSong> DIRECT_CODEC
    • DIRECT_STREAM_CODEC

      public static final StreamCodec<RegistryFriendlyByteBuf,JukeboxSong> DIRECT_STREAM_CODEC
    • CODEC

      public static final com.mojang.serialization.Codec<Holder<JukeboxSong>> CODEC
    • STREAM_CODEC

      public static final StreamCodec<RegistryFriendlyByteBuf,Holder<JukeboxSong>> STREAM_CODEC
    • SONG_END_PADDING_TICKS

      private static final int SONG_END_PADDING_TICKS
      See Also:
  • Constructor Details

    • JukeboxSong

      public JukeboxSong(Holder<SoundEvent> soundEvent, Component description, float lengthInSeconds, int comparatorOutput)
      Creates an instance of a JukeboxSong record class.
      Parameters:
      soundEvent - the value for the soundEvent record component
      description - the value for the description record component
      lengthInSeconds - the value for the lengthInSeconds record component
      comparatorOutput - the value for the comparatorOutput record component
  • Method Details

    • lengthInTicks

      public int lengthInTicks()
    • hasFinished

      public boolean hasFinished(long p_350621_)
    • fromStack

      public static Optional<Holder<JukeboxSong>> fromStack(HolderLookup.Provider p_350602_, ItemStack p_350870_)
    • 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 '=='.
      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
    • description

      public Component description()
      Returns the value of the description record component.
      Returns:
      the value of the description record component
    • lengthInSeconds

      public float lengthInSeconds()
      Returns the value of the lengthInSeconds record component.
      Returns:
      the value of the lengthInSeconds record component
    • comparatorOutput

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