📡 Network Synchronization & Payloads (Minecraft 26.2)
📌 Repository Source Disclaimer: The documentation in this Wiki reflects the current source code state in the repository, which may include recent unreleased commits or developmental features ahead of public release builds on CurseForge and Modrinth.
1. Official Infobox
| Parameter | Technical Details |
|---|---|
| Subsystem Name | Network Synchronization Protocol |
| Payload Class | StewLimitSyncPayload.java |
| Payload Identifier | stew-stacker:sync_limit |
| Protocol Phase | Play (clientbound S2C) |
| Codec Implementation | StreamCodec<RegistryFriendlyByteBuf, StewLimitSyncPayload> |
| Client Receiver | StewStackerFabricClient.java |
| Server Dispatch Events | ServerPlayConnectionEvents.JOIN, ServerLifecycleEvents.SERVER_STARTED, DynamicGameRuleManager listener |
| Menu Synchronization | broadcastFullState() on containerMenu and inventoryMenu |
2. Step-by-Step Player Workflow & Synchronization Lifecycle
Initial Player Connection (Handshake): When a player connects to the dedicated server,
ServerPlayConnectionEvents.JOINtriggers. The server queries the current activestewLimitfromStewStackerManagerand dispatches aStewLimitSyncPayloadto the connecting client.Client-Side State Storage: Upon packet receipt on the client,
StewStackerFabricClientschedules a task on the Minecraft client render thread (context.client().execute(...)) to updateStewStackerManager.setClientLimit(payload.stewLimit()). This guarantees that client-side item stack rendering and slot previews reflect the server's authoritative state.In-Game Administrator Mutation: An administrator executes
/gamerule stew-stacker-addon:stew_limit 32.DynamicGameRuleManagerdetects the value change and invokesStewStackerManager.setLimit(...).Full Multi-Client Broadcast & Menu Refresh: The server iterates through all online players (
server.getPlayerList().getPlayers()), dispatchesStewLimitSyncPayload, and invokesbroadcastFullState()on every player's open container and inventory menus, instantly forcing the client to re-render slot contents without ghost items.
3. Mathematical Formulas & Network Bandwidth
Payload Byte Size Calculation ($B$)
stewLimit is serialized via ByteBufCodecs.VAR_INT. A Minecraft VarInt encodes 7 bits of data per byte with the 8th bit reserved as continuation flag: $$\text{VarIntBytes}(v) = \begin{cases} 1 & 0 \le v \le 127 \ 2 & 128 \le v \le 16{,}383 \ 3 & 16{,}384 \le v \le 2{,}097{,}151 \ 4 & 2{,}097{,}152 \le v \le 268{,}435{,}455 \ 5 & 268{,}435{,}456 \le v \le 2{,}147{,}483{,}647 \end{cases}$$
The total packet payload size $B$ in bytes is: $$B = \text{VarIntBytes}(S_{\text{limit}})$$
For default settings ($S = 16$): $$B = 1\text{ byte}$$
Even at the maximum safe limit ($39{,}768{,}215$): $$B = 4\text{ bytes}$$
Network overhead is effectively $O(1)$ and negligible across all network environments.
4. Visual ASCII Diagrams & Packet Lifecycle
Player Join Handshake Protocol
[ Client ] [ Dedicated Server ]
| |
|----------------- C2S Login / Handshake -------------------->|
| |
| ServerPlayConnectionEvents.JOIN
| |
| Query StewStackerManager
| sLimit=16
| |
|<--- S2C StewLimitSyncPayload(16) ---------------------------|
|
Receive Packet
context.client().execute()
StewStackerManager.setClientLimit(16)
|
Client GUI & Tooltips SynchronizedLive Dynamic GameRule Update & State Refresh
[ Server Admin: /gamerule stew-stacker-addon:stew_limit 64 ]
|
v
StewStackerManager.setLimit(64, server)
|
+---------------+---------------+
| |
v v
Send StewLimitSyncPayload For every ServerPlayer:
to all connected players containerMenu.broadcastFullState()
inventoryMenu.broadcastFullState()
|
v
Eliminates Ghost Items & Resets Caches5. Packet Buffer Layout & Codec Schema
Binary Packet Byte Stream Layout:
+------------------------------------+
| Field 1: stewLimit (VarInt) |
| Range: 1 .. 2,147,483,647 (1-5 B) |
+------------------------------------+Codec Definition (StewLimitSyncPayload.java):
public static final StreamCodec<RegistryFriendlyByteBuf, StewLimitSyncPayload> CODEC = StreamCodec.composite(
ByteBufCodecs.VAR_INT,
StewLimitSyncPayload::stewLimit,
StewLimitSyncPayload::new
);6. Exhaustive Reference Matrix
| Attribute | Value | Description |
|---|---|---|
| Payload Identifier | stew-stacker:sync_limit | CustomPacketPayload.Type identifier |
| Network Channel | clientboundPlay | Registered via PayloadTypeRegistry |
| Field 0 | stewLimit (int) | Maximum stack limit for stews/soups |
| Execution Thread | Main Client Render Thread | Dispatched via context.client().execute() |
| Trigger 1 | Player Join | ServerPlayConnectionEvents.JOIN |
| Trigger 2 | Server Started | ServerLifecycleEvents.SERVER_STARTED |
| Trigger 3 | GameRule Mutation | StewStackerManager.setLimit |
| Menu Sync Hook | broadcastFullState() | Forces client inventory slot cache refresh |
7. Developer & Network Hooks
Payload Registration (StewStackerFabric.java):
PayloadTypeRegistry.clientboundPlay().register(
StewLimitSyncPayload.TYPE,
StewLimitSyncPayload.CODEC
);Client Receiver Registration (StewStackerFabricClient.java):
ClientPlayNetworking.registerGlobalReceiver(StewLimitSyncPayload.TYPE, (payload, context) -> {
context.client().execute(() -> {
StewStackerManager.setClientLimit(payload.stewLimit());
});
});