Guest User

ModLoader KeyBinding Example

a guest
Jul 13th, 2011
1,553
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.75 KB | None | 0 0
  1. package net.minecraft.src;
  2.  
  3. import net.minecraft.client.Minecraft;
  4.  
  5. public class mod_KeybindTest extends BaseMod {
  6.  
  7.     public KeyBinding key_test = new KeyBinding("key_test", 36);
  8.    
  9.     public mod_KeybindTest()
  10.     {
  11.         ModLoader.RegisterKey(this, this.key_test, false);
  12.         ModLoader.AddLocalization("key_test", "Test");
  13.         System.out.println("KeyBindings Loaded -Hopefully-");
  14.     }
  15.    
  16.     public void KeyboardEvent(KeyBinding keybinding)
  17.     {
  18.         System.out.println("Keyboard Event");
  19.         Minecraft mc = ModLoader.getMinecraftInstance();
  20.         EntityPlayer entityplayer = mc.thePlayer;
  21.        
  22.         if(keybinding == this.key_test)
  23.         {
  24.             entityplayer.health = 20;
  25.             entityplayer.motionY += 1.0F;
  26.         }
  27.     }
  28.    
  29.    
  30.     @Override
  31.     public String Version() {
  32.         return "**Keybind Test** Minecraft Beta 1.7.3";
  33.     }
  34.  
  35. }
Advertisement
Add Comment
Please, Sign In to add comment