From cbaebec12a0e9c99d80a614de2ca563d4af41ce4 Mon Sep 17 00:00:00 2001 From: Maksim Belov Date: Sun, 13 Oct 2024 16:23:21 +0300 Subject: [PATCH] Fix[controls]: fix the hotbar out-of-bounds crashes --- .../net/kdt/pojavlaunch/customcontrols/mouse/HotbarView.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/mouse/HotbarView.java b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/mouse/HotbarView.java index 640d65fbc..cd2ff5d1c 100644 --- a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/mouse/HotbarView.java +++ b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/mouse/HotbarView.java @@ -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;