crafty_yt.
๐Ÿ“Ž 1 file 1,506 chars
๐Ÿ“„
pasted-code-1793089878789.txt
txt 31 lines
โ–ถ
Make a client-side Fabric mod for Minecraft 1.21.11 called "Custom Key Sound" (or "KeySound").

### Core Features
- When the player presses a configurable keybind, play a selected sound.
- The keybind must be fully configurable in the normal Minecraft Controls / Key Binds menu (supports any keyboard key + mouse buttons).
- Default keybind: R.

### GUI (very important)
Create a clean in-game GUI (screen) that allows the player to:
- Browse and select any vanilla Minecraft sound (searchable list of SoundEvents preferred).
- Set volume and pitch for the sound (sliders).
- Preview / test the currently selected sound with a "Play" button.
- Save button that saves the selected sound, volume, and pitch.

The GUI should be opened with a command (e.g. /keysound) and/or a second keybind (optional but nice).

### Sound System
- Support all vanilla Minecraft sounds.
- Use the modern sound API (SoundInstance / client sound manager).

### Technical Requirements
- Client-side only.
- Proper Fabric keybind registration so it appears in Minecraft Controls menu.
- Config saved (Cloth Config + ModMenu support preferred, or simple JSON).
- Clean code, stable, ready to compile for 1.21.11.

### Extra
- Clear README explaining how to change the keybind (in Controls menu) and how to open the GUI.
- Make the GUI look decent and easy to use.

Generate the full working mod with all necessary files (main class, keybind, GUI screen, sound handling, config, fabric.mod.json, etc.).
Kodari AI
KodariOct 27 at 8:39 am 2
KeySoundMod
Client-side Fabric mod for Minecraft 1.21.1 that plays a configurable vanilla sound when pressing a keybind. Features a searchable GUI screen with sound selection, volume/pitch sliders, play preview, and save functionality. Registers a configurable keybind (default R) in the Controls menu, supports all vanilla SoundEvents, saves config as JSON, and opens via /keysound command or optional second keybind. Clean, stable code with README documentation.
  1. Set up the client-only Fabric 1.21.11 project and keybind/config flow.

  2. Build the owo-ui sound browser with search, volume/pitch controls, preview, and save.

  3. Add the required metadata, bundled owo-lib manifest, and usage README.

Created the client-only Custom Key Sound mod for Fabric 1.21.11, including configurable R and K keybinds, an owo-ui searchable sound browser with preview and volume/pitch controls, JSON config saving, project metadata, and a README. The sound browser includes registered sounds from the running game and installed mods.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
manifest.kod
README.md
settings.gradle
Code
10 415
src/client/java/com/kodari/keysound/KeySoundClient.java
package com.kodari.keysound;

import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.client.util.InputUtil;
import net.minecraft.util.Identifier;
import org.lwjgl.glfw.GLFW;

public class KeySoundClient implements ClientModInitializer {
    private static final KeyBinding.Category CATEGORY = KeyBinding.Category.create(Identifier.of("keysound", "main"));
    private static KeyBinding playSoundKey;
    private static KeyBinding openSettingsKey;

    @Override
    public void onInitializeClient() {
        KeySoundConfig.load();

        playSoundKey = KeyBindingHelper.registerKeyBinding(new KeyBinding(
                "key.keysound.play",
                InputUtil.Type.KEYSYM,
                GLFW.GLFW_KEY_R,
                CATEGORY
        ));
        openSettingsKey = KeyBindingHelper.registerKeyBinding(new KeyBinding(
                "key.keysound.open",
                InputUtil.Type.KEYSYM,
                GLFW.GLFW_KEY_K,
                CATEGORY
        ));

        ClientTickEvents.END_CLIENT_TICK.register(client -> {
            while (playSoundKey.wasPressed()) {
                KeySoundConfig.play(client, KeySoundConfig.soundId, KeySoundConfig.volume, KeySoundConfig.pitch);
            }

            while (openSettingsKey.wasPressed()) {
                client.setScreen(new KeySoundScreen());
            }
        });
    }
}