Jump to content

Checking if a vanilla keybind is pressed


chimera27

Recommended Posts

I was wondering how I would check if a vanilla keybind is pressed without overwriteing it. I can't seem to find any kind of keybinding handler for the vanilla binds, the keybind class is the closest I could get but it seems very odd in how it works and gives me no way to check if a specific keybind is active. Setting my keybind to that key simply overwrites it and nulifies the vanilla one (which isn't an option considering the one i'm going for is space :/ ) Anyone know a good way of doing this?

Creator of Metroid Cubed! Power Suits, Beams, Hypermode and more!

width=174 height=100http://i.imgur.com/ghgWmA3.jpg[/img]

Link to comment
Share on other sites

This is what I use in my SmartLights mod that I've been working on, to see if the player is sneaking:

 

int sneak = Minecraft.getMinecraft().gameSettings.keyBindSneak.keyCode;

if (Keyboard.isKeyDown(sneak))
{
    // Do stuff
}

 

Note:

 

I  use it in onBlockActivated() so I have access to a World object for checking isRemote to avoid crashing. I'm not sure if it's necessary since the Keyboard object is from the library lwjgLinput which should be loaded by the server too. I haven't tested my mod in MP yet.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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