-
Notifications
You must be signed in to change notification settings - Fork 7
Root
Refaltor77 edited this page Apr 15, 2026
·
2 revisions
Top-level container for a UI screen. Manages namespace, elements, and animations.
use refaltor\ui\builders\Root;
$root = Root::create("my_namespace");
// or
$root = Root::create(); // namespace set later via RootBuild$root->addElement($element); // Add single element
$root->addElements([$el1, $el2]); // Add multiple$root->addAnimation($animation); // Add single animation
$root->addAnimations([$a1, $a2]); // Add multipleTarget vanilla Bedrock UI elements using path syntax. See Modification for all operations.
use refaltor\ui\components\Modification;
// Modify a nested vanilla element
$root->modifyVanillaElement("hud_title_text/title_frame/title", [
Modification::insertBack(Modification::ARRAY_BINDINGS)
->setValue([
[
"binding_type" => "view",
"source_property_name" => "(not (#text = 'hidden'))",
"target_property_name" => "#visible",
]
]),
]);
// Add a custom control to a vanilla screen
$root->modifyVanillaElement("hud_screen", [
Modification::insertBack(Modification::ARRAY_CONTROLS)
->setValue([
["my_element@my_namespace.my_panel" => []]
]),
]);$root->setNamespace("my_namespace"); // Set namespace
$root->setTitleCondition("MY_TITLE"); // Visibility condition$root->generateAndSaveJson("ui/my_screen.json"); // Save to fileThe Root serializes to:
{
"namespace": "my_namespace",
"@my_animation": { "anim_type": "alpha", ... },
"my_element": { "type": "label", ... }
}- RootBuild — Interface for screen definitions
- Animation — Declaring animations on Root
- Element — Elements added to Root
- Modification — Vanilla UI modifications via Root
- JsonValidator — Validation of generated JSON