Class SoundDefinition.SoundBuilder
java.lang.Object
io.github.vampirestudios.vampirelib.api.SoundDefinition.SoundBuilder
- Enclosing class:
- SoundDefinition
Constructs sound files for
SoundDefinition.- Since:
- 1.0.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionattenuationDistance(int attenuationDistance) Sets the maximum distance to be able to hear the sound from.intnet.minecraft.resources.ResourceLocationgetPath()floatgetPitch()getType()floatintbooleanbooleanisStream()pitch(float pitch) Sets the pitch factor for this sound.preload()Causes this sound to be loaded when resources reload.preload(boolean preload) Sets whether to load this sound when resources reload.stream()Causes this sound to be streamed from disc instead of loading the entire file.stream(boolean stream) Sets whether to stream this sound from disc instead of loading the entire file.com.google.gson.JsonElementtoJson()Sets how the value ofnameis interpreted by Minecraft.volume(float volume) Sets the volume factor for this sound.weight(int weight) Sets the weight for this file.
-
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
oggfile, excludingsounds/
-
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
- 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
Sets the volume factor for this sound.- Parameters:
volume- The new volume multiplier
-
pitch
Sets the pitch factor for this sound.- Parameters:
pitch- The new pitch multiplier
-
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 ofnameis interpreted by Minecraft.- Parameters:
type- The new type- See Also:
-
preload
Causes this sound to be loaded when resources reload. -
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
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
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
-