Difference between revisions of "User:WinX64/Slot Data"

From wiki.vg
Jump to navigation Jump to search
(Starting template for the updated slot data page)
 
(General structure)
Line 1: Line 1:
The '''Slot''' data structure is how Minecraft represents an item and its associated data in the [[Protocol|Minecraft Protocol]].
+
The '''Slot''' data structure defines how an item is represented when inside an inventory window of any kind, such as a chest or furnace.
 +
 
 +
This page presents the new Slot data structure, using structured components. You can find the documentation of the old structure, that utilizes raw NBT data, [[Special:Permalink/18899|here]].
 +
 
 +
= Format =
  
=== Slot ===
 
  
 
{| class="wikitable"
 
{| class="wikitable"
  ! Name
+
  ! colspan="2"| Name
  ! Type
+
  ! colspan="2"| Type
 
  ! Meaning
 
  ! Meaning
 
  |-
 
  |-
  | Present
+
  | colspan="2"| Item Count
  | {{Type|Boolean}}
+
  | colspan="2"| {{Type|VarInt}}
  | True if there is an item in this position; false if it is empty.
+
  | The item count. Every following field is only present if this value is greater than zero.
 
  |-
 
  |-
  | Item ID
+
  | colspan="2"| Item ID
  | {{Type|Optional}} {{Type|VarInt}}
+
  | colspan="2"| {{Type|Optional}} {{Type|VarInt}}
  | Omitted if present is false. The {{Minecraft Wiki|Java Edition data values#Blocks|item ID}}. Item IDs are distinct from block IDs; see [[Data Generators]] for more information
+
  | The {{Minecraft Wiki|Java Edition data values#Blocks|item ID}}. Item IDs are distinct from block IDs; see [[Data Generators]] for more information.
 
  |-
 
  |-
  | Item Count
+
  | colspan="2"| Components with data
  | {{Type|Optional}} {{Type|Byte}}
+
| colspan="2"| {{Type|Optional}} {{Type|NBT}}
  | Omitted if present is false.
+
| Number of elements present in the first data component array
 +
|-
 +
  | colspan="2"| Components without data
 +
| colspan="2"| {{Type|Optional}} {{Type|NBT}}
 +
  | Number of elements present in the second data component array. This serve as a way to remove the default component values that are present on some items.
 +
|-
 +
| rowspan="2"| Components to add
 +
| Component type
 +
| rowspan="2"| {{Type|Optional}} {{Type|Array}}
 +
| {{Type|Optional}} {{Type|VarInt}} {{Type|Enum}}
 +
| colspan="2"| The type of component. See [[#Structured_components|Structured components]] for more detail.
 +
|-
 +
| Component data
 +
| {{Type|Optional}} Varies
 +
| colspan="1"| The component-dependent data. See [[#Structured_components|Structured components]] for more detail.
 +
|-
 +
| rowspan="1"| Components to remove
 +
| Component type
 +
| rowspan="1"| {{Type|Optional}} {{Type|Array}}
 +
| {{Type|Optional}} {{Type|VarInt}} {{Type|Enum}}
 +
| colspan="2"| The type of component. See [[#Structured_components|Structured components]] for more detail.
 
  |-
 
  |-
| NBT
 
| {{Type|Optional}} {{Type|NBT}}
 
| Omitted if present is false. If 0 (TAG_End), there is no NBT data, and no further data follows. Otherwise the byte is the start of an NBT blob as shown below:
 
 
  |}
 
  |}
  
<pre>
+
== Structured components ==
  COMPOUND
 
    LIST 'StoredEnchantments'
 
      COMPOUND
 
        STRING 'id'
 
        SHORT 'lvl'
 
      END
 
      COMPOUND
 
        ...
 
      END
 
      ...
 
    END
 
    INT 'Unbreakable'
 
    ...
 
  END
 
</pre>
 
  
Note that on old versions, the enchantment id was sent as a SHORT, and not as a STRING.
+
Blah.
  
Since 1.20.2 the root compound also has no name anymore. The NBT data starts with one byte indicating the type, followed by the type-specific data.
+
{| class="wikitable"
 
+
! Type
See [[NBT]] for more information about the NBT format, and {{Minecraft Wiki|Player.dat format#Item structure|here}} for the contained information and its formatNote that tool durability is included in NBT, among other things.
+
! Name
 
+
! Description
== Examples ==
+
! Data
 
+
|-
<pre>
+
| 0
  00                      | empty slot
+
| <code>minecraft:custom_data</code>
  01 01 01 00            | a stone block
+
| Description here.
  01 01 01 03 12 34 56 78 | a stone block with (made-up) NBT data
+
| Data here.
</pre>
+
|-
 +
| 1
 +
| <code>minecraft:max_stack_size</code>
 +
| Description here.
 +
| Data here.
 +
|-
 +
| 2
 +
| <code>minecraft:max_damage</code>
 +
| Description here.
 +
| Data here.
 +
|-
 +
| 3
 +
| <code>minecraft:damage</code>
 +
| Description here.
 +
| Data here.
 +
|-
 +
| 4
 +
| <code>minecraft:unbreakable</code>
 +
| Description here.
 +
| Data here.
 +
|-
 +
| 5
 +
| <code>minecraft:custom_name</code>
 +
| Description here.
 +
| Data here.
 +
|-
 +
| 6
 +
| <code>minecraft:item_name</code>
 +
| Description here.
 +
| Data here.
 +
|-
 +
| 7
 +
| <code>minecraft:lore</code>
 +
| Description here.
 +
| Data here.
 +
|-
 +
| 8
 +
| <code>minecraft:rarity</code>
 +
| Description here.
 +
| Data here.
 +
|-
 +
| 9
 +
| <code>minecraft:enchantments</code>
 +
| Description here.
 +
| Data here.
 +
|-
 +
| 10
 +
| <code>minecraft:can_place_on</code>
 +
| Description here.
 +
| Data here.
 +
|-
 +
| 11
 +
| <code>minecraft:can_break</code>
 +
| Description here.
 +
| Data here.
 +
|-
 +
| 12
 +
| <code>minecraft:attribute_modifiers</code>
 +
| Description here.
 +
| Data here.
 +
|-
 +
| 13
 +
| <code>minecraft:custom_model_data</code>
 +
| Description here.
 +
| Data here.
 +
|-
 +
| 14
 +
| <code>minecraft:hide_additional_tooltip</code>
 +
| Description here.
 +
| Data here.
 +
|-
 +
| 15
 +
| <code>minecraft:hide_tooltip</code>
 +
| Description here.
 +
| Data here.
 +
|-
 +
| 16
 +
| <code>minecraft:repair_cost</code>
 +
| Description here.
 +
| Data here.
 +
|-
 +
| 17
 +
| <code>minecraft:creative_slot_lock</code>
 +
| Description here.
 +
| Data here.
 +
|-
 +
| 18
 +
| <code>minecraft:enchantment_glint_override</code>
 +
| Description here.
 +
| Data here.
 +
|-
 +
| 19
 +
| <code>minecraft:intangible_projectile</code>
 +
| Description here.
 +
| Data here.
 +
|-
 +
| 20
 +
| <code>minecraft:food</code>
 +
| Description here.
 +
| Data here.
 +
|-
 +
| 21
 +
| <code>minecraft:fire_resistant</code>
 +
| Description here.
 +
| Data here.
 +
|-
 +
  | 22
 +
| <code>minecraft:tool</code>
 +
| Description here.
 +
| Data here.
 +
|-
 +
| 23
 +
| <code>minecraft:stored_enchantments</code>
 +
| Description here.
 +
| Data here.
 +
|-
 +
| 24
 +
| <code>minecraft:dyed_color</code>
 +
| Description here.
 +
| Data here.
 +
|-
 +
| 25
 +
| <code>minecraft:map_color</code>
 +
| Description here.
 +
| Data here.
 +
|-
 +
| 26
 +
| <code>minecraft:map_id</code>
 +
| Description here.
 +
| Data here.
 +
|-
 +
| 27
 +
| <code>minecraft:map_decorations</code>
 +
| Description here.
 +
| Data here.
 +
|-
 +
| 28
 +
| <code>minecraft:map_post_processing</code>
 +
| Description here.
 +
| Data here.
 +
|-
 +
| 29
 +
| <code>minecraft:charged_projectiles</code>
 +
| Description here.
 +
| Data here.
 +
|-
 +
| 30
 +
| <code>minecraft:bundle_contents</code>
 +
| Description here.
 +
| Data here.
 +
|-
 +
| 31
 +
| <code>minecraft:potion_contents</code>
 +
| Description here.
 +
| Data here.
 +
|-
 +
| 32
 +
| <code>minecraft:suspicious_stew_effects</code>
 +
| Description here.
 +
| Data here.
 +
|-
 +
| 33
 +
| <code>minecraft:writable_book_content</code>
 +
| Description here.
 +
| Data here.
 +
|-
 +
| 34
 +
| <code>minecraft:written_book_content</code>
 +
| Description here.
 +
| Data here.
 +
|-
 +
| 35
 +
| <code>minecraft:trim</code>
 +
| Description here.
 +
| Data here.
 +
|-
 +
| 36
 +
| <code>minecraft:debug_stick_state</code>
 +
| Description here.
 +
| Data here.
 +
|-
 +
| 37
 +
| <code>minecraft:entity_data</code>
 +
| Description here.
 +
| Data here.
 +
|-
 +
| 38
 +
| <code>minecraft:bucket_entity_data</code>
 +
| Description here.
 +
| Data here.
 +
|-
 +
| 39
 +
| <code>minecraft:block_entity_data</code>
 +
| Description here.
 +
| Data here.
 +
|-
 +
| 40
 +
| <code>minecraft:instrument</code>
 +
| Description here.
 +
| Data here.
 +
|-
 +
| 41
 +
| <code>minecraft:ominous_bottle_amplifier</code>
 +
| Description here.
 +
| Data here.
 +
|-
 +
| 42
 +
| <code>minecraft:recipes</code>
 +
| Description here.
 +
| Data here.
 +
|-
 +
| 43
 +
| <code>minecraft:lodestone_tracker</code>
 +
| Description here.
 +
| Data here.
 +
|-
 +
| 44
 +
| <code>minecraft:firework_explosion</code>
 +
| Description here.
 +
| Data here.
 +
|-
 +
| 45
 +
| <code>minecraft:fireworks</code>
 +
| Description here.
 +
| Data here.
 +
|-
 +
| 46
 +
| <code>minecraft:profile</code>
 +
| Description here.
 +
| Data here.
 +
|-
 +
| 47
 +
| <code>minecraft:note_block_sound</code>
 +
| Description here.
 +
| Data here.
 +
|-
 +
| 48
 +
| <code>minecraft:banner_patterns</code>
 +
| Description here.
 +
| Data here.
 +
|-
 +
| 49
 +
| <code>minecraft:base_color</code>
 +
| Description here.
 +
| Data here.
 +
|-
 +
| 50
 +
| <code>minecraft:pot_decorations</code>
 +
| Description here.
 +
| Data here.
 +
|-
 +
| 51
 +
| <code>minecraft:container</code>
 +
| Description here.
 +
| Data here.
 +
|-
 +
| 52
 +
| <code>minecraft:block_state</code>
 +
| Description here.
 +
| Data here.
 +
|-
 +
| 53
 +
| <code>minecraft:bees</code>
 +
| Description here.
 +
| Data here.
 +
|-
 +
| 54
 +
| <code>minecraft:lock</code>
 +
| Description here.
 +
| Data here.
 +
|-
 +
| 55
 +
| <code>minecraft:container_loot</code>
 +
| Description here.
 +
| Data here.
 +
|}
  
 
[[Category:Protocol Details]]
 
[[Category:Protocol Details]]
 
[[Category:Minecraft Modern]]
 
[[Category:Minecraft Modern]]

Revision as of 18:19, 6 June 2024

The Slot data structure defines how an item is represented when inside an inventory window of any kind, such as a chest or furnace.

This page presents the new Slot data structure, using structured components. You can find the documentation of the old structure, that utilizes raw NBT data, here.

Format

Name Type Meaning
Item Count VarInt The item count. Every following field is only present if this value is greater than zero.
Item ID Optional VarInt The item ID. Item IDs are distinct from block IDs; see Data Generators for more information.
Components with data Optional NBT Number of elements present in the first data component array
Components without data Optional NBT Number of elements present in the second data component array. This serve as a way to remove the default component values that are present on some items.
Components to add Component type Optional Array Optional VarInt Enum The type of component. See Structured components for more detail.
Component data Optional Varies The component-dependent data. See Structured components for more detail.
Components to remove Component type Optional Array Optional VarInt Enum The type of component. See Structured components for more detail.

Structured components

Blah.

Type Name Description Data
0 minecraft:custom_data Description here. Data here.
1 minecraft:max_stack_size Description here. Data here.
2 minecraft:max_damage Description here. Data here.
3 minecraft:damage Description here. Data here.
4 minecraft:unbreakable Description here. Data here.
5 minecraft:custom_name Description here. Data here.
6 minecraft:item_name Description here. Data here.
7 minecraft:lore Description here. Data here.
8 minecraft:rarity Description here. Data here.
9 minecraft:enchantments Description here. Data here.
10 minecraft:can_place_on Description here. Data here.
11 minecraft:can_break Description here. Data here.
12 minecraft:attribute_modifiers Description here. Data here.
13 minecraft:custom_model_data Description here. Data here.
14 minecraft:hide_additional_tooltip Description here. Data here.
15 minecraft:hide_tooltip Description here. Data here.
16 minecraft:repair_cost Description here. Data here.
17 minecraft:creative_slot_lock Description here. Data here.
18 minecraft:enchantment_glint_override Description here. Data here.
19 minecraft:intangible_projectile Description here. Data here.
20 minecraft:food Description here. Data here.
21 minecraft:fire_resistant Description here. Data here.
22 minecraft:tool Description here. Data here.
23 minecraft:stored_enchantments Description here. Data here.
24 minecraft:dyed_color Description here. Data here.
25 minecraft:map_color Description here. Data here.
26 minecraft:map_id Description here. Data here.
27 minecraft:map_decorations Description here. Data here.
28 minecraft:map_post_processing Description here. Data here.
29 minecraft:charged_projectiles Description here. Data here.
30 minecraft:bundle_contents Description here. Data here.
31 minecraft:potion_contents Description here. Data here.
32 minecraft:suspicious_stew_effects Description here. Data here.
33 minecraft:writable_book_content Description here. Data here.
34 minecraft:written_book_content Description here. Data here.
35 minecraft:trim Description here. Data here.
36 minecraft:debug_stick_state Description here. Data here.
37 minecraft:entity_data Description here. Data here.
38 minecraft:bucket_entity_data Description here. Data here.
39 minecraft:block_entity_data Description here. Data here.
40 minecraft:instrument Description here. Data here.
41 minecraft:ominous_bottle_amplifier Description here. Data here.
42 minecraft:recipes Description here. Data here.
43 minecraft:lodestone_tracker Description here. Data here.
44 minecraft:firework_explosion Description here. Data here.
45 minecraft:fireworks Description here. Data here.
46 minecraft:profile Description here. Data here.
47 minecraft:note_block_sound Description here. Data here.
48 minecraft:banner_patterns Description here. Data here.
49 minecraft:base_color Description here. Data here.
50 minecraft:pot_decorations Description here. Data here.
51 minecraft:container Description here. Data here.
52 minecraft:block_state Description here. Data here.
53 minecraft:bees Description here. Data here.
54 minecraft:lock Description here. Data here.
55 minecraft:container_loot Description here. Data here.