@@ -145,6 +145,7 @@ private enum SearchMode
145145 private java .util .List <net .minecraft .world .phys .Vec3 > tracerEnds ;
146146 private ChunkPos lastPlayerChunk ;
147147 private int lastMatchesVersion ;
148+ private boolean lastNeedsVertexBuffer ;
148149
149150 private SearchMode lastMode ;
150151 private int lastListHash ;
@@ -221,6 +222,7 @@ protected void onEnable()
221222 lastPlayerChunk = new ChunkPos (MC .player .blockPosition ());
222223 lastMode = mode .getSelected ();
223224 lastListHash = blockList .getBlockNames ().hashCode ();
225+ lastNeedsVertexBuffer = needsVertexBuffer ();
224226 applySearchCriteria (block .getBlock (), "" );
225227 lastMatchesVersion = coordinator .getMatchesVersion ();
226228 if (shaderSafeMode )
@@ -336,6 +338,13 @@ public void onUpdate()
336338 notify = true ;
337339 }
338340
341+ boolean needsVertexBuffer = needsVertexBuffer ();
342+ if (needsVertexBuffer != lastNeedsVertexBuffer )
343+ {
344+ lastNeedsVertexBuffer = needsVertexBuffer ;
345+ stopBuildingBuffer (true );
346+ }
347+
339348 if (!coordinator .hasReadyMatches ())
340349 return ;
341350
@@ -351,6 +360,13 @@ public void onUpdate()
351360 if (!getMatchingBlocksTask .isDone ())
352361 return ;
353362
363+ if (!needsVertexBuffer )
364+ {
365+ if (!bufferUpToDate )
366+ setSimpleBufferFromTask ();
367+ return ;
368+ }
369+
354370 if (compileVerticesTask == null )
355371 startCompileVerticesTask ();
356372
@@ -377,8 +393,10 @@ public void onRender(PoseStack matrixStack, float partialTicks)
377393 style .hasBoxes () && vertexBuffer != null && bufferRegion != null ;
378394 boolean drawTracers =
379395 style .hasLines () && tracerEnds != null && !tracerEnds .isEmpty ();
396+ boolean drawHighlights =
397+ highlightBoxes != null && !highlightBoxes .isEmpty ();
380398
381- if (!drawBoxes && !drawTracers )
399+ if (!drawBoxes && !drawTracers && ! drawHighlights )
382400 return ;
383401
384402 float [] rgb = useFixedColor .isChecked () ? fixedColor .getColorF ()
@@ -400,7 +418,7 @@ public void onRender(PoseStack matrixStack, float partialTicks)
400418 tracerColor , false );
401419 }
402420
403- if (highlightBoxes != null && ! highlightBoxes . isEmpty () )
421+ if (drawHighlights )
404422 {
405423 float alpha = getHighlightAlphaFloat ();
406424 int color = RenderUtils .toIntColor (rgb , alpha );
@@ -641,6 +659,12 @@ else if(notify)
641659 notify = false ;
642660 }
643661
662+ if (!needsVertexBuffer ())
663+ {
664+ setSimpleBufferFromMatches (matchingBlocks );
665+ return ;
666+ }
667+
644668 ArrayList <int []> vertices = BlockVertexCompiler .compile (matchingBlocks );
645669 setBufferFromVertices (vertices , matchingBlocks );
646670 }
@@ -657,6 +681,44 @@ private void setBufferFromTask()
657681 setBufferFromVertices (vertices , lastMatchingBlocks );
658682 }
659683
684+ private void setSimpleBufferFromTask ()
685+ {
686+ HashSet <BlockPos > matchingBlocks = getMatchingBlocksTask .join ();
687+ lastMatchingBlocks = matchingBlocks ;
688+ setSimpleBufferFromMatches (matchingBlocks );
689+ }
690+
691+ private void setSimpleBufferFromMatches (HashSet <BlockPos > matchingBlocks )
692+ {
693+ if (vertexBuffer != null )
694+ {
695+ vertexBuffer .close ();
696+ vertexBuffer = null ;
697+ }
698+
699+ bufferRegion = null ;
700+ bufferUpToDate = true ;
701+
702+ if (matchingBlocks != null )
703+ {
704+ highlightBoxes = matchingBlocks .stream ().map (AABB ::new )
705+ .collect (java .util .stream .Collectors .toList ());
706+ tracerEnds = matchingBlocks .stream ().map (pos -> {
707+ if (net .wurstclient .util .BlockUtils .canBeClicked (pos ))
708+ return net .wurstclient .util .BlockUtils .getBoundingBox (pos )
709+ .getCenter ();
710+ return pos .getCenter ();
711+ }).collect (java .util .stream .Collectors .toList ());
712+ foundCount = Math .min (matchingBlocks .size (), 999 );
713+
714+ }else
715+ {
716+ highlightBoxes = null ;
717+ tracerEnds = null ;
718+ foundCount = 0 ;
719+ }
720+ }
721+
660722 private void setBufferFromVertices (ArrayList <int []> vertices ,
661723 HashSet <BlockPos > matchingBlocks )
662724 {
@@ -716,6 +778,11 @@ private void stopBuildingBuffer(boolean discardCurrent)
716778 }
717779 }
718780
781+ private boolean needsVertexBuffer ()
782+ {
783+ return highlightFill .isChecked ();
784+ }
785+
719786 private float getHighlightAlphaFloat ()
720787 {
721788 int v = (int )Math .round (highlightAlpha .getValue ());
0 commit comments