Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-261980

Opening the inventory quickly doesn't make the cursor centered sometimes

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • None
    • 1.19.4
    • None
    • Unconfirmed
    • (Unassigned)

      The bug:

      Opening the inventory and moving your cursor quickly sometimes doesn't make the cursor centered. Since this bug is very unpredictable it can really screw you up when you need to replace your popped Totem of Undying extremely quickly while you're PvPing someone.

       

      Steps to reproduce :

      I couldn't reproduce this bug since I don't really understand it, so I asked a mod developer who already fixed the bug for a mod about how to reproduce it. This is what he told me:

      A stable trigger method of the bug: the game window lost its focus without any GUI opening, when it gains the focus again then open a GUI, the cursor will appear from where it was when the window gained the focus. Theoretically, if the cursor can move without a GUI opening, after locking the cursor again(by game input system) and then opening a GUI, the cursor will appear from where it was locked. This may occasionally happen when there is a "tick events traffic".

      In fact, it seems the bug turns out to be a mistake made by GLFW's documentation - the Javadoc of method GLFW.glfwSetCursorPos() says it will only work when the cursor mode is CURSOR_DISABLED, but according to my experiments, this method actually only takes effect when the cursor mode is CURSOR_RELEASED. The Minecraft does try to center the cursor when opening a GUI, but when GLFW.glfwSetCursorPos() method is invoked by MC the cursor mode is CURSOR_DISABLED, so this action actually fails all the time. This mod just manually set the cursor mode to CURSOR_RELEASED before the invocation of Minecraft's cursor centering method.

       

      Intended behavior:

      The cursor should always be in the middle-uppermost slot when you open your inventory.

       

      Actual behavior:

      The cursor appears in a random spot in your inventory when you open your own inventory.

            Unassigned Unassigned
            Fusion035 Fusion Fusion
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: