Statistics sprites don't look pressed when clicked
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
- Open the statistics screen.
- 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:_
@Override 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); }
- Unresolved
Ismael Rosillo- 11
- 5
- Confirmed
- UI
1.16.3 - 1.21.4
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-pre1 1.18-pre4 1.18-pre5 1.18-pre6 1.18-pre7 1.18-rc2 1.18 1.18.1 22w06a 22w07a 1.18.2-pre1 1.18.2-pre3 1.18.2 22w11a 22w12a 1.19 1.19.2 1.19.3-pre2 1.19.3 23w05a 1.19.4-pre1 1.19.4 23w16a 1.20 1.20.1 23w31a 1.20.2 1.20.3 1.20.4 1.20.5 1.21 1.21.1 24w34a 1.21.3 1.21.4
Created Issue:
Statistics sprites don't look pressed when clicked
This happens since 1.13.
When going to Puse Menu->Statistics->Items, when I click at one of the sprites it does not change its look to its "pressed" state.
Code analysis:
This bug is caused by net.minecraft.client.MouseHandler.isLeftPressed() returning always false (even if the left mouse button is pressed) while on the statistics screen. This method is called just before rendering the sprites, and because of said method returning false it sets net.minecraft.client.gui.screens.achievement.StatsScreen.ItemStatisticsList.headerPressed to -1.
How to fix (it worked on my modified client):
Just copy the code from below to net.minecraft.client.gui.screens.achievement.StatsScreen.ItemStatisticsList and remove the conditional "if (!this.minecraft.mouseHandler.isLeftPressed())" and its content from net.minecraft.client.gui.screens.achievement.StatsScreen.ItemStatisticsList.renderHeader().
public boolean mouseReleased(double mouseX, double mouseY, int clickedMouseButton) { if (clickedMouseButton == 0 && this.itemStatsList != null) { this.itemStatsList.headerPressed = -1; } return super.mouseReleased(mouseX, mouseY, clickedMouseButton); }
This happens since 1.13.
When going to Pause Menu->Statistics->Items, when I click at one of the sprites it does not change its look to its "pressed" state.
Code analysis:
This bug is caused by net.minecraft.client.MouseHandler.isLeftPressed() returning always false (even if the left mouse button is pressed) while on the statistics screen. This method is called just before rendering the sprites, and because of said method returning false it sets net.minecraft.client.gui.screens.achievement.StatsScreen.ItemStatisticsList.headerPressed to -1.
How to fix (it worked on my modified client):
Just copy the code from below to net.minecraft.client.gui.screens.achievement.StatsScreen.ItemStatisticsList and remove the conditional "if (!this.minecraft.mouseHandler.isLeftPressed())" and its content from net.minecraft.client.gui.screens.achievement.StatsScreen.ItemStatisticsList.renderHeader().
public boolean mouseReleased(double mouseX, double mouseY, int clickedMouseButton) { if (clickedMouseButton == 0 && this.itemStatsList != null) { this.itemStatsList.headerPressed = -1; } return super.mouseReleased(mouseX, mouseY, clickedMouseButton); }
This happens since 1.13.
When going to Pause Menu->Statistics->Items, when I click at one of the sprites it does not change its look to its "pressed" state.
Code analysis:
This bug is caused by net.minecraft.client.MouseHandler.isLeftPressed() returning always false (even if the left mouse button is pressed) while on the statistics screen. This method is called just before rendering the sprites, and because of said method returning false it sets net.minecraft.client.gui.screens.achievement.StatsScreen.ItemStatisticsList.headerPressed to -1.
How to fix (it worked on my modified client):
Just copy the code from below to net.minecraft.client.gui.screens.achievement.StatsScreen.ItemStatisticsList and remove the conditional "if (!this.minecraft.mouseHandler.isLeftPressed())" and its content from net.minecraft.client.gui.screens.achievement.StatsScreen.ItemStatisticsList.renderHeader().
public boolean mouseReleased(double mouseX, double mouseY, int clickedMouseButton) { if (clickedMouseButton == 0 && this.itemStatsList != null) { this.itemStatsList.headerPressed = -1; } return super.mouseReleased(mouseX, mouseY, clickedMouseButton); }
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
- Open the statistics screen.
- 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
Just copy the code from below to net.minecraft.client.gui.screens.achievement.StatsScreen.ItemStatisticsList and remove the conditional "if (!this.minecraft.mouseHandler.isLeftPressed())" and its content from net.minecraft.client.gui.screens.achievement.StatsScreen.ItemStatisticsList.renderHeader().
public boolean mouseReleased(double mouseX, double mouseY, int clickedMouseButton) { if (clickedMouseButton == 0 && this.itemStatsList != null) { this.itemStatsList.headerPressed = -1; } return super.mouseReleased(mouseX, mouseY, clickedMouseButton); }
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
- Open the statistics screen.
- 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
Just copy the code from below to net.minecraft.client.gui.screens.achievement.StatsScreen.ItemStatisticsList and remove the conditional "if (!this.minecraft.mouseHandler.isLeftPressed())" and its content from net.minecraft.client.gui.screens.achievement.StatsScreen.ItemStatisticsList.renderHeader().
public boolean mouseReleased(double mouseX, double mouseY, int clickedMouseButton){ if (clickedMouseButton == 0 && this.itemStatsList != null){ this.itemStatsList.headerPressed = -1; } return super.mouseReleased(mouseX, mouseY, clickedMouseButton); }
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
- Open the statistics screen.
- 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:_
@Override 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); }

Can confirm in 21w14a.
Can confirm in 1.18.1.
Can confirm in 23w05a