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