Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Taken from "?menu keybinds" on #mcp-modding, and then annotated.
- package net.minecraft.src;
- // Import these, we'll need 'em
- import net.minecraft.client.Minecraft;
- import java.lang.reflect.Method;
- public class mod_ToggleKey extends BaseMod
- {
- public mod_ToggleKey()
- {
- // Register a key with ModLoader. Keep the params the way they are.
- ModLoader.RegisterKey(this, this.key_toggle, false);
- // Name the key.
- ModLoader.AddLocalization("key.toggle", "name of key");
- }
- // Code here is executed every tick, see other tutorial in my pastebin.
- public void OnTickInGame(Minecraft minecraft)
- {
- if(toggle)
- {
- // The stuff that the toggle does goes here.
- }
- }
- // This code just helps us realize when you push the key down.
- public void KeyboardEvent(KeyBinding event)
- {
- Minecraft minecraft = ModLoader.getMinecraftInstance();
- if (event == this.key_time)
- {
- toggle = !toggle;
- }
- }
- // Standard ModLoader procedure...
- public String Version()
- {
- return "v0.1 for Beta 1.6.6 - Frizkie's Keybind Tut";
- }
- // Define our key_toggle. The "20" parameter is the key code which can be found here: http://img87.imageshack.us/img87/5476/keyboardt.png
- private KeyBinding key_toggle = new KeyBinding("key.toggle", 20);
- private boolean toggle = false;
- }
Advertisement
Add Comment
Please, Sign In to add comment