Skip to content

Commit f311f2e

Browse files
committed
Fixed LootSearch, Updated ChestSearch
1 parent bbf4dbc commit f311f2e

11 files changed

Lines changed: 3270 additions & 3081 deletions

File tree

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,9 +432,10 @@ Reports number of waypoints changed.
432432
- Using [my fork](https://github.com/cev-api/SeedMapper-CevAPI) of [SeedMapper](https://github.com/xpple/SeedMapper/) you can export loot tables for selected/all structures and then parse that information using the same UI as ChestSearch.
433433
- Sorted by closest chest.
434434
- You can search for specific loot and set a waypoint towards it.
435+
- Supports enchantments.
435436
- Will not function without a valid SeedMapper loot export JSON for the server you're in.
436437

437-
![Loot](https://i.imgur.com/7pkTPxW.png)
438+
![Loot](https://i.imgur.com/pe7bbAB.png)
438439

439440
### SpearAssist
440441
- Boost Modes:

src/main/java/net/wurstclient/clickgui/screens/ChestSearchScreen.java

Lines changed: 54 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ public final class ChestSearchScreen extends Screen
5959
private int scrollThumbTop = 0;
6060
private int scrollThumbHeight = 0;
6161
private double scrollMaxOffset = 0.0;
62+
private int contentWidth = 340;
6263

6364
// persist temp waypoints across screen instances
6465
private static final class TempWp
@@ -122,6 +123,23 @@ private static String makeEntryKey(ChestEntry entry)
122123
+ formatBlockPos(max);
123124
}
124125

126+
private int getContentWidth()
127+
{
128+
int max = Math.max(0, this.width - 4);
129+
int width = contentWidth;
130+
if(width < 340)
131+
width = 340;
132+
if(width > max)
133+
width = max;
134+
return width;
135+
}
136+
137+
private int getContentLeft()
138+
{
139+
int width = getContentWidth();
140+
return (this.width - width) / 2;
141+
}
142+
125143
public static boolean isWaypointActive(String dimension, BlockPos pos)
126144
{
127145
String key = makePosKey(dimension, pos);
@@ -577,7 +595,7 @@ private void rebuildRowButtons()
577595
}
578596
rowButtons.clear();
579597

580-
int x = this.width / 2 - 150;
598+
int x = getContentLeft();
581599
int resultsTop = getResultsTop();
582600
int y = resultsTop - (int)Math.round(scrollOffset);
583601
int visibleTop = resultsTop;
@@ -708,7 +726,7 @@ private void rebuildRowButtons()
708726
.create(Component.literal("ESP active")));
709727
}
710728
// position esp and wp buttons to the right side of the result box
711-
int boxRight = x + 340;
729+
int boxRight = x + getContentWidth();
712730
int wpWidth = 56;
713731
int espWidth = isLootManager ? 0 : 40;
714732
int deleteWidth = 56;
@@ -1004,8 +1022,37 @@ public void render(GuiGraphics context, int mouseX, int mouseY, float delta)
10041022
int sfY = 18;
10051023
context.fill(sfX - 2, sfY - 2, sfX + 222, sfY + 22, 0xFF333333);
10061024
int summaryY = sfY + 24;
1025+
int shown = results == null ? 0 : results.size();
1026+
String limiter = limitedResults
1027+
? " (showing first " + WurstClient.INSTANCE.getHax().chestSearchHack
1028+
.getMaxSearchResults() + ")"
1029+
: "";
1030+
java.util.ArrayList<String> summaryExtras = new java.util.ArrayList<>();
1031+
if(radiusFilterActive && radiusLimitBlocks < Integer.MAX_VALUE)
1032+
summaryExtras.add("radius <= " + radiusLimitBlocks + " blocks");
1033+
if(radiusFilterActive && radiusFilteredOut > 0)
1034+
summaryExtras.add(radiusFilteredOut + " outside radius");
1035+
String summaryExtra = summaryExtras.isEmpty() ? ""
1036+
: " (" + String.join(", ", summaryExtras) + ")";
1037+
String matchLabel =
1038+
currentQuery.isEmpty() ? "Listed items" : "Matching items";
1039+
String summary = "Showing " + shown + "/" + totalMatches + limiter
1040+
+ summaryExtra + " - " + matchLabel + ": " + totalMatchingItems
1041+
+ " - Tracking " + totalChestsLogged + " chests, "
1042+
+ totalItemsLogged + " items";
1043+
int summaryPadding = 8;
1044+
int summaryWidth = this.font.width(summary) + summaryPadding * 2;
1045+
if(summaryWidth > this.width - 4)
1046+
summaryWidth = this.width - 4;
1047+
int desiredWidth = Math.max(340, summaryWidth);
1048+
if(desiredWidth != contentWidth)
1049+
{
1050+
contentWidth = desiredWidth;
1051+
clampScroll();
1052+
rebuildRowButtons();
1053+
}
10071054
// draw result panels BEFORE super.render so buttons draw on top
1008-
int x = this.width / 2 - 150;
1055+
int x = getContentLeft();
10091056
int visibleTop = getResultsTop();
10101057
int visibleBottom = getVisibleBottom();
10111058
int visibleHeight = Math.max(0, visibleBottom - visibleTop);
@@ -1032,7 +1079,7 @@ else if(scrollOffset > maxScroll)
10321079
int y = visibleTop - (int)Math.round(scrollOffset);
10331080

