Inventory Format: Difference between revisions

From The Blockheads Wiki
(Create page)
 
m (Protected "Inventory Format": Advanced technical content ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite)))
 
(One intermediate revision by the same user not shown)
(No difference)

Latest revision as of 18:59, 16 December 2023

The Blockheads uses an interesting method to store Blockhead inventories. The inventories are encoded into a binary property list (plist) format, with each item represented by a specific struct in Objective-C++. This encoding process involves compressing the plist using zlib with a maximum window size (wbits) of 16. This page provides insights into the structure of Blockhead inventories and the tools available to parse and interpret them.

ItemSaveData Struct

The foundation of the inventory structure lies in the ItemSaveData struct, which is implemented in Objective-C++. This struct defines the properties associated with each item in the inventory.

@interface ItemSaveData : NSObject

@property (nonatomic, assign) uint16_t itemType;
@property (nonatomic, assign) uint16_t dataA;
@property (nonatomic, assign) uint16_t dataB;
@property (nonatomic, assign) uint8_t selectedSubItemIndex;
@property (nonatomic, assign) uint8_t padding;

@end
  • itemType: Represents the type of item.
  • dataA and dataB: Additional data associated with the item.
  • selectedSubItemIndex: Index of the selected sub-item.
  • padding: Additional padding for data alignment.

Encoding Process

  1. The ItemSaveData structs are populated with item information.
  2. These structs are then serialized into a binary plist.
  3. The binary plist is compressed using zlib with a max wbits of 16.

Sample Mac Server Inventory

A sample inventory in its binary form, extracted using Python:

b'\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\x13K*\xc8\xc9,.10X\xc1\xc8\xcc\xca\xcd\xcb\xc7/\xb0\x90\xc9\x83\x91\x01\x02\x16\xb2x\x0800\xb0\x82\x98K\xd9\xd898\xb9<l\x18\xea\x81\x90\xc1\x81\x18\xc6B\x1e\x0f\x1e\x889\x0e\x0b\x80\x80CPXFN]\xd7\xcc\xde#0*&5-=\x03"\xc7\x08\xb3L\x90\x01\x15d\x02\x00\xea$B\x0e\x9a\x00\x00\x00'

Parsing Tool Output

A tool has been developed to parse and interpret the inventory information. The output of the tool, based on the provided binary string, is as follows:

Item 1:
  Item Type: 1 (Clothing Slot)
  Data A: 0
  Data B: 0
  Selected Sub-Item Index: b'\x00'
  Padding: b'\x00'

Item 2:
  Item Type: 16 (Flint Spade)
  Data A: 1280
  Data B: 0
  Selected Sub-Item Index: b'\x00'
  Padding: b'\x00'

Item 3:
  Item Type: 60 (Orange)
  Data A: 127
  Data B: 127
  Selected Sub-Item Index: b'\x00'
  Padding: b'@'

Item 4:
  Item Type: 12 (Basket)
  Data A: 0
  Data B: 0
  Selected Sub-Item Index: b'\x00'
  Padding: b'@'

Item 5:
  This is an empty slot.

Item 6:
  This is an empty slot.

Item 7:
  This is an empty slot.

Item 8:
  This is an empty slot.