{"type": "session", "harness": "opencode", "id": "mc-0007", "name": "Custom Sounds"} {"type": "message", "message": {"role": "system", "content": "You are an expert Fabric mod developer. You write idiomatic Minecraft Fabric mods using Java, Fabric API, and Yarn mappings."}} {"type": "message", "message": {"role": "user", "content": "How do I add custom sound events and set up sounds.json for my Fabric mod?"}} {"type": "message", "message": {"role": "assistant", "content": "Register sound events:\n```java\npublic class MySounds {\n public static final SoundEvent CUSTOM_USE = SoundEvent.of(Identifier.of(\"mymod\", \"custom_use\"));\n public static final SoundEvent CUSTOM_EXPLOSION = SoundEvent.of(Identifier.of(\"mymod\", \"custom_explosion\"));\n public static final SoundEvent CUSTOM_AMBIENT = SoundEvent.of(Identifier.of(\"mymod\", \"custom_ambient\"));\n\n public static void register() {\n Registry.register(Registries.SOUND_EVENT, CUSTOM_USE.getId(), CUSTOM_USE);\n Registry.register(Registries.SOUND_EVENT, CUSTOM_EXPLOSION.getId(), CUSTOM_EXPLOSION);\n Registry.register(Registries.SOUND_EVENT, CUSTOM_AMBIENT.getId(), CUSTOM_AMBIENT);\n }\n}\n```\n\nsounds.json (assets/mymod/sounds.json):\n```json\n{\"custom_use\": {\"category\": \"block\", \"sounds\": [{\"name\": \"mymod:custom_use_1\", \"stream\": false}]},\n \"custom_explosion\": {\"category\": \"hostile\", \"sounds\": [{\"name\": \"mymod:custom_explosion\", \"stream\": true, \"attenuation_distance\": 16}]},\n \"custom_ambient\": {\"category\": \"ambient\", \"sounds\": [{\"name\": \"mymod:custom_ambient\", \"stream\": true, \"preload\": true}]}}\n```\n\nSound files: src/main/resources/assets/mymod/sounds/custom_use_1.ogg, custom_explosion.ogg, custom_ambient.ogg\n\nPlaying sounds:\n```java\nplayer.playSound(MySounds.CUSTOM_USE, 1.0f, 1.0f);\nworld.playSound(null, pos, MySounds.CUSTOM_EXPLOSION, SoundSource.HOSTILE, 1.0f, 1.0f);\nMinecraftClient.getInstance().player.playSound(MySounds.CUSTOM_AMBIENT, 0.5f, 1.0f);\n```"}}