Mouse Simulation: Get rid of native mouse invocations
Related closed issue: #39 #22, if this issue can be finished, the #374 can also be resolved.
- [ ] find a way to modify the coordinates that game thinks mouse is.
- [ ] make an API for retrieving in-bound coordinates of given GUI component.
- [x] replace
MouseUtilwith new system. - [ ] update doc about native mouse API
PR 1: make mouse mock works, replace Mouse Simulation feature with the new way.
PR 2: make GUI monk works but not replace whole MouseUtil, just replace one use case for each util method.
PR 3: replace the rest and update doc
This mod has achieved mouse simulation: https://github.com/isXander/Controlify
For GUI mouse event handler, see Element.mouse*.
The button can be clicked with
@Override
public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
if (keyCode == GLFW.GLFW_KEY_SPACE || keyCode == GLFW.GLFW_KEY_ENTER || keyCode == GLFW.GLFW_KEY_KP_ENTER) {
this.mouseClicked(this.rectangle.x + 1, this.rectangle.y + 1, 0);
return true;
}
return false;
}
Root method: GuiEventListener.mouseClicked(double mouseX, double mouseY, int button)
Inventory Screens inherit from AbstractContainerScreen, save their slots into menu.slots, and that saves all slots on the screen, doesn't care about position. I think we need to keep Shoaib's slot group since the vanilla code doesn't have this layer of abstraction but we need it. If I refactor current Inventory Controls code, the best thing I can get is making underlying data structure which represents relationship between slots simpler.