Skip to content

TraceLine.Builder ​

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

Since1.9.0

Configures a trace line before building it. Defaults are a white, fully opaque line targeting the origin and drawn over terrain. build() returns a detached line; buildAndAdd() adds it to this builder's overlay.

Nested type declared in TraceLine.

Constructors ​

new TraceLine.Builder ​

new TraceLine.Builder(Draw3D parent)#
Creates a builder with an origin target, opaque white color, and alwaysOnTop enabled. The parent is stored without validation and is used only by buildAndAdd(); it may be null for detached build() calls, but buildAndAdd() then fails with NullPointerException.

Parameters:

  • parent: overlay for buildAndAdd(), or null when only building detached lines

Methods ​

alpha ​

alpha(int alpha): TraceLine.BuilderSince1.9.0#
Sets alpha independently of the stored colour integer; the value is not clamped.

Parameters:

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

alwaysOnTop ​

alwaysOnTop(boolean alwaysOnTop): TraceLine.BuilderSince2.0.0#
Sets whether the line is drawn over terrain; the default is true.
const draw = Hud.createDraw3D();
draw.traceLineBuilder().pos(0, 64, 0).alwaysOnTop(false).buildAndAdd();
draw.register();

Parameters:

  • alwaysOnTop: whether terrain depth should be ignored when drawing the line
Returns: self for chaining

build ​

build(): TraceLineSince1.9.0#
Builds a detached line; add it to an overlay before it can render.
Returns: the build line

buildAndAdd ​

buildAndAdd(): TraceLineSince1.9.0#
Builds the line and adds it to this builder's overlay. It renders only while the overlay is registered.
Returns: the build line

color ​

color(int color): TraceLine.BuilderSince1.9.0#
Sets the packed colour and derives alpha from its top byte after applying the renderer's zero-alpha rule; non-black RGB with a zero alpha becomes opaque.

Parameters:

  • color: the color of the line
Returns: self for chaining
color(int color, int alpha): TraceLine.BuilderSince1.9.0#
Stores the colour integer unchanged and sets alpha separately; neither value is clamped.

Parameters:

  • color: the color of the line
  • alpha: the alpha value of the line's color
Returns: self for chaining
color(int r, int g, int b): TraceLine.BuilderSince1.9.0#
Sets packed RGB using (r << 16) | (g << 8) | b; values are not clamped and alpha is unchanged.

Parameters:

  • r: the red component of the color
  • g: the green component of the color
  • b: the blue component of the color
Returns: self for chaining
color(int r, int g, int b, int a): TraceLine.BuilderSince1.9.0#
Sets packed RGB as in color(int, int, int) and sets alpha separately; values are not clamped.

Parameters:

  • r: the red component of the color
  • g: the green component of the color
  • b: the blue component of the color
  • a: the alpha value of the color
Returns: self for chaining

getAlpha ​

getAlpha(): intSince1.9.0#
Returns the alpha value stored by the builder, initially 255. color(int) derives it from the supplied packed colour.
Returns: the alpha value of the line's color

getColor ​

getColor(): intSince1.9.0#
Returns the colour integer stored by the builder unchanged.
Returns: the color of the line

getPos ​

getPos(): Pos3DSince1.9.0#
Returns the target position held by the builder. It defaults to the origin; a position passed to pos(Pos3D) is retained by reference.
Returns: the position of the target

pos ​

pos(Pos3D pos): TraceLine.BuilderSince1.9.0#
Sets the world-space target endpoint; the camera-side endpoint is computed each render frame.

Parameters:

  • pos: the position of the target
Returns: self for chaining
Sets the target to the block position's integer coordinates (the block corner, with no half-block offset).

Parameters:

  • pos: the position of the target
Returns: self for chaining
pos(int x, int y, int z): TraceLine.BuilderSince1.9.0#
Sets the target using block coordinates; integer coordinates identify block corners, not centers.

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