Class PlayAudioMessage

java.lang.Object
com.minecolonies.core.network.messages.client.PlayAudioMessage
All Implemented Interfaces:
IMessage

public class PlayAudioMessage extends Object implements IMessage
Asks the client to play a specific music
  • Constructor Summary

    Constructors
    Constructor
    Description
    Default constructor.
    PlayAudioMessage(net.minecraft.sounds.SoundEvent event)
    Create a play music message with a specific sound event.
    PlayAudioMessage(net.minecraft.sounds.SoundEvent event, net.minecraft.sounds.SoundSource category)
    Create a play music message with a specific sound event.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    fromBytes(net.minecraft.network.FriendlyByteBuf buf)
    Reads message data from buffer.
    @Nullable net.minecraftforge.fml.LogicalSide
    Which sides is message able to be executed at.
    void
    onExecute(net.minecraftforge.network.NetworkEvent.Context ctxIn, boolean isLogicalServer)
    Executes message action.
    static void
    sendToAll(IColony col, boolean important, boolean stop, PlayAudioMessage... messages)
    Plays a sound event to everyone in the colony
    void
    toBytes(net.minecraft.network.FriendlyByteBuf buf)
    Writes message data to buffer.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • PlayAudioMessage

      public PlayAudioMessage()
      Default constructor.
    • PlayAudioMessage

      public PlayAudioMessage(net.minecraft.sounds.SoundEvent event)
      Create a play music message with a specific sound event.
      Parameters:
      event - the sound event.
    • PlayAudioMessage

      public PlayAudioMessage(net.minecraft.sounds.SoundEvent event, net.minecraft.sounds.SoundSource category)
      Create a play music message with a specific sound event.
      Parameters:
      event - the sound event.
      category - the sound category to play on
  • Method Details

    • toBytes

      public void toBytes(net.minecraft.network.FriendlyByteBuf buf)
      Description copied from interface: IMessage
      Writes message data to buffer.
      Specified by:
      toBytes in interface IMessage
      Parameters:
      buf - network data byte buffer
    • fromBytes

      public void fromBytes(net.minecraft.network.FriendlyByteBuf buf)
      Description copied from interface: IMessage
      Reads message data from buffer.
      Specified by:
      fromBytes in interface IMessage
      Parameters:
      buf - network data byte buffer
    • getExecutionSide

      @Nullable public @Nullable net.minecraftforge.fml.LogicalSide getExecutionSide()
      Description copied from interface: IMessage
      Which sides is message able to be executed at.
      Specified by:
      getExecutionSide in interface IMessage
      Returns:
      CLIENT or SERVER or null (for both)
    • onExecute

      public void onExecute(net.minecraftforge.network.NetworkEvent.Context ctxIn, boolean isLogicalServer)
      Description copied from interface: IMessage
      Executes message action.
      Specified by:
      onExecute in interface IMessage
      Parameters:
      ctxIn - network context of incoming message
      isLogicalServer - whether message arrived at logical server side
    • sendToAll

      public static void sendToAll(IColony col, boolean important, boolean stop, PlayAudioMessage... messages)
      Plays a sound event to everyone in the colony
      Parameters:
      col - the colony
      important - if the audio is sent to important message players only
      stop - if all other sounds should be stopped first
      messages - one or more messages to send to each player.