NBT
This modifier will apply the NBT data to the item.
WARNING
This modifier will reset all item settings. Therefore, It's recommended to order the settings in the following pattern: ID (Material), NBT, other item settings.
Format
nbt: <nbt>
nbt-data: <nbt>Example
custom-model-chestplate:
id: leather_chestplate
nbt:
CustomModelData: 104230
name: "&aCustom Model Chestplate"
lore:
- "This is a custom model chestplate"
position-x: 1
position-y: 1
colored-leather-chestplate:
id: leather_chestplate
nbt:
display:
color: 16175144
name: "&aColored Leather Chestplate"
lore:
- "This is a colored leather chestplate"
position-x: 2
position-y: 1How to set NBT
BetterGUI automatically converts YAML-structured NBT settings into valid SNBT (Stringified Named Binary Tag) format. The following section describes the structure and syntax required for proper NBT configuration.
Basic Conversion Rules
YAML structure mapping to NBT equivalents:
- Objects → NBT compound tags (denoted by curly brackets
{}in SNBT) - Lists → NBT list/array tags (denoted by square brackets
[]in SNBT) - Key-value pairs → individual NBT entries
Example 1: Primitive Value
{CustomModelData:12}Corresponding YAML configuration:
nbt:
CustomModelData: 12Example 2: Compound Structures with List Elements
{CustomModelData:12,ench:[{lvl:2,id:sharpness},{lvl:1,id:unbreaking}]}Corresponding YAML configuration:
nbt:
CustomModelData: 12
ench:
- id: sharpness
lvl: 2
- id: unbreaking
lvl: 1Type Enforcement with Forced-Value Maps
In basic scenarios, string and integer values are inferred automatically from their YAML representation. However, when incorporating Variables into NBT values, explicit type specification becomes necessary.
When a value is dynamic (contains a variable reference), use a forced-value map with $type and $value properties to explicitly declare the NBT data type. This ensures correct type conversion when the variable is resolved at runtime.
Example: Dynamic Enchantment Level
To set an enchantment level based on a player variable {level}
nbt:
ench:
- id: unbreaking
lvl:
$type: "integer"
$value: "{level}"Supported Data Types
The following data types are available for the $type property:
byte- Signed 8-bit integerboolean- True/false valueshort- Signed 16-bit integerintorinteger- Signed 32-bit integerlong- Signed 64-bit integerfloat- 32-bit floating-pointdouble- 64-bit floating-pointstring- Text stringraw- Raw SNBT string (parsed as-is)list- Homogeneous listcompound- Compound tag (object)byte_array- Array of bytesint_array- Array of integerslong_array- Array of longs
For array types (byte_array, int_array, long_array), the $value must be specified as a list:
$type: "int_array"
$value:
- "12"
- "{level}"
- "23"Raw SNBT Strings
For advanced use cases, SNBT can be specified directly as a string value instead of using structured YAML. This bypasses automatic type inference and conversion, allowing direct SNBT syntax:
nbt: "{CustomModelData:12,ench:[{lvl:2,id:sharpness},{lvl:1,id:unbreaking}]}"