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