当前位置: 首页>>代码示例>>Java>>正文


Java InputEvent.KeyInputEvent方法代码示例

本文整理汇总了Java中cpw.mods.fml.common.gameevent.InputEvent.KeyInputEvent方法的典型用法代码示例。如果您正苦于以下问题:Java InputEvent.KeyInputEvent方法的具体用法?Java InputEvent.KeyInputEvent怎么用?Java InputEvent.KeyInputEvent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cpw.mods.fml.common.gameevent.InputEvent的用法示例。


在下文中一共展示了InputEvent.KeyInputEvent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onKeyInput

import cpw.mods.fml.common.gameevent.InputEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onKeyInput(InputEvent.KeyInputEvent event) {
    // first check that the player is not using the chat menu
    // you can use this method from before:
    // if (FMLClientHandler.instance().getClient().inGameHasFocus) {
    // or you can use this new one that is available, doesn't really matter
    if (!FMLClientHandler.instance().isGUIOpen(GuiChat.class)) {
        // you can get the key code of the key pressed using the Keyboard class:
        int kb = Keyboard.getEventKey();
        // similarly, you can get the key state, but this will always be true when the event is fired:
        boolean isDown = Keyboard.getEventKeyState();

        // same as before, chain if-else if statements to find which of your custom keys
        // was pressed and act accordingly:
        if (kb == keys[CUSTOM_INV].getKeyCode()) {
            EntityPlayer player = FMLClientHandler.instance().getClient().thePlayer;
            // before you could close the screen from here, but that no longer seems to be
            // possible instead, you need to do so from within the GUI itself
            // so we will just send a packet to open the GUI:
            player.openGui(LOTRRings.instance, UIHandler.PLAYERINVENTORY_UI_1, player.getEntityWorld(), player.chunkCoordX, player.chunkCoordY, player.chunkCoordZ);
        }
    }
}
 
开发者ID:TimVerhaegen,项目名称:Lotr_Mod_Addons,代码行数:24,代码来源:CustomKeyHandler.java

示例2: handleKeyInputEvent

import cpw.mods.fml.common.gameevent.InputEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void handleKeyInputEvent(InputEvent.KeyInputEvent event) {
    KeyBindings key = getPressedKey();
    if (key != null) {
        switch (key) {
            case MODE:
                if (Minecraft.getMinecraft().thePlayer.getHeldItem() == null || Minecraft.getMinecraft().thePlayer.
                        getHeldItem().getItem() != ItemHandler.fireWand)
                    return;

                ItemStack w = Minecraft.getMinecraft().thePlayer.getHeldItem();

                if (ItemHelper.getString(w, "mode", "PROJECTILE").equals("PROJECTILE")) {
                    NetworkHandler.sendToServer(new MessageModeWand("mode", "FIRE"));
                    Minecraft.getMinecraft().thePlayer.addChatComponentMessage(new ChatComponentText(EnumChatFormatting.DARK_GRAY +
                            "Fire Mode enabled!"));
                } else if (ItemHelper.getString(w, "mode", "PROJECTILE").equals("FIRE")) {
                    NetworkHandler.sendToServer(new MessageModeWand("mode", "PROJECTILE"));
                    Minecraft.getMinecraft().thePlayer.addChatComponentMessage(new ChatComponentText(EnumChatFormatting.DARK_GRAY +
                            "Projectile Mode enabled!"));
                }
                break;
        }
    }
}
 
开发者ID:BRForgers,项目名称:DynamicCraft,代码行数:26,代码来源:KeyInputHandler.java

示例3: onKeyInput

import cpw.mods.fml.common.gameevent.InputEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onKeyInput(InputEvent.KeyInputEvent event) {
    PlayerInfo pi = PlayerManagerTFC.getInstance().getClientPlayer();
    EntityClientPlayerMP player = FMLClientHandler.instance().getClient().thePlayer;

    if (FMLClientHandler.instance().getClient().inGameHasFocus &&
            FMLClientHandler.instance().getClient().thePlayer.getCurrentEquippedItem() != null &&
            FMLClientHandler.instance().getClient().currentScreen == null) {
        if (Key_PrevChiselMode.isPressed()) {
            if (player.getCurrentEquippedItem().getItem() instanceof ItemChisel) {
                pi.setChiselMode(prevChiselMode(pi));
                //Let's send the actual ChiselMode so the server/client does not
                //come out of sync.
                AbstractPacket pkt = new KeyPressPacket(pi.chiselMode);
                TerraFirmaCraft.PACKET_PIPELINE.sendToServer(pkt);

            }
        }
    }
}
 
开发者ID:raymondbh,项目名称:TFC-Additions,代码行数:21,代码来源:KeyBindingHandler.java

示例4: onKeyInput

