TraceLine
com.jsmacrosce.jsmacros.client.api.classes.render.components3d.TraceLine
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 blocksy: target y coordinate in blocksz: target z coordinate in blockscolor: 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 blocksy: target y coordinate in blocksz: target z coordinate in blockscolor: RGB source; only its low 24 bits are usedalpha: 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 blocksy: target y coordinate in blocksz: target z coordinate in blockscolor: RGB source; only its low 24 bits are usedalpha: value shifted into the top bytealwaysOnTop: whether to disable depth testing
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 copiedcolor: packed color; nonzero RGB with zero alpha becomes opaque, while zero-alpha black remains transparent
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 copiedcolor: RGB source; only its low 24 bits are usedalpha: value shifted into the top byte
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 copiedcolor: RGB source; only its low 24 bits are usedalpha: value shifted into the top bytealwaysOnTop: whether to disable depth testing
Methods
compareToSame
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
otherequals
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 valuegetAlpha
Returns the alpha byte of the packed color, from
0 (transparent) to 255 (opaque).Returns: the alpha value of the line's color.
getColor
Returns the RGB color without its alpha byte; use getAlpha() to read alpha.
Returns: the color of the line.
getPos
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
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
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 originsink: the buffer source the geometry goes intotickDelta: how far into the current tick this frame is, from 0 to 1
setAlpha
setAlwaysOnTop
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
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
setPos
Sets the target endpoint; the camera-side endpoint is recalculated during rendering.
Parameters:
x: the x coordinate of the targety: the y coordinate of the targetz: the z coordinate of the target
Returns: self for chaining