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