@@ -32,7 +32,7 @@ Modifying chunk packet data involved incompatibly modifying network packets, the
32
32
which is a lot of work for a simple feature. This mod provides a way to add custom data to chunks without having
33
33
to modify any of the vanilla classes yourself.
34
34
35
- Description
35
+ API and spec
36
36
-----------
37
37
38
38
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
60
60
You can also disable specific manager IDs by calling ` disableDataManager ` , but this is not recommended, and should
61
61
only be used if you know what you are doing. You need to do all the disabling inside the ` postInit ` phase.
62
62
63
- Alternatives
64
- ------------
63
+ ### Packet specification
65
64
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 .
68
67
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 |
71
100
72
- This mod will be tested by using it in my own mods, primarily EndlessIDs.
101
+ Manager data:
73
102
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 |
76
109
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.
80
110
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.
84
111
85
112
Dependencies
86
113
------------
0 commit comments