import cpw.mods.fml.common.gameevent.InputEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onKeyInput(InputEvent.KeyInputEvent event) {
	if (Keybindings.openGui.isPressed())
		Minecraft.getMinecraft().thePlayer.openGui(MacroMaker.instance, Reference.Guis.WAYPOINT.ordinal(), Minecraft.getMinecraft().thePlayer.worldObj, (int)Minecraft.getMinecraft().thePlayer.posX, (int)Minecraft.getMinecraft().thePlayer.posY, (int)Minecraft.getMinecraft().thePlayer.posZ);
	else if (Keybindings.macro.isPressed())
		Minecraft.getMinecraft().thePlayer.openGui(MacroMaker.instance, Reference.Guis.MACRO.ordinal(), Minecraft.getMinecraft().thePlayer.worldObj, (int)Minecraft.getMinecraft().thePlayer.posX, (int)Minecraft.getMinecraft().thePlayer.posY, (int)Minecraft.getMinecraft().thePlayer.posZ);
	else if (Keybindings.activateMacros.isPressed())
		TickHandler.isMacroInUse = !TickHandler.isMacroInUse;
	if (Config.showKeysOnHUD) {
		if (Keyboard.getEventKeyState())
			try {
				KeyOverlay.keys.offer(new Object[]{Keyboard.getKeyName(Keyboard.getEventKey()).toUpperCase(), KeyOverlay.KEY_LIFE_LENGTH});
			} catch (Exception e) {
				e.printStackTrace();
			}
	}
}
 
开发者ID:austinv11,项目名称:MacroMaker,代码行数:18,代码来源:KeyHandler.java

示例5: onKeyInput

import cpw.mods.fml.common.gameevent.InputEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onKeyInput(InputEvent.KeyInputEvent event) {
	
	/**if(KeyBindings.fly.isPressed()){
		Jetpack.canFly = true;
		Minecraft.getMinecraft().thePlayer.setJumping(true);
	}else{
		Jetpack.canFly = false;
	}
		
	*/
	if(KeyBindings.refuel.isPressed()){
		Jetpack.refuel = true;
		}
		else{
			Jetpack.refuel = false;
		}
}
 
开发者ID:Beamfield,项目名称:TectoCraft,代码行数:19,代码来源:KeyInputHandler.java

示例6: onKeyInput

import cpw.mods.fml.common.gameevent.InputEvent; //导入方法依赖的package包/类
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onKeyInput(InputEvent.KeyInputEvent event) {
	 if(Minecraft.getMinecraft().inGameHasFocus) {
		   if(Minecraft.getMinecraft().gameSettings.keyBindJump.getIsKeyPressed())
  {
          message = new PZPacketKeyBind().setPacketData("jump", 90);
          ProjectZulu_Core.packetHandler.sendToServer(message);
      }
		   if(Minecraft.getMinecraft().gameSettings.keyBindInventory.getIsKeyPressed()){
	            message = new PZPacketKeyBind().setPacketData("inventory", 0); 
	            ProjectZulu_Core.packetHandler.sendToServer(message);
	        }
		   if(Minecraft.getMinecraft().gameSettings.keyBindSneak.getIsKeyPressed()){
            message = new PZPacketKeyBind().setPacketData("dismount", 0); 
            ProjectZulu_Core.packetHandler.sendToServer(message);
        }
		   
 }
}
 
开发者ID:soultek101,项目名称:projectzulu1.7.10,代码行数:21,代码来源:KeyHandler.java

示例7: onKeyInput

import cpw.mods.fml.common.gameevent.InputEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onKeyInput(InputEvent.KeyInputEvent event)
{
    if (Config.getInstance().isServerListEnabled() && ((Client) CreeperHost.proxy).openGuiKey.isPressed())
    {
        if (CreeperHost.instance.handledInvite != null)
        {
            CreeperHost.instance.clearToast(false);
            mc.displayGuiScreen(new GuiInvited(CreeperHost.instance.handledInvite, mc.currentScreen));
            CreeperHost.instance.handledInvite = null;
        }
        else
            CreeperHost.proxy.openFriendsGui();
    }
}
 
开发者ID:CreeperHost,项目名称:CreeperHostGui,代码行数:16,代码来源:EventHandler.java

示例8: invoke

import cpw.mods.fml.common.gameevent.InputEvent; //导入方法依赖的package包/类
@Override
public void invoke(Event e) {
    InputEvent.KeyInputEvent event = (InputEvent.KeyInputEvent) e;
    if (!Keyboard.getEventKeyState()) return;
    if (Keyboard.getEventKey() == Keyboard.KEY_NONE) return;
    new KeypressEvent(Keyboard.getEventKey()).call();
}
 
开发者ID:Ygore,项目名称:bit-client,代码行数:8,代码来源:KeypressEventDispatcher.java

示例9: onEvent

