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());
}
});
}
}