Skip to content

Commit 01ee9c3

Browse files
committed
Updated Breadcrumbs
1 parent 9b9eb08 commit 01ee9c3

File tree

4 files changed

+147
-30
lines changed

4 files changed

+147
-30
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ I have no other experience in the field of Minecraft and have never used any oth
183183
### EnchantmentHandler
184184
- Displays an inventory overlay for chests containing enchanted items, listing each item’s slot number, enchantments, and providing quick-take options (single or by category).
185185
- Renders on top of the vanilla screen darkening, stays aligned beside the container and has an adjustable size and font scaling
186-
- Works with books and gear and will separate them in the list by category and type
186+
- Works with books, potions and gear and will separate them in the list by category and type
187187

188188
![Chest](https://i.imgur.com/6u9S2OD.png)
189189

src/main/java/net/wurstclient/clickgui/ClickGui.java

Lines changed: 42 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import net.wurstclient.WurstClient;
3636
import net.wurstclient.clickgui.components.FeatureButton;
3737
import net.wurstclient.hacks.ClickGuiHack;
38+
import net.wurstclient.hacks.TooManyHaxHack;
3839
import net.wurstclient.settings.Setting;
3940
import net.wurstclient.util.RenderUtils;
4041
import net.wurstclient.util.json.JsonUtils;
@@ -67,6 +68,10 @@ public ClickGui(Path windowsFile)
6768

6869
public void init()
6970
{
71+
// Clear existing windows/popups so repeated init() calls rebuild
72+
// the UI instead of duplicating entries.
73+
windows.clear();
74+
popups.clear();
7075
updateColors();
7176

7277
LinkedHashMap<Category, Window> windowMap = new LinkedHashMap<>();
@@ -78,16 +83,41 @@ public void init()
7883
features.addAll(WURST.getCmds().getAllCmds());
7984
features.addAll(WURST.getOtfs().getAllOtfs());
8085

86+
TooManyHaxHack tooManyHax = WURST.getHax().tooManyHaxHack;
8187
for(Feature f : features)
88+
{
89+
// When TooManyHax is enabled, hide hacks that it disabled from
90+
// the ClickGUI to avoid cluttering the UI. The Navigator should
91+
// keep showing all features, so we only apply this filter here.
92+
if(f instanceof net.wurstclient.hack.Hack && tooManyHax.isEnabled()
93+
&& tooManyHax.isBlocked(f)
94+
&& !((net.wurstclient.hack.Hack)f).isEnabled())
95+
{
96+
continue;
97+
}
98+
8299
if(f.getCategory() != null)
83100
windowMap.get(f.getCategory()).add(new FeatureButton(f));
101+
}
84102
// add favorites window entries (show favorites in the Favorites
85-
// category)
103+
// category). Respect TooManyHax hiding behaviour here as well so
104+
// favorite hacks disabled by TooManyHax don't appear in ClickGUI.
86105
for(Feature f : features)
87-
if(f instanceof net.wurstclient.hack.Hack
88-
&& ((net.wurstclient.hack.Hack)f).isFavorite())
89-
windowMap.get(net.wurstclient.Category.FAVORITES)
90-
.add(new FeatureButton(f));
106+
{
107+
if(!(f instanceof net.wurstclient.hack.Hack
108+
&& ((net.wurstclient.hack.Hack)f).isFavorite()))
109+
continue;
110+
111+
if(f instanceof net.wurstclient.hack.Hack && tooManyHax.isEnabled()
112+
&& tooManyHax.isBlocked(f)
113+
&& !((net.wurstclient.hack.Hack)f).isEnabled())
114+
{
115+
continue;
116+
}
117+
118+
windowMap.get(net.wurstclient.Category.FAVORITES)
119+
.add(new FeatureButton(f));
120+
}
91121
// ensure favourites window is sorted alphabetically
92122
Window favWindow = windowMap.get(net.wurstclient.Category.FAVORITES);
93123
if(favWindow != null)
@@ -329,7 +359,9 @@ private boolean handlePopupMouseClick(double mouseX, double mouseY,
329359
int cMouseY = (int)(mouseY - y0);
330360
popup.handleMouseClick(cMouseX, cMouseY, mouseButton);
331361

332-
popups.remove(i);
362+
// remove by object to avoid index-based removal issues if the
363+
// list was modified concurrently
364+
popups.remove(popup);
333365
popups.add(popup);
334366
return true;
335367
}
@@ -380,8 +412,10 @@ else if(!window.isMinimized())
380412

381413
}else
382414
continue;
383-
384-
windows.remove(i);
415+
416+
// remove by object to avoid index-based removal issues if the
417+
// windows list was modified concurrently
418+
windows.remove(window);
385419
windows.add(window);
386420
break;
387421
}

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

