interface AddonBiomeDefinitionComponents { [key: string]: any; } declare class AddonBiome { format_version: string; definition: AddonBiomeDefinition; constructor(format_version: string, definition: AddonBiomeDefinition); toObject(): Record; } declare class AddonBiomeDescription { identifier: string; constructor(identifier: string); } declare class AddonBiomeDefinition { description: AddonBiomeDescription; components: AddonBiomeDefinitionComponents; constructor(description: AddonBiomeDescription, components: AddonBiomeDefinitionComponents); } declare class AddonFeatureRule { format_version: string; denifition: AddonFeatureRuleDenifition; constructor(format_version: string, denifition: AddonFeatureRuleDenifition); toObject(): Record; } declare class AddonFeatureRuleDenifition { description: AddonFeatureRuleDecription; conditions: any; distribution: any; constructor(description: AddonFeatureRuleDecription, conditions: any, distribution: any); } declare class AddonFeatureRuleDecription { identifier: string; places_feature: string; constructor(identifier: string, places_feature: string); } interface ManifestOptions { allow_random_seed?: boolean; lock_template_options?: boolean; pack_scope?: string; base_game_version?: string; min_engine_version?: string; } declare class AddonSemanticVersion { major: number; minor: number; patch: number; constructor(major: number, minor: number, patch: number); toString(): string; } declare class AddonManifestHeader { name: string; description: string; version: AddonSemanticVersion; uuid: string; allow_random_seed?: boolean; lock_template_options?: boolean; pack_scope?: string; base_game_version?: string; min_engine_version?: string; constructor(name: string, description: string, version: AddonSemanticVersion, uuid: string, options?: ManifestOptions); } declare class AddonManifestModule { description: string; type: string; uuid: string; version: AddonSemanticVersion; constructor(description: string, moduleType: string, uuid: string, version: AddonSemanticVersion); } declare class AddonManifestDependency { module_name: string; uuid: string; version: AddonSemanticVersion; constructor(name: string, uuid: string, version: AddonSemanticVersion); } declare class AddonManifestMetadata { authors: string[]; license: string; generated_with: string[]; product_type?: string; url?: string; constructor(authors: string[], license: string, generatedWith: string[], productType?: string, url?: string); } declare class AddonManifest { format_version: number; header: AddonManifestHeader; modules: AddonManifestModule[]; dependencies: AddonManifestDependency[]; capabilities?: string[]; metadata?: AddonManifestMetadata; constructor(formatVersion: number, header: AddonManifestHeader, modules: AddonManifestModule[], dependencies: AddonManifestDependency[], capabilities?: string[] | null, metadata?: AddonManifestMetadata | null); } declare class AddonMenuCategory { category: string; group?: string; is_hidden_in_commands?: boolean; constructor(category: string, group?: string, is_hidden?: boolean); } declare class AddonBlock { format_version: string; definitions: AddonBlockDefinition; constructor(format_version: string, definitions: AddonBlockDefinition); toObject(): Record; } declare class AddonBlockDefinition { description: AddonBlockDescription; components: Record; permutations: any[]; constructor(description: AddonBlockDescription, components: Record, permutations?: any[]); } declare class AddonBlockDescription { identifier: string; traits: Record; states: Record; menu_category: AddonMenuCategory; constructor(identifier: string, traits: Record, states: Record, menu_category: AddonMenuCategory); } declare class AddonAnimationController { format_version: string; definition: AddonAnimationStateMachine; constructor(format_version: string, definition: AddonAnimationStateMachine); toObject(): Record; } declare class AddonAnimationStateMachine { identifier: string; namespace: string; name: string; initialState: string | null; states: Map[]; }>; constructor(identifier: string); setInitialState(stateName: string): this; addState(stateName: string, animations?: string[]): this; addTransition(fromState: string, toState: string, condition: string): this; toObject(): Record; } declare class AddonRenderControllerGroup { static id: number; format_version: string; render_controllers: Map; constructor(format_version: string, render_controllers?: Map); setRenderController(identifier: string, render_controller: AddonRenderController): this; addRenderController(render_controller: AddonRenderController): this; toObject(): Record; } declare class AddonRenderController { name: string; arrays: Record; geometry: string; materials: string[]; textures: string[]; constructor(name: string); setGeometry(geometry: string): this; addMaterial(material: string): this; addTexture(texture: string): this; registerArray(name: string, array: any[]): this; registerGeometriesArray(array: any[]): this; registerTexturesArray(array: any[]): this; toObject(): Record; } declare class AddonClientEntity { format_version: string; definitions: AddonClientEntityDefinition; constructor(format_version: string, definitions: AddonClientEntityDefinition); toObject(): Record; } declare class AddonClientEntityDefinition { description: AddonClientEntityDescription; constructor(description: AddonClientEntityDescription); } declare class AddonClientEntityDescription { identifier: string; min_engine_version?: string; particle_effects?: Record; materials?: Record; textures?: Record; geometry?: Record; animations?: Record; animation_controllers?: Record[]; render_controllers?: string[]; locators?: Record; spawn_egg?: { texture: string; texture_index: number; }; scripts?: Record; constructor(identifier: string, min_engine_version?: string); addParticleEffect(name: string, particle: any): this; addMaterial(name: string, material: string): this; addTexture(name: string, texture: string): this; addGeometry(name: string, geometry: string): this; addAnimation(name: string, animation: string): this; addAnimationController(name: string, controller: string): this; addRenderController(controller: string): this; addLocator(name: string, locator: any): this; setSpawnEgg(texture: string, texture_index: number): this; setScript(key: string, value: any): this; } declare class AddonEntity { format_version: string; definitions: AddonEntityDefinition; constructor(format_version: string, definitions: AddonEntityDefinition); toObject(): Record; } declare class AddonEntityDefinition { description: AddonEntityDescription; components: Record; component_groups: Record; events: Record; constructor(description: AddonEntityDescription, components?: Record, component_groups?: Record, events?: Record); } declare class AddonEntityDescription { identifier: string; is_spawnable: boolean; is_summonable: boolean; properties: Record; runtime_identifier?: string; constructor(identifier: string, is_spawnable?: boolean, is_summonable?: boolean, properties?: Record, runtime_identifier?: string); } declare class AddonOreFeature { format_version: string; definition: AddonOreFeatureDefinition; constructor(format_version: string, definition: AddonOreFeatureDefinition); toObject(): Record; } declare class AddonOreFeatureDescription { identifier: string; constructor(identifier: string); } declare class AddonOreFeatureDefinition { description: AddonOreFeatureDescription; count: number; replace_rules: any[]; constructor(description: AddonOreFeatureDescription, count: number, replace_rules: any[]); } declare class AddonAttachable { format_version: string; definitions: AddonAttachableDefinition; constructor(format_version: string, definitions: AddonAttachableDefinition); toObject(): Record; } declare class AddonAttachableDefinition { description: AddonAttachableDescription; constructor(description: AddonAttachableDescription); } declare class AddonAttachableDescription { identifier: string; materials?: Record; textures?: Record; geometry?: Record; animations?: Record; animation_controllers?: Record[]; render_controllers?: string[]; locators?: Record; scripts?: Record; constructor(identifier: string); addMaterial(name: string, material: string): this; addTexture(name: string, texture: string): this; addGeometry(name: string, geometry: string): this; addAnimation(name: string, animation: string): this; addAnimationController(name: string, controller: string): this; addRenderController(controller: string): this; addLocator(name: string, locator: unknown): this; setScript(key: string, value: unknown): this; } declare class AddonItem { format_version: string; definitions: AddonItemDefinition; constructor(format_version: string, definitions: AddonItemDefinition); toObject(): Record; } declare class AddonItemDefinition { description: AddonItemDescription; components: Record; constructor(description: AddonItemDescription, components: Record); } declare class AddonItemDescription { identifier: string; menu_category: AddonMenuCategory; constructor(identifier: string, menu_category: AddonMenuCategory); } declare class AddonRecipe { format_version: string; recipe_type: string; definitions: Record; constructor(format_version: string, recipe_type: string, definitions?: Record); getId(): string; identifier(identifier: string): this; tags(tags: string[]): this; toObject(): Record; } declare const RecipeInputTags: Record; declare const RecipeTags: Record; declare const RecipeTypes: Record; declare class AddonRecipeFurnace extends AddonRecipe { constructor(format_version: string, definitions: Record); static create(ver: string, def: Record): AddonRecipeFurnace; input(item: string, data?: any, count?: number): this; output(item: string): this; } declare class AddonRecipeFurnace_1_12 extends AddonRecipeFurnace { constructor(definitions?: Record); } declare class AddonRecipeFurnace_1_17 extends AddonRecipeFurnace { constructor(definitions?: Record); } declare class AddonRecipeShaped extends AddonRecipe { constructor(format_version: string, definitions: Record); assumeSymmetry(): void; key(key: Record): this; pattern(pattern: string[]): this; priority(priority: number): this; output(item: string | Record): this; static create(ver: string, def: Record): AddonRecipeShaped; } declare class AddonRecipeShaped_1_12 extends AddonRecipeShaped { constructor(definitions?: Record); } declare class AddonRecipeShaped_1_17 extends AddonRecipeShaped { constructor(definitions?: Record); } declare class AddonRecipeShaped_1_19 extends AddonRecipeShaped { constructor(definitions?: Record); } declare class AddonRecipeShaped_1_20 extends AddonRecipeShaped { constructor(definitions?: Record); } declare class AddonRecipeShapeless extends AddonRecipe { constructor(format_version: string, definitions: Record); static create(ver: string, def: Record): AddonRecipeShapeless; priority(priority: number): this; ingredients(ingredients: any[]): this; output(item: string | Record): this; } declare class AddonRecipeShapeless_1_12 extends AddonRecipeShapeless { constructor(definitions: Record); } declare class AddonRecipeShapeless_1_17 extends AddonRecipeShapeless { constructor(definitions: Record); } declare class Biome { constructor(identifier: any); identifier: any; components: Map; /** * 添加组件 * @param {Map} componentMap 组件 Map */ addComponent(componentMap: Map): this; toObject(): any; } declare class BiomeComponent { /** * 将多个组件集合合并为一个。 * @param {...Map} componentMaps - 多个组件集合。 * @returns {Map} - 合并后的组件集合。 */ static combineComponents(...componentMaps: Map[]): Map; /** * 设置生物群系的气候参数 * @param {number} downfall - 降水量(范围通常为 0 到 1) * @param {number} snow_accumulation - 积雪量(范围通常为 0 到 1) * @param {number} temperature - 温度(范围通常为 0 到 1) * @returns {Map} 返回一个包含气候参数的 Map 对象,键为 "minecraft:climate" */ static setClimate(downfall: number, snow_accumulation: number, temperature: number): Map; /** * 设置生物群系的世界高度参数(通常用于生成地形) * @param {Object} noise_params - 噪声参数,用于控制地形生成 * @returns {Map} 返回一个包含高度参数的 Map 对象,键为 "minecraft:overworld_height" */ static setOverworldHeight(noise_params: Object): Map; /** * 设置生物群系的表面参数(如地表材料、海底材料等) * @param {Object} params - 表面参数对象,包含以下属性: * @param {number} params.sea_floor_depth - 海底深度 * @param {string} params.sea_floor_material - 海底材料(如 "minecraft:sand") * @param {string} params.foundation_material - 基础材料(如 "minecraft:stone") * @param {string} params.mid_material - 中间层材料(如 "minecraft:dirt") * @param {string} params.top_material - 顶层材料(如 "minecraft:grass_block") * @param {string} params.sea_material - 海洋材料(如 "minecraft:water") * @returns {Map} 返回一个包含表面参数的 Map 对象,键为 "minecraft:surface_parameters" */ static setSurfaceParameters(params: { sea_floor_depth: number; sea_floor_material: string; foundation_material: string; mid_material: string; top_material: string; sea_material: string; }): Map; /** * 设置生物群系在生成时的规则(如适用于哪些气候类型) * @returns {Map} 返回一个包含生成规则的 Map 对象,键为 "minecraft:overworld_generation_rules" */ static setOverworldGenerationRules(medium_weight: any, warm_weight: any, cold_weight: any): Map; } declare class BasicBlock { /** * 基础方块类 * @param {string} identifier 方块唯一标识符 * @param {string} category 菜单栏分类 可选:"construction", "nature", "equipment", "items", and "none" * @param {Array} textures_arr 纹理数组 [上,下,东,西,南,北] * @param {Object} options 可选参数 * @param {string} options.group 分组,默认为 "construction" * @param {boolean} options.hide_in_command 是否在命令中隐藏,默认为 false */ constructor(identifier: string, category: string, textures_arr: any[], options?: { group: string; hide_in_command: boolean; }); format_version: any; identifier: string; category: string; textures: any[]; group: string; hide_in_command: boolean; traits: Map; states: Map; components: Map; permutations: any[]; getId(): string; registerTrait(key: any, value: any): this; registerState(key: any, value: any): this; /** * 添加组件 * @param {Map} componentMap 组件 Map */ addComponent(componentMap: Map): this; /** * 移除组件 * @param {string} key 组件名称 */ removeComponent(key: string): this; /** * 添加方块变体 * @param {string} condition 变体条件 * @param {Map|Object} component 组件 Map 或普通对象 */ addPermutation(condition: string, component: Map | Object): this; /** * 提交前的自检(由 `registry.submit()` → `runValidators()` 在序列化之前调用一次)。 * * ⚠️ 不能在 `registerBlock` 里做这类检查:`BlockAPI.createXxx()` 是「先注册、后 addComponent」, * 注册那一刻用户还没挂组件,检查必然看不到容器组件。真守卫就是这里。 * * 检查两件事,都**只 warn、不改产物**: * * 1. 方块 components 里出现 `minecraft:inventory` —— 它是**实体**组件,不是方块组件, * 引擎必然拒绝(`not present in the Schema`)。容器请走实体路线。 * 2. `minecraft:block_entity.container.slot_count` 超出官方文档的 `[1, 54]` * (`BlockComponent.setBlockEntity({container})` 已经抛错;这里兜住"手写组件对象 / 裸 Map"的写法)。 */ validate(): void; /** * 将方块对象转换为 JSON 格式 * @returns {Object} JSON 格式的方块对象 */ toObject(): Object; } declare class Block extends BasicBlock { /** * 方块类 * @param {string} identifier 方块的唯一标识符 * @param {string} category 方块的分类 "construction", "nature", "equipment", "items", and "none" * @param {Array} variantDatas 方块的变体数据,包含每个变体的状态标签和纹理 * @param {Object} options 可选参数 * @param {string} options.group 分组,默认为 "construction" * @param {boolean} options.hide_in_command 是否在命令中隐藏,默认为 false * @param {boolean} options.ambient_occlusion 是否应用环境光遮蔽,默认为 false * @param {boolean} options.face_dimming 是否根据面的方向进行亮度调整,默认为 false * @param {string} options.render_method 渲染方法,默认为 "alpha_test" */ constructor(identifier: string, category: string, variantDatas: any[], options?: { group: string; hide_in_command: boolean; ambient_occlusion: boolean; face_dimming: boolean; render_method: string; }); options: { group: string; hide_in_command: boolean; ambient_occlusion: boolean; face_dimming: boolean; render_method: string; }; variantDatas: any[]; addVariantComponent(variantIndex: any, componentMap: any): this; #private; } declare class BlockComponent { /** * @param {string} texture - 纹理短名 * @param {Object|string} [options] - 可选参数对象,或旧版 tint_method 字符串 * @param {number} [options.particle_count] - 粒子数量 (0-255,默认 100) * @param {string} [options.tint_method] - 染色方法(如 "grass") * @returns {Map} */ static setDestructionParticles(texture: string, options?: Object | string): Map; /** * 自定义方块组件 * [warning] 需要 Scripting V2.0.0 * @param {string} component_id 组件标识符 * @param {object} params 自定义参数接口对象 * @returns {Map} 物品组件Map */ static setCustomComponentV2(component_id: string, params: object): Map; /** * * @param {Array} interval_range * @param {boolean} looping * @returns {Map} */ static setTick(interval_range: any[], looping: boolean): Map; /** * * @param {Array} custom_components * @returns {Map} */ static setCustomComponents(custom_components: any[]): Map; /** * 创建一个用于 Minecraft 方块的变换对象,并返回一个 Map。 * @param {number[]} [translation=[0, 0, 0]] - 平移向量 [x, y, z]。 * @param {number[]} [scale=[1, 1, 1]] - 缩放向量 [x, y, z]。 * @param {number[]} [scale_pivot=[0, 0, 0]] - 缩放的枢轴点 [x, y, z]。 * @param {number[]} [rotation=[0, 0, 0]] - 旋转向量(角度)[x, y, z]。 * @param {number[]} [rotation_pivot=[0, 0, 0]] - 旋转的枢轴点 [x, y, z]。 * @returns {Map} - 一个包含变换数据的 Map 对象。 * @throws {Error} - 如果任何参数无效,则抛出错误。 */ static setTransformation(translation?: number[], scale?: number[], scale_pivot?: number[], rotation?: number[], rotation_pivot?: number[]): Map; /** * 设置方块的呼吸行为。 * @param {String} value - 呼吸行为,可选值为 "solid" 或 "air"。 * @returns {Map} - 新的组件集合。 */ static setBreathability(value: string): Map; /** * 启用或禁用方块的碰撞箱。 * @param {Boolean} enabled - 是否启用碰撞箱。 * @returns {Map} - 新的组件集合。 */ static setCollisionBoxEnabled(enabled: boolean): Map; /** * 设置自定义的碰撞箱。 * @param {Array} origin - 碰撞箱的起点坐标 [x, y, z]。 * @param {Array} size - 碰撞箱的大小 [width, height, depth]。 * @returns {Map} - 新的组件集合。 */ static setCollisionBoxCustom(origin: any[], size: any[]): Map; /** * 设置方块的合成台属性。 * @param {Array} craftingTags - 合成标签。 * @param {String} tableName - 合成台名称。 * @returns {Map} - 新的组件集合。 */ static setCraftingTable(craftingTags: any[], tableName: string): Map; /** * 启用或禁用方块的爆炸抗性。 * @param {Boolean} enabled - 是否启用爆炸抗性。 * @returns {Map} - 新的组件集合。 */ static setDestructibleByExplosionEnabled(enabled: boolean): Map; /** * 设置自定义的爆炸抗性。 * @param {Number} explosionResistance - 爆炸抗性值。 * @returns {Map} - 新的组件集合。 */ static setDestructibleByExplosionCustom(explosionResistance: number): Map; /** * 启用或禁用方块的挖掘抗性。 * @param {Boolean} enabled - 是否启用挖掘抗性。 * @returns {Map} - 新的组件集合。 */ static setDestructibleByMiningEnabled(enabled: boolean): Map; /** * 设置自定义的挖掘抗性。 * @param {Number} secondsToDestroy - 破坏所需时间(秒)。 * @param {Array} itemSpecificSpeeds - 特定工具的挖掘速度。 * @returns {Map} - 新的组件集合。 */ static setDestructibleByMiningCustom(secondsToDestroy: number, itemSpecificSpeeds: any[]): Map; /** * 设置方块的显示名称。 * @param {String} displayName - 显示名称。 * @returns {Map} - 新的组件集合。 */ static setDisplayName(displayName: string): Map; /** * 启用或禁用方块的易燃性。 * @param {Boolean} enabled - 是否启用易燃性。 * @returns {Map} - 新的组件集合。 */ static setFlammableEnabled(enabled: boolean): Map; /** * 设置自定义的易燃性。 * @param {Number} catchChanceModifier - 着火概率。 * @param {Number} destroyChanceModifier - 被火焰摧毁的概率。 * @param {String} [lava_flammable] - 岩浆能否点燃该方块 ("always"|"never",默认 "never") * @returns {Map} - 新的组件集合。 */ static setFlammableCustom(catchChanceModifier: number, destroyChanceModifier: number, lava_flammable?: string): Map; /** * 设置方块的摩擦力。 * @param {Number} value - 摩擦力值,范围为 0.0 到 0.9。 * @returns {Map} - 新的组件集合。 */ static setFriction(value: number): Map; /** * 设置方块的几何模型。 * @param {String} identifier - 几何模型标识符。 * @param {Object} [options] - 可选参数。 * @param {Object} [options.bone_visibility] - 骨骼可见性配置。 * @param {String} [options.culling] - 裁剪规则标识符(格式: :culling.)。 * @param {String} [options.culling_layer] - 裁剪层标识符(如 "minecraft:culling_layer.leaves")。 * @param {String} [options.culling_shape] - 体素形状(仅支持 "minecraft:unit_cube")。 * @param {Boolean|String[]} [options.uv_lock] - 是否锁定 UV 旋转,或指定骨骼名称数组。 * @returns {Map} - 新的组件集合。 */ static setGeometry(identifier: string, options?: { bone_visibility?: Object | undefined; culling?: string | undefined; culling_layer?: string | undefined; culling_shape?: string | undefined; uv_lock?: boolean | string[] | undefined; }): Map; /** * 设置方块的骨骼可见性。 * @param {Object} bone_visibility - 骨骼可见性配置。 * @returns {Map} - 新的组件集合。 */ static setBoneVisibility(bone_visibility: Object): Map; /** * 设置方块的物品视觉属性。 * @param {String} geometry - 几何模型标识符。 * @param {Object} materialInstances - 材质实例配置。 * @returns {Map} - 新的组件集合。 */ static setItemVisual(geometry: string, materialInstances: Object): Map; /** * 设置方块的光衰减值。 * @param {Number} value - 光的衰减值,范围为 0 到 15。 * @returns {Map} - 新的组件集合。 */ static setLightDampening(value: number): Map; /** * 设置方块的光照强度。 * @param {Number} value - 光照强度,范围为 0 到 15。 * @returns {Map} - 新的组件集合。 */ static setLightEmission(value: number): Map; /** * 设置方块的液体检测属性。 * @param {Boolean|Object} canContainLiquid - 是否可容纳液体,或是完整选项对象 * @param {String} [liquidType] - 液体类型 * @param {String} [onLiquidTouches] - 对液体的反应方式 * @param {Array} [stopsLiquidFlowingFromDirection] - 阻止液体流动的方向 * @returns {Map} - 新的组件集合。 */ static setLiquidDetection(canContainLiquid: boolean | Object, liquidType?: string, onLiquidTouches?: string, stopsLiquidFlowingFromDirection?: any[]): Map; /** * 设置方块的战利品表路径。 * @param {String} path - 战利品表路径。 * @returns {Map} - 新的组件集合。 */ static setLoot(path: string): Map; /** * 设置方块的地图颜色。 * @param {String|Array|Object} value - 地图颜色,可以是十六进制字符串、RGB 数组或对象格式。 * @returns {Map} - 新的组件集合。 */ static setMapColor(value: string | any[] | Object): Map; /** * 设置方块的材质实例。 * @param {Object} instances - 材质实例配置。 * @returns {Map} - 新的组件集合。 */ static setMaterialInstances(instances: Object): Map; /** * 设置方块的放置过滤条件。 * @param {Array} conditions - 放置条件列表。 * @returns {Map} - 新的组件集合。 */ static setPlacementFilter(conditions: any[]): Map; /** * 设置方块的红石导电性。 * @param {Boolean} allowsWireToStepDown - 是否允许红石线向下阶梯连接。 * @param {Boolean} redstoneConductor - 方块是否可以被红石信号激活。 * @returns {Map} - 新的组件集合。 */ static setRedstoneConductivity(allowsWireToStepDown: boolean, redstoneConductor: boolean): Map; /** * 启用或禁用方块的选择框。 * @param {Boolean} enabled - 是否启用选择框。 * @returns {Map} - 新的组件集合。 */ static setSelectionBoxEnabled(enabled: boolean): Map; /** * 设置自定义的选择框。 * @param {Array} origin - 选择框的起点坐标 [x, y, z]。 * @param {Array} size - 选择框的大小 [width, height, depth]。 * @returns {Map} - 新的组件集合。 */ static setSelectionBoxCustom(origin: any[], size: any[]): Map; /** * 设置方块实体(Block Entity,实验性功能,需开启 Upcoming Creator Features)。 * * 两种调用方式(都支持,互不干扰): * ```js * BlockComponent.setBlockEntity() // → { dynamic_properties: false }(历史产物,逐字节不变) * BlockComponent.setBlockEntity(true) // → { dynamic_properties: true }(历史产物,逐字节不变) * BlockComponent.setBlockEntity(true, { container: { slot_count: 27 } }) * BlockComponent.setBlockEntity({ container: 54 }) // 只给容器时也可以省掉第一个参数 * ``` * * ⚠️ **`container` 是「方块容器」的规范写法**(官方文档 * * :`container.slot_count`,`>= 1` 且 `<= 54`,超限**抛错**), * 但**当前引擎版本仍会拒绝该成员**。**要现在就能用的容器,请走实体路线**: * `BlockAPI.createTileBlock(identifier, category, textures_arr, { inventory_size })`。 * 引擎拒绝的原文与版本见 `doc/dev/known-pitfalls.md`。 * * ⚠️ `combineComponents` 是「**后者覆盖前者**」:要同时给 `dynamic_properties` 与 `container`, * 请像上面那样**一次调用写完**;把两个 `setBlockEntity(...)` 合并会让先出现的那个被整份丢掉 * (框架不在 `combineComponents` 里做隐式深合并 —— 那会把"覆盖"这条既有语义改掉)。 * * @param {Boolean|Object} [dynamic_properties=false] 是否启用动态属性存储;也可以直接传 `options` 对象 * (此时读 `options.dynamic_properties`,缺省 false)。 * @param {Object} [options] 可选参数。 * @param {Object|number} [options.container] 方块容器:`{ slot_count }`(`inventory_size` 亦可作别名), * 或直接给槽位数。必须是 `[1, 54]` 的整数,超限抛错。 * @returns {Map} - 新的组件集合。 */ static setBlockEntity(dynamic_properties?: boolean | Object, options?: { container?: number | Object | undefined; }): Map; /** * 设置方块容器 —— ⚠️ **已废弃(deprecated),且当前引擎版本拒绝该组件**。 * * ## 为什么废弃 * 本方法产出的是**方块** `components` 里的 `minecraft:inventory`。但 `minecraft:inventory` * 是**实体**组件(官方文档在 Entity Components 下: * ), * **不是**方块组件(Block Components 列表里没有它)。于是真机引擎直接拒绝: * ``` * -> components -> minecraft:inventory: this component was found in the input, * but is not present in the Schema * ``` * ⇒ 把实体组件写在方块里,**在任何版本上都不成立**(不是"版本太旧"的问题)。 * 也就是说:**框架此前产不出任何可用的方块容器**,这条 API 是误导性的。 * * ## 现在该怎么做 * - **要能用的容器 → 实体路线**(当前引擎版本下**唯一可用**): * `BlockAPI.createTileBlock(identifier, category, textures_arr, { inventory_size, container_type, can_be_siphoned_from })` * —— 方块带承载实体、实体的行为文件里挂 `minecraft:inventory`。 * 已在用的 `TileBlock` 也可以直接改 `tile.entity.behavior.addComponent(EntityComponent.setInventoryProperties({...}))`。 * - **要规范的方块容器 JSON → `BlockComponent.setBlockEntity(true, { container: { slot_count } })`** * (`slot_count` 官方文档限制 `[1,54]`)。它会生成正确的 `minecraft:block_entity.container`, * 但**当前引擎版本同样会拒** —— 等引擎支持后即可直接用。 * * ## 为什么保留签名(而不是删掉 / 改成别的产物) * 1. 已有项目调用它时,产物里的键、字段**一个字节都不变** —— 不会出现"升个框架版本构建就报错", * 也不会因为改成 `block_entity.container` 而与用户自己写的 `setBlockEntity(...)` 抢同一个 JSON 键 * (`combineComponents` 是后者覆盖前者,改键会让容器信息在某些写法下**被静默吞掉**)。 * 2. 真正的错误(把实体组件当方块组件用)由**构建期 warn** 明确指出,并给出两条新路线。 * 3. `inventory_size` 超过 54 的写法在这里仍可表达(实体组件文档**没有**上限)。 * * @deprecated 改用实体路线(`createTileBlock` 的 `inventory_size`),或 * `BlockComponent.setBlockEntity(true, { container: { slot_count } })` 产出规范写法。 * @param {Object} options - 容器参数。 * @param {number} options.inventory_size - 槽位数(正整数,必填;实体组件文档未给上限)。 * @param {boolean} [options.private] - 是否仅所有者可访问。 * @param {string} [options.container_type] - 容器音效/行为类型。官方文档列出的取值: * `horse` / `minecart_chest` / `chest_boat` / `minecart_hopper` / `inventory` / `container` / `hopper` * (此处不做白名单,避免把未文档化但可用的值写死掉)。 * @param {boolean} [options.can_be_siphoned_from] - 能否用漏斗抽取。 * @param {number} [options.additional_slots_per_strength] - 每级强度的额外槽位(非负整数)。 * @param {boolean} [options.restrict_to_owner] - 是否限制为所有者可打开。 * @returns {Map} - 组件集合(仅 `minecraft:inventory`)。 */ static setInventory(options?: { inventory_size: number; private?: boolean | undefined; container_type?: string | undefined; can_be_siphoned_from?: boolean | undefined; additional_slots_per_strength?: number | undefined; restrict_to_owner?: boolean | undefined; }): Map; /** * 设置方块的活塞移动行为。 * @param {String} movement_type - 移动类型: "immovable" | "popped" | "push" | "push_pull"。 * @param {String} [sticky] - 黏性行为: "same" 可复制黏液块/蜂蜜块功能。 * @returns {Map} - 新的组件集合。 */ static setMovable(movement_type: string, sticky?: string): Map; /** * 设置方块的监听红石信号行为(配合自定义组件 onRedstoneUpdate 使用)。 * @param {Number} min_power - 最小触发红石信号强度 (0-15)。 * @param {Boolean} [propagates_power] - 是否传导红石信号。 * @returns {Map} - 新的组件集合。 */ static setRedstoneConsumer(min_power: number, propagates_power?: boolean): Map; /** * 设置方块产生红石信号。 * @param {Number} power - 信号强度 (0-15)。 * @param {String} strongly_powered_face - 强充能方向: "up" | "down" | "north" | "south" | "east" | "west"。 * @param {String[]} [connected_faces] - 连接的方向数组。 * @param {Boolean} [transform_relative] - 面方向是否相对于变换组件的旋转。 * @returns {Map} - 新的组件集合。 */ static setRedstoneProducer(power: number, strongly_powered_face: string, connected_faces?: string[], transform_relative?: boolean): Map; /** * 设置方块可被替换(放置其他方块时替换此方块)。 * @returns {Map} - 新的组件集合。 */ static setReplaceable(): Map; /** * 设置方块的支撑形状。 * @param {String} shape - 支撑形状: "fence" | "stair"。 * @returns {Map} - 新的组件集合。 */ static setSupport(shape: string): Map; /** * 设置方块标签。 * @param {String[]} tags - 标签数组。 * @returns {Map} - 新的组件集合。 */ static setTags(tags: string[]): Map; /** * 设置方块可被拴绳拴住(类似栅栏)。 * @param {Number[]} [offset=[0, 12, 0]] - 拴绳结位置偏移 [x, y, z]。 * @returns {Map} - 新的组件集合。 */ static setLeashable(offset?: number[]): Map; /** * 设置方块对实体坠落事件的触发。 * @param {Number} min_fall_distance - 最小坠落距离(方块数)。 * @returns {Map} - 新的组件集合。 */ static setEntityFallOn(min_fall_distance: number): Map; /** * 设置方块可放入花盆(配合 setEmbeddedVisual 使用)。 * @returns {Map} - 新的组件集合。 */ static setFlowerPottable(): Map; /** * 设置方块与降水(雨/雪)的交互行为。 * @param {String} behavior - 降水行为: "obstruct_rain_accumulate_snow" | "obstruct_rain" | "snowlogging" | "none"。 * @returns {Map} - 新的组件集合。 */ static setPrecipitationInteractions(behavior: string): Map; /** * 设置方块的随机偏移(碰撞箱/选择框/几何)。 * @param {Object} axis_config - 每个轴的偏移配置。 * @param {Object} [axis_config.x] - X 轴配置。 * @param {Object} [axis_config.y] - Y 轴配置。 * @param {Object} [axis_config.z] - Z 轴配置。 * @param {Object} axis_config.x.range - 范围 {min, max}。 * @param {Number} [axis_config.x.steps=0] - 步数(0=任意值)。 * @returns {Map} - 新的组件集合。 */ static setRandomOffset(axis_config: { x?: Object | undefined; y?: Object | undefined; z?: Object | undefined; }): Map; /** * 设置方块对箱子开启的遮挡行为。 * @param {String} rule - 遮挡规则: "always" | "never" | "shape"。 * @returns {Map} - 新的组件集合。 */ static setChestObstruction(rule: string): Map; /** * 设置方块在花盆中的显示外观。 * @param {String|Object} geometry - 几何标识符或几何对象。 * @param {Object} material_instances - 材质实例。 * @returns {Map} - 新的组件集合。 */ static setEmbeddedVisual(geometry: string | Object, material_instances: Object): Map; /** * 设置方块与栅栏/墙等方块的连接规则。 * @param {String} [accepts_from="all"] - 连接来源: "all" | "only_fences" | "none"。 * @param {String[]} [enabled_directions] - 允许连接的方向数组。 * @returns {Map} - 新的组件集合。 */ static setConnectionRule(accepts_from?: string, enabled_directions?: string[]): Map; /** * 设置方块的声音。 * @param {String} sound - 声音名称。 * @returns {Map} - 新的组件集合。 */ static setSound(sound: string): Map; /** * 将多个组件集合合并为一个。 * @param {...Map} componentMaps - 多个组件集合。 * @returns {Map} - 合并后的组件集合。 */ static combineComponents(...componentMaps: Map[]): Map; /** * 获取当前组件的 JSON 表示。 * @param {Map} components - 组件集合。 * @returns {Object} - 组件的 JSON 对象。 */ static toJSON(components: Map): Object; } interface BeforeOnPlayerPlaceEvent { block: any; cancel: boolean; dimension: any; face: string; permutationToPlace: any; player?: any; } interface OnBlockStateChangeEvent { block: any; dimension: any; previousPermutation: any; } interface OnBreakEvent { block: any; dimension: any; blockDestructionSource?: any; brokenBlockPermutation: any; entitySource?: any; } interface OnEntityEvent { block: any; blockPermutation: any; dimension: any; entitySource: any; name: string; } interface OnEntityFallOnEvent { block: any; dimension: any; entity?: any; fallDistance: number; } interface OnPlaceEvent { block: any; dimension: any; previousBlock: any; } interface OnPlayerBreakEvent { block: any; brokenBlockPermutation: any; dimension: any; player?: any; } interface OnPlayerInteractEvent { block: any; dimension: any; face: string; faceLocation: any; player?: any; } interface OnRandomTickEvent { block: any; dimension: any; } interface OnRedstoneUpdateEvent { block: any; dimension: any; power: number; } interface OnStepOffEvent { block: any; dimension: any; entity?: any; } interface OnStepOnEvent { block: any; dimension: any; entity?: any; } interface OnTickEvent { block: any; dimension: any; } interface BlockCustomComponentHandlers { beforeOnPlayerPlace?: (event: BeforeOnPlayerPlaceEvent) => void; onBlockStateChange?: (event: OnBlockStateChangeEvent) => void; onBreak?: (event: OnBreakEvent) => void; onEntity?: (event: OnEntityEvent) => void; onEntityFallOn?: (event: OnEntityFallOnEvent) => void; onPlace?: (event: OnPlaceEvent) => void; onPlayerBreak?: (event: OnPlayerBreakEvent) => void; onPlayerInteract?: (event: OnPlayerInteractEvent) => void; onRandomTick?: (event: OnRandomTickEvent) => void; onRedstoneUpdate?: (event: OnRedstoneUpdateEvent) => void; onStepOff?: (event: OnStepOffEvent) => void; onStepOn?: (event: OnStepOnEvent) => void; onTick?: (event: OnTickEvent) => void; } /** * 块自定义组件构建器 - 提供流式 API 定义块事件处理器, * 并提供类型安全的事件参数绑定。 * * @example * ```ts * const comp = new BlockCustomComponentBuilder('wiki:my_comp') * .onTick() // 只声明事件类型,生成骨架代码 * .onPlayerInteract(({ player }) => { ... }) // 带完整 handler * * // 在 block JSON 中注册组件 ID * block.addComponent(BlockComponent.setCustomComponents([comp.id()])) * ``` */ declare class BlockCustomComponentBuilder { private static allInstances; private componentId; private handlers; private declaredEvents; constructor(componentId: string); /** 返回所有已创建的构建器实例 */ static getAllInstances(): BlockCustomComponentBuilder[]; /** 重置实例列表(用于测试/热重载) */ static resetInstances(): void; /** 返回组件标识符,用于 setCustomComponents */ id(): string; /** 返回已声明(含 handler)的事件名称列表 */ declaredEventNames(): string[]; /** 返回已注册的事件处理器数量 */ handlerCount(): number; beforeOnPlayerPlace(handler?: (event: BeforeOnPlayerPlaceEvent) => void): this; onBlockStateChange(handler?: (event: OnBlockStateChangeEvent) => void): this; onBreak(handler?: (event: OnBreakEvent) => void): this; onEntity(handler?: (event: OnEntityEvent) => void): this; onEntityFallOn(handler?: (event: OnEntityFallOnEvent) => void): this; onPlace(handler?: (event: OnPlaceEvent) => void): this; onPlayerBreak(handler?: (event: OnPlayerBreakEvent) => void): this; onPlayerInteract(handler?: (event: OnPlayerInteractEvent) => void): this; onRandomTick(handler?: (event: OnRandomTickEvent) => void): this; onRedstoneUpdate(handler?: (event: OnRedstoneUpdateEvent) => void): this; onStepOff(handler?: (event: OnStepOffEvent) => void): this; onStepOn(handler?: (event: OnStepOnEvent) => void): this; onTick(handler?: (event: OnTickEvent) => void): this; /** 构建处理器对象,可用于 runtime 的 registerCustomComponent */ build(): BlockCustomComponentHandlers; /** 生成 runtime 脚本模块源码 */ generateRuntimeCode(): string; } declare class CropBlock extends Block { stageNum: number; } declare class GeometryBlock extends BasicBlock { /** * 带模型方块类 * @param {string} identifier 方块标识符 由命名空间和方块名组成 例如 "my_mod:stone" * @param {string} category 方块的分类 "construction", "nature", "equipment", "items", and "none" * @param {string} geometry 模型标识符 * @param {Object} material_instances 材质实例对象 * @param {Object} options 可选参数 */ constructor(identifier: string, category: string, geometry: string, material_instances: Object, options?: Object); } declare class OreFeature { constructor(identifier: any, count: any, replace_rules: any); identifier: any; count: any; replace_rules: any; toObject(): any; } /** * 表示生物群系过滤条件的类 */ declare class BiomeFilter { filters: any[]; /** * 添加一个逻辑条件组(如 any_of, all_of) * @param {"any_of" | "all_of"} logicType - 逻辑类型 * @param {Array} conditions - 条件数组 * @returns {BiomeFilter} 返回自身以支持链式调用 */ addLogicGroup(logicType: "any_of" | "all_of", conditions: Array): BiomeFilter; /** * 添加一个简单条件(如 has_biome_tag) * @param {string} test - 测试类型(如 "has_biome_tag") * @param {"==" | "!="} operator - 操作符 * @param {string} value - 目标值(如 "overworld") * @returns {BiomeFilter} 返回自身以支持链式调用 */ addSimpleCondition(test: string, operator: "==" | "!=", value: string): BiomeFilter; /** * 转换为 JSON 格式 * @returns {Array} 返回生物群系过滤条件数组 */ toObject(): Array; } /** * 表示功能规则生成条件的类 */ declare class FeatureConditions { conditions: { placement_pass: string; "minecraft:biome_filter": never[]; }; /** * 设置生成阶段(placement_pass) * @param {string} pass - 生成阶段标识符(如 "underground_pass") * @returns {FeatureConditions} 返回自身以支持链式调用 */ setPlacementPass(pass: string): FeatureConditions; /** * 设置生物群系过滤器 * @param {BiomeFilter} biomeFilter - 生物群系过滤条件对象 * @returns {FeatureConditions} 返回自身以支持链式调用 */ setBiomeFilter(biomeFilter: BiomeFilter): FeatureConditions; /** * 转换为 JSON 格式 * @returns {Object} 返回生成条件对象 */ toObject(): Object; } /** * 表示单个坐标轴(x/y/z)分布规则的类 */ declare class CoordinateDistribution { /** * @param {"uniform" | "triangle"} distribution - 分布类型 * @param {Array} extent - 范围(如 [0, 16]) */ constructor(distribution?: "uniform" | "triangle", extent?: Array); distribution: "uniform" | "triangle"; extent: number[]; /** * 转换为 JSON 格式 * @returns {Object} 返回坐标分布配置 */ toObject(): Object; } /** * 表示功能规则分布配置的类 */ declare class FeatureDistribution { distribution: { iterations: number; coordinate_eval_order: string; x: any; y: any; z: any; }; /** * 设置迭代次数 * @param {number} iterations - 放置尝试次数 * @returns {FeatureDistribution} 返回自身以支持链式调用 */ setIterations(iterations: number): FeatureDistribution; /** * 设置坐标轴的分布规则 * @param {"x" | "y" | "z"} axis - 坐标轴 * @param {CoordinateDistribution} config - 分布配置 * @returns {FeatureDistribution} 返回自身以支持链式调用 */ setAxisDistribution(axis: "x" | "y" | "z", config: CoordinateDistribution): FeatureDistribution; /** * 转换为 JSON 格式 * @returns {Object} 返回分布规则对象 */ toObject(): Object; } declare class FeatureRule { constructor(identifier: any, places_feature: any); identifier: any; places_feature: any; condition: FeatureConditions; distribution: FeatureDistribution; setPlacementPass(pass: any): void; setBiomeFilter(biomeFilter: any): void; setIterations(iterations: any): void; setAxisDistribution(axis: any, config: any): void; toObject(): any; } declare class OreBlock extends BasicBlock { constructor(identifier: any, category: any, textures_arr: any, options?: {}); feature: OreFeature; feature_rules: FeatureRule; } declare namespace RotationTypes { let CARDINAL: string; let FACING: string; let BLOCK_FACE: string; let LOG: string; } declare class RotatableBlock extends BasicBlock { /** * 可旋转方块类 * @param {string} identifier 方块唯一标识符 * @param {string} category 菜单栏分类 * @param {Array} textures_arr 纹理数组 [上,下,东,西,南,北] * @param {Object} options 可选参数 * @param {string} options.group 分组,默认为 "construction" * @param {boolean} options.hide_in_command 是否在命令中隐藏,默认为 false * @param {string} options.rotationType 旋转类型,默认为 "cardinal" * @param {number} options.yRotationOffset 初始旋转偏移量,默认为 0 */ constructor(identifier: string, category: string, textures_arr: any[], options?: { group: string; hide_in_command: boolean; rotationType: string; yRotationOffset: number; }); #private; } declare class BasicEntity { static entities: Map; static getEntity(identifier: any): any; /** * 构造函数 * @param {string} identifier - 实体的唯一标识符 * @param {Object} options - 配置选项 * @param {boolean} [options.is_spawnable=true] - 是否可生成 * @param {boolean} [options.is_summonable=true] - 是否可召唤 * @param {string} [options.runtime_identifier] - 复刻标识符 * @param {Object} data - 继承的数据 * @param {Object} [data.components={}] - 继承的组件 * @param {Object} [data.component_groups={}] - 继承的组件组 * @param {Object} [data.events={}] - 继承的事件 */ constructor(identifier: string, options?: { is_spawnable?: boolean | undefined; is_summonable?: boolean | undefined; runtime_identifier?: string | undefined; }, data?: { components?: Object | undefined; component_groups?: Object | undefined; events?: Object | undefined; }); identifier: string; is_spawnable: boolean; is_summonable: boolean; runtime_identifier: string | undefined; properties: any; components: Map; component_groups: Map; events: Map; /** * 添加属性到实体 * @param {string} name 属性名称 * @param {Object} value 属性值 * @returns */ addProperty(name: string, value: Object): this; /** * 移除属性 * @param {string} name 属性名称 * @returns */ removeProperty(name: string): this; /** * 移除所有属性 * @returns */ clearProperties(): this; /** * 添加事件到实体 * @param {string} name - 事件名称 * @param {Map} eventMap - 事件的键值对 Map * @returns {BasicEntity} - 返回当前实例以支持链式调用 */ addEvent(name: string, eventMap: Map): BasicEntity; /** * 删除事件 * @param {string} name - 事件名称 * @returns {BasicEntity} - 返回当前实例以支持链式调用 */ removeEvent(name: string): BasicEntity; /** * 清除所有事件 * @returns {BasicEntity} - 返回当前实例以支持链式调用 */ clearEvents(): BasicEntity; /** * 添加组件组到实体 * @param {string} name - 组件组名称 * @param {Map} componentMap - 组件组的键值对 Map * @returns {BasicEntity} - 返回当前实例以支持链式调用 */ addComponentGroup(name: string, componentMap: Map): BasicEntity; /** * 删除组件组 * @param {string} name - 组件组名称 * @returns {BasicEntity} - 返回当前实例以支持链式调用 */ removeComponentGroup(name: string): BasicEntity; /** * 清除所有组件组 * @returns {BasicEntity} - 返回当前实例以支持链式调用 */ clearComponentGroups(): BasicEntity; /** * 添加组件到实体 * @param {Map} componentMap - 组件的键值对 Map * @returns {BasicEntity} - 返回当前实例以支持链式调用 */ addComponent(componentMap: Map): BasicEntity; /** * 删除组件 * @param {string} key - 组件名称 * @returns {BasicEntity} - 返回当前实例以支持链式调用 */ removeComponent(key: string): BasicEntity; /** * 清除所有组件 * @returns {BasicEntity} - 返回当前实例以支持链式调用 */ clearComponents(): BasicEntity; /** * 清除所有数据 */ clearAll(): this; /** * 将实体转换为 JSON 格式 * @returns {Object} - 返回 JSON 格式的实体数据 */ toObject(): Object; } /** * ClientEntity 类,用于表示客户端实体。 * 继承自 AddonClientEntityDescription,并扩展了实体的数据加载和 JSON 序列化功能。 */ declare class ClientEntity extends AddonClientEntityDescription { static entities: Map; /** * @param {string} identifier * @returns {ClientEntity} */ static getEntity(identifier: string): ClientEntity; /** * 构造函数,用于创建一个客户端实体实例。 * * @param {string} identifier - 实体的唯一标识符。 * @param {Object} data - 实体的初始数据,默认为空对象。 */ constructor(identifier: string, data?: Object); /** * 将当前实体实例转换为 JSON 格式。 * * @returns {Object} - 表示实体的 JSON 对象。 */ toObject(): Object; } declare class Entity { /** * * @param {string} identifier * @param {string} [texture] * @param {any} [options] * @param {any} [behData] * @param {any} [resData] */ constructor(identifier: string, texture?: string, options?: any, behData?: any, resData?: any); identifier: string; behavior: BasicEntity; resource: ClientEntity; } declare class TileBlock { /** * 带实体的方块类 * * 容器走**实体**路线:`minecraft:inventory` 是**实体**组件,挂在 `${identifier}_entity` 的 * 行为文件上。这是当前引擎版本下**唯一可用**的方块容器方案(方块侧的 * `minecraft:block_entity.container` 成员会被引擎拒: * `-> minecraft:block_entity -> container: … is not present in the Schema`)。 * * @param {*} identifier * @param {*} category * @param {*} textures_arr * @param {*} options * @param {boolean} [options.hide_in_command=false] 是否在命令中隐藏(透传给 `BasicBlock`)。 * @param {string} [options.group] 创造菜单分组(透传给 `BasicBlock` → `menu_category.group`)。 * ⚠️ 与 `createBasicBlock` 取值一致:**不传 = undefined**(产物里 `menu_category` 只有 * `category` 与 `is_hidden_in_commands`)。分组名是**本地化键**,项目须在 * `RP/texts/*.lang` 里定义,否则显示裸键名。 * @param {string} [options.format_version] 方块 JSON 的 `format_version`(默认 `1.26.30`)。 * @param {string} [options.entity_texture] 客户端实体的贴图**资源路径** * (如 `"textures/blocks/entity/normal"`,省略扩展名)。 * 默认 = `textures_arr[0]`(**历史行为,逐字节不变**)。 * ⚠️ `textures_arr[0]` 在**方块**侧是 terrain_texture.json 的**键**、在**实体**侧却必须是 * 资源路径 —— 两者不是一回事。只给短名的项目(如 `"machineblock_0"`)必须传本参数, * 否则客户端实体会报 `Missing referenced asset`。 * @param {number} [options.inventory_size=27] 实体容器槽位数(正整数)。 * ⚠️ 官方文档() * 只写 "Number of slots the container has"、**未给上限** —— 别照搬方块路线 `[1,54]` 的限制。 * @param {string} [options.container_type="minecart_chest"] 容器音效/行为类型。官方文档列出的取值: * `horse` / `minecart_chest` / `chest_boat` / `minecart_hopper` / `inventory` / `container` / `hopper` * (此处不做白名单,避免把未文档化但可用的值写死掉)。 * @param {boolean} [options.can_be_siphoned_from=true] 能否用漏斗抽取。 * ⚠️ **没有**「延迟 despawn」这类入口,而且**不要**去加: * 往 `item_despawn` 组的 `minecraft:transformation` 上加 `delay` 会让同组的 * `minecraft:instant_despawn` 先把实体删掉 ⇒ **整容器一个都不掉**(真机教训, * 见 `doc/dev/known-pitfalls.md` §4.15)。 */ constructor(identifier: any, category: any, textures_arr: any, options?: any); block: BasicBlock; entity: Entity; setGeometry(geometry: any): void; addAnimation(name: any, animation: any): void; setScript(key: any, value: any): void; } declare class GlassBlock extends BasicBlock { constructor(identifier: any, category: any, texture: any, options?: {}); } declare class HeadBlock extends BasicBlock { constructor(identifier: any, category: any, texture: any, options?: {}); #private; } declare class FenceBlock extends BasicBlock { constructor(identifier: any, category: any, textures_arr: any, options?: {}); } declare class StairBlock extends BasicBlock { constructor(identifier: any, category: any, textures_arr: any, options?: {}); #private; } declare class TrapdoorBlock extends BasicBlock { constructor(identifier: any, category: any, texture: any, options?: {}); #private; } declare const TintMethod: { readonly GRASS: "grass"; readonly WATER: "water"; readonly DEFAULT_FOLIAGE: "default_foliage"; readonly EVERGREEN_FOLIAGE: "evergreen_foliage"; readonly DRY_FOLIAGE: "dry_foliage"; readonly BIRCH_FOLIAGE: "birch_foliage"; }; type TintMethod = (typeof TintMethod)[keyof typeof TintMethod]; interface FlipbookEntry { flipbook_texture: string; atlas_tile?: string; ticks_per_frame?: number; blend_frames?: boolean; replicate?: number; } declare class FlipbookTextureConfig { private entries; addEntry(entry: FlipbookEntry): this; addEntries(entries: FlipbookEntry[]): this; toObject(): { flipbook_textures: FlipbookEntry[]; }; } interface TextureVariation { path: string; weight?: number; } interface TextureEntry { textures: string | TextureVariation[]; } declare class TextureVariationConfig { private textureData; addTexture(name: string, path: string): this; addTextureWithVariations(name: string, variations: TextureVariation[]): this; toObject(): { texture_data: Record; }; } declare class DummyEntity extends Entity { constructor(identifier: any, texture: any, options: {} | undefined, behData: any, resData: any); } declare class NativeEntity { constructor(identifier: any, proto_id: any, options?: {}); identifier: any; behavior: BasicEntity; resource: ClientEntity; } declare class Projectile extends NativeEntity { } declare class FollowMobBehavior { constructor(priority: any); priority: any; searchRange: number; speedMultiplier: number; stopDistance: number; setPriority(priority: any): this; setSearchRange(searchRange: any): this; setSpeedMultiplier(speedMultiplier: any): this; setStopDistance(stopDistance: any): this; toObject(): Map; } declare class FollowParentBehavior { constructor(priority: any); priority: any; speed_multiplier: number; setSpeedMultiplier(speed_multiplier: any): void; toObject(): Map; } declare class RandomStrollBehavior { /** * 随机漫步行为 * @param {number} priority 优先级 * @param {number} interval 间隔 * @param {number} speed_multiplier 速度倍数 */ constructor(priority: number, interval: number, speed_multiplier: number); priority: number; interval: number; speed_multiplier: number; xz_dist: number; y_dist: number; /** * 设置水平距离 * @param {number} xz_dist 水平距离 * @returns {EntityBehaviorRandomStroll} 返回当前实例以支持链式调用 */ setXZDist(xz_dist: number): EntityBehaviorRandomStroll; /** * 设置垂直距离 * @param {number} y_dist 垂直距离 * @returns {EntityBehaviorRandomStroll} 返回当前实例以支持链式调用 */ setYDist(y_dist: number): EntityBehaviorRandomStroll; /** * 将组件转换为 JSON 对象 * @returns {Object} minecraft:behavior.random_stroll 组件的 JSON 对象 */ toObject(): Object; } declare class TemptBehavior { /** * 创建 minecraft:behavior.tempt 组件。 * @param {number} priority 行为的优先级 */ constructor(priority: number); priority: number; can_get_scared: boolean; can_tempt_vertically: boolean; can_tempt_while_ridden: boolean; items: any[]; sound_interval: { range_min: number; range_max: number; }; speed_multiplier: number; tempt_sound: string | null; within_radius: number; /** * 设置是否会被吓跑。 * @param {boolean} canGetScared 是否会被吓跑 * @returns {TemptBehavior} 返回当前实例以支持链式调用 */ canGetScared(canGetScared: boolean): TemptBehavior; /** * 设置是否考虑垂直距离。 * @param {boolean} canTemptVertically 是否考虑垂直距离 * @returns {TemptBehavior} 返回当前实例以支持链式调用 */ canTemptVertically(canTemptVertically: boolean): TemptBehavior; /** * 设置是否在被骑乘时被吸引。 * @param {boolean} canTemptWhileRidden 是否在被骑乘时被吸引 * @returns {TemptBehavior} 返回当前实例以支持链式调用 */ canTemptWhileRidden(canTemptWhileRidden: boolean): TemptBehavior; /** * 设置吸引实体的物品列表。 * @param {Array} items 吸引实体的物品列表 * @returns {TemptBehavior} 返回当前实例以支持链式调用 */ setItems(items: any[]): TemptBehavior; /** * 设置播放吸引声音的随机间隔时间。 * @param {number} min 最小间隔时间 * @param {number} max 最大间隔时间 * @returns {TemptBehavior} 返回当前实例以支持链式调用 */ setSoundInterval(min: number, max: number): TemptBehavior; /** * 设置移动速度倍数。 * @param {number} speedMultiplier 移动速度倍数 * @returns {TemptBehavior} 返回当前实例以支持链式调用 */ setSpeedMultiplier(speedMultiplier: number): TemptBehavior; /** * 设置吸引时播放的声音。 * @param {string} temptSound 吸引时播放的声音 * @returns {TemptBehavior} 返回当前实例以支持链式调用 */ setTemptSound(temptSound: string): TemptBehavior; /** * 设置吸引的最大距离。 * @param {number} withinRadius 吸引的最大距离 * @returns {TemptBehavior} 返回当前实例以支持链式调用 */ setWithinRadius(withinRadius: number): TemptBehavior; /** * 将组件转换为 JSON 对象。 * @returns {Object} minecraft:behavior.tempt 组件的 JSON 对象 */ toObject(): Object; } declare class NearestAttackableTargetBehavor { constructor(priority: any, entity_types: any); priority: any; must_reach: boolean; must_see: boolean; entity_types: any; setMustReach(must_reach: any): this; setMustSee(must_see: any): this; toObject(): Map; } /** * 控制生物拾取物品的 AI 行为配置 * @example * // 创建类似 Allay 的拾取行为 * const allayPickup = new PickupItemsBehavior(2) * .setMaxDist(32) * .setSearchHeight(32) * .setSpeedMultiplier(6) * .setPickupSameItemsAsInHand(true); * * // 创建类似 Drowned 的配置 * const drownedPickup = new PickupItemsBehavior(6) * .setExcludedItems(["minecraft:glow_ink_sac"]) * .setSpeedMultiplier(1.2); */ declare class PickupItemsBehavior { private priority; private can_pickup_any_item; private can_pickup_to_hand_or_equipment; private cooldown_after_being_attacked?; private excluded_items?; private goal_radius; private max_dist; private pickup_based_on_chance; private pickup_same_items_as_in_hand?; private search_height?; private speed_multiplier; private track_target; /** * @param priority - 行为优先级(数值越小优先级越高) */ constructor(priority: number); /** * 设置是否可以拾取任意物品 * @param value - 默认 false * @returns 当前实例(支持链式调用) */ setCanPickupAnyItem(value: boolean): this; /** * 设置是否允许拾取到手上或装备栏 * @param value - 默认 true */ setCanPickupToHandOrEquipment(value: boolean): this; /** * 设置被攻击后的拾取冷却时间 * @param ticks - 冷却时间(游戏刻) */ setCooldownAfterBeingAttacked(ticks: number): this; /** * 设置禁止拾取的物品列表 * @param items - 物品ID数组,如 ["minecraft:glow_ink_sac"] */ setExcludedItems(items: string[]): this; /** * 设置拾取目标的判定半径 * @param radius - 默认 0.5 格 */ setGoalRadius(radius: number): this; /** * 设置最大搜索距离 * @param distance - 单位:格(0 表示无限制) */ setMaxDist(distance: number): this; /** * 设置是否基于难度随机决定能否拾取 * @param enabled - 默认 false */ setPickupBasedOnChance(enabled: boolean): this; /** * 设置是否仅拾取与手中相同的物品 * @param condition - 可设为布尔值或特定物品ID */ setPickupSameItemsAsInHand(condition: boolean | string): this; /** * 设置垂直搜索范围 * @param height - 单位:格 */ setSearchHeight(height: number): this; /** * 设置移动速度倍率 * @param multiplier - 默认 1.0 */ setSpeedMultiplier(multiplier: number): this; /** * 设置是否持续追踪目标 * @param enabled - 默认 false */ setTrackTarget(enabled: boolean): this; /** * 序列化为 Minecraft 行为包格式 */ toObject(): Map; } declare class MoveTowardsHomeRestrictionBehavior { /** * 创建 minecraft:behavior.move_towards_home_restriction 组件。 * @param {number} priority 行为的优先级 */ constructor(priority: number); priority: number; speed_multiplier: number; /** * 设置移动速度倍数。 * @param {number} speedMultiplier 移动速度倍数 * @returns {MoveTowardsHomeRestrictionBehavior} 返回当前实例以支持链式调用 */ setSpeedMultiplier(speedMultiplier: number): MoveTowardsHomeRestrictionBehavior; /** * 将组件转换为 JSON 对象。 * @returns {Object} minecraft:behavior.move_towards_home_restriction 组件的 JSON 对象 */ toObject(): Object; } declare class GoHomeBehavior { /** * 创建 minecraft:behavior.go_home 组件。 * @param {number} priority 行为的优先级 */ constructor(priority: number); priority: number; speed_multiplier: number; goal_radius: number; interval: number; /** * 设置移动速度倍数。 * @param {number} speedMultiplier 移动速度倍数 * @returns {GoHomeBehavior} 返回当前实例以支持链式调用 */ setSpeedMultiplier(speedMultiplier: number): GoHomeBehavior; /** * 设置回家目标判定半径。 * @param {number} goalRadius 判定半径(方块格) * @returns {GoHomeBehavior} 返回当前实例以支持链式调用 */ setGoalRadius(goalRadius: number): GoHomeBehavior; /** * 设置回家行为执行的间隔时间(游戏刻)。 * @param {number} interval 间隔时间(游戏刻) * @returns {GoHomeBehavior} 返回当前实例以支持链式调用 */ setInterval(interval: number): GoHomeBehavior; /** * 将组件转换为 JSON 对象。 * @returns {Object} minecraft:behavior.go_home 组件的 JSON 对象 */ toObject(): Object; } declare class BasicBundle { /** * 添加组件到捆绑包 * @param {Map} componentMap 组件 * @returns {BasicBundle} 返回捆绑包对象 */ addComponent(componentMap: Map): BasicBundle; addComponents(components: any): void; removeComponent(name: any): this; serialize(): Map; #private; } declare const BasicMovementBundle: BasicBundle; interface RideableComponent { controllingSeat: number; crouchingSkipInteract: boolean; familyTypes: string[]; interactText: string; onRiderEnterEvent: string; onRiderExitEvent: string; passengerMaxWidth: number; pullInEntities: boolean; seatCount: number; seats: Partial[]; } type RideableComponentDesc = Partial; interface RideableSeat { camera_relax_distance_smoothing: number; lock_rider_rotation: number; max_rider_count: number; min_rider_count: number; position: [number, number, number]; rotate_rider_by: string; third_person_camera_radius: number; } declare class EntityComponent { /** * 设置实体是否可以堆叠 * @returns */ static setIsStackable(): Map; /** * 设置实体周围的效果范围 * @param {Object} options - 效果配置 * @param {string} options.effect - 效果ID(如"minecraft:poison") * @param {number} [options.range=0.2] - 效果作用范围(单位:格) * @param {number|'infinite'} [options.duration=10] - 效果持续时间(秒) * @param {number} [options.cooldown=0] - 效果触发冷却时间(秒) * @param {Object} [options.filter] - 实体过滤器配置 * @returns {Map} 返回 Minecraft mob_effect 组件 * * @example // 河豚毒效果(小范围中毒) * const pufferfish = EntityComponent.setMobEffect({ * effect: "minecraft:poison", * range: 0.2, * duration: 10 * }); * * @example // 监守者黑暗效果(大范围) * const warden = EntityComponent.setMobEffect({ * effect: "minecraft:darkness", * range: 20, * duration: 13, * cooldown: 6, * filter: { * all_of: [ * { test: "is_family", subject: "other", value: "player" }, * { operator: "not", test: "has_ability", subject: "other", value: "invulnerable" } * ] * } * }); * * @example // 无限持续时间效果 * const infiniteEffect = EntityComponent.setMobEffect({ * effect: "minecraft:regeneration", * duration: 'infinite' * }); */ static setMobEffect({ effect, range, duration, cooldown, filter }: { effect: string; range?: number | undefined; duration?: number | "infinite" | undefined; cooldown?: number | undefined; filter?: Object | undefined; }): Map; /** * 设置控制实体所需的物品 * @param {string|string[]} controlItems - 可控制物品ID或数组 * @returns {Map} 返回 Minecraft item_controllable 组件 * * @example // 猪控制(胡萝卜钓竿) * const pigControl = EntityComponent.setItemControllable("carrotOnAStick"); * * @example // 炽足兽控制(诡异菌钓竿) * const striderControl = EntityComponent.setItemControllable("warped_fungus_on_a_stick"); * * @example // 多物品控制(同时接受两种控制物品) * const multiControl = EntityComponent.setItemControllable([ * "carrotOnAStick", * "custom:special_stick" * ]); */ static setItemControllable(controlItems: string | string[]): Map; /** * 设置实体群组大小追踪规则 * @param {number} [radius=16] - 检测半径范围(单位:方块格,默认16格) * @param {Object} [filter] - 实体过滤器配置(可选) * @returns {Map} 返回 Minecraft group_size 组件配置 * * @example // 基础用法 - 只设置检测半径 * const basic = EntityComponent.setGroupSize(12); * * @example // 猪灵配置 - 32格半径,过滤成年猪灵 * const hoglin = EntityComponent.setGroupSize(32, { * all_of: [ * { test: "has_component", operator: "!=", value: "minecraft:is_baby" }, * { test: "is_family", value: "hoglin" } * ] * }); * * @example // 村民配置 - 24格半径,过滤成年村民 * const villager = EntityComponent.setGroupSize(24, { * all_of: [ * { test: "is_family", value: "villager" }, * { test: "has_component", operator: "!=", value: "minecraft:is_baby" } * ] * }); * * @example // 怪物群体检测 - 16格半径,过滤所有敌对生物 * const monsters = EntityComponent.setGroupSize(16, { * any_of: [ * { test: "is_family", value: "monster" }, * { test: "is_family", value: "undead" } * ] * }); */ static setGroupSize(radius?: number, filter?: Object): Map; /** * 设置实体的装备配置 * @param {Object} options - 装备配置选项 * @param {string} [options.table] - 装备表的文件路径(相对于行为包根目录) * @param {Array} [options.slotDropChance] - 装备槽位的掉落概率配置 * @param {string} options.slotDropChance[].slot - 装备槽位名称(如:"slot.weapon.mainhand") * @param {number} options.slotDropChance[].dropChance - 掉落概率(0-1) * @returns {Map} 返回 Minecraft 装备组件 * * @example * // 沼泽僵尸(使用骨骼装备表) * const bogged = EntityComponent.setEquipment({ * table: "loot_tables/entities/skeleton_gear.json" * }); * * // 溺尸(设置主手武器100%掉落) * const drowned = EntityComponent.setEquipment({ * slotDropChance: [{ * slot: "slot.weapon.mainhand", * dropChance: 1 * }] * }); * * // 村民(主手武器不会掉落) * const villager = EntityComponent.setEquipment({ * slotDropChance: [{ * slot: "slot.weapon.mainhand", * dropChance: 0 * }] * }); */ static setEquipment(options?: { table?: string | undefined; slotDropChance?: Object[] | undefined; }): Map; /** * 设置实体装备物品的行为 * @param {Object} [options={}] - 装备配置选项 * @param {boolean} [options.canWearArmor] - 是否可以穿戴盔甲 * @param {Array} [options.excludedItems] - 禁止装备的物品列表 * @param {string} options.excludedItems[].item - 禁止装备的物品ID(格式:"命名空间:物品名:数据值") * @returns {Map} 返回 Minecraft 装备物品组件 * * @example * // 沼泽僵尸(禁止装备特定旗帜) * const bogged = EntityComponent.setEquipItem({ * excludedItems: [{ item: "minecraft:banner:15" }] * }); * * // 唤魔者(默认空配置) * const evoker = EntityComponent.setEquipItem(); * * // 狐狸(禁止穿戴盔甲) * const fox = EntityComponent.setEquipItem({ * canWearArmor: false * }); */ static setEquipItem(options?: { canWearArmor?: boolean | undefined; excludedItems?: Object[] | undefined; }): Map; /** * Makes entity immune to fire damage * @param {boolean} [value=true] - Whether the entity is fire immune * @returns {Map} Minecraft fire_immune component */ static setFireImmune(value?: boolean): Map; /** * Sets the crop growth promotion properties when entity walks over crops * @param {Object} options - Growth configuration * @param {number} [options.chance=0] - Success chance per tick (0-1) * @param {number} [options.charges=10] - Number of growth charges * @returns {Map} Minecraft grows_crop component */ static setGrowsCrop({ chance, charges }?: { chance?: number | undefined; charges?: number | undefined; }): Map; /** * 设置实体立即消失 * @param {Object} [options] - 消失配置选项 * @param {boolean} [options.removeChildEntities=false] - 是否同时移除子实体(如被拴绳牵引的实体) * @returns {Map} 返回Minecraft立即消失组件 */ static setInstantDespawn(options?: { removeChildEntities?: boolean | undefined; }): Map; /** * 设置实体在指定方块内的通知器 * @param {Array} blockList - 要监测的方块列表 * @param {Object[]} blockList[].block - 方块定义 * @param {string} blockList[].block.name - 方块ID (如"minecraft:bubble_column") * @param {Object} [blockList[].block.states] - 方块状态 (如{"drag_down": true}) * @param {Object} [blockList[].entered_block_event] - 进入方块时触发的事件 * @param {string} blockList[].entered_block_event.event - 进入事件名称 * @param {string} [blockList[].entered_block_event.target="self"] - 事件目标 * @param {Object} [blockList[].exited_block_event] - 离开方块时触发的事件 * @param {string} blockList[].exited_block_event.event - 离开事件名称 * @param {string} [blockList[].exited_block_event.target="self"] - 事件目标 * @returns {Map} 返回Minecraft方块内部通知器组件 */ static setInsideBlockNotifier(blockList: any[]): Map; /** * 设置实体的库存属性 * @param {Object} options - 库存配置选项 * @param {number} [options.additionalSlotsPerStrength] - 每点力量值增加的额外槽位数 * @param {boolean} [options.canBeSiphonedFrom] - 是否允许漏斗从此库存抽取物品 * @param {'horse'|'minecart_chest'|'chest_boat'} [options.containerType] - 容器类型 * @param {number} [options.inventorySize] - 库存槽位数量 * @param {boolean} [options.isPrivate] - 死亡时是否不掉落库存物品 * @param {boolean} [options.restrictToOwner] - 是否只有所有者能访问 * @returns {Map} 返回Minecraft库存组件 */ static setInventoryProperties(options: { additionalSlotsPerStrength?: number | undefined; canBeSiphonedFrom?: boolean | undefined; containerType?: "horse" | "chest_boat" | "minecart_chest" | undefined; inventorySize?: number | undefined; isPrivate?: boolean | undefined; restrictToOwner?: boolean | undefined; }): Map; /** * 设置自定义碰撞箱 * @param {Array} hitboxes - 碰撞箱定义数组 * @returns {Map} 返回Minecraft自定义碰撞测试组件 */ static setCustomHitTest(hitboxes: any[]): Map; /** * @param {string[]} family_arr * @returns */ static setTypeFamily(family_arr: string[]): Map; static setDamageSensor(deals_damage: any): Map; /** * @param {RideableComponentDesc} param0 * @returns */ static setRideable({ controllingSeat, crouchingSkipInteract, familyTypes, interactText, onRiderEnterEvent, onRiderExitEvent, seatCount, seats, passengerMaxWidth, pullInEntities, }: RideableComponentDesc): Map[] | undefined; passenger_max_width: number | undefined; pull_in_entities: boolean | undefined; }>; static setInputGroundControlled(): Map; /** * @param {number} [base] * @param {number} [controlled] * @param {number} [jumpPrevented] * @returns */ static setVariableMaxAutoStep(base?: number, controlled?: number, jumpPrevented?: number): Map; static setMovement(speed: any): Map; static setCollisionBox(width: any, height: any): Map; /** * 将多个组件集合合并为一个。 * @param {...Map} componentMaps - 多个组件集合。 * @returns {Map} - 合并后的组件集合。 */ static combineComponents(...componentMaps: Map[]): Map; /** * 创建 minecraft:health 组件。 * @param {Object} options 配置选项 * @param {number} options.max 实体的最大生命值 * @param {number|Object} options.value 实体的初始生命值(可以是固定值或范围值) * @returns {Map} 包含 minecraft:health 组件的 Map 对象 * @throws {Error} 如果参数无效。 */ static setHealth(options?: { max: number; value: number | Object; }): Map; /** * 验证 minecraft:health 组件的参数。 * @param {number} max 最大生命值 * @param {number|Object} value 初始生命值 * @throws {Error} 如果参数无效。 */ static validateHealthParameters(max: number, value: number | Object): void; /** * 创建 minecraft:physics 组件。 * @param {boolean} has_collision 是否碰撞(默认:true) * @param {boolean} has_gravity 是否受重力影响(默认:true) * @param {boolean} push_towards_closest_space 是否在卡住时推向最近空间(默认:false) * @returns {Map} 包含 minecraft:physics 组件的 Map 对象 * @throws {Error} 如果参数不是布尔类型。 */ static setPhysics(has_collision?: boolean, has_gravity?: boolean, push_towards_closest_space?: boolean): Map; /** * 创建 minecraft:scale 组件。 * @param {number} value 实体的缩放比例(默认:1.0) * @returns {Map} 包含 minecraft:scale 组件的 Map 对象 * @throws {Error} 如果参数无效。 */ static setScale(value?: number): Map; /** * 创建默认的 minecraft:nameable 组件(不填写参数)。 * @returns {Map} 包含 minecraft:nameable 组件的 Map 对象 */ static setDefaultNameable(): Map; /** * 创建自定义的 minecraft:nameable 组件(填写参数)。 * @param {boolean} allowNameTagRenaming 是否允许使用命名牌重命名(默认:true) * @param {boolean} alwaysShow 是否始终显示名称(默认:false) * @param {Object} defaultTrigger 默认触发事件(可选) * @param {Array} nameActions 特殊名称及其对应的事件(可选) * @returns {Map} 包含 minecraft:nameable 组件的 Map 对象 * @throws {Error} 如果参数无效。 */ static setCustomNameable(allowNameTagRenaming?: boolean, alwaysShow?: boolean, defaultTrigger?: Object, nameActions?: any[]): Map; /** * 创建 minecraft:pushable 组件。 * @param {boolean} isPushable 是否可以被其他实体推动(默认:true) * @param {boolean} isPushableByPiston 是否可以被活塞推动(默认:true) * @returns {Map} 包含 minecraft:pushable 组件的 Map 对象 * @throws {Error} 如果参数无效。 */ static setPushable(isPushable?: boolean, isPushableByPiston?: boolean): Map; /** * 创建 minecraft:jump.static 组件。 * @param {number} jumpPower 跳跃的初始垂直速度(默认:0.42) * @returns {Map} 包含 minecraft:jump.static 组件的 Map 对象 * @throws {Error} 如果参数无效。 */ static setJumpStatic(jumpPower?: number): Map; /** * 创建 minecraft:navigation.walk 组件。 * @param {Object} options 配置选项 * @param {boolean} options.avoidDamageBlocks 是否避免伤害性方块(默认:false) * @param {boolean} options.avoidPortals 是否避免传送门(默认:false) * @param {boolean} options.avoidSun 是否避免阳光下的方块(默认:false) * @param {boolean} options.avoidWater 是否避免水(默认:false) * @param {Array} options.blocksToAvoid 需要避免的方块列表(默认:[]) * @param {boolean} options.canBreach 是否可以跳出水面(默认:false) * @param {boolean} options.canBreakDoors 是否可以破坏门(默认:false) * @param {boolean} options.canFloat 是否可以漂浮(默认:false) * @param {boolean} options.canJump 是否可以跳跃(默认:true) * @param {boolean} options.canOpenDoors 是否可以开门(默认:false) * @param {boolean} options.canOpenIronDoors 是否可以开铁门(默认:false) * @param {boolean} options.canPassDoors 是否可以穿过门(默认:true) * @param {boolean} options.canPathFromAir 是否可以在空中开始路径规划(默认:false) * @param {boolean} options.canPathOverLava 是否可以在熔岩表面行走(默认:false) * @param {boolean} options.canPathOverWater 是否可以在水面上行走(默认:false) * @param {boolean} options.canSink 是否会在水中下沉(默认:true) * @param {boolean} options.canSwim 是否可以游泳(默认:false) * @param {boolean} options.canWalk 是否可以在地面上行走(默认:true) * @param {boolean} options.canWalkInLava 是否可以在熔岩中行走(默认:false) * @param {boolean} options.isAmphibious 是否可以在水下行走(默认:false) * @returns {Map} 包含 minecraft:navigation.walk 组件的 Map 对象 * @throws {Error} 如果参数无效。 */ static setNavigationWalk(options?: { avoidDamageBlocks: boolean; avoidPortals: boolean; avoidSun: boolean; avoidWater: boolean; blocksToAvoid: any[]; canBreach: boolean; canBreakDoors: boolean; canFloat: boolean; canJump: boolean; canOpenDoors: boolean; canOpenIronDoors: boolean; canPassDoors: boolean; canPathFromAir: boolean; canPathOverLava: boolean; canPathOverWater: boolean; canSink: boolean; canSwim: boolean; canWalk: boolean; canWalkInLava: boolean; isAmphibious: boolean; }): Map; /** * 创建 minecraft:movement.basic 组件。 * @param {number} maxTurn 实体每 tick 可以转向的最大角度(默认:30.0) * @returns {Map} 包含 minecraft:movement.basic 组件的 Map 对象 * @throws {Error} 如果参数无效。 */ static setMovementBasic(maxTurn?: number): Map; /** * 创建 minecraft:projectile 组件。 * @param {Object} options 配置选项 * @param {number} options.anchor 发射锚点(默认:0) * @param {number} options.angleOffset 角度偏移(默认:0.0) * @param {boolean} options.catchFire 是否点燃目标(默认:false) * @param {boolean} options.critParticleOnHurt 是否生成暴击粒子(默认:false) * @param {boolean} options.destroyOnHurt 是否在击中时销毁(默认:false) * @param {string} options.filter 过滤的实体(可选) * @param {boolean} options.fireAffectedByGriefing 是否受游戏规则影响(默认:false) * @param {number} options.gravity 重力值(默认:0.05) * @param {string} options.hitSound 击中声音(可选) * @param {string} options.hitGroundSound 击中地面声音(可选) * @param {boolean} options.homing 是否追踪目标(默认:false) * @param {number} options.inertia 空气惯性(默认:0.99) * @param {boolean} options.isDangerous 是否对玩家危险(默认:false) * @param {boolean} options.knockback 是否击退目标(默认:true) * @param {boolean} options.lightning 是否召唤闪电(默认:false) * @param {number} options.liquidInertia 水中惯性(默认:0.6) * @param {boolean} options.multipleTargets 是否可击中多个目标(默认:true) * @param {number[]} options.offset 发射偏移量(默认:[0, 0, 0]) * @param {number} options.onFireTime 着火时间(默认:0.0) * @param {Object} options.onHit 击中时的行为(可选) * @param {string} options.particle 碰撞粒子(默认:"ironcrack") * @param {number} options.power 初始速度(默认:1.3) * @param {number} options.reflectImmunity 反射免疫时间(默认:0.0) * @param {boolean} options.reflectOnHurt 是否反射(默认:false) * @param {string} options.shootSound 发射声音(可选) * @param {boolean} options.shootTarget 是否朝向目标发射(默认:true) * @param {boolean} options.shouldBounce 是否反弹(默认:false) * @param {boolean} options.splashPotion 是否为喷溅药水(默认:false) * @param {number} options.splashRange 喷溅范围(默认:4) * @param {boolean} options.stopOnHurt 是否在击中时停止(默认:false) * @param {number} options.uncertaintyBase 基础精度(默认:0) * @param {number} options.uncertaintyMultiplier 精度倍数(默认:0) * @returns {Map} 包含 minecraft:projectile 组件的 Map 对象 * @throws {Error} 如果参数无效。 */ static setProjectile(options?: { anchor: number; angleOffset: number; catchFire: boolean; critParticleOnHurt: boolean; destroyOnHurt: boolean; filter: string; fireAffectedByGriefing: boolean; gravity: number; hitSound: string; hitGroundSound: string; homing: boolean; inertia: number; isDangerous: boolean; knockback: boolean; lightning: boolean; liquidInertia: number; multipleTargets: boolean; offset: number[]; onFireTime: number; onHit: Object; particle: string; power: number; reflectImmunity: number; reflectOnHurt: boolean; shootSound: string; shootTarget: boolean; shouldBounce: boolean; splashPotion: boolean; splashRange: number; stopOnHurt: boolean; uncertaintyBase: number; uncertaintyMultiplier: number; }): Map; /** * 设置实体的家(工作站点)组件,用于限制实体的活动范围。 * @param {Object} [options] - 配置选项 * @param {number} [options.restriction_radius=16] - 限制半径(方块格) * @param {string[]} [options.home_block_list=["minecraft:chest"]] - 可绑定为家的方块列表 * @param {string} [options.restriction_type] - 限制类型(可选,如 "limited"),需 format_version >= 1.21.40 * @returns {Map} 返回 Minecraft home 组件 * * @example // 基础用法 - 16格半径,箱子作为家 * const home = EntityComponent.setHome(); * * @example // 自定义配置 * const customHome = EntityComponent.setHome({ * restriction_radius: 32, * home_block_list: ["minecraft:chest", "minecraft:barrel"], * restriction_type: "limited" * }); */ static setHome({ restriction_radius, home_block_list, restriction_type }?: { restriction_radius?: number | undefined; home_block_list?: string[] | undefined; restriction_type?: string | undefined; }): Map; /** * 设置可分享物品列表(该实体感兴趣并会主动拾取的物品) * 与 minecraft:behavior.pickup_items 配合使用 * @param {Object} [options] - 配置选项 * @param {Array} [options.items=[]] - 物品条目列表 * @param {string} options.items[].item - 物品ID * @param {number} [options.items[].want_amount] - 想要保留的数量 * @param {number} [options.items[].surplus_amount] - 溢出阈值(超出此数量可分享给玩家) * @param {number} [options.items[].priority] - 优先级(数值越小优先级越高) * @param {number} [options.items[].max_amount] - 最大持有数 * @param {number} [options.items[].pickup_limit] - 单次拾取数限制 * @param {boolean} [options.items[].pickup_only] - 是否只拾取不分享 * @param {boolean} [options.items[].stored_in_inventory] - 是否存入库存 * @param {boolean} [options.items[].consume_item] - 是否消耗物品 * @param {Object} [options.items[].admire] - 欣赏物品行为 * @param {Object} [options.items[].barter] - 以物易物配置 * @param {Object} [options.items[].craft_into] - 合成转换配置 * @param {boolean} [options.all_items=false] - 是否接受任意物品 * @param {boolean} [options.singular_pickup=false] - 是否一次只拾取一个 * @returns {Map} 返回 Minecraft shareables 组件 */ static setShareables({ items, all_items, singular_pickup }?: { items?: Object[] | undefined; }): Map; } type BehaviorLiterals = 'beh' | 'behavior' | 'behaviour'; type ResourceLiterals = 'res' | 'resource'; declare class NativeEntityData { static getDataById(type: BehaviorLiterals | ResourceLiterals, id: string): any; static getBehavior(id: string): any; static getResource(id: string): any; } declare namespace Navigation { function walk(options?: { avoid_damage_blocks?: boolean | undefined; avoid_portals?: boolean | undefined; avoid_sun?: boolean | undefined; avoid_water?: boolean | undefined; blocks_to_avoid?: any[] | undefined; can_breach?: boolean | undefined; can_break_doors?: boolean | undefined; can_jump?: boolean | undefined; can_open_doors?: boolean | undefined; can_open_iron_doors?: boolean | undefined; can_pass_doors?: boolean | undefined; can_path_from_air?: boolean | undefined; can_path_over_lava?: boolean | undefined; can_path_over_water?: boolean | undefined; can_sink?: boolean | undefined; can_swim?: boolean | undefined; can_walk?: boolean | undefined; can_walk_in_lava?: boolean | undefined; is_amphibious?: boolean | undefined; }): Map; } declare namespace BiomeAPI { function createBiome(identifier: any): Biome; } declare function registerBlock(block: Block): void; declare namespace BlockAPI { function createBasicBlock(identifier: string, category: string, textures_arr: any[], options?: { group: string; hide_in_command: boolean; format_version?: string | undefined; }): BasicBlock; function createBlock(identifier: string, category: string, variantDatas: any[], options?: { group: string; hide_in_command: boolean; ambient_occlusion: boolean; face_dimming: boolean; render_method: string; format_version?: string | undefined; }): Block; function createRotatableBlock(identifier: string, category: string, textures_arr: any[], options?: { group: string; hide_in_command: boolean; rotationType: string; yRotationOffset: number; format_version?: string | undefined; }): RotatableBlock; function createGeometryBlock(identifier: any, category: any, geometry: any, material_instances: any, options?: {}): GeometryBlock; function createTileBlock(identifier: string, category: string, textures_arr: any[], options?: { group?: string | undefined; hide_in_command?: boolean | undefined; format_version?: string | undefined; entity_texture?: string | undefined; inventory_size?: number | undefined; container_type?: string | undefined; can_be_siphoned_from?: boolean | undefined; }): TileBlock; function createOreBlock(identifier: any, category: any, textures_arr: any, options?: {}): OreBlock; function createHeadBlock(identifier: string, category: string, texture: string, options?: { group: string; hide_in_command: boolean; ambient_occlusion: boolean; face_dimming: boolean; render_method: string; tick_interval?: any[] | undefined; custom_components?: any[] | undefined; format_version?: string | undefined; }): HeadBlock; function createGlassBlock(identifier: any, category: any, texture: any, options?: {}): GlassBlock; function createFenceBlock(identifier: any, category: any, textures_arr: any, options?: {}): FenceBlock; function createStairBlock(identifier: any, category: any, textures_arr: any, options?: {}): StairBlock; function createTrapdoorBlock(identifier: any, category: any, texture: any, options?: {}): TrapdoorBlock; function createCropBlock(identifier: any, category: any, variantDatas: any, options?: {}): CropBlock; } declare function registerEntity(behData: any, resData: any): void; declare namespace EntityAPI { function createNativeEntity(identifier: string, proto_id: string, options?: Object): { behavior: BasicEntity; resource: ClientEntity; }; function createEntity(identifier: string, texture?: string, options?: Object, behData?: Object, resData?: Object): { behavior: BasicEntity; resource: ClientEntity; }; function createProjectile(identifier: string, texture: string, options?: Object): { behavior: BasicEntity; resource: ClientEntity; }; function createDummyEntity(identifier: string, texture: string, options?: Object, behData?: Object, resData?: Object): { behavior: BasicEntity; resource: ClientEntity; }; } declare namespace FeatureAPI { function createOreFeature(identifier: any, count: any, replace_rules: any): OreFeature; function createFeatureRules(identifier: any, places_feature: any): FeatureRule; } /** * 物品菜单栏分类枚举 * 用于 Item / Food / FlipbookItem 及 ItemAPI 的 category 参数 */ declare enum ItemCategory { Commands = "commands", Construction = "construction", Equipment = "equipment", Nature = "nature", Items = "items", None = "none" } /** * 物品组件 Map:以 Minecraft 组件名为 key */ type ItemComponentMap = Map; /** * 物品选项 * snake_case(对应 Minecraft JSON 字段)与 camelCase 互为别名,camelCase 优先 */ interface ItemOptions { group?: string; hide_in_command?: boolean; hideInCommand?: boolean; max_stack_size?: number; maxStackSize?: number; format_version?: string; formatVersion?: string; /** * 图标纹理名称;传 null 表示不添加 minecraft:icon 组件 */ icon?: string | null; displayName?: string; } /** * 3D 手持物品骨骼变换(动画中的 position/rotation/scale) */ interface ModelBoneTransform { position?: [number, number, number]; rotation?: [number, number, number]; scale?: number | [number, number, number]; } /** * 3D 手持物品选项(Method 2:model binding) */ interface CreateModelItemOptions extends ItemOptions { /** * 几何根骨骼名,内置动画将作用于该骨骼;必须与用户 geometry 中带 * binding(q.item_slot_to_bone_name)的骨骼名一致。默认 "rightitem"。 */ boneName?: string; /** * 默认材质。默认 "entity"(不透明,同官方示例); * 模型含透明像素时可用 "entity_alphatest"。 */ material?: string; /** * 覆盖内置第一人称握持姿态(默认参照官方示例) */ holdFirstPerson?: ModelBoneTransform; /** * 覆盖内置第三人称握持姿态(默认参照官方示例) */ holdThirdPerson?: ModelBoneTransform; } /** * 食物选项 */ interface FoodOptions extends ItemOptions { animation?: string; movement?: number; useDuration?: number; canAlwaysEat?: boolean; nutrition?: number; saturationModifier?: number; /** * 是否为肉类(自动追加 minecraft:is_meat 标签) */ isMeat?: boolean; /** * 是否为鱼类(自动追加 minecraft:is_fish 标签) */ isFish?: boolean; /** * 是否为熟食(自动追加 minecraft:is_cooked 标签) */ isCooked?: boolean; } /** * 可投掷组件选项 */ interface ThrowableOptions { doSwingAnimation?: boolean; launchPowerScale?: number; maxDrawDuration?: number; maxLaunchPower?: number; minDrawDuration?: number; scalePowerByDrawDuration?: boolean; } /** * 食物组件选项 */ interface FoodComponentOptions { nutrition?: number; saturationModifier?: number; canAlwaysEat?: boolean; usingConvertsTo?: string; } /** * 方块描述符:字符串、带状态的名称对象或标签 Molang 查询对象 */ type BlockDescriptor = string | { name: string; states?: Record; } | { tags: string; }; /** * 数值范围 */ interface Range { min: number; max: number; } /** * 物品稀有度 */ type ItemRarity = 'common' | 'uncommon' | 'rare' | 'epic'; /** * 放置方块组件选项 */ interface BlockPlacerOptions { replaceBlockItem?: boolean; alignedPlacement?: boolean; useOn?: BlockDescriptor[]; } /** * 使用修饰组件选项 */ interface UseModifiersOptions { movementModifier?: number; useDuration?: number; emitVibrations?: boolean; startSound?: string; startUsing?: 'always' | 'if_first'; } /** * 图标纹理(对象格式) */ interface IconTextures { default: string; dyed?: string; iconTrim?: string; bundleOpenBack?: string; bundleOpenFront?: string; } /** * 冷却组件选项 */ interface CooldownOptions { category: string; duration: number; type?: 'use' | 'attack'; } /** * 挖掘组件选项 */ interface DiggerOptions { destroySpeeds: { block: BlockDescriptor; speed: number; }[]; useEfficiency?: boolean; } /** * 耐久传感器阈值 */ interface DurabilityThreshold { durability: number; particleType?: string; soundEvent?: string; } /** * 耐久传感器组件选项 */ interface DurabilitySensorOptions { durabilityThresholds: DurabilityThreshold[]; } /** * 放置实体组件选项 */ interface EntityPlacerOptions { dispenseOn?: BlockDescriptor[]; useOn?: BlockDescriptor[]; } /** * 动能武器组件选项 */ interface KineticWeaponOptions { delay: number; hitboxMargin?: number; reach?: Range; creativeReach?: Range; damageMultiplier?: number; damageModifier?: number; damageConditions?: Record; dismountConditions?: Record; knockbackConditions?: Record; } /** * 穿刺武器组件选项 */ interface PiercingWeaponOptions { hitboxMargin?: number; reach?: Range; creativeReach?: Range; } /** * 唱片组件选项 */ interface RecordOptions { comparatorSignal: number; duration: number; soundEvent: string; } /** * 修复条目 */ interface RepairItem { items: (string | { tags: string; })[]; repairAmount?: number | string; } /** * 射击组件弹药 */ interface ShooterAmmunition { item: string; searchInventory?: boolean; useInCreative?: boolean; useOffhand?: boolean; } /** * 射击组件选项 */ interface ShooterOptions { ammunition: ShooterAmmunition[]; chargeOnDraw?: boolean; maxDrawDuration?: number; scalePowerByDrawDuration?: boolean; } /** * 容器物品组件选项 */ interface StorageItemOptions { maxSlots: number; allowNestedStorageItems: boolean; allowedItems?: string[]; bannedItems?: string[]; } /** * 挥砍音效组件选项 */ interface SwingSoundsOptions { attackMiss?: string; attackHit?: string; attackCriticalHit?: string; } declare class Attachable extends AddonAttachableDescription { #private; constructor(identifier: string, formatVersion?: string); getId(): string; toObject(): Record; } declare class Item { identifier: string; category: string; texture: string; group?: string; hide_in_command: boolean; format_version: string; components: ItemComponentMap; attachable?: Attachable; /** * 物品类 * @param identifier 物品唯一标识符 * @param category 菜单栏分类,见 {@link ItemCategory} * @param texture 物品纹理 * @param options 可选参数 */ constructor(identifier: string, category: ItemCategory, texture: string, options?: ItemOptions); /** * 添加组件 * @param componentMap 组件 Map */ addComponent(componentMap: ItemComponentMap): this; /** * 移除组件 * @param key 组件名称 */ removeComponent(key: string): this; getAttachable(): Attachable | undefined; /** * 将物品转换为 JSON 格式 * @returns JSON 格式的物品对象 */ toObject(): Record; } /** * 盔甲类型枚举 */ declare enum ArmorType { Chestplate = "chestplate", Helmet = "helmet", Boots = "boots", Leggings = "leggings" } /** * 盔甲类型规格 * 参考 Bedrock Wiki "Custom Armor":https://wiki.bedrock.dev/items/custom-armor */ interface ArmorSpec { group: string; geometry: string; script: string; protection: number; slot: string; enchantSlot: string; maxDurability: number; displayName: string; } /** * 盔甲选项 * 参考 Bedrock Wiki "Custom Armor":https://wiki.bedrock.dev/items/custom-armor */ interface ArmorOptions extends ItemOptions { displayName?: string; /** * 附魔槽位与等级(参考 wiki 规范,默认 { slot: 按部位, value: 10 }) */ enchantable?: { slot: string; value?: number; }; /** * 最大耐久(参考 wiki 规范,默认按部位:头盔 363 / 胸甲 528 / 护腿 495 / 靴子 429) */ maxDurability?: number; /** * 修复条目(参考 wiki 规范,默认木棍,每次恢复 25% 最大耐久) */ repairItems?: RepairItem[]; /** * 附加标签(参考 wiki 规范,默认 ["minecraft:is_armor", "minecraft:trimmable_armors"]) */ tags?: string[]; /** * 渲染控制器,默认 "controller.render.armor"(兼容旧版),可传 "controller.render.armor.v2" */ renderController?: string; } /** * 盔甲类 * 由 ArmorType 数据表驱动,同时生成物品(Item)与可附着物(Attachable) */ declare class Armor { type: ArmorType; identifier: string; item: Item; attachable: Attachable; constructor(identifier: string, item_texture: string, texture_path: string, type?: ArmorType, options?: ArmorOptions); /** * 设置可附着物的几何模型 * @param key 几何模型名称 * @param geometry 几何模型标识符 * @returns 当前实例,支持链式调用 */ setAttachableGeometry(key: string, geometry: string): this; /** * 获取行为包与资源包的 JSON 表示 * @returns { behavior, resource } 两个包的注册内容 */ toObject(): { behavior: Record; resource: Record; }; } declare class Food extends Item { /** * 食物类 * @param identifier 物品唯一标识符 * @param category 菜单栏分类,见 {@link ItemCategory} * @param texture 物品纹理 * @param options 可选参数 */ constructor(identifier: string, category: ItemCategory, texture: string, options?: FoodOptions); } /** * 翻书物品配置选项接口 */ interface FlipbookItemOptions { /** * 物品分组 - 用于在创造模式物品栏中分组显示 * @example "construction" - 建筑类 * @example "equipment" - 装备类 * @example "nature" - 自然类 */ group?: string; /** * 是否在命令自动补全中隐藏该物品 * @default false - 默认在命令中显示 */ hide_in_command?: boolean; /** * 每个动画帧持续的游戏刻数(tick) * 1秒 = 20游戏刻,因此8刻 = 0.4秒 * @default 8 - 默认每帧显示0.4秒 * @minimum 1 - 最小值1刻 */ ticks_per_frame?: number; /** * 物品的最大堆叠数量 * @default 64 - 默认堆叠64个 * @minimum 1 - 最小值1 * @maximum 99 - 最大堆叠限制 */ max_stack_size?: number; /** * 资源包的格式版本号 * @example "1.20.0" - 1.20版本 * @example "1.19.0" - 1.19版本 * @default "1.20.0" - 默认使用最新版本 */ format_version?: string; /** * 翻书纹理文件的完整路径(不含 .png 后缀)。 * @default `"textures/blocks/${texture}"` - 默认使用方块纹理目录 */ texture_path?: string; } /** * 翻书物品类 * 继承自Item类,用于创建具有动态翻书动画效果的物品 * 该类会自动创建对应的几何方块并注册翻书材质动画 */ declare class FlipbookItem extends Item { /** * 关联的外观方块实例 * 用于在游戏中显示该翻书物品的3D模型 */ block: GeometryBlock; /** * 创建并注册翻书物品 * * @param identifier - 物品的唯一标识符(如:"my_mod:flipbook_item") * @param category - 物品所属的分类(如:"construction", "equipment"等) * @param texture - 纹理名称(不包含路径和后缀,如:"my_flipbook_texture") * @param options - 可选的配置参数对象 * @param options.group - 物品分组,用于在创造模式物品栏中分组显示 * @param options.hide_in_command - 是否在命令自动补全中隐藏该物品 * @param options.ticks_per_frame - 每个动画帧持续的游戏刻数(tick),默认8刻 * @param options.max_stack_size - 物品的最大堆叠数量 * @param options.format_version - 格式版本号 */ constructor(identifier: string, category: ItemCategory, texture: string, options?: FlipbookItemOptions); } /** * 物品目录分类 * 参考 Bedrock Wiki Item Catalog:仅支持 construction / equipment / items / nature 四类 */ type ItemCatalogCategory = 'construction' | 'equipment' | 'items' | 'nature'; /** * 可展开分组配置 */ interface ItemCatalogGroupOptions { /** * 分组图标使用的物品 */ icon?: string; /** * 分组的本地化键,如 "wiki:itemGroup.name.ore";同时可用作物品/方块的 menu_category.group */ name?: string; } /** * 物品目录 * 生成 BP/item_catalog/crafting_item_catalog.json, * 用于指定物品在创造菜单与配方手册中的分组位置。 */ declare class ItemCatalog { format_version: string; private categories; /** * @param format_version 格式版本,默认 "1.26.30" */ constructor(format_version?: string); /** * 添加一组物品到指定分类 * @param category 创造菜单分类(construction/equipment/items/nature) * @param items 物品标识符列表 * @param options 可展开分组配置 * @returns 当前实例,支持链式调用 */ addGroup(category: ItemCatalogCategory, items: string[], options?: ItemCatalogGroupOptions): this; /** * 添加单个物品到指定分类 * @param category 创造菜单分类(construction/equipment/items/nature) * @param item 物品标识符 * @param options 可展开分组配置 * @returns 当前实例,支持链式调用 */ addItem(category: ItemCatalogCategory, item: string, options?: ItemCatalogGroupOptions): this; /** * 注册到行为包的 item_catalog/ 目录 * @returns 当前实例 */ register(): this; /** * 将物品目录转换为 JSON 格式 * @returns JSON 格式的物品目录对象 */ toObject(): Record; } declare const ItemAPI: { /** * 创建一个普通物品。 * @param identifier 物品的唯一标识符。 * @param category 物品在创造菜单中的分类,见 {@link ItemCategory}。 * @param texture 物品的纹理。 * @param options 额外选项。 * @returns 创建的物品。 */ createItem(identifier: string, category: ItemCategory, texture: string, options?: ItemOptions): Item; /** * 创建一个大型物品(Item + Attachable)。 * 用于在手持时显示为大型 3D 模型(如部分 3D 物品)。 * @param identifier 物品的唯一标识符。 * @param category 物品在创造菜单中的分类,见 {@link ItemCategory}。 * @param texture 物品的纹理。 * @param options 额外选项。 * @returns 创建的物品。 */ createLargeItem(identifier: string, category: ItemCategory, texture: string, options?: ItemOptions): Item; /** * 创建一个 3D 手持物品(Item + Attachable + 内置默认握持动画)。 * 采用 Bedrock Wiki "Attachables" 的 Method 2(model binding):attachable 使用 * scripts.animate 按 context.is_first_person 切换首/第三人称动画,并搭配 * controller.render.item_default 渲染控制器。内置动画姿态参照官方示例 * (首/第三人称各用固定值),骨骼名须与用户 geometry 中的根骨骼一致。 * 用户需自行将几何模型放入 RP(geometry 根骨骼应使用 * "q.item_slot_to_bone_name(c.item_slot)" 绑定槽位)。 * @param identifier 物品的唯一标识符(如 "my_mod:model_sword")。 * @param category 物品在创造菜单中的分类,见 {@link ItemCategory}。 * @param icon 物品图标(创造菜单/物品栏显示的短名,需登记在 item_texture.json)。 * 与 texture 相互独立,可分别指定。 * @param texture attachable 的 3D 贴图路径。传完整路径(如 "textures/entity/skeleton/skeleton") * 将直接用作贴图;传短名(如 "amethyst_shard")则自动拼接 "textures/items/" 前缀。 * @param geometry 用户几何标识符(如 "geometry.my_model")。 * @param options 额外选项,见 {@link CreateModelItemOptions}。 * @returns 创建的物品。 */ createModelItem(identifier: string, category: ItemCategory, icon: string, texture: string, geometry: string, options?: CreateModelItemOptions): Item; /** * 创建一个食物物品。 * @param identifier 食物的唯一标识符。 * @param category 食物在创造菜单中的分类,见 {@link ItemCategory}。 * @param texture 食物的纹理。 * @param options 额外选项。 * @returns 创建的食物物品。 */ createFood(identifier: string, category: ItemCategory, texture: string, options?: FoodOptions): Food; /** * 创建一个可附着物品。 * @param identifier 可附着物品的唯一标识符。 * @param texture 可附着物品的纹理。 * @param material 可附着物品的材质。 * @param options 额外选项。 * @returns 创建的可附着物品。 */ createAttachable(identifier: string, texture: string, material: string, options?: ItemOptions): Attachable; /** * 创建一个胸甲(Item + Attachable)。 * @param identifier 物品的唯一标识符。 * @param item_texture 物品图标纹理名称。 * @param texture_path 盔甲模型纹理路径。 * @param options 额外选项。 * @returns 创建的盔甲实例。 */ createChestplateArmor(identifier: string, item_texture: string, texture_path: string, options?: ItemOptions): Armor; /** * 创建一个头盔(Item + Attachable)。 */ createHelmetArmor(identifier: string, item_texture: string, texture_path: string, options?: ItemOptions): Armor; /** * 创建一个靴子(Item + Attachable)。 */ createBootArmor(identifier: string, item_texture: string, texture_path: string, options?: ItemOptions): Armor; /** * 创建一个护腿(Item + Attachable)。 */ createLeggingsArmor(identifier: string, item_texture: string, texture_path: string, options?: ItemOptions): Armor; /** * 创建并注册翻书物品。 * @param identifier 物品的唯一标识符(如:"my_mod:flipbook_item")。 * @param category 物品所属的分类,见 {@link ItemCategory}。 * @param texture 纹理名称(不包含路径和后缀,如:"my_flipbook_texture")。 * @param options 可选的配置参数对象。 * @returns 创建的翻书物品。 */ createFlipbookItem(identifier: string, category: ItemCategory, texture: string, options?: FlipbookItemOptions): FlipbookItem; /** * 创建物品目录(生成 BP/item_catalog/crafting_item_catalog.json)。 * 用于指定物品在创造菜单与配方手册中的分组位置。 * @param formatVersion 格式版本,默认 "1.26.30" * @returns 物品目录实例 */ createItemCatalog(formatVersion?: string): ItemCatalog; }; declare const RecipeAPI: RecipeRegistry; declare class RecipeRegistry { /** * * @param {AddonRecipeFurnace_1_17} recipe */ registerRecipe(recipe: AddonRecipeFurnace_1_17): void; registerSimpleFurnace(identifier: any, output: any, input: any): AddonRecipeFurnace_1_17; registerFurnace(identifier: any): AddonRecipeFurnace_1_17; registerSimpleShaped(identifier: any, output: any, pattern: any, key: any): AddonRecipeShaped_1_20; registerShaped(identifier: any): AddonRecipeShaped_1_20; registerSimpleShapeless(identifier: any, output: any, ingredients: any): AddonRecipeShapeless_1_17; registerShapeless(identifier: any): AddonRecipeShapeless_1_17; } type Any$1 = any; declare class UISystem { identifier: string; namespace: string; name: string; path: string; elements: Map; animations: Map; constructor(identifier: string, path: string); addElement(element: Any$1): this; getElement(element_name: string): Any$1; addAnimation(name: string, value: Any$1): void; getAnimation(animation_name: string): Any$1; toObject(): Record; } /** 共享 UI 类型定义(JSON UI 规范的受控映射) */ /** 尺寸向量(像素数字或百分比/计算字符串),如 [320, 207] / ["50%", "100%"] */ type Size2$1 = [number | string, number | string]; /** 偏移向量 [x, y](像素) */ type Offset2$1 = [number, number]; /** 锚点(anchor_from / anchor_to)可选值 */ type Anchor = 'top_left' | 'top_middle' | 'top_right' | 'left_middle' | 'center' | 'right_middle' | 'bottom_left' | 'bottom_middle' | 'bottom_right'; /** 数据绑定类型 */ type BindingType = 'global' | 'view' | 'collection' | 'collection_details' | 'none'; /** 数据绑定条件 */ type BindingCondition = 'always' | 'always_when_visible' | 'visible' | 'once' | 'none' | 'visibility_changed'; /** 调制操作类型(Modifications.OPERATION 的字面量) */ type ModificationOperation = 'insert_back' | 'insert_front' | 'insert_after' | 'insert_before' | 'move_back' | 'move_front' | 'move_after' | 'move_before' | 'swap' | 'replace' | 'remove'; /** 支持任意键的 JSON UI 属性包(类内部索引签名基类型) */ type JsonUIBag = { [key: string]: any; }; /** * DataBindingObject 类 * * 该类表示数据绑定配置,用于将硬编码值或变量绑定到元素属性。 * * 属性: * - ignored: boolean - 是否忽略绑定(默认值:false) * - binding_type: enum - 绑定类型(可能值:global, view, collection, collection_details, none) * - binding_name: string - 数据绑定名称或条件的值 * - binding_name_override: string - 应用 binding_name 值的 UI 元素属性名称 * - binding_collection_name: string - 要使用的集合名称 * - binding_collection_prefix: string - 集合前缀 * - binding_condition: enum - 数据绑定的条件(可能值:always, always_when_visible, visible, once, none, visibility_changed) * - source_control_name: string - 要观察其属性值的 UI 元素名称 * - source_property_name: string - 存储 source_control_name 引用的 UI 元素的属性值 * - target_property_name: string - 应用 source_property_name 值的 UI 元素属性 * - resolve_sibling_scope: boolean - 是否允许选择同级元素而非子元素(默认值:false) */ type BindingTypeOrString = BindingType | string; type BindingConditionOrString = BindingCondition | string; declare class DataBindingObject { [key: string]: unknown; ignored: boolean; binding_type: BindingTypeOrString; binding_name: string; binding_name_override: string; binding_collection_name: string; binding_collection_prefix: string; binding_condition: BindingConditionOrString; source_control_name: string; source_property_name: string; target_property_name: string; resolve_sibling_scope: boolean; /** * 设置是否忽略绑定。 * @param {boolean} ignored - 是否忽略绑定(默认值:false) * @returns {DataBindingObject} 返回当前实例以支持链式调用 */ setIgnored(ignored?: boolean): this; /** * 设置绑定类型。 * @param {BindingTypeOrString} type - 绑定类型(可能值:global, view, collection, collection_details, none) * @returns {DataBindingObject} 返回当前实例以支持链式调用 */ setBindingType(type: BindingTypeOrString): this; /** * 设置数据绑定名称或条件的值。 * @param {string} name - 数据绑定名称或条件的值 * @returns {DataBindingObject} 返回当前实例以支持链式调用 */ setBindingName(name: string): this; /** * 设置应用 binding_name 值的 UI 元素属性名称。 * @param {string} nameOverride - 应用 binding_name 值的 UI 元素属性名称 * @returns {DataBindingObject} 返回当前实例以支持链式调用 */ setBindingNameOverride(nameOverride: string): this; /** * 设置要使用的集合名称。 * @param {string} collectionName - 集合名称 * @returns {DataBindingObject} 返回当前实例以支持链式调用 */ setBindingCollectionName(collectionName: string): this; /** * 设置集合前缀。 * @param {string} prefix - 集合前缀 * @returns {DataBindingObject} 返回当前实例以支持链式调用 */ setBindingCollectionPrefix(prefix: string): this; /** * 设置数据绑定的条件。 * @param {BindingConditionOrString} condition - 数据绑定的条件(可能值:always, always_when_visible, visible, once, none, visibility_changed) * @returns {DataBindingObject} 返回当前实例以支持链式调用 */ setBindingCondition(condition: BindingConditionOrString): this; /** * 设置要观察其属性值的 UI 元素名称。 * @param {string} controlName - UI 元素名称 * @returns {DataBindingObject} 返回当前实例以支持链式调用 */ setSourceControlName(controlName: string): this; /** * 设置存储 source_control_name 引用的 UI 元素的属性值。 * @param {string} propertyName - 属性名称 * @returns {DataBindingObject} 返回当前实例以支持链式调用 */ setSourcePropertyName(propertyName: string): this; /** * 设置应用 source_property_name 值的 UI 元素属性。 * @param {string} propertyName - 属性名称 * @returns {DataBindingObject} 返回当前实例以支持链式调用 */ setTargetPropertyName(propertyName: string): this; /** * 设置是否允许选择同级元素而非子元素。 * @param {boolean} resolve - 是否允许选择同级元素(默认值:false) * @returns {DataBindingObject} 返回当前实例以支持链式调用 */ setResolveSiblingScope(resolve?: boolean): this; } declare class DataBinding { [key: string]: unknown; bindings: DataBindingObject[]; binding: DataBindingObject; setBinding(binding: DataBindingObject): this; addDataBinding(dataBindingObject: DataBindingObject): this; } /** * Control Class * * This class represents a UI control element with various properties and methods to manipulate its state. * * Properties: * - visible: boolean - If the UI element should be visible (default: true) * - enabled: boolean - If true and if the UI element or any of its children have the locked state then they will be in the locked (default: true) * - layer: int - Z-Index/Layer (like zindex in CSS) relative to parent element. Higher layers will render above (default: 0) * - alpha: float - Alpha/transparency of the element. It will only affect the UI element. Its children will be unaffected. (default: 1.0) * - propagate_alpha: boolean - If alpha should not only apply to the parent if possible but also all its children (default: false) * - clips_children: boolean - Cuts off visually and interactively everything beyond the boundaries of the UI element (default: false) * - allow_clipping: boolean - If clips_children works in the UI element. Otherwise, it won't have any effect (default: true) * - clip_offset: Vector [x, y] - Offset from the start of the clipping (default: [0, 0]) * - clip_state_change_event: string - Event triggered when the clip state changes * - enable_scissor_test: boolean - Enables scissor test for clipping (default: false) * - property_bag: object - Property bag contains properties/variables that are more related with the data than the actual structure and look of the UI element * - selected: boolean - If the text box is selected by default * - use_child_anchors: boolean - Use the anchor_from and anchor_to of the child of the UI element (default: false) * - controls: array - For adding children to the element * - anims: string[] - Array of the animation names * - disable_anim_fast_forward: boolean - Disables fast-forwarding animations * - animation_reset_name: string - Name of the animation to reset to * - ignored: boolean - If the UI element should be ignored (default: false) * - variables: array or object - A bunch of conditions that change the variables values * - modifications: array - Allows to modify the UI files of resource packs below (vanilla being the most bottom one) * - grid_position: Vector [row, column] - Position that the control will take inside the grid. This also allows to modify specific grid items of a hardcoded grid * - collection_index: int - Index that the control takes in the collection */ /** 附加到 Control.controls 的子元素:可序列化元素对象或 JSON UI 控件对象 */ type ChildControl = Record; declare class Control { [key: string]: unknown; visible: boolean; enabled: boolean; layer: number; alpha: number; propagate_alpha: boolean; clips_children: boolean; allow_clipping: boolean; clip_offset: Offset2$1; clip_state_change_event: string; enable_scissor_test: boolean; property_bag: JsonUIBag; selected: boolean; use_child_anchors: boolean; controls: ChildControl[]; anims: string[]; disable_anim_fast_forward: boolean; animation_reset_name: string; ignored: boolean; variables: JsonUIBag; modifications: unknown[]; grid_position: Offset2$1; collection_index: number; /** * 设置控件的可见性。 * @param {boolean} visible - 控件是否可见(默认值:true) * @returns {Control} 返回当前实例以支持链式调用 */ setVisible(visible?: boolean): this; /** * 设置控件的启用状态。 * @param {boolean} enabled - 控件是否启用(默认值:true) * @returns {Control} 返回当前实例以支持链式调用 */ setEnabled(enabled?: boolean): this; /** * 设置控件的层级(z-index)。 * @param {number} layer - 要设置的层级(默认值:0) * @returns {Control} 返回当前实例以支持链式调用 */ setLayer(layer?: number): this; /** * 设置控件的透明度。 * @param {number} alpha - 要设置的透明度值(默认值:1.0) * @returns {Control} 返回当前实例以支持链式调用 */ setAlpha(alpha?: number): this; /** * 设置透明度是否应传播到子元素。 * @param {boolean} propagate - 透明度是否应传播(默认值:false) * @returns {Control} 返回当前实例以支持链式调用 */ setPropagateAlpha(propagate?: boolean): this; /** * 设置控件是否应裁剪其子元素。 * @param {boolean} clips - 控件是否应裁剪其子元素(默认值:false) * @returns {Control} 返回当前实例以支持链式调用 */ setClipsChildren(clips?: boolean): this; /** * 设置控件是否允许裁剪。 * @param {boolean} allow - 是否允许裁剪(默认值:true) * @returns {Control} 返回当前实例以支持链式调用 */ setAllowClipping(allow?: boolean): this; /** * 设置控件的裁剪偏移量。 * @param {Offset2} offset - 裁剪偏移量,格式为 [x, y](默认值:[0, 0]) * @returns {Control} 返回当前实例以支持链式调用 */ setClipOffset(offset?: Offset2$1): this; /** * 设置裁剪状态更改事件。 * @param {string} event - 裁剪状态更改时触发的事件名称 * @returns {Control} 返回当前实例以支持链式调用 */ setClipStateChangeEvent(event: string): this; /** * 设置是否启用裁剪测试。 * @param {boolean} enable - 是否启用裁剪测试(默认值:false) * @returns {Control} 返回当前实例以支持链式调用 */ setEnableScissorTest(enable?: boolean): this; /** * 设置控件的属性包。 * @param {JsonUIBag} bag - 要设置的属性包 * @returns {Control} 返回当前实例以支持链式调用 */ setPropertyBag(bag: JsonUIBag): this; /** * 设置控件是否被选中。 * @param {boolean} selected - 控件是否被选中(默认值:false) * @returns {Control} 返回当前实例以支持链式调用 */ setSelected(selected?: boolean): this; /** * 设置控件是否使用子元素的锚点。 * @param {boolean} use - 是否使用子元素的锚点(默认值:false) * @returns {Control} 返回当前实例以支持链式调用 */ setUseChildAnchors(use?: boolean): this; /** * 向控件添加子控件。 * @param {ChildControl} control - 要添加的子控件 * @returns {Control} 返回当前实例以支持链式调用 */ addControl(control: ChildControl): this; /** * 设置控件的动画。 * @param {string[]} anims - 动画名称数组 * @returns {Control} 返回当前实例以支持链式调用 */ setAnimations(anims: string[]): this; /** * 设置是否禁用动画快进。 * @param {boolean} disable - 是否禁用动画快进(默认值:false) * @returns {Control} 返回当前实例以支持链式调用 */ setDisableAnimFastForward(disable?: boolean): this; /** * 设置动画重置名称。 * @param {string} name - 要重置的动画名称 * @returns {Control} 返回当前实例以支持链式调用 */ setAnimationResetName(name: string): this; /** * 设置是否忽略该控件。 * @param {boolean} ignored - 是否忽略该控件(默认值:false) * @returns {Control} 返回当前实例以支持链式调用 */ setIgnored(ignored?: boolean): this; /** * 设置控件的变量。 * @param {JsonUIBag} variables - 要设置的变量 * @returns {Control} 返回当前实例以支持链式调用 */ setVariables(variables: JsonUIBag): this; /** * 设置控件的修改项。 * @param {unknown[]} modifications - 要设置的修改项 * @returns {Control} 返回当前实例以支持链式调用 */ setModifications(modifications: unknown[]): this; /** * 设置控件在网格中的位置。 * @param {Offset2} position - 网格位置,格式为 [行, 列] * @returns {Control} 返回当前实例以支持链式调用 */ setGridPosition(position: Offset2$1): this; /** * 设置控件在集合中的索引。 * @param {number} index - 要设置的索引 * @returns {Control} 返回当前实例以支持链式调用 */ setCollectionIndex(index: number): this; } /** * Layout 类 * * 该类表示一个具有各种属性和方法的 UI 布局元素,用于操作其布局和大小。 * * 属性: * - size: Vector [width, height] - UI 元素的大小(默认值:["default", "default"]) * - max_size: Vector [width, height] - UI 元素的最大大小(默认值:["default", "default"]) * - min_size: Vector [width, height] - UI 元素的最小大小(默认值:["default", "default"]) * - offset: Vector [x, y] - UI 元素相对于父元素的位置(默认值:[0, 0]) * - anchor_from: enum - 父元素中的锚点(默认值:center) * - anchor_to: enum - 元素自身的锚点(默认值:center) * - inherit_max_sibling_width: boolean - 是否使用兄弟元素的最大宽度(默认值:false) * - inherit_max_sibling_height: boolean - 是否使用兄弟元素的最大高度(默认值:false) * - use_anchored_offset: boolean - 是否使用基于锚点的偏移(默认值:false) * - contained: boolean - 是否限制元素在父元素边界内(默认值:false) * - draggable: enum - 是否使元素可拖动(可能值:vertical, horizontal, both) * - follows_cursor: boolean - 是否使元素跟随光标(默认值:false) */ type AnchorOrString = Anchor | string; type SizeOrString = Size2$1 | string; declare class Layout { [key: string]: unknown; size: SizeOrString; max_size: Size2$1; min_size: Size2$1; offset: Offset2$1; anchor_from: AnchorOrString; anchor_to: AnchorOrString; inherit_max_sibling_width: boolean; inherit_max_sibling_height: boolean; use_anchored_offset: boolean; contained: boolean; draggable: 'vertical' | 'horizontal' | 'both'; follows_cursor: boolean; /** * 设置 UI 元素的大小。 * @param {Size2} size - 大小,格式为 [width, height](默认值:["default", "default"]) * @returns {Layout} 返回当前实例以支持链式调用 */ setSize(size?: SizeOrString): this; /** * 设置 UI 元素的最大大小。 * @param {Size2} maxSize - 最大大小,格式为 [width, height](默认值:["default", "default"]) * @returns {Layout} 返回当前实例以支持链式调用 */ setMaxSize(maxSize?: Size2$1): this; /** * 设置 UI 元素的最小大小。 * @param {Size2} minSize - 最小大小,格式为 [width, height](默认值:["default", "default"]) * @returns {Layout} 返回当前实例以支持链式调用 */ setMinSize(minSize?: Size2$1): this; /** * 设置 UI 元素相对于父元素的位置。 * @param {Offset2} offset - 偏移量,格式为 [x, y](默认值:[0, 0]) * @returns {Layout} 返回当前实例以支持链式调用 */ setOffset(offset?: Offset2$1): this; /** * 设置父元素中的锚点。 * @param {AnchorOrString} anchorFrom - 锚点(可能值:top_left, top_middle, top_right, left_middle, center, right_middle, bottom_left, bottom_middle, bottom_right)(默认值:center) * @returns {Layout} 返回当前实例以支持链式调用 */ setAnchorFrom(anchorFrom?: AnchorOrString): this; /** * 设置元素自身的锚点。 * @param {AnchorOrString} anchorTo - 锚点(可能值:top_left, top_middle, top_right, left_middle, center, right_middle, bottom_left, bottom_middle, bottom_right)(默认值:center) * @returns {Layout} 返回当前实例以支持链式调用 */ setAnchorTo(anchorTo?: AnchorOrString): this; /** * 设置是否使用兄弟元素的最大宽度。 * @param {boolean} inherit - 是否使用兄弟元素的最大宽度(默认值:false) * @returns {Layout} 返回当前实例以支持链式调用 */ setInheritMaxSiblingWidth(inherit?: boolean): this; /** * 设置是否使用兄弟元素的最大高度。 * @param {boolean} inherit - 是否使用兄弟元素的最大高度(默认值:false) * @returns {Layout} 返回当前实例以支持链式调用 */ setInheritMaxSiblingHeight(inherit?: boolean): this; /** * 设置是否使用基于锚点的偏移。 * @param {boolean} use - 是否使用基于锚点的偏移(默认值:false) * @returns {Layout} 返回当前实例以支持链式调用 */ setUseAnchoredOffset(use?: boolean): this; /** * 设置是否限制元素在父元素边界内。 * @param {boolean} contained - 是否限制元素在父元素边界内(默认值:false) * @returns {Layout} 返回当前实例以支持链式调用 */ setContained(contained?: boolean): this; /** * 设置是否使元素可拖动。 * @param {'vertical' | 'horizontal' | 'both'} draggable - 是否使元素可拖动(可能值:vertical, horizontal, both) * @returns {Layout} 返回当前实例以支持链式调用 */ setDraggable(draggable: 'vertical' | 'horizontal' | 'both'): this; /** * 设置是否使元素跟随光标。 * @param {boolean} follows - 是否使元素跟随光标(默认值:false) * @returns {Layout} 返回当前实例以支持链式调用 */ setFollowsCursor(follows?: boolean): this; } /** * Elements A JSON UI element is the basic form of data within JSON UI. Elements must have a unique name for each namespace so as to not have a conflict with other elements of the same name yet may have different functions. Here the element type is label so it will render a text of Hello World when called: vanilla/ui/example_file.json { "test_element": { "type": "label", "text": "Hello World" } } Types The following are some of the element types, which are possible values for the type property: label - for creating text objects image - for rendering images from a filepath provided button - for creating interactive and clickable elements panel - an empty container where you can store all other elements that may overlap to each other stack_panel - an empty container where you can store all other elements in a stack that doesn't overlap to each other grid - uses another element as a template, and then renders it repeatedly in multiple rows and columns factory - renders an element based off of another element, is capable of calling hardcoded values and variables custom - is paired with another property renderer which renders hardcoded JSON UI elements screen - elements that are called by the game directly, usually root panel elements */ type SerializedElement = Record; type AnyJSON = any; declare class UIElement { type: string | undefined; id: string; name: string; control: Control; layout: Layout; properties: Map; variables: Map; dataBinding: DataBinding; modifications: { array_name: string; operation: ModificationOperation; value: AnyJSON; }[]; constructor(name: string, type?: string, template?: string); enableDebug(color?: [number, number, number, number]): this; setLayout(layout: Layout): this; setControl(control: Control): this; addControl(control: UIElement | JsonUIBag): this; addControls(controls: (UIElement | JsonUIBag)[]): this; addVariable(name: string, value: AnyJSON): this; addProp(name: string, value: AnyJSON): this; addModification(modification: { array_name: string; operation: ModificationOperation; value: AnyJSON; }): this; /** * 声明待序列化合并的属性包(子类覆写以加入自己的专属属性包)。 * 合并顺序对结果无影响:重复键值均相同。 */ protected serializableSources(): object[]; serialize(): SerializedElement; } /** * Modifications To modify JSON UI in a non-intrusive way, you can use the modifications property to modify previously existing JSON UI elements from other packs (usually vanilla JSON UI files). Doing this makes sure only necessary parts are modified unless otherwise intended, to improve compatibility with other packs that modify the JSON UI. Modification Description insert_back insert at end of array insert_front insert at start of array insert_after insert after target in array insert_before insert before target in array move_back move target to end of array move_front move target to start of array move_after move target after second target move_before move target before second target swap swap first target with second target replace replace first target with second target remove remove target */ declare class Modifications { static OPERATION: Readonly<{ readonly INSERT_BACK: "insert_back"; readonly INSERT_FRONT: "insert_front"; readonly INSERT_AFTER: "insert_after"; readonly INSERT_BEFORE: "insert_before"; readonly MOVE_BACK: "move_back"; readonly MOVE_FRONT: "move_front"; readonly MOVE_AFTER: "move_after"; readonly MOVE_BEFORE: "move_before"; readonly SWAP: "swap"; readonly REPLACE: "replace"; readonly REMOVE: "remove"; }>; } /** * Factory 类 * * 该类表示一个工厂控件,用于管理子控件的名称和 ID。 * * 属性: * - control_name: string - 工厂的子控件名 * - control_ids: object - 工厂的子控件 ID 对象组 */ declare class Factory { [key: string]: unknown; factory: JsonUIBag; /** * 设置工厂的名。 * @param {string} name - 名(格式:name) * @returns {Factory} 返回当前实例以支持链式调用 */ setName(name: string): this; /** * 设置工厂的子控件名。 * @param {string} name - 子控件名(格式:namespace.controls_name) * @returns {Factory} 返回当前实例以支持链式调用 */ setControlName(name: string): this; /** * 设置工厂的子控件 ID 对象组。 * @param {JsonUIBag} ids - 子控件 ID 对象组 * @returns {Factory} 返回当前实例以支持链式调用 */ setControlIds(ids: JsonUIBag): this; /** * 添加一个子控件 ID。 * @param {string} key - 子控件的键名 * @param {string} value - 子控件的 ID 值 * @returns {Factory} 返回当前实例以支持链式调用 */ addControlId(key: string, value: string): this; } declare class Panel extends UIElement { factory: Factory; /** * @param {string} id * @param {string} [template] */ constructor(id: string, template?: string); setLayout(layout: Layout): this; protected serializableSources(): object[]; } /** * Sprite 类 * * 该类表示一个 Sprite 控件,用于管理图像纹理及其相关属性。 * * 属性: * - texture: string - 图像路径(从包根目录开始,例如:"textures/ui/White") * - allow_debug_missing_texture: boolean - 是否在纹理未找到时显示缺失纹理(默认值:true) * - uv: Vector [u, v] - 纹理映射的起始位置 * - uv_size: Vector [width, height] - 纹理映射的大小 * - texture_file_system: string - 纹理来源(默认值:InUserPackage) * - nineslice_size: int or Vector [x0, y0, x1, y1] - 9-slice 分割大小 * - tiled: boolean or enum - 是否平铺纹理(可能值:true/false, x, y) * - tiled_scale: Vector [sX, sY] - 平铺纹理的缩放比例(默认值:false) * - clip_direction: enum - 裁剪方向的起始点(可能值:left, right, up, down, center) * - clip_ratio: float - 裁剪比例(范围:0.0 到 1.0) * - clip_pixelperfect: boolean - 是否尽可能保持像素精确裁剪 * - keep_ratio: boolean - 是否在调整大小时保持比例(默认值:true) * - bilinear: boolean - 是否在调整大小时使用双线性函数(默认值:false) * - fill: boolean - 是否拉伸图像以适应大小(默认值:false) * - $fit_to_width: boolean - 是否适应宽度 * - zip_folder: string - 压缩文件夹路径 * - grayscale: boolean - 是否以黑白渲染图像(默认值:false) * - force_texture_reload: boolean - 是否在纹理路径更改时强制重新加载图像 * - base_size: Vector [width, height] - 基础大小 */ type UV = [number, number]; type ClipDirection = 'left' | 'right' | 'up' | 'down' | 'center'; type TextureFileSystem = 'InUserPackage' | 'InAppPackage' | 'RawPath' | 'RawPersistent' | 'InSettingsDir' | 'InExternalDir' | 'InServerPackage' | 'InDataDir' | 'InUserDir' | 'InWorldDir' | 'StoreCache' | string; declare class Sprite { [key: string]: unknown; texture: string; allow_debug_missing_texture: boolean; uv: UV; uv_size: UV; texture_file_system: TextureFileSystem; nineslice_size: number | [number, number, number, number]; tiled: boolean | 'x' | 'y'; tiled_scale: [number, number]; clip_direction: ClipDirection | string; clip_ratio: number; clip_pixelperfect: boolean; keep_ratio: boolean; bilinear: boolean; fill: boolean; $fit_to_width: boolean; zip_folder: string; grayscale: boolean; force_texture_reload: boolean; base_size: [number, number]; /** * 设置图像纹理路径。 * @param {string} texture - 图像路径(例如:"textures/ui/White") * @returns {Sprite} 返回当前实例以支持链式调用 */ setTexture(texture: string): this; /** * 设置是否在纹理未找到时显示缺失纹理。 * @param {boolean} allow - 是否显示缺失纹理(默认值:true) * @returns {Sprite} 返回当前实例以支持链式调用 */ setAllowDebugMissingTexture(allow?: boolean): this; /** * 设置纹理映射的起始位置。 * @param {UV} uv - 起始位置,格式为 [u, v] * @returns {Sprite} 返回当前实例以支持链式调用 */ setUV(uv: UV): this; /** * 设置纹理映射的大小。 * @param {UV} uvSize - 大小,格式为 [width, height] * @returns {Sprite} 返回当前实例以支持链式调用 */ setUVSize(uvSize: UV): this; /** * 设置纹理来源。 * @param {TextureFileSystem} source - 纹理来源(可能值:InUserPackage, InAppPackage 等) * @returns {Sprite} 返回当前实例以支持链式调用 */ setTextureFileSystem(source?: TextureFileSystem): this; /** * 设置 9-slice 分割大小。 * @param {number | [number, number, number, number]} size - 9-slice 分割大小 * @returns {Sprite} 返回当前实例以支持链式调用 */ setNineSliceSize(size: number | [number, number, number, number]): this; /** * 设置是否平铺纹理。 * @param {boolean | 'x' | 'y'} tiled - 是否平铺纹理(可能值:true/false, x, y) * @returns {Sprite} 返回当前实例以支持链式调用 */ setTiled(tiled: boolean | 'x' | 'y'): this; /** * 设置平铺纹理的缩放比例。 * @param {[number, number]} scale - 缩放比例,格式为 [sX, sY](默认值:[1, 1]) * @returns {Sprite} 返回当前实例以支持链式调用 */ setTiledScale(scale?: [number, number]): this; /** * 设置裁剪方向的起始点。 * @param {ClipDirection} direction - 裁剪方向(可能值:left, right, up, down, center) * @returns {Sprite} 返回当前实例以支持链式调用 */ setClipDirection(direction: ClipDirection | string): this; /** * 设置裁剪比例。 * @param {number} ratio - 裁剪比例(范围:0.0 到 1.0) * @returns {Sprite} 返回当前实例以支持链式调用 */ setClipRatio(ratio: number): this; /** * 设置是否尽可能保持像素精确裁剪。 * @param {boolean} pixelPerfect - 是否保持像素精确裁剪 * @returns {Sprite} 返回当前实例以支持链式调用 */ setClipPixelPerfect(pixelPerfect?: boolean): this; /** * 设置是否在调整大小时保持比例。 * @param {boolean} keep - 是否保持比例(默认值:true) * @returns {Sprite} 返回当前实例以支持链式调用 */ setKeepRatio(keep?: boolean): this; /** * 设置是否在调整大小时使用双线性函数。 * @param {boolean} bilinear - 是否使用双线性函数(默认值:false) * @returns {Sprite} 返回当前实例以支持链式调用 */ setBilinear(bilinear?: boolean): this; /** * 设置是否拉伸图像以适应大小。 * @param {boolean} fill - 是否拉伸图像(默认值:false) * @returns {Sprite} 返回当前实例以支持链式调用 */ setFill(fill?: boolean): this; /** * 设置是否适应宽度。 * @param {boolean} fit - 是否适应宽度 * @returns {Sprite} 返回当前实例以支持链式调用 */ setFitToWidth(fit?: boolean): this; /** * 设置压缩文件夹路径。 * @param {string} folder - 压缩文件夹路径 * @returns {Sprite} 返回当前实例以支持链式调用 */ setZipFolder(folder: string): this; /** * 设置是否以黑白渲染图像。 * @param {boolean} grayscale - 是否以黑白渲染图像(默认值:false) * @returns {Sprite} 返回当前实例以支持链式调用 */ setGrayscale(grayscale?: boolean): this; /** * 设置是否在纹理路径更改时强制重新加载图像。 * @param {boolean} force - 是否强制重新加载图像(默认值:false) * @returns {Sprite} 返回当前实例以支持链式调用 */ setForceTextureReload(force?: boolean): this; /** * 设置基础大小。 * @param {[number, number]} size - 基础大小,格式为 [width, height] * @returns {Sprite} 返回当前实例以支持链式调用 */ setBaseSize(size: [number, number]): this; } declare class Image extends UIElement { sprite: Sprite; factory: Factory; constructor(id: string, template?: string); setSprite(sprite: Sprite): this; protected serializableSources(): object[]; } /** * Text 类 * * 该类表示一个文本控件,用于管理文本内容及其样式属性。 * * 属性: * - text: string - 文本内容(默认值:空字符串) * - color: Vector [r, g, b] - 文本颜色(RGB 值,范围 0.0 到 1.0,默认值:[1.0, 1.0, 1.0]) * - locked_color: Vector [r, g, b] - 父级禁用时的文本颜色 * - shadow: boolean - 是否显示文本阴影(默认值:false) * - hide_hyphen: boolean - 是否隐藏断词连字符(默认值:false) * - notify_on_ellipses: string[] - 文本出现省略号时需通知的控件名称数组 * - enable_profanity_filter: boolean - 是否启用脏话过滤(默认值:false) * - locked_alpha: float - 父级禁用时的透明度 * - font_size: enum - 字体大小(可能值:small, normal, large, extra_large,默认值:normal) * - font_scale_factor: float - 字体缩放比例(默认值:1.0) * - localize: boolean - 是否启用本地化翻译(默认值:false) * - line_padding: number - 行间距 * - font_type: enum - 字体类型(可能值:default, rune, unicode, smooth, MinecraftTen 或自定义字体,默认值:default) * - backup_font_type: enum - 备用字体类型(默认值:default) * - text_alignment: enum - 文本对齐方式(未定义时根据 anchor_from 和 anchor_to 自动调整) */ type RGB = [number, number, number]; type FontSize = 'small' | 'normal' | 'large' | 'extra_large'; type TextAlignment = 'left' | 'right' | 'center'; declare class Text { [key: string]: unknown; text: string; color: RGB; locked_color: RGB; shadow: boolean; hide_hyphen: boolean; notify_on_ellipses: string[]; enable_profanity_filter: boolean; locked_alpha: number; font_size: FontSize; font_scale_factor: number; localize: boolean; line_padding: number; font_type: string; backup_font_type: string; text_alignment: TextAlignment; /** * 设置文本内容。 * @param {string} text - 文本内容 * @returns {Text} 返回当前实例以支持链式调用 */ setText(text?: string): this; /** * 设置文本颜色。 * @param {RGB} color - RGB 颜色值(格式:[r, g, b],默认值:[1.0, 1.0, 1.0]) * @returns {Text} 返回当前实例以支持链式调用 */ setColor(color?: RGB): this; /** * 设置父级禁用时的文本颜色。 * @param {RGB} lockedColor - RGB 颜色值(格式:[r, g, b]) * @returns {Text} 返回当前实例以支持链式调用 */ setLockedColor(lockedColor: RGB): this; /** * 设置是否显示文本阴影。 * @param {boolean} shadow - 是否显示阴影(默认值:false) * @returns {Text} 返回当前实例以支持链式调用 */ setShadow(shadow?: boolean): this; /** * 设置是否隐藏断词连字符。 * @param {boolean} hide - 是否隐藏连字符(默认值:false) * @returns {Text} 返回当前实例以支持链式调用 */ setHideHyphen(hide?: boolean): this; /** * 设置文本出现省略号时需通知的控件名称数组。 * @param {string[]} controls - 控件名称数组 * @returns {Text} 返回当前实例以支持链式调用 */ setNotifyOnEllipses(controls: string[]): this; /** * 添加一个需通知省略号事件的控件名称。 * @param {string} controlName - 控件名称 * @returns {Text} 返回当前实例以支持链式调用 */ addNotifyOnEllipses(controlName: string): this; /** * 设置是否启用脏话过滤。 * @param {boolean} enable - 是否启用过滤(默认值:false) * @returns {Text} 返回当前实例以支持链式调用 */ setEnableProfanityFilter(enable?: boolean): this; /** * 设置父级禁用时的透明度。 * @param {number} alpha - 透明度(范围:0.0 到 1.0) * @returns {Text} 返回当前实例以支持链式调用 */ setLockedAlpha(alpha: number): this; /** * 设置字体大小。 * @param {FontSize} size - 字体大小(可能值:small, normal, large, extra_large,默认值:normal) * @returns {Text} 返回当前实例以支持链式调用 */ setFontSize(size?: FontSize): this; /** * 设置字体缩放比例。 * @param {number} factor - 缩放比例(默认值:1.0) * @returns {Text} 返回当前实例以支持链式调用 */ setFontScaleFactor(factor?: number): this; /** * 设置是否启用本地化翻译。 * @param {boolean} localize - 是否启用本地化(默认值:false) * @returns {Text} 返回当前实例以支持链式调用 */ setLocalize(localize?: boolean): this; /** * 设置行间距。 * @param {number} padding - 行间距 * @returns {Text} 返回当前实例以支持链式调用 */ setLinePadding(padding: number): this; /** * 设置字体类型。 * @param {string} font - 字体类型(可能值:default, rune, unicode 等,默认值:default) * @returns {Text} 返回当前实例以支持链式调用 */ setFontType(font?: string): this; /** * 设置备用字体类型。 * @param {string} backupFont - 备用字体类型(默认值:default) * @returns {Text} 返回当前实例以支持链式调用 */ setBackupFontType(backupFont?: string): this; /** * 设置文本对齐方式。 * @param {TextAlignment} alignment - 对齐方式(例如:left, right, center) * @returns {Text} 返回当前实例以支持链式调用 */ setTextAlignment(alignment: TextAlignment): this; } declare class Label extends UIElement { text: Text; factory: Factory; constructor(id: string, template?: string); setLayout(layout: Layout): this; setText(text: Text): this; protected serializableSources(): object[]; } declare namespace UiAPI { function createUISystem(identifier: any, path: any): UISystem; function createUIElement(id: any, type: any, template: any): UIElement; function createPanel(id: any, template: any): Panel; function createImage(id: any, template: any): Image; function createLabel(id: any, template: any): Label; } declare class ItemComponent { /** * 设置交互按钮 * @param interact_text 交互文本;传 true 使用通用 "Use Item" 文案,传 false 不显示 * @returns 交互按钮组件 */ static setInteractButton(interact_text: string | boolean): ItemComponentMap; /** * 自定义物品组件 * [warning] 需要物品格式版本 format_version >1.21.90 and Scripting V2.0.0 * @param component_id 组件标识符 * @param params 自定义参数接口对象 * @returns 物品组件 Map */ static setCustomComponentV2(component_id: string, params: object): ItemComponentMap; /** * 物品的耐久度组件 * @param max_durability 最大耐久 * @param damage_chance_min 损坏最小几率 * @param damage_chance_max 损坏最大几率 * @returns 耐久度组件 Map */ static setDurability(max_durability: number, damage_chance_min?: number, damage_chance_max?: number): ItemComponentMap; /** * 设置放置方块组件 * @param block 被放置的方块:标识符字符串,或 BlockDescriptor * (`{ name, states }` / `{ tags }`)。 * ⚠️ `minecraft:block_placer.block` 是否接受 BlockDescriptor 取决于引擎版本 * —— 传之前先按目标引擎验一次(`doc/dev/known-pitfalls.md` §2.3)。 * @param options 放置配置 * @param options.replaceBlockItem 是否替换原方块物品(要求物品 id 与方块 id 相同) * @param options.alignedPlacement 是否启用对齐放置 * @param options.useOn 允许放置的目标方块描述符列表;省略则可放置于任何方块 * @returns 组件 Map * @throws block 不是「非空字符串」也不是「含 string 类型 name 或 tags 的对象」 */ static setBlockPlacer(block: string | BlockDescriptor, options?: BlockPlacerOptions): ItemComponentMap; /** * 设置自定义组件列表 * @param custom_components 自定义组件 ID 数组 * @returns 组件 Map */ static setCustomComponents(custom_components: string[]): ItemComponentMap; /** * 设置物品的可投掷组件。 * @param doSwingAnimation 是否使用挥动动画。 * @param launchPowerScale 投掷力量的缩放比例。 * @param maxDrawDuration 最大蓄力时间。 * @param maxLaunchPower 最大投掷力量。 * @param minDrawDuration 最小蓄力时间。 * @param scalePowerByDrawDuration 投掷力量是否随蓄力时间增加。 * @returns 新的组件集合。 */ static setThrowable(doSwingAnimation?: boolean, launchPowerScale?: number, maxDrawDuration?: number, maxLaunchPower?: number, minDrawDuration?: number, scalePowerByDrawDuration?: boolean): ItemComponentMap; /** * 设置物品的显示名称。 * @param displayName 显示名称或本地化键。 * @returns 新的组件集合。 */ static setDisplayName(displayName: string): ItemComponentMap; /** * 设置物品的食物组件。 * @param options 食物组件配置。 * @param options.canAlwaysEat 是否随时可以食用。 * @param options.nutrition 营养值。 * @param options.saturationModifier 饱和度修正值。 * @param options.usingConvertsTo 食用后转换的目标物品。 * @returns 新的组件集合。 */ static setFoodComponent(options?: FoodComponentOptions): ItemComponentMap; /** * 设置物品的燃料组件。 * @param duration 燃料燃烧的持续时间(秒),最小值为 0.05。 * @returns 新的组件集合。 */ static setFuel(duration: number): ItemComponentMap; /** * 设置物品的附魔光效组件。 * @param hasGlint 是否显示附魔光效。 * @returns 新的组件集合。 */ static setGlint(hasGlint: boolean): ItemComponentMap; /** * 设置物品的手持渲染方式组件。 * @param isHandEquipped 是否像工具一样渲染。 * @returns 新的组件集合。 */ static setHandEquipped(isHandEquipped: boolean): ItemComponentMap; /** * 设置物品的图标组件。 * 支持字符串(default 纹理)或对象(多纹理)两种格式。 * @param texture 图标纹理名称,或包含 default/dyed/iconTrim 等纹理的对象。 * @returns 新的组件集合。 */ static setIcon(texture: string | IconTextures): ItemComponentMap; /** * 设置物品的最大堆叠数量组件。 * @param maxStackSize 最大堆叠数量,默认值为 64。 * @returns 新的组件集合。 */ static setMaxStackSize(maxStackSize?: number): ItemComponentMap; /** * 设置物品的投射物组件。 * @param minimumCriticalPower 投射物需要蓄力多久才能造成暴击。 * @param projectileEntity 作为投射物发射的实体名称。 * @returns 新的组件集合。 */ static setProjectile(minimumCriticalPower?: number, projectileEntity?: string): ItemComponentMap; /** * 设置物品的使用修饰组件。 * @param options 使用修饰配置。 * @param options.movementModifier 使用物品时玩家移动速度的缩放值(0.0-1.0)。 * @param options.useDuration 物品使用所需的时间(秒)。 * @param options.emitVibrations 是否在开始/停止使用时发出振动。 * @param options.startSound 开始使用时触发的音效。 * @param options.startUsing 使用修饰生效的时机("always" 或 "if_first")。 * @returns 新的组件集合。 */ static setUseModifiers(options?: UseModifiersOptions): ItemComponentMap; /** * 设置物品的可穿戴组件。 * @param protection 物品提供的保护值。 * @param slot 物品可以穿戴的槽位(如 "slot.armor.head"、"slot.weapon.offhand" 等)。 * @param hidesPlayerLocation 穿戴时是否从定位栏与定位地图中隐藏。 * @returns 新的组件集合。 */ static setWearable(protection?: number, slot?: string, hidesPlayerLocation?: boolean): ItemComponentMap; /** * 设置物品的使用动画组件。 * @param animation 物品使用时的动画类型(如 "eat"、"drink" 等)。 * @returns 新的组件集合。 */ static setUseAnimation(animation: string): ItemComponentMap; /** * 设置物品是否可装备至副手。 * @param allowed 是否允许装备至副手。 * @returns 新的组件集合。 */ static setAllowOffHand(allowed: boolean): ItemComponentMap; /** * 设置 Bundle 交互组件(需要同时具备 storage_item 组件)。 * @param numViewableSlots 可查看的槽位数量(1-64)。 * @returns 新的组件集合。 */ static setBundleInteraction(numViewableSlots: number): ItemComponentMap; /** * 设置创造模式下能否破坏方块。 * @param canDestroy 是否可破坏。 * @returns 新的组件集合。 */ static setCanDestroyInCreative(canDestroy: boolean): ItemComponentMap; /** * 设置堆肥组件。 * @param compostingChance 堆肥等级增加的概率(0-100)。 * @returns 新的组件集合。 */ static setCompostable(compostingChance: number): ItemComponentMap; /** * 设置物品的冷却组件。 * @param options 冷却配置。 * @param options.category 冷却分类,相同分类的物品共享冷却。 * @param options.duration 冷却时长(秒),负数会使物品无法使用。 * @param options.type 冷却影响的输入类型("use" 或 "attack")。 * @returns 新的组件集合。 */ static setCooldown(options: CooldownOptions): ItemComponentMap; /** * 设置物品的伤害组件。 * @param damage 额外伤害值(0-32767)。 * @returns 新的组件集合。 */ static setDamage(damage: number): ItemComponentMap; /** * 设置伤害吸收组件(需要同时具备 durability 组件并装备于盔甲槽位)。 * @param absorbableCauses 可被吸收的伤害原因列表,如 ["all"]。 * @returns 新的组件集合。 */ static setDamageAbsorption(absorbableCauses: string[]): ItemComponentMap; /** * 设置挖掘组件。 * @param options 挖掘配置。 * @param options.destroySpeeds 破坏速度列表,speed 为 0 表示无法破坏该方块。 * @param options.useEfficiency 效率附魔是否能影响破坏速度。 * @returns 新的组件集合。 */ static setDigger(options: DiggerOptions): ItemComponentMap; /** * 设置耐久传感器组件。 * @param options 耐久传感器配置。 * @param options.durabilityThresholds 耐久阈值列表,达到阈值时触发粒子或音效。 * @returns 新的组件集合。 */ static setDurabilitySensor(options: DurabilitySensorOptions): ItemComponentMap; /** * 设置可染色组件。 * @param defaultColor 默认颜色,如 "#ffffff"。 * @returns 新的组件集合。 */ static setDyeable(defaultColor: string): ItemComponentMap; /** * 设置可附魔组件。 * @param slot 可应用的附魔槽位,如 "sword"、"bow"。 * @param value 附魔质量与数量(0-255)。 * @returns 新的组件集合。 */ static setEnchantable(slot: string, value: number): ItemComponentMap; /** * 设置放置实体组件。 * @param entity 被放置的实体标识符,可带出生事件如 "wiki:entity"。 * @param options 放置配置。 * @param options.dispenseOn 允许发射器放置的目标方块列表。 * @param options.useOn 允许放置的目标方块列表。 * @returns 新的组件集合。 */ static setEntityPlacer(entity: string, options?: EntityPlacerOptions): ItemComponentMap; /** * 设置防火组件。 * @param value 是否防火。 * @returns 新的组件集合。 */ static setFireResistant(value: boolean): ItemComponentMap; /** * 设置物品名颜色组件。 * @param color 颜色名称,如 "minecoin_gold"。 * @returns 新的组件集合。 */ static setHoverTextColor(color: string): ItemComponentMap; /** * 设置动能武器组件。 * @param options 动能武器配置。 * @param options.delay 动能伤害开始生效前的延迟(tick)。 * @param options.hitboxMargin 命中箱额外边距(格)。 * @param options.reach 生效距离范围(格)。 * @param options.creativeReach 创造模式下生效距离范围(格)。 * @param options.damageMultiplier 基础伤害倍率。 * @param options.damageModifier 附加伤害。 * @param options.damageConditions 造成伤害的条件。 * @param options.dismountConditions 解除骑乘的条件。 * @param options.knockbackConditions 造成击退的条件。 * @returns 新的组件集合。 */ static setKineticWeapon(options: KineticWeaponOptions): ItemComponentMap; /** * 设置物品是否与液体方块交互。 * @param clipped 是否在液体内部交互。 * @returns 新的组件集合。 */ static setLiquidClipped(clipped: boolean): ItemComponentMap; /** * 设置穿刺武器组件。 * @param options 穿刺武器配置。 * @param options.hitboxMargin 命中箱额外边距(格)。 * @param options.reach 生效距离范围(格)。 * @param options.creativeReach 创造模式下生效距离范围(格)。 * @returns 新的组件集合。 */ static setPiercingWeapon(options?: PiercingWeaponOptions): ItemComponentMap; /** * 设置物品稀有度组件(会被 hover_text_color 覆盖)。 * @param rarity 稀有度:"common"、"uncommon"、"rare"、"epic"。 * @returns 新的组件集合。 */ static setRarity(rarity: ItemRarity): ItemComponentMap; /** * 设置唱片组件。 * @param options 唱片配置。 * @param options.comparatorSignal 比较器信号强度(0-15)。 * @param options.duration 播放时长(秒)。 * @param options.soundEvent 播放的原版音效事件。 * @returns 新的组件集合。 */ static setRecord(options: RecordOptions): ItemComponentMap; /** * 设置可修复组件。 * @param repairItems 修复条目列表;repair_amount 可为数字或 Molang 表达式字符串。 * @returns 新的组件集合。 */ static setRepairable(repairItems: RepairItem[]): ItemComponentMap; /** * 设置射击组件(需要同时具备 use_modifiers 组件)。 * @param options 射击配置。 * @param options.ammunition 弹药列表,item 必须具有 projectile 组件。 * @param options.chargeOnDraw 是否在拉弓时上弹(如弩)。 * @param options.maxDrawDuration 自动发射前的最大拉弓时长(秒)。 * @param options.scalePowerByDrawDuration 发射威力是否随拉弓时长增加。 * @returns 新的组件集合。 */ static setShooter(options: ShooterOptions): ItemComponentMap; /** * 设置是否应该消失组件。 * @param shouldDespawn 掉落物是否最终消失。 * @returns 新的组件集合。 */ static setShouldDespawn(shouldDespawn: boolean): ItemComponentMap; /** * 设置按数据堆叠组件。 * @param stackedByData 不同数据值的同种物品是否分开堆叠。 * @returns 新的组件集合。 */ static setStackedByData(stackedByData: boolean): ItemComponentMap; /** * 设置容器物品组件(需要 max_stack_size 为 1)。 * @param options 容器配置。 * @param options.maxSlots 容器槽位数量(1-64)。 * @param options.allowNestedStorageItems 是否允许嵌套其他容器物品。 * @param options.allowedItems 仅允许存入的物品列表。 * @param options.bannedItems 禁止存入的物品列表。 * @returns 新的组件集合。 */ static setStorageItem(options: StorageItemOptions): ItemComponentMap; /** * 设置容器重量上限组件(需要同时具备 storage_item 组件)。 * @param maxWeightLimit 容器内物品总重量上限。 * @returns 新的组件集合。 */ static setStorageWeightLimit(maxWeightLimit: number): ItemComponentMap; /** * 设置容器重量修正组件(0 表示不允许放入其他容器)。 * @param weightInStorageItem 该物品放入容器时占用的重量(0-64)。 * @returns 新的组件集合。 */ static setStorageWeightModifier(weightInStorageItem: number): ItemComponentMap; /** * 设置挥动时长组件。 * @param value 基础挥动时长(秒)。 * @returns 新的组件集合。 */ static setSwingDuration(value: number): ItemComponentMap; /** * 设置挥砍音效组件。 * @param options 音效配置。 * @param options.attackMiss 未命中时播放的原版音效。 * @param options.attackHit 普通命中时播放的原版音效。 * @param options.attackCriticalHit 暴击命中时播放的原版音效。 * @returns 新的组件集合。 */ static setSwingSounds(options?: SwingSoundsOptions): ItemComponentMap; /** * 设置物品标签组件。 * @param tags 标签列表。 * @returns 新的组件集合。 */ static setTags(tags: string[]): ItemComponentMap; /** * 将多个组件集合合并为一个。 * @param componentMaps 多个组件集合。 * @returns 合并后的组件集合。 */ static combineComponents(...componentMaps: ItemComponentMap[]): ItemComponentMap; /** * 获取当前组件的 JSON 表示。 * @param components 组件集合。 * @returns 组件的 JSON 对象。 */ static toJSON(components: ItemComponentMap): Record; } /** * ButtonMapping 类 * * 该类表示按钮映射配置,用于定义输入事件的映射关系。 * * 属性: * - ignored: boolean - 是否忽略映射(默认值:false) * - from_button_id: string - 触发事件的按钮 ID * - to_button_id: string - 事件触发时执行的按钮 ID * - mapping_type: enum - 映射类型(可能值:global, pressed, double_pressed, focused) * - scope: enum - 映射范围(可能值:view, controller) * - input_mode_condition: enum - 输入模式条件(可能值:not_gaze, not_gamepad, gamepad_and_not_gaze) * - ignore_input_scope: boolean - 是否忽略输入范围 * - consume_event: boolean - 是否消耗事件 * - handle_select: boolean - 是否处理选择事件 * - handle_deselect: boolean - 是否处理取消选择事件 * - button_up_right_of_first_refusal: boolean - 是否在首次拒绝后处理按钮释放事件 */ declare class ButtonMapping { [key: string]: unknown; ignored: boolean; from_button_id: string; to_button_id: string; mapping_type: string | null; scope: string | null; input_mode_condition: string | null; ignore_input_scope: boolean; consume_event: boolean; handle_select: boolean; handle_deselect: boolean; button_up_right_of_first_refusal: boolean; constructor(); /** * 设置是否忽略映射。 * @param {boolean} ignored - 是否忽略映射(默认值:false) * @returns {ButtonMapping} 返回当前实例以支持链式调用 */ setIgnored(ignored?: boolean): this; /** * 设置触发事件的按钮 ID。 * @param {string} fromButtonId - 触发事件的按钮 ID * @returns {ButtonMapping} 返回当前实例以支持链式调用 */ setFromButtonId(fromButtonId: string): this; /** * 设置事件触发时执行的按钮 ID。 * @param {string} toButtonId - 事件触发时执行的按钮 ID * @returns {ButtonMapping} 返回当前实例以支持链式调用 */ setToButtonId(toButtonId: string): this; /** * 设置映射类型。 * @param {string} mappingType - 映射类型(可能值:global, pressed, double_pressed, focused) * @returns {ButtonMapping} 返回当前实例以支持链式调用 */ setMappingType(mappingType: string): this; /** * 设置映射范围。 * @param {string} scope - 映射范围(可能值:view, controller) * @returns {ButtonMapping} 返回当前实例以支持链式调用 */ setScope(scope: string): this; /** * 设置输入模式条件。 * @param {string} condition - 输入模式条件(可能值:not_gaze, not_gamepad, gamepad_and_not_gaze) * @returns {ButtonMapping} 返回当前实例以支持链式调用 */ setInputModeCondition(condition: string): this; /** * 设置是否忽略输入范围。 * @param {boolean} ignore - 是否忽略输入范围 * @returns {ButtonMapping} 返回当前实例以支持链式调用 */ setIgnoreInputScope(ignore?: boolean): this; /** * 设置是否消耗事件。 * @param {boolean} consume - 是否消耗事件 * @returns {ButtonMapping} 返回当前实例以支持链式调用 */ setConsumeEvent(consume?: boolean): this; /** * 设置是否处理选择事件。 * @param {boolean} handle - 是否处理选择事件 * @returns {ButtonMapping} 返回当前实例以支持链式调用 */ setHandleSelect(handle?: boolean): this; /** * 设置是否处理取消选择事件。 * @param {boolean} handle - 是否处理取消选择事件 * @returns {ButtonMapping} 返回当前实例以支持链式调用 */ setHandleDeselect(handle?: boolean): this; /** * 设置是否在首次拒绝后处理按钮释放事件。 * @param {boolean} handle - 是否处理按钮释放事件 * @returns {ButtonMapping} 返回当前实例以支持链式调用 */ setButtonUpRightOfFirstRefusal(handle?: boolean): this; } interface ProgressBarLayer { color: [number, number, number]; clipRatio: number; } interface HudProgressBarOptions { id: string; texture: string; uv?: [number, number]; uvSize?: [number, number]; barSize?: [string | number, string | number]; layers: ProgressBarLayer[]; states: number; fillColor?: [number, number, number]; fillUv?: [number, number]; segments?: { count: number; color: [number, number, number]; }; hudSize?: [string | number, string | number]; anchorFrom?: string; anchorTo?: string; offset?: [number, number]; clipDirection?: string; } declare class HudProgressBar { private panel; private options; constructor(options: HudProgressBarOptions); private build; getPanel(): Panel; mountToHud(): void; } type AnyUI = any; declare class UISystemRegistry { #private; static registerUISystem(ui_system: AnyUI): void; static addOuterUIdefs(ui_defs: string[]): void; } /** * Input 类 * * 该类表示输入配置,用于管理 UI 元素的输入行为。 * * 属性: * - button_mappings: Array of mapping objects - 按钮映射配置 * - modal: boolean - 是否为模态输入 * - inline_modal: boolean - 是否为内联模态输入 * - always_listen_to_input: boolean - 是否始终监听输入 * - always_handle_pointer: boolean - 是否始终处理指针事件 * - always_handle_controller_direction: boolean - 是否始终处理控制器方向事件 * - hover_enabled: boolean - 是否启用悬停事件 * - prevent_touch_input: boolean - 是否阻止触摸输入 * - consume_event: boolean - 是否消耗事件 * - consume_hover_events: boolean - 是否消耗悬停事件 * - gesture_tracking_button: string - 手势跟踪按钮 */ declare class Input { [key: string]: unknown; button_mappings: JsonUIBag[]; modal: boolean; inline_modal: boolean; always_listen_to_input: boolean; always_handle_pointer: boolean; always_handle_controller_direction: boolean; hover_enabled: boolean; prevent_touch_input: boolean; consume_event: boolean; consume_hover_events: boolean; gesture_tracking_button: string; /** * 设置按钮映射配置。 * @param {JsonUIBag[]} mappings - 按钮映射配置数组 * @returns {Input} 返回当前实例以支持链式调用 */ setButtonMappings(mappings: JsonUIBag[]): this; /** * 设置是否为模态输入。 * @param {boolean} modal - 是否为模态输入 * @returns {Input} 返回当前实例以支持链式调用 */ setModal(modal?: boolean): this; /** * 设置是否为内联模态输入。 * @param {boolean} inlineModal - 是否为内联模态输入 * @returns {Input} 返回当前实例以支持链式调用 */ setInlineModal(inlineModal?: boolean): this; /** * 设置是否始终监听输入。 * @param {boolean} alwaysListen - 是否始终监听输入 * @returns {Input} 返回当前实例以支持链式调用 */ setAlwaysListenToInput(alwaysListen?: boolean): this; /** * 设置是否始终处理指针事件。 * @param {boolean} alwaysHandle - 是否始终处理指针事件 * @returns {Input} 返回当前实例以支持链式调用 */ setAlwaysHandlePointer(alwaysHandle?: boolean): this; /** * 设置是否始终处理控制器方向事件。 * @param {boolean} alwaysHandle - 是否始终处理控制器方向事件 * @returns {Input} 返回当前实例以支持链式调用 */ setAlwaysHandleControllerDirection(alwaysHandle?: boolean): this; /** * 设置是否启用悬停事件。 * @param {boolean} enabled - 是否启用悬停事件 * @returns {Input} 返回当前实例以支持链式调用 */ setHoverEnabled(enabled?: boolean): this; /** * 设置是否阻止触摸输入。 * @param {boolean} prevent - 是否阻止触摸输入 * @returns {Input} 返回当前实例以支持链式调用 */ setPreventTouchInput(prevent?: boolean): this; /** * 设置是否消耗事件。 * @param {boolean} consume - 是否消耗事件 * @returns {Input} 返回当前实例以支持链式调用 */ setConsumeEvent(consume?: boolean): this; /** * 设置是否消耗悬停事件。 * @param {boolean} consume - 是否消耗悬停事件 * @returns {Input} 返回当前实例以支持链式调用 */ setConsumeHoverEvents(consume?: boolean): this; /** * 设置手势跟踪按钮。 * @param {string} button - 手势跟踪按钮 * @returns {Input} 返回当前实例以支持链式调用 */ setGestureTrackingButton(button: string): this; } /** * Sound 类 * * 该类表示一个声音控件,用于管理声音播放及其相关属性。 * * 属性: * - sound_name: string - 声音名称(定义在 RP/sounds/sound_definitions.json 文件中) * - sound_volume: float - 声音音量(默认值:1.0) * - sound_pitch: float - 声音音调(默认值:1.0) * - sounds: Array of sound objects - 触发事件时播放的声音数组 */ declare class Sound { [key: string]: unknown; sound_name: string; sound_volume: number; sound_pitch: number; sounds: JsonUIBag[]; /** * 设置声音名称。 * @param {string} name - 声音名称(定义在 RP/sounds/sound_definitions.json 文件中) * @returns {Sound} 返回当前实例以支持链式调用 */ setSoundName(name: string): this; /** * 设置声音音量。 * @param {number} volume - 音量(范围:0.0 到 1.0,默认值:1.0) * @returns {Sound} 返回当前实例以支持链式调用 */ setSoundVolume(volume?: number): this; /** * 设置声音音调。 * @param {number} pitch - 音调(默认值:1.0) * @returns {Sound} 返回当前实例以支持链式调用 */ setSoundPitch(pitch?: number): this; /** * 设置触发事件时播放的声音数组。 * @param {JsonUIBag[]} sounds - 声音对象数组 * @returns {Sound} 返回当前实例以支持链式调用 */ setSounds(sounds: JsonUIBag[]): this; /** * 添加一个声音对象到声音数组。 * @param {JsonUIBag} sound - 声音对象 * @returns {Sound} 返回当前实例以支持链式调用 */ addSound(sound: JsonUIBag): this; } /** * Button Property Name Type Default Value Description default_control string Name of the child control that will be displayed only in the default state hover_control string Name of the child control that will be displayed only in the hover state pressed_control string Name of the child control that will be displayed only in the pressed state locked_control string Name of the child control that will be displayed only in the locked state */ declare class Button extends UIElement { input: Input; sound: Sound; factory: Factory; constructor(id: string, template?: string); setDefaultControl(default_control: string): this; setHoverControl(hover_control: string): this; setPressedControl(pressed_control: string): this; setLockedControl(locked_control: string): this; setInput(input: Input): this; setSound(sound: Sound): this; setLayout(layout: Layout): this; protected serializableSources(): object[]; } declare class CollectionPanel extends UIElement { factory: Factory; constructor(id: string, template?: string); setCollectionName(collection_name: string): this; setLayout(layout: Layout): this; protected serializableSources(): object[]; } /** * Grid 类 * * 该类表示一个网格控件属性,用于管理网格布局及其相关属性。 * * 属性: * - grid_dimensions: Vector [columns, rows] - 网格的列数和行数 * - maximum_grid_items: int - 网格生成的最大项目数 * - grid_dimension_binding: string - 网格尺寸的绑定名称 * - grid_rescaling_type: enum - 网格重新缩放方向(可能值:vertical, horizontal, none,默认值:none) * - grid_fill_direction: enum - 网格填充方向(可能值:vertical, horizontal, none,默认值:none) * - grid_item_template: string - 处理集合的子元素名称(例如:"common.container_item") * - precached_grid_item_count: int - 预缓存的网格项目数量 */ declare class GridProp { [key: string]: unknown; grid_dimensions: [number, number]; maximum_grid_items: number; grid_dimension_binding: string; grid_rescaling_type: 'vertical' | 'horizontal' | 'none'; grid_fill_direction: 'vertical' | 'horizontal' | 'none'; grid_item_template: string; precached_grid_item_count: number; /** * 设置网格的列数和行数。 * @param {[number, number]} dimensions - 格式为 [columns, rows] * @returns {GridProp} 返回当前实例以支持链式调用 */ setGridDimensions(dimensions: [number, number]): this; /** * 设置网格生成的最大项目数。 * @param {number} maxItems - 最大项目数 * @returns {GridProp} 返回当前实例以支持链式调用 */ setMaximumGridItems(maxItems: number): this; /** * 设置网格尺寸的绑定名称。 * @param {string} binding - 绑定名称 * @returns {GridProp} 返回当前实例以支持链式调用 */ setGridDimensionBinding(binding: string): this; /** * 设置网格重新缩放方向。 * @param {'vertical' | 'horizontal' | 'none'} type - 可能值:vertical, horizontal, none(默认值:none) * @returns {GridProp} 返回当前实例以支持链式调用 */ setGridRescalingType(type?: 'vertical' | 'horizontal' | 'none'): this; /** * 设置网格填充方向。 * @param {'vertical' | 'horizontal' | 'none'} direction - 可能值:vertical, horizontal, none(默认值:none) * @returns {GridProp} 返回当前实例以支持链式调用 */ setGridFillDirection(direction?: 'vertical' | 'horizontal' | 'none'): this; /** * 设置处理集合的子元素名称。 * @param {string} template - 元素名称(例如:"common.container_item") * @returns {GridProp} 返回当前实例以支持链式调用 */ setGridItemTemplate(template: string): this; /** * 设置预缓存的网格项目数量。 * @param {number} count - 预缓存数量 * @returns {GridProp} 返回当前实例以支持链式调用 */ setPrecachedGridItemCount(count: number): this; } declare class Grid extends CollectionPanel { gridNum: number; grid: GridProp; constructor(id: string, template?: string); setGridProp(grid_prop: GridProp): this; addGridItem(grid_position: Offset2$1, content: UIElement | JsonUIBag, name?: string, debugColor?: [number, number, number, number]): this; protected serializableSources(): object[]; serialize(): SerializedElement; } /** * ScrollView 类 * * 该类表示一个滚动视图控件,用于管理滚动行为及其相关属性。 * * 属性: * - scrollbar_track_button: string - 滚动条轨道按钮的 ID * - scrollbar_touch_button: string - 滚动条触摸按钮的 ID * - scroll_speed: number - 滚动速度 * - gesture_control_enabled: boolean - 是否启用手势控制 * - always_handle_scrolling: boolean - 是否始终处理滚动 * - touch_mode: boolean - 是否启用触摸模式 * - scrollbar_box: string - 滚动条滑块子元素的名称 * - scrollbar_track: string - 滚动条轨道子元素的名称 * - scroll_view_port: string - 视口子元素的名称 * - scroll_content: string - 内容根父元素的名称 * - scroll_box_and_track_panel: string - 包含滚动条滑块和轨道的子元素名称 * - jump_to_bottom_on_update: boolean - 是否在更新时跳转到底部 */ declare class ScrollView { [key: string]: unknown; scrollbar_track_button: string; scrollbar_touch_button: string; scroll_speed: number; gesture_control_enabled: boolean; always_handle_scrolling: boolean; touch_mode: boolean; scrollbar_box: string; scrollbar_track: string; scroll_view_port: string; scroll_content: string; scroll_box_and_track_panel: string; jump_to_bottom_on_update: boolean; /** * 设置滚动条轨道按钮的 ID。 * @param {string} buttonId - 滚动条轨道按钮的 ID * @returns {ScrollView} 返回当前实例以支持链式调用 */ setScrollbarTrackButton(buttonId: string): this; /** * 设置滚动条触摸按钮的 ID。 * @param {string} buttonId - 滚动条触摸按钮的 ID * @returns {ScrollView} 返回当前实例以支持链式调用 */ setScrollbarTouchButton(buttonId: string): this; /** * 设置滚动速度。 * @param {number} speed - 滚动速度 * @returns {ScrollView} 返回当前实例以支持链式调用 */ setScrollSpeed(speed: number): this; /** * 设置是否启用手势控制。 * @param {boolean} enabled - 是否启用手势控制(默认值:false) * @returns {ScrollView} 返回当前实例以支持链式调用 */ setGestureControlEnabled(enabled?: boolean): this; /** * 设置是否始终处理滚动。 * @param {boolean} alwaysHandle - 是否始终处理滚动(默认值:false) * @returns {ScrollView} 返回当前实例以支持链式调用 */ setAlwaysHandleScrolling(alwaysHandle?: boolean): this; /** * 设置是否启用触摸模式。 * @param {boolean} touchMode - 是否启用触摸模式(默认值:false) * @returns {ScrollView} 返回当前实例以支持链式调用 */ setTouchMode(touchMode?: boolean): this; /** * 设置滚动条滑块子元素的名称。 * @param {string} boxName - 滚动条滑块子元素的名称 * @returns {ScrollView} 返回当前实例以支持链式调用 */ setScrollbarBox(boxName: string): this; /** * 设置滚动条轨道子元素的名称。 * @param {string} trackName - 滚动条轨道子元素的名称 * @returns {ScrollView} 返回当前实例以支持链式调用 */ setScrollbarTrack(trackName: string): this; /** * 设置视口子元素的名称。 * @param {string} viewPortName - 视口子元素的名称 * @returns {ScrollView} 返回当前实例以支持链式调用 */ setScrollViewPort(viewPortName: string): this; /** * 设置内容根父元素的名称。 * @param {string} contentName - 内容根父元素的名称 * @returns {ScrollView} 返回当前实例以支持链式调用 */ setScrollContent(contentName: string): this; /** * 设置包含滚动条滑块和轨道的子元素名称。 * @param {string} panelName - 包含滚动条滑块和轨道的子元素名称 * @returns {ScrollView} 返回当前实例以支持链式调用 */ setScrollBoxAndTrackPanel(panelName: string): this; /** * 设置是否在更新时跳转到底部。 * @param {boolean} jump - 是否在更新时跳转到底部(默认值:false) * @returns {ScrollView} 返回当前实例以支持链式调用 */ setJumpToBottomOnUpdate(jump?: boolean): this; } declare class ScrollingPanel extends UIElement { input: Input; scrollView: ScrollView; factory: Factory; constructor(id: string, template?: string); protected serializableSources(): object[]; } declare class StackPanel extends Panel { orientation: string; stackNum: number; constructor(id: string, template?: string); addStack(size: Size2$1 | string, content: UIElement | JsonUIBag, debug?: boolean): this; /** * Possible values: vertical horizontal * @param {string} orientation */ setOrientation(orientation: string): this; serialize(): SerializedElement; } declare namespace HudUISystem { /** * 获取HUD UI系统实例 * @returns The HUD UI System instance */ function getInstance(): UISystem; function registerElement(element: UIElement): void; function mountRootElement(element: UIElement): void; } declare class HudStatePanel { name: string; private root_panel; private ui_id; constructor(name: string); addStateControl(state: string | number, control: UIElement): this; getPanel(): Panel; } declare class ChestUISystem { static chest_screen: UISystem; static registerContainerUI(new_container_title: string, ui_system_root_panel: string): void; } /** * 容器槽位的版面换算 —— 纯函数模块。 * * 只做三件事:槽号 ↔ `grid_position`、像素坐标 ↔ 格位 `offset`、槽位声明校验。 * **零 import**,因此 Node 里可直接加载、可离线单测(不依赖 UI 元素类与构建管道)。 * * 坐标系约定:`pos` / `gridOrigin` 都是**面板左上角为原点**的像素坐标(`top_left` 锚)。 */ type Offset2 = [number, number]; type Size2 = [number | string, number | string]; /** * 槽位语义:`input` 不写标志位;`output` / `display` 写 `enabled: false`。 * * ⚠️ 这只是**缺省值**:声明里显式给了 `enabled` 时一律以显式值为准(见 `SlotSpec.enabled`)。 */ type SlotKind = 'input' | 'output' | 'display'; /** 声明的槽位语义全集(用于校验与遍历) */ declare const SLOT_KINDS: readonly SlotKind[]; /** * 该槽位语义的**缺省**门控值:`output` / `display` → `false`(`input` → 不写该键)。 * * 它只在调用方**没有**显式给 `enabled` 时生效 —— 显式值永远优先(`resolveSlot`)。 */ declare function isGatedKind(kind: SlotKind): boolean; /** 格位尺寸:单数字 = 正方形边长;二元组 = [宽, 高] */ type CellSizeInput = number | Offset2; /** 九宫格切分:单数字或 [x0, y0, x1, y1] */ type NineSlice = number | [number, number, number, number]; /** 格位背景:纹理路径,或带九宫格切分的纹理描述 */ type SlotBackground = string | { texture: string; nineslice_size?: NineSlice; }; /** 内层格位控件的锚点(与 `SLOT_CALIBRATION.anchor` 同步) */ type SlotAnchor = 'top_left' | 'center'; /** 原版 `common.container_item` 可覆盖变量子集 */ interface ItemRendererSpec { /** `$item_renderer`:渲染器控件引用 */ ref?: string; /** `$item_renderer_size` */ size?: Offset2; /** `$item_renderer_offset` */ offset?: Offset2; /** `$item_renderer_panel_size` */ panelSize?: Offset2; } /** 槽位声明(`addSlot` 的入参;旧接口路径可用 `gridPosition` / `offset` 直传) */ interface SlotSpec { /** 容器槽位号(与 `gridPosition` 二选一;两者都给时以 `gridPosition` 为准) */ slot?: number; /** 面板内像素坐标(`top_left` 锚);与 `offset` 二选一(都给时以 `offset` 为准) */ pos?: Offset2; /** 显式网格位置 `[列, 行]`(旧接口路径;给了就不再由 `slot` 换算) */ gridPosition?: Offset2; /** 显式偏移(旧接口路径;给了就不再由 `pos` 换算) */ offset?: Offset2; /** 槽位语义,默认 `input` */ kind?: SlotKind; /** * 该槽的**视觉**格位尺寸(默认取标定表)。 * * 只影响内层控件的 `$cell_image_size` / `size`,**不参与**基座与网格尺寸换算 —— * 网格几何一律由 `setSlotDefaults({ cellSize })`(或标定表)决定;比格位大的视觉尺寸 * 会从格位左上角向外溢出(原版槽位模板允许,用于画长条进度槽之类)。 */ cellSize?: CellSizeInput; /** 内层控件尺寸(不给则等于 `cellSize`) */ size?: Size2; /** * 显式写进内层控件的 `enabled` 值。**给了就以此为准**,覆盖 `kind` 的缺省门控。 * * 缺省行为:`input` 不写该键(继承原版默认 `true`)、`output` / `display` 写 `false`。 * 传 `true` 可让被门控的槽位恢复交互(例如「产物要能取出来」的输出槽)。 */ enabled?: boolean; /** 格位背景纹理(框架据此生成背景 image 控件) */ background?: SlotBackground; /** `$background_images`:直接指定已有的背景控件引用 */ backgroundImages?: string; /** 原版 item renderer 变量覆盖 */ itemRenderer?: ItemRendererSpec; /** 其余原版可覆盖变量,键名不带 `$` 与 `|default` 后缀 */ vars?: Record; } /** 槽位默认值(`setSlotDefaults` 的入参:除 `slot` / `pos` / `gridPosition` / `offset` 外均可) */ type SlotDefaults = Omit; /** 标定表 */ interface SlotCalibration { anchor: SlotAnchor; originPadding: Offset2; cellSize: Offset2; columns: number; /** 未调用 `setGridOrigin` 时网格的默认原点(给顶部标题留高度) */ defaultGridOrigin: Offset2; } /** * ★ 待真机校准项 —— 整套「格位基座」假设集中在此,校准只需改这一个对象。 * * 假设:格位基座 = 网格原点 + 该格在网格里的序号 × **网格统一格位尺寸**,且格位锚点在左上角。 * 真机实测若证明锚点其实在格位中心(offset 整体差半格),把 `anchor` 改成 `'center'` * 即可同时翻转换算与写进产物的 `anchor_from` / `anchor_to`,不必改调用方。 */ declare const SLOT_CALIBRATION: Readonly; /** 换算参数 */ interface CellLayoutOptions { /** 网格在面板内的原点(`top_left` 锚,像素) */ gridOrigin?: Offset2; /** 槽号所在网格的列数(默认取标定表) */ columns?: number; /** * **网格统一格位尺寸**(几何):整张网格的格位尺寸,同一网格内只有这一个值 * (来自 `setSlotDefaults({ cellSize })` 或标定表)。 * * 逐槽声明的 `cellSize` **不参与**基座换算,它只决定内层控件的视觉尺寸(可溢出格位)。 * 传入逐槽尺寸会让偏移与网格尺寸互相矛盾。 */ gridCellSize?: CellSizeInput; /** 标定表覆盖(默认 `SLOT_CALIBRATION`) */ calibration?: SlotCalibration; } /** 解析标定表:缺省字段回落 `SLOT_CALIBRATION` */ declare function resolveCalibration(calibration?: Partial): SlotCalibration; /** 把 `number | [宽, 高]` 归一成 `[宽, 高]`;非法输入回落 `fallback` */ declare function normalizeCellSize(size: CellSizeInput | undefined, fallback?: Offset2): Offset2; /** * 槽号 → 网格位置 `[列, 行]`(行优先)。 * @param slot 容器槽位号,须为非负整数 * @param columns 网格列数,默认取标定表(1 = 单列) */ declare function slotToGridPosition(slot: number, columns?: number): Offset2; /** 一组网格位置 → `grid_dimensions` `[列, 行]`(至少 `[1, 1]`) */ declare function gridDimensionsFor(positions: Offset2[]): Offset2; /** * 单个格位的基座坐标(面板像素)。 * * 这是「网格原点 + 序号 × 网格统一格位尺寸」假设的**唯一落点**;锚点由标定表的 `anchor` 决定 * (`top_left` 时基座即格位左上角,`center` 时再加半个格位)。 * * ⚠️ 格位尺寸取 `options.gridCellSize`(整张网格一个值);**不要**传某个槽自己的视觉尺寸 —— * 引擎的网格格位是均匀的,逐槽尺寸只会让偏移与网格尺寸互相矛盾。 */ declare function cellBase(slot: number, options?: CellLayoutOptions): Offset2; /** * 像素坐标 → 格位 `offset`(相对格位基座)。 * @param pos 目标位置(面板左上角为原点的像素坐标) * @param slot 容器槽位号 */ declare function posToOffset(pos: Offset2, slot: number, options?: CellLayoutOptions): Offset2; /** 与标定表同步的锚点属性(写进内层格位控件) */ declare function anchorProps(calibration?: Partial): { anchor_from: SlotAnchor; anchor_to: SlotAnchor; }; /** 归一化背景描述:字符串 → `{ texture }`;非法输入 → `undefined` */ declare function normalizeBackground(background: SlotBackground | undefined): { texture: string; nineslice_size?: NineSlice; } | undefined; /** * 校验一条槽位声明。 * @returns 警告文案数组(空数组 = 通过);**任何输入都不会抛错** */ declare function validateSlotSpec(spec: SlotSpec | undefined, context?: { existingSlots?: number[]; }): string[]; /** 门控键(同时会用作 `ui/.json` 的文件名)允许的字符 */ declare const UI_NAME_PATTERN: RegExp; /** 门控键是否可安全用作 UI 文件名 */ declare function isSafeUIName(name: unknown): boolean; /** * 校验门控键 / UI 文件名。 * @returns 不合规时的说明文案;合规返回 `undefined` */ declare function checkUIName(name: unknown): string | undefined; /** 已解析的槽位:默认值已合并、`grid_position` 与 `offset` 已换算完毕 */ interface ResolvedSlot { slot: number; kind: SlotKind; /** 写进产物的 `grid_position` `[列, 行]` */ gridPosition: Offset2; /** 面板像素坐标(显式 `gridPosition` 路径下为格位基座) */ pos: Offset2; /** 写进产物的 `offset` */ offset: Offset2; /** 该槽的**视觉**格位尺寸(网格几何由 `setSlotDefaults` 决定,见 `CellLayoutOptions.gridCellSize`) */ cellSize: Offset2; /** 调用方是否显式声明了 `cellSize`(决定是否写出 `$cell_image_size` / `size`) */ cellSizeDeclared: boolean; /** 写进 `enabled` 的值;`undefined` = 不写该键 */ enabled: boolean | undefined; /** 是否由 `pos` 换算得到 offset(是则同时写锚点,保证换算前提成立) */ derived: boolean; background?: { texture: string; nineslice_size?: NineSlice; }; backgroundImages?: string; size?: Size2; itemRenderer?: ItemRendererSpec; vars: Record; } /** * 把一条槽位声明解析成可写进产物的槽位记录(合并默认值 + 换算 `grid_position` / `offset`)。 * * `gridPosition` / `offset` 任一显式给出时走旧接口路径:该维度原样使用,不参与换算。 */ declare function resolveSlot(spec: SlotSpec, options?: CellLayoutOptions & { defaults?: SlotDefaults; }): ResolvedSlot; type Any = any; /** 旧式格位声明(`addGridItem` / `addInputGrid` / `addOutputGrid` 的 options) */ interface LegacyGridItemOptions { /** @deprecated 用 `enabled`;JSON UI 的属性名是 `enabled` 不是 `enable` */ enable?: boolean; /** 是否写 `enabled`;给了就覆盖 `kind` 的缺省门控,不给则只有 `output` / `display` 写 `false` */ enabled?: boolean; /** 内层控件尺寸 */ size?: Any; /** `$background_images` 背景控件引用 */ background_images?: Any; } /** `setPanel` 的入参 */ interface PanelOptions { /** 根面板尺寸(像素) */ size?: Size2; /** 面板背景纹理 */ background?: SlotBackground; } /** 进度指示图的裁切方向:露出的是**该侧**的比例那一段(`'left'` = 从左往右填) */ type ProgressClipDirection = 'left' | 'right' | 'up' | 'down' | 'center'; /** `addProgressSlot` 的入参 */ interface ProgressSlotOptions { /** 容器槽位号 */ slot: number; /** 面板内像素坐标(左上角原点),与 `addSlot` 同义 */ pos: Offset2; /** 按比例裁开的填充图(纹理路径),例如 `textures/ui/arrow_active` */ fill: string; /** 垫在下面的静止底图(可选);给了的话即使裁切没生效也还看得见轮廓 */ base?: string; /** 视觉尺寸(像素),默认 `[22, 15]`(原版熔炉箭头尺寸) */ size?: Offset2; /** 裁切方向,默认 `'left'`;从下往上烧的火焰用 `'down'` */ clipDirection?: ProgressClipDirection; /** * 贴图是否**保持纵横比**,默认 `false`(= 按 `size` 拉伸铺满)。 * * 默认拉伸,是因为这个槽的契约就是「这块就是 `size` 像素」;原版箭头的贴图恰与尺寸同比例, * 两者无差别。**贴图与 `size` 比例不同时**(例如把一根竖长条压进矮格子)必须显式决定: * `false` = 拉伸变形;`true` = 按比例缩放(会留边,实际宽度不再是 `size`)。 */ keepRatio?: boolean; /** 比例来源的集合名,默认 `"container_items"`(小箱子与大箱子都是它) */ collection?: string; /** 额外写进槽位的原版变量(可覆盖内置的两条) */ vars?: Record; } /** * 自定义容器 UI 系统:把「容器槽位」声明成面板内的像素版面。 * * 坐标系为面板左上角原点的像素坐标(`top_left` 锚);`grid_position` 与格位基座的换算见 * `containerLayout.ts`(其中 `SLOT_CALIBRATION` 是唯一的待真机校准点)。 * 面板背景与已声明槽位在每次修改后整体重建,故可自由链式调用。 */ declare class ContainerUISystem { #private; system: UISystem; title: string; root_panel_size: [number, number]; gridDimension: [number, number]; /** 输出槽记录(`setOutputSlots` 写入);不参与版面,版面由槽位声明的 `kind` 决定 */ outputSlots: number[][]; main_panel: Panel; grids: Grid; constructor(identifier: string, path: string); /** * 设置面板尺寸与背景图。 * @param {PanelOptions} [options] - `size` 为像素尺寸;`background` 为纹理路径或 `{ texture, nineslice_size? }` * @returns {ContainerUISystem} 返回当前实例以支持链式调用 */ setPanel(options?: PanelOptions): this; /** * 设置网格在面板内的原点(未调用时取标定表的默认原点,已为顶部标题让开一行)。 * @param {Offset2} origin - 像素坐标 [x, y] * @returns {ContainerUISystem} 返回当前实例以支持链式调用 */ setGridOrigin(origin: Offset2): this; /** * 合并槽位默认值(对之后声明的每个槽生效)。 * * ★ `cellSize` 是**整张网格的统一格位尺寸(几何)**:基座换算与网格尺寸都用它。 * 逐槽声明 `addSlot({ cellSize })` 只改该格的视觉尺寸(可溢出格位),不参与几何。 * @param {SlotDefaults} defaults - 除 `slot` / `pos` / `gridPosition` / `offset` 外的槽位字段 * @returns {ContainerUISystem} 返回当前实例以支持链式调用 */ setSlotDefaults(defaults?: SlotDefaults): this; /** * 声明一个容器槽位:`slot` 定槽号、`pos` 定面板内像素位置,框架负责换算 `grid_position` 与 `offset`。 * * `kind` 为 `output` / `display` 时写 `enabled: false`;`input`(默认)不写该键。 * 显式传 `enabled` 则一律以它为准(`{ kind: 'output', enabled: true }` = 产物格可交互)。 * 声明不合规时只 `console.warn`,不抛错。 * @param {SlotSpec} spec - 槽位声明 * @returns {ContainerUISystem} 返回当前实例以支持链式调用 */ addSlot(spec: SlotSpec): this; /** * 向主面板中添加一个控件。 * @param {UIElement | Any} element - 控件(UIElement 实例或原生 JSON UI 控件对象) * @param {Offset2} [pos] - 面板内像素坐标 [x, y];给了就按 `top_left` 锚定位 * @returns {ContainerUISystem} 返回当前实例以支持链式调用 */ addControl(element: UIElement | Any, pos?: Offset2): this; /** * 向主面板中添加一个控件(`addControl` 的别名)。 * @param {UIElement | Any} element - 控件 * @returns {ContainerUISystem} 返回当前实例以支持链式调用 */ addElementToMain(element: UIElement | Any): this; /** * 声明一个「进度指示槽」:`base` 垫底、`fill` 按 `clipDirection` 裁开,比例取**本格物品的耐久**。 * * 与 `addSlot` 的区别:除了声明槽位,还会生成一个自定控件、经 `$cell_overlay_ref` * 注入到格子内部(`common.container_item` 的 `item_cell`)。它在格内, * 所以保留每格的 collection 上下文,读的是**本格自己**的绑定 —— 每格可以各显示各的进度。 * * 典型用法:脚本往该槽写一个可损耗物品、让「剩余耐久 = 进度」 * (见 `examples/mob_chest/scripts/progress_bar.js`),即可用原版箭头/火焰贴图画出进度, * **不需要任何进度条贴图**。 * * 同时会关掉引擎自带的耐久条(`$durability_bar_required`)并把格子的浅灰底换成零尺寸面板 * (`$background_images`),否则会看到「灰方块 + 图」。`vars` 可覆盖这两条内置变量。 * @param {ProgressSlotOptions} options 槽位声明 * @returns {ContainerUISystem} 返回当前实例以支持链式调用 */ addProgressSlot(options: ProgressSlotOptions): this; /** * 旧式网格项:直接给 `grid_position` 与 `offset`,不做坐标换算。 * @param {Offset2} grid_position - 网格位置 [列, 行] * @param {Offset2} offset - 内层控件的偏移 [x, y] * @param {LegacyGridItemOptions} [options] - 可选覆盖 * @returns {ContainerUISystem} 返回当前实例以支持链式调用 */ addGridItem(grid_position: Offset2, offset: Offset2, options?: LegacyGridItemOptions): this; /** * 旧式输入槽(等价 `addGridItem`)。 * @param {Offset2} grid_position - 网格位置 [列, 行] * @param {Offset2} offset - 内层控件的偏移 [x, y] * @param {LegacyGridItemOptions} [options] - 可选覆盖 */ addInputGrid(grid_position: Offset2, offset: Offset2, options?: LegacyGridItemOptions): void; /** * 旧式输出槽:在该格位内层控件上写 `enabled: false`。 * * ⚠️ 该标志位**整体禁用这一格**(既放不进、也取不出)⇒ 需要能取出产物的输出槽 * 请用 `addSlot({ kind: 'output', enabled: true })`。 * @param {Offset2} grid_position - 网格位置 [列, 行] * @param {Offset2} offset - 内层控件的偏移 [x, y] * @param {LegacyGridItemOptions} [options] - 可选覆盖(本方法不转发 `enabled` ⇒ 恒为 `false`) */ addOutputGrid(grid_position: Offset2, offset: Offset2, options?: LegacyGridItemOptions): void; /** * 记录输出槽数组(供上层读取);不改变已声明槽位的版面与语义。 * @param {number[][]} output_arr - 输出槽记录 */ setOutputSlots(output_arr: number[][]): void; /** * @deprecated 名字写反了(它存的是输出槽),改用 `setOutputSlots` * @param {number[][]} output_arr - 输出槽记录 */ setInputGrid(output_arr: number[][]): void; /** * 设置网格的行列数(显式覆盖;不调用则按已声明槽位自动推导)。 * @param {number[]} dimension - 网格维度 [列数, 行数] * @returns {ContainerUISystem} 返回当前实例以支持链式调用 */ setGridDimension(dimension: number[]): this; /** * 设置容器的标题。 * @param {string} title - 容器的标题 * @returns {ContainerUISystem} 返回当前实例以支持链式调用 */ setTitle(title: string): this; /** * 设置根面板的尺寸。 * @param {number[]} size - 根面板的尺寸 [宽度, 高度](像素) * @returns {ContainerUISystem} 返回当前实例以支持链式调用 */ setSize(size: number[]): this; } /** * sapdon_ui: 页面壳路由系统(生成 server_form.json) * * 采用 Bedrock Wiki「Modifying Server Forms — Action Form」官方路由: * main_screen_content ─(modification: insert_back controls)→ sapdon_form_factory * └─ factory { name: server_form_factory, control_ids.long_form } → @server_form.sapdon_long_form_panel * └─ (modifications insert_back) 所有注册页 Panel($panel_id 前缀门控) * └─ content@$user_content_panel (下) + buttons@$user_buttons_panel (上) * vanilla long_form ─(modification: bindings)→ title 含 'sapdon_ui:' 时隐藏原生表单 * * 关键收益:自定义页处于 main_screen_content 作用域 → #form_text / #title_text 均可解析。 */ interface SapdonPageRegistration { panelId: string; contentPanel: UIElement | string; buttonsPanel?: UIElement | string; /** 页面控件名(默认 pageN) */ name?: string; } declare class SapdonServerUI { static readonly MARKER = "sapdon_ui:"; static readonly NS = "server_form"; private static _system; private static _factories; private static _pageCount; private static _ensureBuilt; /** 页面根壳:在页面自己的 UISystem 里生成 元素(门控 + content/buttons 子控件 + 变量),供工厂 long_form 引用 */ static createPageRoot(reg: { name: string; panelId: string; contentRef: string; buttonsRef: string; }): UIElement; /** 注册一个自定义页面:向 main_screen_content 追加一个纯 gated factory(long_form → @<页ns>.),门控在页面根 */ static registerPage(reg: SapdonPageRegistration): void; static getSystem(): UISystem | null; } /** * SapdonPanel:一个自定义页面 = 一个 UI 文件(text_ui_xxx.json) * 由「内容面板 + 按键面板」两个元素组成。 */ declare class SapdonPanel { private system; constructor(namespace: string); /** 设置内容面板元素 */ setContent(content: UIElement): this; /** 设置按键面板元素 */ setButtons(buttons: UIElement): this; build(): UISystem; } /** * FormButton:服务端表单按钮(纯样式)。 * 只管长什么样(三态纹理 / 尺寸 / 锚点 / 门控键),不含几何与绑定。 * 必须 addButton 进 FormButtonGrid 才被注入集合/门控绑定并定位生效。 */ declare class FormButton extends Button { constructor(id: string); /** 三态纹理 default/hover/pressed */ setTexture(defaultTex: string, hoverTex: string, pressedTex: string): this; /** 尺寸(原地改,保留锚点/offset) */ setSize(w: number | string, h: number | string): this; /** 锚点对齐(原地改,导航贴角用) */ setAnchor(anchor: string): this; /** 门控键:仅当运行时 emit 的 #form_button_text 等于该键时可见(绑定由 Grid 注入) */ setBinding(key: string): this; } /** * FormButtonGrid:按键格盘(几何 + 激活)。 * 内部一个 Grid(collection: form_buttons),把面板按 dimensions 分格; * addButton 时按 index 派生基准格 base 并注入 FormButton 的三组绑定。 */ declare class FormButtonGrid { private grid; private cols; private rows; private index; private debug; private static readonly RED; constructor(id: string, options: { dimensions: [number, number]; size: [number | string, number | string]; }); /** 给每个格子描红调试框 */ enableDebug(): this; /** * 加一枚内容。 * * ⚠️ index 必须是该按钮在**运行期 form 里的槽位序号**(不是视觉序号): * index 被编码成 grid_position(col = index%c, row = index/c),而 Bedrock 的集合格盘 * 正是靠 grid_position(行优先序号)**把格子绑到对应的 form 按钮**; * 按钮最终落在哪一格由第二个参数 pos 决定(offset = -基准格 + pos)。 * 例:表单前 3 个槽被 prev/home/next 占用时,第 i 张卡要写 addButton(3 + i, card, [i, 0]); * 若误传视觉序号(0/1/2…),卡片会绑到 no_prev/no_home/no_next 等占位槽, * 门控 `($binding_button_text = #form_button_text)` 不成立 → 卡片整片不显示。 * * 仅 FormButton 注入集合/门控绑定。 */ addButton(index: number, btn: FormButton | UIElement, pos?: [number, number]): this; /** 注入 FormButton 的集合/门控绑定(离开 Grid 则无效) */ private injectBindings; build(): UIElement; } /** * @deprecated 图标/纹理按钮请改用 FormButton(@common.button + 三态纹理 + 门控绑定)。 * 本类仅为兼容 NeoGuidebook 保留;后续随 guidebook 迁移一并移除。 */ declare class SapdonTexturedButton extends UIElement { constructor(id: string, bindingButtonName?: string); setDefaultTexture(texture: string): this; setHoverTexture(texture: string): this; setPressedTexture(texture: string): this; /** 设置锚点对齐 */ setAnchor(anchor: string, size?: [number | string, number | string]): this; } /** * SapdonGuideBook —— 帕秋莉式手册(分类索引 INDEX + 词条列表 CAT + 内容页 ENT + home/prev/next 导航)。 * * 线协议(运行时发射): * body = "INDEX" → 索引页 p0(左封面 + 右半页 ≤16 张分类卡) * body = "IDX|p" → 索引页 p1+(左右半页各 ≤8 张卡,先填左列再填右列) * body = "CAT:|p" → 分类页(p0 左简介/右 list,p1+ 左右 list) * body = "ENT::|p" → 词条内容页(按 pageType 渲染、可分页) * title = "sapdon_ui:" * button(...) → 集合 form_buttons:分类按钮 idx or 导航,均 exact-match 门控 * * 索引页(INDEX)分页规则: * 每页最多 IDX_PER_PAGE(16) 张分类卡;p0 用右半页(4 列 × ≤4 行 = ≤16), * p1+ 左右半页各一列(4 列 × ≤2 行 = ≤8/列),**先填左列再填右列**; * 卡片绑定名 = 分类在 build() 入参里的全局序号(idx0..idxN),跨页唯一。 * 分类 ≤16 时只有 p0,body 仍是历史上的 "INDEX"(旧脚本无需改动)。 * * ⚠️ p1+ 的 body 用 "IDX|p" 而非 "INDEX|p":门控是「包含」匹配(见 gateLayout), * "INDEX|p1" 会同时命中 p0 的 "INDEX",让封面与 p0 卡格一起亮起来; * "IDX|p1" 不含 "INDEX" 子串,两页互斥。 */ type GuideBookPageType = 'text' | 'crafting' | 'spotlight' | 'image'; /** * 手册里由框架渲染的固定标签(i18n 接入点)。 * * ⚠️ 框架**不做任何 lang 键解析**:这里拿到什么字符串就原样交给 `Text.setText`, * JSON UI 自己会解析 `fz.gb.ui.chapter` 这类键。所以传 lang 键的项目**必须** * 在 `RP/texts/*.lang` 里定义该键,否则界面显示裸键名。 * ⚠️ 默认值 = 历史上的中文字面量,**故意保持现状**:不传 labels 的项目产物逐字节不变 * (回归基线见 AGENTS.md / doc/guidebook.md:guidebook_demo 的 book.json 587870 字节)。 */ interface GuideBookLabels { /** CAT 页章节列表的标题 */ chapter: string; /** INDEX 页索引卡列的标题 */ category: string; } /** 手册固定标签的默认值(= 历史字面量,改它会让所有既有项目产物变化) */ declare const DEFAULT_GUIDE_BOOK_LABELS: GuideBookLabels; interface GuideBookOptions { /** 覆盖框架渲染的固定标签(只传要改的键,其余走默认值) */ labels?: Partial; } interface GuideBookChapter { name: string; icon: string; /** 词条正文(多行,ENT 页逐行渲染;text 类型按 5 行/半页分页) */ lines: string[]; /** 页类型(默认 text) */ pageType?: GuideBookPageType; /** crafting:3×3 合成格(9 项,空位 '')+ 输出图标 */ craft?: { grid: string[]; output: string; }; /** spotlight:大图标 + 描述 */ spotlight?: { icon: string; desc: string; }; /** image:整页图 + 说明 */ image?: { texture: string; caption: string; }; } interface GuideBookCategory { /** 英文 id(路由用,如 intro / routing / controls / undecided) */ id: string; /** 中文标题(左页标题 / 索引卡名称) */ title: string; /** 分类图标(索引卡) */ icon: string; /** 简介正文(左页,多行,逐行渲染) */ introLines: string[]; /** 右页章节条目 */ chapters: GuideBookChapter[]; } declare class SapdonGuideBook { private system; private namespace; private name; private size; private background; private debug; /** 框架渲染的固定标签(i18n;默认值 = 历史中文字面量) */ private labels; private coverTitle; private coverLines; constructor(identifier: string, size?: [number, number], background?: string, options?: GuideBookOptions); enableDebug(): this; /** 自定义封面:标题(可含 \n)+ 简介行 */ setCover(title: string, lines: string[]): this; /** * 覆盖框架渲染的固定标签(章节 / 类别)。 * 只传要改的键,其余保持**当前值**(增量合并,可反复调用)—— * 传 lang 键如 'fz.gb.ui.chapter' 时由 JSON UI 自行解析。 */ setLabels(labels: Partial): this; /** 布局容器: 命中 #form_text(含 tag 即显示) */ private gateLayout; private navButton; private closeButton; /** NeoGuidebook 书页纸面:页脊 + 页边模板(左/右半页) */ private bookPagePane; /** 全幅纸页基底:横向 50/50 左右半页(crease+edge),layer 0 常显 */ private bookPageBase; /** 给游离 FormButton 注入集合/门控绑定(非 FormButtonGrid 场景,如章节条目行) */ private wireButton; /** 章节列表列(章节标题 + 分割线 + ≤8 行条目) */ private catListColumn; /** 介绍列(标题 + 分割线 + 简介逐行)——仅 p0 左页 */ private catIntroColumn; /** * CAT 页(L2):按词条数分页容器,门控 CAT:|p。 * p0:左=介绍,右=章节 list(≤8);p1+:左、右都是章节 list(容量 8+8=16,先填左列再右列)。 */ private catPages; /** ENT 词条内容页(L3):按 pageType 分派布局;text 按 5 行/半页分页;门控 ENT::|p */ private entPages; /** 一张索引卡:上图标、下名称(绑定名 = 分类全局序号 idx) */ private catCard; /** * 往 col 里挂一列索引卡:空 5% / 标题 10% / 分割线 3% / 卡格 rows 行 / 分割线 3% / 余量。 * 卡格 = 4 列 × rows 行的 FormButtonGrid,装 cards[start, end)(全局序号,先左后右逐行填)。 * ids 由调用方给定,便于 p0 沿用历史元素名(right_index / cat_row / sp_end …)。 * * ⚠️ slotBase = 本列第一张卡在运行期 form 里的**槽位序号**(INDEX 页固定 3:prev/home/next 占 0-2)。 * FormButtonGrid.addButton 的 index 会被编码成 grid_position,而 Bedrock 的集合格盘是靠 * grid_position(行优先序号)**把格子绑到对应的 form 按钮**上;视觉落点由第二个参数 pos 决定。 * 所以 index 必须是槽位序号(历史上就是 `3 + i`),写成 0/1/2… 会让卡片绑到 no_prev/no_home/ * no_next 等占位槽,门控 `($binding_button_text = #form_button_text)` 全部不成立 → 卡片整片消失。 */ private addIndexColumn; /** 索引卡分几页:p0 容量 16,p1+ 每页 16(左 8 + 右 8) */ private indexPageCount; build(categories: GuideBookCategory[]): this; getSystem(): UISystem; } declare class ItemTextureManager { static item_texture_sets: Map; static getItemTextureSet(): Map; static getItemTextures(): any; static registerTextureData(texture_name: any, texture_data: any): void; static registerTexture(texture_name: any, texture_path: any): void; static toObject(): any; } declare class TerrainTextureManager { static terrain_texture_sets: Map; static getTerrainTextureSet(): Map; static getTerrainTextures(): any; static registerTextureData(texture_name: any, texture_data: any): void; static registerTexture(texture_name: any, texture_path: any): void; static toObject(): any; } declare namespace FlipbookTextures { let flipbook_textures: never[]; function registerFlipbookTexture(atlas_tile: any, texture: any, ticks_per_frame: any, options?: {}): void; function toObject(): never[]; } declare function getMetadata(target: any): any; declare function getOrCreateMetadata(target: any): any; declare function mixin(target: T, ...source: S[]): R; declare class NonNullMap implements Map { private readonly empty; constructor(empty: () => V); clear(): void; delete(key: K): boolean; forEach(callbackfn: (value: V, key: K, map: Map) => void, thisArg?: any): void; get(key: K): V | undefined; set(key: K, value: V): this; has(key: K): boolean; get size(): number; entries(): MapIterator<[K, V]>; keys(): MapIterator; values(): MapIterator; [Symbol.iterator](): MapIterator<[K, V]>; get [Symbol.toStringTag](): string; private readonly map; } interface ISerializer { (instance: any): object; } declare function jsonEncoderReplacer(_: string, v: any): any; declare const defaultSerializer: ISerializer; declare function Serializable(serializer?: ISerializer): (_: any, ctx: DecoratorContext) => void; declare const Serializer: MethodDecorator; declare function serialize(inst: T): R; declare const jsonEncodeDecoder: EncodeDecoder; declare function encode(value: Base, encodeDecoder?: EncodeDecoder): Trans; declare function decode(value: Trans, encodeDecoder?: EncodeDecoder): Base; interface EncodeDecoder { encode: (data: Base) => Trans; decode: (chunk: Trans) => Base; } type ConstructorOf = new (...args: Args) => T; type FloatLiteral = `${number}.${number}`; interface RawType extends RawJSON { valueOf(): T; } declare const IS_RAW_SYMBOL: unique symbol; declare const f64: (literal: FloatLiteral) => { [IS_RAW_SYMBOL]: boolean; rawJSON: string; valueOf(): number; }; declare function isRawJSON(v: any): boolean; /** * Client */ declare class GRegistry { static debug: boolean; /** * 生成注册器 * @param {string} name 文件名字 * @param {string} root 根目录,如 "behavior"、"resource" 等 * @param {string} path 数据的路径,如 "blocks/"、"items/"、"recipes/" 等 * @param {object} data 数据操作类实例 通过toObject方法转成正确格式json文本 */ static register(name: string, root: string, path: string, data: object): void; static submit(): void; } declare namespace registry { function submit(): void; } export { AddonAnimationController, AddonAnimationStateMachine, AddonAttachable, AddonAttachableDefinition, AddonAttachableDescription, AddonBiome, AddonBiomeDefinition, AddonBiomeDescription, AddonBlock, AddonBlockDefinition, AddonBlockDescription, AddonClientEntity, AddonClientEntityDefinition, AddonClientEntityDescription, AddonEntity, AddonEntityDefinition, AddonEntityDescription, AddonFeatureRule, AddonFeatureRuleDecription, AddonFeatureRuleDenifition, AddonItem, AddonItemDefinition, AddonItemDescription, AddonManifest, AddonManifestDependency, AddonManifestHeader, AddonManifestMetadata, AddonManifestModule, AddonMenuCategory, AddonOreFeature, AddonOreFeatureDefinition, AddonOreFeatureDescription, AddonRecipe, AddonRecipeFurnace, AddonRecipeFurnace_1_12, AddonRecipeFurnace_1_17, AddonRecipeShaped, AddonRecipeShaped_1_12, AddonRecipeShaped_1_17, AddonRecipeShaped_1_19, AddonRecipeShaped_1_20, AddonRecipeShapeless, AddonRecipeShapeless_1_12, AddonRecipeShapeless_1_17, AddonRenderController, AddonRenderControllerGroup, AddonSemanticVersion, Armor, ArmorType, Attachable, BasicBlock, BasicBundle, BasicEntity, BasicMovementBundle, Biome, BiomeAPI, BiomeComponent, BiomeFilter, Block, BlockAPI, BlockComponent, BlockCustomComponentBuilder, Button, ButtonMapping, ChestUISystem, ClientEntity, CollectionPanel, ContainerUISystem, Control, CoordinateDistribution, CropBlock, DEFAULT_GUIDE_BOOK_LABELS, DataBinding, DataBindingObject, DummyEntity, Entity, EntityAPI, EntityComponent, Factory, FeatureAPI, FeatureConditions, FeatureDistribution, FeatureRule, FenceBlock, FlipbookItem, FlipbookTextureConfig, FlipbookTextures, FollowMobBehavior, FollowParentBehavior, Food, FormButton, FormButtonGrid, GRegistry, GeometryBlock, GlassBlock, GoHomeBehavior, Grid, GridProp, HeadBlock, HudProgressBar, HudStatePanel, HudUISystem, Image, Input, Item, ItemAPI, ItemCatalog, ItemCategory, ItemComponent, ItemTextureManager, Label, Layout, Modifications, MoveTowardsHomeRestrictionBehavior, NativeEntity, NativeEntityData, Navigation, NearestAttackableTargetBehavor, NonNullMap, OreBlock, OreFeature, Panel, PickupItemsBehavior, Projectile, RandomStrollBehavior, RecipeAPI, RecipeInputTags, RecipeTags, RecipeTypes, RotatableBlock, RotationTypes, SLOT_CALIBRATION, SLOT_KINDS, SapdonGuideBook, SapdonPanel, SapdonServerUI, SapdonTexturedButton, ScrollView, ScrollingPanel, Serializable, Serializer, Sound, Sprite, StackPanel, StairBlock, TemptBehavior, TerrainTextureManager, Text, TextureVariationConfig, TileBlock, TintMethod, TrapdoorBlock, UIElement, UISystem, UISystemRegistry, UI_NAME_PATTERN, UiAPI, anchorProps, cellBase, checkUIName, decode, defaultSerializer, encode, f64, getMetadata, getOrCreateMetadata, gridDimensionsFor, isGatedKind, isRawJSON, isSafeUIName, jsonEncodeDecoder, jsonEncoderReplacer, mixin, normalizeBackground, normalizeCellSize, posToOffset, registerBlock, registerEntity, registry, resolveCalibration, resolveSlot, serialize, slotToGridPosition, validateSlotSpec }; export type { ArmorOptions, ArmorSpec, BeforeOnPlayerPlaceEvent, BlockCustomComponentHandlers, BlockDescriptor, BlockPlacerOptions, CellLayoutOptions, CellSizeInput, ConstructorOf, CooldownOptions, CreateModelItemOptions, DiggerOptions, DurabilitySensorOptions, DurabilityThreshold, EncodeDecoder, EntityPlacerOptions, FlipbookEntry, FlipbookItemOptions, FloatLiteral, FoodComponentOptions, FoodOptions, GuideBookCategory, GuideBookChapter, GuideBookLabels, GuideBookOptions, GuideBookPageType, ISerializer, IconTextures, ItemCatalogCategory, ItemCatalogGroupOptions, ItemComponentMap, ItemOptions, ItemRarity, ItemRendererSpec, KineticWeaponOptions, LegacyGridItemOptions, ModelBoneTransform, NineSlice, Offset2, OnBlockStateChangeEvent, OnBreakEvent, OnEntityEvent, OnEntityFallOnEvent, OnPlaceEvent, OnPlayerBreakEvent, OnPlayerInteractEvent, OnRandomTickEvent, OnRedstoneUpdateEvent, OnStepOffEvent, OnStepOnEvent, OnTickEvent, PanelOptions, PiercingWeaponOptions, ProgressClipDirection, ProgressSlotOptions, Range, RawType, RecordOptions, RepairItem, ResolvedSlot, SapdonPageRegistration, SerializedElement, ShooterAmmunition, ShooterOptions, Size2, SlotAnchor, SlotBackground, SlotCalibration, SlotDefaults, SlotKind, SlotSpec, StorageItemOptions, SwingSoundsOptions, TextureEntry, TextureVariation, ThrowableOptions, UseModifiersOptions };