Shape rendering · Drawing lines, boxes, spheres, arrows and text on the client¶
This domain draws lines, boxes, circles, spheres, arrows and text at a given world coordinate, visible to the client only: no entities in the server world, no collision, and nothing written to the save. It suits region markers, building guides, range hints and temporary notice text.
Manage each shape with the integer id returned at creation. Setting a property (text, position, colour …) changes the value recorded on the server; a shape that is already on screen does not move until you call shapeUpdate or shapeDraw once more.
Quick start¶
const shapeCreateLine = ll.import("HologramLib", "shapeCreateLine");
const shapeSetColor = ll.import("HologramLib", "shapeSetColor");
const shapeDraw = ll.import("HologramLib", "shapeDraw");
// a red line from (100,65,100) to (110,65,110), shown to every online player
const lineId = shapeCreateLine(100, 65, 100, 110, 65, 110);
shapeSetColor(lineId, 1.0, 0.2, 0.2, 1.0); // RGBA, all four components are 0.0 ~ 1.0
shapeDraw(lineId);
Coordinates are always world coordinates; colours are always four components in 0.0 ~ 1.0.
Creation¶
Create a text shape¶
shapeCreateText(x, y, z, text)
- Parameters:
x:Float
the world coordinate X the text sits aty:Float
the world coordinate Y the text sits atz:Float
the world coordinate Z the text sits attext:String
the text to display; it may use§colour codes, for example"§eSpawn"- Return value: the shape id (incrementing from
1);<= 0means creation failed - Return type:
Integer -
Example:
Draw a line segment between two points¶
shapeCreateLine(x1, y1, z1, x2, y2, z2)
- Parameters:
x1:Float
the world coordinate X of the start pointy1:Float
the world coordinate Y of the start pointz1:Float
the world coordinate Z of the start pointx2:Float
the world coordinate X of the end pointy2:Float
the world coordinate Y of the end pointz2:Float
the world coordinate Z of the end point- Return value: the shape id;
<= 0means creation failed - Return type:
Integer -
Example:
Create a box wireframe from two opposite corners¶
shapeCreateBox(x1, y1, z1, x2, y2, z2)
- Parameters:
x1:Float
the world coordinate X of the first cornery1:Float
the world coordinate Y of the first cornerz1:Float
the world coordinate Z of the first cornerx2:Float
the world coordinate X of the opposite corner (the order of the two points does not matter; the edge lengths are the coordinate differences between them)y2:Float
the world coordinate Y of the opposite cornerz2:Float
the world coordinate Z of the opposite corner- Return value: the shape id;
<= 0means creation failed - Return type:
Integer -
Example:
Create a circle at a coordinate¶
shapeCreateCircle(x, y, z, scale)
- Parameters:
x:Float
the world coordinate X of the circle's centrey:Float
the world coordinate Y of the circle's centrez:Float
the world coordinate Z of the circle's centrescale:Float
the size of the circle; this is the shape scale set at creation time, andshapeSetScalecan change it later- Return value: the shape id;
<= 0means creation failed - Return type:
Integer -
Example:
Create a sphere at a coordinate¶
shapeCreateSphere(x, y, z, scale)
- Parameters:
x:Float
the world coordinate X of the sphere's centrey:Float
the world coordinate Y of the sphere's centrez:Float
the world coordinate Z of the sphere's centrescale:Float
the size of the sphere; this is the shape scale set at creation time, andshapeSetScalecan change it later- Return value: the shape id;
<= 0means creation failed - Return type:
Integer -
Example:
Draw an arrow from a start point to an end point¶
shapeCreateArrow(x1, y1, z1, x2, y2, z2)
- Parameters:
x1:Float
the world coordinate X of the arrow's taily1:Float
the world coordinate Y of the arrow's tailz1:Float
the world coordinate Z of the arrow's tailx2:Float
the world coordinate X the arrow points aty2:Float
the world coordinate Y the arrow points atz2:Float
the world coordinate Z the arrow points at- Return value: the shape id;
<= 0means creation failed - Return type:
Integer -
Example:
Properties¶
Replace the text of a text shape¶
shapeSetText(id, text)
- Parameters:
id:Integer
the shape idtext:String
the new text; it only means something on a text shape, and calling it on another type changes nothing- Return value:
truewhen the write succeeds;falsewheniddoes not exist - Return type:
Boolean -
Example:
const create = ll.import("HologramLib", "shapeCreateText"); const setText = ll.import("HologramLib", "shapeSetText"); const id = create(100, 66, 100, "§eFirst version"); setText(id, "§aEdited text"); // the server-side value has changed ll.import("HologramLib", "shapeUpdate")(id); // re-send once when it is already on screen
Read back the text of a text shape¶
shapeGetText(id)
- Parameters:
id:Integer
the shape id- Return value: the current text; the empty string
""wheniddoes not exist or is not a text shape - Return type:
String -
Example:
Move a shape to a new coordinate¶
shapeSetLocation(id, x, y, z)
- Parameters:
id:Integer
the shape idx:Float
the new world coordinate Xy:Float
the new world coordinate Yz:Float
the new world coordinate Z- Return value:
trueon success;falsewheniddoes not exist - Return type:
Boolean -
Example:
Query a shape's current coordinate¶
shapeGetLocation(id)
- Parameters:
id:Integer
the shape id- Return value:
[x, y, z]; an empty array wheniddoes not exist - Return type:
Array<Float> -
Example:
Set a shape's colour¶
shapeSetColor(id, r, g, b, a)
- Parameters:
id:Integer
the shape idr:Float
the red component,0.0 ~ 1.0g:Float
the green component,0.0 ~ 1.0b:Float
the blue component,0.0 ~ 1.0a:Float
the alpha component,0.0 ~ 1.0- Return value:
trueon success;falsewheniddoes not exist - Return type:
Boolean -
Example:
Read back a shape's current colour¶
shapeGetColor(id)
- Parameters:
id:Integer
the shape id- Return value:
[r, g, b, a], each component0.0 ~ 1.0; an empty array wheniddoes not exist. Colours are stored at 8 bits, so a value read back may differ from the value written by±1/255 - Return type:
Array<Float> -
Example:
Set the shape scale¶
shapeSetScale(id, scale)
- Parameters:
id:Integer
the shape idscale:Float
the scale factor;1is the size at creation time- Return value:
trueon success;falsewheniddoes not exist - Return type:
Boolean -
Example:
Make a shape disappear after a number of seconds¶
shapeSetDuration(id, seconds)
- Parameters:
id:Integer
the shape idseconds:Float
how long it lasts, in seconds. Not calling this function = shown permanently- Return value:
trueon success;falsewheniddoes not exist - Return type:
Boolean -
Example:
Set the dimension a shape belongs to¶
shapeSetDimension(id, dimId)
- Parameters:
id:Integer
the shape iddimId:Integer
the dimension number —0Overworld,1Nether,2End- Return value:
trueon success;falsewheniddoes not exist - Return type:
Boolean -
Example:
Fix a shape to a three-axis orientation¶
shapeSetRotation(id, pitch, yaw, roll)
- Parameters:
id:Integer
the shape idpitch:Float
one of the rotation angles about the three axes, in degreesyaw:Float
one of the rotation angles about the three axes, in degreesroll:Float
one of the rotation angles about the three axes, in degrees- Return value:
trueon success;falsewheniddoes not exist. Once set, a text shape no longer faces the camera - Return type:
Boolean -
Example:
const create = ll.import("HologramLib", "shapeCreateText"); const setRotation = ll.import("HologramLib", "shapeSetRotation"); const id = create(100, 66, 100, "§eLying flat"); setRotation(id, 90, 0, 0); // a text shape turns on double-sided rendering automatically ll.import("HologramLib", "shapeDraw")(id);
Clear the rotation so a shape faces the camera¶
shapeClearRotation(id)
- Parameters:
id:Integer
the shape id- Return value:
trueon success;falsewheniddoes not exist - Return type:
Boolean -
Example:
Query a shape's current rotation angles¶
shapeGetRotation(id)
- Parameters:
id:Integer
the shape id- Return value:
[pitch, yaw, roll](degrees); an empty array when no rotation was ever set (it still faces the camera) or wheniddoes not exist - Return type:
Array<Float> -
Example:
Query which kind of shape an id is¶
shapeGetShapeType(id)
- Parameters:
id:Integer
the shape id- Return value: the type number:
0text,1line,2box,3circle,4sphere,5arrow;-1wheniddoes not exist - Return type:
Integer -
Example:
Set the colour of the board behind a text shape¶
shapeSetBackgroundColor(id, r, g, b, a)
- Parameters:
id:Integer
the shape idr:Float
the red component of the board colour,0.0 ~ 1.0g:Float
the green component of the board colour,0.0 ~ 1.0b:Float
the blue component of the board colour,0.0 ~ 1.0a:Float
the alpha component of the board colour,0.0 ~ 1.0; leave it unset for the client's default colour- Return value:
trueon success;falsewheniddoes not exist or is not a text shape - Return type:
Boolean -
Example:
Restore the text board to the client's default colour¶
shapeClearBackgroundColor(id)
- Parameters:
id:Integer
the shape id- Return value:
trueon success;falsewheniddoes not exist or is not a text shape - Return type:
Boolean -
Example:
Decide whether text is occluded by blocks¶
shapeSetDepthTest(id, enabled)
- Parameters:
id:Integer
the shape idenabled:Booleantrue= occluded by blocks / entities;false= always rendered (visible through walls), which is also the default behaviour- Return value:
trueon success;falsewheniddoes not exist or is not a text shape - Return type:
Boolean -
Example:
Display¶
Show a shape to every online player (any dimension)¶
shapeDraw(id)
- Parameters:
id:Integer
the shape id- Return value:
trueonce it has been sent;falsewheniddoes not exist - Return type:
Boolean -
Example:
Show a shape to one player only¶
shapeDrawToPlayer(id, playerName)
- Parameters:
id:Integer
the shape idplayerName:String
the player name (LSE'srealName). Nothing is displayed while the player is offline- Return value:
trueonce it has been sent;falsewheniddoes not exist or the player is offline - Return type:
Boolean -
Example:
Show a shape to one dimension only¶
shapeDrawToDimension(id, dimId)
- Parameters:
id:Integer
the shape iddimId:Integer
the dimension number —0Overworld,1Nether,2End- Return value:
trueonce it has been sent;falsewheniddoes not exist. The shape's dimension is recorded as that value - Return type:
Boolean -
Example:
Show several shapes at once¶
shapeDrawBatch(ids)
- Parameters:
ids:Array<Integer>
an array of shape ids; ids in the array that do not exist are skipped (an empty array also returnstrue)- Return value:
trueonce it has been sent - Return type:
Boolean -
Example:
const createText = ll.import("HologramLib", "shapeCreateText"); const createLine = ll.import("HologramLib", "shapeCreateLine"); const drawBatch = ll.import("HologramLib", "shapeDrawBatch"); const a = createText(100, 66, 100, "§eA"); const b = createLine(100, 65, 100, 110, 65, 110); drawBatch([a, b]);
Hide a shape from every player but keep its data¶
shapeRemove(id)
- Parameters:
id:Integer
the shape id- Return value:
trueon success;falsewheniddoes not exist. The data stays on the server, so the shape can be drawn again - Return type:
Boolean -
Example:
Make a shape invisible to one player only¶
shapeRemoveToPlayer(id, playerName)
- Parameters:
id:Integer
the shape idplayerName:String
the player name; returnsfalsewhen the player is offline- Return value:
trueon success;falsewheniddoes not exist or the player is offline - Return type:
Boolean -
Example:
Make a shape invisible to one dimension¶
shapeRemoveToDimension(id, dimId)
- Parameters:
id:Integer
the shape iddimId:Integer
the dimension number —0Overworld,1Nether,2End- Return value:
trueon success;falsewheniddoes not exist - Return type:
Boolean -
Example:
Re-send changed properties to the viewers¶
shapeUpdate(id)
- Parameters:
id:Integer
the shape id- Return value:
truewhenidexists; does nothing (and reports no error) when the shape has not been displayed yet, andfalsewheniddoes not exist - Return type:
Boolean -
Example:
const create = ll.import("HologramLib", "shapeCreateText"); const setText = ll.import("HologramLib", "shapeSetText"); const update = ll.import("HologramLib", "shapeUpdate"); const id = create(100, 66, 100, "§eCountdown: 10"); ll.import("HologramLib", "shapeDraw")(id); setText(id, "§eCountdown: 9"); update(id); // changing the text alone does not reach the screen; re-send it
Re-send changed properties to one player¶
shapeUpdateToPlayer(id, playerName)
- Parameters:
id:Integer
the shape idplayerName:String
the player name; returnsfalsewhen the player is offline- Return value:
truewhenidexists (nothing is sent if it was never displayed);falsewheniddoes not exist or the player is offline - Return type:
Boolean -
Example:
Re-send changed properties to one dimension¶
shapeUpdateToDimension(id, dimId)
- Parameters:
id:Integer
the shape iddimId:Integer
the dimension number —0Overworld,1Nether,2End- Return value:
truewhenidexists (nothing is sent if it was never displayed);falsewheniddoes not exist - Return type:
Boolean -
Example:
Queries¶
Find text shapes near a point¶
shapeFindTextByLocation(x, y, z, radius)
- Parameters:
x:Float
the centre world coordinate X to queryy:Float
the centre world coordinate Y to queryz:Float
the centre world coordinate Z to queryradius:Float
the query radius (bounds included); only text shapes take part in the match, lines / boxes / circles / spheres / arrows are not returned- Return value: the ids of the text shapes that matched; an empty array when there are none
- Return type:
Array<Integer> -
Example:
Find a text shape near a point by its content¶
shapeFindTextByLocationAndContent(x, y, z, radius, text)
- Parameters:
x:Float
the centre world coordinate Xy:Float
the centre world coordinate Yz:Float
the centre world coordinate Zradius:Float
the query radius (bounds included)text:String
the full text to compare (only an exact match counts)- Return value: the id of the first matching text shape;
-1when nothing matched - Return type:
Integer -
Example:
List the ids of every current shape¶
shapeGetAllShapeIds()
- Return value: every shape id (all types); an empty array when there is no shape at all
- Return type:
Array<Integer> -
Example:
Tell whether a shape id still exists¶
shapeExists(id)
- Parameters:
id:Integer
the shape id- Return value:
truewhen it exists;falsewhen it does not - Return type:
Boolean -
Example:
Destruction¶
Delete a shape from the client and the server together¶
shapeDestroy(id)
- Parameters:
id:Integer
the shape id- Return value:
truewhen the deletion succeeds;falsewheniddoes not exist - Return type:
Boolean -
Example:
Delete every current shape¶
shapeDestroyAll()
- Return value: no return value; any shapes left over on the client disappear along with it
- Return type:
Null -
Example:
Delete a batch of shapes at once¶
shapeDestroyBatch(ids)
- Parameters:
ids:Array<Integer>
an array of shape ids; ids in the array that do not exist are skipped (an empty array also returnstrue)- Return value:
trueonce it has been handled - Return type:
Boolean -
Example:
Things to know¶
- Pass every parameter the signature asks for. There are no default values on the LSE side: give too few or too many and the call hands you the failure value straight away (
Booleangivesfalse,Integergives0,Stringgives an empty string), with no exception to warn you. - Re-send after changing a property:
shapeSetText/shapeSetLocation/shapeSetColor/shapeSetScale/shapeSetRotation/shapeSetBackgroundColor/shapeSetDepthTest/shapeSetDimensiononly change the value recorded on the server, so a shape that is already on screen needs anothershapeUpdate(orshapeUpdateToPlayer/shapeUpdateToDimension), or simply anothershapeDraw. - The three things only a text shape has: the background box colour (
shapeSetBackgroundColor), the through-walls switch (shapeSetDepthTest) and the three-axis orientation switch. Lines / boxes / circles / spheres / arrows returnfalsestraight away when you call the first two. - Colours are stored at 8 bits: after writing
0.5,shapeGetColormay read back0.498or0.502, so do not compare colours with a strict equality. shapeSetDurationis a countdown deletion: once it is set the client deletes the shape on its own when the time runs out, so do not call it if you want the shape shown permanently.- The display function decides who can see it:
shapeDrawsends to every online player (any dimension),shapeDrawToDimensionsends only to that dimension,shapeDrawToPlayersends only to that player; the automatic resend when a player joins later uses the last setting as well. - You do not have to resend when a player joins: these shapes live in client memory only, and the library resends them automatically after a player joins (once 1 second and once 5 seconds after joining, then a background resend every 15 seconds).
- Calling from the main thread is recommended (inside a server tick or an event callback).
- When the library is not installed or not loaded,
ll.importreturnsnulland calling it directly throws; you can check for null first, or callll.hasExported("HologramLib", "shapeDraw")first as a capability check.