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