介绍
feat(tooltip): Implement conditional tooltip expansion with Shift key
This commit introduces a new client-side quality-of-life feature that
modifies how item tooltips are displayed in the game. When a player is
viewing an item’s tooltip, a placeholder message “Hold Shift for
details…” is shown by default. Pressing and holding the Shift key
reveals the full, complete tooltip, providing an organized and clean
inventory browsing experience.
Background / Problem:
- Tooltips in Minecraft can become excessively long, especially in modded environments where items often carry detailed descriptions, enchantment information, and mod-specific metadata.
- A cluttered tooltip obstructs the player’s view and makes inventory management cumbersome, as crucial information is always visible whether needed or not.
- There is currently no vanilla or standard Forge method to toggle tooltips or hide them behind a modifier key.
Implementation Details:
- Created a new event handler that listens to the
ItemTooltipEvent(Forge’s API event for tooltip construction). - When the event is triggered, the handler checks the state of the Shift key using
Screen.hasShiftDown()(client-side) to determine if the player is holding the key while hovering over the item. - If the key is pressed, the original, unmodified tooltip text list (List) is added to the tooltip, showing every line of information.
- If the key is not pressed, the default tooltip is cleared and replaced with a single-line component: “Hold Shift for details…”.
- The tooltip is automatically updated and re-rendered each time the player’s key state changes while the item is hovered over.
Changes in Behavior:
- Players can now quickly glance at an item without being overwhelmed by lengthy text.
- The full tooltip is instantly revealed when needed, without any additional keybinds or configuration menus.
- The placeholder text is localized and can be adapted or internationalized by future updates.
- This feature works on all items, including those from other mods, because it intercepts the tooltip event at a generic level.
Testing Performed:
- Verified on Forge 1.20.1 with both vanilla and modded items (e.g., items with enchantments, modded equipment).
- Confirmed that the Shift key detection works reliably in all game screens (inventory, creative menu, containers).
- Tested the responsiveness of the tooltip when the key is pressed, released, and pressed again while the mouse remains on the same item.
- Ensured compatibility with other mods that also modify
ItemTooltipEventthrough event priority adjustments.
Additional Notes:
- This mod is fully client-side and does not require any server-side installation.
- The
Screen.hasShiftDown()method is used overkeyBindSneakto accurately reflect GUI-related key presses without interfering with movement controls. - Future consideration: Adding a configurable keybind to toggle this behavior or customize the placeholder message.
Resolves: #ISSUE-42 (Replace with actual issue ticket number if applicable)
常见问题
Hidden description 支持哪些 Minecraft 版本?
Hidden description 支持 Minecraft Java 版 1.20.1–1.20.6,共 6 个版本,可用的加载器:Forge。下载时注意选择和你游戏版本一致的文件。
Hidden description 怎么安装?
先用 PCL2 或 HMCL 启动器安装对应版本的 Forge,再把下载的 .jar 文件放进游戏目录的 mods 文件夹,重新启动游戏即可。开启了版本隔离的,mods 文件夹在 versions/版本名 下面。运行环境:客户端和服务端都要装。
Kuzhizaizheli 的其他作品
查看全部 →Find me
Find Me 是一个用于存储、召唤和管理生物与载具的模组。
Starter Cabin
Starter Cabin is a Minecraft mod that lets you save a player-built structure and automatically place it near the spawn point of any new world.
Building Blueprint
Building Blueprint lets players save buildings as blueprint items, preview them in the world, rotate the preview, and place the saved structure later.
Inner voice
Inner Voice is a client‑side mod that displays floating, typewriter‑style “inner voice” text in the world when you fight or approach specified mobs, and can also assign custom BGM with synchronized lyrics/subtitles to each mob.
评论
登录后评论和评分