Java Code Examples for net.minecraftforge.fml.client.registry.ClientRegistry#registerKeyBinding()

The following examples show how to use net.minecraftforge.fml.client.registry.ClientRegistry#registerKeyBinding() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ClientProxy.java    From IGW-mod with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void preInit(FMLPreInitializationEvent event){
    MinecraftForge.EVENT_BUS.register(new TickHandler());

    MinecraftForge.EVENT_BUS.register(new TooltipOverlayHandler());

    //Not being used, as it doesn't really add anything...
    // MinecraftForge.EVENT_BUS.register(new HighlightHandler());

    openInterfaceKey = new KeyBinding("igwmod.keys.wiki", Constants.DEFAULT_KEYBIND_OPEN_GUI, "igwmod.keys.category");//TODO blend keybinding category in normal
    ClientRegistry.registerKeyBinding(openInterfaceKey);
    MinecraftForge.EVENT_BUS.register(this);//subscribe to key events.

    ConfigHandler.init(event.getSuggestedConfigurationFile());

    WikiRegistry.registerWikiTab(new IGWWikiTab());
    WikiRegistry.registerWikiTab(new BlockAndItemWikiTab());
    WikiRegistry.registerWikiTab(new EntityWikiTab());

    WikiRegistry.registerRecipeIntegrator(new IntegratorImage());
    WikiRegistry.registerRecipeIntegrator(new IntegratorCraftingRecipe());
    WikiRegistry.registerRecipeIntegrator(new IntegratorFurnace());
    WikiRegistry.registerRecipeIntegrator(new IntegratorStack());
    WikiRegistry.registerRecipeIntegrator(new IntegratorComment());
}
 
Example 2
Source File: ShulkerViewer.java    From ForgeHax with MIT License 6 votes vote down vote up
public ShulkerViewer() {
  super(Category.RENDER, "ShulkerViewer", false, "View the contents of a shulker box.");
  ClientRegistry.registerKeyBinding(lockDownKey);
  lockDownKey.setKeyConflictContext(
      new IKeyConflictContext() {
        @Override
        public boolean isActive() {
          return MC.currentScreen instanceof GuiContainer;
        }
        
        @Override
        public boolean conflicts(IKeyConflictContext other) {
          return false; // this will never conflict as
        }
      });
}
 
Example 3
Source File: AutoPlace.java    From ForgeHax with MIT License 5 votes vote down vote up
public AutoPlace() {
  super(Category.PLAYER, "AutoPlace", false, "Automatically place blocks on top of other blocks");
  
  this.bindSelect.setKeyConflictContext(BindingHelper.getEmptyKeyConflictContext());
  this.bindFinish.setKeyConflictContext(BindingHelper.getEmptyKeyConflictContext());
  
  ClientRegistry.registerKeyBinding(this.bindSelect);
  ClientRegistry.registerKeyBinding(this.bindFinish);
}
 
Example 4
Source File: ClientProxy.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void registerKeys()
{
	//KeyBindings.addKeyBinding(KeyBindingHandler.Key_CombatMode);
	//KeyBindings.addIsRepeating(false);
	//ClientRegistry.registerKeyBinding(KeyBindingHandler.Key_ToolMode);
	//ClientRegistry.registerKeyBinding(KeyBindingHandler.Key_LockTool);
	ClientRegistry.registerKeyBinding(KeyBindingHandler.Key_CombatMode);
	//uploadKeyBindingsToGame();
}
 
Example 5
Source File: ClientProxy.java    From Levels with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void init()
{
	keyBindingL = new KeyBinding("key.gui.weapon_interface", Keyboard.KEY_L, "key.levels");
	
	ClientRegistry.registerKeyBinding(keyBindingL);
}
 
Example 6
Source File: ClientEventHandler.java    From HoloInventory with MIT License 5 votes vote down vote up
public static void init()
{
    if (instance != null) MinecraftForge.EVENT_BUS.unregister(instance);
    instance = new ClientEventHandler();
    MinecraftForge.EVENT_BUS.register(new ClientEventHandler());

    keyHold = new KeyBinding("Hold to show", KeyConflictContext.IN_GAME, Keyboard.KEY_H, HoloInventory.MODID);
    keyToggle = new KeyBinding("Toggle to show", KeyConflictContext.IN_GAME, 0, HoloInventory.MODID);
    ClientRegistry.registerKeyBinding(keyHold);
    ClientRegistry.registerKeyBinding(keyToggle);
}
 
Example 7
Source File: SkyblockAddons.java    From SkyblockAddons with MIT License 5 votes vote down vote up
public void addKeybinds(SkyblockKeyBinding... keybinds) {
    for (SkyblockKeyBinding skyblockKeyBinding : keybinds) {
        KeyBinding keyBinding = new KeyBinding("key.skyblockaddons."+ skyblockKeyBinding.getName(), skyblockKeyBinding.getDefaultKey(), MOD_NAME);
        ClientRegistry.registerKeyBinding(keyBinding);
        skyblockKeyBinding.setKeyBinding(keyBinding);

        keyBindings.add(skyblockKeyBinding);
    }
}
 
Example 8
Source File: KeybindManager.java    From MediaMod with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Fired when you want to register keybinds
 *
 * @see MediaMod#preInit(FMLPreInitializationEvent)
 */
public void register() {
    // Initialize and declare keybinds
    INSTANCE.disableKeybind = new KeyBinding("key.disableKeybind", Keyboard.KEY_P, "key.categories.mediamod");
    INSTANCE.menuKeybind = new KeyBinding("key.menuKeybind", Keyboard.KEY_M, "key.categories.mediamod");
    INSTANCE.skipKeybind = new KeyBinding("key.skipKeybind", Keyboard.KEY_F, "key.categories.mediamod");
    INSTANCE.pausePlayKeybind = new KeyBinding("key.pausePlayKeybind", Keyboard.KEY_N, "key.categories.mediamod");

    ClientRegistry.registerKeyBinding(disableKeybind);
    ClientRegistry.registerKeyBinding(menuKeybind);
    ClientRegistry.registerKeyBinding(skipKeybind);
    ClientRegistry.registerKeyBinding(pausePlayKeybind);
}
 
Example 9
Source File: MacroCommand.java    From ForgeHax with MIT License 4 votes vote down vote up
private void registerBind() {
  KeyBinding bind = new KeyBinding(name.get(), this.getKey(), "Macros");
  ClientRegistry.registerKeyBinding(bind); // TODO: listen for key pressed for anonymous macros
  this.bind = bind;
}
 
Example 10
Source File: Nuker.java    From ForgeHax with MIT License 4 votes vote down vote up
public Nuker() {
  super(Category.PLAYER, "Nuker", false, "Mine blocks around yourself");
  this.bindSelect.setKeyConflictContext(BindingHelper.getEmptyKeyConflictContext());
  ClientRegistry.registerKeyBinding(this.bindSelect);
}
 
Example 11
Source File: KeyBindings.java    From YouTubeModdingTutorial with MIT License 4 votes vote down vote up
public static void init() {
    wandMode = new KeyBinding("key.wandmode", KeyConflictContext.IN_GAME, Keyboard.KEY_M, "key.categories.mymod");
    ClientRegistry.registerKeyBinding(wandMode);
}
 
Example 12
Source File: Module.java    From bleachhack-1.14 with GNU General Public License v3.0 4 votes vote down vote up
public void registerBind(String name, int keycode) {
	this.key = new KeyBinding(name, keycode, "BleachHack");
	ClientRegistry.registerKeyBinding(this.key);
}
 