Lines changed: 57 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import java.util.UUID;
1818

1919
import net.minecraft.client.util.math.MatrixStack;
20+
import net.minecraft.world.dimension.DimensionType;
2021
import net.minecraft.util.math.Vec3d;
2122
import net.wurstclient.Category;
2223
import net.wurstclient.SearchTags;
@@ -126,14 +127,26 @@ public String getValueString(double v)
126127
net.wurstclient.settings.SliderSetting.ValueDisplay.INTEGER);
127128
private final CheckboxSetting paused = new CheckboxSetting("Paused", false);
128129

129-
private final Deque<Vec3d> points = new ArrayDeque<>();
130+
private final Deque<Point> points = new ArrayDeque<>();
130131
// map from player uuid to their breadcrumb points
131-
private final Map<UUID, Deque<Vec3d>> otherPoints = new HashMap<>();
132+
private final Map<UUID, Deque<Point>> otherPoints = new HashMap<>();
132133
// previous target selection to detect changes
133134
private Target prevTarget = null;
134135
// previous random toggle so we can clean up registry on toggle off
135136
private boolean prevRandom = false;
137+
136138
// per-player colors are managed via PlayerColorRegistry
139+
private static final class Point
140+
{
141+
final Vec3d pos;
142+
final DimensionType dim;
143+
144+
Point(Vec3d pos, DimensionType dim)
145+
{
146+
this.pos = pos;
147+
this.dim = dim;
148+
}
149+
}
137150

