1---2name: construction-skill3description: 使用 VoxelBuilder API 生成 JavaScript 代码来建造结构。在建筑时务必使用此技能来查看和创建实际的建筑代码。4---56# 📝 建造技能 (Construction Skill)78使用 VoxelBuilder API 生成 JavaScript 代码来建造高品质体素建筑。910## VoxelBuilder API1112### 基础方块操作13| 方法 | 用途 |14|------|------|15| `builder.set(x, y, z, block)` | 放置单个方块 |16| `builder.get(x, y, z)` | 获取指定位置方块 |17| `builder.fill(x1, y1, z1, x2, y2, z2, block)` | 填充立方体区域 |18| `builder.walls(x1, y1, z1, x2, y2, z2, block)` | 建四面墙(空心) |19| `builder.line(x1, y1, z1, x2, y2, z2, block)` | 画直线/斜线 |20| `builder.clear(...)` | 清空区域 |2122### 分组与优先级 (Groups & Priority)23| 方法 | 用途 |24|------|------|25| `builder.beginGroup(name, { priority })` | 开始分组 |26| `builder.endGroup()` | 结束分组 |27| `builder.setPriority(n)` | 设置当前优先级 |2829统一优先级分层:`door=100`, `frame=95`, `windows=70`, `roof=60`, `walls=50`, `decor=20`, `foundation=10`3031### 门窗32| 方法 | 用途 |33|------|------|34| `builder.setDoor(x, y, z, type)` | 放置双格门 (如 'oak_door') |3536### 屋顶与山墙 (Roofs & Auto-Gable)37| 方法 | 用途 |38|------|------|39| `builder.drawRoofBounds(x1, y, z1, x2, z2, height, style, material, opts)` | 矩形屋顶 |40| `builder.drawPolyRoof(x, y, z, radius, height, sides, style, material)` | 多边形/圆形屋顶 |4142- `style`: `straight` / `gambrel` / `arch` / `cone` / `dome` / `curve` / `steep`43- `opts`: `{ gable: '墙体材料', ridge: '屋脊材料' }`44- **⚠️ 重要规范**:屋顶两侧的人字形山墙**严禁手动写 for 循环**!直接在 `opts` 中传入 `{ gable: 'WALL_MATERIAL' }`,系统引擎会自动精准封闭山墙且无任何错位缝隙。4546### 几何体47| 方法 | 用途 |48|------|------|49| `builder.drawCylinder(x,y,z,r,h,mat,opts)` | 圆柱体 |50| `builder.drawSphere(x,y,z,r,mat,opts)` | 球体 |51| `builder.drawEllipsoid(x,y,z,rx,ry,rz,mat,opts)` | 椭球体 |52| `builder.drawPolygon(x,y,z,r,sides,h,mat,opts)` | 多边形柱 |53| `builder.drawPyramid(x,y,z,base,h,mat,opts)` | 金字塔 |54| `builder.drawTorus(x,y,z,R,r,mat,opts)` | 圆环 |5556**通用 options:**57- `hollow`: 是否空心58- `thickness`: 壁厚59- `axis`: 'y'|'x'|'z' (简单轴向)60- `noise`: { amount, scale } (有机自然起伏,适合树木/山体)61- `rotateX/Y/Z`: 任意角度旋转 (度数)6263### 曲线与装饰64| 方法 | 用途 |65|------|------|66| `builder.drawBezier(points,mat,w)` | 贝塞尔曲线 (用于弯曲藤蔓/树干) |67| `builder.scatter(x1,y,z1,x2,z2,d,types)` | 2D地面散布花草 |68| `builder.scatter3D(...)` | 3D空间散布 |69| `builder.drawHanging(x,y,z,opts)` | 单点悬挂物 (灯笼/链条) |70| `builder.drawHangingRing(x,y,z,r,opts)` | 环形悬挂 |71| `builder.drawSpiralStairs(x,y,z,r,h,mat)` | 螺旋楼梯 |7273### 组件系统74| 方法 | 用途 |75|------|------|76| `builder.defineComponent(name, (b, params) => { ... })` | 定义组件 (组件内部必须使用传入的 `b` 参数) |77| `builder.placeComponent(name, x, y, z, options)` | 放置组件 |7879### 方块属性语法规范80```javascript81'stone' // 普通方块82'oak_stairs?facing=north' // 楼梯正放与朝向83'stone_brick_stairs?facing=south,half=top' // 楼梯倒放 (檐口椽头)84'oak_door?facing=south,half=lower' // 门下半85'spruce_trapdoor?facing=east,open=true' // 活板门做百叶窗86'oak_log?axis=x' // 原木横放87'lantern?hanging=true' // 悬挂灯笼88```8990## 使用方法9192想了解各函数的具体用法,请使用 `read_subdoc` 查阅子文档,例如:93```json94{ "name": "read_subdoc", "arguments": { "skill": "construction-skill", "doc": "resources/drawRoofBounds" } }95```