Sounds - Server Sound Definitions
anvil.api.sounds.server_sound_definitions
The behavior pack's server sound definitions: music information and duration of sounds, for the server.
MusicInfo
dataclass
The server-side information of a sound, registered with server_sound= on the
sound methods.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
genres
|
list[str]
|
Free-form genre labels. |
None
|
moods
|
list[str]
|
Free-form mood labels. |
None
|
artist
|
str
|
The artist, as display text or a translation key. |
None
|
title
|
str
|
The title, as display text or a translation key. |
None
|
duration
|
float
|
The length of the sound, in seconds. When set, the server tracks the sound's lifetime. |
None
|
duration_tracking
|
DurationInfoMode
|
How the duration drains: by game ticks or by wall-clock time. Defaults to game time. |
GameTime
|
tags
|
list[tuple[str, str | list[str]]]
|
Pack-defined |
None
|
broadcast_range
|
float
|
A broadcast play of the sound reaches players within this many blocks, capped by their view distance. |
None
|
ServerSoundDefinition
Bases: JsonFile[_ServerSoundDefinitionsFile]
The behavior pack's server sound definitions: duration, music information and tags of sounds the resource pack defines.
Server sounds are registered through server_sound= on SoundDefinition.sound_reference
and the methods that call it (MusicDefinition.music_definition, the
SoundEvent.add_*_event methods), so a server sound always has its client sound.
identifier
property
The file's identifier.
name
property
The identifier's name, without its namespace.
__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 server sound definitions, when there is any.
server_sound_reference(sound_identifier, music_info)
Registers the server information of a sound the resource pack defines.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sound_identifier
|
str
|
The sound name, |
required |
music_info
|
MusicInfo
|
The duration, music information and tags. |
required |