10341081
int trackWidth = 8;
1035-
int trackX = x + 340 + 6;
1082+
int trackX = x + getContentWidth() + 6;
10361083
int buttonWidth =
10371084
scrollUpButton != null ? scrollUpButton.getWidth() : 44;
10381085
int buttonHeight =
@@ -1118,10 +1165,11 @@ else if(scrollOffset > maxScroll)
11181165
if(y > visibleBottom)
11191166
break;
11201167
int bgColor = pinnedEntry ? 0x80423210 : 0x80202020;
1121-
context.fill(x - 6, y, x + 340, y + boxHeight, bgColor);
1168+
context.fill(x - 6, y, x + getContentWidth(), y + boxHeight,
1169+
bgColor);
11221170
int headerY = y + 6;
11231171
String locationLabel = formatLocationLabel(e, dim);
1124-
int boxRight = x + 340;
1172+
int boxRight = x + getContentWidth();
11251173
// compute available width for location text (leave space for
11261174
// buttons)
11271175
int wpWidth = 56;
@@ -1330,28 +1378,6 @@ else if(scrollOffset > maxScroll)
13301378
}
13311379
// now draw children (buttons etc.) on top
13321380
super.render(context, mouseX, mouseY, delta);
1333-
int shown = results == null ? 0 : results.size();
1334-
String limiter = limitedResults
1335-
? " (showing first " + WurstClient.INSTANCE.getHax().chestSearchHack
1336-
.getMaxSearchResults() + ")"
1337-
: "";
1338-
java.util.ArrayList<String> summaryExtras = new java.util.ArrayList<>();
1339-
if(radiusFilterActive && radiusLimitBlocks < Integer.MAX_VALUE)
1340-
summaryExtras.add("radius <= " + radiusLimitBlocks + " blocks");
1341-
if(radiusFilterActive && radiusFilteredOut > 0)
1342-
summaryExtras.add(radiusFilteredOut + " outside radius");
1343-
String extra = summaryExtras.isEmpty() ? ""
1344-
: " (" + String.join(", ", summaryExtras) + ")";
1345-
String matchLabel =
1346-
currentQuery.isEmpty() ? "Listed items" : "Matching items";
1347-
String summary =
1348-
"Showing " + shown + "/" + totalMatches + limiter + extra + " - "
1349-
+ matchLabel + ": " + totalMatchingItems + " - Tracking "
1350-
+ totalChestsLogged + " chests, " + totalItemsLogged + " items";
1351-
int summaryPadding = 8;
1352-
int summaryWidth = this.font.width(summary) + summaryPadding * 2;
1353-
if(summaryWidth > this.width - 4)
1354-
summaryWidth = this.width - 4;
13551381
int summaryHalf = summaryWidth / 2;
13561382
int summaryCenter = this.width / 2;
13571383
int summaryLeft = Math.max(0, summaryCenter - summaryHalf);

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

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,14 @@ protected void onEnable()
5353
if(f == null)
5454
{
5555
if(WurstClient.MC != null && WurstClient.MC.player != null)
56+
{
5657
WurstClient.MC.player
5758
.displayClientMessage(
5859
net.minecraft.network.chat.Component.literal(
5960
"No loot export found for this server."),
6061
false);
62+
sendLootSearchDebug(serverIp, dir);
63+
}
6164
setEnabled(false);
6265
return;
6366
}
@@ -72,4 +75,47 @@ protected void onEnable()
7275
}
7376
setEnabled(false);
7477
}
78+
79+
private void sendLootSearchDebug(String serverIp, File dir)
80+
{
81+
if(WurstClient.MC == null || WurstClient.MC.player == null)
82+
return;
83+
84+
String ip = serverIp == null ? "<null>" : serverIp;
85+
String dirPath = dir == null ? "<null>" : dir.getAbsolutePath();
86+
WurstClient.MC.player
87+
.displayClientMessage(net.minecraft.network.chat.Component
88+
.literal("LootSearch debug: serverIp=" + ip), false);
89+
WurstClient.MC.player
90+
.displayClientMessage(net.minecraft.network.chat.Component
91+
.literal("LootSearch debug: lootDir=" + dirPath), false);
92+
93+
if(dir == null || !dir.exists() || !dir.isDirectory())
94+
return;
95+
96+
File[] files =
97+
dir.listFiles((d, name) -> name.toLowerCase().endsWith(".json"));
98+
if(files == null || files.length == 0)
99+
{
100+
WurstClient.MC.player.displayClientMessage(
101+
net.minecraft.network.chat.Component.literal(
102+
"LootSearch debug: no .json files in lootDir"),
103+
false);
104+
return;
105+
}
106+
107+
StringBuilder names = new StringBuilder();
108+
for(int i = 0; i < files.length && i < 10; i++)
109+
{
110+
if(i > 0)
111+
names.append(", ");
112+
names.append(files[i].getName());
113+
}
114+
if(files.length > 10)
115+
names.append(" ... (").append(files.length).append(" total)");
116+
117+
WurstClient.MC.player
118+
.displayClientMessage(net.minecraft.network.chat.Component
119+
.literal("LootSearch debug: files=" + names), false);
120+
}
75121
}

0 commit comments

Comments
 (0)