Skip to content

Commit 1ddd473

Browse files
committed
Updated Search
1 parent 858ec70 commit 1ddd473

File tree

7 files changed

+353
-60
lines changed

7 files changed

+353
-60
lines changed

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ All credit for the original client goes to Wurst-Imperium and its contributors.
166166
- Works together with XRay
167167
- Add items with the list UI, meaning you can add keywords or just select multiple blocks easily.
168168

169-
![Surface](https://i.ibb.co.com/WptKT2yY/Untitldded.png)
169+
![Surface](https://i.imgur.com/fQzefis.png)
170170

171171
### AntiDrop
172172
- Prevents you from dropping the selected items by accident. Defaults to all weapons, tools, and shulker boxes.
@@ -177,7 +177,7 @@ All credit for the original client goes to Wurst-Imperium and its contributors.
177177
- Renders on top of the vanilla screen darkening, stays aligned beside the container and has an adjustable size and font scaling
178178
- Works with books and gear and will separate them in the list by category and type
179179

180-
![Chest](https://i.ibb.co/0yRPQ0jy/javaw-sg-VUhu-MCDY.png)
180+
![Chest](https://i.imgur.com/6u9S2OD.png)
181181

182182
## What’s changed or improved in this fork?
183183

@@ -227,6 +227,7 @@ Examples:
227227
- New minimum search to 100 results.
228228
- Replaced full-sort approach to bounded max-heap (PriorityQueue) that keeps the closest N matches. This avoids sorting entire result and keeps search as fast as X-Ray.
229229
- Safer rescans and better crash handling.
230+
- Improved search speed.
230231

231232
![Search](https://i.imgur.com/zpITuWb.png)
232233

@@ -296,7 +297,10 @@ Examples:
296297
- Ignores shulker boxes
297298

298299
### AutoLibrarian Improved
299-
- Can now discover enchantments provided by modpacks
300+
- Can now discover enchantments provided by data packs.
301+
- Able to search for enchantments by keywords.
302+
303+
![Library](https://i.imgur.com/ZCK7Frz.png)
300304

301305
### Unsafe Chat Toast
302306
- Optional; toggle via NoChatReports or Wurst Options.

gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ loom_version=1.11-SNAPSHOT
1515
fabric_version=0.135.0+1.21.10
1616

1717
# Mod Properties
18-
mod_version=v7.50.3-MC1.21.10
18+
mod_version=v7.50.3-CevAPI-MC1.21.10
1919
maven_group=net.wurstclient
2020
archives_base_name=Wurst-Client
2121
mod_loader=Fabric
2222

2323
# GitHub
24-
gh_repo_id=Wurst-Imperium/Wurst7
24+
gh_repo_id=cev-api/Wurst7-CevAPI
2525
mcx_repo_id=Wurst-Imperium/Wurst-MCX2
2626

2727
# Dependencies

src/main/java/net/wurstclient/hacks/SearchHack.java

Lines changed: 62 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ private enum SearchMode
129129
// Precomputed tracer endpoints
130130
private java.util.List<net.minecraft.util.math.Vec3d> tracerEnds;
131131
private ChunkPos lastPlayerChunk;
132+
private int lastMatchesVersion;
132133

133134
private SearchMode lastMode;
134135
private int lastListHash;
@@ -200,6 +201,7 @@ protected void onEnable()
200201
lastMode = mode.getSelected();
201202
lastListHash = blockList.getBlockNames().hashCode();
202203
applySearchCriteria(block.getBlock(), "");
204+
lastMatchesVersion = coordinator.getMatchesVersion();
203205
EVENTS.add(UpdateListener.class, this);
204206
EVENTS.add(PacketInputListener.class, coordinator);
205207
EVENTS.add(RenderListener.class, this);
@@ -213,7 +215,7 @@ protected void onDisable()
213215
EVENTS.remove(PacketInputListener.class, coordinator);
214216
EVENTS.remove(RenderListener.class, this);
215217
EVENTS.remove(CameraTransformViewBobbingListener.class, this);
216-
stopBuildingBuffer();
218+
stopBuildingBuffer(true);
217219
coordinator.reset();
218220
forkJoinPool.shutdownNow();
219221
if(vertexBuffer != null)
@@ -229,14 +231,13 @@ protected void onDisable()
229231
@Override
230232
public void onUpdate()
231233
{
232-
boolean searchersChanged = false;
233-
// Mode/list changes
234234
SearchMode currentMode = mode.getSelected();
235+
236+
// Mode/list changes
235237
if(currentMode != lastMode)
236238
{
237239
lastMode = currentMode;
238240
applySearchCriteria(block.getBlock(), "");
239-
searchersChanged = true;
240241
}
241242
if(currentMode == SearchMode.LIST)
242243
{
@@ -245,59 +246,61 @@ public void onUpdate()
245246
{
246247
lastListHash = listHash;
247248
applySearchCriteria(block.getBlock(), "");
248-
searchersChanged = true;
249249
}
250250
}
251+
251252
// Recenter per chunk when sticky is off
252253
ChunkPos currentChunk = new ChunkPos(MC.player.getBlockPos());
253254
if(!stickyArea.isChecked() && !currentChunk.equals(lastPlayerChunk))
254255
{
255256
lastPlayerChunk = currentChunk;
256257
coordinator.reset();
257-
stopBuildingBuffer();
258-
searchersChanged = true;
258+
stopBuildingBuffer(false);
259259
}
260+
260261
// Area changes
261262
ChunkAreaSetting.ChunkArea currentArea = area.getSelected();
262263
if(currentArea != lastAreaSelection)
263264
{
264265
lastAreaSelection = currentArea;
265266
coordinator.reset();
266-
searchersChanged = true;
267+
stopBuildingBuffer(true);
268+
notify = true;
267269
}
270+
268271
// Criteria changes only for modes that use them
269272
if(currentMode == SearchMode.BLOCK_ID)
270273
{
271274
Block currentBlock = block.getBlock();
272275
if(currentBlock != lastBlock)
273-
{
274276
applySearchCriteria(currentBlock, "");
275-
searchersChanged = true;
276-
}
277277
}else if(currentMode == SearchMode.QUERY)
278278
{
279279
String currentQuery = normalizeQuery(query.getValue());
280280
if(!currentQuery.equals(lastQuery))
281-
{
282281
applySearchCriteria(block.getBlock(), currentQuery);
283-
searchersChanged = true;
284-
}
285282
}
286-
// Coordinator update
287-
if(coordinator.update())
288-
searchersChanged = true;
289-
if(searchersChanged)
290-
stopBuildingBuffer();
291-
if(!coordinator.isDone())
292-
return;
283+
284+
// Update coordinator (adds/removes searchers, applies packet updates)
285+
coordinator.update();
286+
287+
int matchesVersion = coordinator.getMatchesVersion();
288+
if(matchesVersion != lastMatchesVersion)
289+
{
290+
lastMatchesVersion = matchesVersion;
291+
stopBuildingBuffer(false);
292+
}
293293

294294
if(limit.getValueI() != prevLimit)
295295
{
296-
stopBuildingBuffer();
296+
stopBuildingBuffer(false);
297297
prevLimit = limit.getValueI();
298298
notify = true;
299299
}
300300

301+
if(!coordinator.hasReadyMatches())
302+
return;
303+
301304
if(getMatchingBlocksTask == null)
302305
startGetMatchingBlocksTask();
303306

@@ -326,34 +329,31 @@ public void onCameraTransformViewBobbing(
326329
@Override
327330
public void onRender(MatrixStack matrixStack, float partialTicks)
328331
{
329-
if(vertexBuffer == null || bufferRegion == null)
330-
{
331-
if(style.hasLines() && tracerEnds != null && !tracerEnds.isEmpty())
332-
{
333-
int color = useFixedColor.isChecked()
334-
? net.wurstclient.util.RenderUtils
335-
.toIntColor(fixedColor.getColorF(), 0.5F)
336-
: net.wurstclient.util.RenderUtils.toIntColor(
337-
net.wurstclient.util.RenderUtils.getRainbowColor(),
338-
0.5F);
339-
net.wurstclient.util.RenderUtils.drawTracers(matrixStack,
340-
partialTicks, tracerEnds, color, false);
341-
}
332+
boolean drawBoxes =
333+
style.hasBoxes() && vertexBuffer != null && bufferRegion != null;
334+
boolean drawTracers =
335+
style.hasLines() && tracerEnds != null && !tracerEnds.isEmpty();
336+
337+
if(!drawBoxes && !drawTracers)
342338
return;
343-
}
344-
matrixStack.push();
345-
RenderUtils.applyRegionalRenderOffset(matrixStack, bufferRegion);
339+
346340
float[] rgb = useFixedColor.isChecked() ? fixedColor.getColorF()
347341
: RenderUtils.getRainbowColor();
348-
vertexBuffer.draw(matrixStack, WurstRenderLayers.ESP_QUADS, rgb, 0.5F);
349-
matrixStack.pop();
350-
if(style.hasLines() && tracerEnds != null && !tracerEnds.isEmpty())
342+
343+
if(drawBoxes)
351344
{
352-
int color = useFixedColor.isChecked()
353-
? RenderUtils.toIntColor(fixedColor.getColorF(), 0.5F)
354-
: RenderUtils.toIntColor(RenderUtils.getRainbowColor(), 0.5F);
345+
matrixStack.push();
346+
RenderUtils.applyRegionalRenderOffset(matrixStack, bufferRegion);
347+
vertexBuffer.draw(matrixStack, WurstRenderLayers.ESP_QUADS, rgb,
348+
0.5F);
349+
matrixStack.pop();
350+
}
351+
352+
if(drawTracers)
353+
{
354+
int tracerColor = RenderUtils.toIntColor(rgb, 0.5F);
355355
RenderUtils.drawTracers(matrixStack, partialTicks, tracerEnds,
356-
color, false);
356+
tracerColor, false);
357357
}
358358
}
359359

@@ -375,6 +375,8 @@ private String abbreviate(String text)
375375

376376
private void applySearchCriteria(Block currentBlock, String normalizedQuery)
377377
{
378+
stopBuildingBuffer(true);
379+
378380
switch(mode.getSelected())
379381
{
380382
case LIST:
@@ -445,6 +447,7 @@ private void applySearchCriteria(Block currentBlock, String normalizedQuery)
445447
lastQuery = "";
446448
}
447449
notify = true;
450+
lastMatchesVersion = coordinator.getMatchesVersion();
448451
}
449452

450453
private boolean blockMatchesQuery(Block block, String normalizedQuery)
@@ -487,7 +490,7 @@ private void startGetMatchingBlocksTask()
487490
(a, b) -> Integer.compare(b.getManhattanDistance(eyesPos),
488491
a.getManhattanDistance(eyesPos)));
489492
java.util.Iterator<ChunkSearcher.Result> it =
490-
coordinator.getMatches().iterator();
493+
coordinator.getReadyMatches().iterator();
491494
while(it.hasNext())
492495
{
493496
ChunkSearcher.Result r = it.next();
@@ -556,7 +559,7 @@ private void setBufferFromTask()
556559
}
557560
}
558561

559-
private void stopBuildingBuffer()
562+
private void stopBuildingBuffer(boolean discardCurrent)
560563
{
561564
if(getMatchingBlocksTask != null)
562565
getMatchingBlocksTask.cancel(true);
@@ -565,6 +568,17 @@ private void stopBuildingBuffer()
565568
compileVerticesTask.cancel(true);
566569
compileVerticesTask = null;
567570
bufferUpToDate = false;
568-
tracerEnds = null;
571+
if(discardCurrent)
572+
{
573+
tracerEnds = null;
574+
lastMatchingBlocks = null;
575+
foundCount = 0;
576+
if(vertexBuffer != null)
577+
{
578+
vertexBuffer.close();
579+
vertexBuffer = null;
580+
}
581+
bufferRegion = null;
582+
}
569583
}
570584
}

0 commit comments

Comments
 (0)