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/pocket102.xml 8 */ 9 module sul.protocol.pocket102.play; 10 11 import std.bitmanip : write, peek; 12 static import std.conv; 13 import std.system : Endian; 14 import std.typetuple : TypeTuple; 15 import std.typecons : Tuple; 16 import std.uuid : UUID; 17 18 import sul.utils.buffer; 19 import sul.utils.var; 20 21 static import sul.protocol.pocket102.types; 22 23 static if(__traits(compiles, { import sul.metadata.pocket102; })) import sul.metadata.pocket102; 24 25 alias Packets = TypeTuple!(Login, PlayStatus, ServerToClientHandshake, ClientToServerHandshake, Disconnect, Batch, ResourcePacksInfo, ResourcePacksStackPacket, ResourcePackClientResponse, Text, SetTime, StartGame, AddPlayer, AddEntity, RemoveEntity, AddItemEntity, AddHangingEntity, TakeItemEntity, MoveEntity, MovePlayer, RiderJump, RemoveBlock, UpdateBlock, AddPainting, Explode, LevelSoundEvent, LevelEvent, BlockEvent, EntityEvent, MobEffect, UpdateAttributes, MobEquipment, MobArmorEquipment, Interact, UseItem, PlayerAction, PlayerFall, HurtArmor, SetEntityData, SetEntityMotion, SetEntityLink, SetHealth, SetSpawnPosition, Animate, Respawn, DropItem, InventoryAction, ContainerOpen, ContainerClose, ContainerSetSlot, ContainerSetData, ContainerSetContent, CraftingData, CraftingEvent, AdventureSettings, BlockEntityData, PlayerInput, FullChunkData, SetCommandsEnabled, SetDifficulty, ChangeDimension, SetPlayerGameType, PlayerList, TelemetryEvent, SpawnExperienceOrb, ClientboundMapItemData, MapInfoRequest, RequestChunkRadius, ChunkRadiusUpdated, ItemFrameDropItem, ReplaceSelectedItem, GameRulesChanged, Camera, AddItem, BossEvent, ShowCredits, AvailableCommands, CommandStep, UpdateTrade, ResourcePackDataInfo, ResourcePackChunkData, ResourcePackChunkRequest, Transfer); 26 27 class Login : Buffer { 28 29 public enum ubyte ID = 1; 30 31 public enum bool CLIENTBOUND = false; 32 public enum bool SERVERBOUND = true; 33 34 // edition 35 public enum ubyte CLASSIC = 0; 36 public enum ubyte EDUCATION = 1; 37 38 public enum string[] FIELDS = ["protocol", "edition", "body_"]; 39 40 public uint protocol; 41 public ubyte edition; 42 public ubyte[] body_; 43 44 public pure nothrow @safe @nogc this() {} 45 46 public pure nothrow @safe @nogc this(uint protocol, ubyte edition=ubyte.init, ubyte[] body_=(ubyte[]).init) { 47 this.protocol = protocol; 48 this.edition = edition; 49 this.body_ = body_; 50 } 51 52 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 53 _buffer.length = 0; 54 static if(writeId){ writeBigEndianUbyte(ID); } 55 writeBigEndianUint(protocol); 56 writeBigEndianUbyte(edition); 57 writeBytes(varuint.encode(cast(uint)body_.length)); writeBytes(body_); 58 return _buffer; 59 } 60 61 public pure nothrow @safe void decode(bool readId=true)() { 62 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 63 protocol=readBigEndianUint(); 64 edition=readBigEndianUbyte(); 65 body_.length=varuint.decode(_buffer, &_index); if(_buffer.length>=_index+body_.length){ body_=_buffer[_index.._index+body_.length].dup; _index+=body_.length; } 66 } 67 68 public static pure nothrow @safe Login fromBuffer(bool readId=true)(ubyte[] buffer) { 69 Login ret = new Login(); 70 ret._buffer = buffer; 71 ret.decode!readId(); 72 return ret; 73 } 74 75 public override string toString() { 76 return "Login(protocol: " ~ std.conv.to!string(this.protocol) ~ ", edition: " ~ std.conv.to!string(this.edition) ~ ", body_: " ~ std.conv.to!string(this.body_) ~ ")"; 77 } 78 79 } 80 81 class PlayStatus : Buffer { 82 83 public enum ubyte ID = 2; 84 85 public enum bool CLIENTBOUND = true; 86 public enum bool SERVERBOUND = false; 87 88 // status 89 public enum uint OK = 0; 90 public enum uint OUTDATED_CLIENT = 1; 91 public enum uint OUTDATED_SERVER = 2; 92 public enum uint SPAWNED = 3; 93 public enum uint INVALID_TENANT = 4; 94 public enum uint EDITION_MISMATCH = 5; 95 96 public enum string[] FIELDS = ["status"]; 97 98 public uint status; 99 100 public pure nothrow @safe @nogc this() {} 101 102 public pure nothrow @safe @nogc this(uint status) { 103 this.status = status; 104 } 105 106 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 107 _buffer.length = 0; 108 static if(writeId){ writeBigEndianUbyte(ID); } 109 writeBigEndianUint(status); 110 return _buffer; 111 } 112 113 public pure nothrow @safe void decode(bool readId=true)() { 114 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 115 status=readBigEndianUint(); 116 } 117 118 public static pure nothrow @safe PlayStatus fromBuffer(bool readId=true)(ubyte[] buffer) { 119 PlayStatus ret = new PlayStatus(); 120 ret._buffer = buffer; 121 ret.decode!readId(); 122 return ret; 123 } 124 125 public override string toString() { 126 return "PlayStatus(status: " ~ std.conv.to!string(this.status) ~ ")"; 127 } 128 129 } 130 131 class ServerToClientHandshake : Buffer { 132 133 public enum ubyte ID = 3; 134 135 public enum bool CLIENTBOUND = true; 136 public enum bool SERVERBOUND = false; 137 138 public enum string[] FIELDS = ["serverPublicKey", "token"]; 139 140 public string serverPublicKey; 141 public ubyte[] token; 142 143 public pure nothrow @safe @nogc this() {} 144 145 public pure nothrow @safe @nogc this(string serverPublicKey, ubyte[] token=(ubyte[]).init) { 146 this.serverPublicKey = serverPublicKey; 147 this.token = token; 148 } 149 150 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 151 _buffer.length = 0; 152 static if(writeId){ writeBigEndianUbyte(ID); } 153 writeBytes(varuint.encode(cast(uint)serverPublicKey.length)); writeString(serverPublicKey); 154 writeBytes(varuint.encode(cast(uint)token.length)); writeBytes(token); 155 return _buffer; 156 } 157 158 public pure nothrow @safe void decode(bool readId=true)() { 159 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 160 uint cvdvuvbl=varuint.decode(_buffer, &_index); serverPublicKey=readString(cvdvuvbl); 161 token.length=varuint.decode(_buffer, &_index); if(_buffer.length>=_index+token.length){ token=_buffer[_index.._index+token.length].dup; _index+=token.length; } 162 } 163 164 public static pure nothrow @safe ServerToClientHandshake fromBuffer(bool readId=true)(ubyte[] buffer) { 165 ServerToClientHandshake ret = new ServerToClientHandshake(); 166 ret._buffer = buffer; 167 ret.decode!readId(); 168 return ret; 169 } 170 171 public override string toString() { 172 return "ServerToClientHandshake(serverPublicKey: " ~ std.conv.to!string(this.serverPublicKey) ~ ", token: " ~ std.conv.to!string(this.token) ~ ")"; 173 } 174 175 } 176 177 class ClientToServerHandshake : Buffer { 178 179 public enum ubyte ID = 4; 180 181 public enum bool CLIENTBOUND = false; 182 public enum bool SERVERBOUND = true; 183 184 public enum string[] FIELDS = []; 185 186 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 187 _buffer.length = 0; 188 static if(writeId){ writeBigEndianUbyte(ID); } 189 return _buffer; 190 } 191 192 public pure nothrow @safe void decode(bool readId=true)() { 193 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 194 } 195 196 public static pure nothrow @safe ClientToServerHandshake fromBuffer(bool readId=true)(ubyte[] buffer) { 197 ClientToServerHandshake ret = new ClientToServerHandshake(); 198 ret._buffer = buffer; 199 ret.decode!readId(); 200 return ret; 201 } 202 203 public override string toString() { 204 return "ClientToServerHandshake()"; 205 } 206 207 } 208 209 class Disconnect : Buffer { 210 211 public enum ubyte ID = 5; 212 213 public enum bool CLIENTBOUND = true; 214 public enum bool SERVERBOUND = false; 215 216 public enum string[] FIELDS = ["hideDisconnectionScreen", "message"]; 217 218 public bool hideDisconnectionScreen; 219 public string message; 220 221 public pure nothrow @safe @nogc this() {} 222 223 public pure nothrow @safe @nogc this(bool hideDisconnectionScreen, string message=string.init) { 224 this.hideDisconnectionScreen = hideDisconnectionScreen; 225 this.message = message; 226 } 227 228 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 229 _buffer.length = 0; 230 static if(writeId){ writeBigEndianUbyte(ID); } 231 writeBigEndianBool(hideDisconnectionScreen); 232 if(hideDisconnectionScreen==false){ writeBytes(varuint.encode(cast(uint)message.length)); writeString(message); } 233 return _buffer; 234 } 235 236 public pure nothrow @safe void decode(bool readId=true)() { 237 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 238 hideDisconnectionScreen=readBigEndianBool(); 239 if(hideDisconnectionScreen==false){ uint bvcfz=varuint.decode(_buffer, &_index); message=readString(bvcfz); } 240 } 241 242 public static pure nothrow @safe Disconnect fromBuffer(bool readId=true)(ubyte[] buffer) { 243 Disconnect ret = new Disconnect(); 244 ret._buffer = buffer; 245 ret.decode!readId(); 246 return ret; 247 } 248 249 public override string toString() { 250 return "Disconnect(hideDisconnectionScreen: " ~ std.conv.to!string(this.hideDisconnectionScreen) ~ ", message: " ~ std.conv.to!string(this.message) ~ ")"; 251 } 252 253 } 254 255 class Batch : Buffer { 256 257 public enum ubyte ID = 6; 258 259 public enum bool CLIENTBOUND = true; 260 public enum bool SERVERBOUND = true; 261 262 public enum string[] FIELDS = ["data"]; 263 264 public ubyte[] data; 265 266 public pure nothrow @safe @nogc this() {} 267 268 public pure nothrow @safe @nogc this(ubyte[] data) { 269 this.data = data; 270 } 271 272 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 273 _buffer.length = 0; 274 static if(writeId){ writeBigEndianUbyte(ID); } 275 writeBytes(varuint.encode(cast(uint)data.length)); writeBytes(data); 276 return _buffer; 277 } 278 279 public pure nothrow @safe void decode(bool readId=true)() { 280 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 281 data.length=varuint.decode(_buffer, &_index); if(_buffer.length>=_index+data.length){ data=_buffer[_index.._index+data.length].dup; _index+=data.length; } 282 } 283 284 public static pure nothrow @safe Batch fromBuffer(bool readId=true)(ubyte[] buffer) { 285 Batch ret = new Batch(); 286 ret._buffer = buffer; 287 ret.decode!readId(); 288 return ret; 289 } 290 291 public override string toString() { 292 return "Batch(data: " ~ std.conv.to!string(this.data) ~ ")"; 293 } 294 295 } 296 297 class ResourcePacksInfo : Buffer { 298 299 public enum ubyte ID = 7; 300 301 public enum bool CLIENTBOUND = true; 302 public enum bool SERVERBOUND = false; 303 304 public enum string[] FIELDS = ["mustAccept", "behaviourPacks", "resourcePacks"]; 305 306 public bool mustAccept; 307 public sul.protocol.pocket102.types.PackWithSize[] behaviourPacks; 308 public sul.protocol.pocket102.types.PackWithSize[] resourcePacks; 309 310 public pure nothrow @safe @nogc this() {} 311 312 public pure nothrow @safe @nogc this(bool mustAccept, sul.protocol.pocket102.types.PackWithSize[] behaviourPacks=(sul.protocol.pocket102.types.PackWithSize[]).init, sul.protocol.pocket102.types.PackWithSize[] resourcePacks=(sul.protocol.pocket102.types.PackWithSize[]).init) { 313 this.mustAccept = mustAccept; 314 this.behaviourPacks = behaviourPacks; 315 this.resourcePacks = resourcePacks; 316 } 317 318 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 319 _buffer.length = 0; 320 static if(writeId){ writeBigEndianUbyte(ID); } 321 writeBigEndianBool(mustAccept); 322 writeLittleEndianUshort(cast(ushort)behaviourPacks.length); foreach(yvyzbvuf;behaviourPacks){ yvyzbvuf.encode(bufferInstance); } 323 writeLittleEndianUshort(cast(ushort)resourcePacks.length); foreach(cvbvyvyn;resourcePacks){ cvbvyvyn.encode(bufferInstance); } 324 return _buffer; 325 } 326 327 public pure nothrow @safe void decode(bool readId=true)() { 328 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 329 mustAccept=readBigEndianBool(); 330 behaviourPacks.length=readLittleEndianUshort(); foreach(ref yvyzbvuf;behaviourPacks){ yvyzbvuf.decode(bufferInstance); } 331 resourcePacks.length=readLittleEndianUshort(); foreach(ref cvbvyvyn;resourcePacks){ cvbvyvyn.decode(bufferInstance); } 332 } 333 334 public static pure nothrow @safe ResourcePacksInfo fromBuffer(bool readId=true)(ubyte[] buffer) { 335 ResourcePacksInfo ret = new ResourcePacksInfo(); 336 ret._buffer = buffer; 337 ret.decode!readId(); 338 return ret; 339 } 340 341 public override string toString() { 342 return "ResourcePacksInfo(mustAccept: " ~ std.conv.to!string(this.mustAccept) ~ ", behaviourPacks: " ~ std.conv.to!string(this.behaviourPacks) ~ ", resourcePacks: " ~ std.conv.to!string(this.resourcePacks) ~ ")"; 343 } 344 345 } 346 347 class ResourcePacksStackPacket : Buffer { 348 349 public enum ubyte ID = 8; 350 351 public enum bool CLIENTBOUND = true; 352 public enum bool SERVERBOUND = false; 353 354 public enum string[] FIELDS = ["mustAccept", "behaviourPacks", "resourcePacks"]; 355 356 public bool mustAccept; 357 public sul.protocol.pocket102.types.Pack[] behaviourPacks; 358 public sul.protocol.pocket102.types.Pack[] resourcePacks; 359 360 public pure nothrow @safe @nogc this() {} 361 362 public pure nothrow @safe @nogc this(bool mustAccept, sul.protocol.pocket102.types.Pack[] behaviourPacks=(sul.protocol.pocket102.types.Pack[]).init, sul.protocol.pocket102.types.Pack[] resourcePacks=(sul.protocol.pocket102.types.Pack[]).init) { 363 this.mustAccept = mustAccept; 364 this.behaviourPacks = behaviourPacks; 365 this.resourcePacks = resourcePacks; 366 } 367 368 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 369 _buffer.length = 0; 370 static if(writeId){ writeBigEndianUbyte(ID); } 371 writeBigEndianBool(mustAccept); 372 writeLittleEndianUshort(cast(ushort)behaviourPacks.length); foreach(yvyzbvuf;behaviourPacks){ yvyzbvuf.encode(bufferInstance); } 373 writeLittleEndianUshort(cast(ushort)resourcePacks.length); foreach(cvbvyvyn;resourcePacks){ cvbvyvyn.encode(bufferInstance); } 374 return _buffer; 375 } 376 377 public pure nothrow @safe void decode(bool readId=true)() { 378 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 379 mustAccept=readBigEndianBool(); 380 behaviourPacks.length=readLittleEndianUshort(); foreach(ref yvyzbvuf;behaviourPacks){ yvyzbvuf.decode(bufferInstance); } 381 resourcePacks.length=readLittleEndianUshort(); foreach(ref cvbvyvyn;resourcePacks){ cvbvyvyn.decode(bufferInstance); } 382 } 383 384 public static pure nothrow @safe ResourcePacksStackPacket fromBuffer(bool readId=true)(ubyte[] buffer) { 385 ResourcePacksStackPacket ret = new ResourcePacksStackPacket(); 386 ret._buffer = buffer; 387 ret.decode!readId(); 388 return ret; 389 } 390 391 public override string toString() { 392 return "ResourcePacksStackPacket(mustAccept: " ~ std.conv.to!string(this.mustAccept) ~ ", behaviourPacks: " ~ std.conv.to!string(this.behaviourPacks) ~ ", resourcePacks: " ~ std.conv.to!string(this.resourcePacks) ~ ")"; 393 } 394 395 } 396 397 class ResourcePackClientResponse : Buffer { 398 399 public enum ubyte ID = 9; 400 401 public enum bool CLIENTBOUND = false; 402 public enum bool SERVERBOUND = true; 403 404 // status 405 public enum ubyte REFUSED = 1; 406 public enum ubyte SEND_PACKS = 2; 407 public enum ubyte HAVE_ALL_PACKS = 3; 408 public enum ubyte COMPLETED = 4; 409 410 public enum string[] FIELDS = ["status", "packIds"]; 411 412 public ubyte status; 413 public string[] packIds; 414 415 public pure nothrow @safe @nogc this() {} 416 417 public pure nothrow @safe @nogc this(ubyte status, string[] packIds=(string[]).init) { 418 this.status = status; 419 this.packIds = packIds; 420 } 421 422 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 423 _buffer.length = 0; 424 static if(writeId){ writeBigEndianUbyte(ID); } 425 writeBigEndianUbyte(status); 426 writeLittleEndianUshort(cast(ushort)packIds.length); foreach(cfalc;packIds){ writeBytes(varuint.encode(cast(uint)cfalc.length)); writeString(cfalc); } 427 return _buffer; 428 } 429 430 public pure nothrow @safe void decode(bool readId=true)() { 431 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 432 status=readBigEndianUbyte(); 433 packIds.length=readLittleEndianUshort(); foreach(ref cfalc;packIds){ uint yzbm=varuint.decode(_buffer, &_index); cfalc=readString(yzbm); } 434 } 435 436 public static pure nothrow @safe ResourcePackClientResponse fromBuffer(bool readId=true)(ubyte[] buffer) { 437 ResourcePackClientResponse ret = new ResourcePackClientResponse(); 438 ret._buffer = buffer; 439 ret.decode!readId(); 440 return ret; 441 } 442 443 public override string toString() { 444 return "ResourcePackClientResponse(status: " ~ std.conv.to!string(this.status) ~ ", packIds: " ~ std.conv.to!string(this.packIds) ~ ")"; 445 } 446 447 } 448 449 class Text : Buffer { 450 451 public enum ubyte ID = 10; 452 453 public enum bool CLIENTBOUND = true; 454 public enum bool SERVERBOUND = true; 455 456 public enum string[] FIELDS = ["type"]; 457 458 public ubyte type; 459 460 public pure nothrow @safe @nogc this() {} 461 462 public pure nothrow @safe @nogc this(ubyte type) { 463 this.type = type; 464 } 465 466 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 467 _buffer.length = 0; 468 static if(writeId){ writeBigEndianUbyte(ID); } 469 writeBigEndianUbyte(type); 470 return _buffer; 471 } 472 473 public pure nothrow @safe void decode(bool readId=true)() { 474 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 475 type=readBigEndianUbyte(); 476 } 477 478 public static pure nothrow @safe Text fromBuffer(bool readId=true)(ubyte[] buffer) { 479 Text ret = new Text(); 480 ret._buffer = buffer; 481 ret.decode!readId(); 482 return ret; 483 } 484 485 public override string toString() { 486 return "Text(type: " ~ std.conv.to!string(this.type) ~ ")"; 487 } 488 489 alias _encode = encode; 490 491 enum string variantField = "type"; 492 493 alias Variants = TypeTuple!(Raw, Chat, Translation, Popup, Tip, System, Whisper); 494 495 public class Raw { 496 497 public enum typeof(type) TYPE = 0; 498 499 public enum string[] FIELDS = ["message"]; 500 501 public string message; 502 503 public pure nothrow @safe @nogc this() {} 504 505 public pure nothrow @safe @nogc this(string message) { 506 this.message = message; 507 } 508 509 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 510 type = 0; 511 _encode!writeId(); 512 writeBytes(varuint.encode(cast(uint)message.length)); writeString(message); 513 return _buffer; 514 } 515 516 public pure nothrow @safe void decode() { 517 uint bvcfz=varuint.decode(_buffer, &_index); message=readString(bvcfz); 518 } 519 520 public override string toString() { 521 return "Text.Raw(message: " ~ std.conv.to!string(this.message) ~ ")"; 522 } 523 524 } 525 526 public class Chat { 527 528 public enum typeof(type) TYPE = 1; 529 530 public enum string[] FIELDS = ["sender", "message"]; 531 532 public string sender; 533 public string message; 534 535 public pure nothrow @safe @nogc this() {} 536 537 public pure nothrow @safe @nogc this(string sender, string message=string.init) { 538 this.sender = sender; 539 this.message = message; 540 } 541 542 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 543 type = 1; 544 _encode!writeId(); 545 writeBytes(varuint.encode(cast(uint)sender.length)); writeString(sender); 546 writeBytes(varuint.encode(cast(uint)message.length)); writeString(message); 547 return _buffer; 548 } 549 550 public pure nothrow @safe void decode() { 551 uint cvzv=varuint.decode(_buffer, &_index); sender=readString(cvzv); 552 uint bvcfz=varuint.decode(_buffer, &_index); message=readString(bvcfz); 553 } 554 555 public override string toString() { 556 return "Text.Chat(sender: " ~ std.conv.to!string(this.sender) ~ ", message: " ~ std.conv.to!string(this.message) ~ ")"; 557 } 558 559 } 560 561 public class Translation { 562 563 public enum typeof(type) TYPE = 2; 564 565 public enum string[] FIELDS = ["message", "parameters"]; 566 567 public string message; 568 public string[] parameters; 569 570 public pure nothrow @safe @nogc this() {} 571 572 public pure nothrow @safe @nogc this(string message, string[] parameters=(string[]).init) { 573 this.message = message; 574 this.parameters = parameters; 575 } 576 577 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 578 type = 2; 579 _encode!writeId(); 580 writeBytes(varuint.encode(cast(uint)message.length)); writeString(message); 581 writeBytes(varuint.encode(cast(uint)parameters.length)); foreach(cfy1dvc;parameters){ writeBytes(varuint.encode(cast(uint)cfy1dvc.length)); writeString(cfy1dvc); } 582 return _buffer; 583 } 584 585 public pure nothrow @safe void decode() { 586 uint bvcfz=varuint.decode(_buffer, &_index); message=readString(bvcfz); 587 parameters.length=varuint.decode(_buffer, &_index); foreach(ref cfy1dvc;parameters){ uint yzmry=varuint.decode(_buffer, &_index); cfy1dvc=readString(yzmry); } 588 } 589 590 public override string toString() { 591 return "Text.Translation(message: " ~ std.conv.to!string(this.message) ~ ", parameters: " ~ std.conv.to!string(this.parameters) ~ ")"; 592 } 593 594 } 595 596 public class Popup { 597 598 public enum typeof(type) TYPE = 3; 599 600 public enum string[] FIELDS = ["title", "subtitle"]; 601 602 public string title; 603 public string subtitle; 604 605 public pure nothrow @safe @nogc this() {} 606 607 public pure nothrow @safe @nogc this(string title, string subtitle=string.init) { 608 this.title = title; 609 this.subtitle = subtitle; 610 } 611 612 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 613 type = 3; 614 _encode!writeId(); 615 writeBytes(varuint.encode(cast(uint)title.length)); writeString(title); 616 writeBytes(varuint.encode(cast(uint)subtitle.length)); writeString(subtitle); 617 return _buffer; 618 } 619 620 public pure nothrow @safe void decode() { 621 uint dlbu=varuint.decode(_buffer, &_index); title=readString(dlbu); 622 uint cvdlbu=varuint.decode(_buffer, &_index); subtitle=readString(cvdlbu); 623 } 624 625 public override string toString() { 626 return "Text.Popup(title: " ~ std.conv.to!string(this.title) ~ ", subtitle: " ~ std.conv.to!string(this.subtitle) ~ ")"; 627 } 628 629 } 630 631 public class Tip { 632 633 public enum typeof(type) TYPE = 4; 634 635 public enum string[] FIELDS = ["message"]; 636 637 public string message; 638 639 public pure nothrow @safe @nogc this() {} 640 641 public pure nothrow @safe @nogc this(string message) { 642 this.message = message; 643 } 644 645 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 646 type = 4; 647 _encode!writeId(); 648 writeBytes(varuint.encode(cast(uint)message.length)); writeString(message); 649 return _buffer; 650 } 651 652 public pure nothrow @safe void decode() { 653 uint bvcfz=varuint.decode(_buffer, &_index); message=readString(bvcfz); 654 } 655 656 public override string toString() { 657 return "Text.Tip(message: " ~ std.conv.to!string(this.message) ~ ")"; 658 } 659 660 } 661 662 public class System { 663 664 public enum typeof(type) TYPE = 5; 665 666 public enum string[] FIELDS = ["message"]; 667 668 public string message; 669 670 public pure nothrow @safe @nogc this() {} 671 672 public pure nothrow @safe @nogc this(string message) { 673 this.message = message; 674 } 675 676 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 677 type = 5; 678 _encode!writeId(); 679 writeBytes(varuint.encode(cast(uint)message.length)); writeString(message); 680 return _buffer; 681 } 682 683 public pure nothrow @safe void decode() { 684 uint bvcfz=varuint.decode(_buffer, &_index); message=readString(bvcfz); 685 } 686 687 public override string toString() { 688 return "Text.System(message: " ~ std.conv.to!string(this.message) ~ ")"; 689 } 690 691 } 692 693 public class Whisper { 694 695 public enum typeof(type) TYPE = 6; 696 697 public enum string[] FIELDS = ["sender", "message"]; 698 699 public string sender; 700 public string message; 701 702 public pure nothrow @safe @nogc this() {} 703 704 public pure nothrow @safe @nogc this(string sender, string message=string.init) { 705 this.sender = sender; 706 this.message = message; 707 } 708 709 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 710 type = 6; 711 _encode!writeId(); 712 writeBytes(varuint.encode(cast(uint)sender.length)); writeString(sender); 713 writeBytes(varuint.encode(cast(uint)message.length)); writeString(message); 714 return _buffer; 715 } 716 717 public pure nothrow @safe void decode() { 718 uint cvzv=varuint.decode(_buffer, &_index); sender=readString(cvzv); 719 uint bvcfz=varuint.decode(_buffer, &_index); message=readString(bvcfz); 720 } 721 722 public override string toString() { 723 return "Text.Whisper(sender: " ~ std.conv.to!string(this.sender) ~ ", message: " ~ std.conv.to!string(this.message) ~ ")"; 724 } 725 726 } 727 728 } 729 730 class SetTime : Buffer { 731 732 public enum ubyte ID = 11; 733 734 public enum bool CLIENTBOUND = true; 735 public enum bool SERVERBOUND = false; 736 737 public enum string[] FIELDS = ["time", "daylightCycle"]; 738 739 public int time; 740 public bool daylightCycle; 741 742 public pure nothrow @safe @nogc this() {} 743 744 public pure nothrow @safe @nogc this(int time, bool daylightCycle=bool.init) { 745 this.time = time; 746 this.daylightCycle = daylightCycle; 747 } 748 749 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 750 _buffer.length = 0; 751 static if(writeId){ writeBigEndianUbyte(ID); } 752 writeBytes(varint.encode(time)); 753 writeBigEndianBool(daylightCycle); 754 return _buffer; 755 } 756 757 public pure nothrow @safe void decode(bool readId=true)() { 758 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 759 time=varint.decode(_buffer, &_index); 760 daylightCycle=readBigEndianBool(); 761 } 762 763 public static pure nothrow @safe SetTime fromBuffer(bool readId=true)(ubyte[] buffer) { 764 SetTime ret = new SetTime(); 765 ret._buffer = buffer; 766 ret.decode!readId(); 767 return ret; 768 } 769 770 public override string toString() { 771 return "SetTime(time: " ~ std.conv.to!string(this.time) ~ ", daylightCycle: " ~ std.conv.to!string(this.daylightCycle) ~ ")"; 772 } 773 774 } 775 776 class StartGame : Buffer { 777 778 public enum ubyte ID = 12; 779 780 public enum bool CLIENTBOUND = true; 781 public enum bool SERVERBOUND = false; 782 783 // dimension 784 public enum int OVERWORLD = 0; 785 public enum int NETHER = 1; 786 public enum int END = 2; 787 788 // generator 789 public enum int OLD = 0; 790 public enum int INFINITE = 1; 791 public enum int FLAT = 2; 792 793 // world gamemode 794 public enum int SURVIVAL = 0; 795 public enum int CREATIVE = 1; 796 797 // difficulty 798 public enum int PEACEFUL = 0; 799 public enum int EASY = 1; 800 public enum int NORMAL = 2; 801 public enum int HARD = 3; 802 803 // edition 804 public enum ubyte CLASSIC = 0; 805 public enum ubyte EDUCATION = 1; 806 807 public enum string[] FIELDS = ["entityId", "runtimeId", "position", "yaw", "pitch", "seed", "dimension", "generator", "worldGamemode", "difficulty", "spawnPosition", "loadedInCreative", "time", "edition", "rainLevel", "lightningLevel", "commandsEnabled", "textureRequired", "levelId", "worldName"]; 808 809 public long entityId; 810 public long runtimeId; 811 public Tuple!(float, "x", float, "y", float, "z") position; 812 public float yaw; 813 public float pitch; 814 public int seed; 815 public int dimension = 0; 816 public int generator = 1; 817 public int worldGamemode; 818 public int difficulty; 819 public Tuple!(int, "x", int, "y", int, "z") spawnPosition; 820 public bool loadedInCreative; 821 public int time; 822 public ubyte edition; 823 public float rainLevel; 824 public float lightningLevel; 825 public bool commandsEnabled; 826 public bool textureRequired; 827 public string levelId; 828 public string worldName; 829 830 public pure nothrow @safe @nogc this() {} 831 832 public pure nothrow @safe @nogc this(long entityId, long runtimeId=long.init, Tuple!(float, "x", float, "y", float, "z") position=Tuple!(float, "x", float, "y", float, "z").init, float yaw=float.init, float pitch=float.init, int seed=int.init, int dimension=0, int generator=1, int worldGamemode=int.init, int difficulty=int.init, Tuple!(int, "x", int, "y", int, "z") spawnPosition=Tuple!(int, "x", int, "y", int, "z").init, bool loadedInCreative=bool.init, int time=int.init, ubyte edition=ubyte.init, float rainLevel=float.init, float lightningLevel=float.init, bool commandsEnabled=bool.init, bool textureRequired=bool.init, string levelId=string.init, string worldName=string.init) { 833 this.entityId = entityId; 834 this.runtimeId = runtimeId; 835 this.position = position; 836 this.yaw = yaw; 837 this.pitch = pitch; 838 this.seed = seed; 839 this.dimension = dimension; 840 this.generator = generator; 841 this.worldGamemode = worldGamemode; 842 this.difficulty = difficulty; 843 this.spawnPosition = spawnPosition; 844 this.loadedInCreative = loadedInCreative; 845 this.time = time; 846 this.edition = edition; 847 this.rainLevel = rainLevel; 848 this.lightningLevel = lightningLevel; 849 this.commandsEnabled = commandsEnabled; 850 this.textureRequired = textureRequired; 851 this.levelId = levelId; 852 this.worldName = worldName; 853 } 854 855 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 856 _buffer.length = 0; 857 static if(writeId){ writeBigEndianUbyte(ID); } 858 writeBytes(varlong.encode(entityId)); 859 writeBytes(varlong.encode(runtimeId)); 860 writeLittleEndianFloat(position.x); writeLittleEndianFloat(position.y); writeLittleEndianFloat(position.z); 861 writeLittleEndianFloat(yaw); 862 writeLittleEndianFloat(pitch); 863 writeBytes(varint.encode(seed)); 864 writeBytes(varint.encode(dimension)); 865 writeBytes(varint.encode(generator)); 866 writeBytes(varint.encode(worldGamemode)); 867 writeBytes(varint.encode(difficulty)); 868 writeBytes(varint.encode(spawnPosition.x)); writeBytes(varint.encode(spawnPosition.y)); writeBytes(varint.encode(spawnPosition.z)); 869 writeBigEndianBool(loadedInCreative); 870 writeBytes(varint.encode(time)); 871 writeBigEndianUbyte(edition); 872 writeLittleEndianFloat(rainLevel); 873 writeLittleEndianFloat(lightningLevel); 874 writeBigEndianBool(commandsEnabled); 875 writeBigEndianBool(textureRequired); 876 writeBytes(varuint.encode(cast(uint)levelId.length)); writeString(levelId); 877 writeBytes(varuint.encode(cast(uint)worldName.length)); writeString(worldName); 878 return _buffer; 879 } 880 881 public pure nothrow @safe void decode(bool readId=true)() { 882 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 883 entityId=varlong.decode(_buffer, &_index); 884 runtimeId=varlong.decode(_buffer, &_index); 885 position.x=readLittleEndianFloat(); position.y=readLittleEndianFloat(); position.z=readLittleEndianFloat(); 886 yaw=readLittleEndianFloat(); 887 pitch=readLittleEndianFloat(); 888 seed=varint.decode(_buffer, &_index); 889 dimension=varint.decode(_buffer, &_index); 890 generator=varint.decode(_buffer, &_index); 891 worldGamemode=varint.decode(_buffer, &_index); 892 difficulty=varint.decode(_buffer, &_index); 893 spawnPosition.x=varint.decode(_buffer, &_index); spawnPosition.y=varint.decode(_buffer, &_index); spawnPosition.z=varint.decode(_buffer, &_index); 894 loadedInCreative=readBigEndianBool(); 895 time=varint.decode(_buffer, &_index); 896 edition=readBigEndianUbyte(); 897 rainLevel=readLittleEndianFloat(); 898 lightningLevel=readLittleEndianFloat(); 899 commandsEnabled=readBigEndianBool(); 900 textureRequired=readBigEndianBool(); 901 uint bvzxz=varuint.decode(_buffer, &_index); levelId=readString(bvzxz); 902 uint d9bry1=varuint.decode(_buffer, &_index); worldName=readString(d9bry1); 903 } 904 905 public static pure nothrow @safe StartGame fromBuffer(bool readId=true)(ubyte[] buffer) { 906 StartGame ret = new StartGame(); 907 ret._buffer = buffer; 908 ret.decode!readId(); 909 return ret; 910 } 911 912 public override string toString() { 913 return "StartGame(entityId: " ~ std.conv.to!string(this.entityId) ~ ", runtimeId: " ~ std.conv.to!string(this.runtimeId) ~ ", position: " ~ std.conv.to!string(this.position) ~ ", yaw: " ~ std.conv.to!string(this.yaw) ~ ", pitch: " ~ std.conv.to!string(this.pitch) ~ ", seed: " ~ std.conv.to!string(this.seed) ~ ", dimension: " ~ std.conv.to!string(this.dimension) ~ ", generator: " ~ std.conv.to!string(this.generator) ~ ", worldGamemode: " ~ std.conv.to!string(this.worldGamemode) ~ ", difficulty: " ~ std.conv.to!string(this.difficulty) ~ ", spawnPosition: " ~ std.conv.to!string(this.spawnPosition) ~ ", loadedInCreative: " ~ std.conv.to!string(this.loadedInCreative) ~ ", time: " ~ std.conv.to!string(this.time) ~ ", edition: " ~ std.conv.to!string(this.edition) ~ ", rainLevel: " ~ std.conv.to!string(this.rainLevel) ~ ", lightningLevel: " ~ std.conv.to!string(this.lightningLevel) ~ ", commandsEnabled: " ~ std.conv.to!string(this.commandsEnabled) ~ ", textureRequired: " ~ std.conv.to!string(this.textureRequired) ~ ", levelId: " ~ std.conv.to!string(this.levelId) ~ ", worldName: " ~ std.conv.to!string(this.worldName) ~ ")"; 914 } 915 916 } 917 918 class AddPlayer : Buffer { 919 920 public enum ubyte ID = 13; 921 922 public enum bool CLIENTBOUND = true; 923 public enum bool SERVERBOUND = false; 924 925 public enum string[] FIELDS = ["uuid", "username", "entityId", "runtimeId", "position", "motion", "pitch", "headYaw", "yaw", "heldItem", "metadata"]; 926 927 public UUID uuid; 928 public string username; 929 public long entityId; 930 public long runtimeId; 931 public Tuple!(float, "x", float, "y", float, "z") position; 932 public Tuple!(float, "x", float, "y", float, "z") motion; 933 public float pitch; 934 public float headYaw; 935 public float yaw; 936 public sul.protocol.pocket102.types.Slot heldItem; 937 public Metadata metadata; 938 939 public pure nothrow @safe @nogc this() {} 940 941 public pure nothrow @safe @nogc this(UUID uuid, string username=string.init, long entityId=long.init, long runtimeId=long.init, Tuple!(float, "x", float, "y", float, "z") position=Tuple!(float, "x", float, "y", float, "z").init, Tuple!(float, "x", float, "y", float, "z") motion=Tuple!(float, "x", float, "y", float, "z").init, float pitch=float.init, float headYaw=float.init, float yaw=float.init, sul.protocol.pocket102.types.Slot heldItem=sul.protocol.pocket102.types.Slot.init, Metadata metadata=Metadata.init) { 942 this.uuid = uuid; 943 this.username = username; 944 this.entityId = entityId; 945 this.runtimeId = runtimeId; 946 this.position = position; 947 this.motion = motion; 948 this.pitch = pitch; 949 this.headYaw = headYaw; 950 this.yaw = yaw; 951 this.heldItem = heldItem; 952 this.metadata = metadata; 953 } 954 955 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 956 _buffer.length = 0; 957 static if(writeId){ writeBigEndianUbyte(ID); } 958 writeBytes(uuid.data); 959 writeBytes(varuint.encode(cast(uint)username.length)); writeString(username); 960 writeBytes(varlong.encode(entityId)); 961 writeBytes(varlong.encode(runtimeId)); 962 writeLittleEndianFloat(position.x); writeLittleEndianFloat(position.y); writeLittleEndianFloat(position.z); 963 writeLittleEndianFloat(motion.x); writeLittleEndianFloat(motion.y); writeLittleEndianFloat(motion.z); 964 writeLittleEndianFloat(pitch); 965 writeLittleEndianFloat(headYaw); 966 writeLittleEndianFloat(yaw); 967 heldItem.encode(bufferInstance); 968 metadata.encode(bufferInstance); 969 return _buffer; 970 } 971 972 public pure nothrow @safe void decode(bool readId=true)() { 973 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 974 if(_buffer.length>=_index+16){ ubyte[16] dvz=_buffer[_index.._index+16].dup; _index+=16; uuid=UUID(dvz); } 975 uint dnc5bu=varuint.decode(_buffer, &_index); username=readString(dnc5bu); 976 entityId=varlong.decode(_buffer, &_index); 977 runtimeId=varlong.decode(_buffer, &_index); 978 position.x=readLittleEndianFloat(); position.y=readLittleEndianFloat(); position.z=readLittleEndianFloat(); 979 motion.x=readLittleEndianFloat(); motion.y=readLittleEndianFloat(); motion.z=readLittleEndianFloat(); 980 pitch=readLittleEndianFloat(); 981 headYaw=readLittleEndianFloat(); 982 yaw=readLittleEndianFloat(); 983 heldItem.decode(bufferInstance); 984 metadata=Metadata.decode(bufferInstance); 985 } 986 987 public static pure nothrow @safe AddPlayer fromBuffer(bool readId=true)(ubyte[] buffer) { 988 AddPlayer ret = new AddPlayer(); 989 ret._buffer = buffer; 990 ret.decode!readId(); 991 return ret; 992 } 993 994 public override string toString() { 995 return "AddPlayer(uuid: " ~ std.conv.to!string(this.uuid) ~ ", username: " ~ std.conv.to!string(this.username) ~ ", entityId: " ~ std.conv.to!string(this.entityId) ~ ", runtimeId: " ~ std.conv.to!string(this.runtimeId) ~ ", position: " ~ std.conv.to!string(this.position) ~ ", motion: " ~ std.conv.to!string(this.motion) ~ ", pitch: " ~ std.conv.to!string(this.pitch) ~ ", headYaw: " ~ std.conv.to!string(this.headYaw) ~ ", yaw: " ~ std.conv.to!string(this.yaw) ~ ", heldItem: " ~ std.conv.to!string(this.heldItem) ~ ", metadata: " ~ std.conv.to!string(this.metadata) ~ ")"; 996 } 997 998 } 999 1000 class AddEntity : Buffer { 1001 1002 public enum ubyte ID = 14; 1003 1004 public enum bool CLIENTBOUND = true; 1005 public enum bool SERVERBOUND = false; 1006 1007 public enum string[] FIELDS = ["entityId", "runtimeId", "type", "position", "motion", "pitch", "yaw", "attributes", "metadata", "links"]; 1008 1009 public long entityId; 1010 public long runtimeId; 1011 public uint type; 1012 public Tuple!(float, "x", float, "y", float, "z") position; 1013 public Tuple!(float, "x", float, "y", float, "z") motion; 1014 public float pitch; 1015 public float yaw; 1016 public sul.protocol.pocket102.types.Attribute[] attributes; 1017 public Metadata metadata; 1018 public sul.protocol.pocket102.types.Link[] links; 1019 1020 public pure nothrow @safe @nogc this() {} 1021 1022 public pure nothrow @safe @nogc this(long entityId, long runtimeId=long.init, uint type=uint.init, Tuple!(float, "x", float, "y", float, "z") position=Tuple!(float, "x", float, "y", float, "z").init, Tuple!(float, "x", float, "y", float, "z") motion=Tuple!(float, "x", float, "y", float, "z").init, float pitch=float.init, float yaw=float.init, sul.protocol.pocket102.types.Attribute[] attributes=(sul.protocol.pocket102.types.Attribute[]).init, Metadata metadata=Metadata.init, sul.protocol.pocket102.types.Link[] links=(sul.protocol.pocket102.types.Link[]).init) { 1023 this.entityId = entityId; 1024 this.runtimeId = runtimeId; 1025 this.type = type; 1026 this.position = position; 1027 this.motion = motion; 1028 this.pitch = pitch; 1029 this.yaw = yaw; 1030 this.attributes = attributes; 1031 this.metadata = metadata; 1032 this.links = links; 1033 } 1034 1035 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 1036 _buffer.length = 0; 1037 static if(writeId){ writeBigEndianUbyte(ID); } 1038 writeBytes(varlong.encode(entityId)); 1039 writeBytes(varlong.encode(runtimeId)); 1040 writeBytes(varuint.encode(type)); 1041 writeLittleEndianFloat(position.x); writeLittleEndianFloat(position.y); writeLittleEndianFloat(position.z); 1042 writeLittleEndianFloat(motion.x); writeLittleEndianFloat(motion.y); writeLittleEndianFloat(motion.z); 1043 writeLittleEndianFloat(pitch); 1044 writeLittleEndianFloat(yaw); 1045 writeBytes(varuint.encode(cast(uint)attributes.length)); foreach(yrcldrc;attributes){ yrcldrc.encode(bufferInstance); } 1046 metadata.encode(bufferInstance); 1047 writeBytes(varuint.encode(cast(uint)links.length)); foreach(blam;links){ blam.encode(bufferInstance); } 1048 return _buffer; 1049 } 1050 1051 public pure nothrow @safe void decode(bool readId=true)() { 1052 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 1053 entityId=varlong.decode(_buffer, &_index); 1054 runtimeId=varlong.decode(_buffer, &_index); 1055 type=varuint.decode(_buffer, &_index); 1056 position.x=readLittleEndianFloat(); position.y=readLittleEndianFloat(); position.z=readLittleEndianFloat(); 1057 motion.x=readLittleEndianFloat(); motion.y=readLittleEndianFloat(); motion.z=readLittleEndianFloat(); 1058 pitch=readLittleEndianFloat(); 1059 yaw=readLittleEndianFloat(); 1060 attributes.length=varuint.decode(_buffer, &_index); foreach(ref yrcldrc;attributes){ yrcldrc.decode(bufferInstance); } 1061 metadata=Metadata.decode(bufferInstance); 1062 links.length=varuint.decode(_buffer, &_index); foreach(ref blam;links){ blam.decode(bufferInstance); } 1063 } 1064 1065 public static pure nothrow @safe AddEntity fromBuffer(bool readId=true)(ubyte[] buffer) { 1066 AddEntity ret = new AddEntity(); 1067 ret._buffer = buffer; 1068 ret.decode!readId(); 1069 return ret; 1070 } 1071 1072 public override string toString() { 1073 return "AddEntity(entityId: " ~ std.conv.to!string(this.entityId) ~ ", runtimeId: " ~ std.conv.to!string(this.runtimeId) ~ ", type: " ~ std.conv.to!string(this.type) ~ ", position: " ~ std.conv.to!string(this.position) ~ ", motion: " ~ std.conv.to!string(this.motion) ~ ", pitch: " ~ std.conv.to!string(this.pitch) ~ ", yaw: " ~ std.conv.to!string(this.yaw) ~ ", attributes: " ~ std.conv.to!string(this.attributes) ~ ", metadata: " ~ std.conv.to!string(this.metadata) ~ ", links: " ~ std.conv.to!string(this.links) ~ ")"; 1074 } 1075 1076 } 1077 1078 class RemoveEntity : Buffer { 1079 1080 public enum ubyte ID = 15; 1081 1082 public enum bool CLIENTBOUND = true; 1083 public enum bool SERVERBOUND = false; 1084 1085 public enum string[] FIELDS = ["entityId"]; 1086 1087 public long entityId; 1088 1089 public pure nothrow @safe @nogc this() {} 1090 1091 public pure nothrow @safe @nogc this(long entityId) { 1092 this.entityId = entityId; 1093 } 1094 1095 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 1096 _buffer.length = 0; 1097 static if(writeId){ writeBigEndianUbyte(ID); } 1098 writeBytes(varlong.encode(entityId)); 1099 return _buffer; 1100 } 1101 1102 public pure nothrow @safe void decode(bool readId=true)() { 1103 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 1104 entityId=varlong.decode(_buffer, &_index); 1105 } 1106 1107 public static pure nothrow @safe RemoveEntity fromBuffer(bool readId=true)(ubyte[] buffer) { 1108 RemoveEntity ret = new RemoveEntity(); 1109 ret._buffer = buffer; 1110 ret.decode!readId(); 1111 return ret; 1112 } 1113 1114 public override string toString() { 1115 return "RemoveEntity(entityId: " ~ std.conv.to!string(this.entityId) ~ ")"; 1116 } 1117 1118 } 1119 1120 class AddItemEntity : Buffer { 1121 1122 public enum ubyte ID = 16; 1123 1124 public enum bool CLIENTBOUND = true; 1125 public enum bool SERVERBOUND = false; 1126 1127 public enum string[] FIELDS = ["entityId", "runtimeId", "item", "position", "motion"]; 1128 1129 public long entityId; 1130 public long runtimeId; 1131 public sul.protocol.pocket102.types.Slot item; 1132 public Tuple!(float, "x", float, "y", float, "z") position; 1133 public Tuple!(float, "x", float, "y", float, "z") motion; 1134 1135 public pure nothrow @safe @nogc this() {} 1136 1137 public pure nothrow @safe @nogc this(long entityId, long runtimeId=long.init, sul.protocol.pocket102.types.Slot item=sul.protocol.pocket102.types.Slot.init, Tuple!(float, "x", float, "y", float, "z") position=Tuple!(float, "x", float, "y", float, "z").init, Tuple!(float, "x", float, "y", float, "z") motion=Tuple!(float, "x", float, "y", float, "z").init) { 1138 this.entityId = entityId; 1139 this.runtimeId = runtimeId; 1140 this.item = item; 1141 this.position = position; 1142 this.motion = motion; 1143 } 1144 1145 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 1146 _buffer.length = 0; 1147 static if(writeId){ writeBigEndianUbyte(ID); } 1148 writeBytes(varlong.encode(entityId)); 1149 writeBytes(varlong.encode(runtimeId)); 1150 item.encode(bufferInstance); 1151 writeLittleEndianFloat(position.x); writeLittleEndianFloat(position.y); writeLittleEndianFloat(position.z); 1152 writeLittleEndianFloat(motion.x); writeLittleEndianFloat(motion.y); writeLittleEndianFloat(motion.z); 1153 return _buffer; 1154 } 1155 1156 public pure nothrow @safe void decode(bool readId=true)() { 1157 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 1158 entityId=varlong.decode(_buffer, &_index); 1159 runtimeId=varlong.decode(_buffer, &_index); 1160 item.decode(bufferInstance); 1161 position.x=readLittleEndianFloat(); position.y=readLittleEndianFloat(); position.z=readLittleEndianFloat(); 1162 motion.x=readLittleEndianFloat(); motion.y=readLittleEndianFloat(); motion.z=readLittleEndianFloat(); 1163 } 1164 1165 public static pure nothrow @safe AddItemEntity fromBuffer(bool readId=true)(ubyte[] buffer) { 1166 AddItemEntity ret = new AddItemEntity(); 1167 ret._buffer = buffer; 1168 ret.decode!readId(); 1169 return ret; 1170 } 1171 1172 public override string toString() { 1173 return "AddItemEntity(entityId: " ~ std.conv.to!string(this.entityId) ~ ", runtimeId: " ~ std.conv.to!string(this.runtimeId) ~ ", item: " ~ std.conv.to!string(this.item) ~ ", position: " ~ std.conv.to!string(this.position) ~ ", motion: " ~ std.conv.to!string(this.motion) ~ ")"; 1174 } 1175 1176 } 1177 1178 class AddHangingEntity : Buffer { 1179 1180 public enum ubyte ID = 17; 1181 1182 public enum bool CLIENTBOUND = true; 1183 public enum bool SERVERBOUND = false; 1184 1185 public enum string[] FIELDS = ["entityId", "runtimeId", "position", "unknown3"]; 1186 1187 public long entityId; 1188 public long runtimeId; 1189 public sul.protocol.pocket102.types.BlockPosition position; 1190 public int unknown3; 1191 1192 public pure nothrow @safe @nogc this() {} 1193 1194 public pure nothrow @safe @nogc this(long entityId, long runtimeId=long.init, sul.protocol.pocket102.types.BlockPosition position=sul.protocol.pocket102.types.BlockPosition.init, int unknown3=int.init) { 1195 this.entityId = entityId; 1196 this.runtimeId = runtimeId; 1197 this.position = position; 1198 this.unknown3 = unknown3; 1199 } 1200 1201 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 1202 _buffer.length = 0; 1203 static if(writeId){ writeBigEndianUbyte(ID); } 1204 writeBytes(varlong.encode(entityId)); 1205 writeBytes(varlong.encode(runtimeId)); 1206 position.encode(bufferInstance); 1207 writeBytes(varint.encode(unknown3)); 1208 return _buffer; 1209 } 1210 1211 public pure nothrow @safe void decode(bool readId=true)() { 1212 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 1213 entityId=varlong.decode(_buffer, &_index); 1214 runtimeId=varlong.decode(_buffer, &_index); 1215 position.decode(bufferInstance); 1216 unknown3=varint.decode(_buffer, &_index); 1217 } 1218 1219 public static pure nothrow @safe AddHangingEntity fromBuffer(bool readId=true)(ubyte[] buffer) { 1220 AddHangingEntity ret = new AddHangingEntity(); 1221 ret._buffer = buffer; 1222 ret.decode!readId(); 1223 return ret; 1224 } 1225 1226 public override string toString() { 1227 return "AddHangingEntity(entityId: " ~ std.conv.to!string(this.entityId) ~ ", runtimeId: " ~ std.conv.to!string(this.runtimeId) ~ ", position: " ~ std.conv.to!string(this.position) ~ ", unknown3: " ~ std.conv.to!string(this.unknown3) ~ ")"; 1228 } 1229 1230 } 1231 1232 class TakeItemEntity : Buffer { 1233 1234 public enum ubyte ID = 18; 1235 1236 public enum bool CLIENTBOUND = true; 1237 public enum bool SERVERBOUND = false; 1238 1239 public enum string[] FIELDS = ["collected", "collector"]; 1240 1241 public long collected; 1242 public long collector; 1243 1244 public pure nothrow @safe @nogc this() {} 1245 1246 public pure nothrow @safe @nogc this(long collected, long collector=long.init) { 1247 this.collected = collected; 1248 this.collector = collector; 1249 } 1250 1251 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 1252 _buffer.length = 0; 1253 static if(writeId){ writeBigEndianUbyte(ID); } 1254 writeBytes(varlong.encode(collected)); 1255 writeBytes(varlong.encode(collector)); 1256 return _buffer; 1257 } 1258 1259 public pure nothrow @safe void decode(bool readId=true)() { 1260 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 1261 collected=varlong.decode(_buffer, &_index); 1262 collector=varlong.decode(_buffer, &_index); 1263 } 1264 1265 public static pure nothrow @safe TakeItemEntity fromBuffer(bool readId=true)(ubyte[] buffer) { 1266 TakeItemEntity ret = new TakeItemEntity(); 1267 ret._buffer = buffer; 1268 ret.decode!readId(); 1269 return ret; 1270 } 1271 1272 public override string toString() { 1273 return "TakeItemEntity(collected: " ~ std.conv.to!string(this.collected) ~ ", collector: " ~ std.conv.to!string(this.collector) ~ ")"; 1274 } 1275 1276 } 1277 1278 class MoveEntity : Buffer { 1279 1280 public enum ubyte ID = 19; 1281 1282 public enum bool CLIENTBOUND = true; 1283 public enum bool SERVERBOUND = false; 1284 1285 public enum string[] FIELDS = ["entityId", "position", "pitch", "headYaw", "yaw"]; 1286 1287 public long entityId; 1288 public Tuple!(float, "x", float, "y", float, "z") position; 1289 public ubyte pitch; 1290 public ubyte headYaw; 1291 public ubyte yaw; 1292 1293 public pure nothrow @safe @nogc this() {} 1294 1295 public pure nothrow @safe @nogc this(long entityId, Tuple!(float, "x", float, "y", float, "z") position=Tuple!(float, "x", float, "y", float, "z").init, ubyte pitch=ubyte.init, ubyte headYaw=ubyte.init, ubyte yaw=ubyte.init) { 1296 this.entityId = entityId; 1297 this.position = position; 1298 this.pitch = pitch; 1299 this.headYaw = headYaw; 1300 this.yaw = yaw; 1301 } 1302 1303 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 1304 _buffer.length = 0; 1305 static if(writeId){ writeBigEndianUbyte(ID); } 1306 writeBytes(varlong.encode(entityId)); 1307 writeLittleEndianFloat(position.x); writeLittleEndianFloat(position.y); writeLittleEndianFloat(position.z); 1308 writeBigEndianUbyte(pitch); 1309 writeBigEndianUbyte(headYaw); 1310 writeBigEndianUbyte(yaw); 1311 return _buffer; 1312 } 1313 1314 public pure nothrow @safe void decode(bool readId=true)() { 1315 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 1316 entityId=varlong.decode(_buffer, &_index); 1317 position.x=readLittleEndianFloat(); position.y=readLittleEndianFloat(); position.z=readLittleEndianFloat(); 1318 pitch=readBigEndianUbyte(); 1319 headYaw=readBigEndianUbyte(); 1320 yaw=readBigEndianUbyte(); 1321 } 1322 1323 public static pure nothrow @safe MoveEntity fromBuffer(bool readId=true)(ubyte[] buffer) { 1324 MoveEntity ret = new MoveEntity(); 1325 ret._buffer = buffer; 1326 ret.decode!readId(); 1327 return ret; 1328 } 1329 1330 public override string toString() { 1331 return "MoveEntity(entityId: " ~ std.conv.to!string(this.entityId) ~ ", position: " ~ std.conv.to!string(this.position) ~ ", pitch: " ~ std.conv.to!string(this.pitch) ~ ", headYaw: " ~ std.conv.to!string(this.headYaw) ~ ", yaw: " ~ std.conv.to!string(this.yaw) ~ ")"; 1332 } 1333 1334 } 1335 1336 class MovePlayer : Buffer { 1337 1338 public enum ubyte ID = 20; 1339 1340 public enum bool CLIENTBOUND = true; 1341 public enum bool SERVERBOUND = true; 1342 1343 // animation 1344 public enum ubyte FULL = 0; 1345 public enum ubyte NONE = 1; 1346 public enum ubyte ROTATION = 2; 1347 1348 public enum string[] FIELDS = ["entityId", "position", "pitch", "headYaw", "yaw", "animation", "onGround"]; 1349 1350 public long entityId; 1351 public Tuple!(float, "x", float, "y", float, "z") position; 1352 public float pitch; 1353 public float headYaw; 1354 public float yaw; 1355 public ubyte animation; 1356 public bool onGround; 1357 1358 public pure nothrow @safe @nogc this() {} 1359 1360 public pure nothrow @safe @nogc this(long entityId, Tuple!(float, "x", float, "y", float, "z") position=Tuple!(float, "x", float, "y", float, "z").init, float pitch=float.init, float headYaw=float.init, float yaw=float.init, ubyte animation=ubyte.init, bool onGround=bool.init) { 1361 this.entityId = entityId; 1362 this.position = position; 1363 this.pitch = pitch; 1364 this.headYaw = headYaw; 1365 this.yaw = yaw; 1366 this.animation = animation; 1367 this.onGround = onGround; 1368 } 1369 1370 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 1371 _buffer.length = 0; 1372 static if(writeId){ writeBigEndianUbyte(ID); } 1373 writeBytes(varlong.encode(entityId)); 1374 writeLittleEndianFloat(position.x); writeLittleEndianFloat(position.y); writeLittleEndianFloat(position.z); 1375 writeLittleEndianFloat(pitch); 1376 writeLittleEndianFloat(headYaw); 1377 writeLittleEndianFloat(yaw); 1378 writeBigEndianUbyte(animation); 1379 writeBigEndianBool(onGround); 1380 return _buffer; 1381 } 1382 1383 public pure nothrow @safe void decode(bool readId=true)() { 1384 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 1385 entityId=varlong.decode(_buffer, &_index); 1386 position.x=readLittleEndianFloat(); position.y=readLittleEndianFloat(); position.z=readLittleEndianFloat(); 1387 pitch=readLittleEndianFloat(); 1388 headYaw=readLittleEndianFloat(); 1389 yaw=readLittleEndianFloat(); 1390 animation=readBigEndianUbyte(); 1391 onGround=readBigEndianBool(); 1392 } 1393 1394 public static pure nothrow @safe MovePlayer fromBuffer(bool readId=true)(ubyte[] buffer) { 1395 MovePlayer ret = new MovePlayer(); 1396 ret._buffer = buffer; 1397 ret.decode!readId(); 1398 return ret; 1399 } 1400 1401 public override string toString() { 1402 return "MovePlayer(entityId: " ~ std.conv.to!string(this.entityId) ~ ", position: " ~ std.conv.to!string(this.position) ~ ", pitch: " ~ std.conv.to!string(this.pitch) ~ ", headYaw: " ~ std.conv.to!string(this.headYaw) ~ ", yaw: " ~ std.conv.to!string(this.yaw) ~ ", animation: " ~ std.conv.to!string(this.animation) ~ ", onGround: " ~ std.conv.to!string(this.onGround) ~ ")"; 1403 } 1404 1405 } 1406 1407 class RiderJump : Buffer { 1408 1409 public enum ubyte ID = 21; 1410 1411 public enum bool CLIENTBOUND = true; 1412 public enum bool SERVERBOUND = true; 1413 1414 public enum string[] FIELDS = ["rider"]; 1415 1416 public long rider; 1417 1418 public pure nothrow @safe @nogc this() {} 1419 1420 public pure nothrow @safe @nogc this(long rider) { 1421 this.rider = rider; 1422 } 1423 1424 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 1425 _buffer.length = 0; 1426 static if(writeId){ writeBigEndianUbyte(ID); } 1427 writeBytes(varlong.encode(rider)); 1428 return _buffer; 1429 } 1430 1431 public pure nothrow @safe void decode(bool readId=true)() { 1432 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 1433 rider=varlong.decode(_buffer, &_index); 1434 } 1435 1436 public static pure nothrow @safe RiderJump fromBuffer(bool readId=true)(ubyte[] buffer) { 1437 RiderJump ret = new RiderJump(); 1438 ret._buffer = buffer; 1439 ret.decode!readId(); 1440 return ret; 1441 } 1442 1443 public override string toString() { 1444 return "RiderJump(rider: " ~ std.conv.to!string(this.rider) ~ ")"; 1445 } 1446 1447 } 1448 1449 class RemoveBlock : Buffer { 1450 1451 public enum ubyte ID = 22; 1452 1453 public enum bool CLIENTBOUND = false; 1454 public enum bool SERVERBOUND = true; 1455 1456 public enum string[] FIELDS = ["position"]; 1457 1458 public sul.protocol.pocket102.types.BlockPosition position; 1459 1460 public pure nothrow @safe @nogc this() {} 1461 1462 public pure nothrow @safe @nogc this(sul.protocol.pocket102.types.BlockPosition position) { 1463 this.position = position; 1464 } 1465 1466 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 1467 _buffer.length = 0; 1468 static if(writeId){ writeBigEndianUbyte(ID); } 1469 position.encode(bufferInstance); 1470 return _buffer; 1471 } 1472 1473 public pure nothrow @safe void decode(bool readId=true)() { 1474 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 1475 position.decode(bufferInstance); 1476 } 1477 1478 public static pure nothrow @safe RemoveBlock fromBuffer(bool readId=true)(ubyte[] buffer) { 1479 RemoveBlock ret = new RemoveBlock(); 1480 ret._buffer = buffer; 1481 ret.decode!readId(); 1482 return ret; 1483 } 1484 1485 public override string toString() { 1486 return "RemoveBlock(position: " ~ std.conv.to!string(this.position) ~ ")"; 1487 } 1488 1489 } 1490 1491 class UpdateBlock : Buffer { 1492 1493 public enum ubyte ID = 23; 1494 1495 public enum bool CLIENTBOUND = true; 1496 public enum bool SERVERBOUND = false; 1497 1498 // flags and meta 1499 public enum uint NEIGHBORS = 1; 1500 public enum uint NETWORK = 2; 1501 public enum uint NO_GRAPHIC = 4; 1502 public enum uint PRIORITY = 8; 1503 1504 public enum string[] FIELDS = ["position", "block", "flagsAndMeta"]; 1505 1506 public sul.protocol.pocket102.types.BlockPosition position; 1507 public uint block; 1508 public uint flagsAndMeta; 1509 1510 public pure nothrow @safe @nogc this() {} 1511 1512 public pure nothrow @safe @nogc this(sul.protocol.pocket102.types.BlockPosition position, uint block=uint.init, uint flagsAndMeta=uint.init) { 1513 this.position = position; 1514 this.block = block; 1515 this.flagsAndMeta = flagsAndMeta; 1516 } 1517 1518 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 1519 _buffer.length = 0; 1520 static if(writeId){ writeBigEndianUbyte(ID); } 1521 position.encode(bufferInstance); 1522 writeBytes(varuint.encode(block)); 1523 writeBytes(varuint.encode(flagsAndMeta)); 1524 return _buffer; 1525 } 1526 1527 public pure nothrow @safe void decode(bool readId=true)() { 1528 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 1529 position.decode(bufferInstance); 1530 block=varuint.decode(_buffer, &_index); 1531 flagsAndMeta=varuint.decode(_buffer, &_index); 1532 } 1533 1534 public static pure nothrow @safe UpdateBlock fromBuffer(bool readId=true)(ubyte[] buffer) { 1535 UpdateBlock ret = new UpdateBlock(); 1536 ret._buffer = buffer; 1537 ret.decode!readId(); 1538 return ret; 1539 } 1540 1541 public override string toString() { 1542 return "UpdateBlock(position: " ~ std.conv.to!string(this.position) ~ ", block: " ~ std.conv.to!string(this.block) ~ ", flagsAndMeta: " ~ std.conv.to!string(this.flagsAndMeta) ~ ")"; 1543 } 1544 1545 } 1546 1547 class AddPainting : Buffer { 1548 1549 public enum ubyte ID = 24; 1550 1551 public enum bool CLIENTBOUND = true; 1552 public enum bool SERVERBOUND = false; 1553 1554 public enum string[] FIELDS = ["entityId", "runtimeId", "position", "direction", "title"]; 1555 1556 public long entityId; 1557 public long runtimeId; 1558 public sul.protocol.pocket102.types.BlockPosition position; 1559 public int direction; 1560 public string title; 1561 1562 public pure nothrow @safe @nogc this() {} 1563 1564 public pure nothrow @safe @nogc this(long entityId, long runtimeId=long.init, sul.protocol.pocket102.types.BlockPosition position=sul.protocol.pocket102.types.BlockPosition.init, int direction=int.init, string title=string.init) { 1565 this.entityId = entityId; 1566 this.runtimeId = runtimeId; 1567 this.position = position; 1568 this.direction = direction; 1569 this.title = title; 1570 } 1571 1572 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 1573 _buffer.length = 0; 1574 static if(writeId){ writeBigEndianUbyte(ID); } 1575 writeBytes(varlong.encode(entityId)); 1576 writeBytes(varlong.encode(runtimeId)); 1577 position.encode(bufferInstance); 1578 writeBytes(varint.encode(direction)); 1579 writeBytes(varuint.encode(cast(uint)title.length)); writeString(title); 1580 return _buffer; 1581 } 1582 1583 public pure nothrow @safe void decode(bool readId=true)() { 1584 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 1585 entityId=varlong.decode(_buffer, &_index); 1586 runtimeId=varlong.decode(_buffer, &_index); 1587 position.decode(bufferInstance); 1588 direction=varint.decode(_buffer, &_index); 1589 uint dlbu=varuint.decode(_buffer, &_index); title=readString(dlbu); 1590 } 1591 1592 public static pure nothrow @safe AddPainting fromBuffer(bool readId=true)(ubyte[] buffer) { 1593 AddPainting ret = new AddPainting(); 1594 ret._buffer = buffer; 1595 ret.decode!readId(); 1596 return ret; 1597 } 1598 1599 public override string toString() { 1600 return "AddPainting(entityId: " ~ std.conv.to!string(this.entityId) ~ ", runtimeId: " ~ std.conv.to!string(this.runtimeId) ~ ", position: " ~ std.conv.to!string(this.position) ~ ", direction: " ~ std.conv.to!string(this.direction) ~ ", title: " ~ std.conv.to!string(this.title) ~ ")"; 1601 } 1602 1603 } 1604 1605 class Explode : Buffer { 1606 1607 public enum ubyte ID = 25; 1608 1609 public enum bool CLIENTBOUND = true; 1610 public enum bool SERVERBOUND = false; 1611 1612 public enum string[] FIELDS = ["position", "radius", "destroyedBlocks"]; 1613 1614 public Tuple!(float, "x", float, "y", float, "z") position; 1615 public float radius; 1616 public sul.protocol.pocket102.types.BlockPosition[] destroyedBlocks; 1617 1618 public pure nothrow @safe @nogc this() {} 1619 1620 public pure nothrow @safe @nogc this(Tuple!(float, "x", float, "y", float, "z") position, float radius=float.init, sul.protocol.pocket102.types.BlockPosition[] destroyedBlocks=(sul.protocol.pocket102.types.BlockPosition[]).init) { 1621 this.position = position; 1622 this.radius = radius; 1623 this.destroyedBlocks = destroyedBlocks; 1624 } 1625 1626 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 1627 _buffer.length = 0; 1628 static if(writeId){ writeBigEndianUbyte(ID); } 1629 writeLittleEndianFloat(position.x); writeLittleEndianFloat(position.y); writeLittleEndianFloat(position.z); 1630 writeLittleEndianFloat(radius); 1631 writeBytes(varuint.encode(cast(uint)destroyedBlocks.length)); foreach(zvdjevqx;destroyedBlocks){ zvdjevqx.encode(bufferInstance); } 1632 return _buffer; 1633 } 1634 1635 public pure nothrow @safe void decode(bool readId=true)() { 1636 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 1637 position.x=readLittleEndianFloat(); position.y=readLittleEndianFloat(); position.z=readLittleEndianFloat(); 1638 radius=readLittleEndianFloat(); 1639 destroyedBlocks.length=varuint.decode(_buffer, &_index); foreach(ref zvdjevqx;destroyedBlocks){ zvdjevqx.decode(bufferInstance); } 1640 } 1641 1642 public static pure nothrow @safe Explode fromBuffer(bool readId=true)(ubyte[] buffer) { 1643 Explode ret = new Explode(); 1644 ret._buffer = buffer; 1645 ret.decode!readId(); 1646 return ret; 1647 } 1648 1649 public override string toString() { 1650 return "Explode(position: " ~ std.conv.to!string(this.position) ~ ", radius: " ~ std.conv.to!string(this.radius) ~ ", destroyedBlocks: " ~ std.conv.to!string(this.destroyedBlocks) ~ ")"; 1651 } 1652 1653 } 1654 1655 class LevelSoundEvent : Buffer { 1656 1657 public enum ubyte ID = 26; 1658 1659 public enum bool CLIENTBOUND = true; 1660 public enum bool SERVERBOUND = true; 1661 1662 // sound 1663 public enum ubyte ITEM_USE_ON = 0; 1664 public enum ubyte HIT = 1; 1665 public enum ubyte STEP = 2; 1666 public enum ubyte JUMP = 3; 1667 public enum ubyte BREAK = 4; 1668 public enum ubyte PLACE = 5; 1669 public enum ubyte HEAVY_STEP = 6; 1670 public enum ubyte GALLOP = 7; 1671 public enum ubyte FALL = 8; 1672 public enum ubyte AMBIENT = 9; 1673 public enum ubyte AMBIENT_BABY = 10; 1674 public enum ubyte AMBIENT_IN_WATER = 11; 1675 public enum ubyte BREATHE = 12; 1676 public enum ubyte DEATH = 13; 1677 public enum ubyte DEATH_IN_WATER = 14; 1678 public enum ubyte DEATH_TO_ZOMBIE = 15; 1679 public enum ubyte HURT = 16; 1680 public enum ubyte HURT_IN_WATER = 17; 1681 public enum ubyte MAD = 18; 1682 public enum ubyte BOOST = 19; 1683 public enum ubyte BOW = 20; 1684 public enum ubyte SQUISH_BIG = 21; 1685 public enum ubyte SQUISH_SMALL = 22; 1686 public enum ubyte FALL_BIG = 23; 1687 public enum ubyte FALL_SMALL = 24; 1688 public enum ubyte SPLASH = 25; 1689 public enum ubyte FIZZ = 26; 1690 public enum ubyte FLAP = 27; 1691 public enum ubyte SWIM = 28; 1692 public enum ubyte DRINK = 29; 1693 public enum ubyte EAT = 30; 1694 public enum ubyte TAKEOFF = 31; 1695 public enum ubyte SHAKE = 32; 1696 public enum ubyte PLOP = 33; 1697 public enum ubyte LAND = 34; 1698 public enum ubyte SADDLE = 35; 1699 public enum ubyte ARMOR = 36; 1700 public enum ubyte ADD_CHEST = 37; 1701 public enum ubyte THROW = 38; 1702 public enum ubyte ATTACK = 39; 1703 public enum ubyte ATTACK_NODAMAGE = 40; 1704 public enum ubyte WARN = 41; 1705 public enum ubyte SHEAR = 42; 1706 public enum ubyte MILK = 43; 1707 public enum ubyte THUNDER = 44; 1708 public enum ubyte EXPLODE = 45; 1709 public enum ubyte FIRE = 46; 1710 public enum ubyte IGNITE = 47; 1711 public enum ubyte FUSE = 48; 1712 public enum ubyte STARE = 49; 1713 public enum ubyte SPAWN = 50; 1714 public enum ubyte SHOOT = 51; 1715 public enum ubyte BREAK_BLOCK = 52; 1716 public enum ubyte REMEDY = 53; 1717 public enum ubyte UNFECT = 54; 1718 public enum ubyte LEVELUP = 55; 1719 public enum ubyte BOW_HIT = 56; 1720 public enum ubyte BULLET_HIT = 57; 1721 public enum ubyte EXTINGUISH_FIRE = 58; 1722 public enum ubyte ITEM_FIZZ = 59; 1723 public enum ubyte CHEST_OPEN = 60; 1724 public enum ubyte CHEST_CLOSED = 61; 1725 public enum ubyte POWER_ON = 62; 1726 public enum ubyte POWER_OFF = 63; 1727 public enum ubyte ATTACH = 64; 1728 public enum ubyte DETACH = 65; 1729 public enum ubyte DENY = 66; 1730 public enum ubyte TRIPOD = 67; 1731 public enum ubyte POP = 68; 1732 public enum ubyte DROP_SLOT = 69; 1733 public enum ubyte NOTE = 70; 1734 public enum ubyte THORNS = 71; 1735 public enum ubyte PISTON_IN = 72; 1736 public enum ubyte PISTON_OUT = 73; 1737 public enum ubyte PORTAL = 74; 1738 public enum ubyte WATER = 75; 1739 public enum ubyte LAVA_POP = 76; 1740 public enum ubyte LAVA = 77; 1741 public enum ubyte BURP = 78; 1742 public enum ubyte BUCKET_FILL_WATER = 79; 1743 public enum ubyte BUCKET_FILL_LAVA = 80; 1744 public enum ubyte BUCKET_EMPTY_WATER = 81; 1745 public enum ubyte BUCKET_EMPTY_LAVA = 82; 1746 public enum ubyte GUARDIAN_FLOP = 83; 1747 public enum ubyte ELDERGUARDIAN_CURSE = 84; 1748 public enum ubyte MOB_WARNING = 85; 1749 public enum ubyte MOB_WARNING_BABY = 86; 1750 public enum ubyte TELEPORT = 87; 1751 public enum ubyte SHULKER_OPEN = 88; 1752 public enum ubyte SHULKER_CLOSE = 89; 1753 public enum ubyte HAGGLE = 90; 1754 public enum ubyte HAGGLE_YES = 91; 1755 public enum ubyte HAGGLE_NO = 92; 1756 public enum ubyte HAGGLE_IDLE = 93; 1757 public enum ubyte DEFAULT = 94; 1758 public enum ubyte UNDEFINED = 95; 1759 1760 public enum string[] FIELDS = ["sound", "position", "volume", "pitch", "unknown4"]; 1761 1762 public ubyte sound; 1763 public Tuple!(float, "x", float, "y", float, "z") position; 1764 public uint volume; 1765 public int pitch; 1766 public bool unknown4; 1767 1768 public pure nothrow @safe @nogc this() {} 1769 1770 public pure nothrow @safe @nogc this(ubyte sound, Tuple!(float, "x", float, "y", float, "z") position=Tuple!(float, "x", float, "y", float, "z").init, uint volume=uint.init, int pitch=int.init, bool unknown4=bool.init) { 1771 this.sound = sound; 1772 this.position = position; 1773 this.volume = volume; 1774 this.pitch = pitch; 1775 this.unknown4 = unknown4; 1776 } 1777 1778 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 1779 _buffer.length = 0; 1780 static if(writeId){ writeBigEndianUbyte(ID); } 1781 writeBigEndianUbyte(sound); 1782 writeLittleEndianFloat(position.x); writeLittleEndianFloat(position.y); writeLittleEndianFloat(position.z); 1783 writeBytes(varuint.encode(volume)); 1784 writeBytes(varint.encode(pitch)); 1785 writeBigEndianBool(unknown4); 1786 return _buffer; 1787 } 1788 1789 public pure nothrow @safe void decode(bool readId=true)() { 1790 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 1791 sound=readBigEndianUbyte(); 1792 position.x=readLittleEndianFloat(); position.y=readLittleEndianFloat(); position.z=readLittleEndianFloat(); 1793 volume=varuint.decode(_buffer, &_index); 1794 pitch=varint.decode(_buffer, &_index); 1795 unknown4=readBigEndianBool(); 1796 } 1797 1798 public static pure nothrow @safe LevelSoundEvent fromBuffer(bool readId=true)(ubyte[] buffer) { 1799 LevelSoundEvent ret = new LevelSoundEvent(); 1800 ret._buffer = buffer; 1801 ret.decode!readId(); 1802 return ret; 1803 } 1804 1805 public override string toString() { 1806 return "LevelSoundEvent(sound: " ~ std.conv.to!string(this.sound) ~ ", position: " ~ std.conv.to!string(this.position) ~ ", volume: " ~ std.conv.to!string(this.volume) ~ ", pitch: " ~ std.conv.to!string(this.pitch) ~ ", unknown4: " ~ std.conv.to!string(this.unknown4) ~ ")"; 1807 } 1808 1809 } 1810 1811 class LevelEvent : Buffer { 1812 1813 public enum ubyte ID = 27; 1814 1815 public enum bool CLIENTBOUND = true; 1816 public enum bool SERVERBOUND = false; 1817 1818 // event id 1819 public enum int START_RAIN = 3001; 1820 public enum int START_THUNDER = 3002; 1821 public enum int STOP_RAIN = 3003; 1822 public enum int STOP_THUNDER = 3004; 1823 public enum int SET_DATA = 4000; 1824 public enum int PLAYERS_SLEEPING = 9800; 1825 public enum int BUBBLE = 16385; 1826 public enum int CRITICAL = 16386; 1827 public enum int BLOCK_FORCE_FIELD = 16387; 1828 public enum int SMOKE = 16388; 1829 public enum int EXPLODE = 16389; 1830 public enum int EVAPORATION = 16390; 1831 public enum int FLAME = 16391; 1832 public enum int LAVA = 16392; 1833 public enum int LARGE_SMOKE = 16393; 1834 public enum int REDSTONE = 16394; 1835 public enum int RISING_RED_DUST = 16395; 1836 public enum int ITEM_BREAK = 16396; 1837 public enum int SNOWBALL_POOF = 16397; 1838 public enum int HUGE_EXPLODE = 16398; 1839 public enum int HUGE_EXPLODE_SEED = 16399; 1840 public enum int MOB_FLAME = 16400; 1841 public enum int HEART = 16401; 1842 public enum int TERRAIN = 16402; 1843 public enum int TOWN_AURA = 16403; 1844 public enum int PORTAL = 16404; 1845 public enum int WATER_SPLASH = 16405; 1846 public enum int WATER_WAKE = 16406; 1847 public enum int DRIP_WATER = 16407; 1848 public enum int DRIP_LAVA = 16408; 1849 public enum int FALLING_DUST = 16409; 1850 public enum int MOB_SPELL = 16410; 1851 public enum int MOB_SPELL_AMBIENT = 16411; 1852 public enum int MOB_SPELL_INSTANTANEOUS = 16412; 1853 public enum int INK = 16413; 1854 public enum int SLIME = 16414; 1855 public enum int RAIN_SPLASH = 16415; 1856 public enum int VILLAGER_ANGRY = 16416; 1857 public enum int VILLAGER_HAPPY = 16417; 1858 public enum int ENCHANTMENT_TABLE = 16418; 1859 public enum int TRACKING_EMITTER = 16419; 1860 public enum int NOTE = 16420; 1861 public enum int WITCH_SPELL = 16421; 1862 public enum int CARROT = 16422; 1863 public enum int END_ROD = 16424; 1864 public enum int DRAGON_BREATH = 16425; 1865 public enum int SHOOT = 2000; 1866 public enum int DESTROY = 2001; 1867 1868 public enum string[] FIELDS = ["eventId", "position", "data"]; 1869 1870 public int eventId; 1871 public Tuple!(float, "x", float, "y", float, "z") position; 1872 public int data; 1873 1874 public pure nothrow @safe @nogc this() {} 1875 1876 public pure nothrow @safe @nogc this(int eventId, Tuple!(float, "x", float, "y", float, "z") position=Tuple!(float, "x", float, "y", float, "z").init, int data=int.init) { 1877 this.eventId = eventId; 1878 this.position = position; 1879 this.data = data; 1880 } 1881 1882 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 1883 _buffer.length = 0; 1884 static if(writeId){ writeBigEndianUbyte(ID); } 1885 writeBytes(varint.encode(eventId)); 1886 writeLittleEndianFloat(position.x); writeLittleEndianFloat(position.y); writeLittleEndianFloat(position.z); 1887 writeBytes(varint.encode(data)); 1888 return _buffer; 1889 } 1890 1891 public pure nothrow @safe void decode(bool readId=true)() { 1892 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 1893 eventId=varint.decode(_buffer, &_index); 1894 position.x=readLittleEndianFloat(); position.y=readLittleEndianFloat(); position.z=readLittleEndianFloat(); 1895 data=varint.decode(_buffer, &_index); 1896 } 1897 1898 public static pure nothrow @safe LevelEvent fromBuffer(bool readId=true)(ubyte[] buffer) { 1899 LevelEvent ret = new LevelEvent(); 1900 ret._buffer = buffer; 1901 ret.decode!readId(); 1902 return ret; 1903 } 1904 1905 public override string toString() { 1906 return "LevelEvent(eventId: " ~ std.conv.to!string(this.eventId) ~ ", position: " ~ std.conv.to!string(this.position) ~ ", data: " ~ std.conv.to!string(this.data) ~ ")"; 1907 } 1908 1909 } 1910 1911 class BlockEvent : Buffer { 1912 1913 public enum ubyte ID = 28; 1914 1915 public enum bool CLIENTBOUND = true; 1916 public enum bool SERVERBOUND = false; 1917 1918 public enum string[] FIELDS = ["position", "data"]; 1919 1920 public sul.protocol.pocket102.types.BlockPosition position; 1921 public int[2] data; 1922 1923 public pure nothrow @safe @nogc this() {} 1924 1925 public pure nothrow @safe @nogc this(sul.protocol.pocket102.types.BlockPosition position, int[2] data=(int[2]).init) { 1926 this.position = position; 1927 this.data = data; 1928 } 1929 1930 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 1931 _buffer.length = 0; 1932 static if(writeId){ writeBigEndianUbyte(ID); } 1933 position.encode(bufferInstance); 1934 foreach(zfy;data){ writeBytes(varint.encode(zfy)); } 1935 return _buffer; 1936 } 1937 1938 public pure nothrow @safe void decode(bool readId=true)() { 1939 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 1940 position.decode(bufferInstance); 1941 foreach(ref zfy;data){ zfy=varint.decode(_buffer, &_index); } 1942 } 1943 1944 public static pure nothrow @safe BlockEvent fromBuffer(bool readId=true)(ubyte[] buffer) { 1945 BlockEvent ret = new BlockEvent(); 1946 ret._buffer = buffer; 1947 ret.decode!readId(); 1948 return ret; 1949 } 1950 1951 public override string toString() { 1952 return "BlockEvent(position: " ~ std.conv.to!string(this.position) ~ ", data: " ~ std.conv.to!string(this.data) ~ ")"; 1953 } 1954 1955 } 1956 1957 class EntityEvent : Buffer { 1958 1959 public enum ubyte ID = 29; 1960 1961 public enum bool CLIENTBOUND = true; 1962 public enum bool SERVERBOUND = true; 1963 1964 // event id 1965 public enum ubyte HURT_ANIMATION = 2; 1966 public enum ubyte DEATH_ANIMATION = 3; 1967 public enum ubyte TAME_FAIL = 6; 1968 public enum ubyte TAME_SUCCESS = 7; 1969 public enum ubyte SHAKE_WET = 8; 1970 public enum ubyte USE_ITEM = 9; 1971 public enum ubyte EAT_GRASS_ANIMATION = 10; 1972 public enum ubyte FISH_HOOK_BUBBLES = 11; 1973 public enum ubyte FISH_HOOK_POSITION = 12; 1974 public enum ubyte FISH_HOOK_HOOK = 13; 1975 public enum ubyte FISH_HOOK_TEASE = 14; 1976 public enum ubyte SQUID_INK_CLOUD = 15; 1977 public enum ubyte AMBIENT_SOUND = 16; 1978 public enum ubyte RESPAWN = 17; 1979 1980 public enum string[] FIELDS = ["entityId", "eventId", "unknown2"]; 1981 1982 public long entityId; 1983 public ubyte eventId; 1984 public int unknown2; 1985 1986 public pure nothrow @safe @nogc this() {} 1987 1988 public pure nothrow @safe @nogc this(long entityId, ubyte eventId=ubyte.init, int unknown2=int.init) { 1989 this.entityId = entityId; 1990 this.eventId = eventId; 1991 this.unknown2 = unknown2; 1992 } 1993 1994 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 1995 _buffer.length = 0; 1996 static if(writeId){ writeBigEndianUbyte(ID); } 1997 writeBytes(varlong.encode(entityId)); 1998 writeBigEndianUbyte(eventId); 1999 writeBytes(varint.encode(unknown2)); 2000 return _buffer; 2001 } 2002 2003 public pure nothrow @safe void decode(bool readId=true)() { 2004 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 2005 entityId=varlong.decode(_buffer, &_index); 2006 eventId=readBigEndianUbyte(); 2007 unknown2=varint.decode(_buffer, &_index); 2008 } 2009 2010 public static pure nothrow @safe EntityEvent fromBuffer(bool readId=true)(ubyte[] buffer) { 2011 EntityEvent ret = new EntityEvent(); 2012 ret._buffer = buffer; 2013 ret.decode!readId(); 2014 return ret; 2015 } 2016 2017 public override string toString() { 2018 return "EntityEvent(entityId: " ~ std.conv.to!string(this.entityId) ~ ", eventId: " ~ std.conv.to!string(this.eventId) ~ ", unknown2: " ~ std.conv.to!string(this.unknown2) ~ ")"; 2019 } 2020 2021 } 2022 2023 class MobEffect : Buffer { 2024 2025 public enum ubyte ID = 30; 2026 2027 public enum bool CLIENTBOUND = true; 2028 public enum bool SERVERBOUND = false; 2029 2030 // event id 2031 public enum ubyte ADD = 1; 2032 public enum ubyte MODIFY = 2; 2033 public enum ubyte REMOVE = 3; 2034 2035 public enum string[] FIELDS = ["entityId", "eventId", "effect", "amplifier", "particles", "duration"]; 2036 2037 public long entityId; 2038 public ubyte eventId; 2039 public int effect; 2040 public int amplifier; 2041 public bool particles; 2042 public int duration; 2043 2044 public pure nothrow @safe @nogc this() {} 2045 2046 public pure nothrow @safe @nogc this(long entityId, ubyte eventId=ubyte.init, int effect=int.init, int amplifier=int.init, bool particles=bool.init, int duration=int.init) { 2047 this.entityId = entityId; 2048 this.eventId = eventId; 2049 this.effect = effect; 2050 this.amplifier = amplifier; 2051 this.particles = particles; 2052 this.duration = duration; 2053 } 2054 2055 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 2056 _buffer.length = 0; 2057 static if(writeId){ writeBigEndianUbyte(ID); } 2058 writeBytes(varlong.encode(entityId)); 2059 writeBigEndianUbyte(eventId); 2060 writeBytes(varint.encode(effect)); 2061 writeBytes(varint.encode(amplifier)); 2062 writeBigEndianBool(particles); 2063 writeBytes(varint.encode(duration)); 2064 return _buffer; 2065 } 2066 2067 public pure nothrow @safe void decode(bool readId=true)() { 2068 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 2069 entityId=varlong.decode(_buffer, &_index); 2070 eventId=readBigEndianUbyte(); 2071 effect=varint.decode(_buffer, &_index); 2072 amplifier=varint.decode(_buffer, &_index); 2073 particles=readBigEndianBool(); 2074 duration=varint.decode(_buffer, &_index); 2075 } 2076 2077 public static pure nothrow @safe MobEffect fromBuffer(bool readId=true)(ubyte[] buffer) { 2078 MobEffect ret = new MobEffect(); 2079 ret._buffer = buffer; 2080 ret.decode!readId(); 2081 return ret; 2082 } 2083 2084 public override string toString() { 2085 return "MobEffect(entityId: " ~ std.conv.to!string(this.entityId) ~ ", eventId: " ~ std.conv.to!string(this.eventId) ~ ", effect: " ~ std.conv.to!string(this.effect) ~ ", amplifier: " ~ std.conv.to!string(this.amplifier) ~ ", particles: " ~ std.conv.to!string(this.particles) ~ ", duration: " ~ std.conv.to!string(this.duration) ~ ")"; 2086 } 2087 2088 } 2089 2090 class UpdateAttributes : Buffer { 2091 2092 public enum ubyte ID = 31; 2093 2094 public enum bool CLIENTBOUND = true; 2095 public enum bool SERVERBOUND = false; 2096 2097 public enum string[] FIELDS = ["entityId", "attributes"]; 2098 2099 public long entityId; 2100 public sul.protocol.pocket102.types.Attribute[] attributes; 2101 2102 public pure nothrow @safe @nogc this() {} 2103 2104 public pure nothrow @safe @nogc this(long entityId, sul.protocol.pocket102.types.Attribute[] attributes=(sul.protocol.pocket102.types.Attribute[]).init) { 2105 this.entityId = entityId; 2106 this.attributes = attributes; 2107 } 2108 2109 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 2110 _buffer.length = 0; 2111 static if(writeId){ writeBigEndianUbyte(ID); } 2112 writeBytes(varlong.encode(entityId)); 2113 writeBytes(varuint.encode(cast(uint)attributes.length)); foreach(yrcldrc;attributes){ yrcldrc.encode(bufferInstance); } 2114 return _buffer; 2115 } 2116 2117 public pure nothrow @safe void decode(bool readId=true)() { 2118 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 2119 entityId=varlong.decode(_buffer, &_index); 2120 attributes.length=varuint.decode(_buffer, &_index); foreach(ref yrcldrc;attributes){ yrcldrc.decode(bufferInstance); } 2121 } 2122 2123 public static pure nothrow @safe UpdateAttributes fromBuffer(bool readId=true)(ubyte[] buffer) { 2124 UpdateAttributes ret = new UpdateAttributes(); 2125 ret._buffer = buffer; 2126 ret.decode!readId(); 2127 return ret; 2128 } 2129 2130 public override string toString() { 2131 return "UpdateAttributes(entityId: " ~ std.conv.to!string(this.entityId) ~ ", attributes: " ~ std.conv.to!string(this.attributes) ~ ")"; 2132 } 2133 2134 } 2135 2136 class MobEquipment : Buffer { 2137 2138 public enum ubyte ID = 32; 2139 2140 public enum bool CLIENTBOUND = true; 2141 public enum bool SERVERBOUND = true; 2142 2143 public enum string[] FIELDS = ["entityId", "item", "inventorySlot", "hotbarSlot", "unknown4"]; 2144 2145 public long entityId; 2146 public sul.protocol.pocket102.types.Slot item; 2147 public ubyte inventorySlot; 2148 public ubyte hotbarSlot; 2149 public ubyte unknown4; 2150 2151 public pure nothrow @safe @nogc this() {} 2152 2153 public pure nothrow @safe @nogc this(long entityId, sul.protocol.pocket102.types.Slot item=sul.protocol.pocket102.types.Slot.init, ubyte inventorySlot=ubyte.init, ubyte hotbarSlot=ubyte.init, ubyte unknown4=ubyte.init) { 2154 this.entityId = entityId; 2155 this.item = item; 2156 this.inventorySlot = inventorySlot; 2157 this.hotbarSlot = hotbarSlot; 2158 this.unknown4 = unknown4; 2159 } 2160 2161 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 2162 _buffer.length = 0; 2163 static if(writeId){ writeBigEndianUbyte(ID); } 2164 writeBytes(varlong.encode(entityId)); 2165 item.encode(bufferInstance); 2166 writeBigEndianUbyte(inventorySlot); 2167 writeBigEndianUbyte(hotbarSlot); 2168 writeBigEndianUbyte(unknown4); 2169 return _buffer; 2170 } 2171 2172 public pure nothrow @safe void decode(bool readId=true)() { 2173 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 2174 entityId=varlong.decode(_buffer, &_index); 2175 item.decode(bufferInstance); 2176 inventorySlot=readBigEndianUbyte(); 2177 hotbarSlot=readBigEndianUbyte(); 2178 unknown4=readBigEndianUbyte(); 2179 } 2180 2181 public static pure nothrow @safe MobEquipment fromBuffer(bool readId=true)(ubyte[] buffer) { 2182 MobEquipment ret = new MobEquipment(); 2183 ret._buffer = buffer; 2184 ret.decode!readId(); 2185 return ret; 2186 } 2187 2188 public override string toString() { 2189 return "MobEquipment(entityId: " ~ std.conv.to!string(this.entityId) ~ ", item: " ~ std.conv.to!string(this.item) ~ ", inventorySlot: " ~ std.conv.to!string(this.inventorySlot) ~ ", hotbarSlot: " ~ std.conv.to!string(this.hotbarSlot) ~ ", unknown4: " ~ std.conv.to!string(this.unknown4) ~ ")"; 2190 } 2191 2192 } 2193 2194 class MobArmorEquipment : Buffer { 2195 2196 public enum ubyte ID = 33; 2197 2198 public enum bool CLIENTBOUND = true; 2199 public enum bool SERVERBOUND = true; 2200 2201 public enum string[] FIELDS = ["entityId", "armor"]; 2202 2203 public long entityId; 2204 public sul.protocol.pocket102.types.Slot[4] armor; 2205 2206 public pure nothrow @safe @nogc this() {} 2207 2208 public pure nothrow @safe @nogc this(long entityId, sul.protocol.pocket102.types.Slot[4] armor=(sul.protocol.pocket102.types.Slot[4]).init) { 2209 this.entityId = entityId; 2210 this.armor = armor; 2211 } 2212 2213 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 2214 _buffer.length = 0; 2215 static if(writeId){ writeBigEndianUbyte(ID); } 2216 writeBytes(varlong.encode(entityId)); 2217 foreach(yjbi;armor){ yjbi.encode(bufferInstance); } 2218 return _buffer; 2219 } 2220 2221 public pure nothrow @safe void decode(bool readId=true)() { 2222 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 2223 entityId=varlong.decode(_buffer, &_index); 2224 foreach(ref yjbi;armor){ yjbi.decode(bufferInstance); } 2225 } 2226 2227 public static pure nothrow @safe MobArmorEquipment fromBuffer(bool readId=true)(ubyte[] buffer) { 2228 MobArmorEquipment ret = new MobArmorEquipment(); 2229 ret._buffer = buffer; 2230 ret.decode!readId(); 2231 return ret; 2232 } 2233 2234 public override string toString() { 2235 return "MobArmorEquipment(entityId: " ~ std.conv.to!string(this.entityId) ~ ", armor: " ~ std.conv.to!string(this.armor) ~ ")"; 2236 } 2237 2238 } 2239 2240 class Interact : Buffer { 2241 2242 public enum ubyte ID = 34; 2243 2244 public enum bool CLIENTBOUND = false; 2245 public enum bool SERVERBOUND = true; 2246 2247 // action 2248 public enum ubyte INTERACT = 1; 2249 public enum ubyte ATTACK = 2; 2250 public enum ubyte LEAVE_VEHICLE = 3; 2251 public enum ubyte HOVER = 4; 2252 2253 public enum string[] FIELDS = ["action", "target"]; 2254 2255 public ubyte action; 2256 public long target; 2257 2258 public pure nothrow @safe @nogc this() {} 2259 2260 public pure nothrow @safe @nogc this(ubyte action, long target=long.init) { 2261 this.action = action; 2262 this.target = target; 2263 } 2264 2265 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 2266 _buffer.length = 0; 2267 static if(writeId){ writeBigEndianUbyte(ID); } 2268 writeBigEndianUbyte(action); 2269 writeBytes(varlong.encode(target)); 2270 return _buffer; 2271 } 2272 2273 public pure nothrow @safe void decode(bool readId=true)() { 2274 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 2275 action=readBigEndianUbyte(); 2276 target=varlong.decode(_buffer, &_index); 2277 } 2278 2279 public static pure nothrow @safe Interact fromBuffer(bool readId=true)(ubyte[] buffer) { 2280 Interact ret = new Interact(); 2281 ret._buffer = buffer; 2282 ret.decode!readId(); 2283 return ret; 2284 } 2285 2286 public override string toString() { 2287 return "Interact(action: " ~ std.conv.to!string(this.action) ~ ", target: " ~ std.conv.to!string(this.target) ~ ")"; 2288 } 2289 2290 } 2291 2292 class UseItem : Buffer { 2293 2294 public enum ubyte ID = 35; 2295 2296 public enum bool CLIENTBOUND = false; 2297 public enum bool SERVERBOUND = true; 2298 2299 public enum string[] FIELDS = ["blockPosition", "hotbarSlot", "face", "facePosition", "position", "slot", "item"]; 2300 2301 public sul.protocol.pocket102.types.BlockPosition blockPosition; 2302 public uint hotbarSlot; 2303 public int face; 2304 public Tuple!(float, "x", float, "y", float, "z") facePosition; 2305 public Tuple!(float, "x", float, "y", float, "z") position; 2306 public int slot; 2307 public sul.protocol.pocket102.types.Slot item; 2308 2309 public pure nothrow @safe @nogc this() {} 2310 2311 public pure nothrow @safe @nogc this(sul.protocol.pocket102.types.BlockPosition blockPosition, uint hotbarSlot=uint.init, int face=int.init, Tuple!(float, "x", float, "y", float, "z") facePosition=Tuple!(float, "x", float, "y", float, "z").init, Tuple!(float, "x", float, "y", float, "z") position=Tuple!(float, "x", float, "y", float, "z").init, int slot=int.init, sul.protocol.pocket102.types.Slot item=sul.protocol.pocket102.types.Slot.init) { 2312 this.blockPosition = blockPosition; 2313 this.hotbarSlot = hotbarSlot; 2314 this.face = face; 2315 this.facePosition = facePosition; 2316 this.position = position; 2317 this.slot = slot; 2318 this.item = item; 2319 } 2320 2321 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 2322 _buffer.length = 0; 2323 static if(writeId){ writeBigEndianUbyte(ID); } 2324 blockPosition.encode(bufferInstance); 2325 writeBytes(varuint.encode(hotbarSlot)); 2326 writeBytes(varint.encode(face)); 2327 writeLittleEndianFloat(facePosition.x); writeLittleEndianFloat(facePosition.y); writeLittleEndianFloat(facePosition.z); 2328 writeLittleEndianFloat(position.x); writeLittleEndianFloat(position.y); writeLittleEndianFloat(position.z); 2329 writeBytes(varint.encode(slot)); 2330 item.encode(bufferInstance); 2331 return _buffer; 2332 } 2333 2334 public pure nothrow @safe void decode(bool readId=true)() { 2335 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 2336 blockPosition.decode(bufferInstance); 2337 hotbarSlot=varuint.decode(_buffer, &_index); 2338 face=varint.decode(_buffer, &_index); 2339 facePosition.x=readLittleEndianFloat(); facePosition.y=readLittleEndianFloat(); facePosition.z=readLittleEndianFloat(); 2340 position.x=readLittleEndianFloat(); position.y=readLittleEndianFloat(); position.z=readLittleEndianFloat(); 2341 slot=varint.decode(_buffer, &_index); 2342 item.decode(bufferInstance); 2343 } 2344 2345 public static pure nothrow @safe UseItem fromBuffer(bool readId=true)(ubyte[] buffer) { 2346 UseItem ret = new UseItem(); 2347 ret._buffer = buffer; 2348 ret.decode!readId(); 2349 return ret; 2350 } 2351 2352 public override string toString() { 2353 return "UseItem(blockPosition: " ~ std.conv.to!string(this.blockPosition) ~ ", hotbarSlot: " ~ std.conv.to!string(this.hotbarSlot) ~ ", face: " ~ std.conv.to!string(this.face) ~ ", facePosition: " ~ std.conv.to!string(this.facePosition) ~ ", position: " ~ std.conv.to!string(this.position) ~ ", slot: " ~ std.conv.to!string(this.slot) ~ ", item: " ~ std.conv.to!string(this.item) ~ ")"; 2354 } 2355 2356 } 2357 2358 class PlayerAction : Buffer { 2359 2360 public enum ubyte ID = 36; 2361 2362 public enum bool CLIENTBOUND = false; 2363 public enum bool SERVERBOUND = true; 2364 2365 // action 2366 public enum int START_BREAK = 0; 2367 public enum int ABORT_BREAK = 1; 2368 public enum int STOP_BREAK = 2; 2369 public enum int RELEASE_ITEM = 5; 2370 public enum int STOP_SLEEPING = 6; 2371 public enum int RESPAWN = 7; 2372 public enum int JUMP = 8; 2373 public enum int START_SPRINT = 9; 2374 public enum int STOP_SPRINT = 10; 2375 public enum int START_SNEAK = 11; 2376 public enum int STOP_SNEAK = 12; 2377 public enum int START_GLIDING = 15; 2378 public enum int STOP_GLIDING = 16; 2379 2380 public enum string[] FIELDS = ["entityId", "action", "position", "face"]; 2381 2382 public long entityId; 2383 public int action; 2384 public sul.protocol.pocket102.types.BlockPosition position; 2385 public int face; 2386 2387 public pure nothrow @safe @nogc this() {} 2388 2389 public pure nothrow @safe @nogc this(long entityId, int action=int.init, sul.protocol.pocket102.types.BlockPosition position=sul.protocol.pocket102.types.BlockPosition.init, int face=int.init) { 2390 this.entityId = entityId; 2391 this.action = action; 2392 this.position = position; 2393 this.face = face; 2394 } 2395 2396 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 2397 _buffer.length = 0; 2398 static if(writeId){ writeBigEndianUbyte(ID); } 2399 writeBytes(varlong.encode(entityId)); 2400 writeBytes(varint.encode(action)); 2401 position.encode(bufferInstance); 2402 writeBytes(varint.encode(face)); 2403 return _buffer; 2404 } 2405 2406 public pure nothrow @safe void decode(bool readId=true)() { 2407 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 2408 entityId=varlong.decode(_buffer, &_index); 2409 action=varint.decode(_buffer, &_index); 2410 position.decode(bufferInstance); 2411 face=varint.decode(_buffer, &_index); 2412 } 2413 2414 public static pure nothrow @safe PlayerAction fromBuffer(bool readId=true)(ubyte[] buffer) { 2415 PlayerAction ret = new PlayerAction(); 2416 ret._buffer = buffer; 2417 ret.decode!readId(); 2418 return ret; 2419 } 2420 2421 public override string toString() { 2422 return "PlayerAction(entityId: " ~ std.conv.to!string(this.entityId) ~ ", action: " ~ std.conv.to!string(this.action) ~ ", position: " ~ std.conv.to!string(this.position) ~ ", face: " ~ std.conv.to!string(this.face) ~ ")"; 2423 } 2424 2425 } 2426 2427 class PlayerFall : Buffer { 2428 2429 public enum ubyte ID = 37; 2430 2431 public enum bool CLIENTBOUND = false; 2432 public enum bool SERVERBOUND = true; 2433 2434 public enum string[] FIELDS = ["distance"]; 2435 2436 public float distance; 2437 2438 public pure nothrow @safe @nogc this() {} 2439 2440 public pure nothrow @safe @nogc this(float distance) { 2441 this.distance = distance; 2442 } 2443 2444 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 2445 _buffer.length = 0; 2446 static if(writeId){ writeBigEndianUbyte(ID); } 2447 writeLittleEndianFloat(distance); 2448 return _buffer; 2449 } 2450 2451 public pure nothrow @safe void decode(bool readId=true)() { 2452 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 2453 distance=readLittleEndianFloat(); 2454 } 2455 2456 public static pure nothrow @safe PlayerFall fromBuffer(bool readId=true)(ubyte[] buffer) { 2457 PlayerFall ret = new PlayerFall(); 2458 ret._buffer = buffer; 2459 ret.decode!readId(); 2460 return ret; 2461 } 2462 2463 public override string toString() { 2464 return "PlayerFall(distance: " ~ std.conv.to!string(this.distance) ~ ")"; 2465 } 2466 2467 } 2468 2469 class HurtArmor : Buffer { 2470 2471 public enum ubyte ID = 38; 2472 2473 public enum bool CLIENTBOUND = true; 2474 public enum bool SERVERBOUND = false; 2475 2476 public enum string[] FIELDS = ["unknown0"]; 2477 2478 public int unknown0; 2479 2480 public pure nothrow @safe @nogc this() {} 2481 2482 public pure nothrow @safe @nogc this(int unknown0) { 2483 this.unknown0 = unknown0; 2484 } 2485 2486 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 2487 _buffer.length = 0; 2488 static if(writeId){ writeBigEndianUbyte(ID); } 2489 writeBytes(varint.encode(unknown0)); 2490 return _buffer; 2491 } 2492 2493 public pure nothrow @safe void decode(bool readId=true)() { 2494 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 2495 unknown0=varint.decode(_buffer, &_index); 2496 } 2497 2498 public static pure nothrow @safe HurtArmor fromBuffer(bool readId=true)(ubyte[] buffer) { 2499 HurtArmor ret = new HurtArmor(); 2500 ret._buffer = buffer; 2501 ret.decode!readId(); 2502 return ret; 2503 } 2504 2505 public override string toString() { 2506 return "HurtArmor(unknown0: " ~ std.conv.to!string(this.unknown0) ~ ")"; 2507 } 2508 2509 } 2510 2511 class SetEntityData : Buffer { 2512 2513 public enum ubyte ID = 39; 2514 2515 public enum bool CLIENTBOUND = true; 2516 public enum bool SERVERBOUND = false; 2517 2518 public enum string[] FIELDS = ["entityId", "metadata"]; 2519 2520 public long entityId; 2521 public Metadata metadata; 2522 2523 public pure nothrow @safe @nogc this() {} 2524 2525 public pure nothrow @safe @nogc this(long entityId, Metadata metadata=Metadata.init) { 2526 this.entityId = entityId; 2527 this.metadata = metadata; 2528 } 2529 2530 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 2531 _buffer.length = 0; 2532 static if(writeId){ writeBigEndianUbyte(ID); } 2533 writeBytes(varlong.encode(entityId)); 2534 metadata.encode(bufferInstance); 2535 return _buffer; 2536 } 2537 2538 public pure nothrow @safe void decode(bool readId=true)() { 2539 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 2540 entityId=varlong.decode(_buffer, &_index); 2541 metadata=Metadata.decode(bufferInstance); 2542 } 2543 2544 public static pure nothrow @safe SetEntityData fromBuffer(bool readId=true)(ubyte[] buffer) { 2545 SetEntityData ret = new SetEntityData(); 2546 ret._buffer = buffer; 2547 ret.decode!readId(); 2548 return ret; 2549 } 2550 2551 public override string toString() { 2552 return "SetEntityData(entityId: " ~ std.conv.to!string(this.entityId) ~ ", metadata: " ~ std.conv.to!string(this.metadata) ~ ")"; 2553 } 2554 2555 } 2556 2557 class SetEntityMotion : Buffer { 2558 2559 public enum ubyte ID = 40; 2560 2561 public enum bool CLIENTBOUND = true; 2562 public enum bool SERVERBOUND = false; 2563 2564 public enum string[] FIELDS = ["entityId", "motion"]; 2565 2566 public long entityId; 2567 public Tuple!(float, "x", float, "y", float, "z") motion; 2568 2569 public pure nothrow @safe @nogc this() {} 2570 2571 public pure nothrow @safe @nogc this(long entityId, Tuple!(float, "x", float, "y", float, "z") motion=Tuple!(float, "x", float, "y", float, "z").init) { 2572 this.entityId = entityId; 2573 this.motion = motion; 2574 } 2575 2576 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 2577 _buffer.length = 0; 2578 static if(writeId){ writeBigEndianUbyte(ID); } 2579 writeBytes(varlong.encode(entityId)); 2580 writeLittleEndianFloat(motion.x); writeLittleEndianFloat(motion.y); writeLittleEndianFloat(motion.z); 2581 return _buffer; 2582 } 2583 2584 public pure nothrow @safe void decode(bool readId=true)() { 2585 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 2586 entityId=varlong.decode(_buffer, &_index); 2587 motion.x=readLittleEndianFloat(); motion.y=readLittleEndianFloat(); motion.z=readLittleEndianFloat(); 2588 } 2589 2590 public static pure nothrow @safe SetEntityMotion fromBuffer(bool readId=true)(ubyte[] buffer) { 2591 SetEntityMotion ret = new SetEntityMotion(); 2592 ret._buffer = buffer; 2593 ret.decode!readId(); 2594 return ret; 2595 } 2596 2597 public override string toString() { 2598 return "SetEntityMotion(entityId: " ~ std.conv.to!string(this.entityId) ~ ", motion: " ~ std.conv.to!string(this.motion) ~ ")"; 2599 } 2600 2601 } 2602 2603 class SetEntityLink : Buffer { 2604 2605 public enum ubyte ID = 41; 2606 2607 public enum bool CLIENTBOUND = true; 2608 public enum bool SERVERBOUND = false; 2609 2610 // action 2611 public enum ubyte ADD = 0; 2612 public enum ubyte RIDE = 1; 2613 public enum ubyte REMOVE = 2; 2614 2615 public enum string[] FIELDS = ["from", "to", "action"]; 2616 2617 public long from; 2618 public long to; 2619 public ubyte action; 2620 2621 public pure nothrow @safe @nogc this() {} 2622 2623 public pure nothrow @safe @nogc this(long from, long to=long.init, ubyte action=ubyte.init) { 2624 this.from = from; 2625 this.to = to; 2626 this.action = action; 2627 } 2628 2629 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 2630 _buffer.length = 0; 2631 static if(writeId){ writeBigEndianUbyte(ID); } 2632 writeBytes(varlong.encode(from)); 2633 writeBytes(varlong.encode(to)); 2634 writeBigEndianUbyte(action); 2635 return _buffer; 2636 } 2637 2638 public pure nothrow @safe void decode(bool readId=true)() { 2639 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 2640 from=varlong.decode(_buffer, &_index); 2641 to=varlong.decode(_buffer, &_index); 2642 action=readBigEndianUbyte(); 2643 } 2644 2645 public static pure nothrow @safe SetEntityLink fromBuffer(bool readId=true)(ubyte[] buffer) { 2646 SetEntityLink ret = new SetEntityLink(); 2647 ret._buffer = buffer; 2648 ret.decode!readId(); 2649 return ret; 2650 } 2651 2652 public override string toString() { 2653 return "SetEntityLink(from: " ~ std.conv.to!string(this.from) ~ ", to: " ~ std.conv.to!string(this.to) ~ ", action: " ~ std.conv.to!string(this.action) ~ ")"; 2654 } 2655 2656 } 2657 2658 class SetHealth : Buffer { 2659 2660 public enum ubyte ID = 42; 2661 2662 public enum bool CLIENTBOUND = true; 2663 public enum bool SERVERBOUND = false; 2664 2665 public enum string[] FIELDS = ["health"]; 2666 2667 public int health; 2668 2669 public pure nothrow @safe @nogc this() {} 2670 2671 public pure nothrow @safe @nogc this(int health) { 2672 this.health = health; 2673 } 2674 2675 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 2676 _buffer.length = 0; 2677 static if(writeId){ writeBigEndianUbyte(ID); } 2678 writeBytes(varint.encode(health)); 2679 return _buffer; 2680 } 2681 2682 public pure nothrow @safe void decode(bool readId=true)() { 2683 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 2684 health=varint.decode(_buffer, &_index); 2685 } 2686 2687 public static pure nothrow @safe SetHealth fromBuffer(bool readId=true)(ubyte[] buffer) { 2688 SetHealth ret = new SetHealth(); 2689 ret._buffer = buffer; 2690 ret.decode!readId(); 2691 return ret; 2692 } 2693 2694 public override string toString() { 2695 return "SetHealth(health: " ~ std.conv.to!string(this.health) ~ ")"; 2696 } 2697 2698 } 2699 2700 class SetSpawnPosition : Buffer { 2701 2702 public enum ubyte ID = 43; 2703 2704 public enum bool CLIENTBOUND = true; 2705 public enum bool SERVERBOUND = false; 2706 2707 public enum string[] FIELDS = ["unknown0", "position", "unknown2"]; 2708 2709 public int unknown0; 2710 public sul.protocol.pocket102.types.BlockPosition position; 2711 public bool unknown2; 2712 2713 public pure nothrow @safe @nogc this() {} 2714 2715 public pure nothrow @safe @nogc this(int unknown0, sul.protocol.pocket102.types.BlockPosition position=sul.protocol.pocket102.types.BlockPosition.init, bool unknown2=bool.init) { 2716 this.unknown0 = unknown0; 2717 this.position = position; 2718 this.unknown2 = unknown2; 2719 } 2720 2721 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 2722 _buffer.length = 0; 2723 static if(writeId){ writeBigEndianUbyte(ID); } 2724 writeBytes(varint.encode(unknown0)); 2725 position.encode(bufferInstance); 2726 writeBigEndianBool(unknown2); 2727 return _buffer; 2728 } 2729 2730 public pure nothrow @safe void decode(bool readId=true)() { 2731 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 2732 unknown0=varint.decode(_buffer, &_index); 2733 position.decode(bufferInstance); 2734 unknown2=readBigEndianBool(); 2735 } 2736 2737 public static pure nothrow @safe SetSpawnPosition fromBuffer(bool readId=true)(ubyte[] buffer) { 2738 SetSpawnPosition ret = new SetSpawnPosition(); 2739 ret._buffer = buffer; 2740 ret.decode!readId(); 2741 return ret; 2742 } 2743 2744 public override string toString() { 2745 return "SetSpawnPosition(unknown0: " ~ std.conv.to!string(this.unknown0) ~ ", position: " ~ std.conv.to!string(this.position) ~ ", unknown2: " ~ std.conv.to!string(this.unknown2) ~ ")"; 2746 } 2747 2748 } 2749 2750 class Animate : Buffer { 2751 2752 public enum ubyte ID = 44; 2753 2754 public enum bool CLIENTBOUND = true; 2755 public enum bool SERVERBOUND = true; 2756 2757 // action 2758 public enum int BREAKING = 1; 2759 public enum int WAKE_UP = 3; 2760 2761 public enum string[] FIELDS = ["action", "entityId"]; 2762 2763 public int action; 2764 public long entityId; 2765 2766 public pure nothrow @safe @nogc this() {} 2767 2768 public pure nothrow @safe @nogc this(int action, long entityId=long.init) { 2769 this.action = action; 2770 this.entityId = entityId; 2771 } 2772 2773 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 2774 _buffer.length = 0; 2775 static if(writeId){ writeBigEndianUbyte(ID); } 2776 writeBytes(varint.encode(action)); 2777 writeBytes(varlong.encode(entityId)); 2778 return _buffer; 2779 } 2780 2781 public pure nothrow @safe void decode(bool readId=true)() { 2782 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 2783 action=varint.decode(_buffer, &_index); 2784 entityId=varlong.decode(_buffer, &_index); 2785 } 2786 2787 public static pure nothrow @safe Animate fromBuffer(bool readId=true)(ubyte[] buffer) { 2788 Animate ret = new Animate(); 2789 ret._buffer = buffer; 2790 ret.decode!readId(); 2791 return ret; 2792 } 2793 2794 public override string toString() { 2795 return "Animate(action: " ~ std.conv.to!string(this.action) ~ ", entityId: " ~ std.conv.to!string(this.entityId) ~ ")"; 2796 } 2797 2798 } 2799 2800 class Respawn : Buffer { 2801 2802 public enum ubyte ID = 45; 2803 2804 public enum bool CLIENTBOUND = true; 2805 public enum bool SERVERBOUND = false; 2806 2807 public enum string[] FIELDS = ["position"]; 2808 2809 public Tuple!(float, "x", float, "y", float, "z") position; 2810 2811 public pure nothrow @safe @nogc this() {} 2812 2813 public pure nothrow @safe @nogc this(Tuple!(float, "x", float, "y", float, "z") position) { 2814 this.position = position; 2815 } 2816 2817 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 2818 _buffer.length = 0; 2819 static if(writeId){ writeBigEndianUbyte(ID); } 2820 writeLittleEndianFloat(position.x); writeLittleEndianFloat(position.y); writeLittleEndianFloat(position.z); 2821 return _buffer; 2822 } 2823 2824 public pure nothrow @safe void decode(bool readId=true)() { 2825 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 2826 position.x=readLittleEndianFloat(); position.y=readLittleEndianFloat(); position.z=readLittleEndianFloat(); 2827 } 2828 2829 public static pure nothrow @safe Respawn fromBuffer(bool readId=true)(ubyte[] buffer) { 2830 Respawn ret = new Respawn(); 2831 ret._buffer = buffer; 2832 ret.decode!readId(); 2833 return ret; 2834 } 2835 2836 public override string toString() { 2837 return "Respawn(position: " ~ std.conv.to!string(this.position) ~ ")"; 2838 } 2839 2840 } 2841 2842 class DropItem : Buffer { 2843 2844 public enum ubyte ID = 46; 2845 2846 public enum bool CLIENTBOUND = false; 2847 public enum bool SERVERBOUND = true; 2848 2849 // action 2850 public enum ubyte DROP = 0; 2851 2852 public enum string[] FIELDS = ["action", "item"]; 2853 2854 public ubyte action; 2855 public sul.protocol.pocket102.types.Slot item; 2856 2857 public pure nothrow @safe @nogc this() {} 2858 2859 public pure nothrow @safe @nogc this(ubyte action, sul.protocol.pocket102.types.Slot item=sul.protocol.pocket102.types.Slot.init) { 2860 this.action = action; 2861 this.item = item; 2862 } 2863 2864 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 2865 _buffer.length = 0; 2866 static if(writeId){ writeBigEndianUbyte(ID); } 2867 writeBigEndianUbyte(action); 2868 item.encode(bufferInstance); 2869 return _buffer; 2870 } 2871 2872 public pure nothrow @safe void decode(bool readId=true)() { 2873 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 2874 action=readBigEndianUbyte(); 2875 item.decode(bufferInstance); 2876 } 2877 2878 public static pure nothrow @safe DropItem fromBuffer(bool readId=true)(ubyte[] buffer) { 2879 DropItem ret = new DropItem(); 2880 ret._buffer = buffer; 2881 ret.decode!readId(); 2882 return ret; 2883 } 2884 2885 public override string toString() { 2886 return "DropItem(action: " ~ std.conv.to!string(this.action) ~ ", item: " ~ std.conv.to!string(this.item) ~ ")"; 2887 } 2888 2889 } 2890 2891 class InventoryAction : Buffer { 2892 2893 public enum ubyte ID = 47; 2894 2895 public enum bool CLIENTBOUND = false; 2896 public enum bool SERVERBOUND = true; 2897 2898 public enum string[] FIELDS = ["action", "item"]; 2899 2900 public int action; 2901 public sul.protocol.pocket102.types.Slot item; 2902 2903 public pure nothrow @safe @nogc this() {} 2904 2905 public pure nothrow @safe @nogc this(int action, sul.protocol.pocket102.types.Slot item=sul.protocol.pocket102.types.Slot.init) { 2906 this.action = action; 2907 this.item = item; 2908 } 2909 2910 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 2911 _buffer.length = 0; 2912 static if(writeId){ writeBigEndianUbyte(ID); } 2913 writeBytes(varint.encode(action)); 2914 item.encode(bufferInstance); 2915 return _buffer; 2916 } 2917 2918 public pure nothrow @safe void decode(bool readId=true)() { 2919 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 2920 action=varint.decode(_buffer, &_index); 2921 item.decode(bufferInstance); 2922 } 2923 2924 public static pure nothrow @safe InventoryAction fromBuffer(bool readId=true)(ubyte[] buffer) { 2925 InventoryAction ret = new InventoryAction(); 2926 ret._buffer = buffer; 2927 ret.decode!readId(); 2928 return ret; 2929 } 2930 2931 public override string toString() { 2932 return "InventoryAction(action: " ~ std.conv.to!string(this.action) ~ ", item: " ~ std.conv.to!string(this.item) ~ ")"; 2933 } 2934 2935 } 2936 2937 class ContainerOpen : Buffer { 2938 2939 public enum ubyte ID = 48; 2940 2941 public enum bool CLIENTBOUND = true; 2942 public enum bool SERVERBOUND = false; 2943 2944 public enum string[] FIELDS = ["window", "type", "slotCount", "position", "entityId"]; 2945 2946 public ubyte window; 2947 public ubyte type; 2948 public int slotCount; 2949 public sul.protocol.pocket102.types.BlockPosition position; 2950 public long entityId; 2951 2952 public pure nothrow @safe @nogc this() {} 2953 2954 public pure nothrow @safe @nogc this(ubyte window, ubyte type=ubyte.init, int slotCount=int.init, sul.protocol.pocket102.types.BlockPosition position=sul.protocol.pocket102.types.BlockPosition.init, long entityId=long.init) { 2955 this.window = window; 2956 this.type = type; 2957 this.slotCount = slotCount; 2958 this.position = position; 2959 this.entityId = entityId; 2960 } 2961 2962 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 2963 _buffer.length = 0; 2964 static if(writeId){ writeBigEndianUbyte(ID); } 2965 writeBigEndianUbyte(window); 2966 writeBigEndianUbyte(type); 2967 writeBytes(varint.encode(slotCount)); 2968 position.encode(bufferInstance); 2969 writeBytes(varlong.encode(entityId)); 2970 return _buffer; 2971 } 2972 2973 public pure nothrow @safe void decode(bool readId=true)() { 2974 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 2975 window=readBigEndianUbyte(); 2976 type=readBigEndianUbyte(); 2977 slotCount=varint.decode(_buffer, &_index); 2978 position.decode(bufferInstance); 2979 entityId=varlong.decode(_buffer, &_index); 2980 } 2981 2982 public static pure nothrow @safe ContainerOpen fromBuffer(bool readId=true)(ubyte[] buffer) { 2983 ContainerOpen ret = new ContainerOpen(); 2984 ret._buffer = buffer; 2985 ret.decode!readId(); 2986 return ret; 2987 } 2988 2989 public override string toString() { 2990 return "ContainerOpen(window: " ~ std.conv.to!string(this.window) ~ ", type: " ~ std.conv.to!string(this.type) ~ ", slotCount: " ~ std.conv.to!string(this.slotCount) ~ ", position: " ~ std.conv.to!string(this.position) ~ ", entityId: " ~ std.conv.to!string(this.entityId) ~ ")"; 2991 } 2992 2993 } 2994 2995 class ContainerClose : Buffer { 2996 2997 public enum ubyte ID = 49; 2998 2999 public enum bool CLIENTBOUND = true; 3000 public enum bool SERVERBOUND = true; 3001 3002 public enum string[] FIELDS = ["window"]; 3003 3004 public ubyte window; 3005 3006 public pure nothrow @safe @nogc this() {} 3007 3008 public pure nothrow @safe @nogc this(ubyte window) { 3009 this.window = window; 3010 } 3011 3012 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 3013 _buffer.length = 0; 3014 static if(writeId){ writeBigEndianUbyte(ID); } 3015 writeBigEndianUbyte(window); 3016 return _buffer; 3017 } 3018 3019 public pure nothrow @safe void decode(bool readId=true)() { 3020 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 3021 window=readBigEndianUbyte(); 3022 } 3023 3024 public static pure nothrow @safe ContainerClose fromBuffer(bool readId=true)(ubyte[] buffer) { 3025 ContainerClose ret = new ContainerClose(); 3026 ret._buffer = buffer; 3027 ret.decode!readId(); 3028 return ret; 3029 } 3030 3031 public override string toString() { 3032 return "ContainerClose(window: " ~ std.conv.to!string(this.window) ~ ")"; 3033 } 3034 3035 } 3036 3037 class ContainerSetSlot : Buffer { 3038 3039 public enum ubyte ID = 50; 3040 3041 public enum bool CLIENTBOUND = true; 3042 public enum bool SERVERBOUND = true; 3043 3044 public enum string[] FIELDS = ["window", "slot", "hotbarSlot", "item", "unknown4"]; 3045 3046 public ubyte window; 3047 public int slot; 3048 public int hotbarSlot; 3049 public sul.protocol.pocket102.types.Slot item; 3050 public ubyte unknown4; 3051 3052 public pure nothrow @safe @nogc this() {} 3053 3054 public pure nothrow @safe @nogc this(ubyte window, int slot=int.init, int hotbarSlot=int.init, sul.protocol.pocket102.types.Slot item=sul.protocol.pocket102.types.Slot.init, ubyte unknown4=ubyte.init) { 3055 this.window = window; 3056 this.slot = slot; 3057 this.hotbarSlot = hotbarSlot; 3058 this.item = item; 3059 this.unknown4 = unknown4; 3060 } 3061 3062 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 3063 _buffer.length = 0; 3064 static if(writeId){ writeBigEndianUbyte(ID); } 3065 writeBigEndianUbyte(window); 3066 writeBytes(varint.encode(slot)); 3067 writeBytes(varint.encode(hotbarSlot)); 3068 item.encode(bufferInstance); 3069 writeBigEndianUbyte(unknown4); 3070 return _buffer; 3071 } 3072 3073 public pure nothrow @safe void decode(bool readId=true)() { 3074 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 3075 window=readBigEndianUbyte(); 3076 slot=varint.decode(_buffer, &_index); 3077 hotbarSlot=varint.decode(_buffer, &_index); 3078 item.decode(bufferInstance); 3079 unknown4=readBigEndianUbyte(); 3080 } 3081 3082 public static pure nothrow @safe ContainerSetSlot fromBuffer(bool readId=true)(ubyte[] buffer) { 3083 ContainerSetSlot ret = new ContainerSetSlot(); 3084 ret._buffer = buffer; 3085 ret.decode!readId(); 3086 return ret; 3087 } 3088 3089 public override string toString() { 3090 return "ContainerSetSlot(window: " ~ std.conv.to!string(this.window) ~ ", slot: " ~ std.conv.to!string(this.slot) ~ ", hotbarSlot: " ~ std.conv.to!string(this.hotbarSlot) ~ ", item: " ~ std.conv.to!string(this.item) ~ ", unknown4: " ~ std.conv.to!string(this.unknown4) ~ ")"; 3091 } 3092 3093 } 3094 3095 class ContainerSetData : Buffer { 3096 3097 public enum ubyte ID = 51; 3098 3099 public enum bool CLIENTBOUND = true; 3100 public enum bool SERVERBOUND = false; 3101 3102 public enum string[] FIELDS = ["window", "property", "value"]; 3103 3104 public ubyte window; 3105 public int property; 3106 public int value; 3107 3108 public pure nothrow @safe @nogc this() {} 3109 3110 public pure nothrow @safe @nogc this(ubyte window, int property=int.init, int value=int.init) { 3111 this.window = window; 3112 this.property = property; 3113 this.value = value; 3114 } 3115 3116 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 3117 _buffer.length = 0; 3118 static if(writeId){ writeBigEndianUbyte(ID); } 3119 writeBigEndianUbyte(window); 3120 writeBytes(varint.encode(property)); 3121 writeBytes(varint.encode(value)); 3122 return _buffer; 3123 } 3124 3125 public pure nothrow @safe void decode(bool readId=true)() { 3126 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 3127 window=readBigEndianUbyte(); 3128 property=varint.decode(_buffer, &_index); 3129 value=varint.decode(_buffer, &_index); 3130 } 3131 3132 public static pure nothrow @safe ContainerSetData fromBuffer(bool readId=true)(ubyte[] buffer) { 3133 ContainerSetData ret = new ContainerSetData(); 3134 ret._buffer = buffer; 3135 ret.decode!readId(); 3136 return ret; 3137 } 3138 3139 public override string toString() { 3140 return "ContainerSetData(window: " ~ std.conv.to!string(this.window) ~ ", property: " ~ std.conv.to!string(this.property) ~ ", value: " ~ std.conv.to!string(this.value) ~ ")"; 3141 } 3142 3143 } 3144 3145 class ContainerSetContent : Buffer { 3146 3147 public enum ubyte ID = 52; 3148 3149 public enum bool CLIENTBOUND = true; 3150 public enum bool SERVERBOUND = false; 3151 3152 public enum string[] FIELDS = ["window", "slots", "hotbar"]; 3153 3154 public ubyte window; 3155 public sul.protocol.pocket102.types.Slot[] slots; 3156 public int[] hotbar; 3157 3158 public pure nothrow @safe @nogc this() {} 3159 3160 public pure nothrow @safe @nogc this(ubyte window, sul.protocol.pocket102.types.Slot[] slots=(sul.protocol.pocket102.types.Slot[]).init, int[] hotbar=(int[]).init) { 3161 this.window = window; 3162 this.slots = slots; 3163 this.hotbar = hotbar; 3164 } 3165 3166 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 3167 _buffer.length = 0; 3168 static if(writeId){ writeBigEndianUbyte(ID); } 3169 writeBigEndianUbyte(window); 3170 writeBytes(varuint.encode(cast(uint)slots.length)); foreach(cxdm;slots){ cxdm.encode(bufferInstance); } 3171 writeBytes(varuint.encode(cast(uint)hotbar.length)); foreach(a9yf;hotbar){ writeBytes(varint.encode(a9yf)); } 3172 return _buffer; 3173 } 3174 3175 public pure nothrow @safe void decode(bool readId=true)() { 3176 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 3177 window=readBigEndianUbyte(); 3178 slots.length=varuint.decode(_buffer, &_index); foreach(ref cxdm;slots){ cxdm.decode(bufferInstance); } 3179 hotbar.length=varuint.decode(_buffer, &_index); foreach(ref a9yf;hotbar){ a9yf=varint.decode(_buffer, &_index); } 3180 } 3181 3182 public static pure nothrow @safe ContainerSetContent fromBuffer(bool readId=true)(ubyte[] buffer) { 3183 ContainerSetContent ret = new ContainerSetContent(); 3184 ret._buffer = buffer; 3185 ret.decode!readId(); 3186 return ret; 3187 } 3188 3189 public override string toString() { 3190 return "ContainerSetContent(window: " ~ std.conv.to!string(this.window) ~ ", slots: " ~ std.conv.to!string(this.slots) ~ ", hotbar: " ~ std.conv.to!string(this.hotbar) ~ ")"; 3191 } 3192 3193 } 3194 3195 class CraftingData : Buffer { 3196 3197 public enum ubyte ID = 53; 3198 3199 public enum bool CLIENTBOUND = true; 3200 public enum bool SERVERBOUND = false; 3201 3202 public enum string[] FIELDS = ["recipes"]; 3203 3204 public sul.protocol.pocket102.types.Recipe[] recipes; 3205 3206 public pure nothrow @safe @nogc this() {} 3207 3208 public pure nothrow @safe @nogc this(sul.protocol.pocket102.types.Recipe[] recipes) { 3209 this.recipes = recipes; 3210 } 3211 3212 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 3213 _buffer.length = 0; 3214 static if(writeId){ writeBigEndianUbyte(ID); } 3215 writeBytes(varuint.encode(cast(uint)recipes.length)); foreach(cvabc;recipes){ cvabc.encode(bufferInstance); } 3216 return _buffer; 3217 } 3218 3219 public pure nothrow @safe void decode(bool readId=true)() { 3220 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 3221 recipes.length=varuint.decode(_buffer, &_index); foreach(ref cvabc;recipes){ cvabc.decode(bufferInstance); } 3222 } 3223 3224 public static pure nothrow @safe CraftingData fromBuffer(bool readId=true)(ubyte[] buffer) { 3225 CraftingData ret = new CraftingData(); 3226 ret._buffer = buffer; 3227 ret.decode!readId(); 3228 return ret; 3229 } 3230 3231 public override string toString() { 3232 return "CraftingData(recipes: " ~ std.conv.to!string(this.recipes) ~ ")"; 3233 } 3234 3235 } 3236 3237 class CraftingEvent : Buffer { 3238 3239 public enum ubyte ID = 54; 3240 3241 public enum bool CLIENTBOUND = false; 3242 public enum bool SERVERBOUND = true; 3243 3244 public enum string[] FIELDS = ["window", "type", "uuid", "input", "output"]; 3245 3246 public ubyte window; 3247 public int type; 3248 public UUID uuid; 3249 public sul.protocol.pocket102.types.Slot[] input; 3250 public sul.protocol.pocket102.types.Slot[] output; 3251 3252 public pure nothrow @safe @nogc this() {} 3253 3254 public pure nothrow @safe @nogc this(ubyte window, int type=int.init, UUID uuid=UUID.init, sul.protocol.pocket102.types.Slot[] input=(sul.protocol.pocket102.types.Slot[]).init, sul.protocol.pocket102.types.Slot[] output=(sul.protocol.pocket102.types.Slot[]).init) { 3255 this.window = window; 3256 this.type = type; 3257 this.uuid = uuid; 3258 this.input = input; 3259 this.output = output; 3260 } 3261 3262 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 3263 _buffer.length = 0; 3264 static if(writeId){ writeBigEndianUbyte(ID); } 3265 writeBigEndianUbyte(window); 3266 writeBytes(varint.encode(type)); 3267 writeBytes(uuid.data); 3268 writeBytes(varuint.encode(cast(uint)input.length)); foreach(a5dq;input){ a5dq.encode(bufferInstance); } 3269 writeBytes(varuint.encode(cast(uint)output.length)); foreach(bvcv;output){ bvcv.encode(bufferInstance); } 3270 return _buffer; 3271 } 3272 3273 public pure nothrow @safe void decode(bool readId=true)() { 3274 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 3275 window=readBigEndianUbyte(); 3276 type=varint.decode(_buffer, &_index); 3277 if(_buffer.length>=_index+16){ ubyte[16] dvz=_buffer[_index.._index+16].dup; _index+=16; uuid=UUID(dvz); } 3278 input.length=varuint.decode(_buffer, &_index); foreach(ref a5dq;input){ a5dq.decode(bufferInstance); } 3279 output.length=varuint.decode(_buffer, &_index); foreach(ref bvcv;output){ bvcv.decode(bufferInstance); } 3280 } 3281 3282 public static pure nothrow @safe CraftingEvent fromBuffer(bool readId=true)(ubyte[] buffer) { 3283 CraftingEvent ret = new CraftingEvent(); 3284 ret._buffer = buffer; 3285 ret.decode!readId(); 3286 return ret; 3287 } 3288 3289 public override string toString() { 3290 return "CraftingEvent(window: " ~ std.conv.to!string(this.window) ~ ", type: " ~ std.conv.to!string(this.type) ~ ", uuid: " ~ std.conv.to!string(this.uuid) ~ ", input: " ~ std.conv.to!string(this.input) ~ ", output: " ~ std.conv.to!string(this.output) ~ ")"; 3291 } 3292 3293 } 3294 3295 class AdventureSettings : Buffer { 3296 3297 public enum ubyte ID = 55; 3298 3299 public enum bool CLIENTBOUND = true; 3300 public enum bool SERVERBOUND = true; 3301 3302 // flags 3303 public enum uint IMMUTABLE_WORLD = 1; 3304 public enum uint PVP_DISABLED = 2; 3305 public enum uint PVM_DISABLED = 4; 3306 public enum uint MVP_DISBALED = 8; 3307 public enum uint EVP_DISABLED = 16; 3308 public enum uint AUTO_JUMP = 32; 3309 public enum uint ALLOW_FLIGHT = 64; 3310 public enum uint NO_CLIP = 128; 3311 public enum uint FLYING = 512; 3312 3313 // permissions 3314 public enum uint USER = 0; 3315 public enum uint OPERATOR = 1; 3316 public enum uint HOST = 2; 3317 public enum uint AUTOMATION = 3; 3318 public enum uint ADMIN = 4; 3319 3320 public enum string[] FIELDS = ["flags", "permissions"]; 3321 3322 public uint flags; 3323 public uint permissions; 3324 3325 public pure nothrow @safe @nogc this() {} 3326 3327 public pure nothrow @safe @nogc this(uint flags, uint permissions=uint.init) { 3328 this.flags = flags; 3329 this.permissions = permissions; 3330 } 3331 3332 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 3333 _buffer.length = 0; 3334 static if(writeId){ writeBigEndianUbyte(ID); } 3335 writeBytes(varuint.encode(flags)); 3336 writeBytes(varuint.encode(permissions)); 3337 return _buffer; 3338 } 3339 3340 public pure nothrow @safe void decode(bool readId=true)() { 3341 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 3342 flags=varuint.decode(_buffer, &_index); 3343 permissions=varuint.decode(_buffer, &_index); 3344 } 3345 3346 public static pure nothrow @safe AdventureSettings fromBuffer(bool readId=true)(ubyte[] buffer) { 3347 AdventureSettings ret = new AdventureSettings(); 3348 ret._buffer = buffer; 3349 ret.decode!readId(); 3350 return ret; 3351 } 3352 3353 public override string toString() { 3354 return "AdventureSettings(flags: " ~ std.conv.to!string(this.flags) ~ ", permissions: " ~ std.conv.to!string(this.permissions) ~ ")"; 3355 } 3356 3357 } 3358 3359 class BlockEntityData : Buffer { 3360 3361 public enum ubyte ID = 56; 3362 3363 public enum bool CLIENTBOUND = true; 3364 public enum bool SERVERBOUND = true; 3365 3366 public enum string[] FIELDS = ["position", "nbt"]; 3367 3368 public sul.protocol.pocket102.types.BlockPosition position; 3369 public ubyte[] nbt; 3370 3371 public pure nothrow @safe @nogc this() {} 3372 3373 public pure nothrow @safe @nogc this(sul.protocol.pocket102.types.BlockPosition position, ubyte[] nbt=(ubyte[]).init) { 3374 this.position = position; 3375 this.nbt = nbt; 3376 } 3377 3378 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 3379 _buffer.length = 0; 3380 static if(writeId){ writeBigEndianUbyte(ID); } 3381 position.encode(bufferInstance); 3382 writeBytes(nbt); 3383 return _buffer; 3384 } 3385 3386 public pure nothrow @safe void decode(bool readId=true)() { 3387 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 3388 position.decode(bufferInstance); 3389 nbt=_buffer[_index..$].dup; _index=_buffer.length; 3390 } 3391 3392 public static pure nothrow @safe BlockEntityData fromBuffer(bool readId=true)(ubyte[] buffer) { 3393 BlockEntityData ret = new BlockEntityData(); 3394 ret._buffer = buffer; 3395 ret.decode!readId(); 3396 return ret; 3397 } 3398 3399 public override string toString() { 3400 return "BlockEntityData(position: " ~ std.conv.to!string(this.position) ~ ", nbt: " ~ std.conv.to!string(this.nbt) ~ ")"; 3401 } 3402 3403 } 3404 3405 class PlayerInput : Buffer { 3406 3407 public enum ubyte ID = 57; 3408 3409 public enum bool CLIENTBOUND = false; 3410 public enum bool SERVERBOUND = true; 3411 3412 public enum string[] FIELDS = ["motion", "flags", "unknown2"]; 3413 3414 public Tuple!(float, "x", float, "y", float, "z") motion; 3415 public ubyte flags; 3416 public bool unknown2; 3417 3418 public pure nothrow @safe @nogc this() {} 3419 3420 public pure nothrow @safe @nogc this(Tuple!(float, "x", float, "y", float, "z") motion, ubyte flags=ubyte.init, bool unknown2=bool.init) { 3421 this.motion = motion; 3422 this.flags = flags; 3423 this.unknown2 = unknown2; 3424 } 3425 3426 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 3427 _buffer.length = 0; 3428 static if(writeId){ writeBigEndianUbyte(ID); } 3429 writeLittleEndianFloat(motion.x); writeLittleEndianFloat(motion.y); writeLittleEndianFloat(motion.z); 3430 writeBigEndianUbyte(flags); 3431 writeBigEndianBool(unknown2); 3432 return _buffer; 3433 } 3434 3435 public pure nothrow @safe void decode(bool readId=true)() { 3436 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 3437 motion.x=readLittleEndianFloat(); motion.y=readLittleEndianFloat(); motion.z=readLittleEndianFloat(); 3438 flags=readBigEndianUbyte(); 3439 unknown2=readBigEndianBool(); 3440 } 3441 3442 public static pure nothrow @safe PlayerInput fromBuffer(bool readId=true)(ubyte[] buffer) { 3443 PlayerInput ret = new PlayerInput(); 3444 ret._buffer = buffer; 3445 ret.decode!readId(); 3446 return ret; 3447 } 3448 3449 public override string toString() { 3450 return "PlayerInput(motion: " ~ std.conv.to!string(this.motion) ~ ", flags: " ~ std.conv.to!string(this.flags) ~ ", unknown2: " ~ std.conv.to!string(this.unknown2) ~ ")"; 3451 } 3452 3453 } 3454 3455 class FullChunkData : Buffer { 3456 3457 public enum ubyte ID = 58; 3458 3459 public enum bool CLIENTBOUND = true; 3460 public enum bool SERVERBOUND = false; 3461 3462 public enum string[] FIELDS = ["position", "data"]; 3463 3464 public Tuple!(int, "x", int, "z") position; 3465 public sul.protocol.pocket102.types.ChunkData data; 3466 3467 public pure nothrow @safe @nogc this() {} 3468 3469 public pure nothrow @safe @nogc this(Tuple!(int, "x", int, "z") position, sul.protocol.pocket102.types.ChunkData data=sul.protocol.pocket102.types.ChunkData.init) { 3470 this.position = position; 3471 this.data = data; 3472 } 3473 3474 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 3475 _buffer.length = 0; 3476 static if(writeId){ writeBigEndianUbyte(ID); } 3477 writeBytes(varint.encode(position.x)); writeBytes(varint.encode(position.z)); 3478 data.encode(bufferInstance); 3479 return _buffer; 3480 } 3481 3482 public pure nothrow @safe void decode(bool readId=true)() { 3483 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 3484 position.x=varint.decode(_buffer, &_index); position.z=varint.decode(_buffer, &_index); 3485 data.decode(bufferInstance); 3486 } 3487 3488 public static pure nothrow @safe FullChunkData fromBuffer(bool readId=true)(ubyte[] buffer) { 3489 FullChunkData ret = new FullChunkData(); 3490 ret._buffer = buffer; 3491 ret.decode!readId(); 3492 return ret; 3493 } 3494 3495 public override string toString() { 3496 return "FullChunkData(position: " ~ std.conv.to!string(this.position) ~ ", data: " ~ std.conv.to!string(this.data) ~ ")"; 3497 } 3498 3499 } 3500 3501 class SetCommandsEnabled : Buffer { 3502 3503 public enum ubyte ID = 59; 3504 3505 public enum bool CLIENTBOUND = true; 3506 public enum bool SERVERBOUND = false; 3507 3508 public enum string[] FIELDS = ["enabled"]; 3509 3510 public bool enabled; 3511 3512 public pure nothrow @safe @nogc this() {} 3513 3514 public pure nothrow @safe @nogc this(bool enabled) { 3515 this.enabled = enabled; 3516 } 3517 3518 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 3519 _buffer.length = 0; 3520 static if(writeId){ writeBigEndianUbyte(ID); } 3521 writeBigEndianBool(enabled); 3522 return _buffer; 3523 } 3524 3525 public pure nothrow @safe void decode(bool readId=true)() { 3526 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 3527 enabled=readBigEndianBool(); 3528 } 3529 3530 public static pure nothrow @safe SetCommandsEnabled fromBuffer(bool readId=true)(ubyte[] buffer) { 3531 SetCommandsEnabled ret = new SetCommandsEnabled(); 3532 ret._buffer = buffer; 3533 ret.decode!readId(); 3534 return ret; 3535 } 3536 3537 public override string toString() { 3538 return "SetCommandsEnabled(enabled: " ~ std.conv.to!string(this.enabled) ~ ")"; 3539 } 3540 3541 } 3542 3543 class SetDifficulty : Buffer { 3544 3545 public enum ubyte ID = 60; 3546 3547 public enum bool CLIENTBOUND = true; 3548 public enum bool SERVERBOUND = false; 3549 3550 // difficulty 3551 public enum uint PEACEFUL = 0; 3552 public enum uint EASY = 1; 3553 public enum uint NORMAL = 2; 3554 public enum uint HARD = 3; 3555 3556 public enum string[] FIELDS = ["difficulty"]; 3557 3558 public uint difficulty; 3559 3560 public pure nothrow @safe @nogc this() {} 3561 3562 public pure nothrow @safe @nogc this(uint difficulty) { 3563 this.difficulty = difficulty; 3564 } 3565 3566 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 3567 _buffer.length = 0; 3568 static if(writeId){ writeBigEndianUbyte(ID); } 3569 writeBytes(varuint.encode(difficulty)); 3570 return _buffer; 3571 } 3572 3573 public pure nothrow @safe void decode(bool readId=true)() { 3574 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 3575 difficulty=varuint.decode(_buffer, &_index); 3576 } 3577 3578 public static pure nothrow @safe SetDifficulty fromBuffer(bool readId=true)(ubyte[] buffer) { 3579 SetDifficulty ret = new SetDifficulty(); 3580 ret._buffer = buffer; 3581 ret.decode!readId(); 3582 return ret; 3583 } 3584 3585 public override string toString() { 3586 return "SetDifficulty(difficulty: " ~ std.conv.to!string(this.difficulty) ~ ")"; 3587 } 3588 3589 } 3590 3591 class ChangeDimension : Buffer { 3592 3593 public enum ubyte ID = 61; 3594 3595 public enum bool CLIENTBOUND = true; 3596 public enum bool SERVERBOUND = false; 3597 3598 // dimension 3599 public enum int OVERWORLD = 0; 3600 public enum int NETHER = 1; 3601 public enum int END = 2; 3602 3603 public enum string[] FIELDS = ["dimension", "position", "unknown2"]; 3604 3605 public int dimension; 3606 public Tuple!(float, "x", float, "y", float, "z") position; 3607 public bool unknown2; 3608 3609 public pure nothrow @safe @nogc this() {} 3610 3611 public pure nothrow @safe @nogc this(int dimension, Tuple!(float, "x", float, "y", float, "z") position=Tuple!(float, "x", float, "y", float, "z").init, bool unknown2=bool.init) { 3612 this.dimension = dimension; 3613 this.position = position; 3614 this.unknown2 = unknown2; 3615 } 3616 3617 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 3618 _buffer.length = 0; 3619 static if(writeId){ writeBigEndianUbyte(ID); } 3620 writeBytes(varint.encode(dimension)); 3621 writeLittleEndianFloat(position.x); writeLittleEndianFloat(position.y); writeLittleEndianFloat(position.z); 3622 writeBigEndianBool(unknown2); 3623 return _buffer; 3624 } 3625 3626 public pure nothrow @safe void decode(bool readId=true)() { 3627 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 3628 dimension=varint.decode(_buffer, &_index); 3629 position.x=readLittleEndianFloat(); position.y=readLittleEndianFloat(); position.z=readLittleEndianFloat(); 3630 unknown2=readBigEndianBool(); 3631 } 3632 3633 public static pure nothrow @safe ChangeDimension fromBuffer(bool readId=true)(ubyte[] buffer) { 3634 ChangeDimension ret = new ChangeDimension(); 3635 ret._buffer = buffer; 3636 ret.decode!readId(); 3637 return ret; 3638 } 3639 3640 public override string toString() { 3641 return "ChangeDimension(dimension: " ~ std.conv.to!string(this.dimension) ~ ", position: " ~ std.conv.to!string(this.position) ~ ", unknown2: " ~ std.conv.to!string(this.unknown2) ~ ")"; 3642 } 3643 3644 } 3645 3646 class SetPlayerGameType : Buffer { 3647 3648 public enum ubyte ID = 62; 3649 3650 public enum bool CLIENTBOUND = true; 3651 public enum bool SERVERBOUND = true; 3652 3653 // gamemode 3654 public enum int SURVIVAL = 0; 3655 public enum int CREATIVE = 1; 3656 3657 public enum string[] FIELDS = ["gamemode"]; 3658 3659 public int gamemode; 3660 3661 public pure nothrow @safe @nogc this() {} 3662 3663 public pure nothrow @safe @nogc this(int gamemode) { 3664 this.gamemode = gamemode; 3665 } 3666 3667 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 3668 _buffer.length = 0; 3669 static if(writeId){ writeBigEndianUbyte(ID); } 3670 writeBytes(varint.encode(gamemode)); 3671 return _buffer; 3672 } 3673 3674 public pure nothrow @safe void decode(bool readId=true)() { 3675 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 3676 gamemode=varint.decode(_buffer, &_index); 3677 } 3678 3679 public static pure nothrow @safe SetPlayerGameType fromBuffer(bool readId=true)(ubyte[] buffer) { 3680 SetPlayerGameType ret = new SetPlayerGameType(); 3681 ret._buffer = buffer; 3682 ret.decode!readId(); 3683 return ret; 3684 } 3685 3686 public override string toString() { 3687 return "SetPlayerGameType(gamemode: " ~ std.conv.to!string(this.gamemode) ~ ")"; 3688 } 3689 3690 } 3691 3692 class PlayerList : Buffer { 3693 3694 public enum ubyte ID = 63; 3695 3696 public enum bool CLIENTBOUND = true; 3697 public enum bool SERVERBOUND = false; 3698 3699 public enum string[] FIELDS = ["action"]; 3700 3701 public ubyte action; 3702 3703 public pure nothrow @safe @nogc this() {} 3704 3705 public pure nothrow @safe @nogc this(ubyte action) { 3706 this.action = action; 3707 } 3708 3709 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 3710 _buffer.length = 0; 3711 static if(writeId){ writeBigEndianUbyte(ID); } 3712 writeBigEndianUbyte(action); 3713 return _buffer; 3714 } 3715 3716 public pure nothrow @safe void decode(bool readId=true)() { 3717 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 3718 action=readBigEndianUbyte(); 3719 } 3720 3721 public static pure nothrow @safe PlayerList fromBuffer(bool readId=true)(ubyte[] buffer) { 3722 PlayerList ret = new PlayerList(); 3723 ret._buffer = buffer; 3724 ret.decode!readId(); 3725 return ret; 3726 } 3727 3728 public override string toString() { 3729 return "PlayerList(action: " ~ std.conv.to!string(this.action) ~ ")"; 3730 } 3731 3732 alias _encode = encode; 3733 3734 enum string variantField = "action"; 3735 3736 alias Variants = TypeTuple!(Add, Remove); 3737 3738 public class Add { 3739 3740 public enum typeof(action) ACTION = 0; 3741 3742 public enum string[] FIELDS = ["players"]; 3743 3744 public sul.protocol.pocket102.types.PlayerList[] players; 3745 3746 public pure nothrow @safe @nogc this() {} 3747 3748 public pure nothrow @safe @nogc this(sul.protocol.pocket102.types.PlayerList[] players) { 3749 this.players = players; 3750 } 3751 3752 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 3753 action = 0; 3754 _encode!writeId(); 3755 writeBytes(varuint.encode(cast(uint)players.length)); foreach(cxevc;players){ cxevc.encode(bufferInstance); } 3756 return _buffer; 3757 } 3758 3759 public pure nothrow @safe void decode() { 3760 players.length=varuint.decode(_buffer, &_index); foreach(ref cxevc;players){ cxevc.decode(bufferInstance); } 3761 } 3762 3763 public override string toString() { 3764 return "PlayerList.Add(players: " ~ std.conv.to!string(this.players) ~ ")"; 3765 } 3766 3767 } 3768 3769 public class Remove { 3770 3771 public enum typeof(action) ACTION = 1; 3772 3773 public enum string[] FIELDS = ["players"]; 3774 3775 public UUID[] players; 3776 3777 public pure nothrow @safe @nogc this() {} 3778 3779 public pure nothrow @safe @nogc this(UUID[] players) { 3780 this.players = players; 3781 } 3782 3783 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 3784 action = 1; 3785 _encode!writeId(); 3786 writeBytes(varuint.encode(cast(uint)players.length)); foreach(cxevc;players){ writeBytes(cxevc.data); } 3787 return _buffer; 3788 } 3789 3790 public pure nothrow @safe void decode() { 3791 players.length=varuint.decode(_buffer, &_index); foreach(ref cxevc;players){ if(_buffer.length>=_index+16){ ubyte[16] yhdm=_buffer[_index.._index+16].dup; _index+=16; cxevc=UUID(yhdm); } } 3792 } 3793 3794 public override string toString() { 3795 return "PlayerList.Remove(players: " ~ std.conv.to!string(this.players) ~ ")"; 3796 } 3797 3798 } 3799 3800 } 3801 3802 class TelemetryEvent : Buffer { 3803 3804 public enum ubyte ID = 64; 3805 3806 public enum bool CLIENTBOUND = true; 3807 public enum bool SERVERBOUND = false; 3808 3809 public enum string[] FIELDS = ["entityId", "eventId"]; 3810 3811 public long entityId; 3812 public int eventId; 3813 3814 public pure nothrow @safe @nogc this() {} 3815 3816 public pure nothrow @safe @nogc this(long entityId, int eventId=int.init) { 3817 this.entityId = entityId; 3818 this.eventId = eventId; 3819 } 3820 3821 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 3822 _buffer.length = 0; 3823 static if(writeId){ writeBigEndianUbyte(ID); } 3824 writeBytes(varlong.encode(entityId)); 3825 writeBytes(varint.encode(eventId)); 3826 return _buffer; 3827 } 3828 3829 public pure nothrow @safe void decode(bool readId=true)() { 3830 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 3831 entityId=varlong.decode(_buffer, &_index); 3832 eventId=varint.decode(_buffer, &_index); 3833 } 3834 3835 public static pure nothrow @safe TelemetryEvent fromBuffer(bool readId=true)(ubyte[] buffer) { 3836 TelemetryEvent ret = new TelemetryEvent(); 3837 ret._buffer = buffer; 3838 ret.decode!readId(); 3839 return ret; 3840 } 3841 3842 public override string toString() { 3843 return "TelemetryEvent(entityId: " ~ std.conv.to!string(this.entityId) ~ ", eventId: " ~ std.conv.to!string(this.eventId) ~ ")"; 3844 } 3845 3846 } 3847 3848 class SpawnExperienceOrb : Buffer { 3849 3850 public enum ubyte ID = 65; 3851 3852 public enum bool CLIENTBOUND = true; 3853 public enum bool SERVERBOUND = false; 3854 3855 public enum string[] FIELDS = ["position", "count"]; 3856 3857 public Tuple!(float, "x", float, "y", float, "z") position; 3858 public int count; 3859 3860 public pure nothrow @safe @nogc this() {} 3861 3862 public pure nothrow @safe @nogc this(Tuple!(float, "x", float, "y", float, "z") position, int count=int.init) { 3863 this.position = position; 3864 this.count = count; 3865 } 3866 3867 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 3868 _buffer.length = 0; 3869 static if(writeId){ writeBigEndianUbyte(ID); } 3870 writeLittleEndianFloat(position.x); writeLittleEndianFloat(position.y); writeLittleEndianFloat(position.z); 3871 writeBytes(varint.encode(count)); 3872 return _buffer; 3873 } 3874 3875 public pure nothrow @safe void decode(bool readId=true)() { 3876 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 3877 position.x=readLittleEndianFloat(); position.y=readLittleEndianFloat(); position.z=readLittleEndianFloat(); 3878 count=varint.decode(_buffer, &_index); 3879 } 3880 3881 public static pure nothrow @safe SpawnExperienceOrb fromBuffer(bool readId=true)(ubyte[] buffer) { 3882 SpawnExperienceOrb ret = new SpawnExperienceOrb(); 3883 ret._buffer = buffer; 3884 ret.decode!readId(); 3885 return ret; 3886 } 3887 3888 public override string toString() { 3889 return "SpawnExperienceOrb(position: " ~ std.conv.to!string(this.position) ~ ", count: " ~ std.conv.to!string(this.count) ~ ")"; 3890 } 3891 3892 } 3893 3894 class ClientboundMapItemData : Buffer { 3895 3896 public enum ubyte ID = 66; 3897 3898 public enum bool CLIENTBOUND = true; 3899 public enum bool SERVERBOUND = false; 3900 3901 // update 3902 public enum uint TEXTURE = 2; 3903 public enum uint DECORATIONS = 4; 3904 public enum uint ENTITIES = 8; 3905 3906 public enum string[] FIELDS = ["mapId", "update", "scale", "size", "offset", "data", "decorations"]; 3907 3908 public long mapId; 3909 public uint update; 3910 public ubyte scale; 3911 public Tuple!(int, "x", int, "z") size; 3912 public Tuple!(int, "x", int, "z") offset; 3913 public ubyte[] data; 3914 public sul.protocol.pocket102.types.Decoration[] decorations; 3915 3916 public pure nothrow @safe @nogc this() {} 3917 3918 public pure nothrow @safe @nogc this(long mapId, uint update=uint.init, ubyte scale=ubyte.init, Tuple!(int, "x", int, "z") size=Tuple!(int, "x", int, "z").init, Tuple!(int, "x", int, "z") offset=Tuple!(int, "x", int, "z").init, ubyte[] data=(ubyte[]).init, sul.protocol.pocket102.types.Decoration[] decorations=(sul.protocol.pocket102.types.Decoration[]).init) { 3919 this.mapId = mapId; 3920 this.update = update; 3921 this.scale = scale; 3922 this.size = size; 3923 this.offset = offset; 3924 this.data = data; 3925 this.decorations = decorations; 3926 } 3927 3928 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 3929 _buffer.length = 0; 3930 static if(writeId){ writeBigEndianUbyte(ID); } 3931 writeBytes(varlong.encode(mapId)); 3932 writeBytes(varuint.encode(update)); 3933 if(update==2||update==4){ writeBigEndianUbyte(scale); } 3934 if(update==2){ writeBytes(varint.encode(size.x)); writeBytes(varint.encode(size.z)); } 3935 if(update==2){ writeBytes(varint.encode(offset.x)); writeBytes(varint.encode(offset.z)); } 3936 if(update==2){ writeBytes(data); } 3937 if(update==4){ writeBytes(varuint.encode(cast(uint)decorations.length)); foreach(zvbjdlbm;decorations){ zvbjdlbm.encode(bufferInstance); } } 3938 return _buffer; 3939 } 3940 3941 public pure nothrow @safe void decode(bool readId=true)() { 3942 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 3943 mapId=varlong.decode(_buffer, &_index); 3944 update=varuint.decode(_buffer, &_index); 3945 if(update==2||update==4){ scale=readBigEndianUbyte(); } 3946 if(update==2){ size.x=varint.decode(_buffer, &_index); size.z=varint.decode(_buffer, &_index); } 3947 if(update==2){ offset.x=varint.decode(_buffer, &_index); offset.z=varint.decode(_buffer, &_index); } 3948 if(update==2){ data=_buffer[_index..$].dup; _index=_buffer.length; } 3949 if(update==4){ decorations.length=varuint.decode(_buffer, &_index); foreach(ref zvbjdlbm;decorations){ zvbjdlbm.decode(bufferInstance); } } 3950 } 3951 3952 public static pure nothrow @safe ClientboundMapItemData fromBuffer(bool readId=true)(ubyte[] buffer) { 3953 ClientboundMapItemData ret = new ClientboundMapItemData(); 3954 ret._buffer = buffer; 3955 ret.decode!readId(); 3956 return ret; 3957 } 3958 3959 public override string toString() { 3960 return "ClientboundMapItemData(mapId: " ~ std.conv.to!string(this.mapId) ~ ", update: " ~ std.conv.to!string(this.update) ~ ", scale: " ~ std.conv.to!string(this.scale) ~ ", size: " ~ std.conv.to!string(this.size) ~ ", offset: " ~ std.conv.to!string(this.offset) ~ ", data: " ~ std.conv.to!string(this.data) ~ ", decorations: " ~ std.conv.to!string(this.decorations) ~ ")"; 3961 } 3962 3963 } 3964 3965 class MapInfoRequest : Buffer { 3966 3967 public enum ubyte ID = 67; 3968 3969 public enum bool CLIENTBOUND = false; 3970 public enum bool SERVERBOUND = true; 3971 3972 public enum string[] FIELDS = ["mapId"]; 3973 3974 public long mapId; 3975 3976 public pure nothrow @safe @nogc this() {} 3977 3978 public pure nothrow @safe @nogc this(long mapId) { 3979 this.mapId = mapId; 3980 } 3981 3982 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 3983 _buffer.length = 0; 3984 static if(writeId){ writeBigEndianUbyte(ID); } 3985 writeBytes(varlong.encode(mapId)); 3986 return _buffer; 3987 } 3988 3989 public pure nothrow @safe void decode(bool readId=true)() { 3990 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 3991 mapId=varlong.decode(_buffer, &_index); 3992 } 3993 3994 public static pure nothrow @safe MapInfoRequest fromBuffer(bool readId=true)(ubyte[] buffer) { 3995 MapInfoRequest ret = new MapInfoRequest(); 3996 ret._buffer = buffer; 3997 ret.decode!readId(); 3998 return ret; 3999 } 4000 4001 public override string toString() { 4002 return "MapInfoRequest(mapId: " ~ std.conv.to!string(this.mapId) ~ ")"; 4003 } 4004 4005 } 4006 4007 class RequestChunkRadius : Buffer { 4008 4009 public enum ubyte ID = 68; 4010 4011 public enum bool CLIENTBOUND = false; 4012 public enum bool SERVERBOUND = true; 4013 4014 public enum string[] FIELDS = ["radius"]; 4015 4016 public int radius; 4017 4018 public pure nothrow @safe @nogc this() {} 4019 4020 public pure nothrow @safe @nogc this(int radius) { 4021 this.radius = radius; 4022 } 4023 4024 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 4025 _buffer.length = 0; 4026 static if(writeId){ writeBigEndianUbyte(ID); } 4027 writeBytes(varint.encode(radius)); 4028 return _buffer; 4029 } 4030 4031 public pure nothrow @safe void decode(bool readId=true)() { 4032 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 4033 radius=varint.decode(_buffer, &_index); 4034 } 4035 4036 public static pure nothrow @safe RequestChunkRadius fromBuffer(bool readId=true)(ubyte[] buffer) { 4037 RequestChunkRadius ret = new RequestChunkRadius(); 4038 ret._buffer = buffer; 4039 ret.decode!readId(); 4040 return ret; 4041 } 4042 4043 public override string toString() { 4044 return "RequestChunkRadius(radius: " ~ std.conv.to!string(this.radius) ~ ")"; 4045 } 4046 4047 } 4048 4049 class ChunkRadiusUpdated : Buffer { 4050 4051 public enum ubyte ID = 69; 4052 4053 public enum bool CLIENTBOUND = true; 4054 public enum bool SERVERBOUND = false; 4055 4056 public enum string[] FIELDS = ["radius"]; 4057 4058 public int radius; 4059 4060 public pure nothrow @safe @nogc this() {} 4061 4062 public pure nothrow @safe @nogc this(int radius) { 4063 this.radius = radius; 4064 } 4065 4066 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 4067 _buffer.length = 0; 4068 static if(writeId){ writeBigEndianUbyte(ID); } 4069 writeBytes(varint.encode(radius)); 4070 return _buffer; 4071 } 4072 4073 public pure nothrow @safe void decode(bool readId=true)() { 4074 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 4075 radius=varint.decode(_buffer, &_index); 4076 } 4077 4078 public static pure nothrow @safe ChunkRadiusUpdated fromBuffer(bool readId=true)(ubyte[] buffer) { 4079 ChunkRadiusUpdated ret = new ChunkRadiusUpdated(); 4080 ret._buffer = buffer; 4081 ret.decode!readId(); 4082 return ret; 4083 } 4084 4085 public override string toString() { 4086 return "ChunkRadiusUpdated(radius: " ~ std.conv.to!string(this.radius) ~ ")"; 4087 } 4088 4089 } 4090 4091 class ItemFrameDropItem : Buffer { 4092 4093 public enum ubyte ID = 70; 4094 4095 public enum bool CLIENTBOUND = true; 4096 public enum bool SERVERBOUND = false; 4097 4098 public enum string[] FIELDS = ["position", "item"]; 4099 4100 public sul.protocol.pocket102.types.BlockPosition position; 4101 public sul.protocol.pocket102.types.Slot item; 4102 4103 public pure nothrow @safe @nogc this() {} 4104 4105 public pure nothrow @safe @nogc this(sul.protocol.pocket102.types.BlockPosition position, sul.protocol.pocket102.types.Slot item=sul.protocol.pocket102.types.Slot.init) { 4106 this.position = position; 4107 this.item = item; 4108 } 4109 4110 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 4111 _buffer.length = 0; 4112 static if(writeId){ writeBigEndianUbyte(ID); } 4113 position.encode(bufferInstance); 4114 item.encode(bufferInstance); 4115 return _buffer; 4116 } 4117 4118 public pure nothrow @safe void decode(bool readId=true)() { 4119 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 4120 position.decode(bufferInstance); 4121 item.decode(bufferInstance); 4122 } 4123 4124 public static pure nothrow @safe ItemFrameDropItem fromBuffer(bool readId=true)(ubyte[] buffer) { 4125 ItemFrameDropItem ret = new ItemFrameDropItem(); 4126 ret._buffer = buffer; 4127 ret.decode!readId(); 4128 return ret; 4129 } 4130 4131 public override string toString() { 4132 return "ItemFrameDropItem(position: " ~ std.conv.to!string(this.position) ~ ", item: " ~ std.conv.to!string(this.item) ~ ")"; 4133 } 4134 4135 } 4136 4137 class ReplaceSelectedItem : Buffer { 4138 4139 public enum ubyte ID = 71; 4140 4141 public enum bool CLIENTBOUND = false; 4142 public enum bool SERVERBOUND = true; 4143 4144 public enum string[] FIELDS = ["item"]; 4145 4146 public sul.protocol.pocket102.types.Slot item; 4147 4148 public pure nothrow @safe @nogc this() {} 4149 4150 public pure nothrow @safe @nogc this(sul.protocol.pocket102.types.Slot item) { 4151 this.item = item; 4152 } 4153 4154 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 4155 _buffer.length = 0; 4156 static if(writeId){ writeBigEndianUbyte(ID); } 4157 item.encode(bufferInstance); 4158 return _buffer; 4159 } 4160 4161 public pure nothrow @safe void decode(bool readId=true)() { 4162 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 4163 item.decode(bufferInstance); 4164 } 4165 4166 public static pure nothrow @safe ReplaceSelectedItem fromBuffer(bool readId=true)(ubyte[] buffer) { 4167 ReplaceSelectedItem ret = new ReplaceSelectedItem(); 4168 ret._buffer = buffer; 4169 ret.decode!readId(); 4170 return ret; 4171 } 4172 4173 public override string toString() { 4174 return "ReplaceSelectedItem(item: " ~ std.conv.to!string(this.item) ~ ")"; 4175 } 4176 4177 } 4178 4179 class GameRulesChanged : Buffer { 4180 4181 public enum ubyte ID = 72; 4182 4183 public enum bool CLIENTBOUND = true; 4184 public enum bool SERVERBOUND = false; 4185 4186 public enum string[] FIELDS = ["rules"]; 4187 4188 public sul.protocol.pocket102.types.Rule[] rules; 4189 4190 public pure nothrow @safe @nogc this() {} 4191 4192 public pure nothrow @safe @nogc this(sul.protocol.pocket102.types.Rule[] rules) { 4193 this.rules = rules; 4194 } 4195 4196 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 4197 _buffer.length = 0; 4198 static if(writeId){ writeBigEndianUbyte(ID); } 4199 writeBigEndianUint(cast(uint)rules.length); foreach(cvzm;rules){ cvzm.encode(bufferInstance); } 4200 return _buffer; 4201 } 4202 4203 public pure nothrow @safe void decode(bool readId=true)() { 4204 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 4205 rules.length=readBigEndianUint(); foreach(ref cvzm;rules){ cvzm.decode(bufferInstance); } 4206 } 4207 4208 public static pure nothrow @safe GameRulesChanged fromBuffer(bool readId=true)(ubyte[] buffer) { 4209 GameRulesChanged ret = new GameRulesChanged(); 4210 ret._buffer = buffer; 4211 ret.decode!readId(); 4212 return ret; 4213 } 4214 4215 public override string toString() { 4216 return "GameRulesChanged(rules: " ~ std.conv.to!string(this.rules) ~ ")"; 4217 } 4218 4219 } 4220 4221 class Camera : Buffer { 4222 4223 public enum ubyte ID = 73; 4224 4225 public enum bool CLIENTBOUND = true; 4226 public enum bool SERVERBOUND = false; 4227 4228 public enum string[] FIELDS = ["unknown0", "unknown1"]; 4229 4230 public long unknown0; 4231 public long unknown1; 4232 4233 public pure nothrow @safe @nogc this() {} 4234 4235 public pure nothrow @safe @nogc this(long unknown0, long unknown1=long.init) { 4236 this.unknown0 = unknown0; 4237 this.unknown1 = unknown1; 4238 } 4239 4240 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 4241 _buffer.length = 0; 4242 static if(writeId){ writeBigEndianUbyte(ID); } 4243 writeBytes(varlong.encode(unknown0)); 4244 writeBytes(varlong.encode(unknown1)); 4245 return _buffer; 4246 } 4247 4248 public pure nothrow @safe void decode(bool readId=true)() { 4249 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 4250 unknown0=varlong.decode(_buffer, &_index); 4251 unknown1=varlong.decode(_buffer, &_index); 4252 } 4253 4254 public static pure nothrow @safe Camera fromBuffer(bool readId=true)(ubyte[] buffer) { 4255 Camera ret = new Camera(); 4256 ret._buffer = buffer; 4257 ret.decode!readId(); 4258 return ret; 4259 } 4260 4261 public override string toString() { 4262 return "Camera(unknown0: " ~ std.conv.to!string(this.unknown0) ~ ", unknown1: " ~ std.conv.to!string(this.unknown1) ~ ")"; 4263 } 4264 4265 } 4266 4267 class AddItem : Buffer { 4268 4269 public enum ubyte ID = 74; 4270 4271 public enum bool CLIENTBOUND = true; 4272 public enum bool SERVERBOUND = false; 4273 4274 public enum string[] FIELDS = ["item"]; 4275 4276 public sul.protocol.pocket102.types.Slot item; 4277 4278 public pure nothrow @safe @nogc this() {} 4279 4280 public pure nothrow @safe @nogc this(sul.protocol.pocket102.types.Slot item) { 4281 this.item = item; 4282 } 4283 4284 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 4285 _buffer.length = 0; 4286 static if(writeId){ writeBigEndianUbyte(ID); } 4287 item.encode(bufferInstance); 4288 return _buffer; 4289 } 4290 4291 public pure nothrow @safe void decode(bool readId=true)() { 4292 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 4293 item.decode(bufferInstance); 4294 } 4295 4296 public static pure nothrow @safe AddItem fromBuffer(bool readId=true)(ubyte[] buffer) { 4297 AddItem ret = new AddItem(); 4298 ret._buffer = buffer; 4299 ret.decode!readId(); 4300 return ret; 4301 } 4302 4303 public override string toString() { 4304 return "AddItem(item: " ~ std.conv.to!string(this.item) ~ ")"; 4305 } 4306 4307 } 4308 4309 class BossEvent : Buffer { 4310 4311 public enum ubyte ID = 75; 4312 4313 public enum bool CLIENTBOUND = true; 4314 public enum bool SERVERBOUND = false; 4315 4316 // event id 4317 public enum uint ADD = 0; 4318 public enum uint UPDATE = 1; 4319 public enum uint REMOVE = 2; 4320 4321 public enum string[] FIELDS = ["entityId", "eventId"]; 4322 4323 public long entityId; 4324 public uint eventId; 4325 4326 public pure nothrow @safe @nogc this() {} 4327 4328 public pure nothrow @safe @nogc this(long entityId, uint eventId=uint.init) { 4329 this.entityId = entityId; 4330 this.eventId = eventId; 4331 } 4332 4333 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 4334 _buffer.length = 0; 4335 static if(writeId){ writeBigEndianUbyte(ID); } 4336 writeBytes(varlong.encode(entityId)); 4337 writeBytes(varuint.encode(eventId)); 4338 return _buffer; 4339 } 4340 4341 public pure nothrow @safe void decode(bool readId=true)() { 4342 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 4343 entityId=varlong.decode(_buffer, &_index); 4344 eventId=varuint.decode(_buffer, &_index); 4345 } 4346 4347 public static pure nothrow @safe BossEvent fromBuffer(bool readId=true)(ubyte[] buffer) { 4348 BossEvent ret = new BossEvent(); 4349 ret._buffer = buffer; 4350 ret.decode!readId(); 4351 return ret; 4352 } 4353 4354 public override string toString() { 4355 return "BossEvent(entityId: " ~ std.conv.to!string(this.entityId) ~ ", eventId: " ~ std.conv.to!string(this.eventId) ~ ")"; 4356 } 4357 4358 } 4359 4360 class ShowCredits : Buffer { 4361 4362 public enum ubyte ID = 76; 4363 4364 public enum bool CLIENTBOUND = true; 4365 public enum bool SERVERBOUND = true; 4366 4367 // status 4368 public enum int START = 0; 4369 public enum int END = 1; 4370 4371 public enum string[] FIELDS = ["entityId", "status"]; 4372 4373 public long entityId; 4374 public int status; 4375 4376 public pure nothrow @safe @nogc this() {} 4377 4378 public pure nothrow @safe @nogc this(long entityId, int status=int.init) { 4379 this.entityId = entityId; 4380 this.status = status; 4381 } 4382 4383 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 4384 _buffer.length = 0; 4385 static if(writeId){ writeBigEndianUbyte(ID); } 4386 writeBytes(varlong.encode(entityId)); 4387 writeBytes(varint.encode(status)); 4388 return _buffer; 4389 } 4390 4391 public pure nothrow @safe void decode(bool readId=true)() { 4392 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 4393 entityId=varlong.decode(_buffer, &_index); 4394 status=varint.decode(_buffer, &_index); 4395 } 4396 4397 public static pure nothrow @safe ShowCredits fromBuffer(bool readId=true)(ubyte[] buffer) { 4398 ShowCredits ret = new ShowCredits(); 4399 ret._buffer = buffer; 4400 ret.decode!readId(); 4401 return ret; 4402 } 4403 4404 public override string toString() { 4405 return "ShowCredits(entityId: " ~ std.conv.to!string(this.entityId) ~ ", status: " ~ std.conv.to!string(this.status) ~ ")"; 4406 } 4407 4408 } 4409 4410 class AvailableCommands : Buffer { 4411 4412 public enum ubyte ID = 77; 4413 4414 public enum bool CLIENTBOUND = true; 4415 public enum bool SERVERBOUND = false; 4416 4417 public enum string[] FIELDS = ["commands", "unknown1"]; 4418 4419 public string commands; 4420 public string unknown1; 4421 4422 public pure nothrow @safe @nogc this() {} 4423 4424 public pure nothrow @safe @nogc this(string commands, string unknown1=string.init) { 4425 this.commands = commands; 4426 this.unknown1 = unknown1; 4427 } 4428 4429 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 4430 _buffer.length = 0; 4431 static if(writeId){ writeBigEndianUbyte(ID); } 4432 writeBytes(varuint.encode(cast(uint)commands.length)); writeString(commands); 4433 writeBytes(varuint.encode(cast(uint)unknown1.length)); writeString(unknown1); 4434 return _buffer; 4435 } 4436 4437 public pure nothrow @safe void decode(bool readId=true)() { 4438 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 4439 uint y9bfzm=varuint.decode(_buffer, &_index); commands=readString(y9bfzm); 4440 uint d5b9be=varuint.decode(_buffer, &_index); unknown1=readString(d5b9be); 4441 } 4442 4443 public static pure nothrow @safe AvailableCommands fromBuffer(bool readId=true)(ubyte[] buffer) { 4444 AvailableCommands ret = new AvailableCommands(); 4445 ret._buffer = buffer; 4446 ret.decode!readId(); 4447 return ret; 4448 } 4449 4450 public override string toString() { 4451 return "AvailableCommands(commands: " ~ std.conv.to!string(this.commands) ~ ", unknown1: " ~ std.conv.to!string(this.unknown1) ~ ")"; 4452 } 4453 4454 } 4455 4456 class CommandStep : Buffer { 4457 4458 public enum ubyte ID = 78; 4459 4460 public enum bool CLIENTBOUND = false; 4461 public enum bool SERVERBOUND = true; 4462 4463 public enum string[] FIELDS = ["command", "overload", "unknown2", "currentStep", "done", "clientId", "input", "output"]; 4464 4465 public string command; 4466 public string overload; 4467 public uint unknown2; 4468 public uint currentStep; 4469 public bool done; 4470 public ulong clientId; 4471 public string input; 4472 public string output; 4473 4474 public pure nothrow @safe @nogc this() {} 4475 4476 public pure nothrow @safe @nogc this(string command, string overload=string.init, uint unknown2=uint.init, uint currentStep=uint.init, bool done=bool.init, ulong clientId=ulong.init, string input=string.init, string output=string.init) { 4477 this.command = command; 4478 this.overload = overload; 4479 this.unknown2 = unknown2; 4480 this.currentStep = currentStep; 4481 this.done = done; 4482 this.clientId = clientId; 4483 this.input = input; 4484 this.output = output; 4485 } 4486 4487 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 4488 _buffer.length = 0; 4489 static if(writeId){ writeBigEndianUbyte(ID); } 4490 writeBytes(varuint.encode(cast(uint)command.length)); writeString(command); 4491 writeBytes(varuint.encode(cast(uint)overload.length)); writeString(overload); 4492 writeBytes(varuint.encode(unknown2)); 4493 writeBytes(varuint.encode(currentStep)); 4494 writeBigEndianBool(done); 4495 writeBytes(varulong.encode(clientId)); 4496 writeBytes(varuint.encode(cast(uint)input.length)); writeString(input); 4497 writeBytes(varuint.encode(cast(uint)output.length)); writeString(output); 4498 return _buffer; 4499 } 4500 4501 public pure nothrow @safe void decode(bool readId=true)() { 4502 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 4503 uint y9bfz=varuint.decode(_buffer, &_index); command=readString(y9bfz); 4504 uint bzcxyq=varuint.decode(_buffer, &_index); overload=readString(bzcxyq); 4505 unknown2=varuint.decode(_buffer, &_index); 4506 currentStep=varuint.decode(_buffer, &_index); 4507 done=readBigEndianBool(); 4508 clientId=varulong.decode(_buffer, &_index); 4509 uint a5dq=varuint.decode(_buffer, &_index); input=readString(a5dq); 4510 uint bvcv=varuint.decode(_buffer, &_index); output=readString(bvcv); 4511 } 4512 4513 public static pure nothrow @safe CommandStep fromBuffer(bool readId=true)(ubyte[] buffer) { 4514 CommandStep ret = new CommandStep(); 4515 ret._buffer = buffer; 4516 ret.decode!readId(); 4517 return ret; 4518 } 4519 4520 public override string toString() { 4521 return "CommandStep(command: " ~ std.conv.to!string(this.command) ~ ", overload: " ~ std.conv.to!string(this.overload) ~ ", unknown2: " ~ std.conv.to!string(this.unknown2) ~ ", currentStep: " ~ std.conv.to!string(this.currentStep) ~ ", done: " ~ std.conv.to!string(this.done) ~ ", clientId: " ~ std.conv.to!string(this.clientId) ~ ", input: " ~ std.conv.to!string(this.input) ~ ", output: " ~ std.conv.to!string(this.output) ~ ")"; 4522 } 4523 4524 } 4525 4526 class UpdateTrade : Buffer { 4527 4528 public enum ubyte ID = 79; 4529 4530 public enum bool CLIENTBOUND = true; 4531 public enum bool SERVERBOUND = false; 4532 4533 public enum string[] FIELDS = ["unknown0", "unknown1", "unknown2", "unknown3", "unknown4", "trader", "player", "unknown7", "offers"]; 4534 4535 public ubyte unknown0; 4536 public ubyte unknown1; 4537 public int unknown2; 4538 public int unknown3; 4539 public bool unknown4; 4540 public long trader; 4541 public long player; 4542 public string unknown7; 4543 public ubyte[] offers; 4544 4545 public pure nothrow @safe @nogc this() {} 4546 4547 public pure nothrow @safe @nogc this(ubyte unknown0, ubyte unknown1=ubyte.init, int unknown2=int.init, int unknown3=int.init, bool unknown4=bool.init, long trader=long.init, long player=long.init, string unknown7=string.init, ubyte[] offers=(ubyte[]).init) { 4548 this.unknown0 = unknown0; 4549 this.unknown1 = unknown1; 4550 this.unknown2 = unknown2; 4551 this.unknown3 = unknown3; 4552 this.unknown4 = unknown4; 4553 this.trader = trader; 4554 this.player = player; 4555 this.unknown7 = unknown7; 4556 this.offers = offers; 4557 } 4558 4559 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 4560 _buffer.length = 0; 4561 static if(writeId){ writeBigEndianUbyte(ID); } 4562 writeBigEndianUbyte(unknown0); 4563 writeBigEndianUbyte(unknown1); 4564 writeBytes(varint.encode(unknown2)); 4565 writeBytes(varint.encode(unknown3)); 4566 writeBigEndianBool(unknown4); 4567 writeBytes(varlong.encode(trader)); 4568 writeBytes(varlong.encode(player)); 4569 writeBytes(varuint.encode(cast(uint)unknown7.length)); writeString(unknown7); 4570 writeBytes(offers); 4571 return _buffer; 4572 } 4573 4574 public pure nothrow @safe void decode(bool readId=true)() { 4575 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 4576 unknown0=readBigEndianUbyte(); 4577 unknown1=readBigEndianUbyte(); 4578 unknown2=varint.decode(_buffer, &_index); 4579 unknown3=varint.decode(_buffer, &_index); 4580 unknown4=readBigEndianBool(); 4581 trader=varlong.decode(_buffer, &_index); 4582 player=varlong.decode(_buffer, &_index); 4583 uint d5b9bc=varuint.decode(_buffer, &_index); unknown7=readString(d5b9bc); 4584 offers=_buffer[_index..$].dup; _index=_buffer.length; 4585 } 4586 4587 public static pure nothrow @safe UpdateTrade fromBuffer(bool readId=true)(ubyte[] buffer) { 4588 UpdateTrade ret = new UpdateTrade(); 4589 ret._buffer = buffer; 4590 ret.decode!readId(); 4591 return ret; 4592 } 4593 4594 public override string toString() { 4595 return "UpdateTrade(unknown0: " ~ std.conv.to!string(this.unknown0) ~ ", unknown1: " ~ std.conv.to!string(this.unknown1) ~ ", unknown2: " ~ std.conv.to!string(this.unknown2) ~ ", unknown3: " ~ std.conv.to!string(this.unknown3) ~ ", unknown4: " ~ std.conv.to!string(this.unknown4) ~ ", trader: " ~ std.conv.to!string(this.trader) ~ ", player: " ~ std.conv.to!string(this.player) ~ ", unknown7: " ~ std.conv.to!string(this.unknown7) ~ ", offers: " ~ std.conv.to!string(this.offers) ~ ")"; 4596 } 4597 4598 } 4599 4600 class ResourcePackDataInfo : Buffer { 4601 4602 public enum ubyte ID = 80; 4603 4604 public enum bool CLIENTBOUND = true; 4605 public enum bool SERVERBOUND = false; 4606 4607 public enum string[] FIELDS = ["id", "maxChunkSize", "chunkCount", "compressedPackSize", "sha256"]; 4608 4609 public string id; 4610 public uint maxChunkSize; 4611 public uint chunkCount; 4612 public ulong compressedPackSize; 4613 public string sha256; 4614 4615 public pure nothrow @safe @nogc this() {} 4616 4617 public pure nothrow @safe @nogc this(string id, uint maxChunkSize=uint.init, uint chunkCount=uint.init, ulong compressedPackSize=ulong.init, string sha256=string.init) { 4618 this.id = id; 4619 this.maxChunkSize = maxChunkSize; 4620 this.chunkCount = chunkCount; 4621 this.compressedPackSize = compressedPackSize; 4622 this.sha256 = sha256; 4623 } 4624 4625 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 4626 _buffer.length = 0; 4627 static if(writeId){ writeBigEndianUbyte(ID); } 4628 writeBytes(varuint.encode(cast(uint)id.length)); writeString(id); 4629 writeLittleEndianUint(maxChunkSize); 4630 writeLittleEndianUint(chunkCount); 4631 writeLittleEndianUlong(compressedPackSize); 4632 writeBytes(varuint.encode(cast(uint)sha256.length)); writeString(sha256); 4633 return _buffer; 4634 } 4635 4636 public pure nothrow @safe void decode(bool readId=true)() { 4637 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 4638 uint aq=varuint.decode(_buffer, &_index); id=readString(aq); 4639 maxChunkSize=readLittleEndianUint(); 4640 chunkCount=readLittleEndianUint(); 4641 compressedPackSize=readLittleEndianUlong(); 4642 uint chmu=varuint.decode(_buffer, &_index); sha256=readString(chmu); 4643 } 4644 4645 public static pure nothrow @safe ResourcePackDataInfo fromBuffer(bool readId=true)(ubyte[] buffer) { 4646 ResourcePackDataInfo ret = new ResourcePackDataInfo(); 4647 ret._buffer = buffer; 4648 ret.decode!readId(); 4649 return ret; 4650 } 4651 4652 public override string toString() { 4653 return "ResourcePackDataInfo(id: " ~ std.conv.to!string(this.id) ~ ", maxChunkSize: " ~ std.conv.to!string(this.maxChunkSize) ~ ", chunkCount: " ~ std.conv.to!string(this.chunkCount) ~ ", compressedPackSize: " ~ std.conv.to!string(this.compressedPackSize) ~ ", sha256: " ~ std.conv.to!string(this.sha256) ~ ")"; 4654 } 4655 4656 } 4657 4658 class ResourcePackChunkData : Buffer { 4659 4660 public enum ubyte ID = 81; 4661 4662 public enum bool CLIENTBOUND = true; 4663 public enum bool SERVERBOUND = false; 4664 4665 public enum string[] FIELDS = ["id", "chunkIndex", "progress", "data"]; 4666 4667 public string id; 4668 public uint chunkIndex; 4669 public ulong progress; 4670 public ubyte[] data; 4671 4672 public pure nothrow @safe @nogc this() {} 4673 4674 public pure nothrow @safe @nogc this(string id, uint chunkIndex=uint.init, ulong progress=ulong.init, ubyte[] data=(ubyte[]).init) { 4675 this.id = id; 4676 this.chunkIndex = chunkIndex; 4677 this.progress = progress; 4678 this.data = data; 4679 } 4680 4681 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 4682 _buffer.length = 0; 4683 static if(writeId){ writeBigEndianUbyte(ID); } 4684 writeBytes(varuint.encode(cast(uint)id.length)); writeString(id); 4685 writeLittleEndianUint(chunkIndex); 4686 writeLittleEndianUlong(progress); 4687 writeBytes(varuint.encode(cast(uint)data.length)); writeBytes(data); 4688 return _buffer; 4689 } 4690 4691 public pure nothrow @safe void decode(bool readId=true)() { 4692 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 4693 uint aq=varuint.decode(_buffer, &_index); id=readString(aq); 4694 chunkIndex=readLittleEndianUint(); 4695 progress=readLittleEndianUlong(); 4696 data.length=varuint.decode(_buffer, &_index); if(_buffer.length>=_index+data.length){ data=_buffer[_index.._index+data.length].dup; _index+=data.length; } 4697 } 4698 4699 public static pure nothrow @safe ResourcePackChunkData fromBuffer(bool readId=true)(ubyte[] buffer) { 4700 ResourcePackChunkData ret = new ResourcePackChunkData(); 4701 ret._buffer = buffer; 4702 ret.decode!readId(); 4703 return ret; 4704 } 4705 4706 public override string toString() { 4707 return "ResourcePackChunkData(id: " ~ std.conv.to!string(this.id) ~ ", chunkIndex: " ~ std.conv.to!string(this.chunkIndex) ~ ", progress: " ~ std.conv.to!string(this.progress) ~ ", data: " ~ std.conv.to!string(this.data) ~ ")"; 4708 } 4709 4710 } 4711 4712 class ResourcePackChunkRequest : Buffer { 4713 4714 public enum ubyte ID = 82; 4715 4716 public enum bool CLIENTBOUND = false; 4717 public enum bool SERVERBOUND = true; 4718 4719 public enum string[] FIELDS = ["id", "chunkIndex"]; 4720 4721 public string id; 4722 public uint chunkIndex; 4723 4724 public pure nothrow @safe @nogc this() {} 4725 4726 public pure nothrow @safe @nogc this(string id, uint chunkIndex=uint.init) { 4727 this.id = id; 4728 this.chunkIndex = chunkIndex; 4729 } 4730 4731 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 4732 _buffer.length = 0; 4733 static if(writeId){ writeBigEndianUbyte(ID); } 4734 writeBytes(varuint.encode(cast(uint)id.length)); writeString(id); 4735 writeLittleEndianUint(chunkIndex); 4736 return _buffer; 4737 } 4738 4739 public pure nothrow @safe void decode(bool readId=true)() { 4740 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 4741 uint aq=varuint.decode(_buffer, &_index); id=readString(aq); 4742 chunkIndex=readLittleEndianUint(); 4743 } 4744 4745 public static pure nothrow @safe ResourcePackChunkRequest fromBuffer(bool readId=true)(ubyte[] buffer) { 4746 ResourcePackChunkRequest ret = new ResourcePackChunkRequest(); 4747 ret._buffer = buffer; 4748 ret.decode!readId(); 4749 return ret; 4750 } 4751 4752 public override string toString() { 4753 return "ResourcePackChunkRequest(id: " ~ std.conv.to!string(this.id) ~ ", chunkIndex: " ~ std.conv.to!string(this.chunkIndex) ~ ")"; 4754 } 4755 4756 } 4757 4758 class Transfer : Buffer { 4759 4760 public enum ubyte ID = 83; 4761 4762 public enum bool CLIENTBOUND = true; 4763 public enum bool SERVERBOUND = false; 4764 4765 public enum string[] FIELDS = ["ip", "port"]; 4766 4767 public string ip; 4768 public ushort port = 19132; 4769 4770 public pure nothrow @safe @nogc this() {} 4771 4772 public pure nothrow @safe @nogc this(string ip, ushort port=19132) { 4773 this.ip = ip; 4774 this.port = port; 4775 } 4776 4777 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 4778 _buffer.length = 0; 4779 static if(writeId){ writeBigEndianUbyte(ID); } 4780 writeBytes(varuint.encode(cast(uint)ip.length)); writeString(ip); 4781 writeLittleEndianUshort(port); 4782 return _buffer; 4783 } 4784 4785 public pure nothrow @safe void decode(bool readId=true)() { 4786 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 4787 uint aa=varuint.decode(_buffer, &_index); ip=readString(aa); 4788 port=readLittleEndianUshort(); 4789 } 4790 4791 public static pure nothrow @safe Transfer fromBuffer(bool readId=true)(ubyte[] buffer) { 4792 Transfer ret = new Transfer(); 4793 ret._buffer = buffer; 4794 ret.decode!readId(); 4795 return ret; 4796 } 4797 4798 public override string toString() { 4799 return "Transfer(ip: " ~ std.conv.to!string(this.ip) ~ ", port: " ~ std.conv.to!string(this.port) ~ ")"; 4800 } 4801 4802 } 4803