1717import java .util .UUID ;
1818
1919import net .minecraft .client .util .math .MatrixStack ;
20+ import net .minecraft .world .dimension .DimensionType ;
2021import net .minecraft .util .math .Vec3d ;
2122import net .wurstclient .Category ;
2223import 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 }
0 commit comments