Item.Builder
com.jsmacrosce.jsmacros.client.api.classes.render.components.Item.Builder
Builds item icons for an overlay. Set the stack, position, scale, rotation, and optional count overlay before building; the default stack is empty.
Nested type declared in Item.
Constructors
new Item.Builder
Methods
getItem
Returns a copy of the stack the builder will use.
Returns: the item to be drawn.
getOverlayText
getParentHeight
getParentHeight(): int#Returns the height of the overlay this builder belongs to, used by parent-relative alignment.
Returns: the height of the parent
getParentWidth
getParentWidth(): int#Returns the width of the builder's overlay.
Returns: the width of the parent
getRotation
Returns the builder's rotation in degrees, before the built icon normalizes it.
Returns: the rotation (clockwise) of the item in degrees.
getScale
Returns the scale the builder will use, initially
1.Returns: the scale of the item.
getScaledHeight
getScaledHeight(): int#Returns the icon's scaled height in whole pixels; it equals its scaled width.
Returns: the scaled height
getScaledLeft
getScaledLeft(): int#Returns the icon's x position; scaling changes its size, not this position.
Returns: the position of the scaled element's left side
getScaledTop
getScaledTop(): int#Returns the icon's y position; scaling changes its size, not this position.
Returns: the position of the scaled element's top side
getScaledWidth
getScaledWidth(): int#Returns the icon's scaled width in whole pixels; fractional results are truncated.
Returns: the scaled width
getX
Returns the x position configured for this builder (zero by default).
Returns: the x position of the item.
getY
Returns the y position configured for this builder (zero by default).
Returns: the y position of the item.
getZIndex
Returns the draw-order value that the builder will assign to the icon.
Returns: the z-index of the item.
isOverlayVisible
Returns whether the built icon will draw its overlay decorations; this is
false initially.Returns:
true if the overlay should be visible, false otherwise.isRotatingCenter
Returns whether the built icon will rotate about its center.
Returns:
true if this item should be rotated around its center, false otherwise.item
Sets the stack to draw, copying it into the builder. A
null helper leaves the builder's current stack unchanged.Parameters:
item: the item to draw
Returns: self for chaining.
Sets the item to draw from its id, using the item's default stack. The namespace may be omitted; an unknown id resolves to the registry's default item.
Parameters:
id: the id of the item to draw, with the namespace optional
Returns: self for chaining.
Sets the item stack from its id and count. Unlike the one-argument overload, this overload's script typing requires a namespace, although runtime parsing accepts a bare name. Unknown ids resolve to the registry's default item. The count does not appear as overlay text by default: the builder's empty overlay text differs from
null, which requests the stack count.Parameters:
id: the id of the item to drawcount: the stack size
Returns: self for chaining.
moveTo
moveTo(int x, int y): Item.Builder#Sets the icon position, equivalent to
pos; alignment methods use this operation. It does not change the icon's size.Parameters:
x: the new x positiony: the new y position
Returns: self for chaining.
overlayText
Sets the overlay text and enables the overlay.
Parameters:
overlayText: the overlay text
Returns: self for chaining.
overlayVisible
Sets whether the built icon draws the game's overlay decorations. This does not change the overlay text; the builder's default empty string produces an empty label rather than the stack count.
Parameters:
visible: whether to draw the decorations
Returns: self for chaining.
pos
Sets both icon coordinates without changing its stack.
Parameters:
x: the x position of the itemy: the y position of the item
Returns: self for chaining.
rotateCenter
Sets whether the built icon rotates about its center rather than its position.
Parameters:
rotateCenter: whether the item should be rotated around its center
Returns: self for chaining.
rotation
Sets the rotation used when building the icon, in degrees. The builder stores the float-converted angle without wrapping (so
450 remains 450); building wraps finite values to [-180, 180), making that angle 90.Parameters:
rotation: the rotation (clockwise) of the item in degrees
Returns: self for chaining.
scale
Sets the icon scale; the builder defaults to
1. The icon's base size is 16 by 16, and the scale must be greater than zero (unlike the element setter, which permits negative values).Parameters:
scale: the scale of the item
Returns: self for chaining.
x
Sets the icon's x position without changing its y position.
Parameters:
x: the x position of the item
Returns: self for chaining.
y
Sets the icon's y position without changing its x position.
Parameters:
y: the y position of the item
Returns: self for chaining.
zIndex
Sets the icon's draw-order value on its overlay; lower values draw first.
Parameters:
zIndex: the z-index of the item
Returns: self for chaining.