minecraft-access icon indicating copy to clipboard operation
minecraft-access copied to clipboard

Mouse Simulation: Get rid of native mouse invocations

Open boholder opened this issue 1 year ago • 2 comments

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 MouseUtil with 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

boholder avatar Nov 12 '24 06:11 boholder

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)

boholder avatar Jan 19 '25 13:01 boholder

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.

boholder avatar Apr 01 '25 10:04 boholder