Container Transaction
This packet is sent when the player interacts with items inside of containers.
- ID: 0x20 (32)
- Size: Variable
- LZ4 Compressed: Yes
- State: Playing
- Bound To: Client -> Server
Structure
This structure has not been fully documented yet. The Transaction Count field might play a different part in this packet.
A Transaction Count of 0
denotes there is no transaction at all. This can be reproduced by opening the inventory of a container, pickup up an item and releasing it in the same slot. This works for most items, but bearings and controllers sometimes trigger a Swap transaction with itself. No pattern has been found to predict which items trigger this behaviour.
A Transaction Count of 1
denotes the packet contains one transaction. This is the most common case.
A Transaction Count of 2
appears to show undefined behaviour. The first transaction works like normal, but the second transaction will have an Action ID that does not seem to be related to anything. This can be reproduced by opening the inventory of a Gas Container, picking up Gasoline from the hotbar and releasing it in the same hotbar slot, all while being in unlimited inventory mode. This will give a second transaction with Action ID 2
. Doing the same with a Battery inside of a Battery Container results in ID 87
. Water gives ID 20
, Potato Ammo 65
, Fertilizer 51
, etc. A Transaction Count of 2
seems to only be possible for containers that have a filter applied. The Action ID is deterministically resolved from the item. A container that accepts multiple item UUIDs has a different Action ID for each item.
Other values of Transaction Count have not been seen.
Offset | Field Name | Field Type | Notes |
---|---|---|---|
0x00 | Transaction Count | be u32 | How many transactions are in the transaction array. Sizes 0 and 1 are documented. Size 2 seems to follow the same format, but no sense is made of the data. |
0x04 | Transactions | Transaction[] | The array of transactions. |
ItemStack
This structure is used by most transactions. It contains all information about an item and where it is located in which container.
Offset | Field Name | Field Type | Notes |
---|---|---|---|
0x00 | Uuid | le u128 | The UUID of the newly equiped item. 00000000-0000-0000-0000-000000000000 when no item is equipped |
0x10 | Tool Instance ID | be u32 | The instance ID of the newly equiped tool. Always 0xFFFFFFFF for items that are not tools or when no item is equipped. |
0x14 | Quantity | be u16 | The amount of items in the item stack. |
0x16 | Slot | be u16 | The index of slot in the container the item stack is located in. |
0x18 | Container ID | be u32 | The ID of the container the item stack is in. |
Transaction
The transaction structure has a variable size. Every Action ID has its own structure.
Offset | Field Name | Field Type | Notes |
---|---|---|---|
0x00 | Action | enum Action : u8 | The type of the transaction. |
0x01 | Action Data | ... | The data of the action. This depends on the value of Action. |
Action enum
The Action field has been left out in all of the following Action structures. The offsets still include the byte containing the action's ID.
ID | Action |
---|---|
0 | Set Item |
1 | Swap |
2 | Collect |
3 | Spend |
4 | Collect To Slot |
5 | Collect To Slot Or Collect |
6 | Spend From Slot |
7 | Move |
8 | Move From Slot |
9 | Move All |
Other | Default Action |
Action 0 - Set Item
- Description: Sets the item in the specified slot in the container to the item stack.
- Occurs when: Adding an item from the unlimited inventory into the hotbar. Both dragging the item as well as holding shift while clicking on the item will use this Action.
Offset | Field Name | Field Type | Notes |
---|---|---|---|
0x01 | To | ItemStack | The item stack to set the slot in the container to. |
Action 1 - Swap
- Description: Swaps two item stacks. The
From
andTo
item stacks can be in two distinct containers. - Occurs when: Dragging an item onto another item. The containers of the
From
andTo
item stacks must both be an unlimited inventory or both be a limited inventory. When one of the containers is an unlimited inventory and the other is a limited inventory, the Spend From Slot action will be used instead.
Offset | Field Name | Field Type | Notes |
---|---|---|---|
0x01 | From | ItemStack | The item stack of the dragged item.
|
0x1D | To | ItemStack | The item stack the dragged item is dropped onto.
|
Action 2 - Collect
- Description: Add an item to the container.
- Occurs when: Holding shift while clicking on an item in the player's unlimited inventory backpack.
Offset | Field Name | Field Type | Notes |
---|---|---|---|
0x01 | Uuid | le u128 | The UUID of the item to add to the container. |
0x11 | Unknown | be u32 | Most likely the tool instance ID, but it is always 0xFFFFFFFF , even for tools. The Lua API function sm.container.collect does not take any parameter that could result into this value being 0xFFFFFFFF . |
0x15 | Quantity | be u16 | The amount of items to add to the container. |
0x17 | Container ID | be u32 | The ID of the container to add the items to. |
0x1B | Unknown | u8 | Not known to be anything other than 0x80 . Could possibly be related to the mustCollectAll parameter of the sm.container.collect Lua API function. Its description reads: Must collect all items for the transaction to be valid. Defaults to true. (Optional) |
Action 3 - Spend
This action calls ContainerManager2.spend()
under the hood, but no usage of this action has been recorded. The documentation for this action has been reverse engineered from the executable.
- Description: Removes a quantity of a given item from a container.
- Occurs when: Unknown.
Offset | Field Name | Field Type | Notes |
---|---|---|---|
0x01 | Uuid | le u128 | The UUID of the item to remove from the container. |
0x11 | Unknown | be u32 | Most likely the tool instance ID. The Lua API function sm.container.spend does not take any other integer parameters, but after reverse engineering the executable we can assume this field is the same as the Collect action. |
0x15 | Quantity | be u16 | The amount of items to remove from the container. |
0x17 | Container ID | be u32 | The ID of the container to remove the items to. |
0x1B | Unknown | u8 | Could possibly be related to the mustSpendAll parameter of the sm.container.spend Lua API function. Its description reads: If true, only remove items if there are enough. If false, remove as many items as possible. Defaults to true. (Optional) |
Action 4 - Collect To Slot
This action calls ContainerManager2.collectToSlot()
under the hood, but no usage of this action has been recorded. The documentation for this action has been reverse engineered from the executable.
- Description: Adds an item to the specified slot of the container, up to the maximum stack size. The remaining number of items does not overflow to other slots.
- Occurs when: Unknown.
Offset | Field Name | Field Type | Notes |
---|---|---|---|
0x01 | To | ItemStack | The item stack collected into the slot of the container. |
0x1D | Unknown | u8 | Could possibly be related to the mustCollectAll parameter of the sm.container.collectToSlot Lua API function. Its description reads: If true, only add items if there is enough room. If false, add as many items as possible. Defaults to true. (Optional) |
Action 5 - Collect To Slot Or Collect
- Description: Adds an item to the specified slot of the container. If the maximum stack size is reached, the remaining number of items will overflow into following slots when possible.
- Occurs when: Dragging an item from the player's unlimited inventory backpack into a limited inventory container.
Offset | Field Name | Field Type | Notes |
---|---|---|---|
0x01 | To | ItemStack | The item stack collected into the slot of the container. |
0x1D | Unknown | u8 | Not known to be anything other than 0x00 . Could possibly be related to the mustCollectAll parameter of the sm.container.collectToSlot Lua API function. Its description reads: If true, only add items if there is enough room. If false, add as many items as possible. Defaults to true. (Optional) |
Action 6 - Spend From Slot
- Description: Removes an item from the specified slot of the container.
- Occurs when: Dragging an item from the limited inventory container into the player's unlimited inventory backpack.
Offset | Field Name | Field Type | Notes |
---|---|---|---|
0x01 | From | ItemStack | The item stack removed from the slot of the container. |
0x1D | Unknown | u8 | Not known to be anything other than 0x00 . Could possibly be related to the mustSpendAll parameter of the sm.container.spendFromSlot Lua API function. Its description reads: If true, only remove items if there are enough. If false, remove as many items as possible. Defaults to true. (Optional) |
Action 7 - Move
- Description: Moves an item stack to an empty slot of a container. The
From
andTo
item stacks can be in two distinct containers. - Occurs when: If the player has a limited inventory, dragging an item onto an empty slot of a container, or holding shift while clicking on an item to move the item between the hotbar and the backpack.
If the player has an unlimited inventory container, the Move action is only used when moving items from the hotbar to another empty hotbar slot while the backpack is open. Opening the GUI of another container and then dragging an item from the hotbar to another empty hotbar slot will use the Spend From Slot action instead.
Offset | Field Name | Field Type | Notes |
---|---|---|---|
0x01 | From | ItemStack | The item stack of the moved item.
|
0x1D | To | ItemStack | The empty slot the moved item is moved to.
|
0x39 | Unknown | u8 | Not known to be anything other than 0x00 . |
Action 8 - Move From Slot
- Description: Moves an item stack in the specified slot to another container.
- Occurs when: Holding shift while clicking on an item. Both containers must be limited inventory containers.
Offset | Field Name | Field Type | Notes |
---|---|---|---|
0x01 | From Slot | be u16 | The index of the slot to be moved to the other container. |
0x03 | From Container ID | be u32 | The ID of the container of the slot to be moved. |
0x07 | To Container ID | be u32 | The ID of the container to move the slot to. |
Action 9 - Move All
- Description: Moves all items from one container to another container.
- Occurs when: Pressing the "TAKE ALL" button in the GUI of the bag a player leaves behind when respawning after death.
Offset | Field Name | Field Type | Notes |
---|---|---|---|
0x01 | From Container ID | be u32 | The ID of the container to move all items from. |
0x05 | To Container ID | be u32 | The ID of the container to move all items to. |
Default Action
In some cases a transaction with an action outside of the 0 to 9 range is created. The game treats these actions the same as Action 7 - Move.