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