Rules: Collections and factories
scripts/gen-rules.mjs builds this page from rules/*.json. Do not edit it by hand; edit the JSON and run npm run gen-rules. The rule bullets on topic pages (- **[ID]**) are filled from the same source.
Explanations and examples are on the topic page Collections and factories.
| ID | Rule | Level | Evidence environment | Source |
|---|---|---|---|---|
| COL-01 | collection_name is used on stack_panel, grid and collection_panel. Using it on panel or image gives an Unknown property [collection_name] error. | measured, vanilla | unknown | BC-facts, BC-S9, BC-S11, VN grid 66, stack_panel 25, collection_panel store_common.json:750, MJ chapter 9 |
| COL-02 | collection_index is received only at the instantiation point (an item inside the parent's controls). Written in a top-level definition it is rejected, and on an image it is rejected anywhere. On a label it is read: on Windows 1.26.65.1, a label with collection_index directly under a collection_name stack_panel read its value (b1) (measurement record). The engine reads collection_index only on direct children of a parent that has a collection name (COL-44). | measured, code (binary) | Windows 1.26.65.1 | BC-facts, NB-07, BC 4.1-(4) |
| COL-03 | The index is inherited down the subtree from the point where it was applied. So the pattern of writing the definition once and giving N references only a different index and offset holds. Bindings that read a collection each specify the collection with binding_collection_name. | measured | unknown | BC-facts |
| COL-04 | A server form button counts a press toward that entry only if the button itself has { "binding_type": "collection_details", "binding_collection_name": "form_buttons" }. If only an ancestor gives the index, it can be pressed but the script receives canceled, which cannot be told from Esc, and there is no log (when the user closes it, reason=UserClosed arrives, but whether the reason for a missing binding can be told apart was not confirmed). Vanilla form buttons have the same structure. | measured, vanilla | unknown | BC-S1, BC-facts, VN server_form.json:211-225 |
| COL-05 | A collection binding with no index host at all reads item 0. This property was used to hide the vanilla chest label with the slot 0 item. | measured | unknown | BC-facts |
| COL-06 | You can make fixed-index slots without a factory: put children with hardcoded collection_index in a stack that has collection_name. The script always sends the same number of entries (including empty values) to fix the index. | working pack, code (source) | - | BA chapter 5 tab 28 slots, BC 4.1-(3) |
| COL-07 | The durability of chest slots (#item_durability_current_amount, #item_durability_total_amount) can be read in ordinary controls and compared and divided if read with a collection_details + collection binding pair. #item_durability_current_amount is the remaining durability (((0 + value) > 100) was true for an iron sword with 100 damage). The value is a float, so comparisons work but concatenating it to a string gives nothing (EXP-22). ('D ' + (0 + value)) and ('D ' + (value * 1)) gave only 'D ' whatever the binding setup. To show it as text, split it into ranges with a comparison chain. | measured, inferred | unknown | BC-S14, BC-S6, BC 6.8-7, CPR |
| COL-08 | A factory is either (a) a "type": "factory" control (36 uses in vanilla, not in the official enum) or (b) the "factory": { … } property of a container. The keys of the factory object are name, control_name (one kind) or control_ids (per kind), max_children_size and factory_variables. | vanilla | - | VN server_form.json:25 and 126, VN factory key tally |
| COL-09 | The keys of control_ids are data kinds the engine decides, and the values are "@ns.definition" (197 uses in vanilla), "instancename@ns.definition" (36 uses) and "ns.definition" (5 uses, for example server_form.json:128). The action form rows are button, label, header and divider, the modal rows are label, toggle, slider, step_slider, dropdown, input, header, divider and multiselect, the HUD ones are hud_title_text and hud_actionbar_text, and chat's is chat_item. | vanilla | - | VN server_form.json:126 and 283, hud_screen.json:3406, 3417 and 1040 |
| COL-10 | visible only stops drawing and does not stop creation and layout. A screen attached under the server form is fully created and laid out every time any form is opened, even if hidden with visible (measured with 5,546 controls repositioned). A component inside it that validates its state at creation, such as a slider, raises an assert even when hidden. The control's own binding_condition: "visible" also does not stop evaluation when an ancestor is hidden. | measured | unknown | BC-S8, BW-best |
| COL-11 | If you bind #collection_length, the factory creates only that many cells. If 0, nothing is created. A computed length like ((#mode = 'on') * 1) becomes a gate that "creates only the one screen needed". | measured, vanilla | unknown | BC-S11, VN server_form.json:138 and 300 |
| COL-12 | A comparison of ways to stop creation. | measured, vanilla | unknown | BC-S8, BC-S11, VN |
| COL-13 | A row type factory creates a cell for every matching row. If there are three slider rows, three slider cells are created per socket. Cells that are not their own row are pushed off screen with #anchored_offset_value_y (((not #mine) * 1000)). | measured | unknown | BC-S9 |
| COL-14 | If you declare an engine factory of the same name once more at another location, a second UI is created from the same data. All three packs use this method: server_form_factory (BC, BA), hud_title_text_factory (BA, AP) and chat_item_factory (AP). | working pack, code (source) | - | BC 4.1-(1), BA chapters 2 and 6, AP 4.1 and 4.5, BW-form, BW-intro |
| COL-15 | factory_variables: ["$a", "$b"] passes the factory host's variables to the created controls. The engine looks up each name in the scope that declared the factory and passes its value (COL-41). Vanilla uses it 37 times (store, pdp, marketplace_sdl, realms_settings, toast_screen, etc.), but none of this project's sources measured it in game. | vanilla, code (binary) | unknown | VN store_common.json and others 37 uses, NB-04 |
| COL-16 | max_children_size is the maximum number a factory creates (vanilla HUD chat 50, AP toast 12). A second factory sharing the same data uses up the limit even on invisible items. | vanilla, working pack, inferred | - | VN hud_screen.json:1041, AP 4.5 |
| COL-17 | Controls created by an engine factory sometimes receive data as variables. The vanilla actionbar label uses "text": "$actionbar_text", and AP reads $title_text in a control created by hud_title_text_factory and decides with ignored. A variable is decided once at creation, so when the value changes the factory recreates the control. | vanilla, working pack | - | VN hud_screen.json:2158, AP 4.1, BW-intro |
| COL-18 | If the cells a factory creates are big, opening the screen is slow. BA had hundreds of controls in one node, so opening took several seconds when all tabs were sent, and it was changed to send only the selected tab's node. Reducing cell size x count comes first. | working pack | - | BA chapter 4 |
| COL-19 | The action form collection (form_buttons) in 1.26.50 vanilla receives not only button but also label, header and divider rows. The selection of the response counts only buttons, so mixing in label() shifts the collection index and the selection number. When using it as a data channel, send every entry with button() and make cells that must not be pressable by removing the button mapping. | vanilla, code (source) | - | VN server_form.json:126-134, BC 4.1-(3) |
| COL-20 | The custom_form rows of a modal form and formValues line up 1:1. A label() is also a row and null arrives in its place in the response. | measured | unknown | BC-S3 |
| COL-21 | A multiselect row was added to the custom_form factory in 1.26.50 vanilla, but the public Script API (@minecraft/server-ui 2.2.0~2.5.0-beta, both ModalFormData and CustomForm) has no method that sends this row. A server that sends the form JSON directly can use it (HOST-46). | vanilla, code (source), measured | unknown | VN server_form.json:294, MJ 4.1, MS |
| COL-22 | If you give a factory with control_ids a string array (the list of keys of that control_ids) through #collection_length, it creates controls of those kinds in array order. An expression cannot build an array, so put the array in property_bag in advance ("#list1": ["apple", "label"]) and pick it by assembling the name with ('#list' + #choice). A control_name factory takes an integer. With #collection_length only in property_bag and no binding, nothing was created, array or integer, and binding a global that does not exist to #collection_length gave the same (measurement record). | measured | Windows 1.26.65.1 | BW-dyn, 2 screenshots, 2026-11-19 Windows 1.26.65.1 |
| COL-23 | A '#name' string made by an expression is read as the value of that name in the same control's property_bag (dictionary lookup). COL-22 and bedrock-core's screen routing (HOST-06 ('#route_' + #title_text)) are the same mechanism. Principle: if the result of a parenthesized group is a #name string, it is replaced by the value in that control's bag (EXP-35). | measured, code (source) | unknown | BW-dyn screenshot, BC 4.1-(2), CN-run |
| COL-24 | A factory driven directly by #collection_length goes in the factory property of a container that supports collections (stack_panel, collection_panel). The wiki example worked with only stack_panel + factory without collection_name. | measured | unknown | BW-dyn screenshot |
| COL-25 | For a "type": "factory" control, the control name is the factory name (server_form_factory). Make a second factory with "type": "panel" + "factory": { "name": "server_form_factory", … } and name the control so it does not collide with the original or siblings. The engine does not read a factory name separately from a type: factory control, and other types read name of the factory object (COL-42). | code (binary), vanilla | unknown | NB-05, VN server_form.json, BW-form (beware of name collision) |
| COL-26 | Factories and grids used with collections automatically attach an index to the controls they create. | unverified | - | BW-dyn |
| COL-27 | #collection_length accepts an integer, a boolean (1/0) and an array of role names. A literal numeric length creates that many only in a control_name template factory. A role name not in the factory creates nothing. The engine also gives a role name array (["tag", …]) as a length value on the store screen (COL-46). | code (source), code (binary) | unknown | NB-14 (role name array), CN tests N12 and B41 (the rest) |
| COL-28 | If control_name exists, control_ids is not read. Do not put both together. max_children_size: 0 is unlimited. | code (source), code (binary) | unknown | NB-06 (control_name first), CN (max_children_size: 0) |
| COL-29 | Cells of a control_name template and of grid_item_template see the $variables of where the factory was declared. Controls made by control_ids see only their own variables and those passed with factory_variables. The engine builds the control_name prototype in the declaring scope when resolving the factory (COL-45). | code (source), code (binary) | unknown | NB-13 (control_name prototype), CN, COL-15 reinforcement |
| COL-30 | The engine writes the grid cell count as #grid_number_size, the factory creation count as #collection_number_size and the collection size as #collection_total_items into the bag. A view binding can read them for use such as an "empty" indicator. | code (source) | - | CN tests B55 and B41 |
| COL-34 | The client held the action form's #form_button_length at the button count of the largest form seen so far (debug label 93, still 93 after reconnecting, unchanged with always_when_visible too). If you set the grid size from this value, empty cells continue in a smaller form. Send the cell count separately through a data channel such as the body (EXP-45). It did not reproduce on Windows 1.26.65.1 (2026-11-19): a 4-button form opened after a 30-button form gave 4 (measurement record). | measured, conflict | Windows 1.26.65.1, Windows 1.26.52 | DF, 2026-11-19 Windows 1.26.65.1 |
| COL-35 | A wrapping grid gives cells to hidden buttons too. Send marker buttons such as tab, back and page after the cell buttons (if placed before, the cells start shifted), and put only the number of cell buttons in the grid size (putting more made one extra empty row and the window scrolled a few pixels). | measured | Windows 1.26.52 | DF |
| COL-36 | Factory and grid lengths followed the value even when computed with an expression of #form_button_length. On Windows 1.26.65.1, a stack_panel with collection_name: "form_buttons" and a factory (control_name) was placed inside a factory-created router window, and 6 buttons were sent. With always on the length binding, #form_button_contents made 6, #form_button_length made 6, (#form_button_length - 1) made 5, and ((#form_button_length * 0) + 1) made 1. With binding_condition: "visible" on the length binding, every factory made 0, even the vanilla form #form_button_contents. In a grid with grid_rescaling_type: "horizontal", #maximum_grid_items from #form_button_length (always_when_visible) gave 6 cells and from (#form_button_length - 1) gave 5 cells (measurement log). The DF measurement (Windows 1.26.52), taken in another structure, recorded that an expression (* 1, * (marker match)) made the factory create no buttons and the grid become the expression itself; this structure did not reproduce it. When a factory comes out empty, check the length binding's condition first. | measured | Windows 1.26.65.1, Windows 1.26.52 | DF, 2026-11-18 Windows 1.26.65.1 |
| COL-37 | With a stack that walks whole buttons per row (a 48-cell grid + a material row), the screen took 4~5 seconds to open, and switching to a fixed layout that reads only one button per cell with collection_index (COL-06) made it about 1 second. Also put only one button per cell (having both a pressable one and a non-pressable one doubles the controls). | measured | Windows 1.26.52 | DF |
| COL-38 | collection_index took effect only on a direct child of a stack_panel that has collection_name. When that place was a panel, Unknown property [collection_index] and [collection_name] were printed in the content log and it was empty (the same conclusion as COL-01 and COL-02, and the same for the chest screen container_items). | measured | Windows 1.26.52 | DF |
| COL-39 | Dictionary lookup routing (HOST-06) worked: with "property_bag": { "#df_layout_1": [ "on" ], "#df_layout_0": [] } on a stack_panel, "factory": { "control_ids": { "on": "…" } }, and #collection_length bound from (('#df_layout_' + (condition * 1))), the layout was created only when the condition matched. There was no freeze or exit (a different result from DBG-19). ('#if_' + boolean) also became '#if_true' or '#if_false' and found the property_bag key (measurement record). | measured | Windows 1.26.65.1, Windows 1.26.52 | DF, 2026-11-19 Windows 1.26.65.1 |
| COL-40 | Fixed collection_index cells inside a layout created by our factory also receive action form data, but they need a binding condition. On Windows 1.26.65.1, the fixed cells in the window of a router inserted with insert_back into main_screen_content of server_form were empty on first open with the default condition and filled from the first open with always on both bindings (measurement record, COL-47). panel + factory created nothing. In one setup (DF) only grid (grid + collection_name) cells received data, and fixed cells and an inner #form_button_contents factory stayed empty even with always; the router position in that setup was not checked. With a 1x1 grid lazy root in the same router window (grid [1,1], #maximum_grid_items set to the button count with once and to a title check expression with visible) and fixed collection_index 0, 4, 5 on a stack_panel inside its cell, the cells filled from the first open even with the default binding condition (same on a second open, record). | measured | Windows 1.26.65.1, Windows 1.26.52 | DF, 2026-11-19 Windows 1.26.65.1 |
| COL-41 | factory_variables is read only when it is an array and silently ignored if not. If an item is not a string, it leaves the error factory_variables should all be strings of json variables created higher up the tree.. Each name is looked up in the scope of the control that declared the factory, and its value is stored in the factory and received by the created controls (the same as the inference in COL-15). | code (binary) | unknown | NB-04 |
| COL-42 | If it is "type": "factory" and that control directly has control_name or control_ids, the factory name is not read separately (the control name is the factory name, COL-25). Other types create a factory only when a "factory": { … } object exists, and if its name is empty it leaves The factory name should not be empty!. | code (binary) | unknown | NB-05 |
| COL-43 | A factory reads control_name first and reads control_ids only when it is empty (COL-28). insert_location inserts at the front only when the value is exactly "front" and anything else is back (default back). | code (binary) | unknown | NB-06 |
| COL-44 | When creating a control, if the parent has a collection component with a collection name, that control automatically becomes a collection item. collection_index is read only then (default -1) and fixes the index. So collection_index is meaningful only on a direct child of a collection parent (the same conclusion as COL-02 and COL-38). For a control that is a direct child but must not become an item (a decorative panel, etc.), give "ignoreCollectionItem": true. | code (binary) | unknown | NB-07 |
| COL-45 | Factory resolution path: if it is "type": "factory" and directly has control_name or control_ids, it resolves without a name, and otherwise, regardless of type, it resolves only when factory is an object and reads name (you may also write a factory object on a type: factory). Only one factory attaches to one control. control_name builds the prototype right away with the declaring control's variable scope at resolution, and control_ids stores only the kind and definition string (the COL-29 difference). max_children_size is 0 if omitted. | code (binary) | unknown | NB-13 |
| COL-46 | tags_factory_first_hidden_child_index, languages_factory_first_hidden_child_index and <prefix>_first_hidden_child_index, which vanilla does not have, are exclusive to the store detail screen description component. This integer in the property bag decides from which tag or language to hide or push to the next row, and an array repeating "tag" or "language" that many times is given as the length binding value. It is not a general factory feature, so it is not used in server form or HUD factories. Who uses this value was not checked. | code (binary) | unknown | NB-14 |
| COL-47 | Inside a window created by the dictionary lookup router (HOST-06) placed in $screen_content of third_party_server_screen, the fixed collection_index cells, the radio toggle cells and a stack factory of length #form_button_contents all received action form data. But if the cells' collection, collection_details and body bindings had the default condition, they were empty on first open and filled after switching a tab once, and when all were set to binding_condition: "always" they were filled as soon as it opened. On Windows 1.26.65.1, fixed cells measured with a router inserted with insert_back into main_screen_content of server_form behaved the same: empty on first open with the default condition (both when opened from the HUD and when coming from a menu form), and filled from the first open with always on both bindings (measurement record). When the fixed cells sit inside the cell of a 1x1 grid lazy root (grid [1,1], #maximum_grid_items set to the button count with once and to a title check expression with visible) instead of directly in the router collection_panel, they filled from the first open even with the default condition (2026-11-19 Windows 1.26.65.1, record). | measured | Windows 1.26.65.1 | FFR |
| COL-48 | A factory placed inside a cell created by a factory created nothing at first if #title_text and the length binding had the default condition. Giving those two bindings always made it created as soon as it opened. Changing the inside to a grid also worked. Having a size animation recalculate the layout, or reading the length from an outside data source, had no effect. | measured | unknown | FFR |
| COL-49 | When drawing buttons in a 2-column grid (cell height 30px), it was fine up to 2000 (about 30000px), and at 3000 (about 45000px) and above only the scroll range was long and the cells were drawn overlapping within the top 200px or so. The cause was not confirmed. Drawing the same count as a one-column vertical stack factory of length #form_button_contents drew but lagged heavily. | measured | unknown | FFR |
| COL-50 | For a 2D layout of fixed collection_index cells, put horizontal stack_panel rows that have collection_name inside a vertical stack_panel, and put the cells as direct children of the rows (COL-38, LAY-56). If the cell parent was a panel, every cell drew the same button (index 0) even with different indices per cell, and adding a collection_details binding or toggle_grid_collection_name to the cells did not change it. | measured | unknown | FFR |
Proposed rules
These proposals are not merged into the adopted rules yet. Check the evidence before using them.
| ID | Rule | Level | Evidence environment | Source |
|---|---|---|---|---|
| COL-31 | The action form row count is read through the global binding #form_button_length. Put it into the factory's #collection_length or the grid's #maximum_grid_items with binding_name_override. The vanilla 1.26.50 UI does not use this name. On Windows 1.26.65.1, a form with 35 buttons, 4 label, 3 divider and 2 header rows gave 44, so label, divider and header rows are counted too (measurement record). | working pack, measured | Windows 1.26.65.1 | SLB chapter 8, EUB example |
| COL-32 | Use a creation-time expression in collection_index: "$start_index": "(($size - '§c§h§e§s§t' - '§') * 1)", "collection_index": "($start_index + 9)". One template then makes fixed slots whose start index differs per size. The * 1 here is applied to a subtraction result, so it is harmless. | unverified | - | CU |
| COL-33 | Show the length of a collection whose count the engine does not give with the last grid cell. Attach a collection_name: players_collection grid with bottom_left inside a holder with clips_children: true (size [180, 12]) so only the last row shows, and print ('players online: ' + (#collection_index + 1) + '§z') in the cell label. | unverified | - | SP |
| id | Source | License | Commit | Accessed |
|---|---|---|---|---|
repo-guide | JSON UI comprehensive guide (this repository) (guide/) | This project's material | 2026-11-13 | |
private-research | Private research (-) | - | 2026-11-13 |