@@ -85,7 +85,7 @@ void updateEntries() {
85
85
86
86
void updateButtons () {
87
87
for (Entry <AbstractWaypointEntry > entry : children ()) {
88
- if (entry instanceof WaypointCategoryEntry categoryEntry && categoryEntry .enabled .isChecked () != categoryEntry .category . waypoints (). stream (). allMatch ( screen :: isEnabled )) {
88
+ if (entry instanceof WaypointCategoryEntry categoryEntry && categoryEntry .enabled .isChecked () != categoryEntry .shouldBeChecked ( )) {
89
89
((CheckboxWidgetAccessor ) categoryEntry .enabled ).setChecked (!categoryEntry .enabled .isChecked ());
90
90
} else if (entry instanceof WaypointEntry waypointEntry && waypointEntry .enabled .isChecked () != screen .isEnabled (waypointEntry .waypoint )) {
91
91
waypointEntry .enabled .onPress ();
@@ -114,7 +114,7 @@ public WaypointCategoryEntry() {
114
114
115
115
public WaypointCategoryEntry (WaypointCategory category ) {
116
116
this .category = category ;
117
- enabled = CheckboxWidget .builder (Text .literal ("" ), client .textRenderer ).checked (! category . waypoints (). isEmpty () && category . waypoints (). stream (). allMatch ( screen :: isEnabled )).callback ((checkbox , checked ) -> category .waypoints ().forEach (waypoint -> screen .enabledChanged (waypoint , checked ))).build ();
117
+ enabled = CheckboxWidget .builder (Text .literal ("" ), client .textRenderer ).checked (shouldBeChecked ( )).callback ((checkbox , checked ) -> category .waypoints ().forEach (waypoint -> screen .enabledChanged (waypoint , checked ))).build ();
118
118
nameField = new TextFieldWidget (client .textRenderer , 70 , 20 , Text .literal ("Name" ));
119
119
nameField .setText (category .name ());
120
120
nameField .setChangedListener (this ::updateName );
@@ -153,6 +153,10 @@ public List<? extends Element> children() {
153
153
return children ;
154
154
}
155
155
156
+ private boolean shouldBeChecked () {
157
+ return !category .waypoints ().isEmpty () && category .waypoints ().stream ().allMatch (screen ::isEnabled );
158
+ }
159
+
156
160
private void updateName (String name ) {
157
161
int index = waypoints .indexOf (category );
158
162
category = category .withName (name );
0 commit comments