Camellias_

KeyInputHandler

May 18th, 2018
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.04 KB | None | 0 0
  1. package com.camellias.voidaicarcania.util.handlers;
  2.  
  3. import com.camellias.voidaicarcania.network.MessageFly;
  4. import com.camellias.voidaicarcania.network.NetworkHandler;
  5. import com.camellias.voidaicarcania.util.Keybindings;
  6.  
  7. import jline.internal.Log;
  8. import net.minecraft.client.Minecraft;
  9. import net.minecraft.entity.player.EntityPlayer;
  10. import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
  11. import net.minecraftforge.fml.common.gameevent.InputEvent;
  12.  
  13. public class KeyInputHandler
  14. {
  15.     private Keybindings getPressedKey()
  16.     {
  17.         for(Keybindings key : Keybindings.values())
  18.         {
  19.             if(key.isPressed()) return key;
  20.         }
  21.         return null;
  22.     }
  23.    
  24.     @SubscribeEvent
  25.     public void handleKeyInputEvent(InputEvent.KeyInputEvent event)
  26.     {
  27.         Keybindings key = getPressedKey();
  28.         if(key != null)
  29.         {
  30.             switch(key)
  31.             {
  32.             case FLY:
  33.                 EntityPlayer player = Minecraft.getMinecraft().player;
  34.                
  35.                 if(player.getTags().contains("flight"))
  36.                 {
  37.                     NetworkHandler.sendToServer(new MessageFly());
  38.                 }
  39.                
  40.                 break;
  41.             }
  42.         }
  43.     }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment