/** * Get the character representation of the key identified by the specified code * * @param code The key code of the key to retrieve the name of * @return The name or character representation of the key requested */ public static String getKeyName(int code) { return Keyboard.getKeyName(code); }
public static String getKeyName(int key) { if (key < 0) { return I18n.translateToLocalFormatted("key.mouseButton", key + 101); } else if (key > Keyboard.KEYBOARD_SIZE) { return Keyboard.getKeyName(0); } return Keyboard.getKeyName(key); }
public static String[] toConfig() { List<String> list = new ArrayList<>(); for (Map.Entry<Integer, Set<EditMode>> entry : keyMap.entrySet()) for (EditMode mode : entry.getValue()) list.add(Keyboard.getKeyName(entry.getKey()) + ":" + mode.name().toLowerCase()); return list.toArray(new String[list.size()]); }
/** * @param keyBindingIndex the index in <code>ZyinHUDKeyHandlers.KEY_BINDINGS[]</code> * @return hotkey as a string */ private String GetKeyBindingAsString(int keyBindingIndex) { try { return Keyboard.getKeyName(ZyinHUDKeyHandlers.KEY_BINDINGS[keyBindingIndex].getKeyCode()); } catch (ArrayIndexOutOfBoundsException e) { return "[?]"; //A user reported having getKeyCode() returning -89 and causing this exception } }
public static String getKeyName(KeyBinding k) { int keyCode = k.getKeyCode(); if (keyCode > Keyboard.getKeyCount() || keyCode < 0) { return "INVALID KEY"; } return Keyboard.getKeyName(keyCode); } }
/** * Get the key name this PEKeybind is bound to. */ public static String getKeyName(PEKeybind k) { int keyCode = peToMc.get(k).getKeyCode(); if (keyCode > Keyboard.getKeyCount() || keyCode < 0) { return "INVALID KEY"; } return Keyboard.getKeyName(keyCode); }
@Override @SideOnly(Side.CLIENT) public void addInformation(ItemStack stack, @Nullable World worldIn, List<String> list, ITooltipFlag flag) { if (canFly()) { list.add(new TextComponentTranslation("tooltip.erebus.poweredglider").getFormattedText()); list.add(new TextComponentTranslation("tooltip.erebus.gliderpoweredkey").getFormattedText() + ": " + Keyboard.getKeyName(KeyBindingHandler.POWERED_GLIDE.getKeyCode())); } list.add(new TextComponentTranslation("tooltip.erebus.gliderglidekey").getFormattedText() + ": " + Keyboard.getKeyName(KeyBindingHandler.GLIDE.getKeyCode())); }
public String getDetails(int level) { String key = "Unknown"; try { key = Keyboard.getKeyName(ClientProxy.keyHandler.getBinding(KeyHandler.ABILITY_USE_KEY).getKeyCode()); } catch (Exception ignored) { } return MOStringHelper.translateToLocal(getUnlocalizedDetails(), key); }
/** * Searches Minecraft's key bindings to get the hotkey based on the hotkey description, then caches the result for future use. * @return String representation of the hotkey, e.x. "K", "LMENU" */ public String GetHotkey() { if(hotkey == null) { //get key binding in Minecraft KeyBinding keyBinding = FindKeyBinding(GetHotkeyDescription()); if(keyBinding != null) { SetHotkey(hotkey); return Keyboard.getKeyName(keyBinding.getKeyCode()); } else { return "?"; } } else return hotkey; }
/** * Called when a key is pressed on the GuiZyinHUDOptions screen. * Updates Minecraft's keybinding. * @param newHotkey e.x. 37 (K), 1 (Esc), 55 (*) */ public void ApplyHotkey(int newHotkey) { waitingForHotkeyInput = false; hotkey = Keyboard.getKeyName(newHotkey); //SetHotkey(hotkey); UpdateDisplayString(); //update key binding in Minecraft KeyBinding keyBinding = FindKeyBinding(GetHotkeyDescription()); if(keyBinding != null) { keyBinding.setKeyCode(newHotkey); KeyBinding.resetKeyBindingArrayAndHash(); } }
@Override public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { if(!playerIn.isSneaking()) { if(SeatUtil.sitOnBlockWithRotationOffset(worldIn, pos.getX(), pos.getY(), pos.getZ(), playerIn, 0.4D, getMetaFromState(state), 0.1D)) { if(worldIn.isRemote) { String key = new TextComponentTranslation("cfm.message.toilet", Keyboard.getKeyName(InputHandler.KEY_FART.getKeyCode())).getUnformattedComponentText(); playerIn.sendMessage(new TextComponentString(TextFormatting.YELLOW + key)); } worldIn.updateComparatorOutputLevel(pos, this); } } else { List<EntityItem> items = worldIn.getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(pos.getX(), pos.getY(), pos.getZ(), pos.getX() + 1.0D, pos.getY() + 1.0D, pos.getZ() + 1.0D).grow(1D)); for(EntityItem item : items) { item.setDead(); } worldIn.playSound(pos.getX() + 0.5D, pos.getY() + 0.5D, pos.getZ() + 0.5D, FurnitureSounds.flush, SoundCategory.BLOCKS, 0.75F, 1.0F, false); } return true; }
p.comment = "The format used when sending your coordiantes in a chat message by pressing '" + Keyboard.getKeyName(ZyinHUDKeyHandlers.KEY_BINDINGS[1].getKeyCode()) + "'. {x}{y}{z} are replaced with actual coordiantes."; if(loadSettings) Coordinates.ChatStringFormat = p.getString(); + Keyboard.getKeyName(ZyinHUDKeyHandlers.KEY_BINDINGS[8].getKeyCode())+" and + + " + Keyboard.getKeyName(ZyinHUDKeyHandlers.KEY_BINDINGS[8].getKeyCode())+"."; if(loadSettings) SafeOverlay.instance.SetDrawDistance(p.getInt(20)); p.comment = "Enable/Disable showing unsafe areas through walls. Toggle in game with Ctrl + "+Keyboard.getKeyName(ZyinHUDKeyHandlers.KEY_BINDINGS[8].getKeyCode())+"."; if(loadSettings) SafeOverlay.instance.SetSeeUnsafePositionsThroughWalls(p.getBoolean(false)); p.comment = "Enables pressing " + Keyboard.getKeyName(ZyinHUDKeyHandlers.KEY_BINDINGS[3].getKeyCode()) + " to eat food even if it is in your inventory and not your hotbar."; if(loadSettings) p.comment = "Enables pressing " + Keyboard.getKeyName(ZyinHUDKeyHandlers.KEY_BINDINGS[9].getKeyCode()) + " to swap between your sword and bow."; if(loadSettings) p.comment = "Enables pressing " + Keyboard.getKeyName(ZyinHUDKeyHandlers.KEY_BINDINGS[4].getKeyCode()) + " to use an enderpearl even if it is in your inventory and not your hotbar."; if(loadSettings) p.comment = "Enables pressing " + Keyboard.getKeyName(ZyinHUDKeyHandlers.KEY_BINDINGS[6].getKeyCode()) + " to drink a potion even if it is in your inventory and not your hotbar."; if(loadSettings)