@@ -226,10 +226,11 @@ private void startGetMatchingBlocksTask()
226226 Comparator <BlockPos > comparator =
227227 Comparator .comparingInt (pos -> eyesPos .distManhattan (pos ));
228228 currentBuildGeneration = buildGeneration ;
229+ int effectiveLimit = getEffectiveRenderLimit ();
229230
230231 getMatchingBlocksTask = forkJoinPool .submit (() -> coordinator
231232 .getMatches ().parallel ().map (ChunkSearcher .Result ::pos )
232- .sorted (comparator ).limit (limit . getValueLog () )
233+ .sorted (comparator ).limit (effectiveLimit )
233234 .collect (Collectors .toCollection (HashSet ::new )));
234235 }
235236
@@ -243,13 +244,14 @@ private void startCompileVerticesTask()
243244
244245 HashSet <BlockPos > matchingBlocks = getMatchingBlocksTask .join ();
245246
246- if (matchingBlocks .size () < limit .getValueLog ())
247+ int effectiveLimit = getEffectiveRenderLimit ();
248+ if (matchingBlocks .size () < effectiveLimit )
247249 notify = true ;
248250 else if (notify )
249251 {
250252 ChatUtils .warning ("CaveFinder found \u00a7 lA LOT\u00a7 r of blocks!"
251253 + " To prevent lag, it will only show the closest \u00a7 6"
252- + limit . getValueString () + "\u00a7 r results." );
254+ + effectiveLimit + "\u00a7 r results." );
253255 notify = false ;
254256 }
255257
@@ -268,21 +270,22 @@ private void buildBufferSafeMode()
268270 BlockPos eyesPos = BlockPos .containing (RotationUtils .getEyesPos ());
269271 Comparator <BlockPos > comparator =
270272 Comparator .comparingInt (pos -> eyesPos .distManhattan (pos ));
273+ int effectiveLimit = getEffectiveRenderLimit ();
271274 java .util .ArrayList <ChunkSearcher .Result > matches =
272275 coordinator .getMatches ().collect (
273276 java .util .stream .Collectors .toCollection (ArrayList ::new ));
274277 HashSet <BlockPos > matchingBlocks =
275278 matches .stream ().map (ChunkSearcher .Result ::pos ).sorted (comparator )
276- .limit (limit . getValueLog () )
279+ .limit (effectiveLimit )
277280 .collect (Collectors .toCollection (HashSet ::new ));
278281
279- if (matchingBlocks .size () < limit . getValueLog () )
282+ if (matchingBlocks .size () < effectiveLimit )
280283 notify = true ;
281284 else if (notify )
282285 {
283286 ChatUtils .warning ("CaveFinder found \u00a7 lA LOT\u00a7 r of blocks!"
284287 + " To prevent lag, it will only show the closest \u00a7 6"
285- + limit . getValueString () + "\u00a7 r results." );
288+ + effectiveLimit + "\u00a7 r results." );
286289 notify = false ;
287290 }
288291
@@ -319,4 +322,12 @@ private void setBufferFromVertices(ArrayList<int[]> vertices)
319322 bufferUpToDate = true ;
320323 bufferRegion = region ;
321324 }
325+
326+ private int getEffectiveRenderLimit ()
327+ {
328+ int localLimit = limit .getValueLog ();
329+ int effective = WURST .getHax ().globalToggleHack
330+ .applyGlobalEspRenderLimit (localLimit );
331+ return Math .max (1 , effective );
332+ }
322333}
0 commit comments