@SubscribeEvent @SideOnly(Side.CLIENT) public void onKeyboardInputEvent(KeyboardInputEvent.Post event) { if (!this.shouldDisplayGuiOverlay(event.getGui())) { return; } this.getGuiOverlay().handleKeyboardInput(); }
@SubscribeEvent (priority = EventPriority.LOWEST, receiveCanceled = true)//we need to be called after JEI has registered the key press and updated the search box. public void onKeyTypedPost(KeyboardInputEvent.Post event) { GuiTextFieldFilter fieldFilter = JEIIntegrationManager.getTextFieldFilter(); if (fieldFilter != null && JEIIntegrationManager.searchBoxOwner == EnumItemBrowser.JEI && isNEIInWorld() && fieldFilter.isFocused()) { NEIClientConfig.setSearchExpression(fieldFilter.getText(), false); LayoutManager.searchField.setText(fieldFilter.getText(), false); } }
@SubscribeEvent public void onKeyTypedPost(KeyboardInputEvent.Post event) { GuiScreen gui = event.getGui(); if (gui instanceof GuiContainer) { char c = Keyboard.getEventCharacter(); int eventKey = Keyboard.getEventKey(); if (eventKey == 0 && c >= 32 || Keyboard.getEventKeyState()) { if (eventKey != 1) { for (IInputHandler inputhander : inputHandlers) { if (inputhander.lastKeyTyped(gui, c, eventKey)) { event.setCanceled(true); return; } } } if (KeyBindings.get("nei.options.keys.gui.enchant").isActiveAndMatches(eventKey) && canPerformAction("enchant")) { NEIClientPacketHandler.sendOpenEnchantmentWindow(); event.setCanceled(true); } if (KeyBindings.get("nei.options.keys.gui.potion").isActiveAndMatches(eventKey) && canPerformAction("potion")) { NEIClientPacketHandler.sendOpenPotionWindow(); event.setCanceled(true); } } } }
@SubscribeEvent public void onKeyInput(KeyboardInputEvent event) { if(FMLClientHandler.instance().isGUIOpen(GuiChat.class) || mc.currentScreen != null) return; EntityPlayer player = mc.thePlayer; Entity ridingEntity = player.ridingEntity; if(ridingEntity instanceof IControllable){ IControllable riding =(IControllable)ridingEntity; if(mc.gameSettings.keyBindForward.isKeyDown()) riding.pressKey(0, player); if(mc.gameSettings.keyBindBack.isKeyDown()) riding.pressKey(1, player); if(mc.gameSettings.keyBindLeft.isKeyDown()) riding.pressKey(2, player); if(mc.gameSettings.keyBindRight.isKeyDown()) riding.pressKey(3, player); if(mc.gameSettings.keyBindJump.isKeyDown()) riding.pressKey(4, player); if(downKey.isPressed()) riding.pressKey(5, player); if(mc.gameSettings.keyBindSneak.isKeyDown()) riding.pressKey(6, player); } }