Minecraft 圖片建造器 是做什麼的?
將任何上傳的 Minecraft 結構圖片或截圖逆向工程,精確生成元件清單、座標錨點表,以及一個可下載的獨立、零依賴 ESM(.mjs)檔案(使用檔案生成工具,而非在聊天中傾印原始程式碼區塊),該檔案會匯出一個適用於 Minecraft 26.3(DataVersion: 5023)的 gzip 壓縮 vanilla .nbt 檔案,立即在單一次傳遞中完成,無需腦力激盪問題。
使用時機
- 使用者提供了 Minecraft 建築(房屋、小屋、塔樓、橋樑、水井、雕像、家具、寺廟或綜合體)的圖片、截圖或渲染圖,並要求重現、複製、逆向工程或將其生成為
.nbt或 Node.js 程式碼。 - 使用者希望獲得直接的視覺分解 + 結構化的方塊/元件列表 + 立即的
.mjs檔案輸出,無需來回確認。
不適用範圍
- 從頭開始的純文字構想(未提供圖片)- 將其轉交給
minecraft-builder進行從無到有的腦力激盪與建築設計。 - 紅石電路、自訂地形/地形改造、儲物箱 NBT 內容或實體擺設 - 清楚說明限制,並改為重建靜態方塊外殼。
資料夾結構
minecraft-image-builder/
├── SKILL.md
└── registry_26_3.json
工作流程(直接執行 - 無腦力激盪)
當提供圖片時,不要提出釐清或腦力激盪問題。在單一回應中依序執行所有四個階段:
階段 1:深度視覺分解與元件清單
從下到上、從前到後仔細檢查圖片,然後輸出簡潔、結構化的藍圖與元件清單:
- 多面板技術圖紙與軸對齊(如適用):
- 當上傳的圖片是多面板技術參考圖紙(例如
01. 前右 3/4 視角、02. 後左 3/4 視角、03. 內部/結構細節視角)時,將所有面板綜合在一起,而不是將它們視為獨立的建築。 - 將
X、Y和Z方向嚴格鎖定在面板 01 的 3D XYZ 軸輔助線(紅色X、綠色Y向上、藍色Z)以及任何"FRONT"地板標籤。如果面板 02 中的輔助線箭頭與面板 01 的相機旋轉衝突,則忽略面板 02 中翻轉或重複的輔助線箭頭。 - 交叉比對面板 01 和面板 02,在不猜測的情況下提取所有 4 個外部立面,並優先使用面板 03 的剖面圖佈局來確定內部房間隔間、樓梯和家具擺放。
- 忽略面板 03 中偶然出現的重複道具(例如一個額外的燈籠或告示牌),這些道具在面板 01 和面板 02 中均未出現。
- 當上傳的圖片是多面板技術參考圖紙(例如
- 整體尺寸與比例(網格三角測量):
- 透過沿寬度 (
X)、高度 (Y) 和深度 (Z) 計算可見方塊,估算確切的邊界框SIZE = [W, H, L],保持與截圖相符的非 1:1:1 比例。 - 如果牆壁或表面在 AI 生成的參考圖像中顯得平滑/非體素,則根據
1x1地板網格線、角落框架柱、窗格和屋頂階梯進行三角測量確切方塊數量,而不是從平滑的牆壁高度猜測。 - 定義高程基準層級:
Y_base、Y_floor1、Y_floor2(如果多層)、Y_roof_start和Y_roof_peak。
- 透過沿寬度 (
- 材質調色板分解(對應
registry_26_3.json):- 地基/底座: 例如
cobblestone、stone_bricks、tuff_bricks、deepslate_bricks。 - 框架柱與橫樑: 例如
oak_log、spruce_log、stripped_dark_oak_log帶有axis屬性。 - 主要與次要牆壁: 例如
oak_planks、white_concrete、calcite、mud_bricks。 - 屋頂與飾邊: 例如
spruce_stairs、brick_stairs、deepslate_tile_stairs、半磚和懸挑飾邊。 - 開口、照明與外部細節: 窗戶 (
glass_pane)、百葉窗 (*_trapdoor)、門 (*_door)、柵欄/牆、燈籠、煙囪、葉子/藤蔓以及在鏡頭中可見的裝飾性道具。
- 地基/底座: 例如
- 背面與內部重建計畫(被遮擋側):
- 對於在所有面板中仍隱藏的任何面或內部角落,推斷出對稱或功能連貫的佈局(與窗戶節奏和屋頂坡度匹配),並遵循模擬市民導航標準(床/工作站/展示品、每
4x4區域照明、以及可通行的1x2路徑)乾淨地佈置內部,無需詢問使用者。
- 對於在所有面板中仍隱藏的任何面或內部角落,推斷出對稱或功能連貫的佈局(與窗戶節奏和屋頂坡度匹配),並遵循模擬市民導航標準(床/工作站/展示品、每
階段 2:方塊註冊表驗證(registry_26_3.json)
- 根據技能目錄中的
registry_26_3.json(Minecraft 26.3 /DataVersion: 5023)驗證每個選擇的方塊 ID(minecraft:<name>)和狀態屬性。 - 絕不發明方塊 ID 或列舉值。如果截圖中出現模組化、平滑或非體素的道具(例如平滑灰泥牆、空調機、展示冰箱、文字告示牌),將其轉換為
registry_26_3.json中最接近的有效 vanilla 26.3 方塊組合,並在元件清單中註明映射關係。
階段 3:座標錨點表與 5 遍建構規則
在撰寫程式碼之前,將元件清單映射為精確的座標錨點表(X, Y, Z):
- 外殼與框架柱: 角柱
(X, Z)座標與外部牆面平面。 - 內部地板範圍(
X_min..X_max,Z_min..Z_max): 確保所有內部家具嚴格保持在X_wall_west + 1 .. X_wall_east - 1和Z_wall_north + 1 .. Z_wall_south - 1範圍內,以便第 5 遍永遠不會覆寫牆壁。 - 門、窗與陽台: 精確的
(X, Y, Z)+facing,在門/閘門前後保持1-2個可通行的地板瓷磚暢通,並確保任何圍欄陽台在其外部欄杆內有>= 1個可通行的地板行(深度 >= 2)。 - 樓梯與閣樓屋脊對齊:
- 使用明確的
shape: 'straight'鎖定可通行的樓梯階梯和樓梯椅,以便autoConnectStairs()僅塑造屋頂階梯。 - 任何延伸至傾斜屋頂上層/閣樓的樓梯必須終止於高中心屋脊 (
Y_roof_peak) 下方,以便carveStairHeadroom(x, y, z, 3)永遠不會穿透外部屋頂斜面。 - 對於轉彎樓梯,使用與第一段樓梯頂部階梯 (
Y_turn) 齊平的平坦1x1(L 型轉彎)或1x2(U 型轉彎)完整方塊平台,在平坦平台上方保持2個方塊的空氣,並從Y_turn + 1開始第二段樓梯。 - 僅在上升階梯正上方且
step.y + 3 >= Y_upper處移除上層地板磚,並用*_fence安全欄杆封閉開放的樓梯井邊緣。
- 使用明確的
- 離散網格鄰接與煙囪蓋:
- 牆壁安裝物品(
wall_torch、*_wall_sign、ladder、trapdoor百葉窗、vine)佔據相鄰的空氣方塊(X_wall +/- 1或Z_wall +/- 1),永遠不會覆寫牆壁方塊。 - 對於延伸至屋頂上方的外部煙囪,檢查頂部
campfire周圍所有 4 個水平鄰近方塊,並在每個與air相鄰的側面放置打開的*_trapdoor(open: 'true',half: 'top')。
- 牆壁安裝物品(
階段 4:立即輸出獨立 .mjs 檔案與執行說明
生成並匯出完整的、自包含的 ESM 檔案(<build-name>.mjs)作為可下載的 .mjs 檔案(如果可用,使用 file_gen 工具——除非檔案生成不可用,否則不要將完整的 .mjs 原始碼作為原始 Markdown 程式碼區塊傾印在聊天回應中),僅使用 node:fs 和 node:zlib,並按照 5 遍建構分層順序進行:
- 第 1 遍: 地基、樁柱和地板。
- 第 2 遍: 框架柱、外牆、窗戶、陽台和門(
placeDoor)。 - 第 3 遍: 屋頂(帶 1 方塊懸挑)和外部煙囪(帶 4 面蓋)。
- 第 4 遍: 樓梯(
shape: 'straight')、精確的樓梯井地板鏤空、安全欄杆和carveStairHeadroom()。 - 第 5 遍: 內部家具(在房間範圍內)、
placeBed()、牆壁附件、照明,接著是autoConnectStairs()、autoPairDoubleDoors()、connectDoubleChests()、connectWalls()以及connectFencesAndPanes()。
不要包含執行時 throw new Error 驗證函式,以便腳本始終乾淨執行。始終以簡短的執行、Shulkr 3D 檢視器預覽(https://www.shulkr.com/en/viewer)和 Minecraft 結構方塊載入指令結尾。
獨立 .mjs 範本
import fs from 'node:fs';
import zlib from 'node:zlib';
class NbtWriter {
constructor() { this.chunks = []; }
u8(v) { const b = Buffer.alloc(1); b.writeUInt8(v); this.chunks.push(b); }
i16(v) { const b = Buffer.alloc(2); b.writeInt16BE(v); this.chunks.push(b); }
i32(v) { const b = Buffer.alloc(4); b.writeInt32BE(v); this.chunks.push(b); }
str(s) { const buf = Buffer.from(s, 'utf8'); this.i16(buf.length); this.chunks.push(buf); }
tagHeader(type, name) { this.u8(type); this.str(name); }
tagInt(name, v) { this.tagHeader(3, name); this.i32(v); }
tagString(name, v) { this.tagHeader(8, name); this.str(v); }
tagListHeader(name, elemType, length) { this.tagHeader(9, name); this.u8(elemType); this.i32(length); }
tagCompoundStart(name) { this.tagHeader(10, name); }
tagEnd() { this.u8(0); }
toBuffer() { return Buffer.concat(this.chunks); }
}
const SIZE = [11, 12, 13];
const palette = [];
const paletteMap = new Map();
const blockGrid = new Map();
const DIR_VEC = {
north: [0, -1],
south: [0, 1],
west: [-1, 0],
east: [1, 0],
};
const LEFT_OF = { north: 'west', west: 'south', south: 'east', east: 'north' };
const RIGHT_OF = { north: 'east', east: 'south', south: 'west', west: 'north' };
function getStateIndex(name, props = {}) {
const keys = Object.keys(props).sort();
const key = `${name}|${keys.map((k) => `${k}=${props[k]}`).join(',')}`;
if (!paletteMap.has(key)) {
paletteMap.set(key, palette.length);
palette.push({ Name: name, Properties: props });
}
return paletteMap.get(key);
}
function setBlock(x, y, z, name, props = {}) {
if (x < 0 || x >= SIZE[0] || y < 0 || y >= SIZE[1] || z < 0 || z >= SIZE[2]) return;
const posKey = `${x},${y},${z}`;
if (name === 'minecraft:air') {
blockGrid.delete(posKey);
return;
}
blockGrid.set(posKey, { pos: [x, y, z], name, props, state: getStateIndex(name, props) });
}
function fill(x1, y1, z1, x2, y2, z2, name, props = {}) {
for (let x = Math.min(x1, x2); x <= Math.max(x1, x2); x++) {
for (let y = Math.min(y1, y2); y <= Math.max(y1, y2); y++) {
for (let z = Math.min(z1, z2); z <= Math.max(z1, z2); z++) {
setBlock(x, y, z, name, props);
}
}
}
}
function placeDoor(x, y, z, blockId, facing = 'south', hinge = 'left', open = 'false') {
setBlock(x, y, z, blockId, { facing, half: 'lower', hinge, open, powered: 'false' });
setBlock(x, y + 1, z, blockId, { facing, half: 'upper', hinge, open, powered: 'false' });
}
function placeBed(headX, y, headZ, blockId = 'minecraft:red_bed', facing = 'north') {
const [dx, dz] = DIR_VEC[facing] ?? [0, -1];
setBlock(headX, y, headZ, blockId, { facing, part: 'head', occupied: 'false' });
setBlock(headX - dx, y, headZ - dz, blockId, { facing, part: 'foot', occupied: 'false' });
}
function carveStairHeadroom(x, y, z, height = 3) {
for (let dy = 1; dy <= height; dy++) {
setBlock(x, y + dy, z, 'minecraft:air');
}
}
function autoConnectStairs(skipPositions = new Set()) {
for (const b of blockGrid.values()) {
if (!b.name.endsWith('_stairs')) continue;
const [x, y, z] = b.pos;
if (skipPositions.has(`${x},${y},${z}`)) continue;
if (b.props.shape !== undefined) continue;
const f = b.props.facing;
const half = b.props.half ?? 'bottom';
if (!f || !DIR_VEC[f]) continue;
const getStairAt = (nx, ny, nz) => {
const nb = blockGrid.get(`${nx},${ny},${nz}`);
if (!nb || !nb.name.endsWith('_stairs')) return null;
if ((nb.props.half ?? 'bottom') !== half) return null;
return nb.props.facing;
};
const [fx, fz] = DIR_VEC[f];
const [lx, lz] = DIR_VEC[LEFT_OF[f]];
const [rx, rz] = DIR_VEC[RIGHT_OF[f]];
const frontFacing = getStairAt(x + fx, y, z + fz);
const backFacing = getStairAt(x - fx, y, z - fz);
const leftFacing = getStairAt(x + lx, y, z + lz);
const rightFacing = getStairAt(x + rx, y, z + rz);
let shape = 'straight';
if (frontFacing === LEFT_OF[f] && rightFacing !== f) shape = 'outer_left';
else if (frontFacing === RIGHT_OF[f] && leftFacing !== f) shape = 'outer_right';
else if (backFacing === LEFT_OF[f] && leftFacing !== f) shape = 'inner_left';
else if (backFacing === RIGHT_OF[f] && rightFacing !== f) shape = 'inner_right';
const nextProps = {
...b.props,
half,
shape,
waterlogged: b.props.waterlogged ?? 'false',
};
b.props = nextProps;
b.state = getStateIndex(b.name, nextProps);
}
}
function autoPairDoubleDoors() {
const paired = new Set();
for (const b of blockGrid.values()) {
if (!b.name.endsWith('_door') || b.name === 'minecraft:iron_door') continue;
if (b.props.half !== 'lower') continue;
const [x, y, z] = b.pos;
const key = `${x},${y},${z}`;
if (paired.has(key)) continue;
const f = b.props.facing ?? 'south';
if (!DIR_VEC[f]) continue;
const [lx, lz] = DIR_VEC[LEFT_OF[f]];
const viewerRightKey = `${x + lx},${y},${z + lz}`;
const neighborLower = blockGrid.get(viewerRightKey);
if (
neighborLower &&
!paired.has(viewerRightKey) &&
neighborLower.name === b.name &&
neighborLower.props.half === 'lower' &&
(neighborLower.props.facing ?? 'south') === f
) {
const setDoorHinge = (dx, dz, hinge) => {
for (const dy of [0, 1]) {
const halfBlock = blockGrid.get(`${dx},${y + dy},${dz}`);
if (halfBlock && halfBlock.name === b.name) {
halfBlock.props = { ...halfBlock.props, hinge };
halfBlock.state = getStateIndex(halfBlock.name, halfBlock.props);
}
}
};
setDoorHinge(x, z, 'left');
setDoorHinge(x + lx, z + lz, 'right');
paired.add(key);
paired.add(viewerRightKey);
}
}
}
function connectDoubleChests() {
const chestBlocks = [...blockGrid.values()].filter(b => b.name.endsWith('_chest') && b.name !== 'minecraft:ender_chest' && b.props.type === 'single');
const paired = new Set();
for (const b of chestBlocks) {
const [x, y, z] = b.pos;
const key = `${x},${y},${z}`;
if (paired.has(key)) continue;
const f = b.props.facing ?? 'north';
if (!DIR_VEC[f]) continue;
const [lx, lz] = DIR_VEC[LEFT_OF[f]];
const [rx, rz] = DIR_VEC[RIGHT_OF[f]];
for (const [dx, dz, neighborDir, myType] of [[lx, lz, 'right', 'left'], [rx, rz, 'left', 'right']]) {
const neighborKey = `${x + dx},${y},${z + dz}`;
const neighbor = blockGrid.get(neighborKey);
if (neighbor && neighbor.name === b.name && neighbor.props.facing === f && !paired.has(neighborKey)) {
b.props = { ...b.props, type: myType };
neighbor.props = { ...neighbor.props, type: neighborDir };
b.state = getStateIndex(b.name, b.props);
neighbor.state = getStateIndex(neighbor.name, neighbor.props);
paired.add(key);
paired.add(neighborKey);
break;
}
}
}
}
function connectWalls() {
const wallBlocks = [...blockGrid.values()].filter(b => b.name.includes('_wall'));
for (const b of wallBlocks) {
const [x, y, z] = b.pos;
const s = {};
for (const [dx, dz, dir] of [[0, -1, 'north'], [0, 1, 'south'], [-1, 0, 'west'], [1, 0, 'east']]) {
const nb = blockGrid.get(`${x + dx},${y},${z + dz}`);
s[dir] = (nb && (nb.name.includes('_wall') || nb.name.endsWith('_wall_sign') || nb.name === 'minecraft:wall_torch' || (nb.name.endsWith('_fence_gate') && nb.name !== b.name))) ? 'low' : 'none';
}
b.props = { ...b.props, ...s, waterlogged: b.props.waterlogged ?? 'false' };
b.state = getStateIndex(b.name, b.props);
}
}
function connectFencesAndPanes() {
const fenceOrPaneBlocks = [...blockGrid.values()].filter(b => b.name.endsWith('_fence') || b.name.endsWith('_glass_pane') || b.name.endsWith('_iron_bars'));
for (const b of fenceOrPaneBlocks) {
const [x, y, z] = b.pos;
const s = {};
for (const [dx, dz, dir] of [[0, -1, 'north'], [0, 1, 'south'], [-1, 0, 'west'], [1, 0, 'east']]) {
const nb = blockGrid.get(`${x + dx},${y},${z + dz}`);
s[dir] = (nb !== undefined) ? 'true' : 'false';
}
b.props = { ...b.props, ...s, waterlogged: b.props.waterlogged ?? 'false' };
b.state = getStateIndex(b.name, b.props);
}
}
function build() {
const writer = new NbtWriter();
writer.tagCompoundStart('');
writer.tagInt('DataVersion', 5023);
writer.tagListHeader('blocks', 10, blockGrid.size);
for (const b of blockGrid.values()) {
writer.tagCompoundStart('');
writer.tagListHeader('pos', 3, 3);
for (const v of b.pos) writer.i32(v);
writer.tagInt('state', b.state);
writer.tagEnd();
}
writer.tagListHeader('palette', 10, palette.length);
for (const p of palette) {
writer.tagCompoundStart('');
writer.tagString('Name', p.Name);
if (Object.keys(p.Properties).length > 0) {
writer.tagCompoundStart('Properties');
for (const [k, v] of Object.entries(p.Properties)) writer.tagString(k, v);
writer.tagEnd();
}
writer.tagEnd();
}
writer.tagListHeader('size', 3, 3);
for (const v of SIZE) writer.i32(v);
writer.tagEnd();
let buf = writer.toBuffer();
buf = zlib.gzipSync(buf);
fs.writeFileSync('output.nbt', buf);
console.log('Generated output.nbt');
}
build();