net.minecraft.client.util.InputMappings Java Examples
The following examples show how to use
net.minecraft.client.util.InputMappings.
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: ClientSettings.java From Better-Sprinting with Mozilla Public License 2.0 | 6 votes |
public static void firstTimeSetup(){ GameSettings settings = Minecraft.getInstance().gameSettings; keyInfoSprintHold.readFrom(settings.keyBindSprint); KeyModifier sprintModifier = getVanillaKeyModifier(settings.keyBindSprint); KeyModifier sneakModifier = getVanillaKeyModifier(settings.keyBindSneak); if (sprintModifier != KeyModifier.NONE){ keyInfoSprintToggle.set(sprintModifier, InputMappings.Type.KEYSYM.getOrMakeInput(GLFW.GLFW_KEY_G)); } if (sneakModifier != KeyModifier.NONE){ keyInfoSneakToggle.set(sneakModifier, InputMappings.Type.KEYSYM.getOrMakeInput(GLFW.GLFW_KEY_G)); } BetterSprintingMod.config.save(); }
Example #2
Source File: GuiSprint.java From Better-Sprinting with Mozilla Public License 2.0 | 6 votes |
@Override public boolean keyPressed(int keyCode, int scanCode, int modifiers){ if (selectedBinding != null){ if (keyCode == GLFW.GLFW_KEY_ESCAPE){ selectedBinding.setBinding(KeyModifier.NONE, InputMappings.INPUT_INVALID); } else{ selectedBinding.setBinding(KeyModifier.getActiveModifier(), InputMappings.getInputByCode(keyCode, scanCode)); } onSelectedBindingUpdated(); return true; } else{ return super.keyPressed(keyCode, scanCode, modifiers); } }
Example #3
Source File: MiningVisualsScreen.java From MiningGadgets with MIT License | 5 votes |
@Override public boolean keyPressed(int p_keyPressed_1_, int p_keyPressed_2_, int p_keyPressed_3_) { InputMappings.Input mouseKey = InputMappings.getInputByCode(p_keyPressed_1_, p_keyPressed_2_); if (p_keyPressed_1_ == 256 || minecraft.gameSettings.keyBindInventory.isActiveAndMatches(mouseKey)) { onClose(); return true; } return super.keyPressed(p_keyPressed_1_, p_keyPressed_2_, p_keyPressed_3_); }
Example #4
Source File: MiningSettingScreen.java From MiningGadgets with MIT License | 5 votes |
@Override public boolean keyPressed(int p_keyPressed_1_, int p_keyPressed_2_, int p_keyPressed_3_) { InputMappings.Input mouseKey = InputMappings.getInputByCode(p_keyPressed_1_, p_keyPressed_2_); if (p_keyPressed_1_ == 256 || minecraft.gameSettings.keyBindInventory.isActiveAndMatches(mouseKey)) { onClose(); return true; } return super.keyPressed(p_keyPressed_1_, p_keyPressed_2_, p_keyPressed_3_); }
Example #5
Source File: MiningGadget.java From MiningGadgets with MIT License | 5 votes |
@Override public void addInformation(ItemStack stack, @Nullable World world, List<ITextComponent> tooltip, ITooltipFlag flag) { super.addInformation(stack, world, tooltip, flag); List<Upgrade> upgrades = UpgradeTools.getUpgrades(stack); Minecraft mc = Minecraft.getInstance(); if (!InputMappings.isKeyDown(mc.getMainWindow().getHandle(), mc.gameSettings.keyBindSneak.getKey().getKeyCode())) { tooltip.add(new TranslationTextComponent("mininggadgets.tooltip.item.show_upgrades", mc.gameSettings.keyBindSneak.getLocalizedName().toLowerCase()) .applyTextStyle(TextFormatting.GRAY)); } else { tooltip.add(new TranslationTextComponent("mininggadgets.tooltip.item.break_cost", getEnergyCost(stack)).applyTextStyle(TextFormatting.RED)); if (!(upgrades.isEmpty())) { tooltip.add(new TranslationTextComponent("mininggadgets.tooltip.item.upgrades").applyTextStyle(TextFormatting.AQUA)); for (Upgrade upgrade : upgrades) { tooltip.add(new StringTextComponent(" - " + I18n.format(upgrade.getLocal()) ).applyTextStyle(TextFormatting.GRAY)); } } } stack.getCapability(CapabilityEnergy.ENERGY, null) .ifPresent(energy -> tooltip.add( new TranslationTextComponent("mininggadgets.gadget.energy", MagicHelpers.tidyValue(energy.getEnergyStored()), MagicHelpers.tidyValue(energy.getMaxEnergyStored())).applyTextStyles(TextFormatting.GREEN))); }
Example #6
Source File: ClientSettings.java From Better-Sprinting with Mozilla Public License 2.0 | 5 votes |
private static KeyModifier getVanillaKeyModifier(KeyBinding binding){ if (binding.getKeyModifier() != KeyModifier.NONE || binding.getKey().getType() != InputMappings.Type.KEYSYM){ return KeyModifier.NONE; } switch(binding.getKey().getKeyCode()){ case GLFW.GLFW_KEY_LEFT_CONTROL: return KeyModifier.CONTROL; case GLFW.GLFW_KEY_LEFT_SHIFT: return KeyModifier.SHIFT; case GLFW.GLFW_KEY_LEFT_ALT: return KeyModifier.ALT; default: return KeyModifier.NONE; } }
Example #7
Source File: GuiSprint.java From Better-Sprinting with Mozilla Public License 2.0 | 5 votes |
@Override public boolean mouseClicked(double mouseX, double mouseY, int button){ if (super.mouseClicked(mouseX, mouseY, button)){ return true; } else if (selectedBinding != null){ selectedBinding.setBinding(InputMappings.Type.MOUSE.getOrMakeInput(button)); onSelectedBindingUpdated(); return true; } return false; }
Example #8
Source File: GuiSprint.java From Better-Sprinting with Mozilla Public License 2.0 | 5 votes |
@Override public boolean keyReleased(int keyCode, int scanCode, int modifiers){ if (selectedBinding != null){ selectedBinding.setBinding(KeyModifier.NONE, InputMappings.getInputByCode(keyCode, scanCode)); onSelectedBindingUpdated(); return true; } else{ return super.keyReleased(keyCode, scanCode, modifiers); } }
Example #9
Source File: KeyListener.java From BoundingBoxOutlineReloaded with MIT License | 5 votes |
public static Key register(String description, String keyName) { InputMappings.Input input = InputMappings.getInputByName(keyName); CustomKeyBinding keyBinding = new CustomKeyBinding(description, input.getKeyCode()); keyBindings.add(keyBinding); Key key = keyBinding.getKey(); keys.add(key); return key; }
Example #10
Source File: KeyListener.java From BoundingBoxOutlineReloaded with MIT License | 5 votes |
private static void onKeyEvent(long windowHandle, int keyCode, int scanCode, int action, int modifiers) { boolean isPressed = action > 0; if (windowHandle == mainWindowHandle && minecraft.currentScreen == null && keyCode != -1 && !InputMappings.isKeyDown(mainWindowHandle, 292) && handleKeyEvent(keyCode, isPressed)) return; minecraft.keyboardListener.onKeyEvent(windowHandle, keyCode, scanCode, action, modifiers); }
Example #11
Source File: KeyBindingInfo.java From Better-Sprinting with Mozilla Public License 2.0 | 4 votes |
public KeyBindingInfo(IntValue keyCode, EnumValue<KeyModifier> keyModifier, EnumValue<InputMappings.Type> keyType){ this.keyCode = keyCode; this.keyModifier = keyModifier; this.keyType = keyType; }
Example #12
Source File: KeyBindingInfo.java From Better-Sprinting with Mozilla Public License 2.0 | 4 votes |
public void set(KeyModifier modifier, InputMappings.Input input){ BetterSprintingMod.config.set(keyCode, input.getKeyCode()); BetterSprintingMod.config.set(keyModifier, modifier); BetterSprintingMod.config.set(keyType, input.getType()); }
Example #13
Source File: GuiButtonInputBinding.java From Better-Sprinting with Mozilla Public License 2.0 | 4 votes |
public void setBinding(InputMappings.Input input){ binding.bind(input); isSelected = false; }
Example #14
Source File: GuiButtonInputBinding.java From Better-Sprinting with Mozilla Public License 2.0 | 4 votes |
public void setBinding(KeyModifier modifier, InputMappings.Input input){ binding.setKeyModifierAndCode(modifier, input); isSelected &= KeyModifier.isKeyCodeModifier(input) && modifier != KeyModifier.NONE; }
Example #15
Source File: Key.java From BoundingBoxOutlineReloaded with MIT License | 4 votes |
public Key register(String keyName) { InputMappings.Input input = InputMappings.getInputByName(keyName); Key key = new Key(input.getKeyCode()); subKeys.add(key); return key; }
Example #16
Source File: CustomKeyBinding.java From BoundingBoxOutlineReloaded with MIT License | 4 votes |
@Override public void bind(InputMappings.Input input) { super.bind(input); int keyCode = input.getKeyCode(); key.updateKeyCode(keyCode); }