Skip to content

Conversation

@Ukinee
Copy link

@Ukinee Ukinee commented Dec 15, 2025

Implementation of (some) Structured Components in InventorySlot.
Client no longer crashes from creative menu items.

Todo:

  • Implement other components
    • Implement TextComponent
    • Implement Identifier
  • Write tests for components encoding/decoding roundrip
  • Rewrite codegen to macro?
  • Add values validation
  • Add enums

I HAD TO MODIFY THE `test_slot_encode_decode_roundtrip` DUE TO ASYMMETRIC PROTOCOL FOR COMPONENTS

When decoding client data, the client sends an extra byte after the component ID.

What the client sends:

55 0 40 1 180 8 1 0 42 5 1 24 0 0 0

where

55 0 40 1 180 8 1 0 // slot data
42 // component id (potion effect)
5 // undocumented byte (i think its length prefix for payload)
1 24 0 0 0 // component payload

However, when sending data to client, it is expected to be encoded exactly as documented:

55 0 40 1 180 8 1 0 42 1 24 0 0 0

If the length byte is included in server to client packets, the client crashes with a decoding error.

But the test expects the protocol to be symmetric (tests object -> bytes -> object), so it crashes when it tries to read more bytes than are available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant