Files
gradle
src
.gitignore
build.gradle
gradle.properties
gradlew
gradlew.bat
settings.gradle
Code
10 478
src/main/java/com/rakeys/RAKeys.java
package com.rakeys;
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 org.lwjgl.glfw.GLFW;
public class RAKeys implements ClientModInitializer {
private static KeyBinding ra1Key;
private static KeyBinding ra2Key;
private static KeyBinding ra3Key;
@Override
public void onInitializeClient() {
ra1Key = KeyBindingHelper.registerKeyBinding(new KeyBinding(
"key.rakeys.ra1",
InputUtil.Type.KEYSYM,
GLFW.GLFW_KEY_R,
"category.rakeys.main"
));
ra2Key = KeyBindingHelper.registerKeyBinding(new KeyBinding(
"key.rakeys.ra2",
InputUtil.Type.KEYSYM,
GLFW.GLFW_KEY_T,
"category.rakeys.main"
));
ra3Key = KeyBindingHelper.registerKeyBinding(new KeyBinding(
"key.rakeys.ra3",
InputUtil.Type.KEYSYM,
GLFW.GLFW_KEY_Y,
"category.rakeys.main"
));
ClientTickEvents.END_CLIENT_TICK.register(client -> {
if (client.player == null) return;
if (ra1Key.wasPressed()) {
client.player.networkHandler.sendCommand("ra 1");
}
if (ra2Key.wasPressed()) {
client.player.networkHandler.sendCommand("ra 2");
}
if (ra3Key.wasPressed()) {
client.player.networkHandler.sendCommand("ra 3");
}
});
}
}