Advertisement
Guest User

Untitled

a guest
Dec 5th, 2015
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.71 KB | None | 0 0
  1. import org.lwjgl.input.Keyboard;
  2.  
  3. import com.daystomine.gun.ItemGun;
  4. import com.daystomine.main.ClientProxy;
  5. import com.daystomine.main.MainRegistry;
  6.  
  7. import net.minecraft.client.Minecraft;
  8. import net.minecraft.client.entity.EntityClientPlayerMP;
  9. import net.minecraft.client.gui.GuiChat;
  10. import net.minecraft.client.settings.KeyBinding;
  11. import net.minecraft.entity.Entity;
  12. import net.minecraft.entity.player.EntityPlayer;
  13. import cpw.mods.fml.client.FMLClientHandler;
  14. import cpw.mods.fml.client.registry.ClientRegistry;
  15. import cpw.mods.fml.common.eventhandler.SubscribeEvent;
  16. import cpw.mods.fml.common.gameevent.InputEvent;
  17. import cpw.mods.fml.common.gameevent.InputEvent.KeyInputEvent;
  18. import cpw.mods.fml.relauncher.Side;
  19. import cpw.mods.fml.relauncher.SideOnly;
  20.  
  21.  
  22. @SideOnly(value = Side.CLIENT)
  23. public class KeyHandler
  24. {
  25. public static KeyBinding zoom = new KeyBinding("battlefield.key.zoom", 44, "keys.catagory.battlefield");
  26. public static KeyBinding attach = new KeyBinding("battlefield.key.attach", 13, "keys.catagory.battlefield");
  27. public static KeyBinding reload = new KeyBinding("battlefield.key.reload", 19, "keys.catagory.battlefield");
  28.  
  29. @SubscribeEvent
  30. @SideOnly(Side.CLIENT)
  31. public void keyPressed(InputEvent.KeyInputEvent event)
  32. {
  33. if (Minecraft.getMinecraft().currentScreen == null) {
  34. if (zoom.isPressed())
  35. {
  36. if ((Minecraft.getMinecraft().theWorld != null) && (Minecraft.getMinecraft().thePlayer != null))
  37. {
  38. EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;
  39. if ((player.getHeldItem() != null) && (player.getHeldItem().getItem() != null) && ((player.getHeldItem().getItem() instanceof ItemGun)))
  40. {
  41. ItemGun item = (ItemGun)player.getHeldItem().getItem();
  42. if (item.canUseScope(player.getHeldItem())) {
  43. ClientProxy.tickHandler.isZoomed = (!ClientProxy.tickHandler.isZoomed);
  44. }
  45. }
  46. }
  47. }
  48. else if (attach.isPressed())
  49. {
  50. if ((Minecraft.getMinecraft().thePlayer == null) || (Minecraft.getMinecraft().theWorld == null)) {
  51. return;
  52. }
  53. EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;
  54. if ((player.getHeldItem() != null) && ((player.getHeldItem().getItem() instanceof ItemGun))) {
  55.  
  56. } else {
  57.  
  58. }
  59. }
  60. else if (reload.isPressed())
  61. {
  62. MainRegistry.proxy.reloadGun();
  63. }
  64. }
  65. }
  66.  
  67. public void registerKeys()
  68. {
  69. ClientRegistry.registerKeyBinding(zoom);
  70. ClientRegistry.registerKeyBinding(attach);
  71. ClientRegistry.registerKeyBinding(reload);
  72. }
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement