Skip to content

Item.Builder ​

com.jsmacrosce.jsmacros.client.api.classes.render.components.Item.Builder

Since1.8.4

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 ​

new Item.Builder(IDraw2D<?> draw2D)#
Creates a builder associated with the supplied overlay.

Parameters:

  • draw2D: the overlay the icons will be added to

Methods ​

getItem ​

getItem(): ItemStackHelperSince1.8.4#
Returns a copy of the stack the builder will use.
Returns: the item to be drawn.

getOverlayText ​

getOverlayText(): StringSince1.8.4#
Returns the builder's overlay text, initially an empty string. Unlike null, an empty string requests an empty label rather than the stack count.
Returns: the overlay text.

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 ​

getRotation(): floatSince1.8.4#
Returns the builder's rotation in degrees, before the built icon normalizes it.
Returns: the rotation (clockwise) of the item in degrees.

getScale ​

getScale(): doubleSince1.8.4#
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 ​

getX(): intSince1.8.4#
Returns the x position configured for this builder (zero by default).
Returns: the x position of the item.

getY ​

getY(): intSince1.8.4#
Returns the y position configured for this builder (zero by default).
Returns: the y position of the item.

getZIndex ​

getZIndex(): intSince1.8.4#
Returns the draw-order value that the builder will assign to the icon.
Returns: the z-index of the item.

isOverlayVisible ​

isOverlayVisible(): booleanSince1.8.4#
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 ​

isRotatingCenter(): booleanSince1.8.4#
Returns whether the built icon will rotate about its center.
Returns: true if this item should be rotated around its center, false otherwise.

item ​

item(ItemStackHelper item): Item.BuilderSince1.8.4#
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.
item(String id): Item.BuilderSince1.8.4#
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.
item(String id, int count): Item.BuilderSince1.8.4#
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 draw
  • count: 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 position
  • y: the new y position
Returns: self for chaining.

overlayText ​

overlayText(String overlayText): Item.BuilderSince1.8.4#
Sets the overlay text and enables the overlay.

Parameters:

  • overlayText: the overlay text
Returns: self for chaining.

overlayVisible ​

overlayVisible(boolean visible): Item.BuilderSince1.8.4#
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 ​

pos(int x, int y): Item.BuilderSince1.8.4#
Sets both icon coordinates without changing its stack.

Parameters:

  • x: the x position of the item
  • y: the y position of the item
Returns: self for chaining.

rotateCenter ​

rotateCenter(boolean rotateCenter): Item.BuilderSince1.8.4#
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 ​

rotation(double rotation): Item.BuilderSince1.8.4#
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 ​

scale(double scale): Item.BuilderSince1.8.4#
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 ​

x(int x): Item.BuilderSince1.8.4#
Sets the icon's x position without changing its y position.

Parameters:

  • x: the x position of the item
Returns: self for chaining.

y ​

y(int y): Item.BuilderSince1.8.4#
Sets the icon's y position without changing its x position.

Parameters:

  • y: the y position of the item
Returns: self for chaining.

zIndex ​

zIndex(int zIndex): Item.BuilderSince1.8.4#
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.