Jump to content

[Solved] KeyBinding in 1.14 not retaining changes


BatHeart

Recommended Posts

Apologies if this has been asked elsewhere. I looked, but didn't find it.

In versions of my Forge mod up to 1.12.2, I was handling KeyBindings like this, and it was working fine:

1. Declare the KeyBindings

2. In FMLPreInitializationEvent, registerKeyBinding

3. Detect the bound keys being used, using a KeyInputEvent, within my code

 

I realise things are slightly different in 1.14.3:

1. I still Declare the KeyBindings as before (but have to use key codes instead of the Keyboard. shortcuts)

2. There is no FMLPreInitializationEvent, so I registerKeyBinding in FMLClientSetupEvent

3. I Detect the keys in virtually the same way, but KeyInputEvent is no more, so I use ClientTickEvent instead

 

All of this basically works in 1.14.3 the same as it used to, but with one problem. If I change a keymapping in-game (on the Controls screen) then it works just fine while I am in-game, and even writes the new key code to the options.txt file, but the next time I go into game, the key mappings are back to the default ones. This didn't happen in 1.12.2. It's as though it is not reading the mappings from options.txt - or is it reading them and then overwriting them with the defaults?

 

Has anyone else experienced this problem in 1.14.3, or maybe you know what I am doing wrong here and can help?

Any help would be much appreciated.

 

Edited by BatHeart
Now solved
Link to comment
Share on other sites

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

Ah. Thank you. Just to confirm that I have got this right - we are both doing exactly the same things, but you do it all in your ClientProxy, whereas I have been doing it in my base mod, and tying them to particular events.

Evidently you do not see this problem, so I shall try to replicate your method in my code and hopefully ...

Link to comment
Share on other sites

After working on restructuring my whole mod, to bring it as close to @Cadiboo's example as I could, this still wasn't working. (But my mod was so much better structured. Thanks, @Cadiboo!)

 

Then I discovered what the problem had been all along. I had been using an old convention available for KeyBindings, which evidently worked up to and including 1.12. My categories were named 'key.category.batty'. This must now be 'key.categories.batty'. I also had the KeyBindings themselves named e.g. 'key.batty:infodisplay' and this should now be 'key.batty.infodisplay'.

 

One or the other (or both) of these were responsible for my problem. It's very strange, because the whole key binding worked fine while I was in game. It's just that it forgot the key bindings which had been changed the next time I entered game.

 

Anyway. All solved. I just thought I would post this in case anyone else wanders into similar problems. It's all in the name!

  • Like 1
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.