Skip to content

Commit a9b4349

Browse files
committed
Updated ChestSearch
1 parent 683db11 commit a9b4349

File tree

4 files changed

+201
-85
lines changed

4 files changed

+201
-85
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ I did not, nor could I copy their code directly as most are Meteor based mods. S
187187
- Adjustable ESP and Waypoint colors
188188
- Adjustable search radius
189189
- Adjustable font size
190-
- Highlight open chests with X with an adjustable color and line thickness
190+
- Highlight open chests with X or an alternative color
191191

192192
![ChestSearch](https://i.imgur.com/OXuVeF5.png)
193193

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

Lines changed: 123 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
package net.wurstclient.hacks;
99

1010
import com.mojang.blaze3d.vertex.PoseStack;
11+
import java.util.ArrayList;
1112
import java.util.List;
1213
import net.minecraft.world.entity.Entity;
1314
import net.minecraft.world.phys.AABB;
@@ -152,85 +153,147 @@ public void onRender(PoseStack matrixStack, float partialTicks)
152153

153154
private void renderBoxes(PoseStack matrixStack)
154155
{
156+
ChestSearchHack csh = null;
157+
boolean canMarkOpened = false;
158+
ChestSearchHack.OpenedChestMarker markerMode =
159+
ChestSearchHack.OpenedChestMarker.LINE;
160+
if(!openedChests.isEmpty())
161+
{
162+
try
163+
{
164+
csh = net.wurstclient.WurstClient.INSTANCE
165+
.getHax().chestSearchHack;
166+
if(csh != null && csh.isMarkOpenedChest())
167+
{
168+
canMarkOpened = true;
169+
ChestSearchHack.OpenedChestMarker selected =
170+
csh.getOpenedChestMarker();
171+
if(selected != null)
172+
markerMode = selected;
173+
}
174+
}catch(Throwable ignored)
175+
{
176+
csh = null;
177+
canMarkOpened = false;
178+
}
179+
}
180+
181+
String curDimFull = MC.level == null ? "overworld"
182+
: MC.level.dimension().identifier().toString();
183+
String curDim = MC.level == null ? "overworld"
184+
: MC.level.dimension().identifier().getPath();
185+
155186
for(ChestEspGroup group : groups.allGroups)
156187
{
157188
if(!group.isEnabled())
158189
continue;
159190

160191
List<AABB> boxes = group.getBoxes();
192+
if(boxes.isEmpty())
193+
continue;
194+
161195
int quadsColor = group.getColorI(0x40);
162196
int linesColor = group.getColorI(0x80);
163197

164-
RenderUtils.drawSolidBoxes(matrixStack, boxes, quadsColor, false);
165-
RenderUtils.drawOutlinedBoxes(matrixStack, boxes, linesColor,
166-
false);
198+
List<AABB> openedBoxes = java.util.Collections.emptyList();
199+
List<AABB> closedBoxes = boxes;
200+
if(canMarkOpened)
201+
{
202+
List<AABB> opened = new ArrayList<>();
203+
List<AABB> closed = new ArrayList<>();
204+
for(AABB box : boxes)
205+
{
206+
if(isRecordedChest(box, curDimFull, curDim))
207+
opened.add(box);
208+
else
209+
closed.add(box);
210+
}
211+
openedBoxes = opened;
212+
closedBoxes = closed;
213+
}
167214

168-
// If ChestSearch marking is enabled, draw an X through opened
169-
// chests that match entries in the ChestSearch DB
170-
try
215+
boolean useRecolor = canMarkOpened
216+
&& markerMode == ChestSearchHack.OpenedChestMarker.RECOLOR
217+
&& !openedBoxes.isEmpty();
218+
219+
if(useRecolor && csh != null)
171220
{
172-
var csh = net.wurstclient.WurstClient.INSTANCE
173-
.getHax().chestSearchHack;
174-
if(csh != null && csh.isMarkOpenedChest()
175-
&& !openedChests.isEmpty())
221+
if(!closedBoxes.isEmpty())
222+
{
223+
RenderUtils.drawSolidBoxes(matrixStack, closedBoxes,
224+
quadsColor, false);
225+
RenderUtils.drawOutlinedBoxes(matrixStack, closedBoxes,
226+
linesColor, false);
227+
}
228+
229+
int markColor = csh.getMarkXColorARGB();
230+
int openedFillColor = (markColor & 0x00FFFFFF) | (0x40 << 24);
231+
int openedLineColor = markColor;
232+
RenderUtils.drawSolidBoxes(matrixStack, openedBoxes,
233+
openedFillColor, false);
234+
RenderUtils.drawOutlinedBoxes(matrixStack, openedBoxes,
235+
openedLineColor, false);
236+
}else
237+
{
238+
RenderUtils.drawSolidBoxes(matrixStack, boxes, quadsColor,
239+
false);
240+
RenderUtils.drawOutlinedBoxes(matrixStack, boxes, linesColor,
241+
false);
242+
243+
if(canMarkOpened
244+
&& markerMode == ChestSearchHack.OpenedChestMarker.LINE
245+
&& csh != null && !openedBoxes.isEmpty())
176246
{
177-
// base esp line color retained if needed
178-
String curDimFull = MC.level == null ? "overworld"
179-
: MC.level.dimension().identifier().toString();
180-
String curDim = MC.level == null ? "overworld"
181-
: MC.level.dimension().identifier().getPath();
182-
for(AABB box : boxes)
247+
for(AABB box : openedBoxes)
183248
{
184-
int boxMinX = (int)Math.floor(box.minX + 1e-6);
185-
int boxMaxX = (int)Math.floor(box.maxX - 1e-6);
186-
int boxMinY = (int)Math.floor(box.minY + 1e-6);
187-
int boxMaxY = (int)Math.floor(box.maxY - 1e-6);
188-
int boxMinZ = (int)Math.floor(box.minZ + 1e-6);
189-
int boxMaxZ = (int)Math.floor(box.maxZ - 1e-6);
190-
boolean matched = false;
191-
for(ChestEntry e : openedChests)
192-
{
193-
if(e == null || e.dimension == null)
194-
continue;
195-
// Accept either namespaced ("minecraft:the_nether")
196-
// or
197-
// plain path ("the_nether") dimension identifiers.
198-
String ed = e.dimension;
199-
if(!(ed.equals(curDimFull) || ed.equals(curDim)
200-
|| ed.endsWith(":" + curDim)))
201-
continue;
202-
int minX = Math.min(e.x, e.maxX);
203-
int maxX = Math.max(e.x, e.maxX);
204-
int minY = Math.min(e.y, e.maxY);
205-
int maxY = Math.max(e.y, e.maxY);
206-
int minZ = Math.min(e.z, e.maxZ);
207-
int maxZ = Math.max(e.z, e.maxZ);
208-
// check range overlap between the ESP box and
209-
// recorded chest bounds
210-
boolean overlap = boxMinX <= maxX && boxMaxX >= minX
211-
&& boxMinY <= maxY && boxMaxY >= minY
212-
&& boxMinZ <= maxZ && boxMaxZ >= minZ;
213-
if(overlap)
214-
{
215-
matched = true;
216-
break;
217-
}
218-
}
219-
if(matched)
220-
{
221-
ChestSearchMarkerRenderer.drawMarker(matrixStack,
222-
box, csh.getMarkXColorARGB(),
223-
csh.getMarkXThickness(), false);
224-
}
249+
ChestSearchMarkerRenderer.drawMarker(matrixStack, box,
250+
csh.getMarkXColorARGB(), csh.getMarkXThickness(),
251+
false);
225252
}
226253
}
227-
}catch(Throwable ignored)
228-
{
229-
// don't fail rendering if chestsearch isn't available
230254
}
231255
}
232256
}
233257

258+
private boolean isRecordedChest(AABB box, String curDimFull, String curDim)
259+
{
260+
if(openedChests.isEmpty())
261+
return false;
262+
263+
int boxMinX = (int)Math.floor(box.minX + 1e-6);
264+
int boxMaxX = (int)Math.floor(box.maxX - 1e-6);
265+
int boxMinY = (int)Math.floor(box.minY + 1e-6);
266+
int boxMaxY = (int)Math.floor(box.maxY - 1e-6);
267+
int boxMinZ = (int)Math.floor(box.minZ + 1e-6);
268+
int boxMaxZ = (int)Math.floor(box.maxZ - 1e-6);
269+
270+
for(ChestEntry e : openedChests)
271+
{
272+
if(e == null || e.dimension == null)
273+
continue;
274+
275+
String ed = e.dimension;
276+
boolean sameDimension = ed.equals(curDimFull) || ed.equals(curDim)
277+
|| ed.endsWith(":" + curDim);
278+
if(!sameDimension)
279+
continue;
280+
281+
int minX = Math.min(e.x, e.maxX);
282+
int maxX = Math.max(e.x, e.maxX);
283+
int minY = Math.min(e.y, e.maxY);
284+
int maxY = Math.max(e.y, e.maxY);
285+
int minZ = Math.min(e.z, e.maxZ);
286+
int maxZ = Math.max(e.z, e.maxZ);
287+
boolean overlap =
288+
boxMinX <= maxX && boxMaxX >= minX && boxMinY <= maxY
289+
&& boxMaxY >= minY && boxMinZ <= maxZ && boxMaxZ >= minZ;
290+
if(overlap)
291+
return true;
292+
}
293+
294+
return false;
295+
}
296+
234297
private void renderTracers(PoseStack matrixStack, float partialTicks)
235298
{
236299
for(ChestEspGroup group : groups.allGroups)

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

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,22 @@ public final class ChestSearchHack extends Hack
4545
private final ColorSetting espLineColor =
4646
new ColorSetting("ESP line", new java.awt.Color(0x22FF88));
4747
private final ColorSetting markXColor =
48-
new ColorSetting("Opened chest color", new java.awt.Color(0xFF2222));
48+
new ColorSetting("Opened chest color", new java.awt.Color(0xFF9900));
4949
private final SliderSetting markXThickness =
5050
new SliderSetting("Opened chest line thickness", 2.0, 0.5, 6.0, 0.5,
5151
ValueDisplay.DECIMAL);
52+
private final EnumSetting<OpenedChestMarker> openedChestMarker =
53+
new EnumSetting<>("Opened chest marker",
54+
"Choose how opened chests recorded by ChestSearch should be highlighted.",
55+
OpenedChestMarker.values(), OpenedChestMarker.LINE);
5256
private final CheckboxSetting markOpenedChest = new CheckboxSetting(
5357
"Mark opened chest",
5458
"Draw ESP/lines through opened chests that appear in your ChestSearch database.",
5559
true);
60+
private final CheckboxSetting recordedChestNotifications =
61+
new CheckboxSetting("Chat notifications",
62+
"Show a chat notification when ChestSearch records a container.",
63+
false);
5664
private final SliderSetting textScale = new SliderSetting("Text scale", 1.0,
5765
0.5, 1.25, 0.05, ValueDisplay.DECIMAL);
5866

@@ -74,9 +82,11 @@ public ChestSearchHack()
7482
addSetting(waypointColor);
7583
addSetting(espFillColor);
7684
addSetting(espLineColor);
85+
addSetting(markOpenedChest);
86+
addSetting(openedChestMarker);
7787
addSetting(markXColor);
7888
addSetting(markXThickness);
79-
addSetting(markOpenedChest);
89+
addSetting(recordedChestNotifications);
8090
}
8191

8292
public int getMarkXColorARGB()
@@ -100,6 +110,23 @@ public boolean isMarkOpenedChest()
100110
return markOpenedChest.isChecked();
101111
}
102112

