Skip to content

Commit c887eb6

Browse files
committed
specced up
1 parent 5cd7f36 commit c887eb6

File tree

1 file changed

+43
-16
lines changed

1 file changed

+43
-16
lines changed

readme.md

Lines changed: 43 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Modifying chunk packet data involved incompatibly modifying network packets, the
3232
which is a lot of work for a simple feature. This mod provides a way to add custom data to chunks without having
3333
to modify any of the vanilla classes yourself.
3434

35-
Description
35+
API and spec
3636
-----------
3737

3838
The API exposes a way to add custom data to chunks, and a way to register custom serializers for the data.
@@ -60,27 +60,54 @@ This is where you actually register your manager. You need to do all registratio
6060
You can also disable specific manager IDs by calling `disableDataManager`, but this is not recommended, and should
6161
only be used if you know what you are doing. You need to do all the disabling inside the `postInit` phase.
6262

63-
Alternatives
64-
------------
63+
### Packet specification
6564

66-
Mods can also implement their own chunk-independent data storage, or even use hidden entities to store data, but
67-
this is not a good solution and prone to breaking.
65+
ChunkAPI modifies the S21PacketChunkData and S26PacketMapChunkBulk vanilla packets, and overwrites their default
66+
formats.
6867

69-
Testing
70-
-------
68+
All sizes in the tables below are specified in bytes.
69+
70+
S21PacketChunkData new format:
71+
72+
| Size (bytes) | Datatype | Name |
73+
|--------------|----------|----------------------------|
74+
| 4 | int | X position |
75+
| 4 | int | Z position |
76+
| 1 | bool | Force Update |
77+
| 2 | short | ExtendedBlockStorage mask |
78+
| 4 | int | Uncompressed data length |
79+
| 4 | int | (n) Compressed data length |
80+
| n | byte[n] | Compressed data |
81+
82+
S26PacketMapChunkBulk new format:
83+
84+
| Size (bytes) | Datatype | Name |
85+
|--------------|----------------------|---------------------------------|
86+
| 2 | short | (n) Chunk count in packet |
87+
| n * 4 | int[n] | Uncompressed chunk data lengths |
88+
| 4 | int | (m) Compressed data length |
89+
| 1 | 1 | Contains skylight data |
90+
| m | byte[m] | Compressed data |
91+
| n * 10 | (int, int, short)[n] | Chunk Headers (x, z, ebs mask) |
92+
93+
In both cases, the compressed data is populated through the ChunkDataRegistryImpl.writeToBuffer method.
94+
The layout of this data is as follows:
95+
96+
| Size (bytes) | Datatype | Name |
97+
|--------------|----------|-------------------|
98+
| 4 | int | (n) Manager count |
99+
| n * varying | MGRData | Manager data |
71100

72-
This mod will be tested by using it in my own mods, primarily EndlessIDs.
101+
Manager data:
73102

74-
Risks and Assumptions
75-
---------------------
103+
| Size (bytes) | Datatype | Name |
104+
|--------------|-----------|-------------------------|
105+
| 4 | int | (n) Manager name length |
106+
| n | UTF-8 str | Manager name |
107+
| 4 | int | (m) Manager data length |
108+
| m | byte[m] | Manager data |
76109

77-
This might slow down chunk loading/saving, and the networking, if the implementation turns out to be bad.
78-
Ideally, mods should declare their custom data as new fields in the chunk class using mixins instead of the
79-
ModdedChunk storage, but this is not a requirement.
80110

81-
Ideally, this project must not have any derivatives or forks, as that will counter the primary purpose of this project,
82-
which is a single, unified codebase for chunk data exchange. For that goal, the project is explicitly licensed such as
83-
no derivatives are permitted.
84111

85112
Dependencies
86113
------------

0 commit comments

Comments
 (0)