Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2016
66
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.halestormxv.Main.handler;
  2.  
  3.  
  4. import org.lwjgl.input.Keyboard;
  5.  
  6. import com.halestormxv.Main.MainRegistry;
  7. import com.halestormxv.Main.handler.network.PacketDispatcher;
  8. import com.halestormxv.Main.handler.network.packets.OpenGuiPacket;
  9. import com.halestormxv.Main.handler.network.packets.OpenGuiPacketAlt;
  10. import com.halestormxv.item.CelestialCraft_items;
  11.  
  12. import cpw.mods.fml.client.FMLClientHandler;
  13. import cpw.mods.fml.client.registry.ClientRegistry;
  14. import cpw.mods.fml.common.eventhandler.SubscribeEvent;
  15. import cpw.mods.fml.common.gameevent.InputEvent;
  16. import cpw.mods.fml.relauncher.Side;
  17. import cpw.mods.fml.relauncher.SideOnly;
  18. import net.minecraft.client.gui.GuiChat;
  19. import net.minecraft.client.settings.KeyBinding;
  20.  
  21. public class KeyHandler {
  22.    
  23.     public static final int BACKPACK_KEY = 0;
  24.    
  25.     private static final String[] keyDesc = {"key.celestialcraft.dismiss.desc"};
  26.     private static final int[] keyValues = {Keyboard.KEY_Y};
  27.     private final KeyBinding[] keys;
  28.    
  29.     public KeyHandler(){
  30.         keys = new KeyBinding[keyValues.length];
  31.         for (int i = 0; i < keyValues.length; i++){
  32.             keys[i] = new KeyBinding(keyDesc[i], keyValues[i], "key.celestialcraft.category");
  33.             ClientRegistry.registerKeyBinding(keys[i]);
  34.         }
  35.     }
  36.    
  37.     @SubscribeEvent
  38.     public void onKeyInput(InputEvent.KeyInputEvent event){
  39.         if(!FMLClientHandler.instance().isGUIOpen(GuiChat.class)){
  40.             int key = Keyboard.getEventKey();
  41.             boolean isDown = Keyboard.getEventKeyState();
  42.            
  43.             //Backpack Key
  44.             if(isDown && key == keyValues[BACKPACK_KEY]){
  45.                 // Send Packet to open GUI
  46.                 PacketDispatcher.sendToServer(new OpenGuiPacketAlt(CelestialCraft_items.guiIDKeyPouch));
  47.             }
  48.         }
  49.        
  50.     }
  51.  
  52. }
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement