From ecb816668762caa88851806276da09d2fa82a35b Mon Sep 17 00:00:00 2001 From: MCbabel Date: Wed, 4 Mar 2026 13:06:50 +0100 Subject: [PATCH] Fix creative inventory crash with Art Tools debug option Fix vector out-of-bounds crash when scrolling the potions tab in the creative inventory with Art Tools debug enabled. - Fix getPageCount() returning total rows instead of scrollable pages in Art Tools mode - Fix off-by-one boundary check in populateMenu() for both static and debug group loops (< should be <=) Fixes #386 --- Minecraft.Client/Common/UI/IUIScene_CreativeMenu.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Minecraft.Client/Common/UI/IUIScene_CreativeMenu.cpp b/Minecraft.Client/Common/UI/IUIScene_CreativeMenu.cpp index 973020db2..41b483acf 100644 --- a/Minecraft.Client/Common/UI/IUIScene_CreativeMenu.cpp +++ b/Minecraft.Client/Common/UI/IUIScene_CreativeMenu.cpp @@ -882,7 +882,7 @@ void IUIScene_CreativeMenu::TabSpec::populateMenu(AbstractContainerMenu *menu, i for(; currentGroup < m_staticGroupsCount; ++currentGroup) { int size = categoryGroups[m_staticGroupsA[currentGroup]].size(); - if( currentIndex + size < startIndex) + if( currentIndex + size <= startIndex) { currentIndex += size; continue; @@ -932,7 +932,7 @@ void IUIScene_CreativeMenu::TabSpec::populateMenu(AbstractContainerMenu *menu, i for(; currentGroup < m_debugGroupsCount; ++currentGroup) { int size = categoryGroups[m_debugGroupsA[currentGroup]].size(); - if( currentIndex + size < startIndex) + if( currentIndex + size <= startIndex) { currentIndex += size; continue; @@ -973,7 +973,9 @@ unsigned int IUIScene_CreativeMenu::TabSpec::getPageCount() #ifndef _CONTENT_PACKAGE if(app.DebugArtToolsOn()) { - return (int)ceil((float)(m_staticItems + m_debugItems) / m_staticPerPage); + int totalItems = m_staticItems + m_debugItems; + const int totalRows = (totalItems + columns - 1) / columns; + return std::max(1, totalRows - rows + 1); } else #endif