Skip to content

Sounds - Sound Definitions

anvil.api.sounds.sound_definitions

The resource pack's sounds/sound_definitions.json: the sound files each sound identifier plays.

SoundDefinition

Bases: JsonFile[_SoundDefinitionsFile]

The sound definitions of the resource pack, sounds/sound_definitions.json: each sound name and the files it plays. There is one per pack.

Documentation reference

identifier property

The file's identifier.

name property

The identifier's name, without its namespace.

__export__()

Copies the sound files and writes the definitions, when there is any.

__schema__() classmethod

The JSON Schema (draft 2020-12) of this file: the schema of its _document_type, with the file's type as title and where it is written under x-anvil-file.

Raises:

Type Description
TypeError

When the class is an abstract file base, with no document type.

queue()

Queues the sound definitions for export.

sound_reference(sound_reference, category, use_legacy_max_distance=False, max_distance=None, min_distance=None, subtitle=None, server_sound=None)

Defines a sound. A sound defined again replaces the first definition.

Parameters:

Name Type Description Default
sound_reference str

The sound name, written as <namespace>:<sound_reference>.

required
category SoundCategory

The volume slider the sound follows.

required
use_legacy_max_distance bool

Uses the old distance falloff. Defaults to False.

False
max_distance float

The distance the sound is no longer heard at.

None
min_distance float

The distance the sound starts to fade at.

None
subtitle str

The subtitle text, or a subtitle. localization key.

None
server_sound MusicInfo

Also registers the sound in the behavior pack's server sound definitions.

None

Returns:

Name Type Description
_SoundDescription _SoundDescription

The sound definition; add its files with add_sound.