GUI、HUD、资源与模型 Schema 参考
本页目录
Schema 是配置结构参考,不是业务授权,也不代替客户端实际表现。完整配置实例与消费步骤见GUI、声明式 HUD、资源和原生模型。这些 Schema 取自本批源码,外部字段不能仅凭猜测新增。
CustomGUI / ReplaceChest
根对象遵守 gui 或 replaceChest 分支;组件、布局、脚本的 required、范围与枚举在 definitions 中。id 保持稳定、嵌套深度/数量受编辑器与运行时限制。unknown 字段被 Schema 允许也不意味着消费者实现了该功能。
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://shadowui.local/schema/custom-gui.schema.json",
"title": "ShadowUI CustomGUI and ReplaceChest document",
"oneOf": [
{"$ref": "#/definitions/gui"},
{"$ref": "#/definitions/replaceChest"}
],
"definitions": {
"identifier": {
"type": "string",
"pattern": "^[A-Za-z0-9_.:-]{1,64}$"
},
"gui": {
"type": "object",
"required": ["id", "width", "height"],
"anyOf": [
{"required": ["components"]},
{"required": ["children"]}
],
"properties": {
"id": {"$ref": "#/definitions/identifier"},
"guiname": {"type": "string"},
"x": {"type": "integer"},
"y": {"type": "integer"},
"width": {"type": "integer", "minimum": 1, "maximum": 4096},
"height": {"type": "integer", "minimum": 1, "maximum": 4096},
"background": {"type": "string"},
"res": {"type": "string"},
"components": {
"type": "array",
"maxItems": 256,
"items": {"$ref": "#/definitions/component"}
},
"children": {
"type": "array",
"maxItems": 256,
"items": {"$ref": "#/definitions/component"}
},
"scripts": {
"type": "array",
"items": {"$ref": "#/definitions/script"}
}
}
},
"baseComponent": {
"type": "object",
"required": ["id", "type"],
"properties": {
"id": {"$ref": "#/definitions/identifier"},
"type": {"type": "string"},
"x": {"type": "integer"},
"y": {"type": "integer"},
"width": {"type": "integer", "minimum": 1},
"height": {"type": "integer", "minimum": 1},
"visible": {"type": "boolean"},
"enabled": {"type": "boolean"},
"zIndex": {"type": "integer"},
"variable": {"type": "string"},
"var": {"type": "string"},
"background": {"type": "string"},
"backgroundTexture": {"type": "string"},
"backgroundOpacity": {"type": "number", "minimum": 0, "maximum": 1},
"action": {"type": "string", "pattern": "^[A-Za-z0-9_.:-]{1,128}$"},
"click": {
"type": "object",
"properties": {
"action": {"type": "string", "pattern": "^[A-Za-z0-9_.:-]{1,128}$"}
}
},
"animate": {"type": "object"},
"animation": {"type": "object"}
}
},
"component": {
"oneOf": [
{"$ref": "#/definitions/canvasComponent"},
{"$ref": "#/definitions/textComponent"},
{"$ref": "#/definitions/imageComponent"},
{"$ref": "#/definitions/buttonComponent"},
{"$ref": "#/definitions/textInputComponent"},
{"$ref": "#/definitions/dropdownComponent"},
{"$ref": "#/definitions/scrollComponent"},
{"$ref": "#/definitions/slotComponent"},
{"$ref": "#/definitions/entityComponent"}
]
},
"canvasComponent": {
"allOf": [
{"$ref": "#/definitions/baseComponent"},
{
"properties": {
"type": {"enum": ["canvas"]},
"viewX": {"type": "integer"},
"viewY": {"type": "integer"},
"contentHeight": {"type": "integer", "minimum": 1},
"clip": {"type": "boolean"},
"components": {
"type": "array",
"maxItems": 256,
"items": {"$ref": "#/definitions/component"}
},
"children": {
"type": "array",
"maxItems": 256,
"items": {"$ref": "#/definitions/component"}
}
}
}
]
},
"textComponent": {
"allOf": [
{"$ref": "#/definitions/baseComponent"},
{
"properties": {
"type": {"enum": ["text"]},
"text": {"type": "string"},
"color": {"type": "string"},
"shadow": {"type": "boolean"},
"scale": {"type": "number", "exclusiveMinimum": 0},
"align": {"enum": ["left", "center", "right"]},
"wrap": {"type": "boolean"},
"lineHeight": {"type": "integer", "minimum": 1}
}
}
]
},
"imageComponent": {
"allOf": [
{"$ref": "#/definitions/baseComponent"},
{
"properties": {
"type": {"enum": ["image"]},
"texture": {"type": "string"},
"resource": {"type": "string"},
"opacity": {"type": "number", "minimum": 0, "maximum": 1},
"gif": {"type": "boolean"},
"frameTicks": {"type": "integer", "minimum": 1},
"frames": {
"type": "array",
"items": {"type": "string"}
}
}
}
]
},
"buttonComponent": {
"allOf": [
{"$ref": "#/definitions/baseComponent"},
{
"properties": {
"type": {"enum": ["button"]},
"text": {"type": "string"},
"textColor": {"type": "string", "pattern": "^#?[0-9A-Fa-f]{6}$"},
"hoverTextColor": {"type": "string", "pattern": "^#?[0-9A-Fa-f]{6}$"},
"disabledTextColor": {"type": "string", "pattern": "^#?[0-9A-Fa-f]{6}$"},
"textYOffset": {"type": "integer", "minimum": -32, "maximum": 32},
"textShadow": {"type": "boolean"},
"texture": {"type": "string"},
"hoverTexture": {"type": "string"},
"pressedTexture": {"type": "string"},
"disabledTexture": {"type": "string"},
"textures": {
"type": "object",
"properties": {
"normal": {"type": "string"},
"hover": {"type": "string"},
"pressed": {"type": "string"},
"disabled": {"type": "string"}
}
}
}
}
]
},
"textInputComponent": {
"allOf": [
{"$ref": "#/definitions/baseComponent"},
{
"properties": {
"type": {"enum": ["textinput", "textfield", "customtextfield", "customtextfiled"]},
"placeholder": {"type": "string"},
"default": {},
"mode": {"enum": ["text", "number", "numeric"]},
"min": {"type": "number"},
"max": {"type": "number"},
"maxLength": {"type": "integer", "minimum": 1},
"syncMode": {"enum": ["change", "submit"]},
"drawBackground": {"type": "boolean"},
"textColor": {"type": "string", "pattern": "^#?[0-9A-Fa-f]{6}$"},
"defaultColor": {"type": "string", "pattern": "^#?[0-9A-Fa-f]{6}$"},
"color": {"type": "string", "pattern": "^#?[0-9A-Fa-f]{6}$"},
"disabledTextColor": {"type": "string", "pattern": "^#?[0-9A-Fa-f]{6}$"},
"placeholderColor": {"type": "string", "pattern": "^#?[0-9A-Fa-f]{6}$"},
"textYOffset": {"type": "integer", "minimum": -32, "maximum": 32},
"textAlign": {"enum": ["left", "center", "right"]},
"align": {"enum": ["left", "center", "right"]}
}
}
]
},
"dropdownComponent": {
"allOf": [
{"$ref": "#/definitions/baseComponent"},
{
"properties": {
"type": {"enum": ["dropdown", "select"]},
"default": {},
"value": {},
"options": {
"type": "array",
"items": {
"oneOf": [
{"type": "string"},
{
"type": "object",
"required": ["value"],
"properties": {
"value": {},
"label": {"type": "string"}
}
}
]
}
}
}
}
]
},
"scrollComponent": {
"allOf": [
{"$ref": "#/definitions/baseComponent"},
{
"required": ["target"],
"properties": {
"type": {"enum": ["scroll", "scrollbar"]},
"target": {"$ref": "#/definitions/identifier"},
"direction": {"enum": ["vertical", "horizontal"]},
"step": {"type": "integer", "minimum": 1}
}
}
]
},
"slotComponent": {
"allOf": [
{"$ref": "#/definitions/baseComponent"},
{
"properties": {
"type": {"enum": ["slot", "item"]},
"scale": {"type": "number", "exclusiveMinimum": 0},
"tooltip": {"type": "boolean"},
"item": {
"type": "object",
"required": ["id"],
"properties": {
"id": {"type": "string"},
"count": {"type": "integer", "minimum": 0},
"amount": {"type": "integer", "minimum": 0},
"meta": {"type": "integer"},
"damage": {"type": "integer"},
"nbt": {"type": "string"}
}
}
}
}
]
},
"entityComponent": {
"allOf": [
{"$ref": "#/definitions/baseComponent"},
{
"properties": {
"type": {"enum": ["entity", "mob"]},
"scale": {"type": "number", "exclusiveMinimum": 0},
"entity": {
"oneOf": [
{"type": "string"},
{
"type": "object",
"properties": {
"id": {"type": "string"},
"name": {"type": "string"},
"nbt": {"type": "string"}
}
}
]
},
"rotation": {
"type": "object",
"properties": {
"yaw": {"type": "number"},
"pitch": {"type": "number"},
"autoRotate": {"type": "boolean"}
}
}
}
}
]
},
"script": {
"type": "object",
"anyOf": [
{"required": ["target"]},
{"required": ["componentid"]}
],
"properties": {
"target": {"$ref": "#/definitions/identifier"},
"componentid": {"$ref": "#/definitions/identifier"},
"action": {
"enum": ["resize", "setTexture", "texture", "setBackground", "background", "show", "hide", "toggleVisible", "set"]
},
"width": {"type": "integer", "minimum": 1},
"height": {"type": "integer", "minimum": 1},
"texture": {"type": "string"},
"background": {"type": "string"},
"set": {"type": "object"},
"when": {
"type": "object",
"properties": {
"visible": {"type": "boolean"},
"type": {"type": "string"},
"slotItemId": {"type": "string"},
"slotItemMeta": {"type": "integer"},
"slotItemCountMin": {"type": "integer", "minimum": 0}
}
}
}
},
"replaceChest": {
"type": "object",
"required": ["matchTitle"],
"properties": {
"enabled": {
"type": "boolean",
"description": "Only true documents are synchronized automatically; omitted means false."
},
"matchTitle": {"type": "string"},
"matchMode": {"enum": ["EXACT", "CONTAINS", "REGEX"]},
"texture": {"type": "string"},
"width": {"type": "integer", "minimum": 1},
"height": {"type": "integer", "minimum": 1},
"guiLeftOffset": {"type": "integer"},
"guiTopOffset": {"type": "integer"},
"titleLeftOffset": {"type": "integer"},
"titleTopOffset": {"type": "integer"},
"widthPos": {"type": "integer"},
"heightPos": {"type": "integer"},
"scale": {"type": "number", "exclusiveMinimum": 0},
"showTitle": {"type": "boolean"},
"drawDefaultBackground": {"type": "boolean"},
"translateMode": {"enum": ["REDIRECT", "MOVE"]},
"slotHideMode": {"enum": ["DEFAULT", "HIDE"]},
"slotConfigs": {
"type": "array",
"items": {
"type": "object",
"required": ["index"],
"properties": {
"index": {"type": "integer", "minimum": 0, "maximum": 89},
"visible": {"type": "boolean"},
"redirect": {"type": "boolean"},
"x": {"type": "integer"},
"y": {"type": "integer"},
"scale": {"type": "number", "exclusiveMinimum": 0}
}
}
},
"_editor": {
"type": "object",
"properties": {
"chestRows": {"type": "integer", "minimum": 1, "maximum": 6}
}
},
"customGui": {"$ref": "#/definitions/gui"}
},
"anyOf": [
{"required": ["customGui"]},
{"required": ["customgui"]}
]
}
}
}
Declarative HUD
锚点、尺寸、组件与动画按本 Schema;它不赋予服务端支付、技能或数据持久化功能。
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://shadowui.local/schema/custom-hud.schema.json",
"title": "ShadowUI Declarative HUD",
"type": "object",
"required": ["id", "components"],
"properties": {
"id": {"type": "string", "pattern": "^[a-z0-9_.:-]{1,64}$"},
"anchor": {"enum": ["top_left", "top_center", "top_right", "center", "bottom_left", "bottom_center", "bottom_right"]},
"scale": {"type": "number", "exclusiveMinimum": 0, "maximum": 16},
"components": {"type": "array", "maxItems": 256, "items": {"$ref": "custom-gui.schema.json#/definitions/component"}}
}
}
远程资源清单
URL、摘要、大小和类型必须与实际资源一致;安全下载策略、回执与 Provider 说明见资源教程。示例域名不是正式下载服务。
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://shadowui.local/schema/resource-manifest.schema.json",
"title": "ShadowUI Resource Manifest v1",
"type": "object",
"required": ["manifestId", "serverId", "resources"],
"properties": {
"manifestId": {"type": "string", "pattern": "^[A-Za-z0-9_.:-]{1,64}$"},
"serverId": {"type": "string", "pattern": "^[A-Za-z0-9_.-]{1,64}$"},
"resources": {
"type": "array", "maxItems": 512,
"items": {
"type": "object", "required": ["path", "url", "sha256", "size"],
"properties": {
"type": {"type": "string", "enum": ["image", "font", "sound", "model"]},
"namespace": {"type": "string", "pattern": "^[a-z0-9_.-]{1,64}$"},
"path": {"type": "string", "pattern": "^assets/[A-Za-z0-9_./-]{1,233}$"},
"url": {"type": "string", "format": "uri", "pattern": "^https://"},
"sha256": {"type": "string", "pattern": "^[a-fA-F0-9]{64}$"},
"size": {"type": "integer", "minimum": 0},
"version": {"type": "string", "pattern": "^[A-Za-z0-9_.:+-]{1,64}$"},
"ttlSeconds": {"type": "integer", "minimum": 0, "maximum": 31536000},
"fallbackPath": {"type": "string", "pattern": "^assets/[A-Za-z0-9_./-]{1,233}$"}
},
"additionalProperties": false
}
}
}
}
原生模型配置
此 Schema 只约束根结构和 kind 等公共部分,没有完整描述每一种模型/动画字段,不能因为 Schema 检查通过就宣称全部字段已被消费者接受。具体字段、条件与资源需求必须结合模型配置教程及实际解析器核对。
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://shadowui.local/schema/model-config.schema.json",
"title": "ShadowModel Config v1",
"type": "object",
"required": ["schemaVersion", "entries"],
"properties": {
"schemaVersion": {"const": 1},
"entries": {
"type": "object",
"propertyNames": {"pattern": "^.{1,128}$"},
"additionalProperties": {
"type": "object",
"required": ["kind"],
"properties": {
"kind": {"enum": ["model", "player-skeleton", "block-skull", "effect", "bedrock-particle", "animation", "player-action-binding", "tooltip"]}
}
}
}
},
"additionalProperties": false
}