Skip to main content

Sound System Protocol

Gate’s sound system operates at the protocol level, sending and managing sound packets for Minecraft clients. This page documents the packet-level implementation details.
For the high-level Sound API documentation, see Sound API - Play and Control Sounds.

Sound Packets

Gate handles two main types of sound packets:

Sound Effect Packet

Plays a named sound effect at a specific location:

Entity Sound Effect Packet

Plays a sound at an entity’s position:

Sound Sources

Sound sources determine which client volume slider controls the sound:

Source String Mapping

Stop Sound Packet

Stops playing sounds based on filters:

Filter Combinations

Protocol Version Handling

Version Requirements

Version-Specific Encoding

Sound packets encode differently based on protocol version:

Sound Package Implementation

The sound package (go.minekube.com/gate/pkg/edition/java/sound) provides high-level functions that construct and send sound packets:

Playing Sounds

Stopping Sounds

Entity ID Management

Sound packets require the entity ID of the emitter player on the backend server:

Getting Entity ID

The entity ID is stored when the player joins the backend server:

Server Matching

Verify both players are on the same backend server:

Error Handling

The sound system defines specific errors:

Error Handling Example

Packet Interception

Intercept sound packets in session handlers:

Minecraft Limitations

Be aware of known Minecraft bugs:

MC-146721: Stereo Sounds Not Positional

In Minecraft 1.14+, stereo sounds are played globally instead of positionally. This is a client bug that cannot be fixed by the proxy.

MC-138832: Volume/Pitch Ignored (1.14-1.16.5)

In Minecraft 1.14 through 1.16.5, the client ignores volume and pitch values in sound packets. Always use default volume (1.0) and pitch (1.0) for these versions.

Invalid Sound Names

The client silently ignores invalid sound names - no error is shown to the player. Always validate sound names against the Minecraft sounds.json.

Complete Example: Custom Sound System

See Also