Created
September 10, 2019 01:02
-
-
Save theoparis/720e19d90a19040b13c7658a43378658 to your computer and use it in GitHub Desktop.
custom keybind help
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package me.creepinson.mod.client; | |
import net.minecraft.client.Minecraft; | |
import net.minecraft.client.settings.KeyBinding; | |
import net.minecraftforge.common.MinecraftForge; | |
import net.minecraftforge.fml.client.registry.ClientRegistry; | |
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; | |
import net.minecraftforge.fml.common.gameevent.InputEvent; | |
import org.lwjgl.input.Keyboard; | |
public class Keybinds | |
{ | |
public static KeyBinding switch; | |
public static void register() | |
{ | |
switch = new KeyBinding("Switch Keybinding", Keyboard.KEY_G, "categories.switch"); | |
ClientRegistry.registerKeyBinding(switch); | |
MinecraftForge.EVENT_BUS.register(new KeyInputHandler()); | |
} | |
public static class KeyInputHandler { | |
@SubscribeEvent | |
public void onKeyInput(InputEvent.KeyInputEvent event) { | |
if(Keybinds.switch.isPressed()){ | |
// do something when the keybind is pressed | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment