Jump to content

Overriding Vanilla Hotkeys


Jongh

Recommended Posts

Hey folks,

 

So basic mod, it's showing up in-game when I run it in eclipse. I'm just trying to rewrite a vanilla hotkey to a different key. For example, I've put this line :

 

        Minecraft.getMinecraft().gameSettings.keyBindRight.setKeyCode(Keyboard.KEY_E);

 

In the init() method of ClientProxy. But when I run the game, the hotkey is still set to the Vanilla one, 'D'. I tried putting a print message right after the line printing out the keyCode for keyBindRight, and it shows up as 18 which is KEY_E. So I think that Minecraft may initialize? the hotkey values after the mods are loaded or something so it overwrites my change.

 

Any way I could get this to work? Thanks.

Link to comment
Share on other sites

Uh well I was trying to make a mod so that when the user types in chat, they will type in dvorak keyboard layout. But after researching it doesn't really look like its possible to change what is input into the pending chat box, just what actually goes to the chat.

 

But I was thinking that it was possible! Because that's what language mods have to do right. The ones that let you type in Chinese for example. But I tried looking at the code for one and it was so complicated, and not really a simple solution I was looking for.

 

So for the sake of finishing my only option is to have the mod just set all the hotkeys to dvorak presets and have the user play with computer on a Dvorak keyboard layout... A bit crude but I'd at least like to have something and this is what I came up with.

Link to comment
Share on other sites

Each player has the option to change vanilla hot-key bindings anyway. I for one have changed my movement, jump, sneak etc keys so I can use the arrows, num-pad and nearby function keys on an idiosyncratic keyboard. If a mod messed with my choices, it would incapacitate me. However, if a mod assumed specific keys and my custom bindings foul it, then the mod wouldn't work (for me or anyone else who customizes keys).

 

I recommend that you not use keys at that level. Instead, have your mod work at the abstract key (e.g. "sneak" or "jump") level so that physical keys can be translated by a player's custom bindings before your mod does anything to them.

 

OTOH, If you're creating new hotkeys, then do both levels (an abstract key function and a default physical key). Players who add your mod can then change your default to suit their own keyboards and playing style (and resolve collisions with their existing customizations), but your mod will still work based on the layer of abstract key functions.

 

If some modders come up with some generally useful key functions, I wonder if Forge will have a key dictionary someday (like the ore dictionary) that can enable mods to sync on "common" added keys. Wait, if that's a good idea, then Forge probably already has one.

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Link to comment
Share on other sites

Hey jeffryfisher, I see what you mean, but what I was trying to do was make the mod change the hotkeys to the Dvorak equivalents simply so that the user doesn't have to go in manually and change it themselves. And then if they use any non-default hotkey values then they will just go and change those once.

 

I know it's not a very elegant idea and I'm not sure that I'm going to continue attempting to make this Dvorak chatting mod, but I'd still like to know why the keybindcode change is not registering in-game, if anybody can help with that.

 

On the other hand if anybody knows how to change the keybinds only when the user is typing into chat, that would be what I was initially trying to do and would be quite helpful.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.