@@ -147,7 +147,7 @@ protected void init() {
147147 this .filtersWidth = librariesWidth + sortingWidth + 2 ;
148148 this .searchRowWidth = this .searchBoxX + searchBoxWidth + 22 ;
149149
150- this .updateFiltersX ();
150+ this .updateFiltersX (true );
151151
152152 if (!ModMenuConfig .CONFIG_MODE .getValue ()) {
153153 this .filtersButton = LegacyTexturedButtonWidget .legacyTexturedBuilder (ModMenuScreenTexts .TOGGLE_FILTER_OPTIONS ,
@@ -322,8 +322,8 @@ public void render(DrawContext DrawContext, int mouseX, int mouseY, float delta)
322322 );
323323 }
324324 if (!ModMenuConfig .CONFIG_MODE .getValue ()) {
325- Text fullModCount = this .computeModCountText (true );
326- if (!ModMenuConfig .CONFIG_MODE .getValue () && this .updateFiltersX ()) {
325+ Text fullModCount = this .computeModCountText (true , false );
326+ if (!ModMenuConfig .CONFIG_MODE .getValue () && this .updateFiltersX (false )) {
327327 if (this .filterOptionsShown ) {
328328 if (!ModMenuConfig .SHOW_LIBRARIES .getValue () ||
329329 textRenderer .getWidth (fullModCount ) <= this .filtersX - 5 ) {
@@ -336,14 +336,14 @@ public void render(DrawContext DrawContext, int mouseX, int mouseY, float delta)
336336 );
337337 } else {
338338 DrawContext .drawText (textRenderer ,
339- computeModCountText (false ).asOrderedText (),
339+ computeModCountText (false , false ).asOrderedText (),
340340 this .searchBoxX ,
341341 46 ,
342342 0xFFFFFF ,
343343 true
344344 );
345345 DrawContext .drawText (textRenderer ,
346- computeLibraryCountText ().asOrderedText (),
346+ computeLibraryCountText (false ).asOrderedText (),
347347 this .searchBoxX ,
348348 57 ,
349349 0xFFFFFF ,
@@ -362,14 +362,14 @@ public void render(DrawContext DrawContext, int mouseX, int mouseY, float delta)
362362 );
363363 } else {
364364 DrawContext .drawText (textRenderer ,
365- computeModCountText (false ).asOrderedText (),
365+ computeModCountText (false , false ).asOrderedText (),
366366 this .searchBoxX ,
367367 46 ,
368368 0xFFFFFF ,
369369 true
370370 );
371371 DrawContext .drawText (textRenderer ,
372- computeLibraryCountText ().asOrderedText (),
372+ computeLibraryCountText (false ).asOrderedText (),
373373 this .searchBoxX ,
374374 57 ,
375375 0xFFFFFF ,
@@ -455,42 +455,42 @@ public void render(DrawContext DrawContext, int mouseX, int mouseY, float delta)
455455 }
456456 }
457457
458- private Text computeModCountText (boolean includeLibs ) {
458+ private Text computeModCountText (boolean includeLibs , boolean onInit ) {
459459 int [] rootMods = formatModCount (ModMenu .ROOT_MODS .values ()
460460 .stream ()
461461 .filter (mod -> !mod .isHidden () && !mod .getBadges ().contains (Mod .Badge .LIBRARY ))
462462 .map (Mod ::getId )
463- .collect (Collectors .toSet ()));
463+ .collect (Collectors .toSet ()), onInit );
464464
465- if (includeLibs && ModMenuConfig .SHOW_LIBRARIES .getValue ()) {
465+ if (includeLibs && ModMenuConfig .SHOW_LIBRARIES .getValue () && ! onInit ) {
466466 int [] rootLibs = formatModCount (ModMenu .ROOT_MODS .values ()
467467 .stream ()
468468 .filter (mod -> !mod .isHidden () && mod .getBadges ().contains (Mod .Badge .LIBRARY ))
469469 .map (Mod ::getId )
470- .collect (Collectors .toSet ()));
470+ .collect (Collectors .toSet ()), false );
471471 return TranslationUtil .translateNumeric ("modmenu.showingModsLibraries" , rootMods , rootLibs );
472472 } else {
473473 return TranslationUtil .translateNumeric ("modmenu.showingMods" , rootMods );
474474 }
475475 }
476476
477- private Text computeLibraryCountText () {
478- if (ModMenuConfig .SHOW_LIBRARIES .getValue ()) {
477+ private Text computeLibraryCountText (boolean onInit ) {
478+ if (ModMenuConfig .SHOW_LIBRARIES .getValue () && ! onInit ) {
479479 int [] rootLibs = formatModCount (ModMenu .ROOT_MODS .values ()
480480 .stream ()
481481 .filter (mod -> !mod .isHidden () && mod .getBadges ().contains (Mod .Badge .LIBRARY ))
482482 .map (Mod ::getId )
483- .collect (Collectors .toSet ()));
483+ .collect (Collectors .toSet ()), false );
484484 return TranslationUtil .translateNumeric ("modmenu.showingLibraries" , rootLibs );
485485 } else {
486486 return Text .literal (null );
487487 }
488488 }
489489
490- private int [] formatModCount (Set <String > set ) {
490+ private int [] formatModCount (Set <String > set , boolean allVisible ) {
491491 int visible = this .modList .getDisplayedCountFor (set );
492492 int total = set .size ();
493- if (visible == total ) {
493+ if (visible == total || allVisible ) {
494494 return new int []{ total };
495495 }
496496 return new int []{ visible , total };
@@ -562,10 +562,10 @@ public String getSearchInput() {
562562 return this .searchBox .getText ();
563563 }
564564
565- private boolean updateFiltersX () {
566- if ((this .filtersWidth + textRenderer .getWidth (this .computeModCountText (true )) + 20 ) >= this .searchRowWidth &&
567- ((this .filtersWidth + textRenderer .getWidth (computeModCountText (false )) + 20 ) >= this .searchRowWidth ||
568- (this .filtersWidth + textRenderer .getWidth (this .computeLibraryCountText ()) + 20 ) >= this .searchRowWidth
565+ private boolean updateFiltersX (boolean onInit ) {
566+ if ((this .filtersWidth + textRenderer .getWidth (this .computeModCountText (true , onInit )) + 20 ) >= this .searchRowWidth &&
567+ ((this .filtersWidth + textRenderer .getWidth (this . computeModCountText (false , onInit )) + 20 ) >= this .searchRowWidth ||
568+ (this .filtersWidth + textRenderer .getWidth (this .computeLibraryCountText (onInit )) + 20 ) >= this .searchRowWidth
569569 )) {
570570 this .filtersX = this .paneWidth / 2 - this .filtersWidth / 2 ;
571571 return !filterOptionsShown ;
0 commit comments