Example 13
Source File: CommandStub.java    From ForgeHax with MIT License 4 votes vote down vote up
protected CommandStub(Map<String, Object> data) throws CommandBuildException {
  super(data);
  
  // key binding
  Integer keyCode = (Integer) data.getOrDefault(KEYBIND, -1);
  if (keyCode != -1) {
    bind = new KeyBinding(getAbsoluteName(), keyCode, "ForgeHax");
    ClientRegistry.registerKeyBinding(bind);
    
    Boolean genOptions = (Boolean) data.getOrDefault(KEYBIND_OPTIONS, true);
    if (genOptions) {
      parser.accepts("bind", "Bind to the given key").withRequiredArg();
      parser.accepts("unbind", "Sets bind to KEY_NONE");
      
      this.processors.add(
          dt -> {
            if (dt.hasOption("bind")) {
              String key = dt.getOptionAsString("bind").toUpperCase();
              
              int kc = Keyboard.getKeyIndex(key);
              if (Keyboard.getKeyIndex(key) == Keyboard.KEY_NONE) {
                throw new CommandExecuteException(
                    String.format("\"%s\" is not a valid key name", key));
              }
              
              bind(kc);
              serialize();
              
              dt.write(String.format("Bound %s to key %s [code=%d]", getAbsoluteName(), key, kc));
              dt.stopProcessing();
            } else if (dt.hasOption("unbind")) {
              unbind();
              serialize();
              
              dt.write(String.format("Unbound %s", getAbsoluteName()));
              dt.stopProcessing();
            }
          });
      this.processors.add(
          dt -> {
            if (!dt.options().hasOptions() && dt.getArgumentCount() > 0) {
              dt.write(
                  String.format(
                      "Unknown command \"%s\"", Strings.nullToEmpty(dt.getArgumentAsString(0))));
            }
          });
    }
  } else {
    bind = null;
  }
}
 
Example 14
Source File: ModKeybinds.java    From Wizardry with GNU Lesser General Public License v3.0 4 votes vote down vote up
@SideOnly(Side.CLIENT)
public static void register() {
	ClientRegistry.registerKeyBinding(pearlSwapping = new KeyBinding("key.pearl_swapping.desc", Keyboard.KEY_C, Wizardry.MODNAME));
}
 
Example 15
Source File: KeyBinds.java    From Cyberware with MIT License 4 votes vote down vote up
public static void init()
{
	menu = new KeyBinding("cyberware.keybinds.menu", Keyboard.KEY_R, "cyberware.keybinds.category");
	ClientRegistry.registerKeyBinding(menu);
}
 
Example 16
Source File: KeyBindings.java    From NotEnoughItems with MIT License 4 votes vote down vote up
public static void register() {
    for (KeyBinding keyBinding : keyBindingsToRegister) {
        ClientRegistry.registerKeyBinding(keyBinding);
    }
}
 
Example 17
Source File: BoingHandler.java    From CommunityMod with GNU Lesser General Public License v2.1 4 votes vote down vote up
public void onInit(FMLInitializationEvent e) {
    jump = new KeyBinding("key.bijump", Keyboard.KEY_SPACE, "key.categories.bijump");
    ClientRegistry.registerKeyBinding(jump);
}
 
Example 18
Source File: KeyBindings.java    From CraftingKeys with MIT License 4 votes vote down vote up
/**
 * Initializes all key bindings and registers them to the client-side.
 */
public static void init() {
    ClientRegistry.registerKeyBinding(openGuiBinding);
}
 
Example 19
Source File: KeyBindings.java    From AdvancedRocketry with MIT License 4 votes vote down vote up
public static final void init() {
	//ClientRegistry.registerKeyBinding(launch);
	ClientRegistry.registerKeyBinding(toggleJetpack);
	ClientRegistry.registerKeyBinding(openRocketUI);
}
 
Example 20
Source File: ClientProxy.java    From Sakura_mod with MIT License 4 votes vote down vote up
@Override
public void init(FMLInitializationEvent event) {
    super.init(event);
    ChangeMode = new KeyBinding("key.sakura.sheath_in", Keyboard.KEY_V, "key.categories.sakura");
    ClientRegistry.registerKeyBinding(ChangeMode); 
}