Class SoundDefinition.Sound
- Enclosing class:
- SoundDefinition
If any of the optional parameters (i.e. the ones that aren't required to obtain an instance of this class) are unset, their default values will be used instead. The list of defaults is available in the text that follows:
- Volume: 1.0F
- Pitch: 1.0F
- Weight: 1
- Stream: false
- Attenuation Distance: 16
- Preload: false
-
Field Summary
Modifier and TypeFieldDescriptionprivate int
private static final int
private static final float
private static final boolean
private static final boolean
private static final SoundDefinition.SoundType
private static final float
private static final int
private final ResourceLocation
private float
private boolean
private boolean
private final SoundDefinition.SoundType
private float
private int
-
Constructor Summary
ModifierConstructorDescriptionprivate
Sound
(ResourceLocation name, SoundDefinition.SoundType type) -
Method Summary
Modifier and TypeMethodDescriptionattenuationDistance
(int attenuationDistance) Sets the attenuation distance of the sound.private boolean
(package private) ResourceLocation
name()
pitch
(double pitch) Sets the pitch of this specific sound.pitch
(float pitch) Sets the pitch of this specific sound.preload()
Marks this sound as needing to be preloaded.preload
(boolean preload) Sets whether this sound should be preloaded or not.(package private) com.google.gson.JsonElement
static SoundDefinition.Sound
sound
(ResourceLocation name, SoundDefinition.SoundType type) Creates a new sound with the given name and type.stream()
Sets this sound to a streamed sound.stream
(boolean stream) Sets whether this sound should be streamed or not.private String
(package private) SoundDefinition.SoundType
type()
volume
(double volume) Sets the volume of this specific sound.volume
(float volume) Sets the volume of this specific sound.weight
(int weight) Sets the weight of this specific sound.
-
Field Details
-
DEFAULT_TYPE
-
DEFAULT_VOLUME
private static final float DEFAULT_VOLUME- See Also:
-
DEFAULT_PITCH
private static final float DEFAULT_PITCH- See Also:
-
DEFAULT_WEIGHT
private static final int DEFAULT_WEIGHT- See Also:
-
DEFAULT_STREAM
private static final boolean DEFAULT_STREAM- See Also:
-
DEFAULT_ATTENUATION_DISTANCE
private static final int DEFAULT_ATTENUATION_DISTANCE- See Also:
-
DEFAULT_PRELOAD
private static final boolean DEFAULT_PRELOAD- See Also:
-
name
-
type
-
volume
private float volume -
pitch
private float pitch -
weight
private int weight -
stream
private boolean stream -
attenuationDistance
private int attenuationDistance -
preload
private boolean preload
-
-
Constructor Details
-
Sound
-
-
Method Details
-
sound
Creates a new sound with the given name and type.- Parameters:
name
- The name of the sound to create.type
- The type of sound to create.
-
volume
Sets the volume of this specific sound.The volume of a sound represents how loud the sound is when played.
- Parameters:
volume
- The volume to set. It must be higher than 0.- Returns:
- This sound for chaining.
-
volume
Sets the volume of this specific sound.The volume of a sound represents how loud the sound is when played.
- Parameters:
volume
- The volume to set. It must be higher than 0.- Returns:
- This sound for chaining.
-
pitch
Sets the pitch of this specific sound.The pitch of a sound represents how high or low the sound is when played.
- Parameters:
pitch
- The pitch to set. It must be higher than 0.- Returns:
- This sound for chaining.
-
pitch
Sets the pitch of this specific sound.The pitch of a sound represents how high or low the sound is when played.
- Parameters:
pitch
- The pitch to set. It must be higher than 0.- Returns:
- This sound for chaining.
-
weight
Sets the weight of this specific sound.The weight represents how likely it is for this sound to be played when the respective event is triggered. This value is ignored when there is only one sound per event.
- Parameters:
weight
- The weight to set. It must be higher than 0.- Returns:
- This sound for chaining.
-
stream
Sets this sound to a streamed sound.In this context, streaming refers to reading the file on disk as needed instead of loading the whole set in memory. This is useful in case of longer sounds, like records and music (usually more than a minute).
This is equivalent to a call to
stream(boolean)
with a value of true.- Returns:
- This sound for chaining
-
stream
Sets whether this sound should be streamed or not.In this context, streaming refers to reading the file on disk as needed instead of loading the whole set in memory. This is useful in case of longer sounds, like records and music (usually more than a minute).
- Parameters:
stream
- Whether the sound should be streamed or not.- Returns:
- This sound for chaining.
-
attenuationDistance
Sets the attenuation distance of the sound.This represents how far this sound will be heard, in blocks. While the specs don't require so, it is suggested to keep this value positive.
- Parameters:
attenuationDistance
- The attenuation distance to set.- Returns:
- This sound for chaining.
-
preload
Marks this sound as needing to be preloaded.A preloaded sound identifies a sound that is loaded in memory as soon as the resource pack is loaded, without having to wait for the sound to be ready to stream. It is suggested to keep this to
false
, unless you are using it for a highly recurring sound (e.g. underwater ambient sounds).This is equivalent to a call to
preload(boolean)
with a value of true.- Returns:
- This sound for chaining.
-
preload
Sets whether this sound should be preloaded or not.A preloaded sound identifies a sound that is loaded in memory as soon as the resource pack is loaded, without having to wait for the sound to be ready to stream. It is suggested to keep this to
false
, unless you are using it for a highly recurring sound (e.g. underwater ambient sounds).- Parameters:
preload
- Whether the sound should be preloaded or not.- Returns:
- This sound for chaining.
-
name
ResourceLocation name() -
type
SoundDefinition.SoundType type() -
serialize
com.google.gson.JsonElement serialize() -
canBeInShortForm
private boolean canBeInShortForm() -
stripMcPrefix
-