Class SoundDefinition.SoundBuilder

java.lang.Object
io.github.vampirestudios.vampirelib.api.SoundDefinition.SoundBuilder
Enclosing class:
SoundDefinition

public static class SoundDefinition.SoundBuilder extends Object
Constructs sound files for SoundDefinition.
Since:
1.0.0
  • Constructor Details

    • SoundBuilder

      public SoundBuilder(net.minecraft.resources.ResourceLocation path)
  • Method Details

    • toJson

      public com.google.gson.JsonElement toJson()
      Returns:
      A new JSON representing this sound file
    • getPath

      public net.minecraft.resources.ResourceLocation getPath()
      Returns:
      The path to the actual ogg file, excluding sounds/
    • getVolume

      public float getVolume()
      Returns:
      The volume factor of the sound. Default is 1.0
    • getPitch

      public float getPitch()
      Returns:
      The pitch factor of the sound. Default is 1.0
    • getWeight

      public int getWeight()
      Returns:
      The weight of this sound playing. This is only used when multiple files are defined to set probability for each file. Default is 1
    • getType

      public SoundDefinition.SoundType getType()
      Returns:
      The type of file this is. Default is SoundDefinition.SoundType.EVENT
    • isPreload

      public boolean isPreload()
      Returns:
      Whether to preload this file when the game loads. Default is false
    • isStream

      public boolean isStream()
      Returns:
      Whether to stream this file. Default is false
    • getAttenuationDistance

      public int getAttenuationDistance()
      Returns:
      The distance the sound is able to be heard from. Default is 16
    • volume

      public SoundDefinition.SoundBuilder volume(float volume)
      Sets the volume factor for this sound.
      Parameters:
      volume - The new volume multiplier
    • pitch

      public SoundDefinition.SoundBuilder pitch(float pitch)
      Sets the pitch factor for this sound.
      Parameters:
      pitch - The new pitch multiplier
    • weight

      public SoundDefinition.SoundBuilder weight(int weight)
      Sets the weight for this file. Higher weights increase the chance of this being chosen when multiple sounds files are defined.
      Parameters:
      weight - The new weight value
    • type

      Sets how the value of name is interpreted by Minecraft.
      Parameters:
      type - The new type
      See Also:
    • preload

      public SoundDefinition.SoundBuilder preload()
      Causes this sound to be loaded when resources reload.
    • preload

      public SoundDefinition.SoundBuilder preload(boolean preload)
      Sets whether to load this sound when resources reload.
      Parameters:
      preload - Whether to preload or not
    • stream

      Causes this sound to be streamed from disc instead of loading the entire file.

      NOTE: THIS WILL NOT ALLOW MODIFICATION OF THE SOUND THROUGH SOUND INSTANCES

      To be able to modify the sound, use preload() instead

    • stream

      public SoundDefinition.SoundBuilder stream(boolean stream)
      Sets whether to stream this sound from disc instead of loading the entire file.

      NOTE: THIS WILL NOT ALLOW MODIFICATION OF THE SOUND THROUGH SOUND INSTANCES

      To be able to modify the sound, use preload() instead

      Parameters:
      stream - Whether to stream the file or not
    • attenuationDistance

      public SoundDefinition.SoundBuilder attenuationDistance(int attenuationDistance)
      Sets the maximum distance to be able to hear the sound from.

      Used by nether portals and redstone components to decrease listening distance

      Parameters:
      attenuationDistance - The new distance to hear sounds from