Difference between revisions of "Object Data"

From wiki.vg
Jump to navigation Jump to search
(Use Template:Type for type links.)
 
(7 intermediate revisions by 4 users not shown)
Line 1: Line 1:
This article documents the '''Data''' field in the [[Protocol#Spawn Object|Spawn Object]] packet. The field is of type Int, and the meaning of its contents depend on the [[Entities#Objects|type of object]] being spawned, as defined in the Type field of the same packet, and is documented below.
+
This article documents the '''Data''' field in the [[Protocol#Spawn Entity|Spawn Entity]] packet. The field is of type Int, and the meaning of its contents depend on the [[Entity_metadata|type of entity]] being spawned, as defined in the Type field of the same packet, and is documented below.
  
In some cases, the data field has no meaning, but is only used to indicate presence of velocity.  In others, it (and velocity) is always ignored.
+
== [[Entity_metadata#Item_Frame|Item Frame]] ==
 
 
== Item (id 2) ==
 
 
 
The int value is ignored, but should be set to <code>1</code> to indicate that velocity is present.
 
 
 
== Minecarts (id 10) ==
 
 
 
The int value itself specifies the minecart's functionality:
 
  
 
{| class="wikitable"
 
{| class="wikitable"
 
  |-
 
  |-
 
  ! Value
 
  ! Value
  ! Minecart functionality
+
  ! Orientation
 
  |-
 
  |-
 
  | 0
 
  | 0
  | Empty (ride-able) minecart
+
  | Down
 
  |-
 
  |-
 
  | 1
 
  | 1
  | Chest minecart
+
  | Up
 
  |-
 
  |-
 
  | 2
 
  | 2
  | Furnace (powered) minecart
+
  | North
 
  |-
 
  |-
 
  | 3
 
  | 3
  | TNT minecart
+
  | South
 
  |-
 
  |-
 
  | 4
 
  | 4
  | Spawner minecart
+
  | West
 
  |-
 
  |-
 
  | 5
 
  | 5
  | Hopper minecart
+
  | East
|-
 
| 6
 
| Command Block minecart
 
 
  |}
 
  |}
  
== Item Frame (id 71) ==
+
The Notchian client clamps invalid values into the valid range through the modulus operator. If the resulting value is negative, the absolute value is used.
 +
 
 +
Velocity in the packet is always ignored.
 +
 
 +
== [[Entity_metadata#Painting|Painting]] ==
  
 
{| class="wikitable"
 
{| class="wikitable"
Line 44: Line 37:
 
  ! Value
 
  ! Value
 
  ! Orientation
 
  ! Orientation
|-
 
| 0
 
| Down
 
|-
 
| 1
 
| Up
 
 
  |-
 
  |-
 
  | 2
 
  | 2
Line 63: Line 50:
 
  | East
 
  | East
 
  |}
 
  |}
 +
 +
The Notchian client clamps invalid values into the valid range through the modulus operator. If the resulting value is negative, the absolute value is used.
 +
 +
{{Warning|Although the values of 0 and 1 are invalid, the Notchian client uses the same clamping algorithm as [[#Item_Frame|Item Frame]], which can result in any value from 0 to 5. If the resulting value is invalid, the entity will fail to spawn.}}
  
 
Velocity in the packet is always ignored.
 
Velocity in the packet is always ignored.
  
== Falling Block (id 70) ==
+
== [[Entity_metadata#Falling_Block|Falling Block]] ==
  
 
{| class="wikitable"
 
{| class="wikitable"
Line 72: Line 63:
 
  ! Field name
 
  ! Field name
 
  ! Field type
 
  ! Field type
! Example
 
 
  ! Notes
 
  ! Notes
 
  |-
 
  |-
  | Block type
+
  | Block state ID
  | Int
+
  | {{Type|Int}}
  | <code>12</code>
+
  | ID of the block state that the falling block will represent.
| <code><nowiki>BlockID | (Metadata << 12)</nowiki></code>
 
 
  |}
 
  |}
  
 
Velocity in the packet is always ignored.
 
Velocity in the packet is always ignored.
  
== Fishing Float (id 90) ==
+
== [[Entity_metadata#Fishing_Hook|Fishing Hook]] ==
  
 
{| class="wikitable"
 
{| class="wikitable"
 
  ! Field name
 
  ! Field name
 
  ! Field type
 
  ! Field type
! Example
 
 
  ! Notes
 
  ! Notes
 
  |-
 
  |-
 
  | Owner
 
  | Owner
  | Int
+
  | {{Type|Int}}
|
 
 
  | The entity ID of the owner
 
  | The entity ID of the owner
 
  |}
 
  |}
 +
 +
{{Warning|If the entity with the Owner ID doesn't exist in the client, the entity will fail to spawn.}}
  
 
Velocity in the packet is ignored, and instead should be inferred from the shooter's position.
 
Velocity in the packet is ignored, and instead should be inferred from the shooter's position.
Line 101: Line 90:
 
{{Need Info|What's the exact algorithm for determining this?}}
 
{{Need Info|What's the exact algorithm for determining this?}}
  
== Arrow (id 60) and Spectral Arrow (id 91) ==
+
== [[Entity_metadata#Projectile|Projectile]] ==
  
 
{| class="wikitable"
 
{| class="wikitable"
Line 107: Line 96:
 
  ! Field name
 
  ! Field name
 
  ! Field type
 
  ! Field type
! Example
 
 
  ! Notes
 
  ! Notes
 
  |-
 
  |-
  | Entity ID
+
  | Owner ID
  | Int
+
  | {{Type|Int}}
| <code>64</code>
+
  | The entity ID of the owner
  | The entity ID of the shooter + 1 (Subtract 1 to get the actual entity ID)
 
 
  |}
 
  |}
  
== Llama spit (id 68) ==
+
== [[Entity_metadata#Warden|Warden]] ==
  
Velocity is always used even though the data field is always 0.
+
{| class="wikitable"
 
+
|-
== Fireball (id 63), small fireball (id 64), dragon fireball (id 93), and wither skull (id 66) ==
+
! Field name
 
+
! Field type
The data field stores the ID of the shooting entity, or 0 if there was no shooting entity. Velocity is used even if data is set to 0.
+
  ! Notes
 
+
|-
== Shulker bullet (id 67) ==
+
| Pose
 
+
| {{Type|Int}}
Velocity is always used even though the data field is always 0.
+
| If a value of 1 is specified, the Warden will spawn in the [[Entity_metadata#Entity_Metadata_Format|emerging pose]].
 
+
Any other value is silently ignored.
== Potion (id 73) ==
+
|}
  
Velocity in the packet is always ignored.
 
 
== EXP bottle (id 75) ==
 
 
Velocity in the packet is always ignored.
 
  
 
[[Category:Protocol Details]]
 
[[Category:Protocol Details]]
 
[[Category:Minecraft Modern]]
 
[[Category:Minecraft Modern]]

Latest revision as of 22:32, 24 February 2024

This article documents the Data field in the Spawn Entity packet. The field is of type Int, and the meaning of its contents depend on the type of entity being spawned, as defined in the Type field of the same packet, and is documented below.

Item Frame

Value Orientation
0 Down
1 Up
2 North
3 South
4 West
5 East

The Notchian client clamps invalid values into the valid range through the modulus operator. If the resulting value is negative, the absolute value is used.

Velocity in the packet is always ignored.

Painting

Value Orientation
2 North
3 South
4 West
5 East

The Notchian client clamps invalid values into the valid range through the modulus operator. If the resulting value is negative, the absolute value is used.

Warning.png Although the values of 0 and 1 are invalid, the Notchian client uses the same clamping algorithm as Item Frame, which can result in any value from 0 to 5. If the resulting value is invalid, the entity will fail to spawn.

Velocity in the packet is always ignored.

Falling Block

Field name Field type Notes
Block state ID Int ID of the block state that the falling block will represent.

Velocity in the packet is always ignored.

Fishing Hook

Field name Field type Notes
Owner Int The entity ID of the owner

Warning.png If the entity with the Owner ID doesn't exist in the client, the entity will fail to spawn.

Velocity in the packet is ignored, and instead should be inferred from the shooter's position.

Huh.png The following information needs to be added to this page:
What's the exact algorithm for determining this?

Projectile

Field name Field type Notes
Owner ID Int The entity ID of the owner

Warden

Field name Field type Notes
Pose Int If a value of 1 is specified, the Warden will spawn in the emerging pose.

Any other value is silently ignored.