Skip to main content

Paint API

About

Paint API allows you to draw things on the screen, both from server and directly from client. This can allow you to create widgets from server side or effects on screen or in world from client side.

Currently it doesn't support any input, but in future, in-game menus similar to Source engine ones will be supported.

Paintable objects are created from NBT/Json objects and all have an id. If id isn't provided, a random one will be generated. Objects x and z are absolute positions based on screen, but you can align elements in one of the corners of screen. You can bulk add multiple objects in one json object. All properties are optional, but obviously some you should almost always override like size and position for rectangles.

You can edit paintable objects with /kubejs paint command, but the recommended way is using player methods - .paint({ object }), .removePaint(id), .clearPaint(). Paintable objects will be cleared when players leave world/server, if its persistent, then it must be re-added in player.logged_in event every time.

Currently available objects and their properties

Root

(available for all objects)

  • String id
Screen Object

(available for all screen / 2D objects)

  • Int x
  • Int y
  • Int z
  • Int width
  • Int height
  • Enum align (one of 'top_left', 'top_right', 'bottom_left', 'bottom_right')
  • Enum drawType (one of 'ingame', 'gui', 'always')
Rectangle
  • Color color
  • String texture
  • Float u0
  • Float v0
  • Float u1
  • Float v1
Gradient
  • Color color
  • Color colorT
  • Color colorB
  • Color colorL
  • Color colorR
  • Color colorTL
  • Color colorTR
  • Color colorBL
  • Color colorBR
  • String texture
  • Float u0
  • Float v0
  • Float u1
  • Float v1
Text
  • Text/String text
  • Float scale
  • Color color