此模组修复了打开 GUI(图形用户界面)时偶尔出现的鼠标光标居中问题。例如,打开容器 GUI 后,光标未从中心出现,这在你需要快速从箱子或物品栏中取出物品时可能会造成危险。
自 Minecraft 26.3 起,原版游戏已切换至 SDL 后端,彻底解决了光标居中问题,因此本模组将不再更新到 26.2 以上的版本。
适用于 Wayland 用户
本模组支持使用 ydotool 或 wdotool 在 Wayland 下居中光标。要启用此功能,你需要正确配置它们,以下是基本设置步骤:
ydotool
1. 从源代码安装 ydotool
最新版本的 ydotool 提供了无缝的居中体验,但目前只能从源代码构建和安装。此工具仅在 XWayland 下有效。
要在任意目录下通过终端构建并安装它,请执行以下命令:
//安装命令可能因平台而异
sudo apt install git cmake scdoc
git clone https://github.com/ReimuNotMoe/ydotool.git
cd ydotool
mkdir build
cd build
cmake ..
make -j "$(nproc)"
sudo make install
运行 ydotoold -V 以验证安装是否成功。
2. 将你的用户添加到 sudo 例外列表
在 Minecraft 中使用 ydotool 成功居中光标的唯一方法是以 sudo 权限运行 ydotool 命令。因此,你需要使你的用户能够无需密码即可使用 sudo 运行 ydotool 命令:编辑 /etc/sudoers,添加两行:
<yourusername> ALL=(ALL) NOPASSWD:<ydotoold_path> //默认路径: /usr/local/bin/ydotoold
<yourusername> ALL=(ALL) NOPASSWD:<ydotool_path> //默认路径: /usr/local/bin/ydotool
wdotool
wdotool 是另一个很好的选择,该功能最近发布且正在积极开发中。它的配置要容易得多,你可以直接前往其 GitHub 页面查看详细配置指南。(注意:如果从源代码构建,还需要额外运行 sudo install -m 755 target/release/wdotool /usr/local/bin/wdotool)
配置完成后,你可以通过指定 JVM 参数 -DuseWdotool=<backend> 将此工具作为模组的后端使用,其中 <backend> 取决于你的 compositor。
指定移动缩放值(可选)
在 Wayland 下通过编程方式移动光标存在一个内部问题——实际移动的位置可能会受到某些系统值的影响,具体取决于你的桌面环境。换句话说,只有在默认鼠标灵敏度且禁用鼠标加速(在某些桌面环境中还需要默认 UI 缩放)的情况下,才能保证默认的居中位置是正确的。幸运的是,请求位置和实际位置似乎始终满足线性函数关系,因此我们可以使用一个 double 类型的因子来修正它。
要确定此值,请在安装此模组的情况下运行游戏并打开任何容器 GUI。模组将使用默认缩放值(1.0)居中光标,然后将光标保持在该位置,拿出你的尺子,将其放在显示器上测量其绝对位置,记录 x 或 y 为 x1 或 y1。接下来,保持游戏窗口的位置不变,确定实际的中心点,并用尺子测量其绝对位置,记录 x 或 y 为 x2 或 y2,那么缩放值应为 x2 / x1 或 y2 / y1。注意:游戏窗口最好较小(屏幕宽度/高度的一半即可)且靠近左上角,以确保光标不会移出屏幕,否则其位置不可靠(会被限制在屏幕边界内)。 这一步也可以通过截图并使用显示像素坐标的绘图软件来测量位置来完成,这样更准确。如有必要,你可以对数值进行四舍五入。
确定缩放值后,你可以重启游戏并添加 JVM 参数 -DcursorMoveScalingValue=<value> 以应用该值,只要你不更改系统鼠标灵敏度/加速度或 UI 缩放值,此值将始终正确。
已知问题
真正的 Wayland 窗口(非 XWayland)无法获取其在屏幕上的绝对位置,因此只有当游戏窗口的位置为 (0,0) 时,计算出的中心点才是正确的。
This mod fixes the cursor centering issue that occasionally happens when opening a GUI, e.g. open a container GUI but the cursor doesn't appear from the center which could be dangerous when you need to pull something from a chest or inventory rapidly.
Vanilla has shipped to SDL backend after 26.3 which completely resolved the cursor centering issues, so this mod will not be update to versions above 26.2.
For Wayland Users
This mod supports centering the cursor on wayland using ydotool or wdotool, to enable this feature, you need to configure them properly, here are the basic setup steps:
ydotool
1. Install ydotool from source
The latest version of ydotool provides seamless centering experience, however it can only be built and installed from source at the moment. This tool is only effective with XWayland.
To build an install it, just execute these commands in terminal under any directory:
//install command may vary on different platforms
sudo apt install git cmake scdoc
git clone https://github.com/ReimuNotMoe/ydotool.git
cd ydotool
mkdir build
cd build
cmake ..
make -j "$(nproc)"
sudo make install
Running ydotoold -V to verify your installation.
2. Add your user to sudo exceptions
The only way to successfully center the cursor using ydotool in Minecraft is running ydotool command with sudo privilege. Thus you need to make your user be able to run ydotool command with sudo without password: edit /etc/sudoers, add two lines:
<yourusername> ALL=(ALL) NOPASSWD:<ydotoold_path> //default path: /usr/local/bin/ydotoold
<yourusername> ALL=(ALL) NOPASSWD:<ydotool_path> //default path: /usr/local/bin/ydotool
wdotool
wdotool is another great option of the feature which was released recently and is being actively developed. It is much easier to configure and you can directly head to their github page for a detailed configuration guide. (Note that you need to run sudo install -m 755 target/release/wdotool /usr/local/bin/wdotool additionally if building from source)
Once configured, you can use this tool as the backend of the mod by specifying the JVM argument -DuseWdotool=<backend>, where <backend> is based on your compositor.
Specify a move scaling value (Optional)
There is an internal problem of moving cursor on wayland programmatically - the actual moved position may be affected by some system values depending on your desktop environment. In other words, the default centering position is guaranteed correct only with default mouse sensitivity and mouse acceleration disabled (also requires default UI scale in some desktop environments). Fortunately, the requested position and actual position seem to always satisfy a liner function relationship, so we can use a double factor to correct it.
To determine this value, run the game with this mod and open any container GUI, the mod will center the cursor using default scaling value (1.0), then keep your cursor at that position and take out your ruler, put it on your monitor to measure its absolute position, record x or y as x1 or y1. Next, keep the position of your game window and determine the actual central point, also measure its absolute position with your ruler, record x or y as x2 or y2, then the scaling value should be x2 / x1 or y2 / y1. Note that the game window is better to be small (1/2 screen width/height is ok) and close to top-left to ensure the cursor will not go outside the screen, or its position is not reliable (be constrained to screen border). This step can also be done by taking screenshots and measuring the position using a painting software that displays pixel coordinates, which is more accurate. You can round the value if necessary.
After determining the scaling value, you can restart the game with a JVM argument -DcursorMoveScalingValue=<value> to apply it, this value should be always correct util you change the system mouse sensitivity/acceleration or UI scaling value.
Known Issue
A real Wayland (not XWayland) window cannot get its absolute position on screen, therefore the calculated central point is only correct if the position of the game window is (0,0).
下载 CursorCentered Fix
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 CursorCentered Fix
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 CursorCentered Fix
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 CursorCentered Fix
下载 CursorCentered Fix
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 CursorCentered Fix
下载 CursorCentered Fix
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 CursorCentered Fix
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 CursorCentered Fix
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 CursorCentered Fix
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
Wayland:修复在多显示器环境下使用 wdotool 时坐标不正确的问题。
关于这个资源的讨论、问题反馈与使用心得
还没有讨论,来发第一帖吧
你是这个资源的作者?登录后可认领此资源。
相似资源
模组
显示你正在注视的方块的信息。(适用于 Minecraft 1.16+ 的 Hwyla/Waila 分支)
模组
查看物品与配方
模组
在游戏画面角落显示附近世界地形、玩家、生物和实体的地图。可创建路径点,帮助你找到标记过的位置。
模组
使用 JavaScript 编辑配方、添加自定义物品、编写世界事件!
模组
添加区块认领和玩家组队功能,并与 Xaero's Minimap 和 World Map 集成
模组
添加全屏世界地图,显示你在世界中已探索的区域。与 Xaero's Minimap 搭配使用效果极佳。
评论 0
登录后参与评分
还没有评论,来抢沙发吧