SHARE
TWEET

Untitled

a guest Sep 21st, 2019 126 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package me.creepinson.mod.client;
  2.  
  3. import net.minecraft.client.Minecraft;
  4. import net.minecraft.client.settings.KeyBinding;
  5. import net.minecraftforge.common.MinecraftForge;
  6. import net.minecraftforge.fml.client.registry.ClientRegistry;
  7. import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
  8. import net.minecraftforge.fml.common.gameevent.InputEvent;
  9. import org.lwjgl.input.Keyboard;
  10.  
  11. public class Keybinds
  12. {
  13.     public static KeyBinding switch;
  14.  
  15.     public static void register()
  16.     {
  17.         switch = new KeyBinding("Switch Keybinding", Keyboard.KEY_G, "categories.switch");
  18.  
  19.         ClientRegistry.registerKeyBinding(switch);
  20.  
  21.         MinecraftForge.EVENT_BUS.register(new KeyInputHandler());
  22.     }
  23.  
  24.     public static class KeyInputHandler {
  25.         @SubscribeEvent
  26.         public void onKeyInput(InputEvent.KeyInputEvent event) {
  27.             if(Keybinds.switch.isPressed()){
  28.                // do something when the keybind is pressed
  29.             }
  30.         }
  31.     }
  32. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top