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