
xoombie
Members-
Content Count
4 -
Joined
-
Last visited
Community Reputation
1 NeutralAbout xoombie
-
Rank
Tree Puncher
-
Got it working. Thanks for clearing up some confusion for this noob. In case anyone else finds it useful, the SRG names are the cryptic kind, eg func_189810_i The dev environment will also accept human-friendly MCP names as ObfuscationReflectionHelper arguments, eg updateAutoJump The runtime-only environment (ie, during normal use) only works if ObfuscationReflectionHelper has SRG name arguments. My working code now looks like: this.updateAutoJump = ObfuscationReflectionHelper.findMethod(ClientPlayerEntity.class, "func_189810_i", // func_189810_i = updateAutoJump float.class, float.class); this.mouseButtonSimulate = ObfuscationReflectionHelper.findMethod(MouseHelper.class, "func_198023_a", // func_198023_a = mouseButtonCallback long.class, int.class, int.class, int.class); Useful links: MCP, environments and naming Tool for looking up SRG names
-
-
On 1.15.2 - 31.2.0 mod runs fine in dev environment, but fails at the first of the following lines during common_setup event phase. If the first line is omitted, it fails on the second, indicating a general problem with symbol lookup in the runtime only environment: this.updateAutoJump = ObfuscationReflectionHelper.findMethod(ClientPlayerEntity.class, "updateAutoJump", float.class, float.class); this.mouseButtonSimulate = ObfuscationReflectionHelper.findMethod(MouseHelper.class, "mouseButtonCallback", long.class, int.class, int.class, int.class); The relevant part of build.gradle: minecraft { [...] mappings channel: 'snapshot', version: '20201216-1.15.1' //mappings channel: 'snapshot', version: '20200514-1.15.1' // also doesn't work [...] } Has anyone else encountered this problem? Have researched for a day now, and just cannot see why the SRG names are not being consistently handled by ObfuscationReflectionHelper Any help greatly appreciated
-
Was a noob mistake. The coordinates used by GLFW for cursor positioning are display pixels, whereas mc renders to a multiple. What worked was: double s = mc.getMainWindow().getGuiScaleFactor(); mc.currentScreen.mouseClicked(x/s, y/s, 0); // 0 is code for left button MinecraftForge.EVENT_BUS.post(new GuiScreenEvent.MouseClickedEvent.Pre(mc.currentScreen, x/s, y/s, 0)); // share event with any mouse handlers (optional) Hope this helps anyone doing something similar
-
On 1.15.2, trying to simulate mouse clicks for a mod for a custom hardware input device. Mouse pointer movement works fine, using GLFW.glfwSetCursorPos() However, none of extensive attempts to simulate a mouse click has worked so far. One way is to use java.awt.Robot, but the mod sees itself in a headless environment, where Robot cannot function. (it appears others have successfully used this, but perhaps on old mc versions? is 1.15.2 fundamentally different in this respect?). Other attempts include: MinecraftForge.EVENT_BUS.post(new GuiScreenEvent.MouseClickedEvent.Pre(screen, x, y, GLFW.GLFW_MOUSE_BUTTON_1)); Because these mouse clicks are for GUIs, not the main game (click events in the game itself can be simulated by activating a keybinding). Many many hours lost through this so far, any ideas greatly appreciated. Am new to Minecraft modding, although very familiar with java.