Posted June 24, 20205 yr I'm trying to make a mod that involves randomly rebinding vanilla controls without user input however I'm confused on the InputMappings.Input class . I'm trying to use an instance of KeyBindingMap like so: public static KeyBindingMap allBinds; to change the mapping of vanilla controls. I get the vanilla binds like so: Minecraft.getInstance().gameSettings.keyBindAttack I then try to change the keybindings like so: allBinds.addKey( ??? ,Minecraft.getInstance().gameSettings.keyBindAttack); the first variable needs to be an instance of InputMappings.Input, but I'm very confused on how to use it. I'm not trying to record user input for this. I want to randomly switch around keyCodes from a predefined set of keys so that one event is done through a different key after the switch. I've already tried removing all the keys in the map and then recreating them to randomly switch the keys, but that crashes the game since (I'm assuming from what I saw In the error logs) some Vanilla values can't be NULL. Edited June 24, 20205 yr by Thigh Exercise wrote something wrong
June 24, 20205 yr Author update: So I tried to get the keys like so: public static InputMappings.Input[] allVanillaKeys = new InputMappings.Input[22]; allVanillaKeys[0] = Minecraft.getInstance().gameSettings.keyBindAttack.getKey(); allVanillaKeys[1] = Minecraft.getInstance().gameSettings.keyBindForward.getKey(); I then flipped the keys with each other Minecraft.getInstance().gameSettings.keyBindAttack.bind(allVanillaKeys[1]); Minecraft.getInstance().gameSettings.keyBindForward.bind(allVanillaKeys[0]); But when I tried running it in game, the game couldn't save options and the game crashed due to a NullPointerException, so I guess switching the keys like that nullifys some stuff.
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.