From c2dbe688c1602ac60004877fc68bb360d60e3fbb Mon Sep 17 00:00:00 2001 From: Joseph Garcia <46433893+free-range-chicken@users.noreply.github.com> Date: Mon, 7 Dec 2020 12:33:19 -0600 Subject: [PATCH] initial key press response --- .../com/josyf/macrobuttons/MacroButtons.java | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/josyf/macrobuttons/MacroButtons.java b/src/main/java/com/josyf/macrobuttons/MacroButtons.java index 1469633..343b678 100644 --- a/src/main/java/com/josyf/macrobuttons/MacroButtons.java +++ b/src/main/java/com/josyf/macrobuttons/MacroButtons.java @@ -1,13 +1,43 @@ package com.josyf.macrobuttons; + + import net.fabricmc.api.ModInitializer; +import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; +import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper; +import net.minecraft.client.options.KeyBinding; +import net.minecraft.client.util.InputUtil; +import net.minecraft.text.LiteralText; +import org.lwjgl.glfw.GLFW; public class MacroButtons implements ModInitializer { public static final String MOD_ID = "mgbuttons"; + @Override public void onInitialize() { - + assignGuiToKey(); } + + private void assignGuiToKey() { + + System.out.println("I'm getting here"); + + KeyBinding keyBinding = KeyBindingHelper.registerKeyBinding(new KeyBinding( + "key.macrobuttons.opengui", // The translation key of the keybinding's name + InputUtil.Type.KEYSYM, // The type of the keybinding, KEYSYM for keyboard, MOUSE for mouse. + GLFW.GLFW_KEY_G, // The keycode of the key + "gui.macrobuttons.mgbuttons" // The translation key of the keybinding's category. + )); + + ClientTickEvents.END_CLIENT_TICK.register(client -> { + while (keyBinding.wasPressed()) { + client.player.sendMessage(new LiteralText("Key 1 was pressed!"), false); + } + }); + } + + } +