@@ -26,6 +26,8 @@ public class OptionListWidget extends ElementListWidget<OptionListWidget.Entry>
2626 private final YACLScreen yaclScreen ;
2727 private boolean singleCategory = false ;
2828
29+ private ImmutableList <Entry > viewableChildren ;
30+
2931 public OptionListWidget (YACLScreen screen , MinecraftClient client , int width , int height ) {
3032 super (client , width / 3 * 2 , height , 0 , height , 22 );
3133 this .yaclScreen = screen ;
@@ -71,6 +73,7 @@ public void refreshOptions() {
7173 }
7274 }
7375
76+ recacheViewableChildren ();
7477 setScrollAmount (0 );
7578 }
7679
@@ -203,9 +206,13 @@ protected void renderBackground(MatrixStack matrices) {
203206 fill (matrices , left , top , right , bottom , 0x6B000000 );
204207 }
205208
209+ public void recacheViewableChildren () {
210+ this .viewableChildren = ImmutableList .copyOf (super .children ().stream ().filter (Entry ::isViewable ).toList ());
211+ }
212+
206213 @ Override
207214 public List <Entry > children () {
208- return super . children (). stream (). filter ( Entry :: isViewable ). toList () ;
215+ return viewableChildren ;
209216 }
210217
211218 public abstract class Entry extends ElementListWidget .Entry <Entry > {
@@ -322,6 +329,7 @@ private GroupSeparatorEntry(OptionGroup group, Screen screen) {
322329 this .groupExpanded = !group .collapsed ();
323330 this .expandMinimizeButton = new LowProfileButtonWidget (0 , 0 , 20 , 20 , Text .empty (), btn -> {
324331 setExpanded (!isExpanded ());
332+ recacheViewableChildren ();
325333 });
326334 updateExpandMinimizeText ();
327335 }
0 commit comments