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

Statistics sprites don't look pressed when clicked



    • Bug
    • Resolution: Unresolved
    • None
    • 1.16.3, 1.16.4, 20w46a, 20w48a, 20w49a, 20w51a, 21w03a, 1.16.5, 21w05a, 21w05b, 21w06a, 21w07a, 21w08b, 21w10a, 21w11a, 21w13a, 21w14a, 21w15a, 21w16a, 21w18a, 21w19a, 21w20a, 1.17, 1.17.1, 21w41a, 21w42a, 21w43a, 21w44a, 1.18 Pre-release 1, 1.18 Pre-release 4, 1.18 Pre-release 5, 1.18 Pre-release 6, 1.18 Pre-release 7, 1.18 Release Candidate 2, 1.18, 1.18.1, 22w06a, 22w07a, 1.18.2 Pre-release 1, 1.18.2 Pre-release 3, 1.18.2, 22w11a, 22w12a, 1.19, 1.19.2, 1.19.3 Pre-release 2, 1.19.3
    • None
    • Confirmed
    • UI


      The bug

      Since 1.13, when opening Pause Menu->Statistics->Items, when you click at one of the header sprites, it does not change its look to its "pressed" state.

      How to reproduce

      1. Open the statistics screen.
      2. Open items and click an item in the header to change the ordering
         The sprite doesn't look pressed

      Code analysis:

      This is caused because the mouse handler has a cached check (see: net.minecraft.client.MouseHandler.java, field isLeftPressed) that is set to false when a screen says that a component is clicked (if mouseClicked/mouseReleased returns true at method onPress). When the statistics' screen 'list header' is clicked mouseClicked always returns true (see: net.minecraft.gui.components.AbstractSelectionList.java, method mouseClicked) causes the MouseHandler's _isLeftPressed not setting to true under this condition (it also affects other checks such as isMiddlePressed and isRightPressed, but they don't seem to be used on any part of the client code). Another problem is that for those cached checks to be updated there must be no screen opened or for it having the passEvents field set to true, wich in fact makes isLeftPressed never changing its value to true when clicking the statistic sprite.
      When rendering these sprites (see: StatsScreen.ItemStatisticsList, method renderHeader), the code checks if MouseHandler.isLeftPressed is true to render the pressed sprite, which in fact is always false, and thus the 'pressed' sprite is never rendered.

      Possible fixes:

      Fixing MouseHandler's isLeftPressed check

      As said in the code analysis, the isLeftPressed check can't be set to true due to the mouseClicked/mouseReleased check and the screen passEvents.
      Changing the isLeftPressed, isMiddlePressed, and isRightPressed checks so they won't be affected by these conditions would fix the bug without causing side effects, because they aren't still used at special cases where the screen is closed or they pass events.

      Removing isLeftPressed check from StatsScreen and using mouseReleased instead

      The Statistics screen uses an internal check of wich header sprite is pressed (see: StatsScreen.ItemStatisticsList, field headerPressed), that is set to -1 at the renderHeader method due to the disfuncional isLeftPressed check. If removing this check, the header press state won't be set to false in any way. To fix this, we must add a different check. At StatScreen, we add an overriding mouseReleased method, to check if the left button is stopping being pressed, if true, the headerPressed int field would set to -1. You can see an example here:_

      public boolean mouseReleased(double mouseX, double mouseY, int clickedButton) {
        if (clickedButton == 0 && this.itemStatsList != null) {
         this.itemStatsList.headerPressed = -1;
        return super.mouseReleased(mouseX, mouseY, clickedMouseButton);



        1. 1.12 and prior.mp4
          794 kB
        2. 1.13 onward.mp4
          1.60 MB
        3. How it should look like.png
          How it should look like.png
          5 kB



            Unassigned Unassigned
            ISRosillo14 Ismael Rosillo
            7 Vote for this issue
            4 Start watching this issue