--- title: MC資料結構:NBT Data tags: math, Data-Structure --- # NBT Data `ref.`[NBT格式 - Minecraft Wiki](https://zh.minecraft.wiki/w/NBT%E6%A0%BC%E5%BC%8F) Minecraft的大部分資料採用「Named Binary Tags」的格式儲存 Data <font color=red>ex.</font> 物品 NBT Data`{item:"minecraft:iron_sword", Count:1b}` --- # NBT Data Type (NBT資料型態) 實際例子與更詳細的說明請參考[wiki](https://zh.minecraft.wiki/w/NBT%E6%A0%BC%E5%BC%8F) 以下簡略的描述Minecraft NBT Data中可使用的資料型態 | Data Type | 型態 | 說明 | | | -------- | -------- | -------- | -------- | | Boolean | 布林值 | 1-bit數值,用於表示真或假 | `true`, `false` | | Byte | 位元組 | 8-bits數值,共可表示 $2^8$ 個整數值 | `b` | | Short | 短整數 | 16-bits數值,共可表示 $2^{16}$ 個整數值 | `s` | | Int | 整數 | 32-bits數值,共可表示 $2^{32}$ 個整數值 | | | Long | 長整數 | 64-bits數值,共可表示 $2^{64}$ 個整數值 | `l` | | Float | 浮點數 | 使用32-bits儲存的小數數值 | `f` | | Double | 雙精度浮點數 | 使用64-bits儲存的小數數值,精度更高 | `d` | | String | 字串 | 儲存任意順序的文字訊息 | `""` | | List | 串列 | 有順序性的儲存數筆資料 | `[]` | | Compound | | 儲存數筆的<font color=blue>鍵值對</font>資料 | `{}` | | Byte Array | 位元組串列 | 元素型態為Byte的List | `[B;]` | | Int Array | 整數串列 | 元素型態為Int的List | `[I;]` | | Long Array | 長整數串列 | 元素型態為Long的List | `[L;]`| :::spoiler <font color=red>Byte/Int/Long Array 與 List 功能相同,但名稱上略有不同</font> > 由於資訊領域方面所談及的概念並不相同 > 所以請特別留意區分Array與List是不一樣的概念 > 此3串列的資料型態為 NBT Format 的錯誤命名 [color=red] ::: ### <font color=blue>數值型態</font> > **整數型態**:Boolean, Byte, Short, Int, Long > **小數型態**:Float, Double [color=blue] > <font color=blue>詳細說明可見:</font>[MC數值結構:常數與變數](https://hackmd.io/@minecraft-advanced-command-tutorial/ByxmmGIuY) ### <font color=blue>資料集合</font> > List`[]`, Compound`{}` > Byte Array`[B;]`, Int Array`[I;]`, Long Array`[L;]` [color=blue] > <font color=blue>詳細說明可見此欄目的後續文章</font>