Java Code Examples for net.minecraft.client.settings.KeyBinding#setKeyBindState()
The following examples show how to use
net.minecraft.client.settings.KeyBinding#setKeyBindState() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GuiMoveModule.java From seppuku with GNU General Public License v3.0 | 5 votes |
@Listener public void onUpdate(EventPlayerUpdate event) { if (event.getStage() == EventStageable.EventStage.PRE) { final Minecraft mc = Minecraft.getMinecraft(); if (mc.currentScreen instanceof GuiChat || mc.currentScreen == null) { return; } final int[] keys = new int[]{mc.gameSettings.keyBindForward.getKeyCode(), mc.gameSettings.keyBindLeft.getKeyCode(), mc.gameSettings.keyBindRight.getKeyCode(), mc.gameSettings.keyBindBack.getKeyCode()}; for (int keyCode : keys) { if (Keyboard.isKeyDown(keyCode)) { KeyBinding.setKeyBindState(keyCode, true); } else { KeyBinding.setKeyBindState(keyCode, false); } } if (Keyboard.isKeyDown(mc.gameSettings.keyBindJump.getKeyCode())) { if (mc.player.isInLava() || mc.player.isInWater()) { mc.player.motionY += 0.039f; } else { if (mc.player.onGround) { mc.player.jump(); } } } if (Mouse.isButtonDown(2)) { Mouse.setGrabbed(true); mc.inGameHasFocus = true; } else { Mouse.setGrabbed(false); mc.inGameHasFocus = false; } } }
Example 2
Source File: MwKeyHandler.java From mapwriter with MIT License | 5 votes |
@SubscribeEvent public void onKeyPress(InputEvent.KeyInputEvent event){ if(keyMapGui.getIsKeyPressed()){ KeyBinding.setKeyBindState(keyMapGui.getKeyCode(), false); Mw.instance.onKeyDown(keyMapGui); } if(keyNewMarker.getIsKeyPressed()){ KeyBinding.setKeyBindState(keyNewMarker.getKeyCode(), false); Mw.instance.onKeyDown(keyNewMarker); } if(keyMapMode.getIsKeyPressed()){ KeyBinding.setKeyBindState(keyMapMode.getKeyCode(), false); Mw.instance.onKeyDown(keyMapMode); } if(keyNextGroup.getIsKeyPressed()){ KeyBinding.setKeyBindState(keyNextGroup.getKeyCode(), false); Mw.instance.onKeyDown(keyNextGroup); } if(keyTeleport.getIsKeyPressed()){ KeyBinding.setKeyBindState(keyTeleport.getKeyCode(), false); Mw.instance.onKeyDown(keyTeleport); } if(keyZoomIn.getIsKeyPressed()){ KeyBinding.setKeyBindState(keyZoomIn.getKeyCode(), false); Mw.instance.onKeyDown(keyZoomIn); } if(keyZoomOut.getIsKeyPressed()){ KeyBinding.setKeyBindState(keyZoomOut.getKeyCode(), false); Mw.instance.onKeyDown(keyZoomOut); } if(keyUndergroundMode.getIsKeyPressed()){ KeyBinding.setKeyBindState(keyUndergroundMode.getKeyCode(), false); Mw.instance.onKeyDown(keyUndergroundMode); } }
Example 3
Source File: GuiCyberwareMenu.java From Cyberware with MIT License | 4 votes |
@Override public void updateScreen() { super.updateScreen(); hex.updateCursorCounter(); if (close) { mc.displayGuiScreen(null); } if (mc != null && mc.gameSettings != null) { if (KeyBinds.menu != null && (!mc.gameSettings.isKeyDown(KeyBinds.menu) && !editing && !color) || CyberwareAPI.getCapability(mc.thePlayer).getNumActiveItems() < 1) { if (this.selectedPart != -1 && !editing) { ICyberwareUserData data = CyberwareAPI.getCapability(mc.thePlayer); ItemStack hki = data.getActiveItems().get(this.selectedPart); ClientUtils.useActiveItemClient(mc.thePlayer, hki); } mc.displayGuiScreen(null); } ImmutableSet<KeyBinding> set = ImmutableSet.of(mc.gameSettings.keyBindForward, mc.gameSettings.keyBindLeft, mc.gameSettings.keyBindBack, mc.gameSettings.keyBindRight, mc.gameSettings.keyBindSneak, mc.gameSettings.keyBindSprint, mc.gameSettings.keyBindJump); for(KeyBinding keybind : set) { boolean ee = false; int key = keybind.getKeyCode(); if (!editing) { if (key < 0) { int button = 100 + key; ee = Mouse.isButtonDown(button); } else { ee = Keyboard.isKeyDown(key); } } KeyBinding.setKeyBindState(key, ee); } } }