Box
com.jsmacrosce.jsmacros.client.api.classes.render.components3d.Box
An axis-aligned cuboid with an outline and an optional filled interior. Its position is defined by two opposite corners, and its outline and fill have independent colours.
Setters taking a packed colour make a zero alpha byte opaque unless the whole value is zero; overloads taking a separate alpha preserve zero alpha.
cull enables depth testing, allowing terrain to hide the box; otherwise it is drawn over the world. Builders and Draw3D helpers default it to false.
js
const draw = Hud.createDraw3D();
// a filled red cube one block on a side, drawn over the world
draw.addBox(0, 64, 0, 1, 65, 1, Color.rgb(0xFF, 0x00, 0x00), Color.argb(0x88, 0, 0, 0), true);
draw.register();Available in scripts as RenderElements.Box.
Nested types
Constructors
new Box
new Box(double x1, double y1, double z1, double x2, double y2, double z2, int color, int fillColor, boolean fill, boolean cull)#Constructs a detached box from two ordered opposite corners in world-space block coordinates and packed outline and fill colours. For each colour, a nonzero RGB value with a zero alpha byte becomes opaque, while zero remains transparent. This does not add or register the box with a Draw3D overlay.
Parameters:
x1: x coordinate of the first cornery1: y coordinate of the first cornerz1: z coordinate of the first cornerx2: x coordinate of the opposite cornery2: y coordinate of the opposite cornerz2: z coordinate of the opposite cornercolor: packed outline colourfillColor: packed fill colourfill: whether to draw the interiorcull: whether to enable the renderer's depth-testing setting
new Box(double x1, double y1, double z1, double x2, double y2, double z2, int color, int alpha, int fillColor, int fillAlpha, boolean fill, boolean cull)#Constructs a detached box from two ordered opposite corners in world-space block coordinates, with outline and fill alpha supplied separately. Each colour's existing alpha byte is ignored; its low 24 bits are combined with the corresponding alpha using a left shift, without range validation. This does not add or register the box with an overlay.
Parameters:
x1: x coordinate of the first cornery1: y coordinate of the first cornerz1: z coordinate of the first cornerx2: x coordinate of the opposite cornery2: y coordinate of the opposite cornerz2: z coordinate of the opposite cornercolor: outline RGB value; its top byte is ignoredalpha: outline alpha, shifted into the top byte without range validationfillColor: fill RGB value; its top byte is ignoredfillAlpha: fill alpha, shifted into the top byte without range validationfill: whether to draw the interiorcull: whether to enable the renderer's depth-testing setting
Fields
color
cull
Whether this box is depth tested, allowing terrain to hide it; false draws it over the world.
fill
Whether to draw the inside as well as the outline.
fillColor
pos
Methods
compareToSame
Compares this box's corner coordinates lexicographically with another box's. The comparison is not based on distance or overlap; colour, fill, and culling do not affect the result.
Parameters:
other: another box to order this one against
Returns: a negative number, zero, or a positive number as this box is before, the same as, or after
otherequals
Tests equality by exact runtime class and current position value; colour, fill, and depth-testing settings are ignored. A null argument or a different class does not match; null positions compare equal to null positions.
Parameters:
o: object to compare
Returns:
true if the objects match by this rulehashCode
hashCode(): int#Computes a hash from the current position only. Since position is mutable, the hash may change when it changes; colour, fill, and depth-testing settings are ignored.
Returns: hash of the current position
setAlpha
Replaces the outline alpha without changing its RGB or the fill colour.
Parameters:
alpha: the alpha of the outline, from 0 to 255
setColor
Replaces the outline colour. If its alpha byte is zero but its RGB value is nonzero, the alpha is made opaque; transparent black remains transparent. Use setColor(int, int) to specify zero alpha explicitly.
Parameters:
color: the colour of the outline
Sets the outline RGB and alpha explicitly. The alpha replaces the top byte; zero remains transparent.
Parameters:
color: the colour of the outlinealpha: the alpha of the outline, from 0 to 255
setFill
Controls whether the interior is drawn; disabling it leaves the outline unchanged.
Parameters:
fill: whether to draw the inside as well as the outline
setFillAlpha
setFillColor
Replaces the fill colour using the same zero-alpha handling as setColor(int). The colour is stored even while filling is disabled.
Parameters:
fillColor: the colour of the inside
setPos
Replaces pos with the supplied opposite corners, retaining their order.
Parameters:
x1: the x coordinate of the first cornery1: the y coordinate of the first cornerz1: the z coordinate of the first cornerx2: the x coordinate of the second cornery2: the y coordinate of the second cornerz2: the z coordinate of the second corner
setPosToBlock
Sets this box to cover the block at
pos, extending one block from its coordinates along each axis.Parameters:
pos: the block to cover
Sets this box to cover the block at the given coordinates, extending one block from that corner along each axis.
Parameters:
x: the x coordinate of the block's cornery: the y coordinate of the block's cornerz: the z coordinate of the block's corner
setPosToPoint
Sets this box to a cube centred on
pos, with side length twice radius.Parameters:
pos: the centre of the cuberadius: half the side length, in blocks
Sets this box to a cube centred on the given point, with side length twice
radius. A negative radius reverses the supplied corner order.Parameters:
x: the x coordinate of the centrey: the y coordinate of the centrez: the z coordinate of the centreradius: half the side length, in blocks