Skip to content

EntityTraceLine ​

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

Since1.9.0

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, or null to leave the line without an entity
  • color: packed color; nonzero RGB with a zero alpha byte becomes opaque, while zero-alpha black remains transparent
  • yOffset: 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, or null to leave the line without an entity
  • color: RGB source; only its low 24 bits are used
  • alpha: value shifted into the color's top byte
  • yOffset: 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, or null to leave the line without an entity
  • color: RGB source; only its low 24 bits are used
  • alpha: value shifted into the color's top byte
  • yOffset: vertical offset added to the target's Y coordinate, in blocks
  • alwaysOnTop: whether to disable depth testing

Fields ​

dirty ​

static dirty: booleanSince1.9.0#
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 ​

entity: EntitySince1.9.0#
The game entity followed by this line, or null if none was set.

shouldRemove ​

shouldRemove: booleanSince1.9.0#
Whether this line is marked for removal after it cannot render its entity.

yOffset ​

yOffset: doubleSince1.9.0#
Vertical offset added to the entity's interpolated Y position, in blocks (default 0.5).

Methods ​

render ​

render(PoseStack poseStack, RenderSink sink, float tickDelta): voidSince1.9.0#
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 origin
  • sink: the buffer source the geometry goes into
  • tickDelta: how far into the current tick this frame is, from 0 to 1

setEntity ​

setEntity(EntityHelper<?> entity): EntityTraceLineSince1.9.0#
Sets the followed entity and clears this line's removal mark. A null argument leaves both unchanged.

Parameters:

  • entity: the entity to follow, or null to leave the current entity unchanged
Returns: self for chaining

setYOffset ​

setYOffset(double yOffset): EntityTraceLineSince1.9.0#
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