컬렉션과 팩토리
컬렉션과 팩토리는 JSON UI에서 개수가 정해지지 않은 목록을 그리는 장치다. 서버 폼의 버튼 수, 상자의 슬롯 수, 채팅 줄 수처럼 화면을 쓰는 시점에야 알 수 있는 데이터를 다룬다.
- 컬렉션(collection): 엔진이 주는 항목 목록이다. 폼 버튼(
form_buttons), 모달 폼 행(custom_form), 상자 슬롯(container_items), 채팅 줄(chat_text_grid)이 있고, 항목마다#form_button_text나#item_id_aux같은 값 바인딩이 따라온다.collection_name을 가진 컨테이너 안에서collection_index로 몇 번째 항목을 읽을지 정하고, 바인딩은binding_collection_name으로 어느 컬렉션을 읽을지 가리킨다. - 팩토리(factory): 항목 수만큼 컨트롤을 실행 중에 만드는 장치다. 컨테이너의
factory속성(또는"type": "factory"컨트롤)에 무엇을 만들지(control_name,control_ids)를 적고, 몇 개를 만들지는 엔진이 정하거나#collection_length바인딩이 정한다. - 그리드(grid): 같은 템플릿 컨트롤을 격자로 배치하는 컨테이너다.
grid_dimensions로 칸 수를 고정하거나#maximum_grid_items로 개수를 정한다.
가장 작은 예제
예 1. 고정 인덱스 슬롯(팩토리 없이 컬렉션만 읽기, COL-06). 서버가 항상 같은 개수의 버튼을 보내면 각 칸이 몇 번째 항목을 읽을지 JSON에 박아 둘 수 있다.
"tab_slots": { "type": "stack_panel", "orientation": "horizontal",
"collection_name": "form_buttons",
"controls": [
{ "slot0@my.tab_cell": { "collection_index": 0 } },
{ "slot1@my.tab_cell": { "collection_index": 1 } }
] }
예 2. 개수를 바인딩으로 정하는 팩토리(아래 Bedrock Wiki 원문의 첫 예제). 타이틀 문자열 Count:3에서 숫자를 꺼내 #collection_length에 넣으면 컨트롤이 3개 만들어진다. 0이면 아무것도 만들지 않는다(COL-11).
예 3. 엔진 팩토리 다시 두기(COL-14). 같은 이름의 팩토리를 하나 더 두면 같은 데이터로 두 번째 UI가 생긴다.
"server_form_factory": { "type": "factory",
"control_ids": { "long_form": "@my.long_form", "custom_form": "@my.custom_form" } }
Bedrock Wiki의 설명(Dynamic Content Generation)
Bedrock Wiki(bedrock-wiki 0930b39)는 팩토리와 그리드를 이렇게 설명한다. 원문(CC BY 4.0)을 그대로 옮긴다. 이 문서가 쓰는 #collection_length, control_ids 배열, #maximum_grid_items, grid_position의 기본 용법이다. 위키 예제는 HUD의 타이틀 문자열(#hud_title_text_string)을 재료로 쓴다.
발췌: Dynamic Content Generation - Factories · docs/json-ui/dynamic-content-generation.md · Bedrock Wiki · 라이선스 CC BY 4.0 (저장소의 docs/licenses/CC-BY-4.0.md) · 커밋 0930b39Factories
A factory generates UI elements specified in its
control_nameorcontrol_idsproperties.
- Invocation: Many of the vanilla factories are invoked natively by the engine. Alternatively, factories can be invoked manually by overriding the
#collection_lengthproperty.- Data Binding: For the use of
#collection_length, the factory must reside within a collection-supporting container (e.g.,collection_panelorstack_panel). The value can either be anintor astring[]based on the implementation of the factory.Key properties
Property Type Short Description name stringThe unique identifier for the factory. This is critical for factories natively invoked by the engine, though custom factories can use any arbitrary string. control_name stringReference to the control to be generated by the factory control_ids ObjectAn object mapping arbitrary string keys to the references of the controls to be generated. Used when generating multiple distinct controls. Must remain unchanged for natively invoked factories. factory_variables string[]List of variables that should be passed to the controls generated by the factory max_children_size intMaximum number of controls to be generated Usage
Using
control_name:In this case,
#collection_lengthmust be overridden with anintvalue. This is the number of elements that will be generated.{"hud_apple": {"type": "image","texture": "textures/items/apple","size": [32, 32]},"apple_factory": {"type": "stack_panel","size": [ "100%cm", "100%c" ],"factory": { // Defined in a stack_panel (Supports collection)"name": "hud_apple_factory","control_name": "hud.hud_apple" // Reference to hud_apple},"bindings": [{"binding_name": "#hud_title_text_string","binding_name_override": "#count"},{"binding_type": "view","source_property_name": "(#count - 'Count:' + 0)", // Gets the int value"target_property_name": "#collection_length" // Overriding #collection_length}]}}Here, an integer value is sent through the title as
Count:{value}that indicates the number of elements to generate. The bindings listed above first fetch the title string and store it in#count. Then,#count - 'Count:'gets theintvalue and#collection_lengthis overridden with this value. Note:+ 0sets a default value of 0 if the string is empty.Expected result: For title:
Count:3Using
control_ids:In this case,
#collection_lengthmust be overridden with an array of strings. The strings are the keys defined incontrol_ids. There's not much freedom with this approach as there is no way to manipulate arrays in JSON UI. Instead, we can pre-define some arrays within theproperty_bagand choose from them. The elements will be generated in the order specified in the array.{"hud_apple": {"type": "image","texture": "textures/items/apple","size": [32, 32]},"hud_label": {"type": "label","text": "Apple!","shadow": true},"apple_factory": {"type": "stack_panel","size": [ "100%cm", "100%c" ],"factory": {"name": "hud_apple_factory","control_ids": {"apple": "hud.hud_apple", // An arbitrary name mapped to the reference of a control"label": "hud.hud_label"}},"property_bag": {// Some pre-defined arrays"#list1": [ "apple", "label" ],"#list2": [ "label", "apple" ]},"bindings": [{"binding_name": "#hud_title_text_string","binding_name_override": "#choice"},{"binding_type": "view","source_property_name": "('#list' + #choice)", // Constructing key name"target_property_name": "#collection_length"}]}}Here, we have defined two controls in
control_idsand two arrangements of these controls as#list1and#list2. In the bindings, we fetch the title string and store it in#choice, which is an integer representing the list to be selected. Then using('#list' + #choice), we construct the name of the list and that list is then overridden to#collection_length.Expected result: For title:
1and2respectively
발췌: Dynamic Content Generation - Factory (Extra) · docs/json-ui/dynamic-content-generation.md · Bedrock Wiki · 라이선스 CC BY 4.0 (저장소의 docs/licenses/CC-BY-4.0.md) · 커밋 0930b39Factory (Extra):
You can define factories directly using
"type": "factory"as well. These factories are always invoked natively by the engine. However, it is possible to define these factories in the ways discussed above we can also modify the control references to generate custom elements instead.{"main_screen_content": { // Vanilla code from server_form.json"type": "panel","size": [0, 0],"controls": [{"server_form_factory": { // Name of control here acts as the factory name and thus should remain unchanged"type": "factory","control_ids": {"long_form": "@server_form.long_form","custom_form": "@server_form.custom_form"}}}]}}
발췌: Dynamic Content Generation - Grids · docs/json-ui/dynamic-content-generation.md · Bedrock Wiki · 라이선스 CC BY 4.0 (저장소의 docs/licenses/CC-BY-4.0.md) · 커밋 0930b39Grids
Grids generate and arrange UI elements in a grid layout. The elements are generated from a template control specified in its
grid_item_templateproperty. We can either generate a fixed number of elements by defininggrid_dimensionsor a variable number by overriding its#maximum_grid_itemsbinding ormaximum_grid_itemsproperty.Key properties
위험Try not to use
verticalas the value ofgrid_rescaling_type. It may crash your game.Usage
정보Grids typically have a default size of
["100%c", "100%c"]. It is ideal to keep the height dynamic (100%c). If a fixed height is applied, generated elements may overlap if the height is too small, or have unintended gaps if the height is too large.Using
grid_dimensions:It is recommended not to override the
sizeproperty in this case, as some elements can go outside the grid bounds and mess up the layout.{"hud_apple": {"type": "image","texture": "textures/items/apple","size": [32, 32]},"apple_grid": {"type": "grid","grid_dimensions": [3, 3],"grid_item_template": "hud.hud_apple"}}Expected result:
Overriding
#maximum_grid_items:For this to work properly, you have to modify the width of the grid. This is because the number of columns in this case will be
floor( width of grid / width of template control ). Moreover, we need to setgrid_rescaling_typetohorizontal. Then we have to override#maximum_grid_itemsthrough bindings, or alternatively, define themaximum_grid_itemsproperty.{"hud_apple": {"type": "image","texture": "textures/items/apple","size": [32, 32]},"apple_grid": {"type": "grid","size": [160, "100%c"], // floor(160 / 32) = 5; Meaning the grid will have 5 columns"grid_item_template": "hud.hud_apple","grid_rescaling_type": "horizontal","bindings": [{"binding_name": "#hud_title_text_string","binding_name_override": "#count"},{"binding_type": "view","source_property_name": "(#count - 'Count:' + 0)", // Gets the int value"target_property_name": "#maximum_grid_items" // Overriding #maximum_grid_items}]}}Here, an integer value is sent through the title as
Count:{value}that indicates the number of elements to generate. The bindings listed above first fetch the title string and store it in#count. Then,#count - 'Count:'gets theintvalue and#maximum_grid_itemsis overridden with this value.Expected result: For title:
Count:15Grid Position
There might be situations where you'd want to manually add controls to the grid instead of generating them from a template. With the
grid_positionproperty you can place your control anywhere on the grid.Usage
Let's say we have a grid with 2 columns and 2 rows and we want to place our controls in this way-
The format
[row, column]indicates the placement within the grid, where the first integer is the row index and the second integer is the column index. The following integer is the index it takes inside the grid for a defined collection.The code:
{"hud_apple": {"type": "image","texture": "textures/items/apple","size": [32, 32]},"apple_grid": {"type": "grid","size": ["100%c", "100%c"], // Define it explicitly to avoid layout issues"grid_dimensions": [2, 2],"controls": [{"apple_1@hud.hud_apple": {"grid_position": [0, 0]}},{"apple_2@hud.hud_apple": {"grid_position": [1, 1]}}]}}Expected result:
Useful Information
- When used with a collection, Factories and Grids automatically index generated elements.
- Generated elements can access outside bindings via
source_control_name, but outside elements cannot access bindings from generated elements.- Invisible elements inside a Grid still occupy physical space, which can leave unintentional gaps in your UI.
- In Grids, animations linked with the
nextproperty can appear bugged. After the first animation, the duration divides among the grid elements, causing subsequent animations to speed up. (flip_bookanimations are the only exception).
이 원문과 이 프로젝트 실측의 차이를 정리한다.
- 위키는
(#count - 'Count:' + 0)을 쓴다. 결과가 숫자가 되는 이유는 EXP-26(식의 중간 결과는 생김새로 타입이 다시 정해진다)이다. 확실히 하려면((#count - 'Count:') - 0)으로 쓴다. - 위키는 팩토리를
collection_name없이stack_panel+factory만으로 만든다. 같은 방식이 실측으로 동작했다(COL-24). - 위키는 팩토리·그리드 안의 컨트롤이 바깥 바인딩은
source_control_name으로 읽지만 바깥은 안쪽을 읽지 못한다고 적는다(BND-19와 같은 결론). - 위키의 "그리드 안에서
next로 이은 애니메이션이 빨라지는 버그"와grid_rescaling_type: vertical이 게임을 멈출 수 있다는 경고는 ANI-18(미검증)로 옮겼다. - 그리드 속성 정리:
grid_dimensions([열, 행]),grid_dimension_binding(칸 수 바인딩 이름, 하드코딩된 이름만),grid_item_template(셀 정의 참조),grid_rescaling_type(none,horizontal,vertical),maximum_grid_items(최대 개수, 바인딩#maximum_grid_items),grid_position([행, 열])이다. 열 수는floor(그리드 폭 / 템플릿 폭)이다.
엔진이 주는 목록 데이터(폼 버튼, 모달 행, 상자 슬롯, 채팅 줄, 대화 버튼)를 읽는 방법이 컬렉션이고, 그 목록의 항목 수만큼 컨트롤을 만드는 장치가 팩토리다. 팩토리 전체 정리는 팩토리 종합에 있다.
출처가 Cinnabar(CN, 26.30 네이티브 클라이언트의 JSON UI 해석기를 재구성한 Rust 코드)인 근거는 수준이 코드이고, CN-run은 이 프로젝트가 그 평가기를 직접 실행한 결과다. 게임 실측과 다르면 실측을 따른다. NB는 Android 1.26.52.3 클라이언트의 네이티브 라이브러리를 분석해 읽은 것이고 수준은 코드다. DF는 연구 서버를 만들며 Windows 1.26.52에서 실측한 것으로, 서버 폼 하나로 여러 화면을 그리는 구조에서 얻었다. FFR은 서버 폼 팩토리와 렉 시험 애드온을 모바일에서 실측한 것이다(2026-11-14). 애드온 구성은 서버 폼 연구 화면에 있다.
컬렉션 주소 지정
- [COL-01]
collection_name은stack_panel,grid,collection_panel에 쓴다.panel,image에 쓰면Unknown property [collection_name]오류가 난다.{실측, 바닐라}(출처: BC-facts, BC-S9, BC-S11, VN grid 66·stack_panel 25·collection_panel store_common.json:750, MJ 9장) - [COL-02]
collection_index는 인스턴스화 지점(부모controls안의 항목)에서만 받는다. 최상위 정의에 쓰면 거부되고,image에는 어디서든 거부된다.label에서는 읽힌다: Windows 1.26.65.1에서collection_namestack_panel바로 아래label에collection_index를 주자 값(b1)을 읽었다(실측 기록). 엔진은 컬렉션 이름을 가진 부모의 직속 자식에서만collection_index를 읽는다(COL-44).{실측, 코드(바이너리)}(출처: BC-facts, NB-07, BC 4.1-(4)) - [COL-03] 인덱스는 적용된 지점부터 하위 트리로 상속된다. 그래서 정의는 한 번 쓰고, 참조 N개에 인덱스와 오프셋만 다르게 주는 패턴이 성립한다. 컬렉션을 읽는 바인딩은 각자
binding_collection_name으로 컬렉션을 지정한다.{실측}(출처: BC-facts) - [COL-04] 서버 폼 버튼은 버튼 자신에
{ "binding_type": "collection_details", "binding_collection_name": "form_buttons" }가 있어야 눌림이 그 엔트리로 집계된다. 조상만 인덱스를 주면 눌리기는 하지만 스크립트에는canceled로 와서 Esc와 구분할 수 없고 로그도 없다(사용자가 닫으면reason=UserClosed가 오는데, 바인딩 누락 때의 reason으로 구분되는지는 확인되지 않았다). 바닐라 폼 버튼도 같은 구조다.{실측, 바닐라}(출처: BC-S1, BC-facts, VN server_form.json:211-225) - [COL-05] 인덱스 호스트가 하나도 없는 컬렉션 바인딩은 0번 항목을 읽는다. 바닐라 상자 라벨을 0번 슬롯 아이템으로 숨기는 데 이 성질을 썼다.
{실측}(출처: BC-facts) - [COL-06] 팩토리 없이 고정 인덱스 슬롯을 만들 수 있다:
collection_name을 가진 스택 안에collection_index를 박은 자식을 둔다. 스크립트는 항상 같은 개수의 엔트리를 보내(빈 값 포함) 인덱스를 고정한다.{작동팩, 코드(소스)}(출처: BA 5장 탭 28슬롯, BC 4.1-(3))
"tab_slots": { "type": "stack_panel", "orientation": "horizontal",
"collection_name": "form_buttons",
"controls": [
{ "slot0@my.tab_cell": { "collection_index": 1 } },
{ "slot1@my.tab_cell": { "collection_index": 2 } } ] }
- [COL-26] 컬렉션과 함께 쓰는 팩토리·그리드는 만든 컨트롤에 인덱스를 자동으로 붙인다.
{미검증}(출처: BW-dyn) - [COL-38]
collection_index는collection_name을 가진stack_panel의 바로 아래 자식에서만 먹었다. 그 자리를panel로 두면 콘텐츠 로그에Unknown property [collection_index]·[collection_name]이 찍히고 비었다(COL-01, COL-02와 같은 결론, 상자 화면container_items도 같다).{실측}(출처: DF) - [COL-44] 컨트롤을 만들 때 부모에 컬렉션 이름이 있는 컬렉션 컴포넌트가 있으면 그 컨트롤은 자동으로 컬렉션 항목이 된다.
collection_index는 이때만 읽혀(기본 -1) 인덱스를 고정한다. 그래서collection_index는 컬렉션 부모의 직속 자식에서만 의미가 있다(COL-02, COL-38과 같은 결론). 직속 자식이지만 항목이 되면 안 되는 컨트롤(장식 패널 등)에는"ignoreCollectionItem": true를 준다.{코드(바이너리)}(출처: NB-07) - [COL-50] 고정
collection_index칸의 2차원 배치는 세로stack_panel안에collection_name을 가진 가로stack_panel줄을 두고, 칸을 줄의 바로 아래 자식으로 둔다(COL-38, LAY-56). 칸 부모가panel이면 칸마다 다른 인덱스를 줘도 모두 같은 버튼(인덱스 0)을 그렸고, 칸에collection_details바인딩이나toggle_grid_collection_name을 더해도 바뀌지 않았다.{실측}(출처: FFR)
컬렉션에서 값 읽기
| 컬렉션 | 항목 값 바인딩(예) | 출처 |
|---|---|---|
form_buttons (액션 폼) | #form_button_text, #form_button_texture, #form_button_texture_file_system | VN server_form.json, BC, BA |
custom_form (모달 폼) | #custom_toggle_state, #custom_slider_steps, #custom_slider_value, #custom_dropdown_length … | VN, BC 4.2 |
custom_dropdown, custom_multiselect | #custom_radio_toggled, #custom_radio_text, #dropdown_option_text, #custom_multiselect_toggled | VN server_form.json:485·582, MJ 4.1 |
container_items (상자) | #item_id_aux, #inventory_stack_count, #item_durability_current_amount, #item_durability_total_amount, #item_custom_color | BC-facts, BC-S14 |
student_buttons_collection (NPC 대화) | #student_button_text (+ binding_collection_prefix: "student_buttons") | VN npc_interact_screen.json:1180, AP 4.3 |
chat_text_grid (채팅) | #chat_text | AP-samples hud_screen.json |
- [COL-07] 상자 슬롯의 내구도(
#item_durability_current_amount,#item_durability_total_amount)는collection_details+collection바인딩 쌍으로 읽으면 일반 컨트롤에서도 읽히고 비교·나눗셈이 된다.#item_durability_current_amount는 남은 내구도다(피해 100인 철 검에서((0 + 값) > 100)이 참). 값은 float이라 비교는 되지만 문자열에 이어 붙이면 아무것도 나오지 않는다(EXP-22).('D ' + (0 + 값)),('D ' + (값 * 1))는 바인딩 방식과 상관없이'D '만 냈다. 글자로 보이려면 비교 사슬로 구간을 나눈다.{실측, 추론}(출처: BC-S14, BC-S6, BC 6.8-7, CPR) - [COL-30] 엔진은 그리드 칸 수를
#grid_number_size, 팩토리 생성 수를#collection_number_size, 컬렉션 크기를#collection_total_items로 주머니에 쓴다. view 바인딩으로 읽어 "비었음" 표시 등에 쓸 수 있다.{코드(소스)}(출처: CN 테스트 B55·B41)
팩토리
팩토리는 두 가지 모양이 있다.
// (가) 팩토리 컨트롤: type 이 factory. 바닐라 server_form 의 진입점
"server_form_factory": { "type": "factory",
"control_ids": { "long_form": "@server_form.long_form", "custom_form": "@server_form.custom_form" } },
// (나) 컨테이너의 factory 속성: 스택/패널/collection_panel 이 셀을 만든다
"long_form_dynamic_buttons_panel": { "type": "stack_panel",
"factory": { "name": "buttons",
"control_ids": { "button": "server_form.dynamic_button", "label": "@server_form.dynamic_label",
"header": "@server_form.dynamic_header", "divider": "@settings_common.option_group_section_divider" } },
"collection_name": "form_buttons",
"bindings": [ { "binding_name": "#form_button_contents", "binding_name_override": "#collection_length" } ] }
- [COL-08] 팩토리는 (가)
"type": "factory"컨트롤(바닐라 36회, 공식 enum에 없음)이거나 (나) 컨테이너의"factory": { … }속성이다.factory객체의 키는name,control_name(한 종류) 또는control_ids(종류별),max_children_size,factory_variables다.{바닐라}(출처: VN server_form.json:25·126, VN factory 키 집계) - [COL-09]
control_ids의 키는 엔진이 정한 데이터 종류이고, 값은"@ns.정의"(바닐라 197회),"인스턴스이름@ns.정의"(36회),"ns.정의"(5회, 예 server_form.json:128)다. 액션 폼 행은button,label,header,divider, 모달 행은label,toggle,slider,step_slider,dropdown,input,header,divider,multiselect, HUD는hud_title_text,hud_actionbar_text, 채팅은chat_item이다.{바닐라}(출처: VN server_form.json:126·283, hud_screen.json:3406·3417·1040) - [COL-10]
visible은 그리기만 막고 생성과 레이아웃은 막지 못한다. 서버 폼 아래에 붙인 화면은visible로 가려도 모든 폼을 열 때마다 전부 생성·레이아웃된다(5,546개 컨트롤 재배치 실측). 그 안의 슬라이더처럼 생성 시 상태를 검증하는 컴포넌트는 숨겨져 있어도 assert를 낸다. 컨트롤 자신의binding_condition: "visible"도 조상이 숨었을 때 평가를 막지 못한다.{실측}(출처: BC-S8, BW-best) - [COL-11]
#collection_length를 바인딩하면 팩토리가 그 수만큼만 셀을 만든다. 0이면 아무것도 만들지 않는다.((#mode = 'on') * 1)같은 계산 길이로 "필요한 화면 하나만 생성"하는 게이트가 된다.{실측, 바닐라}(출처: BC-S11, VN server_form.json:138·300) - [COL-12] 생성을 막는 방법 비교.
{실측, 바닐라}(출처: BC-S8, BC-S11, VN)
| 방법 | 평가 시점 | 조건 재료 | 비용 |
|---|---|---|---|
ignored | 컨트롤 생성 시 한 번 | $변수만 | 생성 안 함 |
팩토리 #collection_length | 런타임, 바인딩 | #바인딩 식 | 0이면 생성 안 함 |
visible | 매 프레임 | #바인딩 식 | 생성·레이아웃 비용 그대로 |
- [COL-13] 행 타입 팩토리는 매칭되는 모든 행마다 셀을 만든다. 슬라이더 행이 셋이면 슬라이더 셀이 소켓마다 셋 생긴다. 자기 행이 아닌 셀은
#anchored_offset_value_y로 화면 밖으로 민다(((not #mine) * 1000)).{실측}(출처: BC-S9) - [COL-14] 같은 이름의 엔진 팩토리를 다른 위치에 한 번 더 선언하면 같은 데이터로 두 번째 UI가 만들어진다. 세 팩이 모두 이 방법을 쓴다:
server_form_factory(BC, BA),hud_title_text_factory(BA, AP),chat_item_factory(AP).{작동팩, 코드(소스)}(출처: BC 4.1-(1), BA 2장·6장, AP 4.1·4.5, BW-form, BW-intro) - [COL-15]
factory_variables: ["$a", "$b"]는 팩토리 호스트의 변수를 만들어진 컨트롤로 넘긴다. 엔진은 각 이름을 팩토리를 선언한 스코프에서 찾아 그 값을 넘긴다(COL-41). 바닐라에서 37회(store, pdp, marketplace_sdl, realms_settings, toast_screen 등) 쓰지만 이 프로젝트 출처 중 게임에서 실측한 곳은 없다.{바닐라, 코드(바이너리)}(출처: VN store_common.json 등 37회, NB-04) - [COL-16]
max_children_size는 팩토리가 만들 최대 개수다(바닐라 HUD 채팅 50, AP 토스트 12). 같은 데이터를 공유하는 두 번째 팩토리는 보이지 않는 항목도 한도를 소모한다.{바닐라, 작동팩, 추론}(출처: VN hud_screen.json:1041, AP 4.5) - [COL-17] 엔진 팩토리가 만든 컨트롤은 데이터를 변수로 받는 경우가 있다. 바닐라 액션바 라벨은
"text": "$actionbar_text"를 쓰고, AP는hud_title_text_factory가 만든 컨트롤에서$title_text를 읽어ignored로 판정한다. 변수는 생성 시 한 번 정해지므로 값이 바뀌면 팩토리가 컨트롤을 다시 만든다.{바닐라, 작동팩}(출처: VN hud_screen.json:2158, AP 4.1, BW-intro) - [COL-18] 팩토리가 만드는 셀이 크면 화면 열기가 느려진다. BA는 노드 하나에 컨트롤 수백 개가 들어 모든 탭을 보내면 여는 데 수 초가 걸렸고, 선택된 탭의 노드만 보내도록 바꿨다. 셀 크기 × 개수를 줄이는 것이 먼저다.
{작동팩}(출처: BA 4장) - [COL-22]
control_ids를 가진 팩토리에#collection_length로 문자열 배열(그control_ids의 키 목록)을 주면 배열 순서대로 그 종류의 컨트롤을 만든다. 식에서 배열을 만들 수는 없으므로property_bag에 배열을 미리 두고("#list1": ["apple", "label"]),('#list' + #choice)로 이름을 조립해 고른다.control_name팩토리는 정수를 받는다.#collection_length를property_bag에만 두고 바인딩하지 않으면 배열이든 정수든 아무것도 만들지 않았고, 없는 전역 바인딩을#collection_length에 걸어도 같았다(실측 기록).{실측}(출처: BW-dyn 스크린샷 2장, 2026-11-19 Windows 1.26.65.1) - [COL-23] 식이 만든
'#이름'문자열은 같은 컨트롤의property_bag에서 그 이름의 값으로 읽힌다(사전 조회). COL-22와 bedrock-core의 화면 라우팅(HOST-06('#route_' + #title_text))이 같은 메커니즘이다. 원리: 괄호 묶음의 결과가#이름문자열이면 그 컨트롤 주머니의 값으로 바뀐다(EXP-35).{실측, 코드(소스)}(출처: BW-dyn 스크린샷, BC 4.1-(2), CN-run) - [COL-24]
#collection_length로 직접 구동하는 팩토리는 컬렉션을 지원하는 컨테이너(stack_panel,collection_panel)의factory속성으로 둔다. 위키 예제는collection_name없이stack_panel+factory만으로 동작했다.{실측}(출처: BW-dyn 스크린샷) - [COL-25]
"type": "factory"컨트롤은 컨트롤 이름이 곧 팩토리 이름이다(server_form_factory). 두 번째 팩토리는"type": "panel"+"factory": { "name": "server_form_factory", … }로 만들고, 컨트롤 이름은 원본·형제와 겹치지 않게 짓는다. 엔진은type: factory컨트롤에서 팩토리 이름을 따로 읽지 않고, 다른 타입은factory객체의name을 읽는다(COL-42).{코드(바이너리), 바닐라}(출처: NB-05, VN server_form.json, BW-form(이름 겹침 주의)) - [COL-42]
"type": "factory"이고 그 컨트롤에control_name이나control_ids가 직접 있으면 팩토리 이름을 따로 읽지 않는다(컨트롤 이름이 팩토리 이름, COL-25). 다른 타입은"factory": { … }객체가 있을 때만 팩토리를 만들고, 그name이 비면The factory name should not be empty!를 남긴다.{코드(바이너리)}(출처: NB-05) - [COL-45] 팩토리 해석 경로:
"type": "factory"이면서control_name·control_ids를 직접 가지면 이름 없이 해석하고, 그 밖에는 타입과 상관없이factory가 객체일 때만 해석해name을 읽는다(type: factory에factory객체를 써도 된다). 컨트롤 하나에는 팩토리가 하나만 붙는다.control_name은 해석할 때 선언한 컨트롤의 변수 스코프로 바로 원형을 만들고,control_ids는 종류와 정의 문자열만 저장한다(COL-29의 차이).max_children_size는 생략하면 0이다.{코드(바이너리)}(출처: NB-13) - [COL-27]
#collection_length는 정수, 불리언(1/0), 역할 이름 배열을 받는다. 리터럴 숫자 길이는control_name템플릿 팩토리에서만 그 수만큼 만든다. 팩토리에 없는 역할 이름은 아무것도 만들지 않는다. 엔진도 상점 화면에서 역할 이름 배열(["tag", …])을 길이 값으로 준다(COL-46).{코드(소스), 코드(바이너리)}(출처: NB-14(역할 이름 배열), CN 테스트 N12·B41(그 밖)) - [COL-28]
control_name이 있으면control_ids는 읽히지 않는다. 둘을 함께 두지 않는다.max_children_size: 0은 무제한이다.{코드(소스), 코드(바이너리)}(출처: NB-06(control_name우선), CN(max_children_size: 0)) - [COL-43] 팩토리는
control_name을 먼저 읽고 비어 있을 때만control_ids를 읽는다(COL-28).insert_location은 값이 정확히"front"일 때만 앞에 넣고 그 밖은 모두 뒤다(기본back).{코드(바이너리)}(출처: NB-06) - [COL-29]
control_name템플릿과grid_item_template의 셀은 팩토리를 선언한 곳의$변수를 본다.control_ids로 만든 컨트롤은 자기 변수와factory_variables로 넘긴 변수만 본다. 엔진은control_name원형을 팩토리 해석 때 선언 스코프로 만든다(COL-45).{코드(소스), 코드(바이너리)}(출처: NB-13(control_name원형), CN, COL-15 보강) - [COL-41]
factory_variables는 배열일 때만 읽고, 배열이 아니면 조용히 무시한다. 항목이 문자열이 아니면factory_variables should all be strings of json variables created higher up the tree.오류를 남긴다. 각 이름은 팩토리를 선언한 컨트롤의 스코프에서 찾아 그 값을 팩토리에 저장하고, 만들어진 컨트롤이 받는다(COL-15의 추론과 같다).{코드(바이너리)}(출처: NB-04) - [COL-36] 팩토리·격자 길이는
#form_button_length의 식으로 계산해도 그 값을 따랐다. Windows 1.26.65.1에서 팩토리가 만든 라우터 창 안에collection_name: "form_buttons"와factory(control_name)를 가진stack_panel을 두고 버튼 6개를 보냈다. 길이 바인딩에always를 주자#form_button_contents는 6개,#form_button_length는 6개,(#form_button_length - 1)은 5개,((#form_button_length * 0) + 1)은 1개를 만들었다. 길이 바인딩이binding_condition: "visible"이면 바닐라 꼴인#form_button_contents까지 모든 팩토리가 0개를 만들었다.grid_rescaling_type: "horizontal"격자의#maximum_grid_items는always_when_visible로#form_button_length를 주면 6칸,(#form_button_length - 1)을 주면 5칸이었다(실측 기록). 다른 구조에서 잰 DF 실측(Windows 1.26.52)은 식(* 1,* (표식 일치))이면 팩토리가 버튼을 만들지 않고 격자는 식 자체가 된다고 기록했는데, 이 구조에서는 재현되지 않았다. 팩토리가 비면 길이 바인딩의 조건부터 본다.{실측}(출처: DF, 2026-11-18 Windows 1.26.65.1) - [COL-39] 사전 조회 라우팅(HOST-06)은 동작했다:
stack_panel에"property_bag": { "#df_layout_1": [ "on" ], "#df_layout_0": [] },"factory": { "control_ids": { "on": "…" } },#collection_length에(('#df_layout_' + (조건 * 1)))를 넣으면 조건이 맞을 때만 레이아웃이 만들어졌다. 멈춤·종료는 없었다(DBG-19와 다른 결과).('#if_' + 불리언)도'#if_true'나'#if_false'가 되어property_bag키를 찾았다(실측 기록).{실측}(출처: DF, 2026-11-19 Windows 1.26.65.1) - [COL-46] 바닐라에 없는
tags_factory_first_hidden_child_index·languages_factory_first_hidden_child_index·<접두어>_first_hidden_child_index는 상점 상세 화면 설명 컴포넌트 전용이다. 속성 주머니의 이 정수로 몇 번째 태그·언어부터 숨기거나 다음 줄로 넘길지 정하고, 그 개수만큼"tag"·"language"를 반복한 배열을 길이 바인딩 값으로 준다. 일반 팩토리 기능이 아니므로 서버 폼·HUD 팩토리에는 쓰지 않는다. 이 값을 누가 쓰는지는 확인하지 않았다.{코드(바이너리)}(출처: NB-14) - [COL-37] 줄마다 버튼 전체를 걷는 스택을 두면(48칸 격자 + 재료 줄) 화면이 여는 데 4~5초 걸렸고, 칸마다
collection_index로 버튼 하나만 읽는 고정 배치(COL-06)로 바꾸니 1초쯤이 됐다. 칸마다 버튼도 하나만 둔다(누르는 것·안 누르는 것을 둘 다 두면 컨트롤이 두 배다).{실측}(출처: DF) - [COL-49] 2열 grid(칸 높이 30px)에 버튼을 그리면 2000개(약 30000px)까지는 정상이고, 3000개(약 45000px) 이상에서는 스크롤 범위만 길게 잡히고 칸들이 맨 위 약 200px 안에 겹쳐 그려졌다. 원인은 확인하지 못했다. 같은 수를
#form_button_contents길이의 세로 스택 팩토리 1열로 그리면 그려지지만 렉이 심했다.{실측}(출처: FFR)
폼 행과 응답 번호
- [COL-19] 1.26.50 바닐라의 액션 폼 컬렉션(
form_buttons)에는button뿐 아니라label,header,divider행도 들어온다. 응답의selection은 버튼만 세므로label()을 섞으면 컬렉션 인덱스와selection번호가 어긋난다. 데이터 채널로 쓸 때는 모든 엔트리를button()으로 보내고, 누를 수 없는 셀은 버튼 매핑을 빼서 만든다.{바닐라, 코드(소스)}(출처: VN server_form.json:126-134, BC 4.1-(3)) - [COL-20] 모달 폼의
custom_form행과formValues는 1:1로 정렬된다.label()도 행이고 응답에는 그 자리에null이 온다.{실측}(출처: BC-S3) - [COL-21] 1.26.50 바닐라
custom_form팩토리에multiselect행이 생겼지만 공개 Script API(@minecraft/server-ui2.2.0~2.5.0-beta,ModalFormData와CustomForm모두)에는 이 행을 보내는 메서드가 없다. 폼 JSON을 직접 보내는 서버는 쓸 수 있다(HOST-46).{바닐라, 코드(소스), 실측}(출처: VN server_form.json:294, MJ 4.1, MS) - [COL-34] 클라이언트는 액션 폼의
#form_button_length를 지금까지 보인 가장 큰 폼의 버튼 수로 붙잡고 있었다(디버그 라벨 93, 재접속 뒤에도 93,always_when_visible로도 그대로). 이 값으로 격자 크기를 정하면 작은 폼에서 빈 칸이 이어진다. 칸 수는 본문 같은 데이터 채널로 따로 보낸다(EXP-45). Windows 1.26.65.1(2026-11-19)에서는 재현되지 않았다: 버튼 30개 폼 다음에 연 버튼 4개 폼에서4였다(실측 기록).{실측, 충돌}(출처: DF, 2026-11-19 Windows 1.26.65.1) - [COL-35] 줄바꿈 격자는 숨은 버튼에도 칸을 준다. 탭·뒤로·쪽 같은 표식 버튼은 칸 버튼 뒤에 보내고(앞에 두면 칸이 밀려 시작), 격자 크기에는 칸 버튼 수만 넣는다(넣으면 빈 줄이 하나 더 생겨 창이 몇 픽셀 스크롤됐다).
{실측}(출처: DF)
팩토리가 만든 창 안의 폼 데이터
- [COL-40] 우리 팩토리가 만든 레이아웃 안의 고정
collection_index칸도 액션 폼 데이터를 받지만, 바인딩 조건이 필요하다. Windows 1.26.65.1에서server_form의main_screen_content에insert_back으로 넣은 라우터 창의 고정 칸은 기본 조건이면 첫 열기에 비었고, 두 바인딩에always를 주자 첫 열기부터 채워졌다(실측 기록, COL-47).panel+factory는 아무것도 만들지 않았다. 한 구성(DF)에서는 격자(grid+collection_name) 칸만 데이터를 받고 고정 칸과#form_button_contents안쪽 팩토리는always로도 비었는데, 그 구성의 라우터 위치는 확인하지 않았다. 같은 라우터 창 안에 1x1 grid 지연 루트(grid[1,1],#maximum_grid_items를once로 버튼 수,visible로 제목 검사 식)를 두고 그 칸 안stack_panel에 고정collection_index0, 4, 5를 두자 바인딩이 기본 조건이어도 첫 열기부터 채워졌다(두 번째 열기도 같음, 기록).{실측}(출처: DF, 2026-11-19 Windows 1.26.65.1) - [COL-47]
third_party_server_screen의$screen_content에 둔 사전 조회 라우터(HOST-06)가 만든 창 안에서는 고정collection_index칸, 라디오 토글 칸,#form_button_contents길이의 스택 팩토리가 모두 액션 폼 데이터를 받았다. 다만 칸의 컬렉션·collection_details·본문 바인딩이 기본 조건이면 처음 열 때 비고 탭을 한 번 바꾸면 채워졌고, 모두binding_condition: "always"로 두자 열자마자 채워졌다. Windows 1.26.65.1에서server_form의main_screen_content에insert_back한 라우터로 고정 칸을 재도 같았다: 기본 조건이면 첫 열기에 비었고(HUD에서 연 경우와 메뉴 폼에서 넘어온 경우 모두), 두 바인딩에always를 주면 첫 열기부터 채워졌다(실측 기록). 고정 칸을 라우터collection_panel에 바로 두지 않고 1x1 grid 지연 루트(grid[1,1],#maximum_grid_items를once로 버튼 수,visible로 제목 검사 식) 칸 안에 두면 기본 조건으로도 첫 열기부터 채워졌다(2026-11-19 Windows 1.26.65.1, 기록).{실측}(출처: FFR) - [COL-48] 팩토리가 만든 칸 안에 둔 팩토리는
#title_text·길이 바인딩이 기본 조건이면 처음에 아무것도 만들지 않았다. 그 두 바인딩에always를 주면 열자마자 만들어졌다. 안쪽을 grid로 바꿔도 됐다. 크기 애니메이션으로 레이아웃을 다시 계산하게 하거나, 길이를 바깥 데이터 소스에서 읽는 방법은 효과가 없었다.{실측}(출처: FFR)
예제: 가장 작은 컬렉션 grid
서버가 보낸 액션 폼 버튼을 2열 grid로 그리는 최소 구성이다. 이 예제는 아래 코드 그대로 게임에서 동작했다 {실측}(예제 실측 기록, 2026-11-27 Windows 1.26.65). grid 버튼 목록의 jup.json과 server_form.json을 줄여 맞춘 것이다.
의지하는 규칙: COL-01, COL-02, COL-10, COL-47. 순서와 조건은 always 없이 첫 화면 채우기를 따른다(BND-37).
게임에서 실측한 완성 애드온은 두 문서에서 내려받는다. grid 버튼 목록은 스크롤 영역, 아이콘, 진행 막대를 갖춘 목록이고, always 없이 첫 화면 채우기는 바인딩 조건이 다른 두 목록의 비교 애드온이다.
RP/
manifest.json
ui/
_ui_defs.json
mygrid.json
server_form.json
manifest.json은 HUD와 타이틀 채널의 10절 예제와 같은 리소스 모듈 하나면 된다. _ui_defs.json은 새 파일만 등록한다. server_form.json은 바닐라와 같은 경로라 등록하지 않는다(FILE-01).
{
"ui_defs": [
"ui/mygrid.json"
]
}
ui/mygrid.json은 칸, grid, 창, 라우터를 정의한다.
{
"namespace": "mygrid",
"cell_face": {
"type": "panel",
"size": [ "100%", "100%" ],
"$bg_texture|default": "textures/ui/button_borderless_light",
"controls": [
{ "bg": { "type": "image", "texture": "$bg_texture", "size": [ "100% - 2px", "100% - 2px" ] } },
{
"name": {
"type": "label",
"layer": 3,
"size": [ 90, 10 ],
"offset": [ 6, 10 ],
"anchor_from": "top_left",
"anchor_to": "top_left",
"color": [ 0.1, 0.1, 0.1 ],
"localize": false,
"text": "#text",
"bindings": [
{ "binding_type": "collection", "binding_collection_name": "form_buttons", "binding_name": "#form_button_text" },
{ "binding_type": "view", "source_property_name": "('%.12s' * #form_button_text)", "target_property_name": "#text" }
]
}
}
]
},
"cell@common.button": {
"size": [ 100, 30 ],
"$focus_enabled": false,
"$pressed_button_name": "button.form_button_click",
"bindings": [
{ "binding_type": "collection_details", "binding_collection_name": "form_buttons", "binding_condition": "always" }
],
"controls": [
{ "default@mygrid.cell_face": {} },
{ "hover@mygrid.cell_face": { "$bg_texture": "textures/ui/button_borderless_lighthover" } },
{ "pressed@mygrid.cell_face": { "$bg_texture": "textures/ui/button_borderless_lightpressed" } }
]
},
"button_grid": {
"type": "grid",
"size": [ 200, "100%c" ],
"offset": [ 0, 20 ],
"anchor_from": "top_middle",
"anchor_to": "top_middle",
"grid_rescaling_type": "horizontal",
"grid_item_template": "mygrid.cell",
"collection_name": "form_buttons",
"bindings": [
{ "binding_name": "#form_button_length", "binding_name_override": "#maximum_grid_items", "binding_condition": "always" }
]
},
"list_window": {
"type": "image",
"texture": "textures/ui/dialog_background_opaque",
"size": [ 224, 140 ],
"layer": 60,
"controls": [
{ "close@common.close_button": {} },
{ "grid@mygrid.button_grid": {} }
]
},
"screen_router": {
"type": "collection_panel",
"size": [ "100%", "100%" ],
"factory": {
"name": "mygrid_screen",
"control_ids": { "g": "@mygrid.list_window" }
},
"property_bag": { "#§b§wmg:G": [ "g" ] },
"bindings": [
{ "binding_name": "#title_text" },
{ "binding_type": "view", "source_property_name": "('#' + ('%.10s' * #title_text))", "target_property_name": "#collection_length" }
]
}
}
ui/server_form.json은 라우터를 server_form_factory 옆에 끼운다.
{
"namespace": "server_form",
"main_screen_content": {
"size": [ "100%", "100%" ],
"modifications": [
{
"array_name": "controls",
"operation": "insert_back",
"value": [ { "mygrid_router@mygrid.screen_router": {} } ]
}
]
}
}
서버는 제목이 §b§wmg:G인 액션 폼에 버튼 몇 개를 담아 보낸다. 버튼 5개로 보내자 칸이 2열로 놓이고 칸마다 버튼 글의 앞 12바이트가 보였으며, 네 번째 칸을 누르자 서버가 selection 3을 받았다. 제목이 다른 폼에서는 grid 창이 생기지 않았다 {실측}. 바닐라 폼은 뒤에 그대로 그려진다.
규칙과 코드의 대응은 이렇다.
collection_name은grid에 둔다.panel이나image에 두면Unknown property오류가 난다(COL-01).- 이 예제는
collection_index를 쓰지 않는다. grid가 칸에 인덱스를 자동으로 주는지는{미검증}(COL-26)이고, 고정 인덱스를 주는collection_index는collection_name을 가진 부모의 직속 자식에서만 읽힌다(COL-02, COL-38, COL-44). 고정 칸이 필요하면 라벨을 패널로 감싸 패널 참조에 인덱스를 준다(COL-02). visible은 그리기만 막고 생성과 레이아웃은 막지 못하므로(COL-10), 이 폼이 아닌 서버 폼에서는 라우터가 창을 0개 만들게 한다. 제목 앞 10바이트로property_bag을 조회해#collection_length에 넣는 방식은 HOST-06, COL-22, COL-23의 것이다.- 라우터가 만든 창 안에서 grid 길이와 칸의
collection_details는binding_condition: "always"로 둔다. 기본 조건이면 처음 열 때 비었다(COL-47, COL-48). 칸 안 라벨은 컬렉션 바인딩 다음 view 바인딩 순서로 두고 조건을 쓰지 않는다(BND-37).
예제에서 위키에 근거가 없어 남긴 것: 스크롤 영역(버튼이 많으면 창 밖으로 넘친다, 스크롤 구성은 완성 애드온에 있다), 바닐라 폼을 이 제목에서 숨기는 바인딩(애드온의 server_form.json에 있다), 창과 칸의 크기. 2열 grid는 버튼 3000개 이상에서 칸이 겹쳐 그려졌다(COL-49).
| id | 출처 | 라이선스 | 커밋 | 접근일 |
|---|---|---|---|---|
repo-guide | JSON UI 종합 가이드 (이 저장소) (guide/) | 이 프로젝트 자료 | 2026-11-13 | |
bedrock-samples | Mojang bedrock-samples | Minecraft EULA 적용, (c) Mojang AB. 모든 권리 보유 | 15701fa9 (가이드 기준 46ba6ea) | 2026-11-13 |
bedrock-wiki | Bedrock Wiki | CC BY 4.0 (저장소의 docs/licenses/CC-BY-4.0.md) | 0930b39 | 2026-11-13 |
ms-learn | Minecraft Creator 문서 (Microsoft Learn) | CC BY 4.0 (문서), MIT (코드) | a9fd1c0 | 2026-11-13 |
private-research | 비공개 조사 (-) | - | 2026-11-13 | |
bedrock-core | bedrock-core UI (@bedrock-core/ui) | MIT (저장소 LICENSE 확인, Copyright 2026 bedrock-core) | aee2bbd (분석 기준, 클론 HEAD 51d5cf2) | 2026-11-13 |
advancementpack | AdvancementPack (r4isen1920) | MIT (저장소 LICENSE 확인, Copyright 2024 r4isen1920) | 0a79929 (분석 대상 v4.2, 2026-10-20 조사) | 2026-11-13 |
cinnabar | Cinnabar (json-ui 크레이트) | PolyForm Noncommercial License 1.0.0 (저장소 LICENSE 확인). 동작 확인과 구현 참고에만 쓰고 원문은 옮기지 않는다 | ceb0fb6 (분석 기준, 클론 HEAD df826f5) | 2026-11-13 |
starlibv2 | StarLibV2 | GPL-3.0 (저장소 LICENSE 확인) | 6bf7875 | 2026-11-13 |