Fix[controls]: fix the hotbar out-of-bounds crashes

This commit is contained in:
Maksim Belov 2024-10-13 16:23:21 +03:00
parent 68254e0c8e
commit cbaebec12a

View File

@ -94,7 +94,8 @@ public class HotbarView extends View implements MCOptionUtils.MCOptionListener,
else mDropGesture.submit();
// Determine the hotbar slot
float x = event.getX();
if(x < 0 || x > mWidth) {
// Ignore positions equal to mWidth because they would translate into an out-of-bounds hotbar index
if(x < 0 || x >= mWidth) {
// If out of bounds, cancel the hotbar gesture to avoid dropping items on last hotbar slots
mDropGesture.cancel();
return true;