Skip to content
Omar Mohamed edited this page Mar 11, 2026 · 2 revisions

Sound

Represents a sound with a namespaced ID, volume, pitch, and optional world position.


Constructor

Sound(soundId, volume, pitch, position)

Creates a new Sound object.

  • Parameters:
    • soundIdString — Namespaced sound ID (e.g. "minecraft:entity.player.levelup")
    • volumeDouble
    • pitchDouble
    • positionPosition
make pos new Position(0, 64, 0)
make snd new Sound("minecraft:block.note_block.harp", 1.0, 1.0, pos)
player.playSound(snd)

Functions

getName()

Returns the namespaced sound ID.

  • Returns: String

getVolume()

Returns the volume of the sound.

  • Returns: Double

getPitch()

Returns the pitch of the sound.

  • Returns: Double

getPosition()

Returns the world position this sound is associated with.

setSoundId(soundId)

Sets the namespaced sound ID.

  • Parameters:
    • soundIdString

setVolume(volume)

Sets the volume.

  • Parameters:
    • volumeDouble

setPitch(pitch)

Sets the pitch.

  • Parameters:
    • pitchDouble

setPosition(position)

Sets the world position.

make pos new Position(0, 64, 0)
make snd new Sound("minecraft:entity.player.levelup", 1.0, 1.0, pos)

~ Modify after creation
snd.setPitch(1.5)
snd.setVolume(0.5)
snd.setSoundId("minecraft:block.note_block.bell")

player.playSound(snd)

toString()

Returns a string representation of this sound.

  • Returns: String — e.g. "Sound{name=minecraft:entity.player.levelup, volume=1.0, pitch=1.0, position=Position{x=0, y=64, z=0}}"
make pos new Position(0, 64, 0)
make snd new Sound("minecraft:ambient.cave", 0.8, 1.0, pos)
say snd.toString()

📖 InteractiveStuff Docs


🧱 Types


⚙️ Scripting

📃 Built-in Library

Clone this wiki locally