@@ -43,6 +43,8 @@ public final class EditBlockListScreen extends Screen
4343 private ButtonWidget doneButton ;
4444
4545 private Block blockToAdd ;
46+ private java .util .List <net .minecraft .block .Block > fuzzyMatches =
47+ java .util .Collections .emptyList ();
4648
4749 public EditBlockListScreen (Screen prevScreen , BlockListSetting blockList )
4850 {
@@ -58,22 +60,30 @@ public void init()
5860 addSelectableChild (listGui );
5961
6062 blockNameField = new TextFieldWidget (client .textRenderer ,
61- width / 2 - 152 , height - 56 , 150 , 20 , Text .literal ("" ));
63+ width / 2 - 152 , height - 56 , 140 , 20 , Text .literal ("" ));
6264 addSelectableChild (blockNameField );
6365 blockNameField .setMaxLength (256 );
6466
6567 addDrawableChild (
6668 addButton = ButtonWidget .builder (Text .literal ("Add" ), b -> {
67- blockList .add (blockToAdd );
69+ if (blockToAdd != null )
70+ {
71+ blockList .add (blockToAdd );
72+ }else if (fuzzyMatches != null && !fuzzyMatches .isEmpty ())
73+ {
74+ for (net .minecraft .block .Block bk : fuzzyMatches )
75+ blockList .add (bk );
76+ }
6877 client .setScreen (EditBlockListScreen .this );
69- }).dimensions (width / 2 - 2 , height - 56 , 30 , 20 ).build ());
78+ }).dimensions (width / 2 + 40 , height - 56 , 80 , 20 ).build ());
7079
80+ // Shift remove to the right to make room for wider Add
7181 addDrawableChild (removeButton =
7282 ButtonWidget .builder (Text .literal ("Remove Selected" ), b -> {
7383 blockList
7484 .remove (blockList .indexOf (listGui .getSelectedBlockName ()));
7585 client .setScreen (EditBlockListScreen .this );
76- }).dimensions (width / 2 + 52 , height - 56 , 100 , 20 ).build ());
86+ }).dimensions (width / 2 + 124 , height - 56 , 120 , 20 ).build ());
7787
7888 addDrawableChild (ButtonWidget .builder (Text .literal ("Reset to Defaults" ),
7989 b -> client .setScreen (new ConfirmScreen (b2 -> {
@@ -82,7 +92,12 @@ public void init()
8292 client .setScreen (EditBlockListScreen .this );
8393 }, Text .literal ("Reset to Defaults" ),
8494 Text .literal ("Are you sure?" ))))
85- .dimensions (width - 108 , 8 , 100 , 20 ).build ());
95+ .dimensions (width - 328 , 8 , 150 , 20 ).build ());
96+
97+ addDrawableChild (ButtonWidget .builder (Text .literal ("Clear List" ), b -> {
98+ blockList .clear ();
99+ client .setScreen (EditBlockListScreen .this );
100+ }).dimensions (width - 168 , 8 , 150 , 20 ).build ());
86101
87102 addDrawableChild (doneButton = ButtonWidget
88103 .builder (Text .literal ("Done" ), b -> client .setScreen (prevScreen ))
@@ -126,8 +141,46 @@ public boolean keyPressed(int keyCode, int scanCode, int int_3)
126141 public void tick ()
127142 {
128143 String nameOrId = blockNameField .getText ();
129- blockToAdd = BlockUtils .getBlockFromNameOrID (nameOrId );
130- addButton .active = blockToAdd != null ;
144+ blockToAdd =
145+ net .wurstclient .util .BlockUtils .getBlockFromNameOrID (nameOrId );
146+ // Build fuzzy matches if no exact block found
147+ if (blockToAdd == null )
148+ {
149+ String q = nameOrId == null ? ""
150+ : nameOrId .trim ().toLowerCase (java .util .Locale .ROOT );
151+ if (q .isEmpty ())
152+ {
153+ fuzzyMatches = java .util .Collections .emptyList ();
154+ }else
155+ {
156+ java .util .ArrayList <net .minecraft .block .Block > list =
157+ new java .util .ArrayList <>();
158+ for (net .minecraft .util .Identifier id : net .minecraft .registry .Registries .BLOCK
159+ .getIds ())
160+ {
161+ String s = id .toString ().toLowerCase (java .util .Locale .ROOT );
162+ if (s .contains (q ))
163+ list .add (
164+ net .minecraft .registry .Registries .BLOCK .get (id ));
165+ }
166+ // Deduplicate and sort by identifier
167+ java .util .LinkedHashMap <String , net .minecraft .block .Block > map =
168+ new java .util .LinkedHashMap <>();
169+ for (net .minecraft .block .Block b : list )
170+ map .put (net .wurstclient .util .BlockUtils .getName (b ), b );
171+ fuzzyMatches = new java .util .ArrayList <>(map .values ());
172+ fuzzyMatches .sort (java .util .Comparator
173+ .comparing (net .wurstclient .util .BlockUtils ::getName ));
174+ }
175+ addButton .active = !fuzzyMatches .isEmpty ();
176+ addButton .setMessage (Text .literal (fuzzyMatches .isEmpty () ? "Add"
177+ : ("Add Matches (" + fuzzyMatches .size () + ")" )));
178+ }else
179+ {
180+ fuzzyMatches = java .util .Collections .emptyList ();
181+ addButton .active = true ;
182+ addButton .setMessage (Text .literal ("Add" ));
183+ }
131184
132185 removeButton .active = listGui .getSelectedOrNull () != null ;
133186 }
@@ -150,34 +203,33 @@ public void render(DrawContext context, int mouseX, int mouseY,
150203
151204 for (Drawable drawable : drawables )
152205 drawable .render (context , mouseX , mouseY , partialTicks );
153-
206+
207+ // Draw placeholder + decorative left icon frame using ABSOLUTE
208+ // coordinates
209+ // derived from the actual TextFieldWidget position/size (no matrix
210+ // translate).
154211 context .state .goUpLayer ();
155- matrixStack .pushMatrix ();
156- matrixStack .translate (-64 + width / 2 - 152 , 0 );
212+
213+ int x0 = blockNameField .getX ();
214+ int y0 = blockNameField .getY ();
215+ int x1 = x0 + blockNameField .getWidth ();
216+ int y1 = y0 + blockNameField .getHeight ();
157217
158218 if (blockNameField .getText ().isEmpty () && !blockNameField .isFocused ())
159219 context .drawTextWithShadow (client .textRenderer , "block name or ID" ,
160- 68 , height - 50 , Colors .GRAY );
220+ x0 + 6 , y0 + 6 , Colors .GRAY );
161221
162222 int border =
163223 blockNameField .isFocused () ? Colors .WHITE : Colors .LIGHT_GRAY ;
164224 int black = Colors .BLACK ;
165225
166- context .fill (48 , height - 56 , 64 , height - 36 , border );
167- context .fill (49 , height - 55 , 65 , height - 37 , black );
168- context .fill (214 , height - 56 , 244 , height - 55 , border );
169- context .fill (214 , height - 37 , 244 , height - 36 , border );
170- context .fill (244 , height - 56 , 246 , height - 36 , border );
171- context .fill (213 , height - 55 , 243 , height - 52 , black );
172- context .fill (213 , height - 40 , 243 , height - 37 , black );
173- context .fill (213 , height - 55 , 216 , height - 37 , black );
174- context .fill (242 , height - 55 , 245 , height - 37 , black );
175-
176- matrixStack .popMatrix ();
226+ // Left decoration for the item icon, anchored to the field.
227+ context .fill (x0 - 16 , y0 , x0 , y1 , border );
228+ context .fill (x0 - 15 , y0 + 1 , x0 - 1 , y1 - 1 , black );
177229
178230 RenderUtils .drawItem (context ,
179231 blockToAdd == null ? ItemStack .EMPTY : new ItemStack (blockToAdd ),
180- width / 2 - 164 , height - 52 , false );
232+ x0 - 28 , y0 + 4 , false );
181233
182234 context .state .goDownLayer ();
183235 matrixStack .popMatrix ();
0 commit comments