/** * Called when the mouse is clicked within this entry. Returning true means that something within this entry was * clicked and the list should not be dragged. */ public boolean mousePressed(int slotIndex, int mouseX, int mouseY, int mouseEvent, int relativeX, int relativeY) { if (this.btnChangeKeyBinding.mousePressed(GuiKeyBindingList.this.mc, mouseX, mouseY)) { GuiKeyBindingList.this.controlsScreen.buttonId = this.keybinding; return true; } else if (this.btnReset.mousePressed(GuiKeyBindingList.this.mc, mouseX, mouseY)) { this.keybinding.setToDefault(); GuiKeyBindingList.this.mc.gameSettings.setOptionKeyBinding(this.keybinding, this.keybinding.getKeyCodeDefault()); KeyBinding.resetKeyBindingArrayAndHash(); return true; } else { return false; } }
@Override public void onKeyPress(KeyBinding key) { Minecraft mc = FMLClientHandler.instance().getClient(); if (mc.inGameHasFocus) { if (key == KeyHandler.getInstance().keybindOpenOptions) { ItemStack helmetStack = mc.player.getItemStackFromSlot(EntityEquipmentSlot.HEAD); if (helmetStack.getItem() == Itemss.PNEUMATIC_HELMET) { FMLCommonHandler.instance().showGuiScreen(GuiHelmetMainScreen.getInstance()); } } else if (key == KeyHandler.getInstance().keybindHack && HackUpgradeRenderHandler.enabledForPlayer(mc.player)) { getSpecificRenderer(BlockTrackUpgradeHandler.class).hack(); getSpecificRenderer(EntityTrackUpgradeHandler.class).hack(); } else if (key == KeyHandler.getInstance().keybindDebuggingDrone && DroneDebugUpgradeHandler.enabledForPlayer(PneumaticCraftRepressurized.proxy.getPlayer())) { getSpecificRenderer(EntityTrackUpgradeHandler.class).selectAsDebuggingTarget(); } } }
@Override public void init() { ClientRegistry.registerKeyBinding(keyOpenToolMenu = new KeyBinding("key.toolbelt.open", Keyboard.KEY_R, "key.toolbelt.category")); //keyOpenToolMenu. ClientRegistry.registerKeyBinding(keyCycleToolMenuL = new KeyBinding("key.toolbelt.cycle.left", 0, "key.toolbelt.category")); ClientRegistry.registerKeyBinding(keyCycleToolMenuR = new KeyBinding("key.toolbelt.cycle.right", 0, "key.toolbelt.category")); Map<String, RenderPlayer> skinMap = Minecraft.getMinecraft().getRenderManager().getSkinMap(); RenderPlayer render = skinMap.get("default"); render.addLayer(new LayerToolBelt(render)); render = skinMap.get("slim"); render.addLayer(new LayerToolBelt(render)); }
/** * Called by the controls from the buttonList when activated. (Mouse pressed for buttons) */ protected void actionPerformed(GuiButton button) throws IOException { if (button.id == 200) { this.mc.displayGuiScreen(this.parentScreen); } else if (button.id == 201) { for (KeyBinding keybinding : this.mc.gameSettings.keyBindings) { keybinding.setToDefault(); } KeyBinding.resetKeyBindingArrayAndHash(); } else if (button.id < 100 && button instanceof GuiOptionButton) { this.options.setOptionValue(((GuiOptionButton)button).returnEnumOptions(), 1); button.displayString = this.options.getKeyBinding(GameSettings.Options.getEnumOptions(button.id)); } }
/** * Called by the controls from the buttonList when activated. (Mouse pressed for buttons) */ protected void actionPerformed(GuiButton button) throws IOException { if (button.id == 200) { this.mc.displayGuiScreen(this.parentScreen); } else if (button.id == 201) { for (KeyBinding keybinding : this.mc.gameSettings.keyBindings) { keybinding.setKeyCode(keybinding.getKeyCodeDefault()); } KeyBinding.resetKeyBindingArrayAndHash(); } else if (button.id < 100 && button instanceof GuiOptionButton) { this.options.setOptionValue(((GuiOptionButton)button).returnEnumOptions(), 1); button.displayString = this.options.getKeyBinding(GameSettings.Options.getEnumOptions(button.id)); } }
/** * Draws the screen and all the components in it. Args : mouseX, mouseY, renderPartialTicks */ public void drawScreen(int mouseX, int mouseY, float partialTicks) { this.drawDefaultBackground(); this.keyBindingList.drawScreen(mouseX, mouseY, partialTicks); this.drawCenteredString(this.fontRendererObj, this.screenTitle, this.width / 2, 8, 16777215); boolean flag = true; for (KeyBinding keybinding : this.options.keyBindings) { if (keybinding.getKeyCode() != keybinding.getKeyCodeDefault()) { flag = false; break; } } this.buttonReset.enabled = !flag; super.drawScreen(mouseX, mouseY, partialTicks); }
public boolean mousePressed(int slotIndex, int p_148278_2_, int p_148278_3_, int p_148278_4_, int p_148278_5_, int p_148278_6_) { if (this.btnChangeKeyBinding.mousePressed(GuiKeyBindingList.this.mc, p_148278_2_, p_148278_3_)) { GuiKeyBindingList.this.field_148191_k.buttonId = this.keybinding; return true; } else if (this.btnReset.mousePressed(GuiKeyBindingList.this.mc, p_148278_2_, p_148278_3_)) { GuiKeyBindingList.this.mc.gameSettings.setOptionKeyBinding(this.keybinding, this.keybinding.getKeyCodeDefault()); KeyBinding.resetKeyBindingArrayAndHash(); return true; } else { return false; } }
/** Call this to finalise any additional key bindings we want to create in the mod. * @param settings Minecraft's original GameSettings object which we are appending to. */ private void fixAdditionalKeyBindings(GameSettings settings) { if (this.additionalKeys == null) { return; // No extra keybindings to add. } // The keybindings are stored in GameSettings as a java built-in array. // There is no way to append to such arrays, so instead we create a new // array of the correct // length, copy across the current keybindings, add our own ones, and // set the new array back // into the GameSettings: KeyBinding[] bindings = (KeyBinding[]) ArrayUtils.addAll(settings.keyBindings, this.additionalKeys.toArray()); settings.keyBindings = bindings; }
/** * Will set the focus to ingame if the Minecraft window is the active with focus. Also clears any GUI screen * currently displayed */ public void setIngameFocus() { if (Display.isActive()) { if (!this.inGameHasFocus) { if (!IS_RUNNING_ON_MAC) { KeyBinding.updateKeyBindState(); } this.inGameHasFocus = true; this.mouseHelper.grabMouseCursor(); this.displayGuiScreen((GuiScreen)null); this.leftClickCounter = 10000; } } }
public AutoClicker() { super("Auto Clicker", 0xb22c2c, ModuleCategory.COMBAT); listeners.add(new Listener<PlayerUpdate>() { @Override public void call(PlayerUpdate event) { if (maxCPS.getValue() < minCPS.getValue()) { maxCPS.setValue(minCPS.getValue()); } if (timer.hasReached(delay)) { timer.reset(); KeyBinding.onTick(mc.gameSettings.keyBindAttack.getKeyCode()); double min = minCPS.getValue(); double delta = maxCPS.getValue() - min; double nextDelay = 1 / (min + Math.random() * delta); delay = (int) Math.floor(nextDelay * 1000); } } }); }
/** * Draws the screen and all the components in it. */ public void drawScreen(int mouseX, int mouseY, float partialTicks) { this.drawDefaultBackground(); this.keyBindingList.drawScreen(mouseX, mouseY, partialTicks); this.drawCenteredString(this.fontRendererObj, this.screenTitle, this.width / 2, 8, 16777215); boolean flag = false; for (KeyBinding keybinding : this.options.keyBindings) { if (keybinding.getKeyCode() != keybinding.getKeyCodeDefault()) { flag = true; break; } } this.buttonReset.enabled = flag; super.drawScreen(mouseX, mouseY, partialTicks); }
public boolean mousePressed(int slotIndex, int mouseX, int mouseY, int mouseEvent, int relativeX, int relativeY) { if (this.btnChangeKeyBinding.mousePressed(GuiKeyBindingList.this.mc, mouseX, mouseY)) { GuiKeyBindingList.this.controlsScreen.buttonId = this.keybinding; return true; } else if (this.btnReset.mousePressed(GuiKeyBindingList.this.mc, mouseX, mouseY)) { GuiKeyBindingList.this.mc.gameSettings.setOptionKeyBinding(this.keybinding, this.keybinding.getKeyCodeDefault()); KeyBinding.resetKeyBindingArrayAndHash(); return true; } else { return false; } }
@Override public void init(FMLInitializationEvent event) { bindingP = new KeyBinding("Player Information", Keyboard.KEY_P, "Lost Eclipse"); ClientRegistry.registerKeyBinding(bindingP); }
@SubscribeEvent public void onInput(InputEvent event) { KeyBinding p = ClientProxy.bindingP; EntityPlayer player = Minecraft.getMinecraft().player; if (player != null && p.isPressed()) { player.openGui(LootSlashConquer.instance, GuiHandler.PLAYER_INFORMATION, player.getEntityWorld(), player.getPosition().getX(), player.getPosition().getY(), player.getPosition().getZ()); } // if ability key is pressed. // send server packet calling ability start. }
private KeyHandler() { registerKeyListener(HUDHandler.instance()); keybindOpenOptions = registerKeyBinding(new KeyBinding(KeyHandler.DESCRIPTION_HELMET_OPTIONS, Keyboard.KEY_U, Names.PNEUMATIC_KEYBINDING_CATEGORY)); keybindHack = registerKeyBinding(new KeyBinding(KeyHandler.DESCRIPTION_HELMET_HACK, Keyboard.KEY_H, Names.PNEUMATIC_KEYBINDING_CATEGORY)); keybindDebuggingDrone = registerKeyBinding(new KeyBinding(KeyHandler.DESCRIPTION_HELMET_DEBUGGING_DRONE, Keyboard.KEY_Y, Names.PNEUMATIC_KEYBINDING_CATEGORY)); }
public void addKey(int keyCode, KeyBinding keyBinding) { KeyModifier keyModifier = keyBinding.getKeyModifier(); IntHashMap<Collection<KeyBinding>> bindingsMap = map.get(keyModifier); Collection<KeyBinding> bindingsForKey = bindingsMap.lookup(keyCode); if (bindingsForKey == null) { bindingsForKey = new ArrayList<KeyBinding>(); bindingsMap.addKey(keyCode, bindingsForKey); } bindingsForKey.add(keyBinding); }
/** * This will only subscribe when NotEnoughKeys is not installed. * * @param event */ @SubscribeEvent public void onKey(KeyInputEvent event) { for (KeyBinding key : keys) { if (key.isPressed()) { onKey(key); } } }
@Override public void keyTyped(char ch, int key) { if (changingKeybinding) { changingKeybinding = false; updateKeybindingButtonText(); KeyHandler.getInstance().keybindOpenOptions.setKeyCode(key); KeyBinding.resetKeyBindingArrayAndHash(); FMLClientHandler.instance().getClient().player.sendStatusMessage(new TextComponentString(TextFormatting.GREEN + "Bound the opening of this menu to the '" + Keyboard.getKeyName(key) + "' key."), false); } }
public KeyHandler(){ keys = new KeyBinding[desc.length]; for(int i = 0; i < desc.length; ++i){ keys[i] = new KeyBinding(desc[i], keyValues[i], "key.uhccompass.category"); ClientRegistry.registerKeyBinding(keys[i]); } }
@SubscribeEvent public void onKeyInput(KeyInputEvent event) { for(KeyBinding key : ringEvents) if(key.isPressed()) sendRingEvent(ringEvents.indexOf(key)); if(openInventory.isPressed()) HarshenClientUtils.openInventory(); }
/** * Fired when a key is typed (except F11 which toggles full screen). This is the equivalent of * KeyListener.keyTyped(KeyEvent e). Args : character (character on the key), keyCode (lwjgl Keyboard key code) */ protected void keyTyped(char typedChar, int keyCode) throws IOException { if (this.buttonId != null) { if (keyCode == 1) { this.buttonId.setKeyModifierAndCode(net.minecraftforge.client.settings.KeyModifier.NONE, 0); this.options.setOptionKeyBinding(this.buttonId, 0); } else if (keyCode != 0) { this.buttonId.setKeyModifierAndCode(net.minecraftforge.client.settings.KeyModifier.getActiveModifier(), keyCode); this.options.setOptionKeyBinding(this.buttonId, keyCode); } else if (typedChar > 0) { this.buttonId.setKeyModifierAndCode(net.minecraftforge.client.settings.KeyModifier.getActiveModifier(), typedChar + 256); this.options.setOptionKeyBinding(this.buttonId, typedChar + 256); } if (!net.minecraftforge.client.settings.KeyModifier.isKeyCodeModifier(keyCode)) this.buttonId = null; this.time = Minecraft.getSystemTime(); KeyBinding.resetKeyBindingArrayAndHash(); } else { super.keyTyped(typedChar, keyCode); } }
private KeyBinding getBinding(int keyCode, KeyModifier keyModifier) { Collection<KeyBinding> bindings = map.get(keyModifier).lookup(keyCode); if (bindings != null) { for (KeyBinding binding : bindings) { if (binding.isActiveAndMatches(keyCode)) { return binding; } } } return null; }
@Override public void bind(int keyCode) { if(bind != null) { bind.setKeyCode(keyCode); KeyBinding.resetKeyBindingArrayAndHash(); } }
@Override public void preInit(FMLPreInitializationEvent e) { super.preInit(e); keyBindings = new KeyBinding[1]; keyBindings[0] = new KeyBinding("key.open_gui", 37, "key.categories.misc"); ClientRegistry.registerKeyBinding(keyBindings[0]); Entities.registerRenders(); }
@Override protected void keyTyped(char typedChar, int keyCode) throws IOException { super.keyTyped(typedChar, keyCode); if (isKeyDown(KeyBindings.keyOpenWheel)) { closeThis(); } else if (keyCode == Keyboard.KEY_SPACE) { page++; if (page >= pages) { page = 0; } } else if ((typedChar >= 'a' && typedChar <= 'z') || (typedChar >= 'A' && typedChar <= 'Z')) { PlayerWheelConfiguration config = PlayerProperties.getWheelConfig(MinecraftTools.getPlayer(mc)); Map<String, Integer> hotkeys = config.getHotkeys(); List<String> actions = getActions(); for (String action : actions) { if (hotkeys.containsKey(action)) { if (hotkeys.get(action) == keyCode) { performAction(action); this.mc.displayGuiScreen(null); mc.setIngameFocus(); KeyBinding.unPressAllKeys(); return; } } } } }
@SubscribeEvent(priority = EventPriority.NORMAL, receiveCanceled = true) public void onEvent(KeyInputEvent event) { KeyBinding[] keyBindings = ClientProxy.keyBindings; if (keyBindings[0].isPressed()) { // TODO convert this to a toggle so that it opens and closes the gui NemesisSystem.NETWORK.sendToServer(new MessageOpenNemesisGuiRequest()); } }
@Override public boolean isMet() { for (KeyBinding kb : this.bindings) { if (!kb.isKeyDown()) { return false; } } return true; }
/** * Called when the mouse is clicked. Args : mouseX, mouseY, clickedButton */ protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException { if (this.buttonId != null) { this.options.setOptionKeyBinding(this.buttonId, -100 + mouseButton); this.buttonId = null; KeyBinding.resetKeyBindingArrayAndHash(); } else if (mouseButton != 0 || !this.keyBindingList.mouseClicked(mouseX, mouseY, mouseButton)) { super.mouseClicked(mouseX, mouseY, mouseButton); } }
/** * Fired when a key is typed (except F11 which toggles full screen). This is the equivalent of * KeyListener.keyTyped(KeyEvent e). Args : character (character on the key), keyCode (lwjgl Keyboard key code) */ protected void keyTyped(char typedChar, int keyCode) throws IOException { if (this.buttonId != null) { if (keyCode == 1) { this.options.setOptionKeyBinding(this.buttonId, 0); } else if (keyCode != 0) { this.options.setOptionKeyBinding(this.buttonId, keyCode); } else if (typedChar > 0) { this.options.setOptionKeyBinding(this.buttonId, typedChar + 256); } this.buttonId = null; this.time = Minecraft.getSystemTime(); KeyBinding.resetKeyBindingArrayAndHash(); } else { super.keyTyped(typedChar, keyCode); } }
public List<KeyBinding> lookupAll(int keyCode) { List<KeyBinding> matchingBindings = new ArrayList<KeyBinding>(); for (IntHashMap<Collection<KeyBinding>> bindingsMap : map.values()) { Collection<KeyBinding> bindings = bindingsMap.lookup(keyCode); if (bindings != null) { matchingBindings.addAll(bindings); } } return matchingBindings; }
public GuiKeyBindingList(GuiControls controls, Minecraft mcIn) { super(mcIn, controls.width, controls.height, 63, controls.height - 32, 20); this.field_148191_k = controls; this.mc = mcIn; KeyBinding[] akeybinding = (KeyBinding[])ArrayUtils.clone(mcIn.gameSettings.keyBindings); this.listEntries = new GuiListExtended.IGuiListEntry[akeybinding.length + KeyBinding.getKeybinds().size()]; Arrays.sort((Object[])akeybinding); int i = 0; String s = null; for (KeyBinding keybinding : akeybinding) { String s1 = keybinding.getKeyCategory(); if (!s1.equals(s)) { s = s1; this.listEntries[i++] = new GuiKeyBindingList.CategoryEntry(s1); } int j = mcIn.fontRendererObj.getStringWidth(I18n.format(keybinding.getKeyDescription(), new Object[0])); if (j > this.maxListLabelWidth) { this.maxListLabelWidth = j; } this.listEntries[i++] = new GuiKeyBindingList.KeyEntry(keybinding); } }
private KeyEntry(KeyBinding p_i45029_2_) { this.keybinding = p_i45029_2_; this.keyDesc = I18n.format(p_i45029_2_.getKeyDescription(), new Object[0]); this.btnChangeKeyBinding = new GuiButton(0, 0, 0, 75, 20, I18n.format(p_i45029_2_.getKeyDescription(), new Object[0])); this.btnReset = new GuiButton(0, 0, 0, 50, 20, I18n.format("controls.reset", new Object[0])); }
public void clearMap() { for (IntHashMap<Collection<KeyBinding>> bindings : map.values()) { bindings.clearMap(); } }
/** * Resets the player keystate, disables the ingame focus, and ungrabs the mouse cursor. */ public void setIngameNotInFocus() { if (this.inGameHasFocus) { KeyBinding.unPressAllKeys(); this.inGameHasFocus = false; this.mouseHelper.ungrabMouseCursor(); } }