EntityTraceLine
com.jsmacrosce.jsmacros.client.api.classes.render.components3d.EntityTraceLine
A TraceLine whose target follows an entity, with yOffset added to its interpolated Y coordinate each frame. If the entity is absent, removed, or in a different level from the client, the line stops rendering and is removed from its overlay. getPos() remains at the origin until the first render.
js
const player = Player.getPlayer();
if (player !== null) {
const draw = Hud.createDraw3D();
// a line from the crosshair to the player, 2.0 blocks above their feet
draw.entityTraceLineBuilder().entity(player).color(Color.rgb(0xFF, 0x00, 0x00)).yOffset(2.0).buildAndAdd();
draw.register();
}Available in scripts as RenderElements.EntityTraceLine.
Nested types
Constructors
new EntityTraceLine
new EntityTraceLine(EntityHelper<?> entity, int color, double yOffset)#Initializes an entity-following trace at the origin. A zero-alpha packed color is made opaque only when its RGB bits are nonzero; depth testing is disabled. A non-null helper's raw entity reference is stored without copying, and
yOffset is stored unchanged; a null helper leaves the line without an entity.Parameters:
entity: helper for the target, ornullto leave the line without an entitycolor: packed color; nonzero RGB with a zero alpha byte becomes opaque, while zero-alpha black remains transparentyOffset: vertical offset added to the target's Y coordinate, in blocks
new EntityTraceLine(EntityHelper<?> entity, int color, int alpha, double yOffset)#Initializes an entity-following trace at the origin with separately supplied alpha and depth testing disabled. Alpha is shifted into the top byte without clamping or range validation. A non-null helper's raw entity reference is stored without copying, and
yOffset is stored unchanged; a null helper leaves the line without an entity.Parameters:
entity: helper for the target, ornullto leave the line without an entitycolor: RGB source; only its low 24 bits are usedalpha: value shifted into the color's top byteyOffset: vertical offset added to the target's Y coordinate, in blocks
new EntityTraceLine(EntityHelper<?> entity, int color, int alpha, double yOffset, boolean alwaysOnTop)#Initializes an entity-following trace at the origin with separately supplied alpha and the requested depth-testing mode. Alpha is shifted into the top byte without clamping or range validation;
alwaysOnTop controls the inverse internal culling flag and does not ensure visibility. A non-null helper's raw entity reference is stored without copying, and yOffset is stored unchanged; a null helper leaves the line without an entity.Parameters:
entity: helper for the target, ornullto leave the line without an entitycolor: RGB source; only its low 24 bits are usedalpha: value shifted into the color's top byteyOffset: vertical offset added to the target's Y coordinate, in blocksalwaysOnTop: whether to disable depth testing
Fields
dirty
Whether an entity trace line has requested removal; overlays use this class-wide flag to decide whether to scan for lines marked for removal.
entity
shouldRemove
Whether this line is marked for removal after it cannot render its entity.
yOffset
Vertical offset added to the entity's interpolated Y position, in blocks (default
0.5).Methods
render
Updates the target to the entity's interpolated position plus
yOffset, then renders the line. If the entity is absent, removed, or not in the client level, marks the line for removal and returns without rendering. Called by the renderer.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
setEntity
Sets the followed entity and clears this line's removal mark. A
null argument leaves both unchanged.Parameters:
entity: the entity to follow, ornullto leave the current entity unchanged
Returns: self for chaining
setYOffset
Sets the vertical offset added to the entity's interpolated Y coordinate each frame, in blocks.
Parameters:
yOffset: the offset above the entity's feet, in blocks
Returns: self for chaining