Item

draw_text.add_item(item: str, x: int, y: int, display_duration: float, layer: int = 1) int

Add an item element to the screen.

Parameters:
  • item – Item to display. Uses the /give command format.

  • x – X-coordinate of the item position.

  • y – Y-coordinate of the item position.

  • display_duration – How long the element remains on screen (in seconds).

  • layer – Rendering layer of the element. Higher layers appear above lower ones. Default is 1.

Returns:

ID of the created element.

draw_text.add_advanced_item(item: str, x: int, y: int, display_duration: float, layer: int, matrix: Matrix) int

Add an item element to the screen, with additional scaling, rotation, and translation options.

Advanced version of add_item() that allows custom transformations.

Parameters:
  • item

    Item to display. Uses the /give command format.

  • x – X-coordinate of the item position.

  • y – Y-coordinate of the item position.

  • display_duration – How long the element remains on screen (in seconds).

  • layer – Rendering layer of the element. Higher layers appear above lower ones. Default is 1.

  • matrix – Transformation matrix applied to the element (scale, rotation, translation). See Matrix.

Returns:

ID of the created element.

draw_text.animate_item(_id: int, func: Callable[[ItemObject], None]) None

Animates the item element with the given id by calling the given function every frame with the item element as the argument.

Parameters:
  • _id – ID of the item element to animate.

  • func – Function to use to animate the item element. The function is called every frame with the item element as the argument.

draw_text.modify_item(_id: int, func: Callable[[ItemObject], None]) None

Modifies the item element with the given id by calling the given function once with the item element as the argument.

Parameters:
  • _id – ID of the item element to modify.

  • func – Function to use to modify the item element. The function is called on the closest render frame.


ItemObject class

class draw_text.ItemObject(_id: int)
item: str

Item to display. Uses the /give command format.

x: int

X-coordinate of the item.

y: int

Y-coordinate of the item.

display_duration_modifier: float

Modifier to the display_duration property.

layer: int

Layer of the element.

matrix: Matrix

Transformation matrix applied to the element (scale, rotation, translation).

property display_duration

Time in seconds that the element will remain on screen. This property cannot be assigned, use display_duration_modifier to change this value.

update(_id: int)

Updates this ItemObject with the values of the item element specified by _id.

Parameters:

_id – ID of the item element.

to_list() list

Returns a list containing all the values of this ItemObject.

Returns:

List containing all the values of this ItemObject.


Example

 1from draw_text import *
 2from math import radians
 3
 4def spin(i:ItemObject):
 5    i.matrix.rotate(radians(2))
 6
 7add_item("stick", x=10, y=10, display_duration=5)
 8add_item("minecraft:stick", x=10, y=36, display_duration=5)
 9add_advanced_item("netherite_boots[trim={"pattern":"host","material":"emerald"}]", x=10, y=72, display_duration=5, layer=1, matrix=Matrix().scale(2))
10
11item_id = add_item("emerald", x=10, y=100, display_duration=5)
12
13animate_item(item_id, spin)