Repository navigation
fix: 侧键无效问题 - #194
Merged
Merged
fix: 侧键无效问题#194
Conversation
原版 runTick 本就把鼠标按钮喂进 KeyBinding(setKeyBindState/onTick 传的都是 -100 + 按钮号),世界里绑在侧键上的热键栏能切;但有两处只认 键盘: - ClickGUI 绑定捕获只喂键盘 raw key,prism 的 raw key 通道又丢掉负值 (鼠标码恰在负数区),侧键既进不了捕获,也没有对应的 EventKey 派发。 - 背包里悬停换位 / 丢弃 / 选取方块走 GuiContainer.keyTyped,这条路只有 键盘事件会进,按侧键什么都不动,数字键却正常。 新增 BindKeys 统一码约定:与原版 GuiControls 写进 options.txt 的 -100 + 按钮一致(显示名 MOUSE4/MOUSE5),含按住式判断。Minecraft 上新增 鼠标事件 mixin:界面外派 EventKey,容器内经 GuiContainerAccessor 把这次 按键按进 keyTyped;ScaledGuiScreen 把中键/侧键喂给绑定界面捕获(死屏 不喂,沿用缓冲卫生规则)。显示名、.bind/.shortcut 解析、缩放与自由视角 的按住绑定一并走该约定。左/右键不参与绑定,留给界面点击与攻击使用。
- BindKeys.isMouse 写成了 code <= -100,而鼠标码是 -100 + 按钮(-99..-93 全落在 键盘区):过桥拿到的负数被 prism 当「这一帧没按键」丢掉,ClickGUI 捕获永远收不到 侧键,绑定名也显示成 NONE。判定改为负数即鼠标码。 - 容器的按键派发挂在 runTick 的鼠标循环上,可界面打开时事件已被 handleInput 抽干、 逐个派给 handleMouseInput,那条循环收不到任何事件,背包里按侧键始终没反应。 改挂 GuiScreen.handleMouseInput(创客背包这类重写了它的屏也会 super 进来),把这次 按键按进 GuiContainer.keyTyped;取方块不补喂——原版 mouseClicked 自己认鼠标按钮, 补了会双踩。
非「物品栏」页悬停热键栏格按热键栏键(mode 2)时,原版 GuiContainerCreative 只给悬停格发 sendSlotPacket,换过去的目标热键栏格服务端仍是旧物品,放置时 露出原物品。侧键绑热键栏后容易撞上(数字键同样受影响)。在 handleMouseClick 末尾补发目标格。 顺带修正 FreeLook 按键判断处的缩进。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
包括clickgui无法绑定侧键为快捷键、背包内无法使用侧键