1 /* 2 * This file was automatically generated by sel-utils and 3 * released under the MIT License. 4 * 5 * License: https://github.com/sel-project/sel-utils/blob/master/LICENSE 6 * Repository: https://github.com/sel-project/sel-utils 7 * Generated from https://github.com/sel-project/sel-utils/blob/master/xml/protocol/bedrock160.xml 8 */ 9 module sul.protocol.bedrock160.types; 10 11 import std.bitmanip : write, peek; 12 static import std.conv; 13 import std.system : Endian; 14 import std.typecons : Tuple; 15 import std.uuid : UUID; 16 17 import sul.utils.buffer; 18 import sul.utils.var; 19 20 static if(__traits(compiles, { import sul.metadata.bedrock160; })) import sul.metadata.bedrock160; 21 22 struct LoginBody { 23 24 public enum string[] FIELDS = ["chain", "clientData"]; 25 26 public ubyte[] chain; 27 public ubyte[] clientData; 28 29 public pure nothrow @safe void encode(Buffer o_buffer) { 30 Buffer buffer = new Buffer(); 31 with(buffer) { 32 writeLittleEndianUint(cast(uint)chain.length); writeBytes(chain); 33 writeLittleEndianUint(cast(uint)clientData.length); writeBytes(clientData); 34 } 35 with(o_buffer){ writeBytes(varuint.encode(cast(uint)buffer._buffer.length)); } 36 o_buffer.writeBytes(buffer._buffer); 37 } 38 39 public pure nothrow @safe void decode(Buffer o_buffer) { 40 Buffer buffer = new Buffer(); 41 with(o_buffer) { 42 immutable _length=varuint.decode(_buffer, &_index); 43 buffer._buffer = readBytes(_length); 44 } 45 with(buffer) { 46 chain.length=readLittleEndianUint(); if(_buffer.length>=_index+chain.length){ chain=_buffer[_index.._index+chain.length].dup; _index+=chain.length; } 47 clientData.length=readLittleEndianUint(); if(_buffer.length>=_index+clientData.length){ clientData=_buffer[_index.._index+clientData.length].dup; _index+=clientData.length; } 48 } 49 } 50 51 public string toString() { 52 return "LoginBody(chain: " ~ std.conv.to!string(this.chain) ~ ", clientData: " ~ std.conv.to!string(this.clientData) ~ ")"; 53 } 54 55 } 56 57 struct PackWithSize { 58 59 public enum string[] FIELDS = ["id", "vers", "size"]; 60 61 public string id; 62 public string vers; 63 public ulong size; 64 65 public pure nothrow @safe void encode(Buffer buffer) { 66 with(buffer) { 67 writeBytes(varuint.encode(cast(uint)id.length)); writeString(id); 68 writeBytes(varuint.encode(cast(uint)vers.length)); writeString(vers); 69 writeLittleEndianUlong(size); 70 } 71 } 72 73 public pure nothrow @safe void decode(Buffer buffer) { 74 with(buffer) { 75 uint aq=varuint.decode(_buffer, &_index); id=readString(aq); 76 uint dvc=varuint.decode(_buffer, &_index); vers=readString(dvc); 77 size=readLittleEndianUlong(); 78 } 79 } 80 81 public string toString() { 82 return "PackWithSize(id: " ~ std.conv.to!string(this.id) ~ ", vers: " ~ std.conv.to!string(this.vers) ~ ", size: " ~ std.conv.to!string(this.size) ~ ")"; 83 } 84 85 } 86 87 struct Pack { 88 89 public enum string[] FIELDS = ["id", "vers"]; 90 91 public string id; 92 public string vers; 93 94 public pure nothrow @safe void encode(Buffer buffer) { 95 with(buffer) { 96 writeBytes(varuint.encode(cast(uint)id.length)); writeString(id); 97 writeBytes(varuint.encode(cast(uint)vers.length)); writeString(vers); 98 } 99 } 100 101 public pure nothrow @safe void decode(Buffer buffer) { 102 with(buffer) { 103 uint aq=varuint.decode(_buffer, &_index); id=readString(aq); 104 uint dvc=varuint.decode(_buffer, &_index); vers=readString(dvc); 105 } 106 } 107 108 public string toString() { 109 return "Pack(id: " ~ std.conv.to!string(this.id) ~ ", vers: " ~ std.conv.to!string(this.vers) ~ ")"; 110 } 111 112 } 113 114 struct Slot { 115 116 public enum string[] FIELDS = ["id", "metaAndCount", "nbt", "canPlaceOn", "canDestroy"]; 117 118 public int id; 119 public int metaAndCount; 120 public ubyte[] nbt; 121 public string[] canPlaceOn; 122 public string[] canDestroy; 123 124 public pure nothrow @safe void encode(Buffer buffer) { 125 with(buffer) { 126 writeBytes(varint.encode(id)); 127 if(id>0){ writeBytes(varint.encode(metaAndCount)); } 128 if(id>0){ writeLittleEndianUshort(cast(ushort)nbt.length); writeBytes(nbt); } 129 writeBytes(varuint.encode(cast(uint)canPlaceOn.length)); foreach(yfuxyvb;canPlaceOn){ writeBytes(varuint.encode(cast(uint)yfuxyvb.length)); writeString(yfuxyvb); } 130 writeBytes(varuint.encode(cast(uint)canDestroy.length)); foreach(yfrvdje;canDestroy){ writeBytes(varuint.encode(cast(uint)yfrvdje.length)); writeString(yfrvdje); } 131 } 132 } 133 134 public pure nothrow @safe void decode(Buffer buffer) { 135 with(buffer) { 136 id=varint.decode(_buffer, &_index); 137 if(id>0){ metaAndCount=varint.decode(_buffer, &_index); } 138 if(id>0){ nbt.length=readLittleEndianUshort(); if(_buffer.length>=_index+nbt.length){ nbt=_buffer[_index.._index+nbt.length].dup; _index+=nbt.length; } } 139 canPlaceOn.length=varuint.decode(_buffer, &_index); foreach(ref yfuxyvb;canPlaceOn){ uint ezely=varuint.decode(_buffer, &_index); yfuxyvb=readString(ezely); } 140 canDestroy.length=varuint.decode(_buffer, &_index); foreach(ref yfrvdje;canDestroy){ uint ezdrz=varuint.decode(_buffer, &_index); yfrvdje=readString(ezdrz); } 141 } 142 } 143 144 public string toString() { 145 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) ~ ")"; 146 } 147 148 } 149 150 struct Attribute { 151 152 public enum string[] FIELDS = ["min", "max", "value", "def", "name"]; 153 154 public float min; 155 public float max; 156 public float value; 157 public float def; 158 public string name; 159 160 public pure nothrow @safe void encode(Buffer buffer) { 161 with(buffer) { 162 writeLittleEndianFloat(min); 163 writeLittleEndianFloat(max); 164 writeLittleEndianFloat(value); 165 writeLittleEndianFloat(def); 166 writeBytes(varuint.encode(cast(uint)name.length)); writeString(name); 167 } 168 } 169 170 public pure nothrow @safe void decode(Buffer buffer) { 171 with(buffer) { 172 min=readLittleEndianFloat(); 173 max=readLittleEndianFloat(); 174 value=readLittleEndianFloat(); 175 def=readLittleEndianFloat(); 176 uint bfz=varuint.decode(_buffer, &_index); name=readString(bfz); 177 } 178 } 179 180 public string toString() { 181 return "Attribute(min: " ~ std.conv.to!string(this.min) ~ ", max: " ~ std.conv.to!string(this.max) ~ ", value: " ~ std.conv.to!string(this.value) ~ ", def: " ~ std.conv.to!string(this.def) ~ ", name: " ~ std.conv.to!string(this.name) ~ ")"; 182 } 183 184 } 185 186 struct BlockPosition { 187 188 public enum string[] FIELDS = ["x", "y", "z"]; 189 190 public int x; 191 public uint y; 192 public int z; 193 194 public pure nothrow @safe void encode(Buffer buffer) { 195 with(buffer) { 196 writeBytes(varint.encode(x)); 197 writeBytes(varuint.encode(y)); 198 writeBytes(varint.encode(z)); 199 } 200 } 201 202 public pure nothrow @safe void decode(Buffer buffer) { 203 with(buffer) { 204 x=varint.decode(_buffer, &_index); 205 y=varuint.decode(_buffer, &_index); 206 z=varint.decode(_buffer, &_index); 207 } 208 } 209 210 public string toString() { 211 return "BlockPosition(x: " ~ std.conv.to!string(this.x) ~ ", y: " ~ std.conv.to!string(this.y) ~ ", z: " ~ std.conv.to!string(this.z) ~ ")"; 212 } 213 214 } 215 216 struct McpeUuid { 217 218 public enum string[] FIELDS = ["mostSignificantBits", "leastSignificantBits"]; 219 220 public long mostSignificantBits; 221 public long leastSignificantBits; 222 223 public pure nothrow @safe void encode(Buffer buffer) { 224 with(buffer) { 225 writeLittleEndianLong(mostSignificantBits); 226 writeLittleEndianLong(leastSignificantBits); 227 } 228 } 229 230 public pure nothrow @safe void decode(Buffer buffer) { 231 with(buffer) { 232 mostSignificantBits=readLittleEndianLong(); 233 leastSignificantBits=readLittleEndianLong(); 234 } 235 } 236 237 public string toString() { 238 return "McpeUuid(mostSignificantBits: " ~ std.conv.to!string(this.mostSignificantBits) ~ ", leastSignificantBits: " ~ std.conv.to!string(this.leastSignificantBits) ~ ")"; 239 } 240 241 } 242 243 struct PlayerList { 244 245 public enum string[] FIELDS = ["uuid", "entityId", "displayName", "skin", "unknown4"]; 246 247 public sul.protocol.bedrock160.types.McpeUuid uuid; 248 public long entityId; 249 public string displayName; 250 public sul.protocol.bedrock160.types.Skin skin; 251 public string unknown4; 252 253 public pure nothrow @safe void encode(Buffer buffer) { 254 with(buffer) { 255 uuid.encode(bufferInstance); 256 writeBytes(varlong.encode(entityId)); 257 writeBytes(varuint.encode(cast(uint)displayName.length)); writeString(displayName); 258 skin.encode(bufferInstance); 259 writeBytes(varuint.encode(cast(uint)unknown4.length)); writeString(unknown4); 260 } 261 } 262 263 public pure nothrow @safe void decode(Buffer buffer) { 264 with(buffer) { 265 uuid.decode(bufferInstance); 266 entityId=varlong.decode(_buffer, &_index); 267 uint zlcxe5bu=varuint.decode(_buffer, &_index); displayName=readString(zlcxe5bu); 268 skin.decode(bufferInstance); 269 uint d5b9bq=varuint.decode(_buffer, &_index); unknown4=readString(d5b9bq); 270 } 271 } 272 273 public string toString() { 274 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) ~ ")"; 275 } 276 277 } 278 279 struct Skin { 280 281 public enum string[] FIELDS = ["name", "data", "capeData", "geometryName", "geometryData"]; 282 283 public string name; 284 public ubyte[] data; 285 public ubyte[] capeData; 286 public string geometryName; 287 public ubyte[] geometryData; 288 289 public pure nothrow @safe void encode(Buffer buffer) { 290 with(buffer) { 291 writeBytes(varuint.encode(cast(uint)name.length)); writeString(name); 292 writeBytes(varuint.encode(cast(uint)data.length)); writeBytes(data); 293 writeBytes(varuint.encode(cast(uint)capeData.length)); writeBytes(capeData); 294 writeBytes(varuint.encode(cast(uint)geometryName.length)); writeString(geometryName); 295 writeBytes(varuint.encode(cast(uint)geometryData.length)); writeBytes(geometryData); 296 } 297 } 298 299 public pure nothrow @safe void decode(Buffer buffer) { 300 with(buffer) { 301 uint bfz=varuint.decode(_buffer, &_index); name=readString(bfz); 302 data.length=varuint.decode(_buffer, &_index); if(_buffer.length>=_index+data.length){ data=_buffer[_index.._index+data.length].dup; _index+=data.length; } 303 capeData.length=varuint.decode(_buffer, &_index); if(_buffer.length>=_index+capeData.length){ capeData=_buffer[_index.._index+capeData.length].dup; _index+=capeData.length; } 304 uint zvbvcly1=varuint.decode(_buffer, &_index); geometryName=readString(zvbvcly1); 305 geometryData.length=varuint.decode(_buffer, &_index); if(_buffer.length>=_index+geometryData.length){ geometryData=_buffer[_index.._index+geometryData.length].dup; _index+=geometryData.length; } 306 } 307 } 308 309 public string toString() { 310 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) ~ ")"; 311 } 312 313 } 314 315 struct Link { 316 317 // action 318 public enum ubyte ADD = 0; 319 public enum ubyte RIDE = 1; 320 public enum ubyte REMOVE = 2; 321 322 public enum string[] FIELDS = ["from", "to", "action", "unknown3"]; 323 324 public long from; 325 public long to; 326 public ubyte action; 327 public ubyte unknown3; 328 329 public pure nothrow @safe void encode(Buffer buffer) { 330 with(buffer) { 331 writeBytes(varlong.encode(from)); 332 writeBytes(varlong.encode(to)); 333 writeLittleEndianUbyte(action); 334 writeLittleEndianUbyte(unknown3); 335 } 336 } 337 338 public pure nothrow @safe void decode(Buffer buffer) { 339 with(buffer) { 340 from=varlong.decode(_buffer, &_index); 341 to=varlong.decode(_buffer, &_index); 342 action=readLittleEndianUbyte(); 343 unknown3=readLittleEndianUbyte(); 344 } 345 } 346 347 public string toString() { 348 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) ~ ")"; 349 } 350 351 } 352 353 struct Recipe { 354 355 // type 356 public enum int SHAPELESS = 0; 357 public enum int SHAPED = 1; 358 public enum int FURNACE = 2; 359 public enum int FURNACE_DATA = 3; 360 public enum int MULTI = 4; 361 362 public enum string[] FIELDS = ["type", "data"]; 363 364 public int type; 365 public ubyte[] data; 366 367 public pure nothrow @safe void encode(Buffer buffer) { 368 with(buffer) { 369 writeBytes(varint.encode(type)); 370 writeBytes(data); 371 } 372 } 373 374 public pure nothrow @safe void decode(Buffer buffer) { 375 with(buffer) { 376 type=varint.decode(_buffer, &_index); 377 data=_buffer[_index..$].dup; _index=_buffer.length; 378 } 379 } 380 381 public string toString() { 382 return "Recipe(type: " ~ std.conv.to!string(this.type) ~ ", data: " ~ std.conv.to!string(this.data) ~ ")"; 383 } 384 385 } 386 387 struct InventoryAction { 388 389 // source 390 public enum uint CONTAINER = 0; 391 public enum uint WORLD = 2; 392 public enum uint CREATIVE = 3; 393 394 public enum string[] FIELDS = ["source", "container", "unknown2", "slot", "oldItem", "newItem"]; 395 396 public uint source; 397 public int container = -1; 398 public uint unknown2; 399 public uint slot; 400 public sul.protocol.bedrock160.types.Slot oldItem; 401 public sul.protocol.bedrock160.types.Slot newItem; 402 403 public pure nothrow @safe void encode(Buffer buffer) { 404 with(buffer) { 405 writeBytes(varuint.encode(source)); 406 if(source==0){ writeBytes(varint.encode(container)); } 407 if(source==2){ writeBytes(varuint.encode(unknown2)); } 408 writeBytes(varuint.encode(slot)); 409 oldItem.encode(bufferInstance); 410 newItem.encode(bufferInstance); 411 } 412 } 413 414 public pure nothrow @safe void decode(Buffer buffer) { 415 with(buffer) { 416 source=varuint.decode(_buffer, &_index); 417 if(source==0){ container=varint.decode(_buffer, &_index); } 418 if(source==2){ unknown2=varuint.decode(_buffer, &_index); } 419 slot=varuint.decode(_buffer, &_index); 420 oldItem.decode(bufferInstance); 421 newItem.decode(bufferInstance); 422 } 423 } 424 425 public string toString() { 426 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) ~ ")"; 427 } 428 429 } 430 431 struct ChunkData { 432 433 public enum string[] FIELDS = ["sections", "heights", "biomes", "borders", "extraData", "blockEntities"]; 434 435 public sul.protocol.bedrock160.types.Section[] sections; 436 public ushort[256] heights; 437 public ubyte[256] biomes; 438 public ubyte[] borders; 439 public sul.protocol.bedrock160.types.ExtraData[] extraData; 440 public ubyte[] blockEntities; 441 442 public pure nothrow @safe void encode(Buffer o_buffer) { 443 Buffer buffer = new Buffer(); 444 with(buffer) { 445 writeBytes(varuint.encode(cast(uint)sections.length)); foreach(cvdlbm;sections){ cvdlbm.encode(bufferInstance); } 446 foreach(avzhc;heights){ writeLittleEndianUshort(avzhc); } 447 writeBytes(biomes); 448 writeBytes(varuint.encode(cast(uint)borders.length)); writeBytes(borders); 449 writeBytes(varuint.encode(cast(uint)extraData.length)); foreach(zhcfyr;extraData){ zhcfyr.encode(bufferInstance); } 450 writeBytes(blockEntities); 451 } 452 with(o_buffer){ writeBytes(varuint.encode(cast(uint)buffer._buffer.length)); } 453 o_buffer.writeBytes(buffer._buffer); 454 } 455 456 public pure nothrow @safe void decode(Buffer o_buffer) { 457 Buffer buffer = new Buffer(); 458 with(o_buffer) { 459 immutable _length=varuint.decode(_buffer, &_index); 460 buffer._buffer = readBytes(_length); 461 } 462 with(buffer) { 463 sections.length=varuint.decode(_buffer, &_index); foreach(ref cvdlbm;sections){ cvdlbm.decode(bufferInstance); } 464 foreach(ref avzhc;heights){ avzhc=readLittleEndianUshort(); } 465 if(_buffer.length>=_index+biomes.length){ biomes=_buffer[_index.._index+biomes.length].dup; _index+=biomes.length; } 466 borders.length=varuint.decode(_buffer, &_index); if(_buffer.length>=_index+borders.length){ borders=_buffer[_index.._index+borders.length].dup; _index+=borders.length; } 467 extraData.length=varuint.decode(_buffer, &_index); foreach(ref zhcfyr;extraData){ zhcfyr.decode(bufferInstance); } 468 blockEntities=_buffer[_index..$].dup; _index=_buffer.length; 469 } 470 } 471 472 public string toString() { 473 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) ~ ")"; 474 } 475 476 } 477 478 struct Section { 479 480 public enum string[] FIELDS = ["storageVersion", "blockIds", "blockMetas"]; 481 482 public ubyte storageVersion = 0; 483 public ubyte[4096] blockIds; 484 public ubyte[2048] blockMetas; 485 486 public pure nothrow @safe void encode(Buffer buffer) { 487 with(buffer) { 488 writeLittleEndianUbyte(storageVersion); 489 writeBytes(blockIds); 490 writeBytes(blockMetas); 491 } 492 } 493 494 public pure nothrow @safe void decode(Buffer buffer) { 495 with(buffer) { 496 storageVersion=readLittleEndianUbyte(); 497 if(_buffer.length>=_index+blockIds.length){ blockIds=_buffer[_index.._index+blockIds.length].dup; _index+=blockIds.length; } 498 if(_buffer.length>=_index+blockMetas.length){ blockMetas=_buffer[_index.._index+blockMetas.length].dup; _index+=blockMetas.length; } 499 } 500 } 501 502 public string toString() { 503 return "Section(storageVersion: " ~ std.conv.to!string(this.storageVersion) ~ ", blockIds: " ~ std.conv.to!string(this.blockIds) ~ ", blockMetas: " ~ std.conv.to!string(this.blockMetas) ~ ")"; 504 } 505 506 } 507 508 struct ExtraData { 509 510 public enum string[] FIELDS = ["key", "value"]; 511 512 public uint key; 513 public ushort value; 514 515 public pure nothrow @safe void encode(Buffer buffer) { 516 with(buffer) { 517 writeBytes(varuint.encode(key)); 518 writeLittleEndianUshort(value); 519 } 520 } 521 522 public pure nothrow @safe void decode(Buffer buffer) { 523 with(buffer) { 524 key=varuint.decode(_buffer, &_index); 525 value=readLittleEndianUshort(); 526 } 527 } 528 529 public string toString() { 530 return "ExtraData(key: " ~ std.conv.to!string(this.key) ~ ", value: " ~ std.conv.to!string(this.value) ~ ")"; 531 } 532 533 } 534 535 struct Decoration { 536 537 public enum string[] FIELDS = ["rotationAndIcon", "position", "label", "color"]; 538 539 public int rotationAndIcon; 540 public Tuple!(ubyte, "x", ubyte, "z") position; 541 public string label; 542 public uint color; 543 544 public pure nothrow @safe void encode(Buffer buffer) { 545 with(buffer) { 546 writeBytes(varint.encode(rotationAndIcon)); 547 writeLittleEndianUbyte(position.x); writeLittleEndianUbyte(position.z); 548 writeBytes(varuint.encode(cast(uint)label.length)); writeString(label); 549 writeLittleEndianUint(color); 550 } 551 } 552 553 public pure nothrow @safe void decode(Buffer buffer) { 554 with(buffer) { 555 rotationAndIcon=varint.decode(_buffer, &_index); 556 position.x=readLittleEndianUbyte(); position.z=readLittleEndianUbyte(); 557 uint bfzw=varuint.decode(_buffer, &_index); label=readString(bfzw); 558 color=readLittleEndianUint(); 559 } 560 } 561 562 public string toString() { 563 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) ~ ")"; 564 } 565 566 } 567 568 struct Rule { 569 570 // name 571 public enum string COMMAND_BLOCK_OUTPUT = "commandblockoutput"; 572 public enum string DO_DAYLIGHT_CYCLE = "dodaylightcycle"; 573 public enum string DO_ENTITY_DROPS = "doentitydrops"; 574 public enum string DO_FIRE_TICK = "dofiretick"; 575 public enum string DO_MOB_LOOT = "domobloot"; 576 public enum string DO_MOB_SPAWNING = "domobspawning"; 577 public enum string DO_TILE_DROPS = "dotiledrops"; 578 public enum string DO_WEATHER_CYCLE = "doweathercycle"; 579 public enum string DROWNING_DAMAGE = "drowningdamage"; 580 public enum string FALL_DAMAGE = "falldamage"; 581 public enum string FIRE_DAMAGE = "firedamage"; 582 public enum string KEEP_INVENTORY = "keepinventory"; 583 public enum string MOB_GRIEFING = "mobgriefing"; 584 public enum string PVP = "pvp"; 585 public enum string SEND_COMMAND_FEEDBACK = "sendcommandfeedback"; 586 587 // type 588 public enum ubyte BOOLEAN = 1; 589 public enum ubyte INTEGER = 2; 590 public enum ubyte FLOATING = 3; 591 592 public enum string[] FIELDS = ["name", "type", "booleanValue", "integerValue", "floatingValue"]; 593 594 public string name; 595 public ubyte type; 596 public bool booleanValue; 597 public uint integerValue; 598 public float floatingValue; 599 600 public pure nothrow @safe void encode(Buffer buffer) { 601 with(buffer) { 602 writeBytes(varuint.encode(cast(uint)name.length)); writeString(name); 603 writeLittleEndianUbyte(type); 604 if(type==1){ writeLittleEndianBool(booleanValue); } 605 if(type==2){ writeBytes(varuint.encode(integerValue)); } 606 if(type==3){ writeLittleEndianFloat(floatingValue); } 607 } 608 } 609 610 public pure nothrow @safe void decode(Buffer buffer) { 611 with(buffer) { 612 uint bfz=varuint.decode(_buffer, &_index); name=readString(bfz); 613 type=readLittleEndianUbyte(); 614 if(type==1){ booleanValue=readLittleEndianBool(); } 615 if(type==2){ integerValue=varuint.decode(_buffer, &_index); } 616 if(type==3){ floatingValue=readLittleEndianFloat(); } 617 } 618 } 619 620 public string toString() { 621 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) ~ ")"; 622 } 623 624 } 625 626 struct Enum { 627 628 public enum string[] FIELDS = ["name", "valuesIndexes"]; 629 630 public string name; 631 public ushort[] valuesIndexes; 632 633 public pure nothrow @safe void encode(Buffer buffer) { 634 with(buffer) { 635 writeBytes(varuint.encode(cast(uint)name.length)); writeString(name); 636 writeBytes(varuint.encode(cast(uint)valuesIndexes.length)); foreach(dfdvs5zh;valuesIndexes){ writeLittleEndianUshort(dfdvs5zh); } 637 } 638 } 639 640 public pure nothrow @safe void decode(Buffer buffer) { 641 with(buffer) { 642 uint bfz=varuint.decode(_buffer, &_index); name=readString(bfz); 643 valuesIndexes.length=varuint.decode(_buffer, &_index); foreach(ref dfdvs5zh;valuesIndexes){ dfdvs5zh=readLittleEndianUshort(); } 644 } 645 } 646 647 public string toString() { 648 return "Enum(name: " ~ std.conv.to!string(this.name) ~ ", valuesIndexes: " ~ std.conv.to!string(this.valuesIndexes) ~ ")"; 649 } 650 651 } 652 653 struct Command { 654 655 public enum string[] FIELDS = ["name", "description", "unknown2", "permissionLevel", "aliasesEnum", "overloads"]; 656 657 public string name; 658 public string description; 659 public ubyte unknown2; 660 public ubyte permissionLevel; 661 public int aliasesEnum = -1; 662 public sul.protocol.bedrock160.types.Overload[] overloads; 663 664 public pure nothrow @safe void encode(Buffer buffer) { 665 with(buffer) { 666 writeBytes(varuint.encode(cast(uint)name.length)); writeString(name); 667 writeBytes(varuint.encode(cast(uint)description.length)); writeString(description); 668 writeLittleEndianUbyte(unknown2); 669 writeLittleEndianUbyte(permissionLevel); 670 writeLittleEndianInt(aliasesEnum); 671 writeBytes(varuint.encode(cast(uint)overloads.length)); foreach(bzcxyr;overloads){ bzcxyr.encode(bufferInstance); } 672 } 673 } 674 675 public pure nothrow @safe void decode(Buffer buffer) { 676 with(buffer) { 677 uint bfz=varuint.decode(_buffer, &_index); name=readString(bfz); 678 uint zvyjcrb4=varuint.decode(_buffer, &_index); description=readString(zvyjcrb4); 679 unknown2=readLittleEndianUbyte(); 680 permissionLevel=readLittleEndianUbyte(); 681 aliasesEnum=readLittleEndianInt(); 682 overloads.length=varuint.decode(_buffer, &_index); foreach(ref bzcxyr;overloads){ bzcxyr.decode(bufferInstance); } 683 } 684 } 685 686 public string toString() { 687 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) ~ ")"; 688 } 689 690 } 691 692 struct Overload { 693 694 public enum string[] FIELDS = ["parameters"]; 695 696 public sul.protocol.bedrock160.types.Parameter[] parameters; 697 698 public pure nothrow @safe void encode(Buffer buffer) { 699 with(buffer) { 700 writeBytes(varuint.encode(cast(uint)parameters.length)); foreach(cfy1dvc;parameters){ cfy1dvc.encode(bufferInstance); } 701 } 702 } 703 704 public pure nothrow @safe void decode(Buffer buffer) { 705 with(buffer) { 706 parameters.length=varuint.decode(_buffer, &_index); foreach(ref cfy1dvc;parameters){ cfy1dvc.decode(bufferInstance); } 707 } 708 } 709 710 public string toString() { 711 return "Overload(parameters: " ~ std.conv.to!string(this.parameters) ~ ")"; 712 } 713 714 } 715 716 struct Parameter { 717 718 // type 719 public enum uint VALID = 1048576; 720 public enum uint INT = 1; 721 public enum uint FLOAT = 2; 722 public enum uint MIXED = 3; 723 public enum uint TARGET = 4; 724 public enum uint STRING = 13; 725 public enum uint POSITION = 14; 726 public enum uint RAWTEXT = 17; 727 public enum uint TEXT = 19; 728 public enum uint JSON = 22; 729 public enum uint COMMAND = 29; 730 public enum uint ENUM = 2097152; 731 public enum uint TEMPLATE = 16777216; 732 733 public enum string[] FIELDS = ["name", "type", "optional"]; 734 735 public string name; 736 public uint type; 737 public bool optional; 738 739 public pure nothrow @safe void encode(Buffer buffer) { 740 with(buffer) { 741 writeBytes(varuint.encode(cast(uint)name.length)); writeString(name); 742 writeLittleEndianUint(type); 743 writeLittleEndianBool(optional); 744 } 745 } 746 747 public pure nothrow @safe void decode(Buffer buffer) { 748 with(buffer) { 749 uint bfz=varuint.decode(_buffer, &_index); name=readString(bfz); 750 type=readLittleEndianUint(); 751 optional=readLittleEndianBool(); 752 } 753 } 754 755 public string toString() { 756 return "Parameter(name: " ~ std.conv.to!string(this.name) ~ ", type: " ~ std.conv.to!string(this.type) ~ ", optional: " ~ std.conv.to!string(this.optional) ~ ")"; 757 } 758 759 } 760