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 blocksy1: y coordinate of the first endpoint, in blocksz1: z coordinate of the first endpoint, in blocksx2: x coordinate of the second endpoint, in blocksy2: y coordinate of the second endpoint, in blocksz2: z coordinate of the second endpoint, in blockscolor: packed ARGB color; a zero alpha byte is fixed as described abovecull: 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 blocksy1: y coordinate of the first endpoint, in blocksz1: z coordinate of the first endpoint, in blocksx2: x coordinate of the second endpoint, in blocksy2: y coordinate of the second endpoint, in blocksz2: z coordinate of the second endpoint, in blockscolor: RGB source; only its low 24 bits are usedalpha: value shifted into the top byte, without range validationcull: whether depth testing is enabled
Fields
color
The line colour packed as ARGB, with alpha in the top byte. Writable; see setColor(int) for alpha handling.
cull
Whether the line is depth tested;
true allows geometry to obscure it.pos
The line's endpoints as a segment, in the order supplied. Writable directly or through setPos(double, double, double, double, double, double).
Methods
compareToSame
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
oequals
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 otherwisegetAlpha
Returns the packed colour's top byte.
Returns: the alpha byte, from 0 to 255.
getColor
Returns the line colour's low 24 bits; read alpha separately with getAlpha().
Returns: the RGB colour, without alpha.
getPos
getPos1
getPos2
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
Returns the inverse of the line's
cull setting.Returns:
true when depth testing is disabled.setAlpha
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
Sets
cull to the inverse of alwaysOnTop; this replaces its current value.Parameters:
alwaysOnTop: whether to disable depth testing for the line
setColor
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
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 ignoredalpha: alpha value, packed into the top byte
setPos
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 blocksy1: y coordinate of the first endpoint, in blocksz1: z coordinate of the first endpoint, in blocksx2: x coordinate of the second endpoint, in blocksy2: y coordinate of the second endpoint, in blocksz2: z coordinate of the second endpoint, in blocks