import cpw.mods.fml.common.gameevent.InputEvent; //导入方法依赖的package包/类
@SideOnly(Side.CLIENT)
@SubscribeEvent(priority= EventPriority.NORMAL, receiveCanceled=true)
public void onEvent(InputEvent.KeyInputEvent event) {
    Minecraft mc = Minecraft.getMinecraft();
    World world = mc.theWorld;
    EntityPlayer player = mc.thePlayer;
    if(keys[0].isPressed()) {
        NetworkManager.sendToServer(new GuiAokMessage());
    }
    if(mc.gameSettings.keyBindChat.isPressed()) {
        player.closeScreen();
        player.openGui(AgeOfKingdom.INSTANCE, AgeOfKingdom.serverProxy.GUI_CHAT, world, (int) player.posX, (int) player.posY, (int) player.posZ);
    }
}
 
开发者ID:jackey8616,项目名称:Age-of-Kingdom,代码行数:15,代码来源:KeyManager.java

示例10: onKeyInput

import cpw.mods.fml.common.gameevent.InputEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onKeyInput(InputEvent.KeyInputEvent event)
{
    if (KeyBindings.dialerModeChange.isPressed())
    {
        RFUtilities.RFU_NET_WRAPPER.sendToServer(new PacketDialerChangeMode());
    }
}
 
开发者ID:XFactHD,项目名称:RFUtilities,代码行数:9,代码来源:KeyInputHandler.java

示例11: onKeyboardInput

import cpw.mods.fml.common.gameevent.InputEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onKeyboardInput(InputEvent.KeyInputEvent event) {
	char eventChar = Keyboard.getEventCharacter();
	boolean isDown = Keyboard.getEventKeyState();
	Page page = book.getPages()[book.getCurrentPage()];
	for (Entry entry : page.getEntries())
		if (entry instanceof InteractiveEntry) {
			((InteractiveEntry) entry).onKeyboardEvent(eventChar, isDown);
		}
}
 
开发者ID:austinv11,项目名称:CollectiveFramework,代码行数:11,代码来源:GuiBook.java

示例12: onKeyInput

import cpw.mods.fml.common.gameevent.InputEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onKeyInput(InputEvent.KeyInputEvent event) {
	if (Config.keyOverlay) {
		if (Keyboard.getEventKeyState())
			try {
				KeyOverlay.keys.offer(new Object[]{Keyboard.getKeyName(Keyboard.getEventKey()).toUpperCase(), KeyOverlay.KEY_LIFE_LENGTH});
			} catch (Exception e) {
				e.printStackTrace();
			}
	}
}
 
开发者ID:austinv11,项目名称:CollectiveFramework,代码行数:12,代码来源:KeyHandler.java

示例13: onKeyInput

import cpw.mods.fml.common.gameevent.InputEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onKeyInput(InputEvent.KeyInputEvent event) {
    if (KeyBindings.openForceBelt.isPressed()) {
        ItemStack forceBelt = DartCraftUtils.getCorrectForceBelt(mc.thePlayer);
        if (forceBelt != null) {
            DartCraft2.NETWORK.sendToServer(new OpenGuiContainerPacket(Reference.GUIs.FORCE_BELT.ordinal()));
        }
    }
}
 
开发者ID:austinv11,项目名称:DartCraft2,代码行数:10,代码来源:KeyInputHandler.java

示例14: keyInput

import cpw.mods.fml.common.gameevent.InputEvent; //导入方法依赖的package包/类
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void keyInput(InputEvent.KeyInputEvent ev) {
    // DEBUG
    KeyBinding[] keyBindings = ClientProxy.keyBindings;
    if (keyBindings[0].isPressed()) {
        MyTownClient.log.info("Key binding = " + keyBindings[0].getKeyDescription());
        Minecraft.getMinecraft().thePlayer.openGui(MyTownClient.instance, 0, Minecraft.getMinecraft().thePlayer.worldObj, (int) Math.floor(Minecraft.getMinecraft().thePlayer.posX), (int) Math.floor(Minecraft.getMinecraft().thePlayer.posY), (int) Math.floor(Minecraft.getMinecraft().thePlayer.posZ));
    }
}
 
开发者ID:MyEssentials,项目名称:MyTown2-Client,代码行数:11,代码来源:InputHandler.java

示例15: onKeyPressed

import cpw.mods.fml.common.gameevent.InputEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onKeyPressed(InputEvent.KeyInputEvent event)
{
    if (!FMLClientHandler.instance().isGUIOpen(GuiProjectPlanner.class) && KeyBindings.openGui.isPressed())
    {
        FMLClientHandler.instance().showGuiScreen(new GuiProjectPlanner());
    }
}
 
开发者ID:Dynious,项目名称:ProjectPlanner,代码行数:9,代码来源:ClientEventHandler.java


注:本文中的cpw.mods.fml.common.gameevent.InputEvent.KeyInputEvent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。