Files
src
build.gradle
gradle.properties
settings.gradle
Code
14 543
src/main/java/com/voiceaction/client/VoiceActionClient.java
package com.voiceaction.client;
import com.voiceaction.client.audio.MicrophoneHandler;
import com.voiceaction.client.control.SmartControlManager;
import com.voiceaction.client.gui.GroupHudOverlay;
import com.voiceaction.network.NetworkHandler;
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.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.client.util.InputUtil;
import org.lwjgl.glfw.GLFW;
public class VoiceActionClient implements ClientModInitializer {
public static KeyBinding openGroupMenuKey;
public static KeyBinding toggleSmartControlKey;
public static KeyBinding simulateJumpKey; // For testing without STT library
@Override
public void onInitializeClient() {
NetworkHandler.registerClient();
MicrophoneHandler.init();
SmartControlManager.init();
openGroupMenuKey = KeyBindingHelper.registerKeyBinding(new KeyBinding(
"key.voiceaction.group_menu",
InputUtil.Type.KEYSYM,
GLFW.GLFW_KEY_G,
"category.voiceaction.general"
));
toggleSmartControlKey = KeyBindingHelper.registerKeyBinding(new KeyBinding(
"key.voiceaction.toggle_smart",
InputUtil.Type.KEYSYM,
GLFW.GLFW_KEY_V,
"category.voiceaction.general"
));
// Debug key to simulate voice command "jump"
simulateJumpKey = KeyBindingHelper.registerKeyBinding(new KeyBinding(
"key.voiceaction.sim_jump",
InputUtil.Type.KEYSYM,
GLFW.GLFW_KEY_J,
"category.voiceaction.debug"
));
ClientTickEvents.END_CLIENT_TICK.register(client -> {
if (openGroupMenuKey.wasPressed()) {
client.setScreen(new com.voiceaction.client.gui.GroupScreen(client.currentScreen));
}
if (toggleSmartControlKey.wasPressed()) {
boolean newState = !SmartControlManager.isEnabled();
SmartControlManager.setEnabled(newState);
if (client.player != null) {
client.player.sendMessage(net.minecraft.text.Text.of("Smart Control: " + (newState ? "ON" : "OFF")), true);
}
}
if (simulateJumpKey.wasPressed()) {
SmartControlManager.processCommand("jump");
}
SmartControlManager.tick(client);
MicrophoneHandler.tick(client);
});
HudRenderCallback.EVENT.register(new GroupHudOverlay());
}
}