Entity and block sounds !

This commit is contained in:
2026-11-22 08:23:11 -03:00
parent da44685f54
commit d18fe19027
17 changed files with 332 additions and 20 deletions
+28
View File
@@ -41,6 +41,34 @@ A sound without a category only follows the player's master volume.
`deno task check-mods` reports a file that isn't there, and warns about an `.ogg` no sound plays.
## Blocks and Entities
A block's or entity's json can name what its sounds' ids start with, and the game plays them without any code:
```json
"sounds": "copper_tools:copper"
```
| For | Sound | When |
| --------- | ---------- | ----------------------------------------------------------------------------------------------------- |
| a block | `/break` | It's broken, by a player or a script's `break_block`. Not when a script replaces it with `set_block`. |
| a block | `/place` | A player or a machine's `use_item_on` places it. |
| a block | `/hit` | Every 4 ticks while a player breaks it, at a quarter of the volume, only on their client. |
| a block | `/step` | Something walks on it with no step sound of its own, every 1.6 blocks, at 0.15 of the volume. |
| an entity | `/hurt` | It's hurt. |
| an entity | `/death` | It dies. |
| an entity | `/step` | It walks on a block, every 1.6 blocks, in place of the block's step. |
| an entity | `/ambient` | Every 4 to 12 seconds while it's alive, timed by each player's client. |
So `"sounds": "copper_tools:copper"` on a block plays `copper_tools:copper/break` when it breaks, and so on. Any of them
can be left out of `sounds.json`, and isn't played. A whole family of blocks usually shares one, like every copper
block, and `check-mods` reports a block or entity whose `sounds` has none of its own, which is usually a typo.
The player breaking or placing a block hears it right away from their own client, and everyone else from the server.
Players step with the blocks they walk on, except the one playing while they sneak or fly. Anything about a mob that
depends on what it's doing is its scripts' to play, see [From the Server](#from-the-server) and
[Lasting Sounds](#lasting-sounds).
## Playing Sounds
Sounds are played where what makes them happens: a server phase for what happens in the world, a shared rule for what a