Skip to content

TraceLine ​

com.jsmacrosce.jsmacros.client.api.classes.render.components3d.TraceLine

Since1.9.0

A line from the camera toward a script-selected world-space target. The renderer updates its camera-side endpoint each frame; getPos() and setPos(double, double, double) refer to the target endpoint.

Constructors without an alwaysOnTop argument default to drawing over terrain. Use an overload with that argument or setAlwaysOnTop(boolean) to control depth testing.

js
const draw = Hud.createDraw3D();  
// A red line from the camera toward this target.  
draw.addTraceLine(0, 64, 0, Color.rgb(0xFF, 0x00, 0x00)).setAlwaysOnTop(false);  
draw.register();

Available in scripts as RenderElements.TraceLine.

Nested types ​

Constructors ​

new TraceLine ​

new TraceLine(double x, double y, double z, int color)#
Initializes a detached trace toward the target in world-space block coordinates. Nonzero RGB with zero alpha becomes opaque, while zero-alpha black remains transparent. Depth testing is disabled.

Parameters:

  • x: target x coordinate in blocks
  • y: target y coordinate in blocks
  • z: target z coordinate in blocks
  • color: packed color; zero-alpha handling is described above
new TraceLine(double x, double y, double z, int color, int alpha)#
Initializes a detached trace toward the target in world-space block coordinates. Alpha is shifted into the color's top byte without clamping or range validation; depth testing is disabled.

Parameters:

  • x: target x coordinate in blocks
  • y: target y coordinate in blocks
  • z: target z coordinate in blocks
  • color: RGB source; only its low 24 bits are used
  • alpha: value shifted into the top byte
new TraceLine(double x, double y, double z, int color, int alpha, boolean alwaysOnTop)#
Initializes a detached trace toward the target in world-space block coordinates. Alpha is shifted into the top byte without clamping or range validation; alwaysOnTop controls the inverse internal depth-test setting and does not ensure visibility.

Parameters:

  • x: target x coordinate in blocks
  • y: target y coordinate in blocks
  • z: target z coordinate in blocks
  • color: RGB source; only its low 24 bits are used
  • alpha: value shifted into the top byte
  • alwaysOnTop: whether to disable depth testing
new TraceLine(Pos3D pos, int color)#
Initializes a detached trace toward a copy of pos's coordinates in world-space blocks. A null position fails with NullPointerException; zero-alpha packed-color handling follows the renderer's opaque-bare-RGB rule. Depth testing is disabled.

Parameters:

  • pos: target position; its coordinates are copied
  • color: packed color; nonzero RGB with zero alpha becomes opaque, while zero-alpha black remains transparent
new TraceLine(Pos3D pos, int color, int alpha)#
Initializes a detached trace toward a copy of pos's coordinates in world-space blocks. A null position fails with NullPointerException. Alpha is shifted into the top byte without clamping or range validation; depth testing is disabled.

Parameters:

  • pos: target position; its coordinates are copied
  • color: RGB source; only its low 24 bits are used
  • alpha: value shifted into the top byte
new TraceLine(Pos3D pos, int color, int alpha, boolean alwaysOnTop)#
Initializes a detached trace toward a copy of pos's coordinates in world-space blocks. A null position fails with NullPointerException. Alpha is shifted into the top byte without clamping or range validation; alwaysOnTop controls the inverse internal depth-test setting and does not ensure visibility.

Parameters:

  • pos: target position; its coordinates are copied
  • color: RGB source; only its low 24 bits are used
  • alpha: value shifted into the top byte
  • alwaysOnTop: whether to disable depth testing

Methods ​

compareToSame ​

compareToSame(TraceLine other): intSince1.9.0#
Compares trace lines by their target endpoint's coordinates. Color is not considered; lines with the same target compare equal.

Parameters:

  • other: another trace line to order this one against
Returns: a negative number, zero, or a positive number as this line is before, the same as, or after other

equals ​

equals(Object o): boolean#
Compares traces by target endpoint value only; the camera-side endpoint, color, and depth setting are ignored. Only the same runtime class compares equal.

Parameters:

  • o: object to compare with
Returns: true for this object or a TraceLine of the exact same runtime class with an equal target endpoint; false for null or any other value

getAlpha ​

getAlpha(): intSince2.1.0#
Returns the alpha byte of the packed color, from 0 (transparent) to 255 (opaque).
Returns: the alpha value of the line's color.

getColor ​

getColor(): intSince2.1.0#
Returns the RGB color without its alpha byte; use getAlpha() to read alpha.
Returns: the color of the line.

getPos ​

getPos(): Pos3DSince2.1.0#
Returns a new position containing the target endpoint; modifying it does not move the line.
Returns: the position of the line's target.

hashCode ​

hashCode(): int#
Computes a hash from the current target endpoint only; changing the target can change the result.
Returns: hash derived from the current target endpoint

isAlwaysOnTop ​

isAlwaysOnTop(): booleanSince2.1.0#
Returns whether depth testing is disabled, so the line draws over terrain. Constructors without an alwaysOnTop argument default to true.
Returns: whether the line renders on top of everything else.

render ​

render(PoseStack poseStack, RenderSink sink, float tickDelta): voidSince1.9.0#
Updates the camera-side endpoint to the screen-centre crosshair direction, then renders the line. Called by the renderer, not by scripts.

Parameters:

  • poseStack: the world transform, already translated so the camera is at the origin
  • sink: the buffer source the geometry goes into
  • tickDelta: how far into the current tick this frame is, from 0 to 1

setAlpha ​

setAlpha(int alpha): TraceLineSince1.9.0#
Replaces the alpha byte without changing RGB. Values are not clamped; zero makes the line transparent.

Parameters:

  • alpha: the alpha value for the line's color
Returns: self for chaining

setAlwaysOnTop ​

setAlwaysOnTop(boolean alwaysOnTop): voidSince2.1.0#
Sets whether depth testing is disabled (true, draws over terrain) or enabled (false).

Parameters:

  • alwaysOnTop: whether the line should render on top of everything else.

setColor ​

setColor(int color): TraceLineSince1.9.0#
Sets the line color, making non-black RGB opaque when its alpha byte is zero. An all-zero color stays transparent; use setColor(int, int) to set alpha explicitly.

Parameters:

  • color: the color of the line
Returns: self for chaining
setColor(int color, int alpha): TraceLineSince1.9.0#
Sets the RGB color and alpha separately; the alpha is packed into the top byte and is not clamped.

Parameters:

  • color: the color of the line
  • alpha: the alpha value of the line's color
Returns: self for chaining

setPos ​

setPos(double x, double y, double z): TraceLineSince1.9.0#
Sets the target endpoint; the camera-side endpoint is recalculated during rendering.

Parameters:

  • x: the x coordinate of the target
  • y: the y coordinate of the target
  • z: the z coordinate of the target
Returns: self for chaining
setPos(Pos3D pos): TraceLineSince1.9.0#
Sets the target endpoint from the coordinates in pos; later changes to pos do not move the line.

Parameters:

  • pos: the position of the target
Returns: self for chaining