Skip to main content

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.

OffsetField NameField TypeNotes
0x00Transaction Countbe u32How 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.
0x04TransactionsTransaction[]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.

OffsetField NameField TypeNotes
0x00Uuidle u128The UUID of the newly equiped item. 00000000-0000-0000-0000-000000000000 when no item is equipped
0x10Tool Instance IDbe u32The instance ID of the newly equiped tool. Always 0xFFFFFFFF for items that are not tools or when no item is equipped.
0x14Quantitybe u16The amount of items in the item stack.
0x16Slotbe u16The index of slot in the container the item stack is located in.
0x18Container IDbe u32The ID of the container the item stack is in.

Transaction

The transaction structure has a variable size. Every Action ID has its own structure.

OffsetField NameField TypeNotes
0x00Actionenum Action : u8The type of the transaction.
0x01Action Data...The data of the action. This depends on the value of Action.

Action enum

note

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.

IDAction
0Set Item
1Swap
2Collect
3Spend
4Collect To Slot
5Collect To Slot Or Collect
6Spend From Slot
7Move
8Move From Slot
9Move All
OtherDefault 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.
OffsetField NameField TypeNotes
0x01ToItemStackThe item stack to set the slot in the container to.

Action 1 - Swap

  • Description: Swaps two item stacks. The From and To item stacks can be in two distinct containers.
  • Occurs when: Dragging an item onto another item. The containers of the From and To 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.
OffsetField NameField TypeNotes
0x01FromItemStack

The item stack of the dragged item.

  • Uuid: Always 00000000-0000-0000-0000-000000000000
  • Tool Instance ID: Always 0xFFFFFFFF
  • Quantity: Always 0
0x1DToItemStack

The item stack the dragged item is dropped onto.

  • Uuid: Always 00000000-0000-0000-0000-000000000000
  • Tool Instance ID: Always 0xFFFFFFFF
  • Quantity: Always 456

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.
OffsetField NameField TypeNotes
0x01Uuidle u128The UUID of the item to add to the container.
0x11Unknownbe u32Most 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.
0x15Quantitybe u16The amount of items to add to the container.
0x17Container IDbe u32The ID of the container to add the items to.
0x1BUnknownu8Not 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

note

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.
OffsetField NameField TypeNotes
0x01Uuidle u128The UUID of the item to remove from the container.
0x11Unknownbe u32Most 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.
0x15Quantitybe u16The amount of items to remove from the container.
0x17Container IDbe u32The ID of the container to remove the items to.
0x1BUnknownu8Could 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

note

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.
OffsetField NameField TypeNotes
0x01ToItemStackThe item stack collected into the slot of the container.
0x1DUnknownu8Could 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.
OffsetField NameField TypeNotes
0x01ToItemStackThe item stack collected into the slot of the container.
0x1DUnknownu8Not 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.
OffsetField NameField TypeNotes
0x01FromItemStackThe item stack removed from the slot of the container.
0x1DUnknownu8Not 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 and To 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.
OffsetField NameField TypeNotes
0x01FromItemStack

The item stack of the moved item.

  • Uuid: Always 00000000-0000-0000-0000-000000000000
  • Tool Instance ID: Always 0xFFFFFFFF
  • Quantity: The amount of items moved. Can be less than the total amount of items an item stack contains.
0x1DToItemStack

The empty slot the moved item is moved to.

  • Uuid: Always 00000000-0000-0000-0000-000000000000
  • Tool Instance ID: Always 0xFFFFFFFF
  • Quantity: Always 337
0x39Unknownu8Not 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.
OffsetField NameField TypeNotes
0x01From Slotbe u16The index of the slot to be moved to the other container.
0x03From Container IDbe u32The ID of the container of the slot to be moved.
0x07To Container IDbe u32The 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.
OffsetField NameField TypeNotes
0x01From Container IDbe u32The ID of the container to move all items from.
0x05To Container IDbe u32The 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.