1 /*
2  * This file has been automatically generated by Soupply and released under the MIT license.
3  * Generated from data/bedrock201.xml
4  */
5 module soupply.bedrock201.types;
6 
7 static import std.conv;
8 import xpacket;
9 
10 import xserial.serial : EndianType, serializeLength, deserializeLength;
11 
12 import xbuffer.memory : xalloc, xfree;
13 
14 import soupply.util;
15 import soupply.bedrock201.metadata;
16 
17 struct LoginBody
18 {
19 
20     private struct Container
21     {
22 
23         enum string[] __fields = ["chain", "clientData"];
24 
25         @Length!uint ubyte[] chain;
26         @Length!uint ubyte[] clientData;
27 
28         mixin Make!(Endian.littleEndian, varuint);
29 
30     }
31 
32     enum string[] __fields = Container.__fields;
33 
34     Container _container;
35 
36     alias _container this;
37 
38     void serialize(Buffer buffer)
39     {
40         Buffer _buffer = xalloc!Buffer(Container.sizeof + 4);
41         _container.encodeBody(_buffer);
42         serializeLength!(EndianType.var, uint)(buffer, _buffer.data!ubyte.length);
43         buffer.writeData(_buffer.data!ubyte);
44         xfree(_buffer);
45     }
46 
47     void deserialize(Buffer buffer)
48     {
49         Buffer _buffer = xalloc!Buffer(cast(ubyte[])buffer.readData(deserializeLength!(EndianType.var, uint)(buffer)));
50         _container.decodeBody(_buffer);
51         xfree(_buffer);
52     }
53 
54     string toString()
55     {
56         return "LoginBody(chain: " ~ std.conv.to!string(this.chain) ~ ", clientData: " ~ std.conv.to!string(this.clientData) ~ ")";
57     }
58 
59 }
60 
61 struct PackWithSize
62 {
63 
64     enum string[] __fields = ["id", "version_", "size", "unknown3", "unknown4"];
65 
66     string id;
67     string version_;
68     ulong size;
69     string unknown3;
70     string unknown4;
71 
72     mixin Make!(Endian.littleEndian, varuint);
73 
74     string toString()
75     {
76         return "PackWithSize(id: " ~ std.conv.to!string(this.id) ~ ", version_: " ~ std.conv.to!string(this.version_) ~ ", size: " ~ std.conv.to!string(this.size) ~ ", unknown3: " ~ std.conv.to!string(this.unknown3) ~ ", unknown4: " ~ std.conv.to!string(this.unknown4) ~ ")";
77     }
78 
79 }
80 
81 struct Pack
82 {
83 
84     enum string[] __fields = ["id", "version_", "unknown2"];
85 
86     string id;
87     string version_;
88     string unknown2;
89 
90     mixin Make!(Endian.littleEndian, varuint);
91 
92     string toString()
93     {
94         return "Pack(id: " ~ std.conv.to!string(this.id) ~ ", version_: " ~ std.conv.to!string(this.version_) ~ ", unknown2: " ~ std.conv.to!string(this.unknown2) ~ ")";
95     }
96 
97 }
98 
99 struct Slot
100 {
101 
102     enum string[] __fields = ["id", "metaAndCount", "nbt", "canPlaceOn", "canDestroy"];
103 
104     @Var int id;
105     @Condition("id>0") @Var int metaAndCount;
106     @Condition("id>0") @Length!ushort ubyte[] nbt;
107     string[] canPlaceOn;
108     string[] canDestroy;
109 
110     mixin Make!(Endian.littleEndian, varuint);
111 
112     string toString()
113     {
114         return "Slot(id: " ~ std.conv.to!string(this.id) ~ ", metaAndCount: " ~ std.conv.to!string(this.metaAndCount) ~ ", nbt: " ~ std.conv.to!string(this.nbt) ~ ", canPlaceOn: " ~ std.conv.to!string(this.canPlaceOn) ~ ", canDestroy: " ~ std.conv.to!string(this.canDestroy) ~ ")";
115     }
116 
117 }
118 
119 struct Attribute
120 {
121 
122     enum string[] __fields = ["min", "max", "value", "default_", "name"];
123 
124     float min;
125     float max;
126     float value;
127     float default_;
128     string name;
129 
130     mixin Make!(Endian.littleEndian, varuint);
131 
132     string toString()
133     {
134         return "Attribute(min: " ~ std.conv.to!string(this.min) ~ ", max: " ~ std.conv.to!string(this.max) ~ ", value: " ~ std.conv.to!string(this.value) ~ ", default_: " ~ std.conv.to!string(this.default_) ~ ", name: " ~ std.conv.to!string(this.name) ~ ")";
135     }
136 
137 }
138 
139 struct BlockPosition
140 {
141 
142     enum string[] __fields = ["x", "y", "z"];
143 
144     @Var int x;
145     @Var uint y;
146     @Var int z;
147 
148     mixin Make!(Endian.littleEndian, varuint);
149 
150     string toString()
151     {
152         return "BlockPosition(x: " ~ std.conv.to!string(this.x) ~ ", y: " ~ std.conv.to!string(this.y) ~ ", z: " ~ std.conv.to!string(this.z) ~ ")";
153     }
154 
155 }
156 
157 struct McpeUuid
158 {
159 
160     enum string[] __fields = ["mostSignificantBits", "leastSignificantBits"];
161 
162     long mostSignificantBits;
163     long leastSignificantBits;
164 
165     mixin Make!(Endian.littleEndian, varuint);
166 
167     string toString()
168     {
169         return "McpeUuid(mostSignificantBits: " ~ std.conv.to!string(this.mostSignificantBits) ~ ", leastSignificantBits: " ~ std.conv.to!string(this.leastSignificantBits) ~ ")";
170     }
171 
172 }
173 
174 struct PlayerList
175 {
176 
177     enum string[] __fields = ["uuid", "entityId", "displayName", "skin", "unknown4"];
178 
179     soupply.bedrock201.types.McpeUuid uuid;
180     @Var long entityId;
181     string displayName;
182     soupply.bedrock201.types.Skin skin;
183     string unknown4;
184 
185     mixin Make!(Endian.littleEndian, varuint);
186 
187     string toString()
188     {
189         return "PlayerList(uuid: " ~ std.conv.to!string(this.uuid) ~ ", entityId: " ~ std.conv.to!string(this.entityId) ~ ", displayName: " ~ std.conv.to!string(this.displayName) ~ ", skin: " ~ std.conv.to!string(this.skin) ~ ", unknown4: " ~ std.conv.to!string(this.unknown4) ~ ")";
190     }
191 
192 }
193 
194 struct Skin
195 {
196 
197     enum string[] __fields = ["name", "data", "capeData", "geometryName", "geometryData"];
198 
199     string name;
200     ubyte[] data;
201     ubyte[] capeData;
202     string geometryName;
203     ubyte[] geometryData;
204 
205     mixin Make!(Endian.littleEndian, varuint);
206 
207     string toString()
208     {
209         return "Skin(name: " ~ std.conv.to!string(this.name) ~ ", data: " ~ std.conv.to!string(this.data) ~ ", capeData: " ~ std.conv.to!string(this.capeData) ~ ", geometryName: " ~ std.conv.to!string(this.geometryName) ~ ", geometryData: " ~ std.conv.to!string(this.geometryData) ~ ")";
210     }
211 
212 }
213 
214 struct Link
215 {
216 
217     // action
218     enum ubyte ADD = 0;
219     enum ubyte RIDE = 1;
220     enum ubyte REMOVE = 2;
221 
222     enum string[] __fields = ["from", "to", "action", "unknown3"];
223 
224     @Var long from;
225     @Var long to;
226     ubyte action;
227     ubyte unknown3;
228 
229     mixin Make!(Endian.littleEndian, varuint);
230 
231     string toString()
232     {
233         return "Link(from: " ~ std.conv.to!string(this.from) ~ ", to: " ~ std.conv.to!string(this.to) ~ ", action: " ~ std.conv.to!string(this.action) ~ ", unknown3: " ~ std.conv.to!string(this.unknown3) ~ ")";
234     }
235 
236 }
237 
238 struct Recipe
239 {
240 
241     // type
242     enum int SHAPELESS = 0;
243     enum int SHAPED = 1;
244     enum int FURNACE = 2;
245     enum int FURNACE_DATA = 3;
246     enum int MULTI = 4;
247 
248     enum string[] __fields = ["type", "data"];
249 
250     @Var int type;
251     @NoLength ubyte[] data;
252 
253     mixin Make!(Endian.littleEndian, varuint);
254 
255     string toString()
256     {
257         return "Recipe(type: " ~ std.conv.to!string(this.type) ~ ", data: " ~ std.conv.to!string(this.data) ~ ")";
258     }
259 
260 }
261 
262 struct InventoryAction
263 {
264 
265     // source
266     enum uint CONTAINER = 0;
267     enum uint WORLD = 2;
268     enum uint CREATIVE = 3;
269 
270     enum string[] __fields = ["source", "container", "unknown2", "slot", "oldItem", "newItem"];
271 
272     @Var uint source;
273     @Condition("source==0") @Var int container = -1;
274     @Condition("source==2") @Var uint unknown2;
275     @Var uint slot;
276     soupply.bedrock201.types.Slot oldItem;
277     soupply.bedrock201.types.Slot newItem;
278 
279     mixin Make!(Endian.littleEndian, varuint);
280 
281     string toString()
282     {
283         return "InventoryAction(source: " ~ std.conv.to!string(this.source) ~ ", container: " ~ std.conv.to!string(this.container) ~ ", unknown2: " ~ std.conv.to!string(this.unknown2) ~ ", slot: " ~ std.conv.to!string(this.slot) ~ ", oldItem: " ~ std.conv.to!string(this.oldItem) ~ ", newItem: " ~ std.conv.to!string(this.newItem) ~ ")";
284     }
285 
286 }
287 
288 struct ChunkData
289 {
290 
291     private struct Container
292     {
293 
294         enum string[] __fields = ["sections", "heights", "biomes", "borders", "extraData", "blockEntities"];
295 
296         soupply.bedrock201.types.Section[] sections;
297         ushort[256] heights;
298         ubyte[256] biomes;
299         ubyte[] borders;
300         soupply.bedrock201.types.ExtraData[] extraData;
301         @NoLength ubyte[] blockEntities;
302 
303         mixin Make!(Endian.littleEndian, varuint);
304 
305     }
306 
307     enum string[] __fields = Container.__fields;
308 
309     Container _container;
310 
311     alias _container this;
312 
313     void serialize(Buffer buffer)
314     {
315         Buffer _buffer = xalloc!Buffer(Container.sizeof + 4);
316         _container.encodeBody(_buffer);
317         serializeLength!(EndianType.var, uint)(buffer, _buffer.data!ubyte.length);
318         buffer.writeData(_buffer.data!ubyte);
319         xfree(_buffer);
320     }
321 
322     void deserialize(Buffer buffer)
323     {
324         Buffer _buffer = xalloc!Buffer(cast(ubyte[])buffer.readData(deserializeLength!(EndianType.var, uint)(buffer)));
325         _container.decodeBody(_buffer);
326         xfree(_buffer);
327     }
328 
329     string toString()
330     {
331         return "ChunkData(sections: " ~ std.conv.to!string(this.sections) ~ ", heights: " ~ std.conv.to!string(this.heights) ~ ", biomes: " ~ std.conv.to!string(this.biomes) ~ ", borders: " ~ std.conv.to!string(this.borders) ~ ", extraData: " ~ std.conv.to!string(this.extraData) ~ ", blockEntities: " ~ std.conv.to!string(this.blockEntities) ~ ")";
332     }
333 
334 }
335 
336 struct Section
337 {
338 
339     enum string[] __fields = ["storageVersion", "blockIds", "blockMetas"];
340 
341     ubyte storageVersion = 0;
342     ubyte[4096] blockIds;
343     ubyte[2048] blockMetas;
344 
345     mixin Make!(Endian.littleEndian, varuint);
346 
347     string toString()
348     {
349         return "Section(storageVersion: " ~ std.conv.to!string(this.storageVersion) ~ ", blockIds: " ~ std.conv.to!string(this.blockIds) ~ ", blockMetas: " ~ std.conv.to!string(this.blockMetas) ~ ")";
350     }
351 
352 }
353 
354 struct ExtraData
355 {
356 
357     enum string[] __fields = ["key", "value"];
358 
359     @Var uint key;
360     ushort value;
361 
362     mixin Make!(Endian.littleEndian, varuint);
363 
364     string toString()
365     {
366         return "ExtraData(key: " ~ std.conv.to!string(this.key) ~ ", value: " ~ std.conv.to!string(this.value) ~ ")";
367     }
368 
369 }
370 
371 struct Decoration
372 {
373 
374     enum string[] __fields = ["rotationAndIcon", "position", "label", "color"];
375 
376     @Var int rotationAndIcon;
377     Vector!(ubyte, "xz") position;
378     string label;
379     uint color;
380 
381     mixin Make!(Endian.littleEndian, varuint);
382 
383     string toString()
384     {
385         return "Decoration(rotationAndIcon: " ~ std.conv.to!string(this.rotationAndIcon) ~ ", position: " ~ std.conv.to!string(this.position) ~ ", label: " ~ std.conv.to!string(this.label) ~ ", color: " ~ std.conv.to!string(this.color) ~ ")";
386     }
387 
388 }
389 
390 struct Rule
391 {
392 
393     // name
394     enum string COMMAND_BLOCK_OUTPUT = "commandblockoutput";
395     enum string DO_DAYLIGHT_CYCLE = "dodaylightcycle";
396     enum string DO_ENTITY_DROPS = "doentitydrops";
397     enum string DO_FIRE_TICK = "dofiretick";
398     enum string DO_MOB_LOOT = "domobloot";
399     enum string DO_MOB_SPAWNING = "domobspawning";
400     enum string DO_TILE_DROPS = "dotiledrops";
401     enum string DO_WEATHER_CYCLE = "doweathercycle";
402     enum string DROWNING_DAMAGE = "drowningdamage";
403     enum string FALL_DAMAGE = "falldamage";
404     enum string FIRE_DAMAGE = "firedamage";
405     enum string KEEP_INVENTORY = "keepinventory";
406     enum string MOB_GRIEFING = "mobgriefing";
407     enum string PVP = "pvp";
408     enum string SEND_COMMAND_FEEDBACK = "sendcommandfeedback";
409 
410     // type
411     enum ubyte BOOLEAN = 1;
412     enum ubyte INTEGER = 2;
413     enum ubyte FLOATING = 3;
414 
415     enum string[] __fields = ["name", "type", "booleanValue", "integerValue", "floatingValue"];
416 
417     string name;
418     ubyte type;
419     @Condition("type==1") bool booleanValue;
420     @Condition("type==2") @Var uint integerValue;
421     @Condition("type==3") float floatingValue;
422 
423     mixin Make!(Endian.littleEndian, varuint);
424 
425     string toString()
426     {
427         return "Rule(name: " ~ std.conv.to!string(this.name) ~ ", type: " ~ std.conv.to!string(this.type) ~ ", booleanValue: " ~ std.conv.to!string(this.booleanValue) ~ ", integerValue: " ~ std.conv.to!string(this.integerValue) ~ ", floatingValue: " ~ std.conv.to!string(this.floatingValue) ~ ")";
428     }
429 
430 }
431 
432 struct Enum
433 {
434 
435     enum string[] __fields = ["name", "valuesIndexes"];
436 
437     string name;
438     ushort[] valuesIndexes;
439 
440     mixin Make!(Endian.littleEndian, varuint);
441 
442     string toString()
443     {
444         return "Enum(name: " ~ std.conv.to!string(this.name) ~ ", valuesIndexes: " ~ std.conv.to!string(this.valuesIndexes) ~ ")";
445     }
446 
447 }
448 
449 struct Command
450 {
451 
452     enum string[] __fields = ["name", "description", "unknown2", "permissionLevel", "aliasesEnum", "overloads"];
453 
454     string name;
455     string description;
456     ubyte unknown2;
457     ubyte permissionLevel;
458     int aliasesEnum = -1;
459     soupply.bedrock201.types.Overload[] overloads;
460 
461     mixin Make!(Endian.littleEndian, varuint);
462 
463     string toString()
464     {
465         return "Command(name: " ~ std.conv.to!string(this.name) ~ ", description: " ~ std.conv.to!string(this.description) ~ ", unknown2: " ~ std.conv.to!string(this.unknown2) ~ ", permissionLevel: " ~ std.conv.to!string(this.permissionLevel) ~ ", aliasesEnum: " ~ std.conv.to!string(this.aliasesEnum) ~ ", overloads: " ~ std.conv.to!string(this.overloads) ~ ")";
466     }
467 
468 }
469 
470 struct Overload
471 {
472 
473     enum string[] __fields = ["parameters"];
474 
475     soupply.bedrock201.types.Parameter[] parameters;
476 
477     mixin Make!(Endian.littleEndian, varuint);
478 
479     string toString()
480     {
481         return "Overload(parameters: " ~ std.conv.to!string(this.parameters) ~ ")";
482     }
483 
484 }
485 
486 struct Parameter
487 {
488 
489     // type
490     enum uint VALID = 1048576;
491     enum uint INT = 1;
492     enum uint FLOAT = 2;
493     enum uint MIXED = 3;
494     enum uint TARGET = 4;
495     enum uint STRING = 13;
496     enum uint POSITION = 14;
497     enum uint RAWTEXT = 17;
498     enum uint TEXT = 19;
499     enum uint JSON = 22;
500     enum uint COMMAND = 29;
501     enum uint ENUM = 2097152;
502     enum uint TEMPLATE = 16777216;
503 
504     enum string[] __fields = ["name", "type", "optional"];
505 
506     string name;
507     uint type;
508     bool optional;
509 
510     mixin Make!(Endian.littleEndian, varuint);
511 
512     string toString()
513     {
514         return "Parameter(name: " ~ std.conv.to!string(this.name) ~ ", type: " ~ std.conv.to!string(this.type) ~ ", optional: " ~ std.conv.to!string(this.optional) ~ ")";
515     }
516 
517 }