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/pocket113.xml 8 */ 9 /** 10 * Packets related to the gameplay. Network-related packets (encapsulation, acks, nacks) 11 * are managed by RakNet and every packet in this section is encapsualted in an Encapsualted 12 * packet. 13 */ 14 module sul.protocol.pocket113.play; 15 16 import std.bitmanip : write, peek; 17 static import std.conv; 18 import std.system : Endian; 19 import std.typetuple : TypeTuple; 20 import std.typecons : Tuple; 21 import std.uuid : UUID; 22 23 import sul.utils.buffer; 24 import sul.utils.var; 25 26 static import sul.protocol.pocket113.types; 27 28 static if(__traits(compiles, { import sul.metadata.pocket113; })) import sul.metadata.pocket113; 29 30 alias Packets = TypeTuple!(Login, PlayStatus, ServerToClientHandshake, ClientToServerHandshake, Disconnect, 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, BlockPickRequest, UseItem, PlayerAction, EntityFall, 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, SimpleEvent, TelemetryEvent, SpawnExperienceOrb, ClientboundMapItemData, MapInfoRequest, RequestChunkRadius, ChunkRadiusUpdated, ItemFrameDropItem, ReplaceItemInSlot, GameRulesChanged, Camera, AddItem, BossEvent, ShowCredits, AvailableCommands, CommandStep, CommandBlockUpdate, UpdateTrade, UpdateEquip, ResourcePackDataInfo, ResourcePackChunkData, ResourcePackChunkRequest, Transfer, PlaySound, StopSound, SetTitle, AddBehaviorTree, StructureBlockUpdate, ShowStoreOffer, PurchaseReceipt); 31 32 /** 33 * First MCPE packet sent after the establishment of the connection through raknet. 34 * It contains informations about the player. 35 */ 36 class Login : Buffer { 37 38 public enum ubyte ID = 1; 39 40 public enum bool CLIENTBOUND = false; 41 public enum bool SERVERBOUND = true; 42 43 // version 44 public enum ubyte VANILLA = 0; 45 public enum ubyte EDUCATION = 1; 46 47 public enum string[] FIELDS = ["protocol", "vers", "body_"]; 48 49 /** 50 * Version of the protocol used by the player. 51 */ 52 public uint protocol = 113; 53 54 /** 55 * Edition that the player is using to join the server. The different editions may 56 * have different features and servers may block the access from unaccepted editions 57 * of the game. 58 */ 59 public ubyte vers; 60 61 /** 62 * Payload that contains 2 JWTs (with each length indicated by an unsigned little-endian 63 * 32-bits integer) with more informations about the player and its account. 64 */ 65 public sul.protocol.pocket113.types.LoginBody body_; 66 67 public pure nothrow @safe @nogc this() {} 68 69 public pure nothrow @safe @nogc this(uint protocol, ubyte vers=ubyte.init, sul.protocol.pocket113.types.LoginBody body_=sul.protocol.pocket113.types.LoginBody.init) { 70 this.protocol = protocol; 71 this.vers = vers; 72 this.body_ = body_; 73 } 74 75 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 76 _buffer.length = 0; 77 static if(writeId){ writeBigEndianUbyte(ID); } 78 writeBigEndianUint(protocol); 79 writeBigEndianUbyte(vers); 80 body_.encode(bufferInstance); 81 return _buffer; 82 } 83 84 public pure nothrow @safe void decode(bool readId=true)() { 85 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 86 protocol=readBigEndianUint(); 87 vers=readBigEndianUbyte(); 88 body_.decode(bufferInstance); 89 } 90 91 public static pure nothrow @safe Login fromBuffer(bool readId=true)(ubyte[] buffer) { 92 Login ret = new Login(); 93 ret._buffer = buffer; 94 ret.decode!readId(); 95 return ret; 96 } 97 98 public override string toString() { 99 return "Login(protocol: " ~ std.conv.to!string(this.protocol) ~ ", vers: " ~ std.conv.to!string(this.vers) ~ ", body_: " ~ std.conv.to!string(this.body_) ~ ")"; 100 } 101 102 } 103 104 /** 105 * Packet sent as response to Login to indicate whether the connection has been accepted 106 * and when the player is ready to spawn in the world. 107 */ 108 class PlayStatus : Buffer { 109 110 public enum ubyte ID = 2; 111 112 public enum bool CLIENTBOUND = true; 113 public enum bool SERVERBOUND = false; 114 115 // status 116 public enum uint OK = 0; 117 public enum uint OUTDATED_CLIENT = 1; 118 public enum uint OUTDATED_SERVER = 2; 119 public enum uint SPAWNED = 3; 120 public enum uint INVALID_TENANT = 4; 121 public enum uint EDITION_MISMATCH_EDU_TO_VANILLA = 5; 122 public enum uint EDITION_MISMATCH_VANILLA_TO_EDU = 6; 123 124 public enum string[] FIELDS = ["status"]; 125 126 public uint status; 127 128 public pure nothrow @safe @nogc this() {} 129 130 public pure nothrow @safe @nogc this(uint status) { 131 this.status = status; 132 } 133 134 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 135 _buffer.length = 0; 136 static if(writeId){ writeBigEndianUbyte(ID); } 137 writeBigEndianUint(status); 138 return _buffer; 139 } 140 141 public pure nothrow @safe void decode(bool readId=true)() { 142 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 143 status=readBigEndianUint(); 144 } 145 146 public static pure nothrow @safe PlayStatus fromBuffer(bool readId=true)(ubyte[] buffer) { 147 PlayStatus ret = new PlayStatus(); 148 ret._buffer = buffer; 149 ret.decode!readId(); 150 return ret; 151 } 152 153 public override string toString() { 154 return "PlayStatus(status: " ~ std.conv.to!string(this.status) ~ ")"; 155 } 156 157 } 158 159 class ServerToClientHandshake : Buffer { 160 161 public enum ubyte ID = 3; 162 163 public enum bool CLIENTBOUND = true; 164 public enum bool SERVERBOUND = false; 165 166 public enum string[] FIELDS = ["serverPublicKey", "token"]; 167 168 public string serverPublicKey; 169 public ubyte[] token; 170 171 public pure nothrow @safe @nogc this() {} 172 173 public pure nothrow @safe @nogc this(string serverPublicKey, ubyte[] token=(ubyte[]).init) { 174 this.serverPublicKey = serverPublicKey; 175 this.token = token; 176 } 177 178 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 179 _buffer.length = 0; 180 static if(writeId){ writeBigEndianUbyte(ID); } 181 writeBytes(varuint.encode(cast(uint)serverPublicKey.length)); writeString(serverPublicKey); 182 writeBytes(varuint.encode(cast(uint)token.length)); writeBytes(token); 183 return _buffer; 184 } 185 186 public pure nothrow @safe void decode(bool readId=true)() { 187 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 188 uint cvdvuvbl=varuint.decode(_buffer, &_index); serverPublicKey=readString(cvdvuvbl); 189 token.length=varuint.decode(_buffer, &_index); if(_buffer.length>=_index+token.length){ token=_buffer[_index.._index+token.length].dup; _index+=token.length; } 190 } 191 192 public static pure nothrow @safe ServerToClientHandshake fromBuffer(bool readId=true)(ubyte[] buffer) { 193 ServerToClientHandshake ret = new ServerToClientHandshake(); 194 ret._buffer = buffer; 195 ret.decode!readId(); 196 return ret; 197 } 198 199 public override string toString() { 200 return "ServerToClientHandshake(serverPublicKey: " ~ std.conv.to!string(this.serverPublicKey) ~ ", token: " ~ std.conv.to!string(this.token) ~ ")"; 201 } 202 203 } 204 205 class ClientToServerHandshake : Buffer { 206 207 public enum ubyte ID = 4; 208 209 public enum bool CLIENTBOUND = false; 210 public enum bool SERVERBOUND = true; 211 212 public enum string[] FIELDS = []; 213 214 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 215 _buffer.length = 0; 216 static if(writeId){ writeBigEndianUbyte(ID); } 217 return _buffer; 218 } 219 220 public pure nothrow @safe void decode(bool readId=true)() { 221 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 222 } 223 224 public static pure nothrow @safe ClientToServerHandshake fromBuffer(bool readId=true)(ubyte[] buffer) { 225 ClientToServerHandshake ret = new ClientToServerHandshake(); 226 ret._buffer = buffer; 227 ret.decode!readId(); 228 return ret; 229 } 230 231 public override string toString() { 232 return "ClientToServerHandshake()"; 233 } 234 235 } 236 237 /** 238 * Disconnects the player from the server. 239 */ 240 class Disconnect : Buffer { 241 242 public enum ubyte ID = 5; 243 244 public enum bool CLIENTBOUND = true; 245 public enum bool SERVERBOUND = false; 246 247 public enum string[] FIELDS = ["hideDisconnectionScreen", "message"]; 248 249 /** 250 * Indicates whether to display the main menu screen or a disconnection message. 251 */ 252 public bool hideDisconnectionScreen; 253 254 /** 255 * The message to display in the disconnection screen. If the message is in the game's 256 * language file it will be translated client-side. 257 */ 258 public string message; 259 260 public pure nothrow @safe @nogc this() {} 261 262 public pure nothrow @safe @nogc this(bool hideDisconnectionScreen, string message=string.init) { 263 this.hideDisconnectionScreen = hideDisconnectionScreen; 264 this.message = message; 265 } 266 267 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 268 _buffer.length = 0; 269 static if(writeId){ writeBigEndianUbyte(ID); } 270 writeBigEndianBool(hideDisconnectionScreen); 271 if(hideDisconnectionScreen==false){ writeBytes(varuint.encode(cast(uint)message.length)); writeString(message); } 272 return _buffer; 273 } 274 275 public pure nothrow @safe void decode(bool readId=true)() { 276 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 277 hideDisconnectionScreen=readBigEndianBool(); 278 if(hideDisconnectionScreen==false){ uint bvcfz=varuint.decode(_buffer, &_index); message=readString(bvcfz); } 279 } 280 281 public static pure nothrow @safe Disconnect fromBuffer(bool readId=true)(ubyte[] buffer) { 282 Disconnect ret = new Disconnect(); 283 ret._buffer = buffer; 284 ret.decode!readId(); 285 return ret; 286 } 287 288 public override string toString() { 289 return "Disconnect(hideDisconnectionScreen: " ~ std.conv.to!string(this.hideDisconnectionScreen) ~ ", message: " ~ std.conv.to!string(this.message) ~ ")"; 290 } 291 292 } 293 294 class ResourcePacksInfo : Buffer { 295 296 public enum ubyte ID = 6; 297 298 public enum bool CLIENTBOUND = true; 299 public enum bool SERVERBOUND = false; 300 301 public enum string[] FIELDS = ["mustAccept", "behaviourPacks", "resourcePacks"]; 302 303 public bool mustAccept; 304 public sul.protocol.pocket113.types.PackWithSize[] behaviourPacks; 305 public sul.protocol.pocket113.types.PackWithSize[] resourcePacks; 306 307 public pure nothrow @safe @nogc this() {} 308 309 public pure nothrow @safe @nogc this(bool mustAccept, sul.protocol.pocket113.types.PackWithSize[] behaviourPacks=(sul.protocol.pocket113.types.PackWithSize[]).init, sul.protocol.pocket113.types.PackWithSize[] resourcePacks=(sul.protocol.pocket113.types.PackWithSize[]).init) { 310 this.mustAccept = mustAccept; 311 this.behaviourPacks = behaviourPacks; 312 this.resourcePacks = resourcePacks; 313 } 314 315 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 316 _buffer.length = 0; 317 static if(writeId){ writeBigEndianUbyte(ID); } 318 writeBigEndianBool(mustAccept); 319 writeLittleEndianUshort(cast(ushort)behaviourPacks.length); foreach(yvyzbvuf;behaviourPacks){ yvyzbvuf.encode(bufferInstance); } 320 writeLittleEndianUshort(cast(ushort)resourcePacks.length); foreach(cvbvyvyn;resourcePacks){ cvbvyvyn.encode(bufferInstance); } 321 return _buffer; 322 } 323 324 public pure nothrow @safe void decode(bool readId=true)() { 325 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 326 mustAccept=readBigEndianBool(); 327 behaviourPacks.length=readLittleEndianUshort(); foreach(ref yvyzbvuf;behaviourPacks){ yvyzbvuf.decode(bufferInstance); } 328 resourcePacks.length=readLittleEndianUshort(); foreach(ref cvbvyvyn;resourcePacks){ cvbvyvyn.decode(bufferInstance); } 329 } 330 331 public static pure nothrow @safe ResourcePacksInfo fromBuffer(bool readId=true)(ubyte[] buffer) { 332 ResourcePacksInfo ret = new ResourcePacksInfo(); 333 ret._buffer = buffer; 334 ret.decode!readId(); 335 return ret; 336 } 337 338 public override string toString() { 339 return "ResourcePacksInfo(mustAccept: " ~ std.conv.to!string(this.mustAccept) ~ ", behaviourPacks: " ~ std.conv.to!string(this.behaviourPacks) ~ ", resourcePacks: " ~ std.conv.to!string(this.resourcePacks) ~ ")"; 340 } 341 342 } 343 344 class ResourcePacksStackPacket : Buffer { 345 346 public enum ubyte ID = 7; 347 348 public enum bool CLIENTBOUND = true; 349 public enum bool SERVERBOUND = false; 350 351 public enum string[] FIELDS = ["mustAccept", "behaviourPacks", "resourcePacks"]; 352 353 public bool mustAccept; 354 public sul.protocol.pocket113.types.Pack[] behaviourPacks; 355 public sul.protocol.pocket113.types.Pack[] resourcePacks; 356 357 public pure nothrow @safe @nogc this() {} 358 359 public pure nothrow @safe @nogc this(bool mustAccept, sul.protocol.pocket113.types.Pack[] behaviourPacks=(sul.protocol.pocket113.types.Pack[]).init, sul.protocol.pocket113.types.Pack[] resourcePacks=(sul.protocol.pocket113.types.Pack[]).init) { 360 this.mustAccept = mustAccept; 361 this.behaviourPacks = behaviourPacks; 362 this.resourcePacks = resourcePacks; 363 } 364 365 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 366 _buffer.length = 0; 367 static if(writeId){ writeBigEndianUbyte(ID); } 368 writeBigEndianBool(mustAccept); 369 writeBytes(varuint.encode(cast(uint)behaviourPacks.length)); foreach(yvyzbvuf;behaviourPacks){ yvyzbvuf.encode(bufferInstance); } 370 writeBytes(varuint.encode(cast(uint)resourcePacks.length)); foreach(cvbvyvyn;resourcePacks){ cvbvyvyn.encode(bufferInstance); } 371 return _buffer; 372 } 373 374 public pure nothrow @safe void decode(bool readId=true)() { 375 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 376 mustAccept=readBigEndianBool(); 377 behaviourPacks.length=varuint.decode(_buffer, &_index); foreach(ref yvyzbvuf;behaviourPacks){ yvyzbvuf.decode(bufferInstance); } 378 resourcePacks.length=varuint.decode(_buffer, &_index); foreach(ref cvbvyvyn;resourcePacks){ cvbvyvyn.decode(bufferInstance); } 379 } 380 381 public static pure nothrow @safe ResourcePacksStackPacket fromBuffer(bool readId=true)(ubyte[] buffer) { 382 ResourcePacksStackPacket ret = new ResourcePacksStackPacket(); 383 ret._buffer = buffer; 384 ret.decode!readId(); 385 return ret; 386 } 387 388 public override string toString() { 389 return "ResourcePacksStackPacket(mustAccept: " ~ std.conv.to!string(this.mustAccept) ~ ", behaviourPacks: " ~ std.conv.to!string(this.behaviourPacks) ~ ", resourcePacks: " ~ std.conv.to!string(this.resourcePacks) ~ ")"; 390 } 391 392 } 393 394 class ResourcePackClientResponse : Buffer { 395 396 public enum ubyte ID = 8; 397 398 public enum bool CLIENTBOUND = false; 399 public enum bool SERVERBOUND = true; 400 401 // status 402 public enum ubyte REFUSED = 1; 403 public enum ubyte SEND_PACKS = 2; 404 public enum ubyte HAVE_ALL_PACKS = 3; 405 public enum ubyte COMPLETED = 4; 406 407 public enum string[] FIELDS = ["status", "packIds"]; 408 409 public ubyte status; 410 public string[] packIds; 411 412 public pure nothrow @safe @nogc this() {} 413 414 public pure nothrow @safe @nogc this(ubyte status, string[] packIds=(string[]).init) { 415 this.status = status; 416 this.packIds = packIds; 417 } 418 419 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 420 _buffer.length = 0; 421 static if(writeId){ writeBigEndianUbyte(ID); } 422 writeBigEndianUbyte(status); 423 writeLittleEndianUshort(cast(ushort)packIds.length); foreach(cfalc;packIds){ writeBytes(varuint.encode(cast(uint)cfalc.length)); writeString(cfalc); } 424 return _buffer; 425 } 426 427 public pure nothrow @safe void decode(bool readId=true)() { 428 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 429 status=readBigEndianUbyte(); 430 packIds.length=readLittleEndianUshort(); foreach(ref cfalc;packIds){ uint yzbm=varuint.decode(_buffer, &_index); cfalc=readString(yzbm); } 431 } 432 433 public static pure nothrow @safe ResourcePackClientResponse fromBuffer(bool readId=true)(ubyte[] buffer) { 434 ResourcePackClientResponse ret = new ResourcePackClientResponse(); 435 ret._buffer = buffer; 436 ret.decode!readId(); 437 return ret; 438 } 439 440 public override string toString() { 441 return "ResourcePackClientResponse(status: " ~ std.conv.to!string(this.status) ~ ", packIds: " ~ std.conv.to!string(this.packIds) ~ ")"; 442 } 443 444 } 445 446 /** 447 * Sends or receives a message from the player. Every variant's field can contain Minecraft's 448 * formatting codes. 449 */ 450 class Text : Buffer { 451 452 public enum ubyte ID = 9; 453 454 public enum bool CLIENTBOUND = true; 455 public enum bool SERVERBOUND = true; 456 457 public enum string[] FIELDS = ["type"]; 458 459 public ubyte type; 460 461 public pure nothrow @safe @nogc this() {} 462 463 public pure nothrow @safe @nogc this(ubyte type) { 464 this.type = type; 465 } 466 467 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 468 _buffer.length = 0; 469 static if(writeId){ writeBigEndianUbyte(ID); } 470 writeBigEndianUbyte(type); 471 return _buffer; 472 } 473 474 public pure nothrow @safe void decode(bool readId=true)() { 475 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 476 type=readBigEndianUbyte(); 477 } 478 479 public static pure nothrow @safe Text fromBuffer(bool readId=true)(ubyte[] buffer) { 480 Text ret = new Text(); 481 ret._buffer = buffer; 482 ret.decode!readId(); 483 return ret; 484 } 485 486 public override string toString() { 487 return "Text(type: " ~ std.conv.to!string(this.type) ~ ")"; 488 } 489 490 alias _encode = encode; 491 492 enum string variantField = "type"; 493 494 alias Variants = TypeTuple!(Raw, Chat, Translation, Popup, Tip, System, Whisper, Announcement); 495 496 /** 497 * Raw message that will be printed in the chat as it is. 498 */ 499 public class Raw { 500 501 public enum typeof(type) TYPE = 0; 502 503 public enum string[] FIELDS = ["message"]; 504 505 public string message; 506 507 public pure nothrow @safe @nogc this() {} 508 509 public pure nothrow @safe @nogc this(string message) { 510 this.message = message; 511 } 512 513 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 514 type = 0; 515 _encode!writeId(); 516 writeBytes(varuint.encode(cast(uint)message.length)); writeString(message); 517 return _buffer; 518 } 519 520 public pure nothrow @safe void decode() { 521 uint bvcfz=varuint.decode(_buffer, &_index); message=readString(bvcfz); 522 } 523 524 public override string toString() { 525 return "Text.Raw(message: " ~ std.conv.to!string(this.message) ~ ")"; 526 } 527 528 } 529 530 /** 531 * Chat message sent by the player to the server. If sent from the server it will display 532 * as `<sender> message`. 533 */ 534 public class Chat { 535 536 public enum typeof(type) TYPE = 1; 537 538 public enum string[] FIELDS = ["sender", "message"]; 539 540 /** 541 * Case sensitive name of the player that has sent the message. 542 */ 543 public string sender; 544 545 /** 546 * Message sent by the player. It should be unformatted (regular expression: `§[a-fA-F0-9k-or]`) 547 * before being processed as chat message by the server. 548 */ 549 public string message; 550 551 public pure nothrow @safe @nogc this() {} 552 553 public pure nothrow @safe @nogc this(string sender, string message=string.init) { 554 this.sender = sender; 555 this.message = message; 556 } 557 558 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 559 type = 1; 560 _encode!writeId(); 561 writeBytes(varuint.encode(cast(uint)sender.length)); writeString(sender); 562 writeBytes(varuint.encode(cast(uint)message.length)); writeString(message); 563 return _buffer; 564 } 565 566 public pure nothrow @safe void decode() { 567 uint cvzv=varuint.decode(_buffer, &_index); sender=readString(cvzv); 568 uint bvcfz=varuint.decode(_buffer, &_index); message=readString(bvcfz); 569 } 570 571 public override string toString() { 572 return "Text.Chat(sender: " ~ std.conv.to!string(this.sender) ~ ", message: " ~ std.conv.to!string(this.message) ~ ")"; 573 } 574 575 } 576 577 /** 578 * Sends a message that will be translated client-side using the player's language. 579 */ 580 public class Translation { 581 582 public enum typeof(type) TYPE = 2; 583 584 public enum string[] FIELDS = ["message", "parameters"]; 585 586 /** 587 * A message in the game's language file. 588 */ 589 public string message; 590 591 /** 592 * Parameters that will be placed instead of the replacement symbols (%1, %2, etc...). 593 */ 594 public string[] parameters; 595 596 public pure nothrow @safe @nogc this() {} 597 598 public pure nothrow @safe @nogc this(string message, string[] parameters=(string[]).init) { 599 this.message = message; 600 this.parameters = parameters; 601 } 602 603 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 604 type = 2; 605 _encode!writeId(); 606 writeBytes(varuint.encode(cast(uint)message.length)); writeString(message); 607 writeBytes(varuint.encode(cast(uint)parameters.length)); foreach(cfy1dvc;parameters){ writeBytes(varuint.encode(cast(uint)cfy1dvc.length)); writeString(cfy1dvc); } 608 return _buffer; 609 } 610 611 public pure nothrow @safe void decode() { 612 uint bvcfz=varuint.decode(_buffer, &_index); message=readString(bvcfz); 613 parameters.length=varuint.decode(_buffer, &_index); foreach(ref cfy1dvc;parameters){ uint yzmry=varuint.decode(_buffer, &_index); cfy1dvc=readString(yzmry); } 614 } 615 616 public override string toString() { 617 return "Text.Translation(message: " ~ std.conv.to!string(this.message) ~ ", parameters: " ~ std.conv.to!string(this.parameters) ~ ")"; 618 } 619 620 } 621 622 /** 623 * Displays popups messages for one tick before fading out. The popup messages are 624 * displayed at the centre of the screen and are not automatically aligned horizontally. 625 */ 626 public class Popup { 627 628 public enum typeof(type) TYPE = 3; 629 630 public enum string[] FIELDS = ["title", "subtitle"]; 631 632 public string title; 633 public string subtitle; 634 635 public pure nothrow @safe @nogc this() {} 636 637 public pure nothrow @safe @nogc this(string title, string subtitle=string.init) { 638 this.title = title; 639 this.subtitle = subtitle; 640 } 641 642 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 643 type = 3; 644 _encode!writeId(); 645 writeBytes(varuint.encode(cast(uint)title.length)); writeString(title); 646 writeBytes(varuint.encode(cast(uint)subtitle.length)); writeString(subtitle); 647 return _buffer; 648 } 649 650 public pure nothrow @safe void decode() { 651 uint dlbu=varuint.decode(_buffer, &_index); title=readString(dlbu); 652 uint cvdlbu=varuint.decode(_buffer, &_index); subtitle=readString(cvdlbu); 653 } 654 655 public override string toString() { 656 return "Text.Popup(title: " ~ std.conv.to!string(this.title) ~ ", subtitle: " ~ std.conv.to!string(this.subtitle) ~ ")"; 657 } 658 659 } 660 661 /** 662 * Displays a tip message for one tick before fading out. The tip message is displayed 663 * on top of the inventory bar and can contain multiple lines separated with `\n`. 664 */ 665 public class Tip { 666 667 public enum typeof(type) TYPE = 4; 668 669 public enum string[] FIELDS = ["message"]; 670 671 public string message; 672 673 public pure nothrow @safe @nogc this() {} 674 675 public pure nothrow @safe @nogc this(string message) { 676 this.message = message; 677 } 678 679 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 680 type = 4; 681 _encode!writeId(); 682 writeBytes(varuint.encode(cast(uint)message.length)); writeString(message); 683 return _buffer; 684 } 685 686 public pure nothrow @safe void decode() { 687 uint bvcfz=varuint.decode(_buffer, &_index); message=readString(bvcfz); 688 } 689 690 public override string toString() { 691 return "Text.Tip(message: " ~ std.conv.to!string(this.message) ~ ")"; 692 } 693 694 } 695 696 public class System { 697 698 public enum typeof(type) TYPE = 5; 699 700 public enum string[] FIELDS = ["message"]; 701 702 public string message; 703 704 public pure nothrow @safe @nogc this() {} 705 706 public pure nothrow @safe @nogc this(string message) { 707 this.message = message; 708 } 709 710 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 711 type = 5; 712 _encode!writeId(); 713 writeBytes(varuint.encode(cast(uint)message.length)); writeString(message); 714 return _buffer; 715 } 716 717 public pure nothrow @safe void decode() { 718 uint bvcfz=varuint.decode(_buffer, &_index); message=readString(bvcfz); 719 } 720 721 public override string toString() { 722 return "Text.System(message: " ~ std.conv.to!string(this.message) ~ ")"; 723 } 724 725 } 726 727 /** 728 * Sends a whisper message to the client that will be displayed in the format `<i>sender 729 * has whispered to you:</i> message`. 730 */ 731 public class Whisper { 732 733 public enum typeof(type) TYPE = 6; 734 735 public enum string[] FIELDS = ["sender", "message"]; 736 737 public string sender; 738 public string message; 739 740 public pure nothrow @safe @nogc this() {} 741 742 public pure nothrow @safe @nogc this(string sender, string message=string.init) { 743 this.sender = sender; 744 this.message = message; 745 } 746 747 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 748 type = 6; 749 _encode!writeId(); 750 writeBytes(varuint.encode(cast(uint)sender.length)); writeString(sender); 751 writeBytes(varuint.encode(cast(uint)message.length)); writeString(message); 752 return _buffer; 753 } 754 755 public pure nothrow @safe void decode() { 756 uint cvzv=varuint.decode(_buffer, &_index); sender=readString(cvzv); 757 uint bvcfz=varuint.decode(_buffer, &_index); message=readString(bvcfz); 758 } 759 760 public override string toString() { 761 return "Text.Whisper(sender: " ~ std.conv.to!string(this.sender) ~ ", message: " ~ std.conv.to!string(this.message) ~ ")"; 762 } 763 764 } 765 766 public class Announcement { 767 768 public enum typeof(type) TYPE = 7; 769 770 public enum string[] FIELDS = ["announcer", "message"]; 771 772 public string announcer; 773 public string message; 774 775 public pure nothrow @safe @nogc this() {} 776 777 public pure nothrow @safe @nogc this(string announcer, string message=string.init) { 778 this.announcer = announcer; 779 this.message = message; 780 } 781 782 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 783 type = 7; 784 _encode!writeId(); 785 writeBytes(varuint.encode(cast(uint)announcer.length)); writeString(announcer); 786 writeBytes(varuint.encode(cast(uint)message.length)); writeString(message); 787 return _buffer; 788 } 789 790 public pure nothrow @safe void decode() { 791 uint y5bvyv=varuint.decode(_buffer, &_index); announcer=readString(y5bvyv); 792 uint bvcfz=varuint.decode(_buffer, &_index); message=readString(bvcfz); 793 } 794 795 public override string toString() { 796 return "Text.Announcement(announcer: " ~ std.conv.to!string(this.announcer) ~ ", message: " ~ std.conv.to!string(this.message) ~ ")"; 797 } 798 799 } 800 801 } 802 803 /** 804 * Sets the time. 805 */ 806 class SetTime : Buffer { 807 808 public enum ubyte ID = 10; 809 810 public enum bool CLIENTBOUND = true; 811 public enum bool SERVERBOUND = false; 812 813 public enum string[] FIELDS = ["time"]; 814 815 /** 816 * Time of the day in a range from 0 to 24000. If higher or lower it will be moduled 817 * to 24000. 818 */ 819 public int time; 820 821 public pure nothrow @safe @nogc this() {} 822 823 public pure nothrow @safe @nogc this(int time) { 824 this.time = time; 825 } 826 827 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 828 _buffer.length = 0; 829 static if(writeId){ writeBigEndianUbyte(ID); } 830 writeBytes(varint.encode(time)); 831 return _buffer; 832 } 833 834 public pure nothrow @safe void decode(bool readId=true)() { 835 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 836 time=varint.decode(_buffer, &_index); 837 } 838 839 public static pure nothrow @safe SetTime fromBuffer(bool readId=true)(ubyte[] buffer) { 840 SetTime ret = new SetTime(); 841 ret._buffer = buffer; 842 ret.decode!readId(); 843 return ret; 844 } 845 846 public override string toString() { 847 return "SetTime(time: " ~ std.conv.to!string(this.time) ~ ")"; 848 } 849 850 } 851 852 class StartGame : Buffer { 853 854 public enum ubyte ID = 11; 855 856 public enum bool CLIENTBOUND = true; 857 public enum bool SERVERBOUND = false; 858 859 // gamemode 860 public enum int SURVIVAL = 0; 861 public enum int CREATIVE = 1; 862 public enum int ADVENTURE = 2; 863 864 // dimension 865 public enum int OVERWORLD = 0; 866 public enum int NETHER = 1; 867 public enum int END = 2; 868 869 // generator 870 public enum int OLD = 0; 871 public enum int INFINITE = 1; 872 public enum int FLAT = 2; 873 874 // difficulty 875 public enum int PEACEFUL = 0; 876 public enum int EASY = 1; 877 public enum int NORMAL = 2; 878 public enum int HARD = 3; 879 880 // version 881 public enum ubyte VANILLA = 0; 882 public enum ubyte EDUCATION = 1; 883 884 public enum string[] FIELDS = ["entityId", "runtimeId", "gamemode", "position", "yaw", "pitch", "seed", "dimension", "generator", "worldGamemode", "difficulty", "spawnPosition", "loadedInCreative", "time", "vers", "rainLevel", "lightingLevel", "commandsEnabled", "textureRequired", "gameRules", "levelId", "worldName", "premiumWorldTemplate", "unknown23", "worldTicks"]; 885 886 /** 887 * Player's entity id that uniquely identifies the entity of the server. 888 */ 889 public long entityId; 890 public long runtimeId; 891 892 /** 893 * Player's gamemode that may differ from the world's gamemode. 894 */ 895 public int gamemode; 896 897 /** 898 * Position where the player will spawn. 899 */ 900 public Tuple!(float, "x", float, "y", float, "z") position; 901 public float yaw; 902 public float pitch; 903 904 /** 905 * World's seed. It's displayed in the game's world settings and in beta's debug informations 906 * on top of the screen. 907 */ 908 public int seed; 909 910 /** 911 * World's dimension. Different dimensions have different sky colours and render distances. 912 */ 913 public int dimension = 0; 914 915 /** 916 * World's type. It's displayed in the game's world settings. 917 * In old and infinite world the sky becomes darker at 32 blocks of altitude and in 918 * flat worlds it only becomes darker under 0. 919 */ 920 public int generator = 1; 921 922 /** 923 * Default's world gamemode. 924 */ 925 public int worldGamemode; 926 927 /** 928 * World's difficulty. The value is visible in the client's world settings. 929 */ 930 public int difficulty; 931 932 /** 933 * Position where the client's compass will point to. 934 */ 935 public Tuple!(int, "x", int, "y", int, "z") spawnPosition; 936 public bool loadedInCreative; 937 938 /** 939 * Time of the day that should be in a range from 0 to 24000. If not the absolute value 940 * is moduled per 24000. 941 */ 942 public int time; 943 944 /** 945 * Game's edition. Some behaviours (some entities for example) may only work in a version 946 * and not in the other. 947 */ 948 public ubyte vers; 949 950 /** 951 * Intensity of the rain or the snow. Any value lower than or equals to 0 means no 952 * rain. 953 */ 954 public float rainLevel; 955 public float lightingLevel; 956 957 /** 958 * Indicates whether the cheats are enabled. If the cheats are disabled the player 959 * cannot send commands. 960 */ 961 public bool commandsEnabled; 962 public bool textureRequired; 963 public sul.protocol.pocket113.types.Rule[] gameRules; 964 public string levelId; 965 966 /** 967 * World's name that will be displayed in the game's world settings. It can contain 968 * formatting codes. 969 */ 970 public string worldName; 971 public string premiumWorldTemplate; 972 public bool unknown23; 973 public ulong worldTicks; 974 975 public pure nothrow @safe @nogc this() {} 976 977 public pure nothrow @safe @nogc this(long entityId, long runtimeId=long.init, int gamemode=int.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 vers=ubyte.init, float rainLevel=float.init, float lightingLevel=float.init, bool commandsEnabled=bool.init, bool textureRequired=bool.init, sul.protocol.pocket113.types.Rule[] gameRules=(sul.protocol.pocket113.types.Rule[]).init, string levelId=string.init, string worldName=string.init, string premiumWorldTemplate=string.init, bool unknown23=bool.init, ulong worldTicks=ulong.init) { 978 this.entityId = entityId; 979 this.runtimeId = runtimeId; 980 this.gamemode = gamemode; 981 this.position = position; 982 this.yaw = yaw; 983 this.pitch = pitch; 984 this.seed = seed; 985 this.dimension = dimension; 986 this.generator = generator; 987 this.worldGamemode = worldGamemode; 988 this.difficulty = difficulty; 989 this.spawnPosition = spawnPosition; 990 this.loadedInCreative = loadedInCreative; 991 this.time = time; 992 this.vers = vers; 993 this.rainLevel = rainLevel; 994 this.lightingLevel = lightingLevel; 995 this.commandsEnabled = commandsEnabled; 996 this.textureRequired = textureRequired; 997 this.gameRules = gameRules; 998 this.levelId = levelId; 999 this.worldName = worldName; 1000 this.premiumWorldTemplate = premiumWorldTemplate; 1001 this.unknown23 = unknown23; 1002 this.worldTicks = worldTicks; 1003 } 1004 1005 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 1006 _buffer.length = 0; 1007 static if(writeId){ writeBigEndianUbyte(ID); } 1008 writeBytes(varlong.encode(entityId)); 1009 writeBytes(varlong.encode(runtimeId)); 1010 writeBytes(varint.encode(gamemode)); 1011 writeLittleEndianFloat(position.x); writeLittleEndianFloat(position.y); writeLittleEndianFloat(position.z); 1012 writeLittleEndianFloat(yaw); 1013 writeLittleEndianFloat(pitch); 1014 writeBytes(varint.encode(seed)); 1015 writeBytes(varint.encode(dimension)); 1016 writeBytes(varint.encode(generator)); 1017 writeBytes(varint.encode(worldGamemode)); 1018 writeBytes(varint.encode(difficulty)); 1019 writeBytes(varint.encode(spawnPosition.x)); writeBytes(varint.encode(spawnPosition.y)); writeBytes(varint.encode(spawnPosition.z)); 1020 writeBigEndianBool(loadedInCreative); 1021 writeBytes(varint.encode(time)); 1022 writeBigEndianUbyte(vers); 1023 writeLittleEndianFloat(rainLevel); 1024 writeLittleEndianFloat(lightingLevel); 1025 writeBigEndianBool(commandsEnabled); 1026 writeBigEndianBool(textureRequired); 1027 writeBytes(varuint.encode(cast(uint)gameRules.length)); foreach(zfzjbv;gameRules){ zfzjbv.encode(bufferInstance); } 1028 writeBytes(varuint.encode(cast(uint)levelId.length)); writeString(levelId); 1029 writeBytes(varuint.encode(cast(uint)worldName.length)); writeString(worldName); 1030 writeBytes(varuint.encode(cast(uint)premiumWorldTemplate.length)); writeString(premiumWorldTemplate); 1031 writeBigEndianBool(unknown23); 1032 writeLittleEndianUlong(worldTicks); 1033 return _buffer; 1034 } 1035 1036 public pure nothrow @safe void decode(bool readId=true)() { 1037 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 1038 entityId=varlong.decode(_buffer, &_index); 1039 runtimeId=varlong.decode(_buffer, &_index); 1040 gamemode=varint.decode(_buffer, &_index); 1041 position.x=readLittleEndianFloat(); position.y=readLittleEndianFloat(); position.z=readLittleEndianFloat(); 1042 yaw=readLittleEndianFloat(); 1043 pitch=readLittleEndianFloat(); 1044 seed=varint.decode(_buffer, &_index); 1045 dimension=varint.decode(_buffer, &_index); 1046 generator=varint.decode(_buffer, &_index); 1047 worldGamemode=varint.decode(_buffer, &_index); 1048 difficulty=varint.decode(_buffer, &_index); 1049 spawnPosition.x=varint.decode(_buffer, &_index); spawnPosition.y=varint.decode(_buffer, &_index); spawnPosition.z=varint.decode(_buffer, &_index); 1050 loadedInCreative=readBigEndianBool(); 1051 time=varint.decode(_buffer, &_index); 1052 vers=readBigEndianUbyte(); 1053 rainLevel=readLittleEndianFloat(); 1054 lightingLevel=readLittleEndianFloat(); 1055 commandsEnabled=readBigEndianBool(); 1056 textureRequired=readBigEndianBool(); 1057 gameRules.length=varuint.decode(_buffer, &_index); foreach(ref zfzjbv;gameRules){ zfzjbv.decode(bufferInstance); } 1058 uint bvzxz=varuint.decode(_buffer, &_index); levelId=readString(bvzxz); 1059 uint d9bry1=varuint.decode(_buffer, &_index); worldName=readString(d9bry1); 1060 uint cjblbdcx=varuint.decode(_buffer, &_index); premiumWorldTemplate=readString(cjblbdcx); 1061 unknown23=readBigEndianBool(); 1062 worldTicks=readLittleEndianUlong(); 1063 } 1064 1065 public static pure nothrow @safe StartGame fromBuffer(bool readId=true)(ubyte[] buffer) { 1066 StartGame ret = new StartGame(); 1067 ret._buffer = buffer; 1068 ret.decode!readId(); 1069 return ret; 1070 } 1071 1072 public override string toString() { 1073 return "StartGame(entityId: " ~ std.conv.to!string(this.entityId) ~ ", runtimeId: " ~ std.conv.to!string(this.runtimeId) ~ ", gamemode: " ~ std.conv.to!string(this.gamemode) ~ ", 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) ~ ", vers: " ~ std.conv.to!string(this.vers) ~ ", rainLevel: " ~ std.conv.to!string(this.rainLevel) ~ ", lightingLevel: " ~ std.conv.to!string(this.lightingLevel) ~ ", commandsEnabled: " ~ std.conv.to!string(this.commandsEnabled) ~ ", textureRequired: " ~ std.conv.to!string(this.textureRequired) ~ ", gameRules: " ~ std.conv.to!string(this.gameRules) ~ ", levelId: " ~ std.conv.to!string(this.levelId) ~ ", worldName: " ~ std.conv.to!string(this.worldName) ~ ", premiumWorldTemplate: " ~ std.conv.to!string(this.premiumWorldTemplate) ~ ", unknown23: " ~ std.conv.to!string(this.unknown23) ~ ", worldTicks: " ~ std.conv.to!string(this.worldTicks) ~ ")"; 1074 } 1075 1076 } 1077 1078 /** 1079 * Spawns a player after adding it to the player's list using PlayerList. If PlayerList 1080 * is sent after this packet the player will appear to have the same skin as the player 1081 * who receives this packet. 1082 * Spawning a player to itself (using the same entity id given in the StartGame packet) 1083 * will crash the client's game. 1084 */ 1085 class AddPlayer : Buffer { 1086 1087 public enum ubyte ID = 12; 1088 1089 public enum bool CLIENTBOUND = true; 1090 public enum bool SERVERBOUND = false; 1091 1092 public enum string[] FIELDS = ["uuid", "username", "entityId", "runtimeId", "position", "motion", "pitch", "headYaw", "yaw", "heldItem", "metadata"]; 1093 1094 /** 1095 * Player's UUID, should match an UUID of a player in the list added through PlayerList. 1096 */ 1097 public sul.protocol.pocket113.types.McpeUuid uuid; 1098 1099 /** 1100 * Player's username and text displayed on the nametag if something else is not specified 1101 * in the metadata. 1102 */ 1103 public string username; 1104 public long entityId; 1105 public long runtimeId; 1106 public Tuple!(float, "x", float, "y", float, "z") position; 1107 public Tuple!(float, "x", float, "y", float, "z") motion; 1108 public float pitch; 1109 public float headYaw; 1110 public float yaw; 1111 public sul.protocol.pocket113.types.Slot heldItem; 1112 public Metadata metadata; 1113 1114 public pure nothrow @safe @nogc this() {} 1115 1116 public pure nothrow @safe @nogc this(sul.protocol.pocket113.types.McpeUuid 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.pocket113.types.Slot heldItem=sul.protocol.pocket113.types.Slot.init, Metadata metadata=Metadata.init) { 1117 this.uuid = uuid; 1118 this.username = username; 1119 this.entityId = entityId; 1120 this.runtimeId = runtimeId; 1121 this.position = position; 1122 this.motion = motion; 1123 this.pitch = pitch; 1124 this.headYaw = headYaw; 1125 this.yaw = yaw; 1126 this.heldItem = heldItem; 1127 this.metadata = metadata; 1128 } 1129 1130 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 1131 _buffer.length = 0; 1132 static if(writeId){ writeBigEndianUbyte(ID); } 1133 uuid.encode(bufferInstance); 1134 writeBytes(varuint.encode(cast(uint)username.length)); writeString(username); 1135 writeBytes(varlong.encode(entityId)); 1136 writeBytes(varlong.encode(runtimeId)); 1137 writeLittleEndianFloat(position.x); writeLittleEndianFloat(position.y); writeLittleEndianFloat(position.z); 1138 writeLittleEndianFloat(motion.x); writeLittleEndianFloat(motion.y); writeLittleEndianFloat(motion.z); 1139 writeLittleEndianFloat(pitch); 1140 writeLittleEndianFloat(headYaw); 1141 writeLittleEndianFloat(yaw); 1142 heldItem.encode(bufferInstance); 1143 metadata.encode(bufferInstance); 1144 return _buffer; 1145 } 1146 1147 public pure nothrow @safe void decode(bool readId=true)() { 1148 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 1149 uuid.decode(bufferInstance); 1150 uint dnc5bu=varuint.decode(_buffer, &_index); username=readString(dnc5bu); 1151 entityId=varlong.decode(_buffer, &_index); 1152 runtimeId=varlong.decode(_buffer, &_index); 1153 position.x=readLittleEndianFloat(); position.y=readLittleEndianFloat(); position.z=readLittleEndianFloat(); 1154 motion.x=readLittleEndianFloat(); motion.y=readLittleEndianFloat(); motion.z=readLittleEndianFloat(); 1155 pitch=readLittleEndianFloat(); 1156 headYaw=readLittleEndianFloat(); 1157 yaw=readLittleEndianFloat(); 1158 heldItem.decode(bufferInstance); 1159 metadata=Metadata.decode(bufferInstance); 1160 } 1161 1162 public static pure nothrow @safe AddPlayer fromBuffer(bool readId=true)(ubyte[] buffer) { 1163 AddPlayer ret = new AddPlayer(); 1164 ret._buffer = buffer; 1165 ret.decode!readId(); 1166 return ret; 1167 } 1168 1169 public override string toString() { 1170 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) ~ ")"; 1171 } 1172 1173 } 1174 1175 class AddEntity : Buffer { 1176 1177 public enum ubyte ID = 13; 1178 1179 public enum bool CLIENTBOUND = true; 1180 public enum bool SERVERBOUND = false; 1181 1182 public enum string[] FIELDS = ["entityId", "runtimeId", "type", "position", "motion", "pitch", "yaw", "attributes", "metadata", "links"]; 1183 1184 public long entityId; 1185 public long runtimeId; 1186 public uint type; 1187 public Tuple!(float, "x", float, "y", float, "z") position; 1188 public Tuple!(float, "x", float, "y", float, "z") motion; 1189 public float pitch; 1190 public float yaw; 1191 public sul.protocol.pocket113.types.Attribute[] attributes; 1192 public Metadata metadata; 1193 public sul.protocol.pocket113.types.Link[] links; 1194 1195 public pure nothrow @safe @nogc this() {} 1196 1197 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.pocket113.types.Attribute[] attributes=(sul.protocol.pocket113.types.Attribute[]).init, Metadata metadata=Metadata.init, sul.protocol.pocket113.types.Link[] links=(sul.protocol.pocket113.types.Link[]).init) { 1198 this.entityId = entityId; 1199 this.runtimeId = runtimeId; 1200 this.type = type; 1201 this.position = position; 1202 this.motion = motion; 1203 this.pitch = pitch; 1204 this.yaw = yaw; 1205 this.attributes = attributes; 1206 this.metadata = metadata; 1207 this.links = links; 1208 } 1209 1210 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 1211 _buffer.length = 0; 1212 static if(writeId){ writeBigEndianUbyte(ID); } 1213 writeBytes(varlong.encode(entityId)); 1214 writeBytes(varlong.encode(runtimeId)); 1215 writeBytes(varuint.encode(type)); 1216 writeLittleEndianFloat(position.x); writeLittleEndianFloat(position.y); writeLittleEndianFloat(position.z); 1217 writeLittleEndianFloat(motion.x); writeLittleEndianFloat(motion.y); writeLittleEndianFloat(motion.z); 1218 writeLittleEndianFloat(pitch); 1219 writeLittleEndianFloat(yaw); 1220 writeBytes(varuint.encode(cast(uint)attributes.length)); foreach(yrcldrc;attributes){ yrcldrc.encode(bufferInstance); } 1221 metadata.encode(bufferInstance); 1222 writeBytes(varuint.encode(cast(uint)links.length)); foreach(blam;links){ blam.encode(bufferInstance); } 1223 return _buffer; 1224 } 1225 1226 public pure nothrow @safe void decode(bool readId=true)() { 1227 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 1228 entityId=varlong.decode(_buffer, &_index); 1229 runtimeId=varlong.decode(_buffer, &_index); 1230 type=varuint.decode(_buffer, &_index); 1231 position.x=readLittleEndianFloat(); position.y=readLittleEndianFloat(); position.z=readLittleEndianFloat(); 1232 motion.x=readLittleEndianFloat(); motion.y=readLittleEndianFloat(); motion.z=readLittleEndianFloat(); 1233 pitch=readLittleEndianFloat(); 1234 yaw=readLittleEndianFloat(); 1235 attributes.length=varuint.decode(_buffer, &_index); foreach(ref yrcldrc;attributes){ yrcldrc.decode(bufferInstance); } 1236 metadata=Metadata.decode(bufferInstance); 1237 links.length=varuint.decode(_buffer, &_index); foreach(ref blam;links){ blam.decode(bufferInstance); } 1238 } 1239 1240 public static pure nothrow @safe AddEntity fromBuffer(bool readId=true)(ubyte[] buffer) { 1241 AddEntity ret = new AddEntity(); 1242 ret._buffer = buffer; 1243 ret.decode!readId(); 1244 return ret; 1245 } 1246 1247 public override string toString() { 1248 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) ~ ")"; 1249 } 1250 1251 } 1252 1253 /** 1254 * Despawns an entity or a player. 1255 */ 1256 class RemoveEntity : Buffer { 1257 1258 public enum ubyte ID = 14; 1259 1260 public enum bool CLIENTBOUND = true; 1261 public enum bool SERVERBOUND = false; 1262 1263 public enum string[] FIELDS = ["entityId"]; 1264 1265 public long entityId; 1266 1267 public pure nothrow @safe @nogc this() {} 1268 1269 public pure nothrow @safe @nogc this(long entityId) { 1270 this.entityId = entityId; 1271 } 1272 1273 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 1274 _buffer.length = 0; 1275 static if(writeId){ writeBigEndianUbyte(ID); } 1276 writeBytes(varlong.encode(entityId)); 1277 return _buffer; 1278 } 1279 1280 public pure nothrow @safe void decode(bool readId=true)() { 1281 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 1282 entityId=varlong.decode(_buffer, &_index); 1283 } 1284 1285 public static pure nothrow @safe RemoveEntity fromBuffer(bool readId=true)(ubyte[] buffer) { 1286 RemoveEntity ret = new RemoveEntity(); 1287 ret._buffer = buffer; 1288 ret.decode!readId(); 1289 return ret; 1290 } 1291 1292 public override string toString() { 1293 return "RemoveEntity(entityId: " ~ std.conv.to!string(this.entityId) ~ ")"; 1294 } 1295 1296 } 1297 1298 /** 1299 * Spawns a dropped item. 1300 */ 1301 class AddItemEntity : Buffer { 1302 1303 public enum ubyte ID = 15; 1304 1305 public enum bool CLIENTBOUND = true; 1306 public enum bool SERVERBOUND = false; 1307 1308 public enum string[] FIELDS = ["entityId", "runtimeId", "item", "position", "motion", "metadata"]; 1309 1310 public long entityId; 1311 public long runtimeId; 1312 public sul.protocol.pocket113.types.Slot item; 1313 public Tuple!(float, "x", float, "y", float, "z") position; 1314 public Tuple!(float, "x", float, "y", float, "z") motion; 1315 public Metadata metadata; 1316 1317 public pure nothrow @safe @nogc this() {} 1318 1319 public pure nothrow @safe @nogc this(long entityId, long runtimeId=long.init, sul.protocol.pocket113.types.Slot item=sul.protocol.pocket113.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, Metadata metadata=Metadata.init) { 1320 this.entityId = entityId; 1321 this.runtimeId = runtimeId; 1322 this.item = item; 1323 this.position = position; 1324 this.motion = motion; 1325 this.metadata = metadata; 1326 } 1327 1328 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 1329 _buffer.length = 0; 1330 static if(writeId){ writeBigEndianUbyte(ID); } 1331 writeBytes(varlong.encode(entityId)); 1332 writeBytes(varlong.encode(runtimeId)); 1333 item.encode(bufferInstance); 1334 writeLittleEndianFloat(position.x); writeLittleEndianFloat(position.y); writeLittleEndianFloat(position.z); 1335 writeLittleEndianFloat(motion.x); writeLittleEndianFloat(motion.y); writeLittleEndianFloat(motion.z); 1336 metadata.encode(bufferInstance); 1337 return _buffer; 1338 } 1339 1340 public pure nothrow @safe void decode(bool readId=true)() { 1341 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 1342 entityId=varlong.decode(_buffer, &_index); 1343 runtimeId=varlong.decode(_buffer, &_index); 1344 item.decode(bufferInstance); 1345 position.x=readLittleEndianFloat(); position.y=readLittleEndianFloat(); position.z=readLittleEndianFloat(); 1346 motion.x=readLittleEndianFloat(); motion.y=readLittleEndianFloat(); motion.z=readLittleEndianFloat(); 1347 metadata=Metadata.decode(bufferInstance); 1348 } 1349 1350 public static pure nothrow @safe AddItemEntity fromBuffer(bool readId=true)(ubyte[] buffer) { 1351 AddItemEntity ret = new AddItemEntity(); 1352 ret._buffer = buffer; 1353 ret.decode!readId(); 1354 return ret; 1355 } 1356 1357 public override string toString() { 1358 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) ~ ", metadata: " ~ std.conv.to!string(this.metadata) ~ ")"; 1359 } 1360 1361 } 1362 1363 class AddHangingEntity : Buffer { 1364 1365 public enum ubyte ID = 16; 1366 1367 public enum bool CLIENTBOUND = true; 1368 public enum bool SERVERBOUND = false; 1369 1370 public enum string[] FIELDS = ["entityId", "runtimeId", "position", "unknown3"]; 1371 1372 public long entityId; 1373 public long runtimeId; 1374 public sul.protocol.pocket113.types.BlockPosition position; 1375 public int unknown3; 1376 1377 public pure nothrow @safe @nogc this() {} 1378 1379 public pure nothrow @safe @nogc this(long entityId, long runtimeId=long.init, sul.protocol.pocket113.types.BlockPosition position=sul.protocol.pocket113.types.BlockPosition.init, int unknown3=int.init) { 1380 this.entityId = entityId; 1381 this.runtimeId = runtimeId; 1382 this.position = position; 1383 this.unknown3 = unknown3; 1384 } 1385 1386 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 1387 _buffer.length = 0; 1388 static if(writeId){ writeBigEndianUbyte(ID); } 1389 writeBytes(varlong.encode(entityId)); 1390 writeBytes(varlong.encode(runtimeId)); 1391 position.encode(bufferInstance); 1392 writeBytes(varint.encode(unknown3)); 1393 return _buffer; 1394 } 1395 1396 public pure nothrow @safe void decode(bool readId=true)() { 1397 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 1398 entityId=varlong.decode(_buffer, &_index); 1399 runtimeId=varlong.decode(_buffer, &_index); 1400 position.decode(bufferInstance); 1401 unknown3=varint.decode(_buffer, &_index); 1402 } 1403 1404 public static pure nothrow @safe AddHangingEntity fromBuffer(bool readId=true)(ubyte[] buffer) { 1405 AddHangingEntity ret = new AddHangingEntity(); 1406 ret._buffer = buffer; 1407 ret.decode!readId(); 1408 return ret; 1409 } 1410 1411 public override string toString() { 1412 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) ~ ")"; 1413 } 1414 1415 } 1416 1417 /** 1418 * Plays the collection animation and despawns the entity that has been collected. 1419 */ 1420 class TakeItemEntity : Buffer { 1421 1422 public enum ubyte ID = 17; 1423 1424 public enum bool CLIENTBOUND = true; 1425 public enum bool SERVERBOUND = false; 1426 1427 public enum string[] FIELDS = ["collected", "collector"]; 1428 1429 /** 1430 * Collected entity, usually an item entity or an arrow, that will float toward the 1431 * collector and despawn. 1432 */ 1433 public long collected; 1434 1435 /** 1436 * Entity that collects, usually a player or another entity with an inventory. 1437 */ 1438 public long collector; 1439 1440 public pure nothrow @safe @nogc this() {} 1441 1442 public pure nothrow @safe @nogc this(long collected, long collector=long.init) { 1443 this.collected = collected; 1444 this.collector = collector; 1445 } 1446 1447 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 1448 _buffer.length = 0; 1449 static if(writeId){ writeBigEndianUbyte(ID); } 1450 writeBytes(varlong.encode(collected)); 1451 writeBytes(varlong.encode(collector)); 1452 return _buffer; 1453 } 1454 1455 public pure nothrow @safe void decode(bool readId=true)() { 1456 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 1457 collected=varlong.decode(_buffer, &_index); 1458 collector=varlong.decode(_buffer, &_index); 1459 } 1460 1461 public static pure nothrow @safe TakeItemEntity fromBuffer(bool readId=true)(ubyte[] buffer) { 1462 TakeItemEntity ret = new TakeItemEntity(); 1463 ret._buffer = buffer; 1464 ret.decode!readId(); 1465 return ret; 1466 } 1467 1468 public override string toString() { 1469 return "TakeItemEntity(collected: " ~ std.conv.to!string(this.collected) ~ ", collector: " ~ std.conv.to!string(this.collector) ~ ")"; 1470 } 1471 1472 } 1473 1474 class MoveEntity : Buffer { 1475 1476 public enum ubyte ID = 18; 1477 1478 public enum bool CLIENTBOUND = true; 1479 public enum bool SERVERBOUND = false; 1480 1481 public enum string[] FIELDS = ["entityId", "position", "pitch", "headYaw", "yaw", "onGround", "teleported"]; 1482 1483 public long entityId; 1484 public Tuple!(float, "x", float, "y", float, "z") position; 1485 public ubyte pitch; 1486 public ubyte headYaw; 1487 public ubyte yaw; 1488 public bool onGround; 1489 public bool teleported; 1490 1491 public pure nothrow @safe @nogc this() {} 1492 1493 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, bool onGround=bool.init, bool teleported=bool.init) { 1494 this.entityId = entityId; 1495 this.position = position; 1496 this.pitch = pitch; 1497 this.headYaw = headYaw; 1498 this.yaw = yaw; 1499 this.onGround = onGround; 1500 this.teleported = teleported; 1501 } 1502 1503 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 1504 _buffer.length = 0; 1505 static if(writeId){ writeBigEndianUbyte(ID); } 1506 writeBytes(varlong.encode(entityId)); 1507 writeLittleEndianFloat(position.x); writeLittleEndianFloat(position.y); writeLittleEndianFloat(position.z); 1508 writeBigEndianUbyte(pitch); 1509 writeBigEndianUbyte(headYaw); 1510 writeBigEndianUbyte(yaw); 1511 writeBigEndianBool(onGround); 1512 writeBigEndianBool(teleported); 1513 return _buffer; 1514 } 1515 1516 public pure nothrow @safe void decode(bool readId=true)() { 1517 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 1518 entityId=varlong.decode(_buffer, &_index); 1519 position.x=readLittleEndianFloat(); position.y=readLittleEndianFloat(); position.z=readLittleEndianFloat(); 1520 pitch=readBigEndianUbyte(); 1521 headYaw=readBigEndianUbyte(); 1522 yaw=readBigEndianUbyte(); 1523 onGround=readBigEndianBool(); 1524 teleported=readBigEndianBool(); 1525 } 1526 1527 public static pure nothrow @safe MoveEntity fromBuffer(bool readId=true)(ubyte[] buffer) { 1528 MoveEntity ret = new MoveEntity(); 1529 ret._buffer = buffer; 1530 ret.decode!readId(); 1531 return ret; 1532 } 1533 1534 public override string toString() { 1535 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) ~ ", onGround: " ~ std.conv.to!string(this.onGround) ~ ", teleported: " ~ std.conv.to!string(this.teleported) ~ ")"; 1536 } 1537 1538 } 1539 1540 class MovePlayer : Buffer { 1541 1542 public enum ubyte ID = 19; 1543 1544 public enum bool CLIENTBOUND = true; 1545 public enum bool SERVERBOUND = true; 1546 1547 // animation 1548 public enum ubyte FULL = 0; 1549 public enum ubyte NONE = 1; 1550 public enum ubyte TELEPORT = 2; 1551 public enum ubyte PITCH = 3; 1552 1553 public enum string[] FIELDS = ["entityId", "position", "pitch", "headYaw", "yaw", "animation", "onGround", "unknown7", "unknown8", "unknown9"]; 1554 1555 public long entityId; 1556 public Tuple!(float, "x", float, "y", float, "z") position; 1557 public float pitch; 1558 public float headYaw; 1559 public float yaw; 1560 public ubyte animation; 1561 public bool onGround; 1562 public long unknown7; 1563 public int unknown8; 1564 public int unknown9; 1565 1566 public pure nothrow @safe @nogc this() {} 1567 1568 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, long unknown7=long.init, int unknown8=int.init, int unknown9=int.init) { 1569 this.entityId = entityId; 1570 this.position = position; 1571 this.pitch = pitch; 1572 this.headYaw = headYaw; 1573 this.yaw = yaw; 1574 this.animation = animation; 1575 this.onGround = onGround; 1576 this.unknown7 = unknown7; 1577 this.unknown8 = unknown8; 1578 this.unknown9 = unknown9; 1579 } 1580 1581 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 1582 _buffer.length = 0; 1583 static if(writeId){ writeBigEndianUbyte(ID); } 1584 writeBytes(varlong.encode(entityId)); 1585 writeLittleEndianFloat(position.x); writeLittleEndianFloat(position.y); writeLittleEndianFloat(position.z); 1586 writeLittleEndianFloat(pitch); 1587 writeLittleEndianFloat(headYaw); 1588 writeLittleEndianFloat(yaw); 1589 writeBigEndianUbyte(animation); 1590 writeBigEndianBool(onGround); 1591 writeBytes(varlong.encode(unknown7)); 1592 if(animation==3){ writeLittleEndianInt(unknown8); } 1593 if(animation==3){ writeLittleEndianInt(unknown9); } 1594 return _buffer; 1595 } 1596 1597 public pure nothrow @safe void decode(bool readId=true)() { 1598 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 1599 entityId=varlong.decode(_buffer, &_index); 1600 position.x=readLittleEndianFloat(); position.y=readLittleEndianFloat(); position.z=readLittleEndianFloat(); 1601 pitch=readLittleEndianFloat(); 1602 headYaw=readLittleEndianFloat(); 1603 yaw=readLittleEndianFloat(); 1604 animation=readBigEndianUbyte(); 1605 onGround=readBigEndianBool(); 1606 unknown7=varlong.decode(_buffer, &_index); 1607 if(animation==3){ unknown8=readLittleEndianInt(); } 1608 if(animation==3){ unknown9=readLittleEndianInt(); } 1609 } 1610 1611 public static pure nothrow @safe MovePlayer fromBuffer(bool readId=true)(ubyte[] buffer) { 1612 MovePlayer ret = new MovePlayer(); 1613 ret._buffer = buffer; 1614 ret.decode!readId(); 1615 return ret; 1616 } 1617 1618 public override string toString() { 1619 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) ~ ", unknown7: " ~ std.conv.to!string(this.unknown7) ~ ", unknown8: " ~ std.conv.to!string(this.unknown8) ~ ", unknown9: " ~ std.conv.to!string(this.unknown9) ~ ")"; 1620 } 1621 1622 } 1623 1624 class RiderJump : Buffer { 1625 1626 public enum ubyte ID = 20; 1627 1628 public enum bool CLIENTBOUND = true; 1629 public enum bool SERVERBOUND = true; 1630 1631 public enum string[] FIELDS = ["rider"]; 1632 1633 public long rider; 1634 1635 public pure nothrow @safe @nogc this() {} 1636 1637 public pure nothrow @safe @nogc this(long rider) { 1638 this.rider = rider; 1639 } 1640 1641 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 1642 _buffer.length = 0; 1643 static if(writeId){ writeBigEndianUbyte(ID); } 1644 writeBytes(varlong.encode(rider)); 1645 return _buffer; 1646 } 1647 1648 public pure nothrow @safe void decode(bool readId=true)() { 1649 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 1650 rider=varlong.decode(_buffer, &_index); 1651 } 1652 1653 public static pure nothrow @safe RiderJump fromBuffer(bool readId=true)(ubyte[] buffer) { 1654 RiderJump ret = new RiderJump(); 1655 ret._buffer = buffer; 1656 ret.decode!readId(); 1657 return ret; 1658 } 1659 1660 public override string toString() { 1661 return "RiderJump(rider: " ~ std.conv.to!string(this.rider) ~ ")"; 1662 } 1663 1664 } 1665 1666 /** 1667 * Instantly removes a block, either because the player is in creative mode or because 1668 * the target block's hardness is 0 or lower (after all enchantments are applied). 1669 */ 1670 class RemoveBlock : Buffer { 1671 1672 public enum ubyte ID = 21; 1673 1674 public enum bool CLIENTBOUND = false; 1675 public enum bool SERVERBOUND = true; 1676 1677 public enum string[] FIELDS = ["position"]; 1678 1679 public sul.protocol.pocket113.types.BlockPosition position; 1680 1681 public pure nothrow @safe @nogc this() {} 1682 1683 public pure nothrow @safe @nogc this(sul.protocol.pocket113.types.BlockPosition position) { 1684 this.position = position; 1685 } 1686 1687 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 1688 _buffer.length = 0; 1689 static if(writeId){ writeBigEndianUbyte(ID); } 1690 position.encode(bufferInstance); 1691 return _buffer; 1692 } 1693 1694 public pure nothrow @safe void decode(bool readId=true)() { 1695 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 1696 position.decode(bufferInstance); 1697 } 1698 1699 public static pure nothrow @safe RemoveBlock fromBuffer(bool readId=true)(ubyte[] buffer) { 1700 RemoveBlock ret = new RemoveBlock(); 1701 ret._buffer = buffer; 1702 ret.decode!readId(); 1703 return ret; 1704 } 1705 1706 public override string toString() { 1707 return "RemoveBlock(position: " ~ std.conv.to!string(this.position) ~ ")"; 1708 } 1709 1710 } 1711 1712 class UpdateBlock : Buffer { 1713 1714 public enum ubyte ID = 22; 1715 1716 public enum bool CLIENTBOUND = true; 1717 public enum bool SERVERBOUND = false; 1718 1719 // flags and meta 1720 public enum uint NEIGHBORS = 1; 1721 public enum uint NETWORK = 2; 1722 public enum uint NO_GRAPHIC = 4; 1723 public enum uint PRIORITY = 8; 1724 1725 public enum string[] FIELDS = ["position", "block", "flagsAndMeta"]; 1726 1727 public sul.protocol.pocket113.types.BlockPosition position; 1728 public uint block; 1729 public uint flagsAndMeta; 1730 1731 public pure nothrow @safe @nogc this() {} 1732 1733 public pure nothrow @safe @nogc this(sul.protocol.pocket113.types.BlockPosition position, uint block=uint.init, uint flagsAndMeta=uint.init) { 1734 this.position = position; 1735 this.block = block; 1736 this.flagsAndMeta = flagsAndMeta; 1737 } 1738 1739 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 1740 _buffer.length = 0; 1741 static if(writeId){ writeBigEndianUbyte(ID); } 1742 position.encode(bufferInstance); 1743 writeBytes(varuint.encode(block)); 1744 writeBytes(varuint.encode(flagsAndMeta)); 1745 return _buffer; 1746 } 1747 1748 public pure nothrow @safe void decode(bool readId=true)() { 1749 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 1750 position.decode(bufferInstance); 1751 block=varuint.decode(_buffer, &_index); 1752 flagsAndMeta=varuint.decode(_buffer, &_index); 1753 } 1754 1755 public static pure nothrow @safe UpdateBlock fromBuffer(bool readId=true)(ubyte[] buffer) { 1756 UpdateBlock ret = new UpdateBlock(); 1757 ret._buffer = buffer; 1758 ret.decode!readId(); 1759 return ret; 1760 } 1761 1762 public override string toString() { 1763 return "UpdateBlock(position: " ~ std.conv.to!string(this.position) ~ ", block: " ~ std.conv.to!string(this.block) ~ ", flagsAndMeta: " ~ std.conv.to!string(this.flagsAndMeta) ~ ")"; 1764 } 1765 1766 } 1767 1768 /** 1769 * Spawns a painting entity in the world. 1770 */ 1771 class AddPainting : Buffer { 1772 1773 public enum ubyte ID = 23; 1774 1775 public enum bool CLIENTBOUND = true; 1776 public enum bool SERVERBOUND = false; 1777 1778 public enum string[] FIELDS = ["entityId", "runtimeId", "position", "direction", "title"]; 1779 1780 public long entityId; 1781 public long runtimeId; 1782 public sul.protocol.pocket113.types.BlockPosition position; 1783 public int direction; 1784 public string title; 1785 1786 public pure nothrow @safe @nogc this() {} 1787 1788 public pure nothrow @safe @nogc this(long entityId, long runtimeId=long.init, sul.protocol.pocket113.types.BlockPosition position=sul.protocol.pocket113.types.BlockPosition.init, int direction=int.init, string title=string.init) { 1789 this.entityId = entityId; 1790 this.runtimeId = runtimeId; 1791 this.position = position; 1792 this.direction = direction; 1793 this.title = title; 1794 } 1795 1796 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 1797 _buffer.length = 0; 1798 static if(writeId){ writeBigEndianUbyte(ID); } 1799 writeBytes(varlong.encode(entityId)); 1800 writeBytes(varlong.encode(runtimeId)); 1801 position.encode(bufferInstance); 1802 writeBytes(varint.encode(direction)); 1803 writeBytes(varuint.encode(cast(uint)title.length)); writeString(title); 1804 return _buffer; 1805 } 1806 1807 public pure nothrow @safe void decode(bool readId=true)() { 1808 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 1809 entityId=varlong.decode(_buffer, &_index); 1810 runtimeId=varlong.decode(_buffer, &_index); 1811 position.decode(bufferInstance); 1812 direction=varint.decode(_buffer, &_index); 1813 uint dlbu=varuint.decode(_buffer, &_index); title=readString(dlbu); 1814 } 1815 1816 public static pure nothrow @safe AddPainting fromBuffer(bool readId=true)(ubyte[] buffer) { 1817 AddPainting ret = new AddPainting(); 1818 ret._buffer = buffer; 1819 ret.decode!readId(); 1820 return ret; 1821 } 1822 1823 public override string toString() { 1824 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) ~ ")"; 1825 } 1826 1827 } 1828 1829 class Explode : Buffer { 1830 1831 public enum ubyte ID = 24; 1832 1833 public enum bool CLIENTBOUND = true; 1834 public enum bool SERVERBOUND = false; 1835 1836 public enum string[] FIELDS = ["position", "radius", "destroyedBlocks"]; 1837 1838 public Tuple!(float, "x", float, "y", float, "z") position; 1839 public float radius; 1840 public sul.protocol.pocket113.types.BlockPosition[] destroyedBlocks; 1841 1842 public pure nothrow @safe @nogc this() {} 1843 1844 public pure nothrow @safe @nogc this(Tuple!(float, "x", float, "y", float, "z") position, float radius=float.init, sul.protocol.pocket113.types.BlockPosition[] destroyedBlocks=(sul.protocol.pocket113.types.BlockPosition[]).init) { 1845 this.position = position; 1846 this.radius = radius; 1847 this.destroyedBlocks = destroyedBlocks; 1848 } 1849 1850 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 1851 _buffer.length = 0; 1852 static if(writeId){ writeBigEndianUbyte(ID); } 1853 writeLittleEndianFloat(position.x); writeLittleEndianFloat(position.y); writeLittleEndianFloat(position.z); 1854 writeLittleEndianFloat(radius); 1855 writeBytes(varuint.encode(cast(uint)destroyedBlocks.length)); foreach(zvdjevqx;destroyedBlocks){ zvdjevqx.encode(bufferInstance); } 1856 return _buffer; 1857 } 1858 1859 public pure nothrow @safe void decode(bool readId=true)() { 1860 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 1861 position.x=readLittleEndianFloat(); position.y=readLittleEndianFloat(); position.z=readLittleEndianFloat(); 1862 radius=readLittleEndianFloat(); 1863 destroyedBlocks.length=varuint.decode(_buffer, &_index); foreach(ref zvdjevqx;destroyedBlocks){ zvdjevqx.decode(bufferInstance); } 1864 } 1865 1866 public static pure nothrow @safe Explode fromBuffer(bool readId=true)(ubyte[] buffer) { 1867 Explode ret = new Explode(); 1868 ret._buffer = buffer; 1869 ret.decode!readId(); 1870 return ret; 1871 } 1872 1873 public override string toString() { 1874 return "Explode(position: " ~ std.conv.to!string(this.position) ~ ", radius: " ~ std.conv.to!string(this.radius) ~ ", destroyedBlocks: " ~ std.conv.to!string(this.destroyedBlocks) ~ ")"; 1875 } 1876 1877 } 1878 1879 /** 1880 * Plays a sound at a certain position. 1881 */ 1882 class LevelSoundEvent : Buffer { 1883 1884 public enum ubyte ID = 25; 1885 1886 public enum bool CLIENTBOUND = true; 1887 public enum bool SERVERBOUND = true; 1888 1889 // sound 1890 public enum ubyte ITEM_USE_ON = 0; 1891 public enum ubyte HIT = 1; 1892 public enum ubyte STEP = 2; 1893 public enum ubyte JUMP = 3; 1894 public enum ubyte BREAK = 4; 1895 public enum ubyte PLACE = 5; 1896 public enum ubyte HEAVY_STEP = 6; 1897 public enum ubyte GALLOP = 7; 1898 public enum ubyte FALL = 8; 1899 public enum ubyte AMBIENT = 9; 1900 public enum ubyte AMBIENT_BABY = 10; 1901 public enum ubyte AMBIENT_IN_WATER = 11; 1902 public enum ubyte BREATHE = 12; 1903 public enum ubyte DEATH = 13; 1904 public enum ubyte DEATH_IN_WATER = 14; 1905 public enum ubyte DEATH_TO_ZOMBIE = 15; 1906 public enum ubyte HURT = 16; 1907 public enum ubyte HURT_IN_WATER = 17; 1908 public enum ubyte MAD = 18; 1909 public enum ubyte BOOST = 19; 1910 public enum ubyte BOW = 20; 1911 public enum ubyte SQUISH_BIG = 21; 1912 public enum ubyte SQUISH_SMALL = 22; 1913 public enum ubyte FALL_BIG = 23; 1914 public enum ubyte FALL_SMALL = 24; 1915 public enum ubyte SPLASH = 25; 1916 public enum ubyte FIZZ = 26; 1917 public enum ubyte FLAP = 27; 1918 public enum ubyte SWIM = 28; 1919 public enum ubyte DRINK = 29; 1920 public enum ubyte EAT = 30; 1921 public enum ubyte TAKEOFF = 31; 1922 public enum ubyte SHAKE = 32; 1923 public enum ubyte PLOP = 33; 1924 public enum ubyte LAND = 34; 1925 public enum ubyte SADDLE = 35; 1926 public enum ubyte ARMOR = 36; 1927 public enum ubyte ADD_CHEST = 37; 1928 public enum ubyte THROW = 38; 1929 public enum ubyte ATTACK = 39; 1930 public enum ubyte ATTACK_NODAMAGE = 40; 1931 public enum ubyte WARN = 41; 1932 public enum ubyte SHEAR = 42; 1933 public enum ubyte MILK = 43; 1934 public enum ubyte THUNDER = 44; 1935 public enum ubyte EXPLODE = 45; 1936 public enum ubyte FIRE = 46; 1937 public enum ubyte IGNITE = 47; 1938 public enum ubyte FUSE = 48; 1939 public enum ubyte STARE = 49; 1940 public enum ubyte SPAWN = 50; 1941 public enum ubyte SHOOT = 51; 1942 public enum ubyte BREAK_BLOCK = 52; 1943 public enum ubyte REMEDY = 53; 1944 public enum ubyte UNFECT = 54; 1945 public enum ubyte LEVELUP = 55; 1946 public enum ubyte BOW_HIT = 56; 1947 public enum ubyte BULLET_HIT = 57; 1948 public enum ubyte EXTINGUISH_FIRE = 58; 1949 public enum ubyte ITEM_FIZZ = 59; 1950 public enum ubyte CHEST_OPEN = 60; 1951 public enum ubyte CHEST_CLOSED = 61; 1952 public enum ubyte SHULKER_BOX_OPEN = 62; 1953 public enum ubyte SHULKER_BOX_CLOSE = 63; 1954 public enum ubyte POWER_ON = 64; 1955 public enum ubyte POWER_OFF = 65; 1956 public enum ubyte ATTACH = 66; 1957 public enum ubyte DETACH = 67; 1958 public enum ubyte DENY = 68; 1959 public enum ubyte TRIPOD = 69; 1960 public enum ubyte POP = 70; 1961 public enum ubyte DROP_SLOT = 71; 1962 public enum ubyte NOTE = 72; 1963 public enum ubyte THORNS = 73; 1964 public enum ubyte PISTON_IN = 74; 1965 public enum ubyte PISTON_OUT = 75; 1966 public enum ubyte PORTAL = 76; 1967 public enum ubyte WATER = 77; 1968 public enum ubyte LAVA_POP = 78; 1969 public enum ubyte LAVA = 79; 1970 public enum ubyte BURP = 80; 1971 public enum ubyte BUCKET_FILL_WATER = 81; 1972 public enum ubyte BUCKET_FILL_LAVA = 82; 1973 public enum ubyte BUCKET_EMPTY_WATER = 83; 1974 public enum ubyte BUCKET_EMPTY_LAVA = 84; 1975 public enum ubyte GUARDIAN_FLOP = 85; 1976 public enum ubyte ELDERGUARDIAN_CURSE = 86; 1977 public enum ubyte MOB_WARNING = 87; 1978 public enum ubyte MOB_WARNING_BABY = 88; 1979 public enum ubyte TELEPORT = 89; 1980 public enum ubyte SHULKER_OPEN = 90; 1981 public enum ubyte SHULKER_CLOSE = 91; 1982 public enum ubyte HAGGLE = 92; 1983 public enum ubyte HAGGLE_YES = 93; 1984 public enum ubyte HAGGLE_NO = 94; 1985 public enum ubyte HAGGLE_IDLE = 95; 1986 public enum ubyte CHORUS_GROW = 96; 1987 public enum ubyte CHORUS_DEATH = 97; 1988 public enum ubyte GLASS = 98; 1989 public enum ubyte CAST_SPELL = 99; 1990 public enum ubyte PREPARE_ATTACK = 100; 1991 public enum ubyte PREPARE_SUMMON = 101; 1992 public enum ubyte PREPARE_WOLOLO = 102; 1993 public enum ubyte FANG = 103; 1994 public enum ubyte CHARGE = 104; 1995 public enum ubyte TAKE_PICTURE = 105; 1996 public enum ubyte DEFAULT = 106; 1997 public enum ubyte UNDEFINED = 107; 1998 1999 public enum string[] FIELDS = ["sound", "position", "volume", "pitch", "unknown4"]; 2000 2001 public ubyte sound; 2002 2003 /** 2004 * Position where the sound was generated. The closer to the player the more intense 2005 * will be on the client. 2006 */ 2007 public Tuple!(float, "x", float, "y", float, "z") position; 2008 public uint volume; 2009 public int pitch; 2010 public bool unknown4; 2011 2012 public pure nothrow @safe @nogc this() {} 2013 2014 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) { 2015 this.sound = sound; 2016 this.position = position; 2017 this.volume = volume; 2018 this.pitch = pitch; 2019 this.unknown4 = unknown4; 2020 } 2021 2022 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 2023 _buffer.length = 0; 2024 static if(writeId){ writeBigEndianUbyte(ID); } 2025 writeBigEndianUbyte(sound); 2026 writeLittleEndianFloat(position.x); writeLittleEndianFloat(position.y); writeLittleEndianFloat(position.z); 2027 writeBytes(varuint.encode(volume)); 2028 writeBytes(varint.encode(pitch)); 2029 writeBigEndianBool(unknown4); 2030 return _buffer; 2031 } 2032 2033 public pure nothrow @safe void decode(bool readId=true)() { 2034 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 2035 sound=readBigEndianUbyte(); 2036 position.x=readLittleEndianFloat(); position.y=readLittleEndianFloat(); position.z=readLittleEndianFloat(); 2037 volume=varuint.decode(_buffer, &_index); 2038 pitch=varint.decode(_buffer, &_index); 2039 unknown4=readBigEndianBool(); 2040 } 2041 2042 public static pure nothrow @safe LevelSoundEvent fromBuffer(bool readId=true)(ubyte[] buffer) { 2043 LevelSoundEvent ret = new LevelSoundEvent(); 2044 ret._buffer = buffer; 2045 ret.decode!readId(); 2046 return ret; 2047 } 2048 2049 public override string toString() { 2050 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) ~ ")"; 2051 } 2052 2053 } 2054 2055 class LevelEvent : Buffer { 2056 2057 public enum ubyte ID = 26; 2058 2059 public enum bool CLIENTBOUND = true; 2060 public enum bool SERVERBOUND = false; 2061 2062 // event id 2063 public enum int START_RAIN = 3001; 2064 public enum int START_THUNDER = 3002; 2065 public enum int STOP_RAIN = 3003; 2066 public enum int STOP_THUNDER = 3004; 2067 public enum int START_BLOCK_BREAK = 3600; 2068 public enum int STOP_BLOCK_BREAK = 3601; 2069 public enum int SET_DATA = 4000; 2070 public enum int PLAYERS_SLEEPING = 9800; 2071 public enum int PARTICLE_BUBBLE = 16385; 2072 public enum int PARTICLE_CRITICAL = 16386; 2073 public enum int PARTICLE_BLOCK_FORCE_FIELD = 16387; 2074 public enum int PARTICLE_SMOKE = 16388; 2075 public enum int PARTICLE_EXPLODE = 16389; 2076 public enum int PARTICLE_EVAPORATION = 16390; 2077 public enum int PARTICLE_FLAME = 16391; 2078 public enum int PARTICLE_LAVA = 16392; 2079 public enum int PARTICLE_LARGE_SMOKE = 16393; 2080 public enum int PARTICLE_REDSTONE = 16394; 2081 public enum int PARTICLE_RISING_RED_DUST = 16395; 2082 public enum int PARTICLE_ITEM_BREAK = 16396; 2083 public enum int PARTICLE_SNOWBALL_POOF = 16397; 2084 public enum int PARTICLE_HUGE_EXPLODE = 16398; 2085 public enum int PARTICLE_HUGE_EXPLODE_SEED = 16399; 2086 public enum int PARTICLE_MOB_FLAME = 16400; 2087 public enum int PARTICLE_HEART = 16401; 2088 public enum int PARTICLE_TERRAIN = 16402; 2089 public enum int PARTICLE_TOWN_AURA = 16403; 2090 public enum int PARTICLE_PORTAL = 16404; 2091 public enum int PARTICLE_WATER_SPLASH = 16405; 2092 public enum int PARTICLE_WATER_WAKE = 16406; 2093 public enum int PARTICLE_DRIP_WATER = 16407; 2094 public enum int PARTICLE_DRIP_LAVA = 16408; 2095 public enum int PARTICLE_FALLING_DUST = 16409; 2096 public enum int PARTICLE_MOB_SPELL = 16410; 2097 public enum int PARTICLE_MOB_SPELL_AMBIENT = 16411; 2098 public enum int PARTICLE_MOB_SPELL_INSTANTANEOUS = 16412; 2099 public enum int PARTICLE_INK = 16413; 2100 public enum int PARTICLE_SLIME = 16414; 2101 public enum int PARTICLE_RAIN_SPLASH = 16415; 2102 public enum int PARTICLE_VILLAGER_ANGRY = 16416; 2103 public enum int PARTICLE_VILLAGER_HAPPY = 16417; 2104 public enum int PARTICLE_ENCHANTMENT_TABLE = 16418; 2105 public enum int PARTICLE_TRACKING_EMITTER = 16419; 2106 public enum int PARTICLE_NOTE = 16420; 2107 public enum int PARTICLE_WITCH_SPELL = 16421; 2108 public enum int PARTICLE_CARROT = 16422; 2109 public enum int PARTICLE_END_ROD = 16424; 2110 public enum int PARTICLE_DRAGON_BREATH = 16425; 2111 public enum int PARTICLE_SHOOT = 2000; 2112 public enum int PARTICLE_DESTROY = 2001; 2113 public enum int PARTICLE_SPLASH = 2002; 2114 public enum int PARTICLE_EYE_DESPAWN = 2003; 2115 public enum int PARTICLE_SPAWN = 2004; 2116 2117 public enum string[] FIELDS = ["eventId", "position", "data"]; 2118 2119 public int eventId; 2120 public Tuple!(float, "x", float, "y", float, "z") position; 2121 public int data; 2122 2123 public pure nothrow @safe @nogc this() {} 2124 2125 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) { 2126 this.eventId = eventId; 2127 this.position = position; 2128 this.data = data; 2129 } 2130 2131 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 2132 _buffer.length = 0; 2133 static if(writeId){ writeBigEndianUbyte(ID); } 2134 writeBytes(varint.encode(eventId)); 2135 writeLittleEndianFloat(position.x); writeLittleEndianFloat(position.y); writeLittleEndianFloat(position.z); 2136 writeBytes(varint.encode(data)); 2137 return _buffer; 2138 } 2139 2140 public pure nothrow @safe void decode(bool readId=true)() { 2141 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 2142 eventId=varint.decode(_buffer, &_index); 2143 position.x=readLittleEndianFloat(); position.y=readLittleEndianFloat(); position.z=readLittleEndianFloat(); 2144 data=varint.decode(_buffer, &_index); 2145 } 2146 2147 public static pure nothrow @safe LevelEvent fromBuffer(bool readId=true)(ubyte[] buffer) { 2148 LevelEvent ret = new LevelEvent(); 2149 ret._buffer = buffer; 2150 ret.decode!readId(); 2151 return ret; 2152 } 2153 2154 public override string toString() { 2155 return "LevelEvent(eventId: " ~ std.conv.to!string(this.eventId) ~ ", position: " ~ std.conv.to!string(this.position) ~ ", data: " ~ std.conv.to!string(this.data) ~ ")"; 2156 } 2157 2158 } 2159 2160 class BlockEvent : Buffer { 2161 2162 public enum ubyte ID = 27; 2163 2164 public enum bool CLIENTBOUND = true; 2165 public enum bool SERVERBOUND = false; 2166 2167 public enum string[] FIELDS = ["position", "data"]; 2168 2169 public sul.protocol.pocket113.types.BlockPosition position; 2170 public int[2] data; 2171 2172 public pure nothrow @safe @nogc this() {} 2173 2174 public pure nothrow @safe @nogc this(sul.protocol.pocket113.types.BlockPosition position, int[2] data=(int[2]).init) { 2175 this.position = position; 2176 this.data = data; 2177 } 2178 2179 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 2180 _buffer.length = 0; 2181 static if(writeId){ writeBigEndianUbyte(ID); } 2182 position.encode(bufferInstance); 2183 foreach(zfy;data){ writeBytes(varint.encode(zfy)); } 2184 return _buffer; 2185 } 2186 2187 public pure nothrow @safe void decode(bool readId=true)() { 2188 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 2189 position.decode(bufferInstance); 2190 foreach(ref zfy;data){ zfy=varint.decode(_buffer, &_index); } 2191 } 2192 2193 public static pure nothrow @safe BlockEvent fromBuffer(bool readId=true)(ubyte[] buffer) { 2194 BlockEvent ret = new BlockEvent(); 2195 ret._buffer = buffer; 2196 ret.decode!readId(); 2197 return ret; 2198 } 2199 2200 public override string toString() { 2201 return "BlockEvent(position: " ~ std.conv.to!string(this.position) ~ ", data: " ~ std.conv.to!string(this.data) ~ ")"; 2202 } 2203 2204 } 2205 2206 class EntityEvent : Buffer { 2207 2208 public enum ubyte ID = 28; 2209 2210 public enum bool CLIENTBOUND = true; 2211 public enum bool SERVERBOUND = true; 2212 2213 // event id 2214 public enum ubyte HURT_ANIMATION = 2; 2215 public enum ubyte DEATH_ANIMATION = 3; 2216 public enum ubyte TAME_FAIL = 6; 2217 public enum ubyte TAME_SUCCESS = 7; 2218 public enum ubyte SHAKE_WET = 8; 2219 public enum ubyte USE_ITEM = 9; 2220 public enum ubyte EAT_GRASS_ANIMATION = 10; 2221 public enum ubyte FISH_HOOK_BUBBLES = 11; 2222 public enum ubyte FISH_HOOK_POSITION = 12; 2223 public enum ubyte FISH_HOOK_HOOK = 13; 2224 public enum ubyte FISH_HOOK_TEASE = 14; 2225 public enum ubyte SQUID_INK_CLOUD = 15; 2226 public enum ubyte AMBIENT_SOUND = 16; 2227 public enum ubyte RESPAWN = 17; 2228 2229 public enum string[] FIELDS = ["entityId", "eventId", "unknown2"]; 2230 2231 public long entityId; 2232 public ubyte eventId; 2233 public int unknown2; 2234 2235 public pure nothrow @safe @nogc this() {} 2236 2237 public pure nothrow @safe @nogc this(long entityId, ubyte eventId=ubyte.init, int unknown2=int.init) { 2238 this.entityId = entityId; 2239 this.eventId = eventId; 2240 this.unknown2 = unknown2; 2241 } 2242 2243 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 2244 _buffer.length = 0; 2245 static if(writeId){ writeBigEndianUbyte(ID); } 2246 writeBytes(varlong.encode(entityId)); 2247 writeBigEndianUbyte(eventId); 2248 writeBytes(varint.encode(unknown2)); 2249 return _buffer; 2250 } 2251 2252 public pure nothrow @safe void decode(bool readId=true)() { 2253 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 2254 entityId=varlong.decode(_buffer, &_index); 2255 eventId=readBigEndianUbyte(); 2256 unknown2=varint.decode(_buffer, &_index); 2257 } 2258 2259 public static pure nothrow @safe EntityEvent fromBuffer(bool readId=true)(ubyte[] buffer) { 2260 EntityEvent ret = new EntityEvent(); 2261 ret._buffer = buffer; 2262 ret.decode!readId(); 2263 return ret; 2264 } 2265 2266 public override string toString() { 2267 return "EntityEvent(entityId: " ~ std.conv.to!string(this.entityId) ~ ", eventId: " ~ std.conv.to!string(this.eventId) ~ ", unknown2: " ~ std.conv.to!string(this.unknown2) ~ ")"; 2268 } 2269 2270 } 2271 2272 class MobEffect : Buffer { 2273 2274 public enum ubyte ID = 29; 2275 2276 public enum bool CLIENTBOUND = true; 2277 public enum bool SERVERBOUND = false; 2278 2279 // event id 2280 public enum ubyte ADD = 1; 2281 public enum ubyte MODIFY = 2; 2282 public enum ubyte REMOVE = 3; 2283 2284 public enum string[] FIELDS = ["entityId", "eventId", "effect", "amplifier", "particles", "duration"]; 2285 2286 public long entityId; 2287 public ubyte eventId; 2288 public int effect; 2289 public int amplifier; 2290 public bool particles; 2291 public int duration; 2292 2293 public pure nothrow @safe @nogc this() {} 2294 2295 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) { 2296 this.entityId = entityId; 2297 this.eventId = eventId; 2298 this.effect = effect; 2299 this.amplifier = amplifier; 2300 this.particles = particles; 2301 this.duration = duration; 2302 } 2303 2304 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 2305 _buffer.length = 0; 2306 static if(writeId){ writeBigEndianUbyte(ID); } 2307 writeBytes(varlong.encode(entityId)); 2308 writeBigEndianUbyte(eventId); 2309 writeBytes(varint.encode(effect)); 2310 writeBytes(varint.encode(amplifier)); 2311 writeBigEndianBool(particles); 2312 writeBytes(varint.encode(duration)); 2313 return _buffer; 2314 } 2315 2316 public pure nothrow @safe void decode(bool readId=true)() { 2317 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 2318 entityId=varlong.decode(_buffer, &_index); 2319 eventId=readBigEndianUbyte(); 2320 effect=varint.decode(_buffer, &_index); 2321 amplifier=varint.decode(_buffer, &_index); 2322 particles=readBigEndianBool(); 2323 duration=varint.decode(_buffer, &_index); 2324 } 2325 2326 public static pure nothrow @safe MobEffect fromBuffer(bool readId=true)(ubyte[] buffer) { 2327 MobEffect ret = new MobEffect(); 2328 ret._buffer = buffer; 2329 ret.decode!readId(); 2330 return ret; 2331 } 2332 2333 public override string toString() { 2334 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) ~ ")"; 2335 } 2336 2337 } 2338 2339 /** 2340 * Updates an entity's attributes. This packet should be used when a value must be 2341 * modified but it cannot be done using another packet (for example controlling the 2342 * player's experience and level). 2343 */ 2344 class UpdateAttributes : Buffer { 2345 2346 public enum ubyte ID = 30; 2347 2348 public enum bool CLIENTBOUND = true; 2349 public enum bool SERVERBOUND = false; 2350 2351 public enum string[] FIELDS = ["entityId", "attributes"]; 2352 2353 public long entityId; 2354 public sul.protocol.pocket113.types.Attribute[] attributes; 2355 2356 public pure nothrow @safe @nogc this() {} 2357 2358 public pure nothrow @safe @nogc this(long entityId, sul.protocol.pocket113.types.Attribute[] attributes=(sul.protocol.pocket113.types.Attribute[]).init) { 2359 this.entityId = entityId; 2360 this.attributes = attributes; 2361 } 2362 2363 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 2364 _buffer.length = 0; 2365 static if(writeId){ writeBigEndianUbyte(ID); } 2366 writeBytes(varlong.encode(entityId)); 2367 writeBytes(varuint.encode(cast(uint)attributes.length)); foreach(yrcldrc;attributes){ yrcldrc.encode(bufferInstance); } 2368 return _buffer; 2369 } 2370 2371 public pure nothrow @safe void decode(bool readId=true)() { 2372 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 2373 entityId=varlong.decode(_buffer, &_index); 2374 attributes.length=varuint.decode(_buffer, &_index); foreach(ref yrcldrc;attributes){ yrcldrc.decode(bufferInstance); } 2375 } 2376 2377 public static pure nothrow @safe UpdateAttributes fromBuffer(bool readId=true)(ubyte[] buffer) { 2378 UpdateAttributes ret = new UpdateAttributes(); 2379 ret._buffer = buffer; 2380 ret.decode!readId(); 2381 return ret; 2382 } 2383 2384 public override string toString() { 2385 return "UpdateAttributes(entityId: " ~ std.conv.to!string(this.entityId) ~ ", attributes: " ~ std.conv.to!string(this.attributes) ~ ")"; 2386 } 2387 2388 } 2389 2390 /** 2391 * Sent when the client puts an item in its hotbar or selects a new hotbar slot. 2392 */ 2393 class MobEquipment : Buffer { 2394 2395 public enum ubyte ID = 31; 2396 2397 public enum bool CLIENTBOUND = true; 2398 public enum bool SERVERBOUND = true; 2399 2400 public enum string[] FIELDS = ["entityId", "item", "inventorySlot", "hotbarSlot", "unknown4"]; 2401 2402 public long entityId; 2403 public sul.protocol.pocket113.types.Slot item; 2404 2405 /** 2406 * Slot of the inventory where the item is. The hotbat slots (0-8) are not counted. 2407 * 255 means that a generic empty slot has been selected. 2408 */ 2409 public ubyte inventorySlot; 2410 2411 /** 2412 * Slot of the hotbar where the item is being moved. 2413 */ 2414 public ubyte hotbarSlot; 2415 public ubyte unknown4; 2416 2417 public pure nothrow @safe @nogc this() {} 2418 2419 public pure nothrow @safe @nogc this(long entityId, sul.protocol.pocket113.types.Slot item=sul.protocol.pocket113.types.Slot.init, ubyte inventorySlot=ubyte.init, ubyte hotbarSlot=ubyte.init, ubyte unknown4=ubyte.init) { 2420 this.entityId = entityId; 2421 this.item = item; 2422 this.inventorySlot = inventorySlot; 2423 this.hotbarSlot = hotbarSlot; 2424 this.unknown4 = unknown4; 2425 } 2426 2427 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 2428 _buffer.length = 0; 2429 static if(writeId){ writeBigEndianUbyte(ID); } 2430 writeBytes(varlong.encode(entityId)); 2431 item.encode(bufferInstance); 2432 writeBigEndianUbyte(inventorySlot); 2433 writeBigEndianUbyte(hotbarSlot); 2434 writeBigEndianUbyte(unknown4); 2435 return _buffer; 2436 } 2437 2438 public pure nothrow @safe void decode(bool readId=true)() { 2439 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 2440 entityId=varlong.decode(_buffer, &_index); 2441 item.decode(bufferInstance); 2442 inventorySlot=readBigEndianUbyte(); 2443 hotbarSlot=readBigEndianUbyte(); 2444 unknown4=readBigEndianUbyte(); 2445 } 2446 2447 public static pure nothrow @safe MobEquipment fromBuffer(bool readId=true)(ubyte[] buffer) { 2448 MobEquipment ret = new MobEquipment(); 2449 ret._buffer = buffer; 2450 ret.decode!readId(); 2451 return ret; 2452 } 2453 2454 public override string toString() { 2455 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) ~ ")"; 2456 } 2457 2458 } 2459 2460 class MobArmorEquipment : Buffer { 2461 2462 public enum ubyte ID = 32; 2463 2464 public enum bool CLIENTBOUND = true; 2465 public enum bool SERVERBOUND = true; 2466 2467 public enum string[] FIELDS = ["entityId", "armor"]; 2468 2469 public long entityId; 2470 public sul.protocol.pocket113.types.Slot[4] armor; 2471 2472 public pure nothrow @safe @nogc this() {} 2473 2474 public pure nothrow @safe @nogc this(long entityId, sul.protocol.pocket113.types.Slot[4] armor=(sul.protocol.pocket113.types.Slot[4]).init) { 2475 this.entityId = entityId; 2476 this.armor = armor; 2477 } 2478 2479 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 2480 _buffer.length = 0; 2481 static if(writeId){ writeBigEndianUbyte(ID); } 2482 writeBytes(varlong.encode(entityId)); 2483 foreach(yjbi;armor){ yjbi.encode(bufferInstance); } 2484 return _buffer; 2485 } 2486 2487 public pure nothrow @safe void decode(bool readId=true)() { 2488 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 2489 entityId=varlong.decode(_buffer, &_index); 2490 foreach(ref yjbi;armor){ yjbi.decode(bufferInstance); } 2491 } 2492 2493 public static pure nothrow @safe MobArmorEquipment fromBuffer(bool readId=true)(ubyte[] buffer) { 2494 MobArmorEquipment ret = new MobArmorEquipment(); 2495 ret._buffer = buffer; 2496 ret.decode!readId(); 2497 return ret; 2498 } 2499 2500 public override string toString() { 2501 return "MobArmorEquipment(entityId: " ~ std.conv.to!string(this.entityId) ~ ", armor: " ~ std.conv.to!string(this.armor) ~ ")"; 2502 } 2503 2504 } 2505 2506 class Interact : Buffer { 2507 2508 public enum ubyte ID = 33; 2509 2510 public enum bool CLIENTBOUND = false; 2511 public enum bool SERVERBOUND = true; 2512 2513 // action 2514 public enum ubyte ATTACK = 1; 2515 public enum ubyte INTERACT = 2; 2516 public enum ubyte LEAVE_VEHICLE = 3; 2517 public enum ubyte HOVER = 4; 2518 2519 public enum string[] FIELDS = ["action", "target"]; 2520 2521 public ubyte action; 2522 public long target; 2523 2524 public pure nothrow @safe @nogc this() {} 2525 2526 public pure nothrow @safe @nogc this(ubyte action, long target=long.init) { 2527 this.action = action; 2528 this.target = target; 2529 } 2530 2531 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 2532 _buffer.length = 0; 2533 static if(writeId){ writeBigEndianUbyte(ID); } 2534 writeBigEndianUbyte(action); 2535 writeBytes(varlong.encode(target)); 2536 return _buffer; 2537 } 2538 2539 public pure nothrow @safe void decode(bool readId=true)() { 2540 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 2541 action=readBigEndianUbyte(); 2542 target=varlong.decode(_buffer, &_index); 2543 } 2544 2545 public static pure nothrow @safe Interact fromBuffer(bool readId=true)(ubyte[] buffer) { 2546 Interact ret = new Interact(); 2547 ret._buffer = buffer; 2548 ret.decode!readId(); 2549 return ret; 2550 } 2551 2552 public override string toString() { 2553 return "Interact(action: " ~ std.conv.to!string(this.action) ~ ", target: " ~ std.conv.to!string(this.target) ~ ")"; 2554 } 2555 2556 } 2557 2558 class BlockPickRequest : Buffer { 2559 2560 public enum ubyte ID = 34; 2561 2562 public enum bool CLIENTBOUND = false; 2563 public enum bool SERVERBOUND = true; 2564 2565 public enum string[] FIELDS = ["position", "slot"]; 2566 2567 public Tuple!(int, "x", int, "y", int, "z") position; 2568 public ubyte slot; 2569 2570 public pure nothrow @safe @nogc this() {} 2571 2572 public pure nothrow @safe @nogc this(Tuple!(int, "x", int, "y", int, "z") position, ubyte slot=ubyte.init) { 2573 this.position = position; 2574 this.slot = slot; 2575 } 2576 2577 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 2578 _buffer.length = 0; 2579 static if(writeId){ writeBigEndianUbyte(ID); } 2580 writeBytes(varint.encode(position.x)); writeBytes(varint.encode(position.y)); writeBytes(varint.encode(position.z)); 2581 writeBigEndianUbyte(slot); 2582 return _buffer; 2583 } 2584 2585 public pure nothrow @safe void decode(bool readId=true)() { 2586 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 2587 position.x=varint.decode(_buffer, &_index); position.y=varint.decode(_buffer, &_index); position.z=varint.decode(_buffer, &_index); 2588 slot=readBigEndianUbyte(); 2589 } 2590 2591 public static pure nothrow @safe BlockPickRequest fromBuffer(bool readId=true)(ubyte[] buffer) { 2592 BlockPickRequest ret = new BlockPickRequest(); 2593 ret._buffer = buffer; 2594 ret.decode!readId(); 2595 return ret; 2596 } 2597 2598 public override string toString() { 2599 return "BlockPickRequest(position: " ~ std.conv.to!string(this.position) ~ ", slot: " ~ std.conv.to!string(this.slot) ~ ")"; 2600 } 2601 2602 } 2603 2604 class UseItem : Buffer { 2605 2606 public enum ubyte ID = 35; 2607 2608 public enum bool CLIENTBOUND = false; 2609 public enum bool SERVERBOUND = true; 2610 2611 public enum string[] FIELDS = ["blockPosition", "hotbarSlot", "face", "facePosition", "position", "slot", "item"]; 2612 2613 public sul.protocol.pocket113.types.BlockPosition blockPosition; 2614 public uint hotbarSlot; 2615 public int face; 2616 public Tuple!(float, "x", float, "y", float, "z") facePosition; 2617 public Tuple!(float, "x", float, "y", float, "z") position; 2618 public int slot; 2619 public sul.protocol.pocket113.types.Slot item; 2620 2621 public pure nothrow @safe @nogc this() {} 2622 2623 public pure nothrow @safe @nogc this(sul.protocol.pocket113.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.pocket113.types.Slot item=sul.protocol.pocket113.types.Slot.init) { 2624 this.blockPosition = blockPosition; 2625 this.hotbarSlot = hotbarSlot; 2626 this.face = face; 2627 this.facePosition = facePosition; 2628 this.position = position; 2629 this.slot = slot; 2630 this.item = item; 2631 } 2632 2633 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 2634 _buffer.length = 0; 2635 static if(writeId){ writeBigEndianUbyte(ID); } 2636 blockPosition.encode(bufferInstance); 2637 writeBytes(varuint.encode(hotbarSlot)); 2638 writeBytes(varint.encode(face)); 2639 writeLittleEndianFloat(facePosition.x); writeLittleEndianFloat(facePosition.y); writeLittleEndianFloat(facePosition.z); 2640 writeLittleEndianFloat(position.x); writeLittleEndianFloat(position.y); writeLittleEndianFloat(position.z); 2641 writeBytes(varint.encode(slot)); 2642 item.encode(bufferInstance); 2643 return _buffer; 2644 } 2645 2646 public pure nothrow @safe void decode(bool readId=true)() { 2647 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 2648 blockPosition.decode(bufferInstance); 2649 hotbarSlot=varuint.decode(_buffer, &_index); 2650 face=varint.decode(_buffer, &_index); 2651 facePosition.x=readLittleEndianFloat(); facePosition.y=readLittleEndianFloat(); facePosition.z=readLittleEndianFloat(); 2652 position.x=readLittleEndianFloat(); position.y=readLittleEndianFloat(); position.z=readLittleEndianFloat(); 2653 slot=varint.decode(_buffer, &_index); 2654 item.decode(bufferInstance); 2655 } 2656 2657 public static pure nothrow @safe UseItem fromBuffer(bool readId=true)(ubyte[] buffer) { 2658 UseItem ret = new UseItem(); 2659 ret._buffer = buffer; 2660 ret.decode!readId(); 2661 return ret; 2662 } 2663 2664 public override string toString() { 2665 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) ~ ")"; 2666 } 2667 2668 } 2669 2670 class PlayerAction : Buffer { 2671 2672 public enum ubyte ID = 36; 2673 2674 public enum bool CLIENTBOUND = false; 2675 public enum bool SERVERBOUND = true; 2676 2677 // action 2678 public enum int START_BREAK = 0; 2679 public enum int ABORT_BREAK = 1; 2680 public enum int STOP_BREAK = 2; 2681 public enum int RELEASE_ITEM = 5; 2682 public enum int STOP_SLEEPING = 6; 2683 public enum int RESPAWN = 7; 2684 public enum int JUMP = 8; 2685 public enum int START_SPRINT = 9; 2686 public enum int STOP_SPRINT = 10; 2687 public enum int START_SNEAK = 11; 2688 public enum int STOP_SNEAK = 12; 2689 public enum int START_GLIDING = 15; 2690 public enum int STOP_GLIDING = 16; 2691 public enum int CONTINUE_BREAK = 18; 2692 2693 public enum string[] FIELDS = ["entityId", "action", "position", "face"]; 2694 2695 public long entityId; 2696 public int action; 2697 public sul.protocol.pocket113.types.BlockPosition position; 2698 public int face; 2699 2700 public pure nothrow @safe @nogc this() {} 2701 2702 public pure nothrow @safe @nogc this(long entityId, int action=int.init, sul.protocol.pocket113.types.BlockPosition position=sul.protocol.pocket113.types.BlockPosition.init, int face=int.init) { 2703 this.entityId = entityId; 2704 this.action = action; 2705 this.position = position; 2706 this.face = face; 2707 } 2708 2709 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 2710 _buffer.length = 0; 2711 static if(writeId){ writeBigEndianUbyte(ID); } 2712 writeBytes(varlong.encode(entityId)); 2713 writeBytes(varint.encode(action)); 2714 position.encode(bufferInstance); 2715 writeBytes(varint.encode(face)); 2716 return _buffer; 2717 } 2718 2719 public pure nothrow @safe void decode(bool readId=true)() { 2720 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 2721 entityId=varlong.decode(_buffer, &_index); 2722 action=varint.decode(_buffer, &_index); 2723 position.decode(bufferInstance); 2724 face=varint.decode(_buffer, &_index); 2725 } 2726 2727 public static pure nothrow @safe PlayerAction fromBuffer(bool readId=true)(ubyte[] buffer) { 2728 PlayerAction ret = new PlayerAction(); 2729 ret._buffer = buffer; 2730 ret.decode!readId(); 2731 return ret; 2732 } 2733 2734 public override string toString() { 2735 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) ~ ")"; 2736 } 2737 2738 } 2739 2740 /** 2741 * Sent by the player when it falls from a distance that causes damage, that can be 2742 * influenced by its armour and its effects. 2743 */ 2744 class EntityFall : Buffer { 2745 2746 public enum ubyte ID = 37; 2747 2748 public enum bool CLIENTBOUND = false; 2749 public enum bool SERVERBOUND = true; 2750 2751 public enum string[] FIELDS = ["entityId", "distance", "unknown2"]; 2752 2753 public long entityId; 2754 2755 /** 2756 * Number of blocks the player has been in free falling before hitting the ground. 2757 */ 2758 public float distance; 2759 public bool unknown2; 2760 2761 public pure nothrow @safe @nogc this() {} 2762 2763 public pure nothrow @safe @nogc this(long entityId, float distance=float.init, bool unknown2=bool.init) { 2764 this.entityId = entityId; 2765 this.distance = distance; 2766 this.unknown2 = unknown2; 2767 } 2768 2769 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 2770 _buffer.length = 0; 2771 static if(writeId){ writeBigEndianUbyte(ID); } 2772 writeBytes(varlong.encode(entityId)); 2773 writeLittleEndianFloat(distance); 2774 writeBigEndianBool(unknown2); 2775 return _buffer; 2776 } 2777 2778 public pure nothrow @safe void decode(bool readId=true)() { 2779 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 2780 entityId=varlong.decode(_buffer, &_index); 2781 distance=readLittleEndianFloat(); 2782 unknown2=readBigEndianBool(); 2783 } 2784 2785 public static pure nothrow @safe EntityFall fromBuffer(bool readId=true)(ubyte[] buffer) { 2786 EntityFall ret = new EntityFall(); 2787 ret._buffer = buffer; 2788 ret.decode!readId(); 2789 return ret; 2790 } 2791 2792 public override string toString() { 2793 return "EntityFall(entityId: " ~ std.conv.to!string(this.entityId) ~ ", distance: " ~ std.conv.to!string(this.distance) ~ ", unknown2: " ~ std.conv.to!string(this.unknown2) ~ ")"; 2794 } 2795 2796 } 2797 2798 class HurtArmor : Buffer { 2799 2800 public enum ubyte ID = 38; 2801 2802 public enum bool CLIENTBOUND = true; 2803 public enum bool SERVERBOUND = false; 2804 2805 public enum string[] FIELDS = ["unknown0"]; 2806 2807 public int unknown0; 2808 2809 public pure nothrow @safe @nogc this() {} 2810 2811 public pure nothrow @safe @nogc this(int unknown0) { 2812 this.unknown0 = unknown0; 2813 } 2814 2815 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 2816 _buffer.length = 0; 2817 static if(writeId){ writeBigEndianUbyte(ID); } 2818 writeBytes(varint.encode(unknown0)); 2819 return _buffer; 2820 } 2821 2822 public pure nothrow @safe void decode(bool readId=true)() { 2823 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 2824 unknown0=varint.decode(_buffer, &_index); 2825 } 2826 2827 public static pure nothrow @safe HurtArmor fromBuffer(bool readId=true)(ubyte[] buffer) { 2828 HurtArmor ret = new HurtArmor(); 2829 ret._buffer = buffer; 2830 ret.decode!readId(); 2831 return ret; 2832 } 2833 2834 public override string toString() { 2835 return "HurtArmor(unknown0: " ~ std.conv.to!string(this.unknown0) ~ ")"; 2836 } 2837 2838 } 2839 2840 /** 2841 * Updates an entity's metadata. 2842 */ 2843 class SetEntityData : Buffer { 2844 2845 public enum ubyte ID = 39; 2846 2847 public enum bool CLIENTBOUND = true; 2848 public enum bool SERVERBOUND = false; 2849 2850 public enum string[] FIELDS = ["entityId", "metadata"]; 2851 2852 public long entityId; 2853 public Metadata metadata; 2854 2855 public pure nothrow @safe @nogc this() {} 2856 2857 public pure nothrow @safe @nogc this(long entityId, Metadata metadata=Metadata.init) { 2858 this.entityId = entityId; 2859 this.metadata = metadata; 2860 } 2861 2862 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 2863 _buffer.length = 0; 2864 static if(writeId){ writeBigEndianUbyte(ID); } 2865 writeBytes(varlong.encode(entityId)); 2866 metadata.encode(bufferInstance); 2867 return _buffer; 2868 } 2869 2870 public pure nothrow @safe void decode(bool readId=true)() { 2871 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 2872 entityId=varlong.decode(_buffer, &_index); 2873 metadata=Metadata.decode(bufferInstance); 2874 } 2875 2876 public static pure nothrow @safe SetEntityData fromBuffer(bool readId=true)(ubyte[] buffer) { 2877 SetEntityData ret = new SetEntityData(); 2878 ret._buffer = buffer; 2879 ret.decode!readId(); 2880 return ret; 2881 } 2882 2883 public override string toString() { 2884 return "SetEntityData(entityId: " ~ std.conv.to!string(this.entityId) ~ ", metadata: " ~ std.conv.to!string(this.metadata) ~ ")"; 2885 } 2886 2887 } 2888 2889 /** 2890 * Updates an entity's motion. 2891 */ 2892 class SetEntityMotion : Buffer { 2893 2894 public enum ubyte ID = 40; 2895 2896 public enum bool CLIENTBOUND = true; 2897 public enum bool SERVERBOUND = false; 2898 2899 public enum string[] FIELDS = ["entityId", "motion"]; 2900 2901 /** 2902 * Entity which motion is updated. If the entity id is the player's, its motion is 2903 * updated client-side and the player will send movement packets to the server (meaning 2904 * that the server has no physical calculations to do). If not an animation will be 2905 * done client-side but the server will have to calculate the new position applying 2906 * the item's movement rules. 2907 */ 2908 public long entityId; 2909 2910 /** 2911 * New motion for the entity that will influence its movement. 2912 */ 2913 public Tuple!(float, "x", float, "y", float, "z") motion; 2914 2915 public pure nothrow @safe @nogc this() {} 2916 2917 public pure nothrow @safe @nogc this(long entityId, Tuple!(float, "x", float, "y", float, "z") motion=Tuple!(float, "x", float, "y", float, "z").init) { 2918 this.entityId = entityId; 2919 this.motion = motion; 2920 } 2921 2922 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 2923 _buffer.length = 0; 2924 static if(writeId){ writeBigEndianUbyte(ID); } 2925 writeBytes(varlong.encode(entityId)); 2926 writeLittleEndianFloat(motion.x); writeLittleEndianFloat(motion.y); writeLittleEndianFloat(motion.z); 2927 return _buffer; 2928 } 2929 2930 public pure nothrow @safe void decode(bool readId=true)() { 2931 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 2932 entityId=varlong.decode(_buffer, &_index); 2933 motion.x=readLittleEndianFloat(); motion.y=readLittleEndianFloat(); motion.z=readLittleEndianFloat(); 2934 } 2935 2936 public static pure nothrow @safe SetEntityMotion fromBuffer(bool readId=true)(ubyte[] buffer) { 2937 SetEntityMotion ret = new SetEntityMotion(); 2938 ret._buffer = buffer; 2939 ret.decode!readId(); 2940 return ret; 2941 } 2942 2943 public override string toString() { 2944 return "SetEntityMotion(entityId: " ~ std.conv.to!string(this.entityId) ~ ", motion: " ~ std.conv.to!string(this.motion) ~ ")"; 2945 } 2946 2947 } 2948 2949 class SetEntityLink : Buffer { 2950 2951 public enum ubyte ID = 41; 2952 2953 public enum bool CLIENTBOUND = true; 2954 public enum bool SERVERBOUND = false; 2955 2956 // action 2957 public enum ubyte ADD = 0; 2958 public enum ubyte RIDE = 1; 2959 public enum ubyte REMOVE = 2; 2960 2961 public enum string[] FIELDS = ["from", "to", "action"]; 2962 2963 public long from; 2964 public long to; 2965 public ubyte action; 2966 2967 public pure nothrow @safe @nogc this() {} 2968 2969 public pure nothrow @safe @nogc this(long from, long to=long.init, ubyte action=ubyte.init) { 2970 this.from = from; 2971 this.to = to; 2972 this.action = action; 2973 } 2974 2975 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 2976 _buffer.length = 0; 2977 static if(writeId){ writeBigEndianUbyte(ID); } 2978 writeBytes(varlong.encode(from)); 2979 writeBytes(varlong.encode(to)); 2980 writeBigEndianUbyte(action); 2981 return _buffer; 2982 } 2983 2984 public pure nothrow @safe void decode(bool readId=true)() { 2985 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 2986 from=varlong.decode(_buffer, &_index); 2987 to=varlong.decode(_buffer, &_index); 2988 action=readBigEndianUbyte(); 2989 } 2990 2991 public static pure nothrow @safe SetEntityLink fromBuffer(bool readId=true)(ubyte[] buffer) { 2992 SetEntityLink ret = new SetEntityLink(); 2993 ret._buffer = buffer; 2994 ret.decode!readId(); 2995 return ret; 2996 } 2997 2998 public override string toString() { 2999 return "SetEntityLink(from: " ~ std.conv.to!string(this.from) ~ ", to: " ~ std.conv.to!string(this.to) ~ ", action: " ~ std.conv.to!string(this.action) ~ ")"; 3000 } 3001 3002 } 3003 3004 class SetHealth : Buffer { 3005 3006 public enum ubyte ID = 42; 3007 3008 public enum bool CLIENTBOUND = true; 3009 public enum bool SERVERBOUND = false; 3010 3011 public enum string[] FIELDS = ["health"]; 3012 3013 public int health; 3014 3015 public pure nothrow @safe @nogc this() {} 3016 3017 public pure nothrow @safe @nogc this(int health) { 3018 this.health = health; 3019 } 3020 3021 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 3022 _buffer.length = 0; 3023 static if(writeId){ writeBigEndianUbyte(ID); } 3024 writeBytes(varint.encode(health)); 3025 return _buffer; 3026 } 3027 3028 public pure nothrow @safe void decode(bool readId=true)() { 3029 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 3030 health=varint.decode(_buffer, &_index); 3031 } 3032 3033 public static pure nothrow @safe SetHealth fromBuffer(bool readId=true)(ubyte[] buffer) { 3034 SetHealth ret = new SetHealth(); 3035 ret._buffer = buffer; 3036 ret.decode!readId(); 3037 return ret; 3038 } 3039 3040 public override string toString() { 3041 return "SetHealth(health: " ~ std.conv.to!string(this.health) ~ ")"; 3042 } 3043 3044 } 3045 3046 class SetSpawnPosition : Buffer { 3047 3048 public enum ubyte ID = 43; 3049 3050 public enum bool CLIENTBOUND = true; 3051 public enum bool SERVERBOUND = false; 3052 3053 // type 3054 public enum int PLAYER_SPAWN = 0; 3055 public enum int WORLD_SPAWN = 1; 3056 3057 public enum string[] FIELDS = ["type", "position", "forced"]; 3058 3059 public int type; 3060 public sul.protocol.pocket113.types.BlockPosition position; 3061 public bool forced; 3062 3063 public pure nothrow @safe @nogc this() {} 3064 3065 public pure nothrow @safe @nogc this(int type, sul.protocol.pocket113.types.BlockPosition position=sul.protocol.pocket113.types.BlockPosition.init, bool forced=bool.init) { 3066 this.type = type; 3067 this.position = position; 3068 this.forced = forced; 3069 } 3070 3071 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 3072 _buffer.length = 0; 3073 static if(writeId){ writeBigEndianUbyte(ID); } 3074 writeBytes(varint.encode(type)); 3075 position.encode(bufferInstance); 3076 writeBigEndianBool(forced); 3077 return _buffer; 3078 } 3079 3080 public pure nothrow @safe void decode(bool readId=true)() { 3081 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 3082 type=varint.decode(_buffer, &_index); 3083 position.decode(bufferInstance); 3084 forced=readBigEndianBool(); 3085 } 3086 3087 public static pure nothrow @safe SetSpawnPosition fromBuffer(bool readId=true)(ubyte[] buffer) { 3088 SetSpawnPosition ret = new SetSpawnPosition(); 3089 ret._buffer = buffer; 3090 ret.decode!readId(); 3091 return ret; 3092 } 3093 3094 public override string toString() { 3095 return "SetSpawnPosition(type: " ~ std.conv.to!string(this.type) ~ ", position: " ~ std.conv.to!string(this.position) ~ ", forced: " ~ std.conv.to!string(this.forced) ~ ")"; 3096 } 3097 3098 } 3099 3100 class Animate : Buffer { 3101 3102 public enum ubyte ID = 44; 3103 3104 public enum bool CLIENTBOUND = true; 3105 public enum bool SERVERBOUND = true; 3106 3107 // action 3108 public enum int BREAKING = 1; 3109 public enum int WAKE_UP = 3; 3110 3111 public enum string[] FIELDS = ["action", "entityId", "unknown2"]; 3112 3113 public int action; 3114 public long entityId; 3115 public float unknown2; 3116 3117 public pure nothrow @safe @nogc this() {} 3118 3119 public pure nothrow @safe @nogc this(int action, long entityId=long.init, float unknown2=float.init) { 3120 this.action = action; 3121 this.entityId = entityId; 3122 this.unknown2 = unknown2; 3123 } 3124 3125 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 3126 _buffer.length = 0; 3127 static if(writeId){ writeBigEndianUbyte(ID); } 3128 writeBytes(varint.encode(action)); 3129 writeBytes(varlong.encode(entityId)); 3130 if(action>128){ writeLittleEndianFloat(unknown2); } 3131 return _buffer; 3132 } 3133 3134 public pure nothrow @safe void decode(bool readId=true)() { 3135 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 3136 action=varint.decode(_buffer, &_index); 3137 entityId=varlong.decode(_buffer, &_index); 3138 if(action>128){ unknown2=readLittleEndianFloat(); } 3139 } 3140 3141 public static pure nothrow @safe Animate fromBuffer(bool readId=true)(ubyte[] buffer) { 3142 Animate ret = new Animate(); 3143 ret._buffer = buffer; 3144 ret.decode!readId(); 3145 return ret; 3146 } 3147 3148 public override string toString() { 3149 return "Animate(action: " ~ std.conv.to!string(this.action) ~ ", entityId: " ~ std.conv.to!string(this.entityId) ~ ", unknown2: " ~ std.conv.to!string(this.unknown2) ~ ")"; 3150 } 3151 3152 } 3153 3154 class Respawn : Buffer { 3155 3156 public enum ubyte ID = 45; 3157 3158 public enum bool CLIENTBOUND = true; 3159 public enum bool SERVERBOUND = false; 3160 3161 public enum string[] FIELDS = ["position"]; 3162 3163 public Tuple!(float, "x", float, "y", float, "z") position; 3164 3165 public pure nothrow @safe @nogc this() {} 3166 3167 public pure nothrow @safe @nogc this(Tuple!(float, "x", float, "y", float, "z") position) { 3168 this.position = position; 3169 } 3170 3171 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 3172 _buffer.length = 0; 3173 static if(writeId){ writeBigEndianUbyte(ID); } 3174 writeLittleEndianFloat(position.x); writeLittleEndianFloat(position.y); writeLittleEndianFloat(position.z); 3175 return _buffer; 3176 } 3177 3178 public pure nothrow @safe void decode(bool readId=true)() { 3179 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 3180 position.x=readLittleEndianFloat(); position.y=readLittleEndianFloat(); position.z=readLittleEndianFloat(); 3181 } 3182 3183 public static pure nothrow @safe Respawn fromBuffer(bool readId=true)(ubyte[] buffer) { 3184 Respawn ret = new Respawn(); 3185 ret._buffer = buffer; 3186 ret.decode!readId(); 3187 return ret; 3188 } 3189 3190 public override string toString() { 3191 return "Respawn(position: " ~ std.conv.to!string(this.position) ~ ")"; 3192 } 3193 3194 } 3195 3196 class DropItem : Buffer { 3197 3198 public enum ubyte ID = 46; 3199 3200 public enum bool CLIENTBOUND = false; 3201 public enum bool SERVERBOUND = true; 3202 3203 // action 3204 public enum ubyte DROP = 0; 3205 3206 public enum string[] FIELDS = ["action", "item"]; 3207 3208 public ubyte action; 3209 public sul.protocol.pocket113.types.Slot item; 3210 3211 public pure nothrow @safe @nogc this() {} 3212 3213 public pure nothrow @safe @nogc this(ubyte action, sul.protocol.pocket113.types.Slot item=sul.protocol.pocket113.types.Slot.init) { 3214 this.action = action; 3215 this.item = item; 3216 } 3217 3218 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 3219 _buffer.length = 0; 3220 static if(writeId){ writeBigEndianUbyte(ID); } 3221 writeBigEndianUbyte(action); 3222 item.encode(bufferInstance); 3223 return _buffer; 3224 } 3225 3226 public pure nothrow @safe void decode(bool readId=true)() { 3227 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 3228 action=readBigEndianUbyte(); 3229 item.decode(bufferInstance); 3230 } 3231 3232 public static pure nothrow @safe DropItem fromBuffer(bool readId=true)(ubyte[] buffer) { 3233 DropItem ret = new DropItem(); 3234 ret._buffer = buffer; 3235 ret.decode!readId(); 3236 return ret; 3237 } 3238 3239 public override string toString() { 3240 return "DropItem(action: " ~ std.conv.to!string(this.action) ~ ", item: " ~ std.conv.to!string(this.item) ~ ")"; 3241 } 3242 3243 } 3244 3245 class InventoryAction : Buffer { 3246 3247 public enum ubyte ID = 47; 3248 3249 public enum bool CLIENTBOUND = false; 3250 public enum bool SERVERBOUND = true; 3251 3252 public enum string[] FIELDS = ["action", "item", "unknown2", "unknown3"]; 3253 3254 public int action; 3255 public sul.protocol.pocket113.types.Slot item; 3256 public int unknown2; 3257 public int unknown3; 3258 3259 public pure nothrow @safe @nogc this() {} 3260 3261 public pure nothrow @safe @nogc this(int action, sul.protocol.pocket113.types.Slot item=sul.protocol.pocket113.types.Slot.init, int unknown2=int.init, int unknown3=int.init) { 3262 this.action = action; 3263 this.item = item; 3264 this.unknown2 = unknown2; 3265 this.unknown3 = unknown3; 3266 } 3267 3268 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 3269 _buffer.length = 0; 3270 static if(writeId){ writeBigEndianUbyte(ID); } 3271 writeBytes(varint.encode(action)); 3272 item.encode(bufferInstance); 3273 writeBytes(varint.encode(unknown2)); 3274 writeBytes(varint.encode(unknown3)); 3275 return _buffer; 3276 } 3277 3278 public pure nothrow @safe void decode(bool readId=true)() { 3279 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 3280 action=varint.decode(_buffer, &_index); 3281 item.decode(bufferInstance); 3282 unknown2=varint.decode(_buffer, &_index); 3283 unknown3=varint.decode(_buffer, &_index); 3284 } 3285 3286 public static pure nothrow @safe InventoryAction fromBuffer(bool readId=true)(ubyte[] buffer) { 3287 InventoryAction ret = new InventoryAction(); 3288 ret._buffer = buffer; 3289 ret.decode!readId(); 3290 return ret; 3291 } 3292 3293 public override string toString() { 3294 return "InventoryAction(action: " ~ std.conv.to!string(this.action) ~ ", item: " ~ std.conv.to!string(this.item) ~ ", unknown2: " ~ std.conv.to!string(this.unknown2) ~ ", unknown3: " ~ std.conv.to!string(this.unknown3) ~ ")"; 3295 } 3296 3297 } 3298 3299 class ContainerOpen : Buffer { 3300 3301 public enum ubyte ID = 48; 3302 3303 public enum bool CLIENTBOUND = true; 3304 public enum bool SERVERBOUND = false; 3305 3306 public enum string[] FIELDS = ["window", "type", "position", "entityId"]; 3307 3308 public ubyte window; 3309 public ubyte type; 3310 public sul.protocol.pocket113.types.BlockPosition position; 3311 public long entityId; 3312 3313 public pure nothrow @safe @nogc this() {} 3314 3315 public pure nothrow @safe @nogc this(ubyte window, ubyte type=ubyte.init, sul.protocol.pocket113.types.BlockPosition position=sul.protocol.pocket113.types.BlockPosition.init, long entityId=long.init) { 3316 this.window = window; 3317 this.type = type; 3318 this.position = position; 3319 this.entityId = entityId; 3320 } 3321 3322 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 3323 _buffer.length = 0; 3324 static if(writeId){ writeBigEndianUbyte(ID); } 3325 writeBigEndianUbyte(window); 3326 writeBigEndianUbyte(type); 3327 position.encode(bufferInstance); 3328 writeBytes(varlong.encode(entityId)); 3329 return _buffer; 3330 } 3331 3332 public pure nothrow @safe void decode(bool readId=true)() { 3333 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 3334 window=readBigEndianUbyte(); 3335 type=readBigEndianUbyte(); 3336 position.decode(bufferInstance); 3337 entityId=varlong.decode(_buffer, &_index); 3338 } 3339 3340 public static pure nothrow @safe ContainerOpen fromBuffer(bool readId=true)(ubyte[] buffer) { 3341 ContainerOpen ret = new ContainerOpen(); 3342 ret._buffer = buffer; 3343 ret.decode!readId(); 3344 return ret; 3345 } 3346 3347 public override string toString() { 3348 return "ContainerOpen(window: " ~ std.conv.to!string(this.window) ~ ", type: " ~ std.conv.to!string(this.type) ~ ", position: " ~ std.conv.to!string(this.position) ~ ", entityId: " ~ std.conv.to!string(this.entityId) ~ ")"; 3349 } 3350 3351 } 3352 3353 class ContainerClose : Buffer { 3354 3355 public enum ubyte ID = 49; 3356 3357 public enum bool CLIENTBOUND = true; 3358 public enum bool SERVERBOUND = true; 3359 3360 public enum string[] FIELDS = ["window"]; 3361 3362 public ubyte window; 3363 3364 public pure nothrow @safe @nogc this() {} 3365 3366 public pure nothrow @safe @nogc this(ubyte window) { 3367 this.window = window; 3368 } 3369 3370 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 3371 _buffer.length = 0; 3372 static if(writeId){ writeBigEndianUbyte(ID); } 3373 writeBigEndianUbyte(window); 3374 return _buffer; 3375 } 3376 3377 public pure nothrow @safe void decode(bool readId=true)() { 3378 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 3379 window=readBigEndianUbyte(); 3380 } 3381 3382 public static pure nothrow @safe ContainerClose fromBuffer(bool readId=true)(ubyte[] buffer) { 3383 ContainerClose ret = new ContainerClose(); 3384 ret._buffer = buffer; 3385 ret.decode!readId(); 3386 return ret; 3387 } 3388 3389 public override string toString() { 3390 return "ContainerClose(window: " ~ std.conv.to!string(this.window) ~ ")"; 3391 } 3392 3393 } 3394 3395 class ContainerSetSlot : Buffer { 3396 3397 public enum ubyte ID = 50; 3398 3399 public enum bool CLIENTBOUND = true; 3400 public enum bool SERVERBOUND = true; 3401 3402 public enum string[] FIELDS = ["window", "slot", "hotbarSlot", "item", "unknown4"]; 3403 3404 public ubyte window; 3405 public int slot; 3406 public int hotbarSlot; 3407 public sul.protocol.pocket113.types.Slot item; 3408 public ubyte unknown4; 3409 3410 public pure nothrow @safe @nogc this() {} 3411 3412 public pure nothrow @safe @nogc this(ubyte window, int slot=int.init, int hotbarSlot=int.init, sul.protocol.pocket113.types.Slot item=sul.protocol.pocket113.types.Slot.init, ubyte unknown4=ubyte.init) { 3413 this.window = window; 3414 this.slot = slot; 3415 this.hotbarSlot = hotbarSlot; 3416 this.item = item; 3417 this.unknown4 = unknown4; 3418 } 3419 3420 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 3421 _buffer.length = 0; 3422 static if(writeId){ writeBigEndianUbyte(ID); } 3423 writeBigEndianUbyte(window); 3424 writeBytes(varint.encode(slot)); 3425 writeBytes(varint.encode(hotbarSlot)); 3426 item.encode(bufferInstance); 3427 writeBigEndianUbyte(unknown4); 3428 return _buffer; 3429 } 3430 3431 public pure nothrow @safe void decode(bool readId=true)() { 3432 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 3433 window=readBigEndianUbyte(); 3434 slot=varint.decode(_buffer, &_index); 3435 hotbarSlot=varint.decode(_buffer, &_index); 3436 item.decode(bufferInstance); 3437 unknown4=readBigEndianUbyte(); 3438 } 3439 3440 public static pure nothrow @safe ContainerSetSlot fromBuffer(bool readId=true)(ubyte[] buffer) { 3441 ContainerSetSlot ret = new ContainerSetSlot(); 3442 ret._buffer = buffer; 3443 ret.decode!readId(); 3444 return ret; 3445 } 3446 3447 public override string toString() { 3448 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) ~ ")"; 3449 } 3450 3451 } 3452 3453 class ContainerSetData : Buffer { 3454 3455 public enum ubyte ID = 51; 3456 3457 public enum bool CLIENTBOUND = true; 3458 public enum bool SERVERBOUND = false; 3459 3460 public enum string[] FIELDS = ["window", "property", "value"]; 3461 3462 public ubyte window; 3463 public int property; 3464 public int value; 3465 3466 public pure nothrow @safe @nogc this() {} 3467 3468 public pure nothrow @safe @nogc this(ubyte window, int property=int.init, int value=int.init) { 3469 this.window = window; 3470 this.property = property; 3471 this.value = value; 3472 } 3473 3474 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 3475 _buffer.length = 0; 3476 static if(writeId){ writeBigEndianUbyte(ID); } 3477 writeBigEndianUbyte(window); 3478 writeBytes(varint.encode(property)); 3479 writeBytes(varint.encode(value)); 3480 return _buffer; 3481 } 3482 3483 public pure nothrow @safe void decode(bool readId=true)() { 3484 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 3485 window=readBigEndianUbyte(); 3486 property=varint.decode(_buffer, &_index); 3487 value=varint.decode(_buffer, &_index); 3488 } 3489 3490 public static pure nothrow @safe ContainerSetData fromBuffer(bool readId=true)(ubyte[] buffer) { 3491 ContainerSetData ret = new ContainerSetData(); 3492 ret._buffer = buffer; 3493 ret.decode!readId(); 3494 return ret; 3495 } 3496 3497 public override string toString() { 3498 return "ContainerSetData(window: " ~ std.conv.to!string(this.window) ~ ", property: " ~ std.conv.to!string(this.property) ~ ", value: " ~ std.conv.to!string(this.value) ~ ")"; 3499 } 3500 3501 } 3502 3503 class ContainerSetContent : Buffer { 3504 3505 public enum ubyte ID = 52; 3506 3507 public enum bool CLIENTBOUND = true; 3508 public enum bool SERVERBOUND = false; 3509 3510 public enum string[] FIELDS = ["window", "entityId", "slots", "hotbar"]; 3511 3512 public uint window; 3513 public long entityId; 3514 public sul.protocol.pocket113.types.Slot[] slots; 3515 public int[] hotbar; 3516 3517 public pure nothrow @safe @nogc this() {} 3518 3519 public pure nothrow @safe @nogc this(uint window, long entityId=long.init, sul.protocol.pocket113.types.Slot[] slots=(sul.protocol.pocket113.types.Slot[]).init, int[] hotbar=(int[]).init) { 3520 this.window = window; 3521 this.entityId = entityId; 3522 this.slots = slots; 3523 this.hotbar = hotbar; 3524 } 3525 3526 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 3527 _buffer.length = 0; 3528 static if(writeId){ writeBigEndianUbyte(ID); } 3529 writeBytes(varuint.encode(window)); 3530 writeBytes(varlong.encode(entityId)); 3531 writeBytes(varuint.encode(cast(uint)slots.length)); foreach(cxdm;slots){ cxdm.encode(bufferInstance); } 3532 writeBytes(varuint.encode(cast(uint)hotbar.length)); foreach(a9yf;hotbar){ writeBytes(varint.encode(a9yf)); } 3533 return _buffer; 3534 } 3535 3536 public pure nothrow @safe void decode(bool readId=true)() { 3537 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 3538 window=varuint.decode(_buffer, &_index); 3539 entityId=varlong.decode(_buffer, &_index); 3540 slots.length=varuint.decode(_buffer, &_index); foreach(ref cxdm;slots){ cxdm.decode(bufferInstance); } 3541 hotbar.length=varuint.decode(_buffer, &_index); foreach(ref a9yf;hotbar){ a9yf=varint.decode(_buffer, &_index); } 3542 } 3543 3544 public static pure nothrow @safe ContainerSetContent fromBuffer(bool readId=true)(ubyte[] buffer) { 3545 ContainerSetContent ret = new ContainerSetContent(); 3546 ret._buffer = buffer; 3547 ret.decode!readId(); 3548 return ret; 3549 } 3550 3551 public override string toString() { 3552 return "ContainerSetContent(window: " ~ std.conv.to!string(this.window) ~ ", entityId: " ~ std.conv.to!string(this.entityId) ~ ", slots: " ~ std.conv.to!string(this.slots) ~ ", hotbar: " ~ std.conv.to!string(this.hotbar) ~ ")"; 3553 } 3554 3555 } 3556 3557 class CraftingData : Buffer { 3558 3559 public enum ubyte ID = 53; 3560 3561 public enum bool CLIENTBOUND = true; 3562 public enum bool SERVERBOUND = false; 3563 3564 public enum string[] FIELDS = ["recipes"]; 3565 3566 public sul.protocol.pocket113.types.Recipe[] recipes; 3567 3568 public pure nothrow @safe @nogc this() {} 3569 3570 public pure nothrow @safe @nogc this(sul.protocol.pocket113.types.Recipe[] recipes) { 3571 this.recipes = recipes; 3572 } 3573 3574 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 3575 _buffer.length = 0; 3576 static if(writeId){ writeBigEndianUbyte(ID); } 3577 writeBytes(varuint.encode(cast(uint)recipes.length)); foreach(cvabc;recipes){ cvabc.encode(bufferInstance); } 3578 return _buffer; 3579 } 3580 3581 public pure nothrow @safe void decode(bool readId=true)() { 3582 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 3583 recipes.length=varuint.decode(_buffer, &_index); foreach(ref cvabc;recipes){ cvabc.decode(bufferInstance); } 3584 } 3585 3586 public static pure nothrow @safe CraftingData fromBuffer(bool readId=true)(ubyte[] buffer) { 3587 CraftingData ret = new CraftingData(); 3588 ret._buffer = buffer; 3589 ret.decode!readId(); 3590 return ret; 3591 } 3592 3593 public override string toString() { 3594 return "CraftingData(recipes: " ~ std.conv.to!string(this.recipes) ~ ")"; 3595 } 3596 3597 } 3598 3599 class CraftingEvent : Buffer { 3600 3601 public enum ubyte ID = 54; 3602 3603 public enum bool CLIENTBOUND = false; 3604 public enum bool SERVERBOUND = true; 3605 3606 public enum string[] FIELDS = ["window", "type", "uuid", "input", "output"]; 3607 3608 public ubyte window; 3609 public int type; 3610 public sul.protocol.pocket113.types.McpeUuid uuid; 3611 public sul.protocol.pocket113.types.Slot[] input; 3612 public sul.protocol.pocket113.types.Slot[] output; 3613 3614 public pure nothrow @safe @nogc this() {} 3615 3616 public pure nothrow @safe @nogc this(ubyte window, int type=int.init, sul.protocol.pocket113.types.McpeUuid uuid=sul.protocol.pocket113.types.McpeUuid.init, sul.protocol.pocket113.types.Slot[] input=(sul.protocol.pocket113.types.Slot[]).init, sul.protocol.pocket113.types.Slot[] output=(sul.protocol.pocket113.types.Slot[]).init) { 3617 this.window = window; 3618 this.type = type; 3619 this.uuid = uuid; 3620 this.input = input; 3621 this.output = output; 3622 } 3623 3624 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 3625 _buffer.length = 0; 3626 static if(writeId){ writeBigEndianUbyte(ID); } 3627 writeBigEndianUbyte(window); 3628 writeBytes(varint.encode(type)); 3629 uuid.encode(bufferInstance); 3630 writeBytes(varuint.encode(cast(uint)input.length)); foreach(a5dq;input){ a5dq.encode(bufferInstance); } 3631 writeBytes(varuint.encode(cast(uint)output.length)); foreach(bvcv;output){ bvcv.encode(bufferInstance); } 3632 return _buffer; 3633 } 3634 3635 public pure nothrow @safe void decode(bool readId=true)() { 3636 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 3637 window=readBigEndianUbyte(); 3638 type=varint.decode(_buffer, &_index); 3639 uuid.decode(bufferInstance); 3640 input.length=varuint.decode(_buffer, &_index); foreach(ref a5dq;input){ a5dq.decode(bufferInstance); } 3641 output.length=varuint.decode(_buffer, &_index); foreach(ref bvcv;output){ bvcv.decode(bufferInstance); } 3642 } 3643 3644 public static pure nothrow @safe CraftingEvent fromBuffer(bool readId=true)(ubyte[] buffer) { 3645 CraftingEvent ret = new CraftingEvent(); 3646 ret._buffer = buffer; 3647 ret.decode!readId(); 3648 return ret; 3649 } 3650 3651 public override string toString() { 3652 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) ~ ")"; 3653 } 3654 3655 } 3656 3657 /** 3658 * Updates the world's settings and client's permissions. 3659 */ 3660 class AdventureSettings : Buffer { 3661 3662 public enum ubyte ID = 55; 3663 3664 public enum bool CLIENTBOUND = true; 3665 public enum bool SERVERBOUND = true; 3666 3667 // flags 3668 public enum uint IMMUTABLE_WORLD = 1; 3669 public enum uint PVP_DISABLED = 2; 3670 public enum uint PVM_DISABLED = 4; 3671 public enum uint MVP_DISBALED = 8; 3672 public enum uint EVP_DISABLED = 16; 3673 public enum uint AUTO_JUMP = 32; 3674 public enum uint ALLOW_FLIGHT = 64; 3675 public enum uint NO_CLIP = 128; 3676 public enum uint FLYING = 512; 3677 public enum uint MUTED = 1024; 3678 3679 // permissions 3680 public enum uint USER = 0; 3681 public enum uint OPERATOR = 1; 3682 public enum uint HOST = 2; 3683 public enum uint AUTOMATION = 3; 3684 public enum uint ADMIN = 4; 3685 3686 public enum string[] FIELDS = ["flags", "permissions"]; 3687 3688 public uint flags; 3689 public uint permissions; 3690 3691 public pure nothrow @safe @nogc this() {} 3692 3693 public pure nothrow @safe @nogc this(uint flags, uint permissions=uint.init) { 3694 this.flags = flags; 3695 this.permissions = permissions; 3696 } 3697 3698 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 3699 _buffer.length = 0; 3700 static if(writeId){ writeBigEndianUbyte(ID); } 3701 writeBytes(varuint.encode(flags)); 3702 writeBytes(varuint.encode(permissions)); 3703 return _buffer; 3704 } 3705 3706 public pure nothrow @safe void decode(bool readId=true)() { 3707 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 3708 flags=varuint.decode(_buffer, &_index); 3709 permissions=varuint.decode(_buffer, &_index); 3710 } 3711 3712 public static pure nothrow @safe AdventureSettings fromBuffer(bool readId=true)(ubyte[] buffer) { 3713 AdventureSettings ret = new AdventureSettings(); 3714 ret._buffer = buffer; 3715 ret.decode!readId(); 3716 return ret; 3717 } 3718 3719 public override string toString() { 3720 return "AdventureSettings(flags: " ~ std.conv.to!string(this.flags) ~ ", permissions: " ~ std.conv.to!string(this.permissions) ~ ")"; 3721 } 3722 3723 } 3724 3725 /** 3726 * Sets a block entity's nbt tag, block's additional data that cannot be indicated 3727 * in the block's meta. More informations about block entities and their tag format 3728 * can be found on Minecraft Wiki. 3729 */ 3730 class BlockEntityData : Buffer { 3731 3732 public enum ubyte ID = 56; 3733 3734 public enum bool CLIENTBOUND = true; 3735 public enum bool SERVERBOUND = false; 3736 3737 public enum string[] FIELDS = ["position", "nbt"]; 3738 3739 /** 3740 * Position of the block that will be associated with tag. 3741 */ 3742 public sul.protocol.pocket113.types.BlockPosition position; 3743 3744 /** 3745 * Named binary tag of the block. The format varies from the classic format of Minecraft: 3746 * Pocket Edition (which is like Minecraft's but little endian) introducing the use 3747 * of varints for some types: 3748 * + The tag `Int` is encoded as a signed varint instead of a simple signed 32-bits 3749 * integer 3750 * + The length of the `ByteArray` and the `IntArray` is encoded as an unsigned varint 3751 * instead of a 32-bits integer 3752 * + The length of the `String` tag and the named tag's name length are encoded as 3753 * an unisgned varint instead of a 16-bits integer 3754 */ 3755 public ubyte[] nbt; 3756 3757 public pure nothrow @safe @nogc this() {} 3758 3759 public pure nothrow @safe @nogc this(sul.protocol.pocket113.types.BlockPosition position, ubyte[] nbt=(ubyte[]).init) { 3760 this.position = position; 3761 this.nbt = nbt; 3762 } 3763 3764 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 3765 _buffer.length = 0; 3766 static if(writeId){ writeBigEndianUbyte(ID); } 3767 position.encode(bufferInstance); 3768 writeBytes(nbt); 3769 return _buffer; 3770 } 3771 3772 public pure nothrow @safe void decode(bool readId=true)() { 3773 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 3774 position.decode(bufferInstance); 3775 nbt=_buffer[_index..$].dup; _index=_buffer.length; 3776 } 3777 3778 public static pure nothrow @safe BlockEntityData fromBuffer(bool readId=true)(ubyte[] buffer) { 3779 BlockEntityData ret = new BlockEntityData(); 3780 ret._buffer = buffer; 3781 ret.decode!readId(); 3782 return ret; 3783 } 3784 3785 public override string toString() { 3786 return "BlockEntityData(position: " ~ std.conv.to!string(this.position) ~ ", nbt: " ~ std.conv.to!string(this.nbt) ~ ")"; 3787 } 3788 3789 } 3790 3791 class PlayerInput : Buffer { 3792 3793 public enum ubyte ID = 57; 3794 3795 public enum bool CLIENTBOUND = false; 3796 public enum bool SERVERBOUND = true; 3797 3798 public enum string[] FIELDS = ["motion", "flags", "unknown2"]; 3799 3800 public Tuple!(float, "x", float, "y", float, "z") motion; 3801 public ubyte flags; 3802 public bool unknown2; 3803 3804 public pure nothrow @safe @nogc this() {} 3805 3806 public pure nothrow @safe @nogc this(Tuple!(float, "x", float, "y", float, "z") motion, ubyte flags=ubyte.init, bool unknown2=bool.init) { 3807 this.motion = motion; 3808 this.flags = flags; 3809 this.unknown2 = unknown2; 3810 } 3811 3812 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 3813 _buffer.length = 0; 3814 static if(writeId){ writeBigEndianUbyte(ID); } 3815 writeLittleEndianFloat(motion.x); writeLittleEndianFloat(motion.y); writeLittleEndianFloat(motion.z); 3816 writeBigEndianUbyte(flags); 3817 writeBigEndianBool(unknown2); 3818 return _buffer; 3819 } 3820 3821 public pure nothrow @safe void decode(bool readId=true)() { 3822 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 3823 motion.x=readLittleEndianFloat(); motion.y=readLittleEndianFloat(); motion.z=readLittleEndianFloat(); 3824 flags=readBigEndianUbyte(); 3825 unknown2=readBigEndianBool(); 3826 } 3827 3828 public static pure nothrow @safe PlayerInput fromBuffer(bool readId=true)(ubyte[] buffer) { 3829 PlayerInput ret = new PlayerInput(); 3830 ret._buffer = buffer; 3831 ret.decode!readId(); 3832 return ret; 3833 } 3834 3835 public override string toString() { 3836 return "PlayerInput(motion: " ~ std.conv.to!string(this.motion) ~ ", flags: " ~ std.conv.to!string(this.flags) ~ ", unknown2: " ~ std.conv.to!string(this.unknown2) ~ ")"; 3837 } 3838 3839 } 3840 3841 /** 3842 * Sends a 16x16 chunk to the client with its blocks, lights and block entities (tiles). 3843 */ 3844 class FullChunkData : Buffer { 3845 3846 public enum ubyte ID = 58; 3847 3848 public enum bool CLIENTBOUND = true; 3849 public enum bool SERVERBOUND = false; 3850 3851 public enum string[] FIELDS = ["position", "data"]; 3852 3853 /** 3854 * Coordinates of the chunk. 3855 */ 3856 public Tuple!(int, "x", int, "z") position; 3857 public sul.protocol.pocket113.types.ChunkData data; 3858 3859 public pure nothrow @safe @nogc this() {} 3860 3861 public pure nothrow @safe @nogc this(Tuple!(int, "x", int, "z") position, sul.protocol.pocket113.types.ChunkData data=sul.protocol.pocket113.types.ChunkData.init) { 3862 this.position = position; 3863 this.data = data; 3864 } 3865 3866 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 3867 _buffer.length = 0; 3868 static if(writeId){ writeBigEndianUbyte(ID); } 3869 writeBytes(varint.encode(position.x)); writeBytes(varint.encode(position.z)); 3870 data.encode(bufferInstance); 3871 return _buffer; 3872 } 3873 3874 public pure nothrow @safe void decode(bool readId=true)() { 3875 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 3876 position.x=varint.decode(_buffer, &_index); position.z=varint.decode(_buffer, &_index); 3877 data.decode(bufferInstance); 3878 } 3879 3880 public static pure nothrow @safe FullChunkData fromBuffer(bool readId=true)(ubyte[] buffer) { 3881 FullChunkData ret = new FullChunkData(); 3882 ret._buffer = buffer; 3883 ret.decode!readId(); 3884 return ret; 3885 } 3886 3887 public override string toString() { 3888 return "FullChunkData(position: " ~ std.conv.to!string(this.position) ~ ", data: " ~ std.conv.to!string(this.data) ~ ")"; 3889 } 3890 3891 } 3892 3893 /** 3894 * Indicates whether the cheats are enabled. If not the client cannot send commands. 3895 */ 3896 class SetCommandsEnabled : Buffer { 3897 3898 public enum ubyte ID = 59; 3899 3900 public enum bool CLIENTBOUND = true; 3901 public enum bool SERVERBOUND = false; 3902 3903 public enum string[] FIELDS = ["enabled"]; 3904 3905 public bool enabled; 3906 3907 public pure nothrow @safe @nogc this() {} 3908 3909 public pure nothrow @safe @nogc this(bool enabled) { 3910 this.enabled = enabled; 3911 } 3912 3913 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 3914 _buffer.length = 0; 3915 static if(writeId){ writeBigEndianUbyte(ID); } 3916 writeBigEndianBool(enabled); 3917 return _buffer; 3918 } 3919 3920 public pure nothrow @safe void decode(bool readId=true)() { 3921 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 3922 enabled=readBigEndianBool(); 3923 } 3924 3925 public static pure nothrow @safe SetCommandsEnabled fromBuffer(bool readId=true)(ubyte[] buffer) { 3926 SetCommandsEnabled ret = new SetCommandsEnabled(); 3927 ret._buffer = buffer; 3928 ret.decode!readId(); 3929 return ret; 3930 } 3931 3932 public override string toString() { 3933 return "SetCommandsEnabled(enabled: " ~ std.conv.to!string(this.enabled) ~ ")"; 3934 } 3935 3936 } 3937 3938 /** 3939 * Sets the world's difficulty. 3940 */ 3941 class SetDifficulty : Buffer { 3942 3943 public enum ubyte ID = 60; 3944 3945 public enum bool CLIENTBOUND = true; 3946 public enum bool SERVERBOUND = false; 3947 3948 // difficulty 3949 public enum uint PEACEFUL = 0; 3950 public enum uint EASY = 1; 3951 public enum uint NORMAL = 2; 3952 public enum uint HARD = 3; 3953 3954 public enum string[] FIELDS = ["difficulty"]; 3955 3956 public uint difficulty; 3957 3958 public pure nothrow @safe @nogc this() {} 3959 3960 public pure nothrow @safe @nogc this(uint difficulty) { 3961 this.difficulty = difficulty; 3962 } 3963 3964 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 3965 _buffer.length = 0; 3966 static if(writeId){ writeBigEndianUbyte(ID); } 3967 writeBytes(varuint.encode(difficulty)); 3968 return _buffer; 3969 } 3970 3971 public pure nothrow @safe void decode(bool readId=true)() { 3972 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 3973 difficulty=varuint.decode(_buffer, &_index); 3974 } 3975 3976 public static pure nothrow @safe SetDifficulty fromBuffer(bool readId=true)(ubyte[] buffer) { 3977 SetDifficulty ret = new SetDifficulty(); 3978 ret._buffer = buffer; 3979 ret.decode!readId(); 3980 return ret; 3981 } 3982 3983 public override string toString() { 3984 return "SetDifficulty(difficulty: " ~ std.conv.to!string(this.difficulty) ~ ")"; 3985 } 3986 3987 } 3988 3989 class ChangeDimension : Buffer { 3990 3991 public enum ubyte ID = 61; 3992 3993 public enum bool CLIENTBOUND = true; 3994 public enum bool SERVERBOUND = false; 3995 3996 // dimension 3997 public enum int OVERWORLD = 0; 3998 public enum int NETHER = 1; 3999 public enum int END = 2; 4000 4001 public enum string[] FIELDS = ["dimension", "position", "unknown2"]; 4002 4003 public int dimension; 4004 public Tuple!(float, "x", float, "y", float, "z") position; 4005 public bool unknown2; 4006 4007 public pure nothrow @safe @nogc this() {} 4008 4009 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) { 4010 this.dimension = dimension; 4011 this.position = position; 4012 this.unknown2 = unknown2; 4013 } 4014 4015 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 4016 _buffer.length = 0; 4017 static if(writeId){ writeBigEndianUbyte(ID); } 4018 writeBytes(varint.encode(dimension)); 4019 writeLittleEndianFloat(position.x); writeLittleEndianFloat(position.y); writeLittleEndianFloat(position.z); 4020 writeBigEndianBool(unknown2); 4021 return _buffer; 4022 } 4023 4024 public pure nothrow @safe void decode(bool readId=true)() { 4025 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 4026 dimension=varint.decode(_buffer, &_index); 4027 position.x=readLittleEndianFloat(); position.y=readLittleEndianFloat(); position.z=readLittleEndianFloat(); 4028 unknown2=readBigEndianBool(); 4029 } 4030 4031 public static pure nothrow @safe ChangeDimension fromBuffer(bool readId=true)(ubyte[] buffer) { 4032 ChangeDimension ret = new ChangeDimension(); 4033 ret._buffer = buffer; 4034 ret.decode!readId(); 4035 return ret; 4036 } 4037 4038 public override string toString() { 4039 return "ChangeDimension(dimension: " ~ std.conv.to!string(this.dimension) ~ ", position: " ~ std.conv.to!string(this.position) ~ ", unknown2: " ~ std.conv.to!string(this.unknown2) ~ ")"; 4040 } 4041 4042 } 4043 4044 /** 4045 * Sets the player's gamemode. This packet is sent by the player when it has the operator 4046 * status (set in AdventureSettings.permissions) and it changes the gamemode in the 4047 * settings screen. 4048 */ 4049 class SetPlayerGameType : Buffer { 4050 4051 public enum ubyte ID = 62; 4052 4053 public enum bool CLIENTBOUND = true; 4054 public enum bool SERVERBOUND = true; 4055 4056 // gamemode 4057 public enum int SURVIVAL = 0; 4058 public enum int CREATIVE = 1; 4059 public enum int ADVENTURE = 2; 4060 4061 public enum string[] FIELDS = ["gamemode"]; 4062 4063 public int gamemode; 4064 4065 public pure nothrow @safe @nogc this() {} 4066 4067 public pure nothrow @safe @nogc this(int gamemode) { 4068 this.gamemode = gamemode; 4069 } 4070 4071 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 4072 _buffer.length = 0; 4073 static if(writeId){ writeBigEndianUbyte(ID); } 4074 writeBytes(varint.encode(gamemode)); 4075 return _buffer; 4076 } 4077 4078 public pure nothrow @safe void decode(bool readId=true)() { 4079 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 4080 gamemode=varint.decode(_buffer, &_index); 4081 } 4082 4083 public static pure nothrow @safe SetPlayerGameType fromBuffer(bool readId=true)(ubyte[] buffer) { 4084 SetPlayerGameType ret = new SetPlayerGameType(); 4085 ret._buffer = buffer; 4086 ret.decode!readId(); 4087 return ret; 4088 } 4089 4090 public override string toString() { 4091 return "SetPlayerGameType(gamemode: " ~ std.conv.to!string(this.gamemode) ~ ")"; 4092 } 4093 4094 } 4095 4096 /** 4097 * Adds or removes a player from the player's list displayed in the pause menu. This 4098 * packet should be sent before spawning a player with AddPlayer, otherwise the skin 4099 * is not applied. 4100 */ 4101 class PlayerList : Buffer { 4102 4103 public enum ubyte ID = 63; 4104 4105 public enum bool CLIENTBOUND = true; 4106 public enum bool SERVERBOUND = false; 4107 4108 public enum string[] FIELDS = ["action"]; 4109 4110 public ubyte action; 4111 4112 public pure nothrow @safe @nogc this() {} 4113 4114 public pure nothrow @safe @nogc this(ubyte action) { 4115 this.action = action; 4116 } 4117 4118 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 4119 _buffer.length = 0; 4120 static if(writeId){ writeBigEndianUbyte(ID); } 4121 writeBigEndianUbyte(action); 4122 return _buffer; 4123 } 4124 4125 public pure nothrow @safe void decode(bool readId=true)() { 4126 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 4127 action=readBigEndianUbyte(); 4128 } 4129 4130 public static pure nothrow @safe PlayerList fromBuffer(bool readId=true)(ubyte[] buffer) { 4131 PlayerList ret = new PlayerList(); 4132 ret._buffer = buffer; 4133 ret.decode!readId(); 4134 return ret; 4135 } 4136 4137 public override string toString() { 4138 return "PlayerList(action: " ~ std.conv.to!string(this.action) ~ ")"; 4139 } 4140 4141 alias _encode = encode; 4142 4143 enum string variantField = "action"; 4144 4145 alias Variants = TypeTuple!(Add, Remove); 4146 4147 public class Add { 4148 4149 public enum typeof(action) ACTION = 0; 4150 4151 public enum string[] FIELDS = ["players"]; 4152 4153 public sul.protocol.pocket113.types.PlayerList[] players; 4154 4155 public pure nothrow @safe @nogc this() {} 4156 4157 public pure nothrow @safe @nogc this(sul.protocol.pocket113.types.PlayerList[] players) { 4158 this.players = players; 4159 } 4160 4161 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 4162 action = 0; 4163 _encode!writeId(); 4164 writeBytes(varuint.encode(cast(uint)players.length)); foreach(cxevc;players){ cxevc.encode(bufferInstance); } 4165 return _buffer; 4166 } 4167 4168 public pure nothrow @safe void decode() { 4169 players.length=varuint.decode(_buffer, &_index); foreach(ref cxevc;players){ cxevc.decode(bufferInstance); } 4170 } 4171 4172 public override string toString() { 4173 return "PlayerList.Add(players: " ~ std.conv.to!string(this.players) ~ ")"; 4174 } 4175 4176 } 4177 4178 public class Remove { 4179 4180 public enum typeof(action) ACTION = 1; 4181 4182 public enum string[] FIELDS = ["players"]; 4183 4184 public sul.protocol.pocket113.types.McpeUuid[] players; 4185 4186 public pure nothrow @safe @nogc this() {} 4187 4188 public pure nothrow @safe @nogc this(sul.protocol.pocket113.types.McpeUuid[] players) { 4189 this.players = players; 4190 } 4191 4192 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 4193 action = 1; 4194 _encode!writeId(); 4195 writeBytes(varuint.encode(cast(uint)players.length)); foreach(cxevc;players){ cxevc.encode(bufferInstance); } 4196 return _buffer; 4197 } 4198 4199 public pure nothrow @safe void decode() { 4200 players.length=varuint.decode(_buffer, &_index); foreach(ref cxevc;players){ cxevc.decode(bufferInstance); } 4201 } 4202 4203 public override string toString() { 4204 return "PlayerList.Remove(players: " ~ std.conv.to!string(this.players) ~ ")"; 4205 } 4206 4207 } 4208 4209 } 4210 4211 class SimpleEvent : Buffer { 4212 4213 public enum ubyte ID = 63; 4214 4215 public enum bool CLIENTBOUND = true; 4216 public enum bool SERVERBOUND = true; 4217 4218 public enum string[] FIELDS = []; 4219 4220 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 4221 _buffer.length = 0; 4222 static if(writeId){ writeBigEndianUbyte(ID); } 4223 return _buffer; 4224 } 4225 4226 public pure nothrow @safe void decode(bool readId=true)() { 4227 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 4228 } 4229 4230 public static pure nothrow @safe SimpleEvent fromBuffer(bool readId=true)(ubyte[] buffer) { 4231 SimpleEvent ret = new SimpleEvent(); 4232 ret._buffer = buffer; 4233 ret.decode!readId(); 4234 return ret; 4235 } 4236 4237 public override string toString() { 4238 return "SimpleEvent()"; 4239 } 4240 4241 } 4242 4243 class TelemetryEvent : Buffer { 4244 4245 public enum ubyte ID = 64; 4246 4247 public enum bool CLIENTBOUND = true; 4248 public enum bool SERVERBOUND = false; 4249 4250 public enum string[] FIELDS = ["entityId", "eventId"]; 4251 4252 public long entityId; 4253 public int eventId; 4254 4255 public pure nothrow @safe @nogc this() {} 4256 4257 public pure nothrow @safe @nogc this(long entityId, int eventId=int.init) { 4258 this.entityId = entityId; 4259 this.eventId = eventId; 4260 } 4261 4262 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 4263 _buffer.length = 0; 4264 static if(writeId){ writeBigEndianUbyte(ID); } 4265 writeBytes(varlong.encode(entityId)); 4266 writeBytes(varint.encode(eventId)); 4267 return _buffer; 4268 } 4269 4270 public pure nothrow @safe void decode(bool readId=true)() { 4271 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 4272 entityId=varlong.decode(_buffer, &_index); 4273 eventId=varint.decode(_buffer, &_index); 4274 } 4275 4276 public static pure nothrow @safe TelemetryEvent fromBuffer(bool readId=true)(ubyte[] buffer) { 4277 TelemetryEvent ret = new TelemetryEvent(); 4278 ret._buffer = buffer; 4279 ret.decode!readId(); 4280 return ret; 4281 } 4282 4283 public override string toString() { 4284 return "TelemetryEvent(entityId: " ~ std.conv.to!string(this.entityId) ~ ", eventId: " ~ std.conv.to!string(this.eventId) ~ ")"; 4285 } 4286 4287 } 4288 4289 class SpawnExperienceOrb : Buffer { 4290 4291 public enum ubyte ID = 66; 4292 4293 public enum bool CLIENTBOUND = true; 4294 public enum bool SERVERBOUND = false; 4295 4296 public enum string[] FIELDS = ["position", "count"]; 4297 4298 public Tuple!(float, "x", float, "y", float, "z") position; 4299 public int count; 4300 4301 public pure nothrow @safe @nogc this() {} 4302 4303 public pure nothrow @safe @nogc this(Tuple!(float, "x", float, "y", float, "z") position, int count=int.init) { 4304 this.position = position; 4305 this.count = count; 4306 } 4307 4308 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 4309 _buffer.length = 0; 4310 static if(writeId){ writeBigEndianUbyte(ID); } 4311 writeLittleEndianFloat(position.x); writeLittleEndianFloat(position.y); writeLittleEndianFloat(position.z); 4312 writeBytes(varint.encode(count)); 4313 return _buffer; 4314 } 4315 4316 public pure nothrow @safe void decode(bool readId=true)() { 4317 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 4318 position.x=readLittleEndianFloat(); position.y=readLittleEndianFloat(); position.z=readLittleEndianFloat(); 4319 count=varint.decode(_buffer, &_index); 4320 } 4321 4322 public static pure nothrow @safe SpawnExperienceOrb fromBuffer(bool readId=true)(ubyte[] buffer) { 4323 SpawnExperienceOrb ret = new SpawnExperienceOrb(); 4324 ret._buffer = buffer; 4325 ret.decode!readId(); 4326 return ret; 4327 } 4328 4329 public override string toString() { 4330 return "SpawnExperienceOrb(position: " ~ std.conv.to!string(this.position) ~ ", count: " ~ std.conv.to!string(this.count) ~ ")"; 4331 } 4332 4333 } 4334 4335 class ClientboundMapItemData : Buffer { 4336 4337 public enum ubyte ID = 67; 4338 4339 public enum bool CLIENTBOUND = true; 4340 public enum bool SERVERBOUND = false; 4341 4342 // update 4343 public enum uint TEXTURE = 2; 4344 public enum uint DECORATIONS = 4; 4345 public enum uint ENTITIES = 8; 4346 4347 public enum string[] FIELDS = ["mapId", "update", "scale", "size", "offset", "data", "decorations"]; 4348 4349 public long mapId; 4350 public uint update; 4351 public ubyte scale; 4352 4353 /** 4354 * Colums and rows. 4355 */ 4356 public Tuple!(int, "x", int, "z") size; 4357 public Tuple!(int, "x", int, "z") offset; 4358 4359 /** 4360 * ARGB colours encoded as unsigned varints. 4361 */ 4362 public ubyte[] data; 4363 public sul.protocol.pocket113.types.Decoration[] decorations; 4364 4365 public pure nothrow @safe @nogc this() {} 4366 4367 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.pocket113.types.Decoration[] decorations=(sul.protocol.pocket113.types.Decoration[]).init) { 4368 this.mapId = mapId; 4369 this.update = update; 4370 this.scale = scale; 4371 this.size = size; 4372 this.offset = offset; 4373 this.data = data; 4374 this.decorations = decorations; 4375 } 4376 4377 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 4378 _buffer.length = 0; 4379 static if(writeId){ writeBigEndianUbyte(ID); } 4380 writeBytes(varlong.encode(mapId)); 4381 writeBytes(varuint.encode(update)); 4382 if(update==2||update==4){ writeBigEndianUbyte(scale); } 4383 if(update==2){ writeBytes(varint.encode(size.x)); writeBytes(varint.encode(size.z)); } 4384 if(update==2){ writeBytes(varint.encode(offset.x)); writeBytes(varint.encode(offset.z)); } 4385 if(update==2){ writeBytes(data); } 4386 if(update==4){ writeBytes(varuint.encode(cast(uint)decorations.length)); foreach(zvbjdlbm;decorations){ zvbjdlbm.encode(bufferInstance); } } 4387 return _buffer; 4388 } 4389 4390 public pure nothrow @safe void decode(bool readId=true)() { 4391 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 4392 mapId=varlong.decode(_buffer, &_index); 4393 update=varuint.decode(_buffer, &_index); 4394 if(update==2||update==4){ scale=readBigEndianUbyte(); } 4395 if(update==2){ size.x=varint.decode(_buffer, &_index); size.z=varint.decode(_buffer, &_index); } 4396 if(update==2){ offset.x=varint.decode(_buffer, &_index); offset.z=varint.decode(_buffer, &_index); } 4397 if(update==2){ data=_buffer[_index..$].dup; _index=_buffer.length; } 4398 if(update==4){ decorations.length=varuint.decode(_buffer, &_index); foreach(ref zvbjdlbm;decorations){ zvbjdlbm.decode(bufferInstance); } } 4399 } 4400 4401 public static pure nothrow @safe ClientboundMapItemData fromBuffer(bool readId=true)(ubyte[] buffer) { 4402 ClientboundMapItemData ret = new ClientboundMapItemData(); 4403 ret._buffer = buffer; 4404 ret.decode!readId(); 4405 return ret; 4406 } 4407 4408 public override string toString() { 4409 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) ~ ")"; 4410 } 4411 4412 } 4413 4414 class MapInfoRequest : Buffer { 4415 4416 public enum ubyte ID = 68; 4417 4418 public enum bool CLIENTBOUND = false; 4419 public enum bool SERVERBOUND = true; 4420 4421 public enum string[] FIELDS = ["mapId"]; 4422 4423 public long mapId; 4424 4425 public pure nothrow @safe @nogc this() {} 4426 4427 public pure nothrow @safe @nogc this(long mapId) { 4428 this.mapId = mapId; 4429 } 4430 4431 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 4432 _buffer.length = 0; 4433 static if(writeId){ writeBigEndianUbyte(ID); } 4434 writeBytes(varlong.encode(mapId)); 4435 return _buffer; 4436 } 4437 4438 public pure nothrow @safe void decode(bool readId=true)() { 4439 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 4440 mapId=varlong.decode(_buffer, &_index); 4441 } 4442 4443 public static pure nothrow @safe MapInfoRequest fromBuffer(bool readId=true)(ubyte[] buffer) { 4444 MapInfoRequest ret = new MapInfoRequest(); 4445 ret._buffer = buffer; 4446 ret.decode!readId(); 4447 return ret; 4448 } 4449 4450 public override string toString() { 4451 return "MapInfoRequest(mapId: " ~ std.conv.to!string(this.mapId) ~ ")"; 4452 } 4453 4454 } 4455 4456 /** 4457 * Packet sent by the client when its view-distance is updated and when it spawns for 4458 * the first time a world. A ChunkRadiusUpdate should always be sent in response, otherwise 4459 * the player will not update its view distance. 4460 */ 4461 class RequestChunkRadius : Buffer { 4462 4463 public enum ubyte ID = 69; 4464 4465 public enum bool CLIENTBOUND = false; 4466 public enum bool SERVERBOUND = true; 4467 4468 public enum string[] FIELDS = ["radius"]; 4469 4470 /** 4471 * Number of chunks before the fog starts to appear in the client's view. The value 4472 * of this field is usually between 8 and 14. 4473 */ 4474 public int radius; 4475 4476 public pure nothrow @safe @nogc this() {} 4477 4478 public pure nothrow @safe @nogc this(int radius) { 4479 this.radius = radius; 4480 } 4481 4482 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 4483 _buffer.length = 0; 4484 static if(writeId){ writeBigEndianUbyte(ID); } 4485 writeBytes(varint.encode(radius)); 4486 return _buffer; 4487 } 4488 4489 public pure nothrow @safe void decode(bool readId=true)() { 4490 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 4491 radius=varint.decode(_buffer, &_index); 4492 } 4493 4494 public static pure nothrow @safe RequestChunkRadius fromBuffer(bool readId=true)(ubyte[] buffer) { 4495 RequestChunkRadius ret = new RequestChunkRadius(); 4496 ret._buffer = buffer; 4497 ret.decode!readId(); 4498 return ret; 4499 } 4500 4501 public override string toString() { 4502 return "RequestChunkRadius(radius: " ~ std.conv.to!string(this.radius) ~ ")"; 4503 } 4504 4505 } 4506 4507 /** 4508 * Packet sent always and only in response to RequestChunkRadius to change the client's 4509 * view distance. 4510 */ 4511 class ChunkRadiusUpdated : Buffer { 4512 4513 public enum ubyte ID = 70; 4514 4515 public enum bool CLIENTBOUND = true; 4516 public enum bool SERVERBOUND = false; 4517 4518 public enum string[] FIELDS = ["radius"]; 4519 4520 /** 4521 * View distance that may be different from the client's one if the server sets a limit 4522 * on the view distance. 4523 */ 4524 public int radius; 4525 4526 public pure nothrow @safe @nogc this() {} 4527 4528 public pure nothrow @safe @nogc this(int radius) { 4529 this.radius = radius; 4530 } 4531 4532 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 4533 _buffer.length = 0; 4534 static if(writeId){ writeBigEndianUbyte(ID); } 4535 writeBytes(varint.encode(radius)); 4536 return _buffer; 4537 } 4538 4539 public pure nothrow @safe void decode(bool readId=true)() { 4540 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 4541 radius=varint.decode(_buffer, &_index); 4542 } 4543 4544 public static pure nothrow @safe ChunkRadiusUpdated fromBuffer(bool readId=true)(ubyte[] buffer) { 4545 ChunkRadiusUpdated ret = new ChunkRadiusUpdated(); 4546 ret._buffer = buffer; 4547 ret.decode!readId(); 4548 return ret; 4549 } 4550 4551 public override string toString() { 4552 return "ChunkRadiusUpdated(radius: " ~ std.conv.to!string(this.radius) ~ ")"; 4553 } 4554 4555 } 4556 4557 class ItemFrameDropItem : Buffer { 4558 4559 public enum ubyte ID = 71; 4560 4561 public enum bool CLIENTBOUND = true; 4562 public enum bool SERVERBOUND = false; 4563 4564 public enum string[] FIELDS = ["position", "item"]; 4565 4566 public sul.protocol.pocket113.types.BlockPosition position; 4567 public sul.protocol.pocket113.types.Slot item; 4568 4569 public pure nothrow @safe @nogc this() {} 4570 4571 public pure nothrow @safe @nogc this(sul.protocol.pocket113.types.BlockPosition position, sul.protocol.pocket113.types.Slot item=sul.protocol.pocket113.types.Slot.init) { 4572 this.position = position; 4573 this.item = item; 4574 } 4575 4576 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 4577 _buffer.length = 0; 4578 static if(writeId){ writeBigEndianUbyte(ID); } 4579 position.encode(bufferInstance); 4580 item.encode(bufferInstance); 4581 return _buffer; 4582 } 4583 4584 public pure nothrow @safe void decode(bool readId=true)() { 4585 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 4586 position.decode(bufferInstance); 4587 item.decode(bufferInstance); 4588 } 4589 4590 public static pure nothrow @safe ItemFrameDropItem fromBuffer(bool readId=true)(ubyte[] buffer) { 4591 ItemFrameDropItem ret = new ItemFrameDropItem(); 4592 ret._buffer = buffer; 4593 ret.decode!readId(); 4594 return ret; 4595 } 4596 4597 public override string toString() { 4598 return "ItemFrameDropItem(position: " ~ std.conv.to!string(this.position) ~ ", item: " ~ std.conv.to!string(this.item) ~ ")"; 4599 } 4600 4601 } 4602 4603 class ReplaceItemInSlot : Buffer { 4604 4605 public enum ubyte ID = 72; 4606 4607 public enum bool CLIENTBOUND = false; 4608 public enum bool SERVERBOUND = true; 4609 4610 public enum string[] FIELDS = ["item"]; 4611 4612 public sul.protocol.pocket113.types.Slot item; 4613 4614 public pure nothrow @safe @nogc this() {} 4615 4616 public pure nothrow @safe @nogc this(sul.protocol.pocket113.types.Slot item) { 4617 this.item = item; 4618 } 4619 4620 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 4621 _buffer.length = 0; 4622 static if(writeId){ writeBigEndianUbyte(ID); } 4623 item.encode(bufferInstance); 4624 return _buffer; 4625 } 4626 4627 public pure nothrow @safe void decode(bool readId=true)() { 4628 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 4629 item.decode(bufferInstance); 4630 } 4631 4632 public static pure nothrow @safe ReplaceItemInSlot fromBuffer(bool readId=true)(ubyte[] buffer) { 4633 ReplaceItemInSlot ret = new ReplaceItemInSlot(); 4634 ret._buffer = buffer; 4635 ret.decode!readId(); 4636 return ret; 4637 } 4638 4639 public override string toString() { 4640 return "ReplaceItemInSlot(item: " ~ std.conv.to!string(this.item) ~ ")"; 4641 } 4642 4643 } 4644 4645 /** 4646 * Updates client's game rules. This packet is ignored if the game is not launched 4647 * as Education Edition and should be avoid in favour of AdventureSettings, with which 4648 * the same result can be obtained with less data. 4649 */ 4650 class GameRulesChanged : Buffer { 4651 4652 public enum ubyte ID = 73; 4653 4654 public enum bool CLIENTBOUND = true; 4655 public enum bool SERVERBOUND = false; 4656 4657 public enum string[] FIELDS = ["rules"]; 4658 4659 public sul.protocol.pocket113.types.Rule[] rules; 4660 4661 public pure nothrow @safe @nogc this() {} 4662 4663 public pure nothrow @safe @nogc this(sul.protocol.pocket113.types.Rule[] rules) { 4664 this.rules = rules; 4665 } 4666 4667 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 4668 _buffer.length = 0; 4669 static if(writeId){ writeBigEndianUbyte(ID); } 4670 writeBigEndianUint(cast(uint)rules.length); foreach(cvzm;rules){ cvzm.encode(bufferInstance); } 4671 return _buffer; 4672 } 4673 4674 public pure nothrow @safe void decode(bool readId=true)() { 4675 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 4676 rules.length=readBigEndianUint(); foreach(ref cvzm;rules){ cvzm.decode(bufferInstance); } 4677 } 4678 4679 public static pure nothrow @safe GameRulesChanged fromBuffer(bool readId=true)(ubyte[] buffer) { 4680 GameRulesChanged ret = new GameRulesChanged(); 4681 ret._buffer = buffer; 4682 ret.decode!readId(); 4683 return ret; 4684 } 4685 4686 public override string toString() { 4687 return "GameRulesChanged(rules: " ~ std.conv.to!string(this.rules) ~ ")"; 4688 } 4689 4690 } 4691 4692 class Camera : Buffer { 4693 4694 public enum ubyte ID = 74; 4695 4696 public enum bool CLIENTBOUND = true; 4697 public enum bool SERVERBOUND = false; 4698 4699 public enum string[] FIELDS = ["unknown0", "unknown1"]; 4700 4701 public long unknown0; 4702 public long unknown1; 4703 4704 public pure nothrow @safe @nogc this() {} 4705 4706 public pure nothrow @safe @nogc this(long unknown0, long unknown1=long.init) { 4707 this.unknown0 = unknown0; 4708 this.unknown1 = unknown1; 4709 } 4710 4711 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 4712 _buffer.length = 0; 4713 static if(writeId){ writeBigEndianUbyte(ID); } 4714 writeBytes(varlong.encode(unknown0)); 4715 writeBytes(varlong.encode(unknown1)); 4716 return _buffer; 4717 } 4718 4719 public pure nothrow @safe void decode(bool readId=true)() { 4720 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 4721 unknown0=varlong.decode(_buffer, &_index); 4722 unknown1=varlong.decode(_buffer, &_index); 4723 } 4724 4725 public static pure nothrow @safe Camera fromBuffer(bool readId=true)(ubyte[] buffer) { 4726 Camera ret = new Camera(); 4727 ret._buffer = buffer; 4728 ret.decode!readId(); 4729 return ret; 4730 } 4731 4732 public override string toString() { 4733 return "Camera(unknown0: " ~ std.conv.to!string(this.unknown0) ~ ", unknown1: " ~ std.conv.to!string(this.unknown1) ~ ")"; 4734 } 4735 4736 } 4737 4738 class AddItem : Buffer { 4739 4740 public enum ubyte ID = 75; 4741 4742 public enum bool CLIENTBOUND = true; 4743 public enum bool SERVERBOUND = false; 4744 4745 public enum string[] FIELDS = ["item"]; 4746 4747 public sul.protocol.pocket113.types.Slot item; 4748 4749 public pure nothrow @safe @nogc this() {} 4750 4751 public pure nothrow @safe @nogc this(sul.protocol.pocket113.types.Slot item) { 4752 this.item = item; 4753 } 4754 4755 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 4756 _buffer.length = 0; 4757 static if(writeId){ writeBigEndianUbyte(ID); } 4758 item.encode(bufferInstance); 4759 return _buffer; 4760 } 4761 4762 public pure nothrow @safe void decode(bool readId=true)() { 4763 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 4764 item.decode(bufferInstance); 4765 } 4766 4767 public static pure nothrow @safe AddItem fromBuffer(bool readId=true)(ubyte[] buffer) { 4768 AddItem ret = new AddItem(); 4769 ret._buffer = buffer; 4770 ret.decode!readId(); 4771 return ret; 4772 } 4773 4774 public override string toString() { 4775 return "AddItem(item: " ~ std.conv.to!string(this.item) ~ ")"; 4776 } 4777 4778 } 4779 4780 /** 4781 * Adds, removes or modifies an entity's boss bar. The percentage of the bar is calculated 4782 * using the entity's attributes for the health and the max health, updated with UpdateAttributes. 4783 */ 4784 class BossEvent : Buffer { 4785 4786 public enum ubyte ID = 76; 4787 4788 public enum bool CLIENTBOUND = true; 4789 public enum bool SERVERBOUND = false; 4790 4791 // event id 4792 public enum uint ADD = 0; 4793 public enum uint UPDATE = 1; 4794 public enum uint REMOVE = 2; 4795 4796 public enum string[] FIELDS = ["entityId", "eventId"]; 4797 4798 public long entityId; 4799 public uint eventId; 4800 4801 public pure nothrow @safe @nogc this() {} 4802 4803 public pure nothrow @safe @nogc this(long entityId, uint eventId=uint.init) { 4804 this.entityId = entityId; 4805 this.eventId = eventId; 4806 } 4807 4808 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 4809 _buffer.length = 0; 4810 static if(writeId){ writeBigEndianUbyte(ID); } 4811 writeBytes(varlong.encode(entityId)); 4812 writeBytes(varuint.encode(eventId)); 4813 return _buffer; 4814 } 4815 4816 public pure nothrow @safe void decode(bool readId=true)() { 4817 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 4818 entityId=varlong.decode(_buffer, &_index); 4819 eventId=varuint.decode(_buffer, &_index); 4820 } 4821 4822 public static pure nothrow @safe BossEvent fromBuffer(bool readId=true)(ubyte[] buffer) { 4823 BossEvent ret = new BossEvent(); 4824 ret._buffer = buffer; 4825 ret.decode!readId(); 4826 return ret; 4827 } 4828 4829 public override string toString() { 4830 return "BossEvent(entityId: " ~ std.conv.to!string(this.entityId) ~ ", eventId: " ~ std.conv.to!string(this.eventId) ~ ")"; 4831 } 4832 4833 } 4834 4835 class ShowCredits : Buffer { 4836 4837 public enum ubyte ID = 77; 4838 4839 public enum bool CLIENTBOUND = true; 4840 public enum bool SERVERBOUND = true; 4841 4842 // status 4843 public enum int START = 0; 4844 public enum int END = 1; 4845 4846 public enum string[] FIELDS = ["entityId", "status"]; 4847 4848 public long entityId; 4849 public int status; 4850 4851 public pure nothrow @safe @nogc this() {} 4852 4853 public pure nothrow @safe @nogc this(long entityId, int status=int.init) { 4854 this.entityId = entityId; 4855 this.status = status; 4856 } 4857 4858 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 4859 _buffer.length = 0; 4860 static if(writeId){ writeBigEndianUbyte(ID); } 4861 writeBytes(varlong.encode(entityId)); 4862 writeBytes(varint.encode(status)); 4863 return _buffer; 4864 } 4865 4866 public pure nothrow @safe void decode(bool readId=true)() { 4867 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 4868 entityId=varlong.decode(_buffer, &_index); 4869 status=varint.decode(_buffer, &_index); 4870 } 4871 4872 public static pure nothrow @safe ShowCredits fromBuffer(bool readId=true)(ubyte[] buffer) { 4873 ShowCredits ret = new ShowCredits(); 4874 ret._buffer = buffer; 4875 ret.decode!readId(); 4876 return ret; 4877 } 4878 4879 public override string toString() { 4880 return "ShowCredits(entityId: " ~ std.conv.to!string(this.entityId) ~ ", status: " ~ std.conv.to!string(this.status) ~ ")"; 4881 } 4882 4883 } 4884 4885 /** 4886 * Sends a list of the commands that the player can use through the CommandStep packet. 4887 */ 4888 class AvailableCommands : Buffer { 4889 4890 public enum ubyte ID = 78; 4891 4892 public enum bool CLIENTBOUND = true; 4893 public enum bool SERVERBOUND = false; 4894 4895 public enum string[] FIELDS = ["commands", "unknown1"]; 4896 4897 /** 4898 * JSON object with the commands. 4899 */ 4900 public string commands; 4901 public string unknown1; 4902 4903 public pure nothrow @safe @nogc this() {} 4904 4905 public pure nothrow @safe @nogc this(string commands, string unknown1=string.init) { 4906 this.commands = commands; 4907 this.unknown1 = unknown1; 4908 } 4909 4910 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 4911 _buffer.length = 0; 4912 static if(writeId){ writeBigEndianUbyte(ID); } 4913 writeBytes(varuint.encode(cast(uint)commands.length)); writeString(commands); 4914 writeBytes(varuint.encode(cast(uint)unknown1.length)); writeString(unknown1); 4915 return _buffer; 4916 } 4917 4918 public pure nothrow @safe void decode(bool readId=true)() { 4919 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 4920 uint y9bfzm=varuint.decode(_buffer, &_index); commands=readString(y9bfzm); 4921 uint d5b9be=varuint.decode(_buffer, &_index); unknown1=readString(d5b9be); 4922 } 4923 4924 public static pure nothrow @safe AvailableCommands fromBuffer(bool readId=true)(ubyte[] buffer) { 4925 AvailableCommands ret = new AvailableCommands(); 4926 ret._buffer = buffer; 4927 ret.decode!readId(); 4928 return ret; 4929 } 4930 4931 public override string toString() { 4932 return "AvailableCommands(commands: " ~ std.conv.to!string(this.commands) ~ ", unknown1: " ~ std.conv.to!string(this.unknown1) ~ ")"; 4933 } 4934 4935 } 4936 4937 class CommandStep : Buffer { 4938 4939 public enum ubyte ID = 79; 4940 4941 public enum bool CLIENTBOUND = false; 4942 public enum bool SERVERBOUND = true; 4943 4944 public enum string[] FIELDS = ["command", "overload", "unknown2", "currentStep", "done", "clientId", "input", "output"]; 4945 4946 public string command; 4947 public string overload; 4948 public uint unknown2; 4949 public uint currentStep; 4950 public bool done; 4951 public ulong clientId; 4952 public string input; 4953 public string output; 4954 4955 public pure nothrow @safe @nogc this() {} 4956 4957 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) { 4958 this.command = command; 4959 this.overload = overload; 4960 this.unknown2 = unknown2; 4961 this.currentStep = currentStep; 4962 this.done = done; 4963 this.clientId = clientId; 4964 this.input = input; 4965 this.output = output; 4966 } 4967 4968 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 4969 _buffer.length = 0; 4970 static if(writeId){ writeBigEndianUbyte(ID); } 4971 writeBytes(varuint.encode(cast(uint)command.length)); writeString(command); 4972 writeBytes(varuint.encode(cast(uint)overload.length)); writeString(overload); 4973 writeBytes(varuint.encode(unknown2)); 4974 writeBytes(varuint.encode(currentStep)); 4975 writeBigEndianBool(done); 4976 writeBytes(varulong.encode(clientId)); 4977 writeBytes(varuint.encode(cast(uint)input.length)); writeString(input); 4978 writeBytes(varuint.encode(cast(uint)output.length)); writeString(output); 4979 return _buffer; 4980 } 4981 4982 public pure nothrow @safe void decode(bool readId=true)() { 4983 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 4984 uint y9bfz=varuint.decode(_buffer, &_index); command=readString(y9bfz); 4985 uint bzcxyq=varuint.decode(_buffer, &_index); overload=readString(bzcxyq); 4986 unknown2=varuint.decode(_buffer, &_index); 4987 currentStep=varuint.decode(_buffer, &_index); 4988 done=readBigEndianBool(); 4989 clientId=varulong.decode(_buffer, &_index); 4990 uint a5dq=varuint.decode(_buffer, &_index); input=readString(a5dq); 4991 uint bvcv=varuint.decode(_buffer, &_index); output=readString(bvcv); 4992 } 4993 4994 public static pure nothrow @safe CommandStep fromBuffer(bool readId=true)(ubyte[] buffer) { 4995 CommandStep ret = new CommandStep(); 4996 ret._buffer = buffer; 4997 ret.decode!readId(); 4998 return ret; 4999 } 5000 5001 public override string toString() { 5002 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) ~ ")"; 5003 } 5004 5005 } 5006 5007 class CommandBlockUpdate : Buffer { 5008 5009 public enum ubyte ID = 80; 5010 5011 public enum bool CLIENTBOUND = true; 5012 public enum bool SERVERBOUND = true; 5013 5014 public enum string[] FIELDS = ["updateBlock", "position", "mode", "redstoneMode", "conditional", "minecart", "command", "lastOutput", "hover", "trackOutput"]; 5015 5016 public bool updateBlock; 5017 public sul.protocol.pocket113.types.BlockPosition position; 5018 public uint mode; 5019 public bool redstoneMode; 5020 public bool conditional; 5021 public long minecart; 5022 public string command; 5023 public string lastOutput; 5024 public string hover; 5025 public bool trackOutput; 5026 5027 public pure nothrow @safe @nogc this() {} 5028 5029 public pure nothrow @safe @nogc this(bool updateBlock, sul.protocol.pocket113.types.BlockPosition position=sul.protocol.pocket113.types.BlockPosition.init, uint mode=uint.init, bool redstoneMode=bool.init, bool conditional=bool.init, long minecart=long.init, string command=string.init, string lastOutput=string.init, string hover=string.init, bool trackOutput=bool.init) { 5030 this.updateBlock = updateBlock; 5031 this.position = position; 5032 this.mode = mode; 5033 this.redstoneMode = redstoneMode; 5034 this.conditional = conditional; 5035 this.minecart = minecart; 5036 this.command = command; 5037 this.lastOutput = lastOutput; 5038 this.hover = hover; 5039 this.trackOutput = trackOutput; 5040 } 5041 5042 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 5043 _buffer.length = 0; 5044 static if(writeId){ writeBigEndianUbyte(ID); } 5045 writeBigEndianBool(updateBlock); 5046 if(updateBlock==true){ position.encode(bufferInstance); } 5047 if(updateBlock==true){ writeBytes(varuint.encode(mode)); } 5048 if(updateBlock==true){ writeBigEndianBool(redstoneMode); } 5049 if(updateBlock==true){ writeBigEndianBool(conditional); } 5050 if(updateBlock==false){ writeBytes(varlong.encode(minecart)); } 5051 writeBytes(varuint.encode(cast(uint)command.length)); writeString(command); 5052 writeBytes(varuint.encode(cast(uint)lastOutput.length)); writeString(lastOutput); 5053 writeBytes(varuint.encode(cast(uint)hover.length)); writeString(hover); 5054 writeBigEndianBool(trackOutput); 5055 return _buffer; 5056 } 5057 5058 public pure nothrow @safe void decode(bool readId=true)() { 5059 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 5060 updateBlock=readBigEndianBool(); 5061 if(updateBlock==true){ position.decode(bufferInstance); } 5062 if(updateBlock==true){ mode=varuint.decode(_buffer, &_index); } 5063 if(updateBlock==true){ redstoneMode=readBigEndianBool(); } 5064 if(updateBlock==true){ conditional=readBigEndianBool(); } 5065 if(updateBlock==false){ minecart=varlong.decode(_buffer, &_index); } 5066 uint y9bfz=varuint.decode(_buffer, &_index); command=readString(y9bfz); 5067 uint bfd9dbd=varuint.decode(_buffer, &_index); lastOutput=readString(bfd9dbd); 5068 uint a9zi=varuint.decode(_buffer, &_index); hover=readString(a9zi); 5069 trackOutput=readBigEndianBool(); 5070 } 5071 5072 public static pure nothrow @safe CommandBlockUpdate fromBuffer(bool readId=true)(ubyte[] buffer) { 5073 CommandBlockUpdate ret = new CommandBlockUpdate(); 5074 ret._buffer = buffer; 5075 ret.decode!readId(); 5076 return ret; 5077 } 5078 5079 public override string toString() { 5080 return "CommandBlockUpdate(updateBlock: " ~ std.conv.to!string(this.updateBlock) ~ ", position: " ~ std.conv.to!string(this.position) ~ ", mode: " ~ std.conv.to!string(this.mode) ~ ", redstoneMode: " ~ std.conv.to!string(this.redstoneMode) ~ ", conditional: " ~ std.conv.to!string(this.conditional) ~ ", minecart: " ~ std.conv.to!string(this.minecart) ~ ", command: " ~ std.conv.to!string(this.command) ~ ", lastOutput: " ~ std.conv.to!string(this.lastOutput) ~ ", hover: " ~ std.conv.to!string(this.hover) ~ ", trackOutput: " ~ std.conv.to!string(this.trackOutput) ~ ")"; 5081 } 5082 5083 } 5084 5085 class UpdateTrade : Buffer { 5086 5087 public enum ubyte ID = 81; 5088 5089 public enum bool CLIENTBOUND = true; 5090 public enum bool SERVERBOUND = false; 5091 5092 public enum string[] FIELDS = ["unknown0", "unknown1", "unknown2", "unknown3", "unknown4", "trader", "player", "unknown7", "offers"]; 5093 5094 public ubyte unknown0; 5095 public ubyte unknown1; 5096 public int unknown2; 5097 public int unknown3; 5098 public bool unknown4; 5099 public long trader; 5100 public long player; 5101 public string unknown7; 5102 public ubyte[] offers; 5103 5104 public pure nothrow @safe @nogc this() {} 5105 5106 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) { 5107 this.unknown0 = unknown0; 5108 this.unknown1 = unknown1; 5109 this.unknown2 = unknown2; 5110 this.unknown3 = unknown3; 5111 this.unknown4 = unknown4; 5112 this.trader = trader; 5113 this.player = player; 5114 this.unknown7 = unknown7; 5115 this.offers = offers; 5116 } 5117 5118 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 5119 _buffer.length = 0; 5120 static if(writeId){ writeBigEndianUbyte(ID); } 5121 writeBigEndianUbyte(unknown0); 5122 writeBigEndianUbyte(unknown1); 5123 writeBytes(varint.encode(unknown2)); 5124 writeBytes(varint.encode(unknown3)); 5125 writeBigEndianBool(unknown4); 5126 writeBytes(varlong.encode(trader)); 5127 writeBytes(varlong.encode(player)); 5128 writeBytes(varuint.encode(cast(uint)unknown7.length)); writeString(unknown7); 5129 writeBytes(offers); 5130 return _buffer; 5131 } 5132 5133 public pure nothrow @safe void decode(bool readId=true)() { 5134 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 5135 unknown0=readBigEndianUbyte(); 5136 unknown1=readBigEndianUbyte(); 5137 unknown2=varint.decode(_buffer, &_index); 5138 unknown3=varint.decode(_buffer, &_index); 5139 unknown4=readBigEndianBool(); 5140 trader=varlong.decode(_buffer, &_index); 5141 player=varlong.decode(_buffer, &_index); 5142 uint d5b9bc=varuint.decode(_buffer, &_index); unknown7=readString(d5b9bc); 5143 offers=_buffer[_index..$].dup; _index=_buffer.length; 5144 } 5145 5146 public static pure nothrow @safe UpdateTrade fromBuffer(bool readId=true)(ubyte[] buffer) { 5147 UpdateTrade ret = new UpdateTrade(); 5148 ret._buffer = buffer; 5149 ret.decode!readId(); 5150 return ret; 5151 } 5152 5153 public override string toString() { 5154 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) ~ ")"; 5155 } 5156 5157 } 5158 5159 class UpdateEquip : Buffer { 5160 5161 public enum ubyte ID = 82; 5162 5163 public enum bool CLIENTBOUND = true; 5164 public enum bool SERVERBOUND = false; 5165 5166 public enum string[] FIELDS = []; 5167 5168 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 5169 _buffer.length = 0; 5170 static if(writeId){ writeBigEndianUbyte(ID); } 5171 return _buffer; 5172 } 5173 5174 public pure nothrow @safe void decode(bool readId=true)() { 5175 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 5176 } 5177 5178 public static pure nothrow @safe UpdateEquip fromBuffer(bool readId=true)(ubyte[] buffer) { 5179 UpdateEquip ret = new UpdateEquip(); 5180 ret._buffer = buffer; 5181 ret.decode!readId(); 5182 return ret; 5183 } 5184 5185 public override string toString() { 5186 return "UpdateEquip()"; 5187 } 5188 5189 } 5190 5191 class ResourcePackDataInfo : Buffer { 5192 5193 public enum ubyte ID = 83; 5194 5195 public enum bool CLIENTBOUND = true; 5196 public enum bool SERVERBOUND = false; 5197 5198 public enum string[] FIELDS = ["id", "maxChunkSize", "chunkCount", "compressedPackSize", "sha256"]; 5199 5200 public string id; 5201 public uint maxChunkSize; 5202 public uint chunkCount; 5203 public ulong compressedPackSize; 5204 public string sha256; 5205 5206 public pure nothrow @safe @nogc this() {} 5207 5208 public pure nothrow @safe @nogc this(string id, uint maxChunkSize=uint.init, uint chunkCount=uint.init, ulong compressedPackSize=ulong.init, string sha256=string.init) { 5209 this.id = id; 5210 this.maxChunkSize = maxChunkSize; 5211 this.chunkCount = chunkCount; 5212 this.compressedPackSize = compressedPackSize; 5213 this.sha256 = sha256; 5214 } 5215 5216 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 5217 _buffer.length = 0; 5218 static if(writeId){ writeBigEndianUbyte(ID); } 5219 writeBytes(varuint.encode(cast(uint)id.length)); writeString(id); 5220 writeLittleEndianUint(maxChunkSize); 5221 writeLittleEndianUint(chunkCount); 5222 writeLittleEndianUlong(compressedPackSize); 5223 writeBytes(varuint.encode(cast(uint)sha256.length)); writeString(sha256); 5224 return _buffer; 5225 } 5226 5227 public pure nothrow @safe void decode(bool readId=true)() { 5228 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 5229 uint aq=varuint.decode(_buffer, &_index); id=readString(aq); 5230 maxChunkSize=readLittleEndianUint(); 5231 chunkCount=readLittleEndianUint(); 5232 compressedPackSize=readLittleEndianUlong(); 5233 uint chmu=varuint.decode(_buffer, &_index); sha256=readString(chmu); 5234 } 5235 5236 public static pure nothrow @safe ResourcePackDataInfo fromBuffer(bool readId=true)(ubyte[] buffer) { 5237 ResourcePackDataInfo ret = new ResourcePackDataInfo(); 5238 ret._buffer = buffer; 5239 ret.decode!readId(); 5240 return ret; 5241 } 5242 5243 public override string toString() { 5244 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) ~ ")"; 5245 } 5246 5247 } 5248 5249 class ResourcePackChunkData : Buffer { 5250 5251 public enum ubyte ID = 84; 5252 5253 public enum bool CLIENTBOUND = true; 5254 public enum bool SERVERBOUND = false; 5255 5256 public enum string[] FIELDS = ["id", "chunkIndex", "progress", "data"]; 5257 5258 public string id; 5259 public uint chunkIndex; 5260 public ulong progress; 5261 public ubyte[] data; 5262 5263 public pure nothrow @safe @nogc this() {} 5264 5265 public pure nothrow @safe @nogc this(string id, uint chunkIndex=uint.init, ulong progress=ulong.init, ubyte[] data=(ubyte[]).init) { 5266 this.id = id; 5267 this.chunkIndex = chunkIndex; 5268 this.progress = progress; 5269 this.data = data; 5270 } 5271 5272 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 5273 _buffer.length = 0; 5274 static if(writeId){ writeBigEndianUbyte(ID); } 5275 writeBytes(varuint.encode(cast(uint)id.length)); writeString(id); 5276 writeLittleEndianUint(chunkIndex); 5277 writeLittleEndianUlong(progress); 5278 writeLittleEndianUint(cast(uint)data.length); writeBytes(data); 5279 return _buffer; 5280 } 5281 5282 public pure nothrow @safe void decode(bool readId=true)() { 5283 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 5284 uint aq=varuint.decode(_buffer, &_index); id=readString(aq); 5285 chunkIndex=readLittleEndianUint(); 5286 progress=readLittleEndianUlong(); 5287 data.length=readLittleEndianUint(); if(_buffer.length>=_index+data.length){ data=_buffer[_index.._index+data.length].dup; _index+=data.length; } 5288 } 5289 5290 public static pure nothrow @safe ResourcePackChunkData fromBuffer(bool readId=true)(ubyte[] buffer) { 5291 ResourcePackChunkData ret = new ResourcePackChunkData(); 5292 ret._buffer = buffer; 5293 ret.decode!readId(); 5294 return ret; 5295 } 5296 5297 public override string toString() { 5298 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) ~ ")"; 5299 } 5300 5301 } 5302 5303 class ResourcePackChunkRequest : Buffer { 5304 5305 public enum ubyte ID = 85; 5306 5307 public enum bool CLIENTBOUND = false; 5308 public enum bool SERVERBOUND = true; 5309 5310 public enum string[] FIELDS = ["id", "chunkIndex"]; 5311 5312 public string id; 5313 public uint chunkIndex; 5314 5315 public pure nothrow @safe @nogc this() {} 5316 5317 public pure nothrow @safe @nogc this(string id, uint chunkIndex=uint.init) { 5318 this.id = id; 5319 this.chunkIndex = chunkIndex; 5320 } 5321 5322 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 5323 _buffer.length = 0; 5324 static if(writeId){ writeBigEndianUbyte(ID); } 5325 writeBytes(varuint.encode(cast(uint)id.length)); writeString(id); 5326 writeLittleEndianUint(chunkIndex); 5327 return _buffer; 5328 } 5329 5330 public pure nothrow @safe void decode(bool readId=true)() { 5331 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 5332 uint aq=varuint.decode(_buffer, &_index); id=readString(aq); 5333 chunkIndex=readLittleEndianUint(); 5334 } 5335 5336 public static pure nothrow @safe ResourcePackChunkRequest fromBuffer(bool readId=true)(ubyte[] buffer) { 5337 ResourcePackChunkRequest ret = new ResourcePackChunkRequest(); 5338 ret._buffer = buffer; 5339 ret.decode!readId(); 5340 return ret; 5341 } 5342 5343 public override string toString() { 5344 return "ResourcePackChunkRequest(id: " ~ std.conv.to!string(this.id) ~ ", chunkIndex: " ~ std.conv.to!string(this.chunkIndex) ~ ")"; 5345 } 5346 5347 } 5348 5349 /** 5350 * Transfers the player to another server. Once transferred the player will immediately 5351 * close the connection with the transferring server, try to resolve the ip and join 5352 * the new server starting a new raknet session. 5353 */ 5354 class Transfer : Buffer { 5355 5356 public enum ubyte ID = 86; 5357 5358 public enum bool CLIENTBOUND = true; 5359 public enum bool SERVERBOUND = false; 5360 5361 public enum string[] FIELDS = ["ip", "port"]; 5362 5363 /** 5364 * Address of the new server. It can be an dotted ip (for example `127.0.0.1`) or an 5365 * URI (for example `localhost` or `play.example.com`). Only IP of version 4 are currently 5366 * allowed. 5367 */ 5368 public string ip; 5369 5370 /** 5371 * Port of the new server. If 0 the server will try to connect to the default port. 5372 */ 5373 public ushort port = 19132; 5374 5375 public pure nothrow @safe @nogc this() {} 5376 5377 public pure nothrow @safe @nogc this(string ip, ushort port=19132) { 5378 this.ip = ip; 5379 this.port = port; 5380 } 5381 5382 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 5383 _buffer.length = 0; 5384 static if(writeId){ writeBigEndianUbyte(ID); } 5385 writeBytes(varuint.encode(cast(uint)ip.length)); writeString(ip); 5386 writeLittleEndianUshort(port); 5387 return _buffer; 5388 } 5389 5390 public pure nothrow @safe void decode(bool readId=true)() { 5391 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 5392 uint aa=varuint.decode(_buffer, &_index); ip=readString(aa); 5393 port=readLittleEndianUshort(); 5394 } 5395 5396 public static pure nothrow @safe Transfer fromBuffer(bool readId=true)(ubyte[] buffer) { 5397 Transfer ret = new Transfer(); 5398 ret._buffer = buffer; 5399 ret.decode!readId(); 5400 return ret; 5401 } 5402 5403 public override string toString() { 5404 return "Transfer(ip: " ~ std.conv.to!string(this.ip) ~ ", port: " ~ std.conv.to!string(this.port) ~ ")"; 5405 } 5406 5407 } 5408 5409 class PlaySound : Buffer { 5410 5411 public enum ubyte ID = 87; 5412 5413 public enum bool CLIENTBOUND = true; 5414 public enum bool SERVERBOUND = false; 5415 5416 public enum string[] FIELDS = ["name", "position", "volume", "pitch"]; 5417 5418 public string name; 5419 public sul.protocol.pocket113.types.BlockPosition position; 5420 public float volume; 5421 public float pitch; 5422 5423 public pure nothrow @safe @nogc this() {} 5424 5425 public pure nothrow @safe @nogc this(string name, sul.protocol.pocket113.types.BlockPosition position=sul.protocol.pocket113.types.BlockPosition.init, float volume=float.init, float pitch=float.init) { 5426 this.name = name; 5427 this.position = position; 5428 this.volume = volume; 5429 this.pitch = pitch; 5430 } 5431 5432 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 5433 _buffer.length = 0; 5434 static if(writeId){ writeBigEndianUbyte(ID); } 5435 writeBytes(varuint.encode(cast(uint)name.length)); writeString(name); 5436 position.encode(bufferInstance); 5437 writeLittleEndianFloat(volume); 5438 writeLittleEndianFloat(pitch); 5439 return _buffer; 5440 } 5441 5442 public pure nothrow @safe void decode(bool readId=true)() { 5443 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 5444 uint bfz=varuint.decode(_buffer, &_index); name=readString(bfz); 5445 position.decode(bufferInstance); 5446 volume=readLittleEndianFloat(); 5447 pitch=readLittleEndianFloat(); 5448 } 5449 5450 public static pure nothrow @safe PlaySound fromBuffer(bool readId=true)(ubyte[] buffer) { 5451 PlaySound ret = new PlaySound(); 5452 ret._buffer = buffer; 5453 ret.decode!readId(); 5454 return ret; 5455 } 5456 5457 public override string toString() { 5458 return "PlaySound(name: " ~ std.conv.to!string(this.name) ~ ", position: " ~ std.conv.to!string(this.position) ~ ", volume: " ~ std.conv.to!string(this.volume) ~ ", pitch: " ~ std.conv.to!string(this.pitch) ~ ")"; 5459 } 5460 5461 } 5462 5463 class StopSound : Buffer { 5464 5465 public enum ubyte ID = 88; 5466 5467 public enum bool CLIENTBOUND = true; 5468 public enum bool SERVERBOUND = false; 5469 5470 public enum string[] FIELDS = ["name", "stopAll"]; 5471 5472 public string name; 5473 public bool stopAll; 5474 5475 public pure nothrow @safe @nogc this() {} 5476 5477 public pure nothrow @safe @nogc this(string name, bool stopAll=bool.init) { 5478 this.name = name; 5479 this.stopAll = stopAll; 5480 } 5481 5482 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 5483 _buffer.length = 0; 5484 static if(writeId){ writeBigEndianUbyte(ID); } 5485 writeBytes(varuint.encode(cast(uint)name.length)); writeString(name); 5486 writeBigEndianBool(stopAll); 5487 return _buffer; 5488 } 5489 5490 public pure nothrow @safe void decode(bool readId=true)() { 5491 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 5492 uint bfz=varuint.decode(_buffer, &_index); name=readString(bfz); 5493 stopAll=readBigEndianBool(); 5494 } 5495 5496 public static pure nothrow @safe StopSound fromBuffer(bool readId=true)(ubyte[] buffer) { 5497 StopSound ret = new StopSound(); 5498 ret._buffer = buffer; 5499 ret.decode!readId(); 5500 return ret; 5501 } 5502 5503 public override string toString() { 5504 return "StopSound(name: " ~ std.conv.to!string(this.name) ~ ", stopAll: " ~ std.conv.to!string(this.stopAll) ~ ")"; 5505 } 5506 5507 } 5508 5509 /** 5510 * Displays titles on the client's screen. 5511 */ 5512 class SetTitle : Buffer { 5513 5514 public enum ubyte ID = 89; 5515 5516 public enum bool CLIENTBOUND = true; 5517 public enum bool SERVERBOUND = false; 5518 5519 // action 5520 public enum int HIDE = 0; 5521 public enum int RESET = 1; 5522 public enum int SET_TITLE = 2; 5523 public enum int SET_SUBTITLE = 3; 5524 public enum int SET_ACTION_BAR = 4; 5525 public enum int SET_TIMINGS = 5; 5526 5527 public enum string[] FIELDS = ["action", "text", "fadeIn", "stay", "fadeOut"]; 5528 5529 public int action; 5530 5531 /** 5532 * Text that will be displayed in the place specified in the action field. 5533 */ 5534 public string text; 5535 public int fadeIn; 5536 public int stay; 5537 public int fadeOut; 5538 5539 public pure nothrow @safe @nogc this() {} 5540 5541 public pure nothrow @safe @nogc this(int action, string text=string.init, int fadeIn=int.init, int stay=int.init, int fadeOut=int.init) { 5542 this.action = action; 5543 this.text = text; 5544 this.fadeIn = fadeIn; 5545 this.stay = stay; 5546 this.fadeOut = fadeOut; 5547 } 5548 5549 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 5550 _buffer.length = 0; 5551 static if(writeId){ writeBigEndianUbyte(ID); } 5552 writeBytes(varint.encode(action)); 5553 writeBytes(varuint.encode(cast(uint)text.length)); writeString(text); 5554 writeBytes(varint.encode(fadeIn)); 5555 writeBytes(varint.encode(stay)); 5556 writeBytes(varint.encode(fadeOut)); 5557 return _buffer; 5558 } 5559 5560 public pure nothrow @safe void decode(bool readId=true)() { 5561 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 5562 action=varint.decode(_buffer, &_index); 5563 uint dvd=varuint.decode(_buffer, &_index); text=readString(dvd); 5564 fadeIn=varint.decode(_buffer, &_index); 5565 stay=varint.decode(_buffer, &_index); 5566 fadeOut=varint.decode(_buffer, &_index); 5567 } 5568 5569 public static pure nothrow @safe SetTitle fromBuffer(bool readId=true)(ubyte[] buffer) { 5570 SetTitle ret = new SetTitle(); 5571 ret._buffer = buffer; 5572 ret.decode!readId(); 5573 return ret; 5574 } 5575 5576 public override string toString() { 5577 return "SetTitle(action: " ~ std.conv.to!string(this.action) ~ ", text: " ~ std.conv.to!string(this.text) ~ ", fadeIn: " ~ std.conv.to!string(this.fadeIn) ~ ", stay: " ~ std.conv.to!string(this.stay) ~ ", fadeOut: " ~ std.conv.to!string(this.fadeOut) ~ ")"; 5578 } 5579 5580 } 5581 5582 class AddBehaviorTree : Buffer { 5583 5584 public enum ubyte ID = 90; 5585 5586 public enum bool CLIENTBOUND = true; 5587 public enum bool SERVERBOUND = false; 5588 5589 public enum string[] FIELDS = []; 5590 5591 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 5592 _buffer.length = 0; 5593 static if(writeId){ writeBigEndianUbyte(ID); } 5594 return _buffer; 5595 } 5596 5597 public pure nothrow @safe void decode(bool readId=true)() { 5598 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 5599 } 5600 5601 public static pure nothrow @safe AddBehaviorTree fromBuffer(bool readId=true)(ubyte[] buffer) { 5602 AddBehaviorTree ret = new AddBehaviorTree(); 5603 ret._buffer = buffer; 5604 ret.decode!readId(); 5605 return ret; 5606 } 5607 5608 public override string toString() { 5609 return "AddBehaviorTree()"; 5610 } 5611 5612 } 5613 5614 class StructureBlockUpdate : Buffer { 5615 5616 public enum ubyte ID = 91; 5617 5618 public enum bool CLIENTBOUND = true; 5619 public enum bool SERVERBOUND = false; 5620 5621 public enum string[] FIELDS = []; 5622 5623 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 5624 _buffer.length = 0; 5625 static if(writeId){ writeBigEndianUbyte(ID); } 5626 return _buffer; 5627 } 5628 5629 public pure nothrow @safe void decode(bool readId=true)() { 5630 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 5631 } 5632 5633 public static pure nothrow @safe StructureBlockUpdate fromBuffer(bool readId=true)(ubyte[] buffer) { 5634 StructureBlockUpdate ret = new StructureBlockUpdate(); 5635 ret._buffer = buffer; 5636 ret.decode!readId(); 5637 return ret; 5638 } 5639 5640 public override string toString() { 5641 return "StructureBlockUpdate()"; 5642 } 5643 5644 } 5645 5646 class ShowStoreOffer : Buffer { 5647 5648 public enum ubyte ID = 92; 5649 5650 public enum bool CLIENTBOUND = true; 5651 public enum bool SERVERBOUND = false; 5652 5653 public enum string[] FIELDS = []; 5654 5655 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 5656 _buffer.length = 0; 5657 static if(writeId){ writeBigEndianUbyte(ID); } 5658 return _buffer; 5659 } 5660 5661 public pure nothrow @safe void decode(bool readId=true)() { 5662 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 5663 } 5664 5665 public static pure nothrow @safe ShowStoreOffer fromBuffer(bool readId=true)(ubyte[] buffer) { 5666 ShowStoreOffer ret = new ShowStoreOffer(); 5667 ret._buffer = buffer; 5668 ret.decode!readId(); 5669 return ret; 5670 } 5671 5672 public override string toString() { 5673 return "ShowStoreOffer()"; 5674 } 5675 5676 } 5677 5678 class PurchaseReceipt : Buffer { 5679 5680 public enum ubyte ID = 93; 5681 5682 public enum bool CLIENTBOUND = false; 5683 public enum bool SERVERBOUND = true; 5684 5685 public enum string[] FIELDS = []; 5686 5687 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 5688 _buffer.length = 0; 5689 static if(writeId){ writeBigEndianUbyte(ID); } 5690 return _buffer; 5691 } 5692 5693 public pure nothrow @safe void decode(bool readId=true)() { 5694 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 5695 } 5696 5697 public static pure nothrow @safe PurchaseReceipt fromBuffer(bool readId=true)(ubyte[] buffer) { 5698 PurchaseReceipt ret = new PurchaseReceipt(); 5699 ret._buffer = buffer; 5700 ret.decode!readId(); 5701 return ret; 5702 } 5703 5704 public override string toString() { 5705 return "PurchaseReceipt()"; 5706 } 5707 5708 } 5709