@@ -47,13 +47,15 @@ public final class WaypointsHack extends Hack implements RenderListener,
4747 private long lastDeathCreatedMs ;
4848
4949 private final SliderSetting textRenderDistance = new SliderSetting (
50- "Text render distance" , 127 , 16 , 1024 , 1 , ValueDisplay .INTEGER );
50+ "Text render distance" , 127 , 0 , 2000 , 1 , ValueDisplay .INTEGER );
51+ private final CheckboxSetting alwaysRenderText =
52+ new CheckboxSetting ("Always render text" , false );
5153 private final SliderSetting fadeDistance = new SliderSetting (
5254 "Waypoint fade distance" , 20 , 0 , 100 , 1 , ValueDisplay .INTEGER );
5355 private final SliderSetting maxDeathPositions = new SliderSetting (
5456 "Max death positions" , 4 , 0 , 20 , 1 , ValueDisplay .INTEGER );
5557 private final SliderSetting labelScale = new SliderSetting ("Label scale" ,
56- 2.0 , 0.5 , 15 .0 , 0.1 , ValueDisplay .DECIMAL );
58+ 2.0 , 0.5 , 10 .0 , 0.1 , ValueDisplay .DECIMAL );
5759 private final CheckboxSetting chatOnDeath =
5860 new CheckboxSetting ("Chat" , true );
5961 private final CheckboxSetting createDeathWaypoints =
@@ -72,6 +74,7 @@ public WaypointsHack()
7274 "Manage waypoints" , this .manager ));
7375
7476 addSetting (textRenderDistance );
77+ addSetting (alwaysRenderText );
7578 addSetting (fadeDistance );
7679 addSetting (maxDeathPositions );
7780 addSetting (chatOnDeath );
@@ -162,27 +165,44 @@ public void onRender(MatrixStack matrices, float partialTicks)
162165
163166 // labels near distance
164167 double dist = Math .sqrt (distSq );
165- if (dist <= textRenderDistance .getValue ())
168+ if (alwaysRenderText .isChecked ()
169+ || dist <= textRenderDistance .getValue ())
166170 {
167171 String title = w .getName () == null ? "" : w .getName ();
168172 String icon = iconChar (w .getIcon ());
169173 if (!icon .isEmpty ())
170174 title = icon + (title .isEmpty () ? "" : " " + title );
171175 String distanceText = (int )dist + " blocks" ;
172176 double baseY = wp .getY () + 1.2 ;
177+ double lx = wp .getX () + 0.5 ;
178+ double ly = baseY ;
179+ double lz = wp .getZ () + 0.5 ;
180+ // If always-render is on, anchor the label along the ray from
181+ // the
182+ // camera to the waypoint, to keep it within a stable render
183+ // range.
184+ if (alwaysRenderText .isChecked ())
185+ {
186+ Vec3d cam = RenderUtils .getCameraPos ();
187+ Vec3d target = new Vec3d (lx , ly , lz );
188+ Vec3d dir = target .subtract (cam );
189+ double len = dir .length ();
190+ if (len > 1e-3 )
191+ {
192+ double anchor = Math .min (len , 12.0 );
193+ Vec3d anchored = cam .add (dir .multiply (anchor / len ));
194+ lx = anchored .x ;
195+ ly = anchored .y ;
196+ lz = anchored .z ;
197+ }
198+ }
173199 float scale = (float )labelScale .getValue ();
174- // Compensate for distance so on-screen size stays roughly
175- // constant
176- double compensate = Math .max (1.0 , Math .sqrt (distSq ) * 0.1 );
177- scale *= (float )compensate ;
178200 // Keep a constant 10px separation using local pixel offset
179201 float sepPx = 10.0f ;
180- drawWorldLabel (matrices , title , wp .getX () + 0.5 , baseY ,
181- wp .getZ () + 0.5 , applyFade (w .getColor (), distSq ), scale ,
182- -sepPx );
183- drawWorldLabel (matrices , distanceText , wp .getX () + 0.5 , baseY ,
184- wp .getZ () + 0.5 , applyFade (w .getColor (), distSq ),
185- (float )(scale * 0.9f ), 0f );
202+ drawWorldLabel (matrices , title , lx , ly , lz ,
203+ applyFade (w .getColor (), distSq ), scale , -sepPx );
204+ drawWorldLabel (matrices , distanceText , lx , ly , lz ,
205+ applyFade (w .getColor (), distSq ), (float )(scale * 0.9f ), 0f );
186206 }
187207 }
188208 }
0 commit comments