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