Skip to content

Line3D ​

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

A fixed line segment between two world-space points.

Coordinates are in blocks. getColor() returns RGB without alpha; use getAlpha() to read the alpha separately. cull controls depth testing: true lets geometry obscure the line, while false draws it on top.

js
const draw = Hud.createDraw3D();  
// a green line across one block, hidden by anything in front of it
const line = draw.addLine(0, 64, 0, 1, 65, 0, Color.rgb(0x00, 0xFF, 0x00), true);  
Chat.log(`runs from ${line.getPos1()} to ${line.getPos2()}`);  
draw.register();

Available in scripts as RenderElements.Line3D.

Nested types ​

Constructors ​

new Line3D ​

new Line3D(double x1, double y1, double z1, double x2, double y2, double z2, int color, boolean cull)#
Initializes a detached line segment with ordered endpoints in block coordinates. A packed color with zero alpha becomes opaque when its RGB bits are nonzero; zero-alpha black remains transparent.

Parameters:

  • x1: x coordinate of the first endpoint, in blocks
  • y1: y coordinate of the first endpoint, in blocks
  • z1: z coordinate of the first endpoint, in blocks
  • x2: x coordinate of the second endpoint, in blocks
  • y2: y coordinate of the second endpoint, in blocks
  • z2: z coordinate of the second endpoint, in blocks
  • color: packed ARGB color; a zero alpha byte is fixed as described above
  • cull: whether depth testing is enabled
new Line3D(double x1, double y1, double z1, double x2, double y2, double z2, int color, int alpha, boolean cull)#
Initializes a detached line segment with ordered endpoints in block coordinates. Alpha is packed without clamping and replaces any alpha bits in color.

Parameters:

  • x1: x coordinate of the first endpoint, in blocks
  • y1: y coordinate of the first endpoint, in blocks
  • z1: z coordinate of the first endpoint, in blocks
  • x2: x coordinate of the second endpoint, in blocks
  • y2: y coordinate of the second endpoint, in blocks
  • z2: z coordinate of the second endpoint, in blocks
  • color: RGB source; only its low 24 bits are used
  • alpha: value shifted into the top byte, without range validation
  • cull: whether depth testing is enabled

Fields ​

color ​

color: intSince1.0.6#
The line colour packed as ARGB, with alpha in the top byte. Writable; see setColor(int) for alpha handling.

cull ​

cull: booleanSince1.0.6#
Whether the line is depth tested; true allows geometry to obscure it.

pos ​

pos: Vec3DSince1.0.6#
The line's endpoints as a segment, in the order supplied. Writable directly or through setPos(double, double, double, double, double, double).

Methods ​

compareToSame ​

compareToSame(Line3D o): intSince1.8.4#
Orders lines by their endpoint coordinates, in endpoint order; colour and culling do not affect the comparison. Reversing a segment's endpoints can change its order.

Parameters:

  • o: another 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 o

equals ​

equals(Object o): boolean#
Tests equality by exact runtime class and endpoint value; color and depth testing are ignored. Endpoint order matters, and a null position compares equal only to another null position.

Parameters:

  • o: object to compare with
Returns: true for this object or an instance of the exact same runtime class with an equal position; false otherwise

getAlpha ​

getAlpha(): intSince2.0.0#
Returns the packed colour's top byte.
Returns: the alpha byte, from 0 to 255.

getColor ​

getColor(): intSince2.0.0#
Returns the line colour's low 24 bits; read alpha separately with getAlpha().
Returns: the RGB colour, without alpha.

getPos ​

getPos(): Vec3DSince2.0.0#
Returns a copy of the line's endpoint coordinates.
Returns: the positions of the line.

getPos1 ​

getPos1(): Pos3DSince2.0.0#
Returns a new position for the first endpoint; modifying it does not move the line.
Returns: the first position of the line.

getPos2 ​

getPos2(): Pos3DSince2.0.0#
Returns a new position for the second endpoint; modifying it does not move the line.
Returns: the second position of the line.

hashCode ​

hashCode(): int#
Computes a hash from the current endpoint value only; changing the position can change this result.
Returns: hash derived from the current position; it is not stable across position changes

isAlwaysOnTop ​

isAlwaysOnTop(): booleanSince2.0.0#
Returns the inverse of the line's cull setting.
Returns: true when depth testing is disabled.

setAlpha ​

setAlpha(int alpha): voidSince1.1.8#
Replaces the top byte of the packed colour without changing its RGB bits.

Parameters:

  • alpha: value packed into the top byte; values are not clamped to 0–255

setAlwaysOnTop ​

setAlwaysOnTop(boolean alwaysOnTop): voidSince2.0.0#
Sets cull to the inverse of alwaysOnTop; this replaces its current value.

Parameters:

  • alwaysOnTop: whether to disable depth testing for the line

setColor ​

setColor(int color): voidSince1.0.6#
Sets the packed colour, making a non-black RGB colour opaque when its alpha byte is zero. Use setColor(int, int) to explicitly set alpha to zero.

Parameters:

  • color: packed line colour
setColor(int color, int alpha): voidSince1.1.8#
Sets RGB from the low 24 bits of color and alpha in the top byte; alpha is not clamped.

Parameters:

  • color: RGB colour; its alpha byte is ignored
  • alpha: alpha value, packed into the top byte

setPos ​

setPos(double x1, double y1, double z1, double x2, double y2, double z2): voidSince1.0.6#
Sets the two endpoints of the segment, in block coordinates. The points are ordered endpoints, not minimum and maximum bounds.

Parameters:

  • x1: x coordinate of the first endpoint, in blocks
  • y1: y coordinate of the first endpoint, in blocks
  • z1: z coordinate of the first endpoint, in blocks
  • x2: x coordinate of the second endpoint, in blocks
  • y2: y coordinate of the second endpoint, in blocks
  • z2: z coordinate of the second endpoint, in blocks