Skip to content

Entities

Lakeland97 edited this page Oct 30, 2026 · 4 revisions

Entities

model.entity.ModelEntity wire body, session datastore, template resolution, and component construction. Entities arrive only as branch-B pushes: the updatedEntities elements of a DataStoreUpdateResponse (Protocol).

The seven-value body

ModelEntity.hxUnserialize (FUN_1408953f0) reads exactly seven top-level values:

# value stored at note
1 instanceID (String) +0x10/+0x18 inline String; the entity's name and datastore key
2 templateID (String) +0x28/+0x30 e.g. "player", "account"
3 StringMap +0x38 property bag; {} is safe
4 value +0x78 used only through a guarded virtual call for a length
5 ModelEntityEvent +0xA0/+0xA8 walked list, null-guarded
6 count-like value — role [UNK]
7 String +0x50/+0x58 the entity's stored componentHash

+0x40 is a one-byte bool written by the awaken path; +0x48 is the component Array, not part of the wire body and initialised empty.

["devuser", "player", {}, null, null, null, ""]

The seventh value must be a String, not null, because it passes through the StringData extractor FUN_14053d960; the empty string is the safe filler. Values appended after the seventh (GUL_DSUR_HX_TAIL) cannot supply the hash, so TAIL=0. Filler past the seventh reports Invalid class data for instance of model.entity.ModelEntity at pos N instead of Invalid char g; N minus the known values gives the arity, seven (Protocol).

Store semantics

model.db.SessionDataStore is a named blob store (getBlob, hasBlob, createBlob, setBlob, listenForChanges over m_cache).

  • There is no local entity factory. createBlob (FUN_140c105b0) and setBlob (FUN_140c10700) only store caller objects and reject duplicates/nulls; the read path is a map lookup. Only a branch-B push creates a ModelEntity.
  • A miss is reported as <key> not in the datastore: FUN_140c10400 builds the message from the key, and the literal has a leading space, so the phrase is never one literal in .rdata.
  • The player key is its playerIID, and the client asks for it after accounts: the failure progresses from accounts not in the datastore to devuser not in the datastore.

Templates

Generated/templates.tplc (a client asset) decodes through the file's shared type cache; the decoder finds 1,439 template IDs.

template file offset length componentHash definitions
account 0x3059D (198,045) 36 ab4939221e37ec0a4fc6c99fbde9012b529fa951 AccountComponent (autoConstruct, empty templateData)
player 0x305C1 (198,081) 4,296 328fadb2c851af2a4118350bb22021f0756a5a8c five components (below)

The hashes are radix strings, not literal bytes: the payload references node 4040, whose chain is 4039:"3" → 4040:"28fadb2c851af2a4118350bb22021f0756a5a8c". A byte search for the hash text finds nothing.

player's five autoConstruct definitions:

component templateData
model.component.player.PlayerComponent empty array
model.component.player.PlayerUpgradeComponent empty array
model.component.player.PlayerCosmeticsComponent 2 ComponentPropertyDefinition
model.component.inventory.InventoryComponent 7 definitions
model.component.advancement.AdvancementComponent 2 definitions

No template declares a ContainerComponent, and there is no fake-player template; account is the only account-shaped template.

Template resolution

FUN_140896730 fetches the template by the entity's templateID (entity+0x28/+0x30) and compares the entity's stored hash (entity+0x50/+0x58) with the template's componentHash (template+0x28/+0x30):

  • Equal → return block at 0x140896d08: return the Success constant DAT_143bc57e0 and skip component creation. The entity carries no components.
  • Different or empty → construct every autoConstruct definition from the template and add it to the entity.

A usable player entity therefore needs a non-matching hash, since the wire body cannot carry inline components; the empty seventh value is the simplest non-match.

account declares only AccountComponent with empty templateData, so [DER] ["<iid>", "account", {}, null, null, null, ""] constructs the component through the same path. No observed login path needs it; the startSession accounts arrive in the session context (Login).

Component construction

FUN_1408938f0 resolves one definition: it looks up the class by name, reads the definition's templateData, and returns a component instance. A missing class, definition or templateData logs Type template data not found, returns null, and FUN_140896730 pushes that null and calls its vtable entry +0x128 — an access violation at address 0 with no named error. That is the "Null Function Pointer" crash: a content error, cleared by using a template ID that exists.

FUN_1410583a0 applies a definition's properties:

  1. always sets component+0x8 = entity;
  2. reads the property count at templateData+8 and does nothing for an empty array;
  3. per property, reads ComponentPropertyDefinition (property, value, plus hash/serialize helpers) and resolves TemplateParameter values against entity+0x38;
  4. calls FUN_140870250 → the component's __SetField (vtable +0x80) with (name, value, 2).

An unknown property name falls through to FUN_14053ab40, which throws a C++ exception with Invalid field:<name>. A wrong-shaped templateData crashes earlier inside FUN_1410583a0 with no named error.

Property → field mapping (from the __SetField overrides):

component property field
PlayerComponent gender +0x10 enum
skinTone +0x18 string
redeemedBundles +0x28 EnumValueMap
playerID +0x30 string
accountProvider +0x40 AccountProvider
PlayerUpgradeComponent version +0x10 int
PlayerCosmeticsComponent defaultCosmetics +0x10 StringMap (9 ids)
requiredSlots +0x18 Array (9 CosmeticSlot)
equippedCosmetics +0x20 EnumValueMap
InventoryComponent startingItemEntries +0xA0 (48 StartingItemEntry)
steamItemEntries +0xA8 (252850, 531810)
twitchItemEntries +0xB0
maxEntities +0xB8 = 100001
inventoryTypes / maxSizeByType / soft limits +0xC0…+0xD8
AdvancementComponent xp +0x10
levelEntries +0x18 (50 levels)
maxLevel +0x20 = 50

PlayerComponent and PlayerUpgradeComponent get no template properties; the constructor defaults (gender, skinTone, redeemedBundles, RNG, version = 3) stand. Only playerID and accountProvider stay null, and the construction/awaken hooks do not dereference them.

Components are not pushable

updatedEntities[i] is one serialized object, inflated independently, but a component is not a valid element:

  • A standalone AccountComponent element crashed the push with complete fields.
  • The consumer's element shape is a DSUR-shaped object whose first field is an array and whose string sits at +0x10/+0x18; ModelEntity takes its components from the template, not from the wire (Protocol).
  • Inline component instances inside the entity body are not read: body values 3–7 are the StringMap, the guarded value, the event, a count and the hash.

Supported shape: one entity per element, a real template ID, a non-matching hash, and the template builds the components.

AccountComponent

Six fields, from the hxcpp name table beside the class literal:

icons  pgsToken  renamedTo  linkedAccount  isSecondaryAccount  overriddenPlayerIID

The client validates declared field names against the real class, so a declaration with a different set fails immediately.

Clone this wiki locally