diff options
| author | Marlian <84173858+MCbabel@users.noreply.github.com> | 2026-03-04 13:47:43 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-03-04 19:47:43 +0700 |
| commit | 2d430798a56b00f321ef92a416797d6ce069d7b0 (patch) | |
| tree | 9fe0b21e8e159c26bd7f4bb6bb75d6cb2ef6b2dc | |
| parent | 52d9bcc9a9fbccd995ab59847c005f98751ebe0a (diff) | |
Fix creative inventory crash with Art Tools debug option (#399)
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
| -rw-r--r-- | Minecraft.Client/Common/UI/IUIScene_CreativeMenu.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/Minecraft.Client/Common/UI/IUIScene_CreativeMenu.cpp b/Minecraft.Client/Common/UI/IUIScene_CreativeMenu.cpp index bda2228e..0099cea6 100644 --- a/Minecraft.Client/Common/UI/IUIScene_CreativeMenu.cpp +++ b/Minecraft.Client/Common/UI/IUIScene_CreativeMenu.cpp @@ -880,7 +880,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; @@ -930,7 +930,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; @@ -971,7 +971,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<int>(1, totalRows - rows + 1); } else #endif |
