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