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