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/java340.xml 8 */ 9 module sul.protocol.java340.serverbound; 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.java340.types; 22 23 static if(__traits(compiles, { import sul.metadata.java340; })) import sul.metadata.java340; 24 25 alias Packets = TypeTuple!(TeleportConfirm, TabComplete, ChatMessage, ClientStatus, ClientSettings, ConfirmTransaction, EnchantItem, ClickWindow, CloseWindow, PluginMessage, UseEntity, KeepAlive, Player, PlayerPosition, PlayerPositionAndLook, PlayerLook, VehicleMove, SteerBoat, CraftRecipeRequest, PlayerAbilities, PlayerDigging, EntityAction, SteerVehicle, CraftingBookData, ResourcePackStatus, AdvencementTab, HeldItemChange, CreativeInventoryAction, UpdateSign, Animation, Spectate, PlayerBlockPlacement, UseItem); 26 27 class TeleportConfirm : Buffer { 28 29 public enum uint ID = 0; 30 31 public enum bool CLIENTBOUND = false; 32 public enum bool SERVERBOUND = true; 33 34 public enum string[] FIELDS = ["teleportId"]; 35 36 public uint teleportId; 37 38 public pure nothrow @safe @nogc this() {} 39 40 public pure nothrow @safe @nogc this(uint teleportId) { 41 this.teleportId = teleportId; 42 } 43 44 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 45 _buffer.length = 0; 46 static if(writeId){ writeBytes(varuint.encode(ID)); } 47 writeBytes(varuint.encode(teleportId)); 48 return _buffer; 49 } 50 51 public pure nothrow @safe void decode(bool readId=true)() { 52 static if(readId){ uint _id; _id=varuint.decode(_buffer, &_index); } 53 teleportId=varuint.decode(_buffer, &_index); 54 } 55 56 public static pure nothrow @safe TeleportConfirm fromBuffer(bool readId=true)(ubyte[] buffer) { 57 TeleportConfirm ret = new TeleportConfirm(); 58 ret._buffer = buffer; 59 ret.decode!readId(); 60 return ret; 61 } 62 63 public override string toString() { 64 return "TeleportConfirm(teleportId: " ~ std.conv.to!string(this.teleportId) ~ ")"; 65 } 66 67 } 68 69 class TabComplete : Buffer { 70 71 public enum uint ID = 1; 72 73 public enum bool CLIENTBOUND = false; 74 public enum bool SERVERBOUND = true; 75 76 public enum string[] FIELDS = ["text", "command", "hasPosition", "block"]; 77 78 public string text; 79 public bool command; 80 public bool hasPosition; 81 public ulong block; 82 83 public pure nothrow @safe @nogc this() {} 84 85 public pure nothrow @safe @nogc this(string text, bool command=bool.init, bool hasPosition=bool.init, ulong block=ulong.init) { 86 this.text = text; 87 this.command = command; 88 this.hasPosition = hasPosition; 89 this.block = block; 90 } 91 92 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 93 _buffer.length = 0; 94 static if(writeId){ writeBytes(varuint.encode(ID)); } 95 writeBytes(varuint.encode(cast(uint)text.length)); writeString(text); 96 writeBigEndianBool(command); 97 writeBigEndianBool(hasPosition); 98 if(hasPosition==true){ writeBigEndianUlong(block); } 99 return _buffer; 100 } 101 102 public pure nothrow @safe void decode(bool readId=true)() { 103 static if(readId){ uint _id; _id=varuint.decode(_buffer, &_index); } 104 uint dvd=varuint.decode(_buffer, &_index); text=readString(dvd); 105 command=readBigEndianBool(); 106 hasPosition=readBigEndianBool(); 107 if(hasPosition==true){ block=readBigEndianUlong(); } 108 } 109 110 public static pure nothrow @safe TabComplete fromBuffer(bool readId=true)(ubyte[] buffer) { 111 TabComplete ret = new TabComplete(); 112 ret._buffer = buffer; 113 ret.decode!readId(); 114 return ret; 115 } 116 117 public override string toString() { 118 return "TabComplete(text: " ~ std.conv.to!string(this.text) ~ ", command: " ~ std.conv.to!string(this.command) ~ ", hasPosition: " ~ std.conv.to!string(this.hasPosition) ~ ", block: " ~ std.conv.to!string(this.block) ~ ")"; 119 } 120 121 } 122 123 class ChatMessage : Buffer { 124 125 public enum uint ID = 2; 126 127 public enum bool CLIENTBOUND = false; 128 public enum bool SERVERBOUND = true; 129 130 public enum string[] FIELDS = ["text"]; 131 132 public string text; 133 134 public pure nothrow @safe @nogc this() {} 135 136 public pure nothrow @safe @nogc this(string text) { 137 this.text = text; 138 } 139 140 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 141 _buffer.length = 0; 142 static if(writeId){ writeBytes(varuint.encode(ID)); } 143 writeBytes(varuint.encode(cast(uint)text.length)); writeString(text); 144 return _buffer; 145 } 146 147 public pure nothrow @safe void decode(bool readId=true)() { 148 static if(readId){ uint _id; _id=varuint.decode(_buffer, &_index); } 149 uint dvd=varuint.decode(_buffer, &_index); text=readString(dvd); 150 } 151 152 public static pure nothrow @safe ChatMessage fromBuffer(bool readId=true)(ubyte[] buffer) { 153 ChatMessage ret = new ChatMessage(); 154 ret._buffer = buffer; 155 ret.decode!readId(); 156 return ret; 157 } 158 159 public override string toString() { 160 return "ChatMessage(text: " ~ std.conv.to!string(this.text) ~ ")"; 161 } 162 163 } 164 165 class ClientStatus : Buffer { 166 167 public enum uint ID = 3; 168 169 public enum bool CLIENTBOUND = false; 170 public enum bool SERVERBOUND = true; 171 172 // action 173 public enum uint RESPAWN = 0; 174 public enum uint REQUEST_STATS = 1; 175 176 public enum string[] FIELDS = ["action"]; 177 178 public uint action; 179 180 public pure nothrow @safe @nogc this() {} 181 182 public pure nothrow @safe @nogc this(uint action) { 183 this.action = action; 184 } 185 186 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 187 _buffer.length = 0; 188 static if(writeId){ writeBytes(varuint.encode(ID)); } 189 writeBytes(varuint.encode(action)); 190 return _buffer; 191 } 192 193 public pure nothrow @safe void decode(bool readId=true)() { 194 static if(readId){ uint _id; _id=varuint.decode(_buffer, &_index); } 195 action=varuint.decode(_buffer, &_index); 196 } 197 198 public static pure nothrow @safe ClientStatus fromBuffer(bool readId=true)(ubyte[] buffer) { 199 ClientStatus ret = new ClientStatus(); 200 ret._buffer = buffer; 201 ret.decode!readId(); 202 return ret; 203 } 204 205 public override string toString() { 206 return "ClientStatus(action: " ~ std.conv.to!string(this.action) ~ ")"; 207 } 208 209 } 210 211 class ClientSettings : Buffer { 212 213 public enum uint ID = 4; 214 215 public enum bool CLIENTBOUND = false; 216 public enum bool SERVERBOUND = true; 217 218 // chat mode 219 public enum uint ENABLED = 0; 220 public enum uint COMMANDS_ONLY = 1; 221 public enum uint DISABLED = 2; 222 223 // displayed skin parts 224 public enum ubyte CAPE = 1; 225 public enum ubyte JACKET = 2; 226 public enum ubyte LEFT_SLEEVE = 4; 227 public enum ubyte RIGHT_SLEEVE = 8; 228 public enum ubyte LEFT_PANTS = 16; 229 public enum ubyte RIGHT_PANTS = 32; 230 public enum ubyte HAT = 64; 231 232 // main hand 233 public enum ubyte RIGHT = 0; 234 public enum ubyte LEFT = 1; 235 236 public enum string[] FIELDS = ["language", "viewDistance", "chatMode", "chatColors", "displayedSkinParts", "mainHand"]; 237 238 public string language; 239 public ubyte viewDistance; 240 public uint chatMode; 241 public bool chatColors; 242 public ubyte displayedSkinParts; 243 public ubyte mainHand; 244 245 public pure nothrow @safe @nogc this() {} 246 247 public pure nothrow @safe @nogc this(string language, ubyte viewDistance=ubyte.init, uint chatMode=uint.init, bool chatColors=bool.init, ubyte displayedSkinParts=ubyte.init, ubyte mainHand=ubyte.init) { 248 this.language = language; 249 this.viewDistance = viewDistance; 250 this.chatMode = chatMode; 251 this.chatColors = chatColors; 252 this.displayedSkinParts = displayedSkinParts; 253 this.mainHand = mainHand; 254 } 255 256 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 257 _buffer.length = 0; 258 static if(writeId){ writeBytes(varuint.encode(ID)); } 259 writeBytes(varuint.encode(cast(uint)language.length)); writeString(language); 260 writeBigEndianUbyte(viewDistance); 261 writeBytes(varuint.encode(chatMode)); 262 writeBigEndianBool(chatColors); 263 writeBigEndianUbyte(displayedSkinParts); 264 writeBigEndianUbyte(mainHand); 265 return _buffer; 266 } 267 268 public pure nothrow @safe void decode(bool readId=true)() { 269 static if(readId){ uint _id; _id=varuint.decode(_buffer, &_index); } 270 uint bfzvzu=varuint.decode(_buffer, &_index); language=readString(bfzvzu); 271 viewDistance=readBigEndianUbyte(); 272 chatMode=varuint.decode(_buffer, &_index); 273 chatColors=readBigEndianBool(); 274 displayedSkinParts=readBigEndianUbyte(); 275 mainHand=readBigEndianUbyte(); 276 } 277 278 public static pure nothrow @safe ClientSettings fromBuffer(bool readId=true)(ubyte[] buffer) { 279 ClientSettings ret = new ClientSettings(); 280 ret._buffer = buffer; 281 ret.decode!readId(); 282 return ret; 283 } 284 285 public override string toString() { 286 return "ClientSettings(language: " ~ std.conv.to!string(this.language) ~ ", viewDistance: " ~ std.conv.to!string(this.viewDistance) ~ ", chatMode: " ~ std.conv.to!string(this.chatMode) ~ ", chatColors: " ~ std.conv.to!string(this.chatColors) ~ ", displayedSkinParts: " ~ std.conv.to!string(this.displayedSkinParts) ~ ", mainHand: " ~ std.conv.to!string(this.mainHand) ~ ")"; 287 } 288 289 } 290 291 class ConfirmTransaction : Buffer { 292 293 public enum uint ID = 5; 294 295 public enum bool CLIENTBOUND = false; 296 public enum bool SERVERBOUND = true; 297 298 public enum string[] FIELDS = ["window", "action", "accepted"]; 299 300 public ubyte window; 301 public ushort action; 302 public bool accepted; 303 304 public pure nothrow @safe @nogc this() {} 305 306 public pure nothrow @safe @nogc this(ubyte window, ushort action=ushort.init, bool accepted=bool.init) { 307 this.window = window; 308 this.action = action; 309 this.accepted = accepted; 310 } 311 312 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 313 _buffer.length = 0; 314 static if(writeId){ writeBytes(varuint.encode(ID)); } 315 writeBigEndianUbyte(window); 316 writeBigEndianUshort(action); 317 writeBigEndianBool(accepted); 318 return _buffer; 319 } 320 321 public pure nothrow @safe void decode(bool readId=true)() { 322 static if(readId){ uint _id; _id=varuint.decode(_buffer, &_index); } 323 window=readBigEndianUbyte(); 324 action=readBigEndianUshort(); 325 accepted=readBigEndianBool(); 326 } 327 328 public static pure nothrow @safe ConfirmTransaction fromBuffer(bool readId=true)(ubyte[] buffer) { 329 ConfirmTransaction ret = new ConfirmTransaction(); 330 ret._buffer = buffer; 331 ret.decode!readId(); 332 return ret; 333 } 334 335 public override string toString() { 336 return "ConfirmTransaction(window: " ~ std.conv.to!string(this.window) ~ ", action: " ~ std.conv.to!string(this.action) ~ ", accepted: " ~ std.conv.to!string(this.accepted) ~ ")"; 337 } 338 339 } 340 341 class EnchantItem : Buffer { 342 343 public enum uint ID = 6; 344 345 public enum bool CLIENTBOUND = false; 346 public enum bool SERVERBOUND = true; 347 348 public enum string[] FIELDS = ["window", "enchantment"]; 349 350 public ubyte window; 351 public ubyte enchantment; 352 353 public pure nothrow @safe @nogc this() {} 354 355 public pure nothrow @safe @nogc this(ubyte window, ubyte enchantment=ubyte.init) { 356 this.window = window; 357 this.enchantment = enchantment; 358 } 359 360 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 361 _buffer.length = 0; 362 static if(writeId){ writeBytes(varuint.encode(ID)); } 363 writeBigEndianUbyte(window); 364 writeBigEndianUbyte(enchantment); 365 return _buffer; 366 } 367 368 public pure nothrow @safe void decode(bool readId=true)() { 369 static if(readId){ uint _id; _id=varuint.decode(_buffer, &_index); } 370 window=readBigEndianUbyte(); 371 enchantment=readBigEndianUbyte(); 372 } 373 374 public static pure nothrow @safe EnchantItem fromBuffer(bool readId=true)(ubyte[] buffer) { 375 EnchantItem ret = new EnchantItem(); 376 ret._buffer = buffer; 377 ret.decode!readId(); 378 return ret; 379 } 380 381 public override string toString() { 382 return "EnchantItem(window: " ~ std.conv.to!string(this.window) ~ ", enchantment: " ~ std.conv.to!string(this.enchantment) ~ ")"; 383 } 384 385 } 386 387 class ClickWindow : Buffer { 388 389 public enum uint ID = 7; 390 391 public enum bool CLIENTBOUND = false; 392 public enum bool SERVERBOUND = true; 393 394 public enum string[] FIELDS = ["window", "slot", "button", "action", "mode", "clickedItem"]; 395 396 public ubyte window; 397 public ushort slot; 398 public ubyte button; 399 public ushort action; 400 public uint mode; 401 public sul.protocol.java340.types.Slot clickedItem; 402 403 public pure nothrow @safe @nogc this() {} 404 405 public pure nothrow @safe @nogc this(ubyte window, ushort slot=ushort.init, ubyte button=ubyte.init, ushort action=ushort.init, uint mode=uint.init, sul.protocol.java340.types.Slot clickedItem=sul.protocol.java340.types.Slot.init) { 406 this.window = window; 407 this.slot = slot; 408 this.button = button; 409 this.action = action; 410 this.mode = mode; 411 this.clickedItem = clickedItem; 412 } 413 414 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 415 _buffer.length = 0; 416 static if(writeId){ writeBytes(varuint.encode(ID)); } 417 writeBigEndianUbyte(window); 418 writeBigEndianUshort(slot); 419 writeBigEndianUbyte(button); 420 writeBigEndianUshort(action); 421 writeBytes(varuint.encode(mode)); 422 clickedItem.encode(bufferInstance); 423 return _buffer; 424 } 425 426 public pure nothrow @safe void decode(bool readId=true)() { 427 static if(readId){ uint _id; _id=varuint.decode(_buffer, &_index); } 428 window=readBigEndianUbyte(); 429 slot=readBigEndianUshort(); 430 button=readBigEndianUbyte(); 431 action=readBigEndianUshort(); 432 mode=varuint.decode(_buffer, &_index); 433 clickedItem.decode(bufferInstance); 434 } 435 436 public static pure nothrow @safe ClickWindow fromBuffer(bool readId=true)(ubyte[] buffer) { 437 ClickWindow ret = new ClickWindow(); 438 ret._buffer = buffer; 439 ret.decode!readId(); 440 return ret; 441 } 442 443 public override string toString() { 444 return "ClickWindow(window: " ~ std.conv.to!string(this.window) ~ ", slot: " ~ std.conv.to!string(this.slot) ~ ", button: " ~ std.conv.to!string(this.button) ~ ", action: " ~ std.conv.to!string(this.action) ~ ", mode: " ~ std.conv.to!string(this.mode) ~ ", clickedItem: " ~ std.conv.to!string(this.clickedItem) ~ ")"; 445 } 446 447 } 448 449 class CloseWindow : Buffer { 450 451 public enum uint ID = 8; 452 453 public enum bool CLIENTBOUND = false; 454 public enum bool SERVERBOUND = true; 455 456 public enum string[] FIELDS = ["window"]; 457 458 public ubyte window; 459 460 public pure nothrow @safe @nogc this() {} 461 462 public pure nothrow @safe @nogc this(ubyte window) { 463 this.window = window; 464 } 465 466 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 467 _buffer.length = 0; 468 static if(writeId){ writeBytes(varuint.encode(ID)); } 469 writeBigEndianUbyte(window); 470 return _buffer; 471 } 472 473 public pure nothrow @safe void decode(bool readId=true)() { 474 static if(readId){ uint _id; _id=varuint.decode(_buffer, &_index); } 475 window=readBigEndianUbyte(); 476 } 477 478 public static pure nothrow @safe CloseWindow fromBuffer(bool readId=true)(ubyte[] buffer) { 479 CloseWindow ret = new CloseWindow(); 480 ret._buffer = buffer; 481 ret.decode!readId(); 482 return ret; 483 } 484 485 public override string toString() { 486 return "CloseWindow(window: " ~ std.conv.to!string(this.window) ~ ")"; 487 } 488 489 } 490 491 class PluginMessage : Buffer { 492 493 public enum uint ID = 9; 494 495 public enum bool CLIENTBOUND = false; 496 public enum bool SERVERBOUND = true; 497 498 public enum string[] FIELDS = ["channel", "data"]; 499 500 public string channel; 501 public ubyte[] data; 502 503 public pure nothrow @safe @nogc this() {} 504 505 public pure nothrow @safe @nogc this(string channel, ubyte[] data=(ubyte[]).init) { 506 this.channel = channel; 507 this.data = data; 508 } 509 510 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 511 _buffer.length = 0; 512 static if(writeId){ writeBytes(varuint.encode(ID)); } 513 writeBytes(varuint.encode(cast(uint)channel.length)); writeString(channel); 514 writeBytes(data); 515 return _buffer; 516 } 517 518 public pure nothrow @safe void decode(bool readId=true)() { 519 static if(readId){ uint _id; _id=varuint.decode(_buffer, &_index); } 520 uint yhb5b=varuint.decode(_buffer, &_index); channel=readString(yhb5b); 521 data=_buffer[_index..$].dup; _index=_buffer.length; 522 } 523 524 public static pure nothrow @safe PluginMessage fromBuffer(bool readId=true)(ubyte[] buffer) { 525 PluginMessage ret = new PluginMessage(); 526 ret._buffer = buffer; 527 ret.decode!readId(); 528 return ret; 529 } 530 531 public override string toString() { 532 return "PluginMessage(channel: " ~ std.conv.to!string(this.channel) ~ ", data: " ~ std.conv.to!string(this.data) ~ ")"; 533 } 534 535 } 536 537 class UseEntity : Buffer { 538 539 public enum uint ID = 10; 540 541 public enum bool CLIENTBOUND = false; 542 public enum bool SERVERBOUND = true; 543 544 // type 545 public enum uint INTERACT = 0; 546 public enum uint ATTACK = 1; 547 public enum uint INTERACT_AT = 2; 548 549 // hand 550 public enum uint MAIN_HAND = 0; 551 public enum uint OFF_HAND = 1; 552 553 public enum string[] FIELDS = ["target", "type", "targetPosition", "hand"]; 554 555 public uint target; 556 public uint type; 557 public Tuple!(float, "x", float, "y", float, "z") targetPosition; 558 public uint hand; 559 560 public pure nothrow @safe @nogc this() {} 561 562 public pure nothrow @safe @nogc this(uint target, uint type=uint.init, Tuple!(float, "x", float, "y", float, "z") targetPosition=Tuple!(float, "x", float, "y", float, "z").init, uint hand=uint.init) { 563 this.target = target; 564 this.type = type; 565 this.targetPosition = targetPosition; 566 this.hand = hand; 567 } 568 569 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 570 _buffer.length = 0; 571 static if(writeId){ writeBytes(varuint.encode(ID)); } 572 writeBytes(varuint.encode(target)); 573 writeBytes(varuint.encode(type)); 574 if(type==2){ writeBigEndianFloat(targetPosition.x); writeBigEndianFloat(targetPosition.y); writeBigEndianFloat(targetPosition.z); } 575 if(type==0||type==2){ writeBytes(varuint.encode(hand)); } 576 return _buffer; 577 } 578 579 public pure nothrow @safe void decode(bool readId=true)() { 580 static if(readId){ uint _id; _id=varuint.decode(_buffer, &_index); } 581 target=varuint.decode(_buffer, &_index); 582 type=varuint.decode(_buffer, &_index); 583 if(type==2){ targetPosition.x=readBigEndianFloat(); targetPosition.y=readBigEndianFloat(); targetPosition.z=readBigEndianFloat(); } 584 if(type==0||type==2){ hand=varuint.decode(_buffer, &_index); } 585 } 586 587 public static pure nothrow @safe UseEntity fromBuffer(bool readId=true)(ubyte[] buffer) { 588 UseEntity ret = new UseEntity(); 589 ret._buffer = buffer; 590 ret.decode!readId(); 591 return ret; 592 } 593 594 public override string toString() { 595 return "UseEntity(target: " ~ std.conv.to!string(this.target) ~ ", type: " ~ std.conv.to!string(this.type) ~ ", targetPosition: " ~ std.conv.to!string(this.targetPosition) ~ ", hand: " ~ std.conv.to!string(this.hand) ~ ")"; 596 } 597 598 } 599 600 class KeepAlive : Buffer { 601 602 public enum uint ID = 11; 603 604 public enum bool CLIENTBOUND = false; 605 public enum bool SERVERBOUND = true; 606 607 public enum string[] FIELDS = ["id"]; 608 609 public long id; 610 611 public pure nothrow @safe @nogc this() {} 612 613 public pure nothrow @safe @nogc this(long id) { 614 this.id = id; 615 } 616 617 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 618 _buffer.length = 0; 619 static if(writeId){ writeBytes(varuint.encode(ID)); } 620 writeBigEndianLong(id); 621 return _buffer; 622 } 623 624 public pure nothrow @safe void decode(bool readId=true)() { 625 static if(readId){ uint _id; _id=varuint.decode(_buffer, &_index); } 626 id=readBigEndianLong(); 627 } 628 629 public static pure nothrow @safe KeepAlive fromBuffer(bool readId=true)(ubyte[] buffer) { 630 KeepAlive ret = new KeepAlive(); 631 ret._buffer = buffer; 632 ret.decode!readId(); 633 return ret; 634 } 635 636 public override string toString() { 637 return "KeepAlive(id: " ~ std.conv.to!string(this.id) ~ ")"; 638 } 639 640 } 641 642 class Player : Buffer { 643 644 public enum uint ID = 12; 645 646 public enum bool CLIENTBOUND = false; 647 public enum bool SERVERBOUND = true; 648 649 public enum string[] FIELDS = ["onGround"]; 650 651 public bool onGround; 652 653 public pure nothrow @safe @nogc this() {} 654 655 public pure nothrow @safe @nogc this(bool onGround) { 656 this.onGround = onGround; 657 } 658 659 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 660 _buffer.length = 0; 661 static if(writeId){ writeBytes(varuint.encode(ID)); } 662 writeBigEndianBool(onGround); 663 return _buffer; 664 } 665 666 public pure nothrow @safe void decode(bool readId=true)() { 667 static if(readId){ uint _id; _id=varuint.decode(_buffer, &_index); } 668 onGround=readBigEndianBool(); 669 } 670 671 public static pure nothrow @safe Player fromBuffer(bool readId=true)(ubyte[] buffer) { 672 Player ret = new Player(); 673 ret._buffer = buffer; 674 ret.decode!readId(); 675 return ret; 676 } 677 678 public override string toString() { 679 return "Player(onGround: " ~ std.conv.to!string(this.onGround) ~ ")"; 680 } 681 682 } 683 684 class PlayerPosition : Buffer { 685 686 public enum uint ID = 13; 687 688 public enum bool CLIENTBOUND = false; 689 public enum bool SERVERBOUND = true; 690 691 public enum string[] FIELDS = ["position", "onGround"]; 692 693 public Tuple!(double, "x", double, "y", double, "z") position; 694 public bool onGround; 695 696 public pure nothrow @safe @nogc this() {} 697 698 public pure nothrow @safe @nogc this(Tuple!(double, "x", double, "y", double, "z") position, bool onGround=bool.init) { 699 this.position = position; 700 this.onGround = onGround; 701 } 702 703 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 704 _buffer.length = 0; 705 static if(writeId){ writeBytes(varuint.encode(ID)); } 706 writeBigEndianDouble(position.x); writeBigEndianDouble(position.y); writeBigEndianDouble(position.z); 707 writeBigEndianBool(onGround); 708 return _buffer; 709 } 710 711 public pure nothrow @safe void decode(bool readId=true)() { 712 static if(readId){ uint _id; _id=varuint.decode(_buffer, &_index); } 713 position.x=readBigEndianDouble(); position.y=readBigEndianDouble(); position.z=readBigEndianDouble(); 714 onGround=readBigEndianBool(); 715 } 716 717 public static pure nothrow @safe PlayerPosition fromBuffer(bool readId=true)(ubyte[] buffer) { 718 PlayerPosition ret = new PlayerPosition(); 719 ret._buffer = buffer; 720 ret.decode!readId(); 721 return ret; 722 } 723 724 public override string toString() { 725 return "PlayerPosition(position: " ~ std.conv.to!string(this.position) ~ ", onGround: " ~ std.conv.to!string(this.onGround) ~ ")"; 726 } 727 728 } 729 730 class PlayerPositionAndLook : Buffer { 731 732 public enum uint ID = 14; 733 734 public enum bool CLIENTBOUND = false; 735 public enum bool SERVERBOUND = true; 736 737 public enum string[] FIELDS = ["position", "yaw", "pitch", "onGround"]; 738 739 public Tuple!(double, "x", double, "y", double, "z") position; 740 public float yaw; 741 public float pitch; 742 public bool onGround; 743 744 public pure nothrow @safe @nogc this() {} 745 746 public pure nothrow @safe @nogc this(Tuple!(double, "x", double, "y", double, "z") position, float yaw=float.init, float pitch=float.init, bool onGround=bool.init) { 747 this.position = position; 748 this.yaw = yaw; 749 this.pitch = pitch; 750 this.onGround = onGround; 751 } 752 753 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 754 _buffer.length = 0; 755 static if(writeId){ writeBytes(varuint.encode(ID)); } 756 writeBigEndianDouble(position.x); writeBigEndianDouble(position.y); writeBigEndianDouble(position.z); 757 writeBigEndianFloat(yaw); 758 writeBigEndianFloat(pitch); 759 writeBigEndianBool(onGround); 760 return _buffer; 761 } 762 763 public pure nothrow @safe void decode(bool readId=true)() { 764 static if(readId){ uint _id; _id=varuint.decode(_buffer, &_index); } 765 position.x=readBigEndianDouble(); position.y=readBigEndianDouble(); position.z=readBigEndianDouble(); 766 yaw=readBigEndianFloat(); 767 pitch=readBigEndianFloat(); 768 onGround=readBigEndianBool(); 769 } 770 771 public static pure nothrow @safe PlayerPositionAndLook fromBuffer(bool readId=true)(ubyte[] buffer) { 772 PlayerPositionAndLook ret = new PlayerPositionAndLook(); 773 ret._buffer = buffer; 774 ret.decode!readId(); 775 return ret; 776 } 777 778 public override string toString() { 779 return "PlayerPositionAndLook(position: " ~ std.conv.to!string(this.position) ~ ", yaw: " ~ std.conv.to!string(this.yaw) ~ ", pitch: " ~ std.conv.to!string(this.pitch) ~ ", onGround: " ~ std.conv.to!string(this.onGround) ~ ")"; 780 } 781 782 } 783 784 class PlayerLook : Buffer { 785 786 public enum uint ID = 15; 787 788 public enum bool CLIENTBOUND = false; 789 public enum bool SERVERBOUND = true; 790 791 public enum string[] FIELDS = ["yaw", "pitch", "onGround"]; 792 793 public float yaw; 794 public float pitch; 795 public bool onGround; 796 797 public pure nothrow @safe @nogc this() {} 798 799 public pure nothrow @safe @nogc this(float yaw, float pitch=float.init, bool onGround=bool.init) { 800 this.yaw = yaw; 801 this.pitch = pitch; 802 this.onGround = onGround; 803 } 804 805 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 806 _buffer.length = 0; 807 static if(writeId){ writeBytes(varuint.encode(ID)); } 808 writeBigEndianFloat(yaw); 809 writeBigEndianFloat(pitch); 810 writeBigEndianBool(onGround); 811 return _buffer; 812 } 813 814 public pure nothrow @safe void decode(bool readId=true)() { 815 static if(readId){ uint _id; _id=varuint.decode(_buffer, &_index); } 816 yaw=readBigEndianFloat(); 817 pitch=readBigEndianFloat(); 818 onGround=readBigEndianBool(); 819 } 820 821 public static pure nothrow @safe PlayerLook fromBuffer(bool readId=true)(ubyte[] buffer) { 822 PlayerLook ret = new PlayerLook(); 823 ret._buffer = buffer; 824 ret.decode!readId(); 825 return ret; 826 } 827 828 public override string toString() { 829 return "PlayerLook(yaw: " ~ std.conv.to!string(this.yaw) ~ ", pitch: " ~ std.conv.to!string(this.pitch) ~ ", onGround: " ~ std.conv.to!string(this.onGround) ~ ")"; 830 } 831 832 } 833 834 class VehicleMove : Buffer { 835 836 public enum uint ID = 16; 837 838 public enum bool CLIENTBOUND = false; 839 public enum bool SERVERBOUND = true; 840 841 public enum string[] FIELDS = ["position", "yaw", "pitch"]; 842 843 public Tuple!(double, "x", double, "y", double, "z") position; 844 public float yaw; 845 public float pitch; 846 847 public pure nothrow @safe @nogc this() {} 848 849 public pure nothrow @safe @nogc this(Tuple!(double, "x", double, "y", double, "z") position, float yaw=float.init, float pitch=float.init) { 850 this.position = position; 851 this.yaw = yaw; 852 this.pitch = pitch; 853 } 854 855 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 856 _buffer.length = 0; 857 static if(writeId){ writeBytes(varuint.encode(ID)); } 858 writeBigEndianDouble(position.x); writeBigEndianDouble(position.y); writeBigEndianDouble(position.z); 859 writeBigEndianFloat(yaw); 860 writeBigEndianFloat(pitch); 861 return _buffer; 862 } 863 864 public pure nothrow @safe void decode(bool readId=true)() { 865 static if(readId){ uint _id; _id=varuint.decode(_buffer, &_index); } 866 position.x=readBigEndianDouble(); position.y=readBigEndianDouble(); position.z=readBigEndianDouble(); 867 yaw=readBigEndianFloat(); 868 pitch=readBigEndianFloat(); 869 } 870 871 public static pure nothrow @safe VehicleMove fromBuffer(bool readId=true)(ubyte[] buffer) { 872 VehicleMove ret = new VehicleMove(); 873 ret._buffer = buffer; 874 ret.decode!readId(); 875 return ret; 876 } 877 878 public override string toString() { 879 return "VehicleMove(position: " ~ std.conv.to!string(this.position) ~ ", yaw: " ~ std.conv.to!string(this.yaw) ~ ", pitch: " ~ std.conv.to!string(this.pitch) ~ ")"; 880 } 881 882 } 883 884 class SteerBoat : Buffer { 885 886 public enum uint ID = 17; 887 888 public enum bool CLIENTBOUND = false; 889 public enum bool SERVERBOUND = true; 890 891 public enum string[] FIELDS = ["rightPaddleTurning", "leftPaddleTurning"]; 892 893 public bool rightPaddleTurning; 894 public bool leftPaddleTurning; 895 896 public pure nothrow @safe @nogc this() {} 897 898 public pure nothrow @safe @nogc this(bool rightPaddleTurning, bool leftPaddleTurning=bool.init) { 899 this.rightPaddleTurning = rightPaddleTurning; 900 this.leftPaddleTurning = leftPaddleTurning; 901 } 902 903 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 904 _buffer.length = 0; 905 static if(writeId){ writeBytes(varuint.encode(ID)); } 906 writeBigEndianBool(rightPaddleTurning); 907 writeBigEndianBool(leftPaddleTurning); 908 return _buffer; 909 } 910 911 public pure nothrow @safe void decode(bool readId=true)() { 912 static if(readId){ uint _id; _id=varuint.decode(_buffer, &_index); } 913 rightPaddleTurning=readBigEndianBool(); 914 leftPaddleTurning=readBigEndianBool(); 915 } 916 917 public static pure nothrow @safe SteerBoat fromBuffer(bool readId=true)(ubyte[] buffer) { 918 SteerBoat ret = new SteerBoat(); 919 ret._buffer = buffer; 920 ret.decode!readId(); 921 return ret; 922 } 923 924 public override string toString() { 925 return "SteerBoat(rightPaddleTurning: " ~ std.conv.to!string(this.rightPaddleTurning) ~ ", leftPaddleTurning: " ~ std.conv.to!string(this.leftPaddleTurning) ~ ")"; 926 } 927 928 } 929 930 class CraftRecipeRequest : Buffer { 931 932 public enum uint ID = 18; 933 934 public enum bool CLIENTBOUND = false; 935 public enum bool SERVERBOUND = true; 936 937 public enum string[] FIELDS = ["window", "recipe", "makeAll"]; 938 939 public ubyte window; 940 public uint recipe; 941 public bool makeAll; 942 943 public pure nothrow @safe @nogc this() {} 944 945 public pure nothrow @safe @nogc this(ubyte window, uint recipe=uint.init, bool makeAll=bool.init) { 946 this.window = window; 947 this.recipe = recipe; 948 this.makeAll = makeAll; 949 } 950 951 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 952 _buffer.length = 0; 953 static if(writeId){ writeBytes(varuint.encode(ID)); } 954 writeBigEndianUbyte(window); 955 writeBytes(varuint.encode(recipe)); 956 writeBigEndianBool(makeAll); 957 return _buffer; 958 } 959 960 public pure nothrow @safe void decode(bool readId=true)() { 961 static if(readId){ uint _id; _id=varuint.decode(_buffer, &_index); } 962 window=readBigEndianUbyte(); 963 recipe=varuint.decode(_buffer, &_index); 964 makeAll=readBigEndianBool(); 965 } 966 967 public static pure nothrow @safe CraftRecipeRequest fromBuffer(bool readId=true)(ubyte[] buffer) { 968 CraftRecipeRequest ret = new CraftRecipeRequest(); 969 ret._buffer = buffer; 970 ret.decode!readId(); 971 return ret; 972 } 973 974 public override string toString() { 975 return "CraftRecipeRequest(window: " ~ std.conv.to!string(this.window) ~ ", recipe: " ~ std.conv.to!string(this.recipe) ~ ", makeAll: " ~ std.conv.to!string(this.makeAll) ~ ")"; 976 } 977 978 } 979 980 class PlayerAbilities : Buffer { 981 982 public enum uint ID = 19; 983 984 public enum bool CLIENTBOUND = false; 985 public enum bool SERVERBOUND = true; 986 987 // flags 988 public enum ubyte CREATIVE_MODE = 1; 989 public enum ubyte FLYING = 2; 990 public enum ubyte ALLOW_FLYING = 4; 991 public enum ubyte INVINCIBLE = 8; 992 993 public enum string[] FIELDS = ["flags", "flyingSpeed", "walkingSpeed"]; 994 995 public ubyte flags; 996 public float flyingSpeed; 997 public float walkingSpeed; 998 999 public pure nothrow @safe @nogc this() {} 1000 1001 public pure nothrow @safe @nogc this(ubyte flags, float flyingSpeed=float.init, float walkingSpeed=float.init) { 1002 this.flags = flags; 1003 this.flyingSpeed = flyingSpeed; 1004 this.walkingSpeed = walkingSpeed; 1005 } 1006 1007 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 1008 _buffer.length = 0; 1009 static if(writeId){ writeBytes(varuint.encode(ID)); } 1010 writeBigEndianUbyte(flags); 1011 writeBigEndianFloat(flyingSpeed); 1012 writeBigEndianFloat(walkingSpeed); 1013 return _buffer; 1014 } 1015 1016 public pure nothrow @safe void decode(bool readId=true)() { 1017 static if(readId){ uint _id; _id=varuint.decode(_buffer, &_index); } 1018 flags=readBigEndianUbyte(); 1019 flyingSpeed=readBigEndianFloat(); 1020 walkingSpeed=readBigEndianFloat(); 1021 } 1022 1023 public static pure nothrow @safe PlayerAbilities fromBuffer(bool readId=true)(ubyte[] buffer) { 1024 PlayerAbilities ret = new PlayerAbilities(); 1025 ret._buffer = buffer; 1026 ret.decode!readId(); 1027 return ret; 1028 } 1029 1030 public override string toString() { 1031 return "PlayerAbilities(flags: " ~ std.conv.to!string(this.flags) ~ ", flyingSpeed: " ~ std.conv.to!string(this.flyingSpeed) ~ ", walkingSpeed: " ~ std.conv.to!string(this.walkingSpeed) ~ ")"; 1032 } 1033 1034 } 1035 1036 class PlayerDigging : Buffer { 1037 1038 public enum uint ID = 20; 1039 1040 public enum bool CLIENTBOUND = false; 1041 public enum bool SERVERBOUND = true; 1042 1043 // status 1044 public enum uint START_DIGGING = 0; 1045 public enum uint CANCEL_DIGGING = 1; 1046 public enum uint FINISH_DIGGING = 2; 1047 public enum uint DROP_ITEM_STACK = 3; 1048 public enum uint DROP_ITEM = 4; 1049 public enum uint SHOOT_ARROW = 5; 1050 public enum uint FINISH_EATING = 5; 1051 public enum uint SWAP_ITEM_IN_HAND = 6; 1052 1053 public enum string[] FIELDS = ["status", "position", "face"]; 1054 1055 public uint status; 1056 public ulong position; 1057 public ubyte face; 1058 1059 public pure nothrow @safe @nogc this() {} 1060 1061 public pure nothrow @safe @nogc this(uint status, ulong position=ulong.init, ubyte face=ubyte.init) { 1062 this.status = status; 1063 this.position = position; 1064 this.face = face; 1065 } 1066 1067 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 1068 _buffer.length = 0; 1069 static if(writeId){ writeBytes(varuint.encode(ID)); } 1070 writeBytes(varuint.encode(status)); 1071 writeBigEndianUlong(position); 1072 writeBigEndianUbyte(face); 1073 return _buffer; 1074 } 1075 1076 public pure nothrow @safe void decode(bool readId=true)() { 1077 static if(readId){ uint _id; _id=varuint.decode(_buffer, &_index); } 1078 status=varuint.decode(_buffer, &_index); 1079 position=readBigEndianUlong(); 1080 face=readBigEndianUbyte(); 1081 } 1082 1083 public static pure nothrow @safe PlayerDigging fromBuffer(bool readId=true)(ubyte[] buffer) { 1084 PlayerDigging ret = new PlayerDigging(); 1085 ret._buffer = buffer; 1086 ret.decode!readId(); 1087 return ret; 1088 } 1089 1090 public override string toString() { 1091 return "PlayerDigging(status: " ~ std.conv.to!string(this.status) ~ ", position: " ~ std.conv.to!string(this.position) ~ ", face: " ~ std.conv.to!string(this.face) ~ ")"; 1092 } 1093 1094 } 1095 1096 class EntityAction : Buffer { 1097 1098 public enum uint ID = 21; 1099 1100 public enum bool CLIENTBOUND = false; 1101 public enum bool SERVERBOUND = true; 1102 1103 // action 1104 public enum uint START_SNEAKING = 0; 1105 public enum uint STOP_SNEAKING = 1; 1106 public enum uint LEAVE_BED = 2; 1107 public enum uint START_SPRINTING = 3; 1108 public enum uint STOP_SPRINTING = 4; 1109 public enum uint START_HORSE_JUMP = 5; 1110 public enum uint STOP_HORSE_JUMP = 6; 1111 public enum uint OPEN_HORSE_INVENTORY = 7; 1112 public enum uint START_ELYTRA_FLYING = 8; 1113 1114 public enum string[] FIELDS = ["entityId", "action", "jumpBoost"]; 1115 1116 public uint entityId; 1117 public uint action; 1118 public uint jumpBoost; 1119 1120 public pure nothrow @safe @nogc this() {} 1121 1122 public pure nothrow @safe @nogc this(uint entityId, uint action=uint.init, uint jumpBoost=uint.init) { 1123 this.entityId = entityId; 1124 this.action = action; 1125 this.jumpBoost = jumpBoost; 1126 } 1127 1128 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 1129 _buffer.length = 0; 1130 static if(writeId){ writeBytes(varuint.encode(ID)); } 1131 writeBytes(varuint.encode(entityId)); 1132 writeBytes(varuint.encode(action)); 1133 writeBytes(varuint.encode(jumpBoost)); 1134 return _buffer; 1135 } 1136 1137 public pure nothrow @safe void decode(bool readId=true)() { 1138 static if(readId){ uint _id; _id=varuint.decode(_buffer, &_index); } 1139 entityId=varuint.decode(_buffer, &_index); 1140 action=varuint.decode(_buffer, &_index); 1141 jumpBoost=varuint.decode(_buffer, &_index); 1142 } 1143 1144 public static pure nothrow @safe EntityAction fromBuffer(bool readId=true)(ubyte[] buffer) { 1145 EntityAction ret = new EntityAction(); 1146 ret._buffer = buffer; 1147 ret.decode!readId(); 1148 return ret; 1149 } 1150 1151 public override string toString() { 1152 return "EntityAction(entityId: " ~ std.conv.to!string(this.entityId) ~ ", action: " ~ std.conv.to!string(this.action) ~ ", jumpBoost: " ~ std.conv.to!string(this.jumpBoost) ~ ")"; 1153 } 1154 1155 } 1156 1157 class SteerVehicle : Buffer { 1158 1159 public enum uint ID = 22; 1160 1161 public enum bool CLIENTBOUND = false; 1162 public enum bool SERVERBOUND = true; 1163 1164 // flags 1165 public enum ubyte JUMP = 1; 1166 public enum ubyte UNMOUNT = 2; 1167 1168 public enum string[] FIELDS = ["sideways", "forward", "flags"]; 1169 1170 public float sideways; 1171 public float forward; 1172 public ubyte flags; 1173 1174 public pure nothrow @safe @nogc this() {} 1175 1176 public pure nothrow @safe @nogc this(float sideways, float forward=float.init, ubyte flags=ubyte.init) { 1177 this.sideways = sideways; 1178 this.forward = forward; 1179 this.flags = flags; 1180 } 1181 1182 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 1183 _buffer.length = 0; 1184 static if(writeId){ writeBytes(varuint.encode(ID)); } 1185 writeBigEndianFloat(sideways); 1186 writeBigEndianFloat(forward); 1187 writeBigEndianUbyte(flags); 1188 return _buffer; 1189 } 1190 1191 public pure nothrow @safe void decode(bool readId=true)() { 1192 static if(readId){ uint _id; _id=varuint.decode(_buffer, &_index); } 1193 sideways=readBigEndianFloat(); 1194 forward=readBigEndianFloat(); 1195 flags=readBigEndianUbyte(); 1196 } 1197 1198 public static pure nothrow @safe SteerVehicle fromBuffer(bool readId=true)(ubyte[] buffer) { 1199 SteerVehicle ret = new SteerVehicle(); 1200 ret._buffer = buffer; 1201 ret.decode!readId(); 1202 return ret; 1203 } 1204 1205 public override string toString() { 1206 return "SteerVehicle(sideways: " ~ std.conv.to!string(this.sideways) ~ ", forward: " ~ std.conv.to!string(this.forward) ~ ", flags: " ~ std.conv.to!string(this.flags) ~ ")"; 1207 } 1208 1209 } 1210 1211 class CraftingBookData : Buffer { 1212 1213 public enum uint ID = 23; 1214 1215 public enum bool CLIENTBOUND = false; 1216 public enum bool SERVERBOUND = true; 1217 1218 public enum string[] FIELDS = ["type"]; 1219 1220 public uint type; 1221 1222 public pure nothrow @safe @nogc this() {} 1223 1224 public pure nothrow @safe @nogc this(uint type) { 1225 this.type = type; 1226 } 1227 1228 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 1229 _buffer.length = 0; 1230 static if(writeId){ writeBytes(varuint.encode(ID)); } 1231 writeBytes(varuint.encode(type)); 1232 return _buffer; 1233 } 1234 1235 public pure nothrow @safe void decode(bool readId=true)() { 1236 static if(readId){ uint _id; _id=varuint.decode(_buffer, &_index); } 1237 type=varuint.decode(_buffer, &_index); 1238 } 1239 1240 public static pure nothrow @safe CraftingBookData fromBuffer(bool readId=true)(ubyte[] buffer) { 1241 CraftingBookData ret = new CraftingBookData(); 1242 ret._buffer = buffer; 1243 ret.decode!readId(); 1244 return ret; 1245 } 1246 1247 public override string toString() { 1248 return "CraftingBookData(type: " ~ std.conv.to!string(this.type) ~ ")"; 1249 } 1250 1251 alias _encode = encode; 1252 1253 enum string variantField = "type"; 1254 1255 alias Variants = TypeTuple!(DisplayedRecipe, CraftingBookStatus); 1256 1257 public class DisplayedRecipe { 1258 1259 public enum typeof(type) TYPE = 1; 1260 1261 public enum string[] FIELDS = ["id"]; 1262 1263 public uint id; 1264 1265 public pure nothrow @safe @nogc this() {} 1266 1267 public pure nothrow @safe @nogc this(uint id) { 1268 this.id = id; 1269 } 1270 1271 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 1272 type = 1; 1273 _encode!writeId(); 1274 writeBigEndianUint(id); 1275 return _buffer; 1276 } 1277 1278 public pure nothrow @safe void decode() { 1279 id=readBigEndianUint(); 1280 } 1281 1282 public override string toString() { 1283 return "CraftingBookData.DisplayedRecipe(id: " ~ std.conv.to!string(this.id) ~ ")"; 1284 } 1285 1286 } 1287 1288 public class CraftingBookStatus { 1289 1290 public enum typeof(type) TYPE = 2; 1291 1292 public enum string[] FIELDS = ["bookOpened", "filtering"]; 1293 1294 public bool bookOpened; 1295 public bool filtering; 1296 1297 public pure nothrow @safe @nogc this() {} 1298 1299 public pure nothrow @safe @nogc this(bool bookOpened, bool filtering=bool.init) { 1300 this.bookOpened = bookOpened; 1301 this.filtering = filtering; 1302 } 1303 1304 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 1305 type = 2; 1306 _encode!writeId(); 1307 writeBigEndianBool(bookOpened); 1308 writeBigEndianBool(filtering); 1309 return _buffer; 1310 } 1311 1312 public pure nothrow @safe void decode() { 1313 bookOpened=readBigEndianBool(); 1314 filtering=readBigEndianBool(); 1315 } 1316 1317 public override string toString() { 1318 return "CraftingBookData.CraftingBookStatus(bookOpened: " ~ std.conv.to!string(this.bookOpened) ~ ", filtering: " ~ std.conv.to!string(this.filtering) ~ ")"; 1319 } 1320 1321 } 1322 1323 } 1324 1325 class ResourcePackStatus : Buffer { 1326 1327 public enum uint ID = 24; 1328 1329 public enum bool CLIENTBOUND = false; 1330 public enum bool SERVERBOUND = true; 1331 1332 // result 1333 public enum uint LOADED = 0; 1334 public enum uint DECLINED = 1; 1335 public enum uint FAILED = 2; 1336 public enum uint ACCEPTED = 3; 1337 1338 public enum string[] FIELDS = ["result"]; 1339 1340 public uint result; 1341 1342 public pure nothrow @safe @nogc this() {} 1343 1344 public pure nothrow @safe @nogc this(uint result) { 1345 this.result = result; 1346 } 1347 1348 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 1349 _buffer.length = 0; 1350 static if(writeId){ writeBytes(varuint.encode(ID)); } 1351 writeBytes(varuint.encode(result)); 1352 return _buffer; 1353 } 1354 1355 public pure nothrow @safe void decode(bool readId=true)() { 1356 static if(readId){ uint _id; _id=varuint.decode(_buffer, &_index); } 1357 result=varuint.decode(_buffer, &_index); 1358 } 1359 1360 public static pure nothrow @safe ResourcePackStatus fromBuffer(bool readId=true)(ubyte[] buffer) { 1361 ResourcePackStatus ret = new ResourcePackStatus(); 1362 ret._buffer = buffer; 1363 ret.decode!readId(); 1364 return ret; 1365 } 1366 1367 public override string toString() { 1368 return "ResourcePackStatus(result: " ~ std.conv.to!string(this.result) ~ ")"; 1369 } 1370 1371 } 1372 1373 class AdvencementTab : Buffer { 1374 1375 public enum uint ID = 25; 1376 1377 public enum bool CLIENTBOUND = false; 1378 public enum bool SERVERBOUND = true; 1379 1380 // action 1381 public enum uint OPEN_TAB = 0; 1382 public enum uint CLOSE_SCREEN = 1; 1383 1384 public enum string[] FIELDS = ["action", "tab"]; 1385 1386 public uint action; 1387 public string tab; 1388 1389 public pure nothrow @safe @nogc this() {} 1390 1391 public pure nothrow @safe @nogc this(uint action, string tab=string.init) { 1392 this.action = action; 1393 this.tab = tab; 1394 } 1395 1396 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 1397 _buffer.length = 0; 1398 static if(writeId){ writeBytes(varuint.encode(ID)); } 1399 writeBytes(varuint.encode(action)); 1400 if(action==0){ writeBytes(varuint.encode(cast(uint)tab.length)); writeString(tab); } 1401 return _buffer; 1402 } 1403 1404 public pure nothrow @safe void decode(bool readId=true)() { 1405 static if(readId){ uint _id; _id=varuint.decode(_buffer, &_index); } 1406 action=varuint.decode(_buffer, &_index); 1407 if(action==0){ uint df=varuint.decode(_buffer, &_index); tab=readString(df); } 1408 } 1409 1410 public static pure nothrow @safe AdvencementTab fromBuffer(bool readId=true)(ubyte[] buffer) { 1411 AdvencementTab ret = new AdvencementTab(); 1412 ret._buffer = buffer; 1413 ret.decode!readId(); 1414 return ret; 1415 } 1416 1417 public override string toString() { 1418 return "AdvencementTab(action: " ~ std.conv.to!string(this.action) ~ ", tab: " ~ std.conv.to!string(this.tab) ~ ")"; 1419 } 1420 1421 } 1422 1423 class HeldItemChange : Buffer { 1424 1425 public enum uint ID = 26; 1426 1427 public enum bool CLIENTBOUND = false; 1428 public enum bool SERVERBOUND = true; 1429 1430 public enum string[] FIELDS = ["slot"]; 1431 1432 public ushort slot; 1433 1434 public pure nothrow @safe @nogc this() {} 1435 1436 public pure nothrow @safe @nogc this(ushort slot) { 1437 this.slot = slot; 1438 } 1439 1440 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 1441 _buffer.length = 0; 1442 static if(writeId){ writeBytes(varuint.encode(ID)); } 1443 writeBigEndianUshort(slot); 1444 return _buffer; 1445 } 1446 1447 public pure nothrow @safe void decode(bool readId=true)() { 1448 static if(readId){ uint _id; _id=varuint.decode(_buffer, &_index); } 1449 slot=readBigEndianUshort(); 1450 } 1451 1452 public static pure nothrow @safe HeldItemChange fromBuffer(bool readId=true)(ubyte[] buffer) { 1453 HeldItemChange ret = new HeldItemChange(); 1454 ret._buffer = buffer; 1455 ret.decode!readId(); 1456 return ret; 1457 } 1458 1459 public override string toString() { 1460 return "HeldItemChange(slot: " ~ std.conv.to!string(this.slot) ~ ")"; 1461 } 1462 1463 } 1464 1465 class CreativeInventoryAction : Buffer { 1466 1467 public enum uint ID = 27; 1468 1469 public enum bool CLIENTBOUND = false; 1470 public enum bool SERVERBOUND = true; 1471 1472 public enum string[] FIELDS = ["slot", "clickedItem"]; 1473 1474 public ushort slot; 1475 public sul.protocol.java340.types.Slot clickedItem; 1476 1477 public pure nothrow @safe @nogc this() {} 1478 1479 public pure nothrow @safe @nogc this(ushort slot, sul.protocol.java340.types.Slot clickedItem=sul.protocol.java340.types.Slot.init) { 1480 this.slot = slot; 1481 this.clickedItem = clickedItem; 1482 } 1483 1484 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 1485 _buffer.length = 0; 1486 static if(writeId){ writeBytes(varuint.encode(ID)); } 1487 writeBigEndianUshort(slot); 1488 clickedItem.encode(bufferInstance); 1489 return _buffer; 1490 } 1491 1492 public pure nothrow @safe void decode(bool readId=true)() { 1493 static if(readId){ uint _id; _id=varuint.decode(_buffer, &_index); } 1494 slot=readBigEndianUshort(); 1495 clickedItem.decode(bufferInstance); 1496 } 1497 1498 public static pure nothrow @safe CreativeInventoryAction fromBuffer(bool readId=true)(ubyte[] buffer) { 1499 CreativeInventoryAction ret = new CreativeInventoryAction(); 1500 ret._buffer = buffer; 1501 ret.decode!readId(); 1502 return ret; 1503 } 1504 1505 public override string toString() { 1506 return "CreativeInventoryAction(slot: " ~ std.conv.to!string(this.slot) ~ ", clickedItem: " ~ std.conv.to!string(this.clickedItem) ~ ")"; 1507 } 1508 1509 } 1510 1511 class UpdateSign : Buffer { 1512 1513 public enum uint ID = 28; 1514 1515 public enum bool CLIENTBOUND = false; 1516 public enum bool SERVERBOUND = true; 1517 1518 public enum string[] FIELDS = ["position", "lines"]; 1519 1520 public ulong position; 1521 public string[4] lines; 1522 1523 public pure nothrow @safe @nogc this() {} 1524 1525 public pure nothrow @safe @nogc this(ulong position, string[4] lines=(string[4]).init) { 1526 this.position = position; 1527 this.lines = lines; 1528 } 1529 1530 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 1531 _buffer.length = 0; 1532 static if(writeId){ writeBytes(varuint.encode(ID)); } 1533 writeBigEndianUlong(position); 1534 foreach(blzm;lines){ writeBytes(varuint.encode(cast(uint)blzm.length)); writeString(blzm); } 1535 return _buffer; 1536 } 1537 1538 public pure nothrow @safe void decode(bool readId=true)() { 1539 static if(readId){ uint _id; _id=varuint.decode(_buffer, &_index); } 1540 position=readBigEndianUlong(); 1541 foreach(ref blzm;lines){ uint yxb=varuint.decode(_buffer, &_index); blzm=readString(yxb); } 1542 } 1543 1544 public static pure nothrow @safe UpdateSign fromBuffer(bool readId=true)(ubyte[] buffer) { 1545 UpdateSign ret = new UpdateSign(); 1546 ret._buffer = buffer; 1547 ret.decode!readId(); 1548 return ret; 1549 } 1550 1551 public override string toString() { 1552 return "UpdateSign(position: " ~ std.conv.to!string(this.position) ~ ", lines: " ~ std.conv.to!string(this.lines) ~ ")"; 1553 } 1554 1555 } 1556 1557 class Animation : Buffer { 1558 1559 public enum uint ID = 29; 1560 1561 public enum bool CLIENTBOUND = false; 1562 public enum bool SERVERBOUND = true; 1563 1564 // hand 1565 public enum uint MAIN_HAND = 0; 1566 public enum uint OFF_HAND = 1; 1567 1568 public enum string[] FIELDS = ["hand"]; 1569 1570 public uint hand; 1571 1572 public pure nothrow @safe @nogc this() {} 1573 1574 public pure nothrow @safe @nogc this(uint hand) { 1575 this.hand = hand; 1576 } 1577 1578 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 1579 _buffer.length = 0; 1580 static if(writeId){ writeBytes(varuint.encode(ID)); } 1581 writeBytes(varuint.encode(hand)); 1582 return _buffer; 1583 } 1584 1585 public pure nothrow @safe void decode(bool readId=true)() { 1586 static if(readId){ uint _id; _id=varuint.decode(_buffer, &_index); } 1587 hand=varuint.decode(_buffer, &_index); 1588 } 1589 1590 public static pure nothrow @safe Animation fromBuffer(bool readId=true)(ubyte[] buffer) { 1591 Animation ret = new Animation(); 1592 ret._buffer = buffer; 1593 ret.decode!readId(); 1594 return ret; 1595 } 1596 1597 public override string toString() { 1598 return "Animation(hand: " ~ std.conv.to!string(this.hand) ~ ")"; 1599 } 1600 1601 } 1602 1603 class Spectate : Buffer { 1604 1605 public enum uint ID = 30; 1606 1607 public enum bool CLIENTBOUND = false; 1608 public enum bool SERVERBOUND = true; 1609 1610 public enum string[] FIELDS = ["player"]; 1611 1612 public UUID player; 1613 1614 public pure nothrow @safe @nogc this() {} 1615 1616 public pure nothrow @safe @nogc this(UUID player) { 1617 this.player = player; 1618 } 1619 1620 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 1621 _buffer.length = 0; 1622 static if(writeId){ writeBytes(varuint.encode(ID)); } 1623 writeBytes(player.data); 1624 return _buffer; 1625 } 1626 1627 public pure nothrow @safe void decode(bool readId=true)() { 1628 static if(readId){ uint _id; _id=varuint.decode(_buffer, &_index); } 1629 if(_buffer.length>=_index+16){ ubyte[16] cxev=_buffer[_index.._index+16].dup; _index+=16; player=UUID(cxev); } 1630 } 1631 1632 public static pure nothrow @safe Spectate fromBuffer(bool readId=true)(ubyte[] buffer) { 1633 Spectate ret = new Spectate(); 1634 ret._buffer = buffer; 1635 ret.decode!readId(); 1636 return ret; 1637 } 1638 1639 public override string toString() { 1640 return "Spectate(player: " ~ std.conv.to!string(this.player) ~ ")"; 1641 } 1642 1643 } 1644 1645 class PlayerBlockPlacement : Buffer { 1646 1647 public enum uint ID = 31; 1648 1649 public enum bool CLIENTBOUND = false; 1650 public enum bool SERVERBOUND = true; 1651 1652 // hand 1653 public enum uint MAIN_HAND = 0; 1654 public enum uint OFF_HAND = 1; 1655 1656 public enum string[] FIELDS = ["position", "face", "hand", "cursorPosition"]; 1657 1658 public ulong position; 1659 public uint face; 1660 public uint hand; 1661 public Tuple!(float, "x", float, "y", float, "z") cursorPosition; 1662 1663 public pure nothrow @safe @nogc this() {} 1664 1665 public pure nothrow @safe @nogc this(ulong position, uint face=uint.init, uint hand=uint.init, Tuple!(float, "x", float, "y", float, "z") cursorPosition=Tuple!(float, "x", float, "y", float, "z").init) { 1666 this.position = position; 1667 this.face = face; 1668 this.hand = hand; 1669 this.cursorPosition = cursorPosition; 1670 } 1671 1672 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 1673 _buffer.length = 0; 1674 static if(writeId){ writeBytes(varuint.encode(ID)); } 1675 writeBigEndianUlong(position); 1676 writeBytes(varuint.encode(face)); 1677 writeBytes(varuint.encode(hand)); 1678 writeBigEndianFloat(cursorPosition.x); writeBigEndianFloat(cursorPosition.y); writeBigEndianFloat(cursorPosition.z); 1679 return _buffer; 1680 } 1681 1682 public pure nothrow @safe void decode(bool readId=true)() { 1683 static if(readId){ uint _id; _id=varuint.decode(_buffer, &_index); } 1684 position=readBigEndianUlong(); 1685 face=varuint.decode(_buffer, &_index); 1686 hand=varuint.decode(_buffer, &_index); 1687 cursorPosition.x=readBigEndianFloat(); cursorPosition.y=readBigEndianFloat(); cursorPosition.z=readBigEndianFloat(); 1688 } 1689 1690 public static pure nothrow @safe PlayerBlockPlacement fromBuffer(bool readId=true)(ubyte[] buffer) { 1691 PlayerBlockPlacement ret = new PlayerBlockPlacement(); 1692 ret._buffer = buffer; 1693 ret.decode!readId(); 1694 return ret; 1695 } 1696 1697 public override string toString() { 1698 return "PlayerBlockPlacement(position: " ~ std.conv.to!string(this.position) ~ ", face: " ~ std.conv.to!string(this.face) ~ ", hand: " ~ std.conv.to!string(this.hand) ~ ", cursorPosition: " ~ std.conv.to!string(this.cursorPosition) ~ ")"; 1699 } 1700 1701 } 1702 1703 class UseItem : Buffer { 1704 1705 public enum uint ID = 32; 1706 1707 public enum bool CLIENTBOUND = false; 1708 public enum bool SERVERBOUND = true; 1709 1710 // hand 1711 public enum uint MAIN_HAND = 0; 1712 public enum uint OFF_HAND = 1; 1713 1714 public enum string[] FIELDS = ["hand"]; 1715 1716 public uint hand; 1717 1718 public pure nothrow @safe @nogc this() {} 1719 1720 public pure nothrow @safe @nogc this(uint hand) { 1721 this.hand = hand; 1722 } 1723 1724 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 1725 _buffer.length = 0; 1726 static if(writeId){ writeBytes(varuint.encode(ID)); } 1727 writeBytes(varuint.encode(hand)); 1728 return _buffer; 1729 } 1730 1731 public pure nothrow @safe void decode(bool readId=true)() { 1732 static if(readId){ uint _id; _id=varuint.decode(_buffer, &_index); } 1733 hand=varuint.decode(_buffer, &_index); 1734 } 1735 1736 public static pure nothrow @safe UseItem fromBuffer(bool readId=true)(ubyte[] buffer) { 1737 UseItem ret = new UseItem(); 1738 ret._buffer = buffer; 1739 ret.decode!readId(); 1740 return ret; 1741 } 1742 1743 public override string toString() { 1744 return "UseItem(hand: " ~ std.conv.to!string(this.hand) ~ ")"; 1745 } 1746 1747 } 1748