Minecraft VR 虚拟手势识别 API
玩 Vivecraft 或 QuestCraft?喜欢模组?是否曾希望模组能更好地兼容 VR?无需再等待。这是为开发者和玩家提供的解决方案!
此 API 允许 Minecraft 模组开发者轻松实现其模组的 VR 兼容性。创建可映射到任意键位绑定并触发事件的任何自定义手势。你不再需要将控制器按键绑定映射到键盘按键。使用此 API,你的身体就是控制器。
演示:
安装方法:
- 安装所需的依赖模组。注意 Questbind 仅在使用 QuestCraft 时需要。
- 下载 VR Jester API 模组并将其放入
mods文件夹中。 - 运行 Minecraft。必要的配置文件将在初始化时自动生成。
使用方法:
-
在 Minecraft VR 中,将控制器的一个按钮绑定到“手势监听器触发器”(Gesture Listener Trigger)。建议使用握持按钮(Grip Button)。对于 Vivecraft,你必须通过 Steam VR 的控制器绑定菜单进行设置;对于 QuestCraft,则通过 QuestBind 进行设置。
-
有两种创建手势的方式:
- 使用
/gesture命令 - 直接修改存储手势的
config/gesture_store.json文件。
示例手势存储配置:
"GESTURE 1": { "RIGHT_CONTROLLER|LEFT_CONTROLLER": [ { "vrDevice": "RIGHT_CONTROLLER|LEFT_CONTROLLER", "movement": "forward", "elapsedTime": 0, "speed": 0.0, "direction": { "x": 0.0, "y": 0.0, "z": 0.0 }, "devicesInProximity": {} } ] }, ... - 使用
-
创建好手势后,你可以在
config/VRJesterAPI.cfg中的 "GESTURE_KEY_MAPPINGS" 字段下创建键值对象,将它们映射到键位绑定。你可以在.minecraft/options.txt中找到键位绑定的名称。(注意:该文件中单个键位绑定的实际 KeyMapping 字符串位于 key_ 和冒号之间。例如:key_key.inventory:18) "KEY_ACTION" 字段用于确定识别出的手势是触发单次 点击 按键按下还是 按住 按键按下。当你在手势被识别后保持手势位置不动时,会触发 按住 效果。
"GESTURE_KEY_MAPPINGS": {
"GESTURE 1": {
"KEY_MAPPING": "examplemod.key.ability_1",
"KEY_ACTION": "click"
},
"GESTURE 2": {
"KEY_MAPPING": "key.hotbar.2,key.sneak",
"KEY_ACTION": "hold"
},
"GESTURE 3": {
"KEY_MAPPING": "key.keyboard.j",
"KEY_ACTION": "click"
}
}
下载:
信息:
- 将方括号 [ ] 内的每个对象视为手势的一个片段。你可以添加多个 GestureComponent 对象。此 API 支持识别复杂程度由你决定的手势!只需知道,手势越复杂,正确执行以匹配存储的手势就越困难。
- "movement" 的不同取值为
forward(前)、back(后)、left(左)、right(右)、up(上)、down(下)。移动方向相对于你按下 Jester Trigger 启动手势监听器时的朝向。简单的例子是:朝你面对的方向出拳会被识别为“forward”。 - "vrDevice" 的不同取值为
RIGHT_CONTROLLER、LEFT_CONTROLLER、HEAD_MOUNTED_DISPLAY。如果你希望手势在多个 VR 设备上都被识别,可以使用管道符|表示逻辑或,例如RIGHT_CONTROLLER|LEFT_CONTROLLER|HEAD_MOUNTED_DISPLAY。 - "elapsedTime" 的单位是毫秒。因此,设置值为
2000意味着该手势片段持续 2 秒。这非常适合类似蓄力攻击的动作。 - "speed" 字段是一个浮点数值,代表该 GestureComponent 的速度。识别出拳速度的合理阈值约为
1500.0-2000.0,你可以随意调整这些值。 - "direction" 字段接受
x,y,z浮点数值以创建一个三维归一化向量。例如,使用{0.0, 1.0, 0.0}可以识别玩家砖手(brick hand)朝上的情况。存在一定容差范围,因此不需要完全精确。 - 最后是 "devicesInProximity",其格式如下:
这个示例的含义是:该 GestureComponent 的 vrDevice 必须在左侧控制器附近持续 20 刻(ticks)。"devicesInProximity": { "LEFT_CONTROLLER": 20 } - 订阅事件总线以处理由识别出的手势触发的事件(Forge),或者注册事件回调接口(Fabric)。
Forge:
@SubscribeEvent
public void onGestureEvent(GestureEvent event) {
// 此处编写手势处理代码 -> event.getGestureName()
}
Fabric:
public static void init() {
GestureEventCallback.EVENT.register((gestureEvent) -> {
// 此处编写手势处理代码 -> gestureEvent.getGestureName()
});
}
计划功能:
未来我将添加连续手势识别、更多配置选项以及性能优化。
2025年3月27日更新 - 我知道有一段时间没有更新了,但我完全打算回归这个模组。我一直在忙于其他项目。为此带来的不便表示歉意。
Virtual Reality Gesture Recognition API for Minecraft VR
Play Vivecraft or QuestCraft? Love mods? Ever wish mods were more VR compatible? Wait no further. This is a solution for devs and players alike!
This API enables Minecraft mod developers to easily implement support for their mod to be more VR compatible. Create any custom gestures that map to any key binds and trigger events. No longer do you need to map controller keybindings to keyboard keys. With this API, your body is the controller.
Demos:
Installation:
- Install required dependency mods. Note that Questbind is only required for QuestCraft usage.
- Download the VR Jester API mod & place it in the
modsfolder. - Run Minecraft. Necessary config files will generate on initialization.
Usage:
- While in Minecraft VR, bind one of your controller buttons to the "Gesture Listener Trigger". I recommend a grip button. For Vivecraft you must do this through Steam VR's controller bindings menu. For QuestCraft you do this through QuestBind.
- These are 2 ways to create gestures:
- Using the
/gesturecommand - Modifying the
config/gesture_store.jsondirectly where gestures are stored. Sample gesture store:
"GESTURE 1": { "RIGHT_CONTROLLER|LEFT_CONTROLLER": [ { "vrDevice": "RIGHT_CONTROLLER|LEFT_CONTROLLER", "movement": "forward", "elapsedTime": 0, "speed": 0.0, "direction": { "x": 0.0, "y": 0.0, "z": 0.0 }, "devicesInProximity": {} } ] }, ... - Using the
- Once your gestures are created, you can map them to key binds in
config/VRJesterAPI.cfgby creating key value objects under the field "GESTURE_KEY_MAPPINGS". You can find the key bind names in.minecraft/options.txt. (Note: The actual KeyMapping string of an individual key bind in that file is in between the key_ and colon. i.e.: key_key.inventory:18) The "KEY_ACTION" field determines whether the recognized gesture triggers a single click key press or a hold down key press. A hold is triggered when you keep your gesture in place after it's recognized.
"GESTURE_KEY_MAPPINGS": {
"GESTURE 1": {
"KEY_MAPPING": "examplemod.key.ability_1",
"KEY_ACTION": "click"
},
"GESTURE 2": {
"KEY_MAPPING": "key.hotbar.2,key.sneak",
"KEY_ACTION": "hold"
},
"GESTURE 3": {
"KEY_MAPPING": "key.keyboard.j",
"KEY_ACTION": "click"
}
}
Download:
Info:
- Consider each object within the square brackets [ ] a mere piece of the gesture. You can add multiple of these GestureComponent objects. This API recognizes gestures as complex as you want! Just know the more conplex, the more difficult it is to perform a gesture correctly to match your stored gesture.
- Different values for "movement" are
forward, back, left, right, up, down. The movement direction is relative to your facing direction at the moment you click the Jester Trigger which initiates the gesture listener. Simple example is punching in the same direction you're facing would be recognized as "forward". - Different values for "vrDevice" are
RIGHT_CONTROLLER, LEFT_CONTROLLER, HEAD_MOUNTED_DISPLAYand if you want a gesture recognized on multiple VR devices you can incorporate a 'logical or' using a pipe|like soRIGHT_CONTROLLER|LEFT_CONTROLLER|HEAD_MOUNTED_DISPLAY - The "elapsedTime" is in milliseconds. So putting a value of
2000would mean that part of the gesture lasts 2 seconds. This would be good for a charge up sort of move. - The "speed" field is a float value representing the velocity of that GestureComponent. A decent threshold to recognize the speed of a punch would be
1500.0-2000.0and feel free to play around with the values as much as you want. - The "direction" field takes
x,y,zfloat values that create a 3D normalized vector. Example usage of this would be having{0.0, 1.0, 0.0}to recognize when the player's brick hand is facing upwards. There's a certain threshold so it doesn't have to be exact. - Finally there's "devicesInProximity" which is formatted like so:
What this example means is that the vrDevice of this GestureComponent has to be within proximity of the left controller for 20 ticks."devicesInProximity": { "LEFT_CONTROLLER": 20 } - Subscribe to the event bus to handle events triggered by a recognized gesture (Forge) or register to the event callback interface (Fabric).
Forge:
@SubscribeEvent
public void onGestureEvent(GestureEvent event) {
// gesture handler code here -> event.getGestureName()
}
Fabric:
public static void init() {
GestureEventCallback.EVENT.register((gestureEvent) -> {
// gesture handler code here -> gestureEvent.getGestureName()
});
}
Planned:
In the future I'll add continous gesture recognition, more configuration options, and optimizations.
Update 3/27/2025 - I know I haven't updated in a while, but I fully intend to come back to this mod. I've been working on other projects. Apologies for the inconvenience.
下载 VR Jester API
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 VR Jester API
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 VR Jester API
下载 VR Jester API
下载 VR Jester API
下载 VR Jester API
下载 VR Jester API
下载 VR Jester API
下载 VR Jester API
下载 VR Jester API
暂无更新日志
关于这个资源的讨论、问题反馈与使用心得
还没有讨论,来发第一帖吧
你是这个资源的作者?登录后可认领此资源。
相似资源
模组
一个用于收集生物掉落物的多区块模组。
模组
显示你正在注视的方块的信息。(适用于 Minecraft 1.16+ 的 Hwyla/Waila 分支)
模组
查看物品与配方
模组
在游戏画面角落显示附近世界地形、玩家、生物和实体的地图。可创建路径点,帮助你找到标记过的位置。
模组
使用 JavaScript 编辑配方、添加自定义物品、编写世界事件!
模组
适用于 MC 1.18+ 的 Effekseer 加载器
评论 0
登录后参与评分
还没有评论,来抢沙发吧