113+
public OpenedChestMarker getOpenedChestMarker()
114+
{
115+
try
116+
{
117+
OpenedChestMarker marker = openedChestMarker.getSelected();
118+
return marker != null ? marker : OpenedChestMarker.LINE;
119+
}catch(Throwable t)
120+
{
121+
return OpenedChestMarker.LINE;
122+
}
123+
}
124+
125+
public boolean isRecordNotificationEnabled()
126+
{
127+
return recordedChestNotifications.isChecked();
128+
}
129+
103130
public int getCleanerGraceTicks()
104131
{
105132
return (int)(gracePeriodSec.getValueI() * 20);
@@ -220,4 +247,23 @@ public String toString()
220247
return displayName;
221248
}
222249
}
250+
251+
public enum OpenedChestMarker
252+
{
253+
LINE("Line"),
254+
RECOLOR("Recolor");
255+
256+
private final String displayName;
257+
258+
private OpenedChestMarker(String displayName)
259+
{
260+
this.displayName = displayName;
261+
}
262+
263+
@Override
264+
public String toString()
265+
{
266+
return displayName;
267+
}
268+
}
223269
}

src/main/java/net/wurstclient/mixin/GenericContainerScreenMixin.java

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1229,31 +1229,38 @@ public void removed()
12291229
&& wurst$shouldNotifyChestRecorded(serverIp, dimension, fx,
12301230
fy, fz))
12311231
{
1232-
chestRecordedNotificationSent = true;
1233-
// Notify player in chat that chest was recorded (on close)
1234-
try
1232+
ChestSearchHack csh = wurst$getChestSearchHack();
1233+
boolean allowNotification =
1234+
csh == null || csh.isRecordNotificationEnabled();
1235+
if(allowNotification)
12351236
{
1236-
String recordedMsg = "Chest recorded at position " + fx
1237-
+ "," + fy + "," + fz;
1238-
if(net.wurstclient.WurstClient.MC != null)
1237+
chestRecordedNotificationSent = true;
1238+
// Notify player in chat that chest was recorded (on
1239+
// close)
1240+
try
12391241
{
1240-
net.wurstclient.WurstClient.MC.execute(() -> {
1241-
try
1242-
{
1243-
if(net.wurstclient.WurstClient.MC.player != null
1244-
&& net.wurstclient.WurstClient.MC.player.containerMenu == net.wurstclient.WurstClient.MC.player.inventoryMenu)
1245-
net.wurstclient.WurstClient.MC.player
1246-
.displayClientMessage(
1247-
net.minecraft.network.chat.Component
1248-
.literal(recordedMsg),
1249-
false);
1250-
}catch(Throwable ignored)
1251-
{}
1252-
});
1242+
String recordedMsg = "Chest recorded at position "
1243+
+ fx + "," + fy + "," + fz;
1244+
if(net.wurstclient.WurstClient.MC != null)
1245+
{
1246+
net.wurstclient.WurstClient.MC.execute(() -> {
1247+
try
1248+
{
1249+
if(net.wurstclient.WurstClient.MC.player != null
1250+
&& net.wurstclient.WurstClient.MC.player.containerMenu == net.wurstclient.WurstClient.MC.player.inventoryMenu)
1251+
net.wurstclient.WurstClient.MC.player
1252+
.displayClientMessage(
1253+
net.minecraft.network.chat.Component
1254+
.literal(recordedMsg),
1255+
false);
1256+
}catch(Throwable ignored)
1257+
{}
1258+
});
1259+
}
1260+
}catch(Throwable ignored)
1261+
{
1262+
// ignore
12531263
}
1254-
}catch(Throwable ignored)
1255-
{
1256-
// ignore
12571264
}
12581265
}
12591266
// If loot export present, compare now and notify if mismatch

0 commit comments

Comments
 (0)