initial key press response
This commit is contained in:
parent
94f1874c41
commit
c2dbe688c1
@ -1,13 +1,43 @@
|
|||||||
package com.josyf.macrobuttons;
|
package com.josyf.macrobuttons;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import net.fabricmc.api.ModInitializer;
|
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 class MacroButtons implements ModInitializer {
|
||||||
|
|
||||||
public static final String MOD_ID = "mgbuttons";
|
public static final String MOD_ID = "mgbuttons";
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInitialize() {
|
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);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user