类 PlaySoundEvent

java.lang.Object
net.minecraftforge.eventbus.api.Event
net.minecraftforge.client.event.sound.SoundEvent
net.minecraftforge.client.event.sound.PlaySoundEvent

public class PlaySoundEvent extends SoundEvent
Fired when a sound is about to be played by the sound engine. This fires before the sound is played and before any checks on the sound (such as a zeroed volume, an empty Sound, and others). This can be used to change or prevent (by passing null) a sound from being played through setSound(SoundInstance)).

This event is not cancellable, and does not have a result.

This event is fired on the main Forge event bus, only on the logical client.

另请参阅:
  • 字段详细资料

  • 构造器详细资料

  • 方法详细资料

    • getName

      public String getName()
      返回 the name of the original sound。 This is equivalent to the path of the location of the original sound.
      返回:
      the name of the original sound
    • getOriginalSound

      public SoundInstance getOriginalSound()
      返回 the original sound that was to be played。
      返回:
      the original sound that was to be played
    • getSound

      @Nullable public @Nullable SoundInstance getSound()
      返回 the sound to be played, or null if no sound will be played。
      返回:
      the sound to be played, or null if no sound will be played
    • setSound

      public void setSound(@Nullable @Nullable SoundInstance newSound)
      Sets the sound to be played, which may be null to prevent any sound from being played.
      参数:
      newSound - the new sound to be played, or null for no sound