138151
public BreadcrumbsHack()
139152
{
@@ -202,17 +215,18 @@ public void onUpdate()
202215
// Do not add new points while paused
203216
if(paused.isChecked())
204217
return;
205-
Vec3d here =
218+
Vec3d herePos =
206219
new Vec3d(MC.player.getX(), MC.player.getY(), MC.player.getZ());
220+
DimensionType hereDim = MC.world.getDimension();
207221
if(points.isEmpty())
208222
{
209-
points.add(here);
223+
points.add(new Point(herePos, hereDim));
210224
return;
211225
}
212-
Vec3d last = points.peekLast();
213-
if(movedEnough(last, here, sectionLen.getValue()))
226+
Vec3d last = points.peekLast().pos;
227+
if(movedEnough(last, herePos, sectionLen.getValue()))
214228
{
215-
points.add(here);
229+
points.add(new Point(herePos, hereDim));
216230
int limit = computeMaxSections(maxSections.getValueI());
217231
boolean infinite = limit >= MAX_SECTIONS_INFINITE;
218232
while(!infinite && points.size() > limit)
@@ -222,7 +236,6 @@ public void onUpdate()
222236
// Track other players if enabled
223237
if(sel == Target.OTHERS || sel == Target.BOTH)
224238
{
225-
int nextIndex = 0;
226239
for(var p : MC.world.getPlayers())
227240
{
228241
if(p == MC.player)
@@ -241,18 +254,19 @@ public void onUpdate()
241254
.assignDeterministic(id, "Breadcrumbs");
242255
}
243256
}
244-
Deque<Vec3d> dq =
257+
Deque<Point> dq =
245258
otherPoints.computeIfAbsent(id, k -> new ArrayDeque<>());
246259
Vec3d pos = new Vec3d(p.getX(), p.getY(), p.getZ());
260+
DimensionType pdim = MC.world.getDimension();
247261
if(dq.isEmpty())
248262
{
249-
dq.add(pos);
263+
dq.add(new Point(pos, pdim));
250264
continue;
251265
}
252-
Vec3d lastp = dq.peekLast();
266+
Vec3d lastp = dq.peekLast().pos;
253267
if(movedEnough(lastp, pos, sectionLen.getValue()))
254268
{
255-
dq.add(pos);
269+
dq.add(new Point(pos, pdim));
256270
int limit = computeMaxSections(maxSections.getValueI());
257271
boolean infinite = limit >= MAX_SECTIONS_INFINITE;
258272
while(!infinite && dq.size() > limit)
@@ -304,23 +318,45 @@ public void onRender(MatrixStack matrixStack, float partialTicks)
304318
double thickness = lineThickness.getValue();
305319
Target sel = target.getSelected();
306320
// render your trail only when YOU or BOTH selected
307-
if((sel == Target.YOU || sel == Target.BOTH) && points.size() >= 2)
321+
if((sel == Target.YOU || sel == Target.BOTH))
308322
{
309-
List<Vec3d> list = new ArrayList<>(points);
310-
int c = RenderUtils.toIntColor(new float[]{color.getColorF()[0],
311-
color.getColorF()[1], color.getColorF()[2]}, 0.8F);
312-
RenderUtils.drawCurvedLine(matrixStack, list, c, false, thickness);
323+
DimensionType curDim = MC.world.getDimension();
324+
List<Vec3d> list = new ArrayList<>();
325+
for(Point p : points)
326+
{
327+
if(p.dim == curDim)
328+
list.add(p.pos);
329+
}
330+
if(list.size() >= 2)
331+
{
332+
int c =
333+
RenderUtils
334+
.toIntColor(
335+
new float[]{color.getColorF()[0],
336+
color.getColorF()[1], color.getColorF()[2]},
337+
0.8F);
338+
RenderUtils.drawCurvedLine(matrixStack, list, c, false,
339+
thickness);
340+
}
313341
}
314342

315343
// render other players' trails
316344
if(sel == Target.OTHERS || sel == Target.BOTH)
317345
{
346+
DimensionType curDim = MC.world.getDimension();
318347
for(var entry : otherPoints.entrySet())
319348
{
320-
Deque<Vec3d> dq = entry.getValue();
321-
if(dq.size() < 2)
322-
continue;
349+
Deque<Point> dq = entry.getValue();
323350
UUID id = entry.getKey();
351+
352+
List<Vec3d> l = new ArrayList<>();
353+
for(Point p : dq)
354+
if(p.dim == curDim)
355+
l.add(p.pos);
356+
357+
if(l.size() < 2)
358+
continue;
359+
324360
int oc;
325361
if(randomBrightColors.isChecked())
326362
{
@@ -339,7 +375,7 @@ public void onRender(MatrixStack matrixStack, float partialTicks)
339375
otherColor.getColorF()[0], otherColor.getColorF()[1],
340376
otherColor.getColorF()[2]}, 0.8F);
341377
}
342-
List<Vec3d> l = new ArrayList<>(dq);
378+
343379
RenderUtils.drawCurvedLine(matrixStack, l, oc, false,
344380
thickness);
345381
}

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

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,15 @@ private void disableBlockedHacks()
9191

9292
((Hack)feature).setEnabled(false);
9393
}
94+
// Refresh ClickGUI so hacks disabled by TooManyHax are hidden there
95+
try
96+
{
97+
if(WURST.getGui() != null)
98+
WURST.getGui().init();
99+
}catch(Exception e)
100+
{
101+
// ignore GUI refresh failures
102+
}
94103
}
95104

96105
public ArrayList<Path> listProfiles()
@@ -140,6 +149,14 @@ public void setBlocked(Feature feature, boolean blocked)
140149
blockedFeatures.remove(feature);
141150

142151
file.save();
152+
try
153+
{
154+
if(WURST.getGui() != null)
155+
WURST.getGui().init();
156+
}catch(Exception e)
157+
{
158+
// ignore GUI refresh failures
159+
}
143160
}
144161

145162
public void blockAll()
@@ -163,12 +180,42 @@ public void blockAll()
163180
.sort(Comparator.comparing(f -> f.getName().toLowerCase()));
164181

165182
file.save();
183+
try
184+
{
185+
if(WURST.getGui() != null)
186+
WURST.getGui().init();
187+
}catch(Exception e)
188+
{
189+
// ignore GUI refresh failures
190+
}
166191
}
167192

168193
public void unblockAll()
169194
{
170195
blockedFeatures.clear();
171196
file.save();
197+
try
198+
{
199+
if(WURST.getGui() != null)
200+
WURST.getGui().init();
201+
}catch(Exception e)
202+
{
203+
// ignore GUI refresh failures
204+
}
205+
}
206+
207+
@Override
208+
protected void onDisable()
209+
{
210+
// Rebuild ClickGUI so previously hidden hacks reappear
211+
try
212+
{
213+
if(WURST.getGui() != null)
214+
WURST.getGui().init();
215+
}catch(Exception e)
216+
{
217+
// ignore GUI refresh failures
218+
}
172219
}
173220

174221
public List<Feature> getBlockedFeatures()

0 commit comments

Comments
 (0)