The Best Resource for Minecraft
The Best Resource for Minecraft

یک سازه .nbt نمایه‌های palette را ذخیره می‌کند، نه نام بلوک‌ها — به همین دلیل بسیار کم‌حجم است

یک سازه .nbt نمایه‌های palette را ذخیره می‌کند، نه نام بلوک‌ها — به همین دلیل بسیار کم‌حجم است

سه کلید کل یک سازه را نگه می‌دارند: size، palette و blocks. هر بلوک یک عدد صحیح است که به palette اشاره می‌کند، بنابراین یک حجم 32³ از سنگ هزینهٔ یک رشته و 32,768 عدد را دارد.

A .nbt structure file — the thing a structure block saves and a datapack ships — is a much simpler format than it looks from the outside. Everything a build needs sits in a handful of top-level keys, and one design decision explains why the files are as small as they are.

سه کلیدی که سازه را نگه می‌دارند

size     [x, y, z]                       — a list of exactly three integers
palette  [ { Name, Properties } … ]      — every DISTINCT block state, once
blocks   [ { pos, state, nbt } … ]       — one entry per placed block

palette holds each distinct block state exactly once. یک ورودی، یک Name — the block id, like minecraft:oak_stairs — plus an optional Properties compound holding its blockstate, such as facing: north and half: bottom.

blocks never repeats a name. هر ورودی دارای یک pos of three integers and a state, and state is an نمایه به palette است، نه یک block id. پله‌های بلوط رو به شمال یک‌بار دادهٔ رشته‌ای هستند و بعد از آن هر کدام از آن‌ها یک عدد صحیح کوچک است.

تمام ترفند همین است. حجم 32 × 32 × 32 از سنگ ساده، یک ورودی palette و 32,768 عدد نمایه است — نه 32,768 کپی از کلمهٔ minecraft:stone. The palette grows with how many متفاوت چیزهایی که با آن‌ها ساختید، و لیست بلوک‌ها بر اساس این‌که چقدر بزرگ ساخته‌اید رشد می‌کند. این‌ها اعداد بسیار متفاوتی هستند و معمولاً فقط یکی از آن‌ها بزرگ است.

دو پیامد که ارزش دارد بر اساس آن‌ها طراحی کنید

حالت‌های بلوک (Blockstates) پالت شما را چند برابر می‌کنند، نه لیست بلوک‌هایتان را. پله‌های بلوط یک ورودی palette نیستند — به ازای هر جهتی که واقعاً استفاده کرده‌اید، یکی وجود دارد. رو به چهار جهت، نیمه بالایی و پایینی، مستقیم و هر دو گوشهٔ داخلی و خارجی: یک بلوک یکسان می‌تواند دوازده اسلات palette را اشغال کند. بنابراین یک سازه پر از جزئیات دارای یک palette بزرگ است و یک سازه ساده این‌طور نیست، فارغ از اندازه.

فقط بلوک‌های قرار داده شده ورودی دریافت می‌کنند. لیست بلوک‌ها یک لیست است، نه یک آرایه سه‌بعدی متراکم، و ورودی‌ای که وجود ندارد، به‌سادگی وجود ندارد — نمایشگر این صفحه شبکه خود را با -1 and treats a missing coordinate as nothing placed. A hollow build is genuinely cheaper to store than a solid one of the same dimensions.

nbt is per-block and optional

هر ورودی در blocks may carry its own nbt compound, and most do not. This is where a chest's contents, a sign's text, a spawner's mob and a banner's patterns live — attached to the individual block rather than to the palette.

این تمایز اهمیت دارد: داده‌های palette مشترک هستند و داده‌های بلوک مشترک نیستند. دو صندوق یک ورودی palette هستند، زیرا حالت بلوک یکسانی دارند — اما هرکدام اینونتوری خود را در nbt. Change the block state and you touch the palette; change what is inside it and you touch one entry in the block list.

خواندن یک لایه در هر زمان

نمایشگر اینجا عمداً 2D است. برای رسم لایه y لیست بلوک‌ها را پیمایش می‌کند، ورودی‌هایی را نگه می‌دارد که pos[1] equals y، و برای هر کدام state up in the palette. That is the entire algorithm, and it is worth knowing because it is also how you would inspect one of these files yourself: there is no spatial index to build and no decompression beyond the gzip wrapper. The format is a flat list you filter.

که همچنین به این معنی است که یک فایل سازه چیزی دربارهٔ اینکه کجا در یک جهان قرار دارد به شما نمی‌گوید. size is a bounding box and pos values are relative to its corner. The placement is the structure block's business, not the file's.

امتحان ابزار: Structure & NBT Component Tools →