UltimateUI guide
How to set Block size based on a placeholder
To create visually appealing statistics like a progress bar, health bar, or food level, you can use blocks with their width based on a placeholder.
For example, to make an element’s width equal to 10 * %player_health%, go to Properties and then left-click on Width.
At this point, you can enter any width value, but instead of a static number, we will use a placeholder-based value. First, we need to get the placeholder we want to use.
We can check whether a placeholder returns a number using the command: /papi parse me %player_health%
where player_health is our placeholder.
Now that we have our placeholder, we can set the width to: 10 * %player_health%
From now on, the width of our block will correspond to the player’s HP value.
Size Based on Text#
In newer versions of the plugin, you can base an element's size or position on the length of a text or its exact rendered width. This allows you to create effects such as a background element that automatically expands as the text gets longer.
To do this, first assign an ID to the text element, for example text1, then, for another element, set its width to %text_length_text1%
Or, if you need the exact rendered width of the text, use %text_width_text1%
The example is shown below.
- type: block
id: background
layer: 1
unicode:
position:
x: 100
y: 100
size:
width: 100 + %text_width_text1%
height: 100
- type: text
id: text1
layer: 2
align: center
text: "Hello world"
position:
x: 100
y: 100
size:
width: 100
height: 100