當前位置: 首頁>>代碼示例>>Java>>正文


Java InputEvent類代碼示例

本文整理匯總了Java中cpw.mods.fml.common.gameevent.InputEvent的典型用法代碼示例。如果您正苦於以下問題:Java InputEvent類的具體用法?Java InputEvent怎麽用?Java InputEvent使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


InputEvent類屬於cpw.mods.fml.common.gameevent包,在下文中一共展示了InputEvent類的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: onMouseInput

import cpw.mods.fml.common.gameevent.InputEvent; //導入依賴的package包/類
@SubscribeEvent
public void onMouseInput(InputEvent.MouseInputEvent event) {
	if (!FMLClientHandler.instance().isGUIOpen(GuiChat.class)) {
		Minecraft mc = Minecraft.getMinecraft();
		EntityPlayer thePlayer = mc.getMinecraft().thePlayer;
		ItemStack hand = thePlayer.getCurrentEquippedItem();
		ExtendedPlayer props = ExtendedPlayer.get((EntityPlayer) thePlayer);
		int x = mc.objectMouseOver.blockX;
		int y = mc.objectMouseOver.blockY;
		int z = mc.objectMouseOver.blockZ;
		if (Mouse.isButtonDown(1) && hand == null)
			props.useMana(10);
		// TheDarkEra.packetPipeline.sendToServer(new PacketUseShout(x, y,
		// z));
	}
}
 
開發者ID:TheDarkEra,項目名稱:TheDarkEra,代碼行數:17,代碼來源:KeyHandler.java

示例6: 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

示例7: onKey

import cpw.mods.fml.common.gameevent.InputEvent; //導入依賴的package包/類
public static void onKey(@SuppressWarnings("unused") InputEvent.KeyInputEvent event) {

        // Support for dropping stacks of items on a Mac.
        if (Main.mc.gameSettings.keyBindDrop.isPressed())
        	Main.mc.thePlayer.dropOneItem(lastKeyIsCMD);
    	lastKeyIsCMD = Main.cmdMac.isPressed();

        if(Main.openConfig.isPressed())
        	openConfigScreen();
        
        if (Main.moveBlocks.isPressed())
        	Main.mc.displayGuiScreen(new GuiEditHUD(Main.mc.currentScreen));
        
        if (Main.showHelp.isPressed())
        	Tutorial.build();
        
    }
 
開發者ID:NomNuggetNom,項目名稱:mcpvp-mod,代碼行數:18,代碼來源:HandleKey.java

示例8: handleKeyInputEvent

import cpw.mods.fml.common.gameevent.InputEvent; //導入依賴的package包/類
@SubscribeEvent
public void handleKeyInputEvent(InputEvent.KeyInputEvent event) {
    LibKey keyPress = getPressedKey();

    if (keyPress == LibKey.UNKNOWN) {
        return;
    }

    if (FMLClientHandler.instance().getClient().inGameHasFocus) {
        if (FMLClientHandler.instance().getClientPlayerEntity() != null) {
            EntityPlayer entityPlayer = FMLClientHandler.instance().getClientPlayerEntity();
            if (entityPlayer.getCurrentEquippedItem() != null) {
                ItemStack currentEquppedItem = entityPlayer.getCurrentEquippedItem();
                if (currentEquppedItem.getItem() instanceof IKeyBound) {
                    if (entityPlayer.worldObj.isRemote) {
                        PacketHandler.INSTANCE.sendToServer(new MessageKeyPressed(keyPress));
                    }
                }
            }
        }
    }
}
 
開發者ID:AgileMods,項目名稱:MateriaMuto,代碼行數:23,代碼來源:KeyInputEventHandler.java

示例9: handleKeyInputEvent

import cpw.mods.fml.common.gameevent.InputEvent; //導入依賴的package包/類
@SubscribeEvent
public void handleKeyInputEvent(InputEvent.KeyInputEvent event) {
    if (FMLClientHandler.instance().getClient().inGameHasFocus) {

        if (FMLClientHandler.instance().getClientPlayerEntity() != null) {
            EntityPlayer entityPlayer = FMLClientHandler.instance().getClientPlayerEntity();

            if (entityPlayer.getCurrentEquippedItem() != null) {
                ItemStack currentlyEquippedItemStack = entityPlayer.getCurrentEquippedItem();

                if (currentlyEquippedItemStack.getItem() instanceof IKeyBound) {
                    if (entityPlayer.worldObj.isRemote) {
                        PacketHandler.INSTANCE.sendToServer(new MessageKeyPressed(getPressedKeybinding()));
                    } else {
                        ((IKeyBound) currentlyEquippedItemStack.getItem()).doKeyBindingAction(entityPlayer, currentlyEquippedItemStack, getPressedKeybinding());
                    }
                }
            }
        }
    }
}
 
開發者ID:XeliteXirish,項目名稱:Quantum-Energistics-2,代碼行數:22,代碼來源:KeyInputEventHandler.java

示例10: onKeyPressed

import cpw.mods.fml.common.gameevent.InputEvent; //導入依賴的package包/類
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void onKeyPressed(InputEvent.KeyInputEvent event) {
	EntityPlayer player = Minecraft.getMinecraft().thePlayer;
	if (player == null)
		return;
	if (mode.isPressed()) {
		Main.derpnet.sendToServer(new ItemModeMessage());
	}
	if (action.isPressed()) {
		Main.derpnet.sendToServer(new SpecialActionMessage());
		if (!MinecraftForge.EVENT_BUS.post(new SpecialActionEvent(player))) {
			ItemStack stack = player.getHeldItem();
			if (stack != null && stack.getItem() instanceof ISpecialActionItem) {
				((ISpecialActionItem) stack.getItem()).specialAction(stack, player, true);
			}
		}
	}
}
 
開發者ID:Wuerfel21,項目名稱:The-Derpy-Shiz-Mod,代碼行數:20,代碼來源:DerpyKeys.java

示例11: 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

示例12: handleKeyPress

import cpw.mods.fml.common.gameevent.InputEvent; //導入依賴的package包/類
@SubscribeEvent
public void handleKeyPress(InputEvent.KeyInputEvent event)
{
    EntityPlayer player = Minecraft.getMinecraft().thePlayer;
    KeyLib.Keys keyPressed = getKeyPressed();
    if(keyPressed.equals(KeyLib.Keys.MULTITOOL))
    {
        if(player.inventory.getCurrentItem() != null && player.inventory.getCurrentItem().getItem() instanceof ItemTemporalMultitool)
        {
            ((IKeybindAbility)player.inventory.getCurrentItem().getItem()).useTemporalAbility();
        }

        if(player.inventory.getCurrentItem() != null && NBTHelper.hasTag(player.inventory.getCurrentItem(), NBTTags.TEMPORAL_ITEMS))
        {
            handleMultitoolAbility();
        }
    }
    else if(keyPressed.equals(KeyLib.Keys.TEMPORAL_ABILITY))
    {
        if(player.inventory.getCurrentItem() != null && player.inventory.getCurrentItem().getItem() instanceof IKeybindAbility)
        {
            ((IKeybindAbility)player.inventory.getCurrentItem().getItem()).useTemporalAbility();
        }
    }
}
 
開發者ID:Lumaceon,項目名稱:ClockworkPhase,代碼行數:26,代碼來源:KeyHandler.java

示例13: 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

示例14: 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

示例15: 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


注:本文中的cpw.mods.fml.common.gameevent.InputEvent類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。