1 /* 2 * This file was automatically generated by sel-utils and 3 * released under the MIT License. 4 * 5 * License: https://github.com/sel-project/sel-utils/blob/master/LICENSE 6 * Repository: https://github.com/sel-project/sel-utils 7 * Generated from https://github.com/sel-project/sel-utils/blob/master/xml/protocol/java210.xml 8 */ 9 module sul.protocol.java210.types; 10 11 import std.bitmanip : write, peek; 12 static import std.conv; 13 import std.system : Endian; 14 import std.typecons : Tuple; 15 import std.uuid : UUID; 16 17 import sul.utils.buffer; 18 import sul.utils.var; 19 20 static if(__traits(compiles, { import sul.metadata.java210; })) import sul.metadata.java210; 21 22 struct Statistic { 23 24 public enum string[] FIELDS = ["name", "value"]; 25 26 public string name; 27 public uint value; 28 29 public pure nothrow @safe void encode(Buffer buffer) { 30 with(buffer) { 31 writeBytes(varuint.encode(cast(uint)name.length)); writeString(name); 32 writeBytes(varuint.encode(value)); 33 } 34 } 35 36 public pure nothrow @safe void decode(Buffer buffer) { 37 with(buffer) { 38 uint bfz=varuint.decode(_buffer, &_index); name=readString(bfz); 39 value=varuint.decode(_buffer, &_index); 40 } 41 } 42 43 public string toString() { 44 return "Statistic(name: " ~ std.conv.to!string(this.name) ~ ", value: " ~ std.conv.to!string(this.value) ~ ")"; 45 } 46 47 } 48 49 struct BlockChange { 50 51 public enum string[] FIELDS = ["xz", "y", "block"]; 52 53 public ubyte xz; 54 public ubyte y; 55 public uint block; 56 57 public pure nothrow @safe void encode(Buffer buffer) { 58 with(buffer) { 59 writeBigEndianUbyte(xz); 60 writeBigEndianUbyte(y); 61 writeBytes(varuint.encode(block)); 62 } 63 } 64 65 public pure nothrow @safe void decode(Buffer buffer) { 66 with(buffer) { 67 xz=readBigEndianUbyte(); 68 y=readBigEndianUbyte(); 69 block=varuint.decode(_buffer, &_index); 70 } 71 } 72 73 public string toString() { 74 return "BlockChange(xz: " ~ std.conv.to!string(this.xz) ~ ", y: " ~ std.conv.to!string(this.y) ~ ", block: " ~ std.conv.to!string(this.block) ~ ")"; 75 } 76 77 } 78 79 struct Slot { 80 81 public enum string[] FIELDS = ["id", "count", "damage", "nbt"]; 82 83 public short id; 84 public ubyte count; 85 public ushort damage; 86 public ubyte[] nbt; 87 88 public pure nothrow @safe void encode(Buffer buffer) { 89 with(buffer) { 90 writeBigEndianShort(id); 91 if(id>0){ writeBigEndianUbyte(count); } 92 if(id>0){ writeBigEndianUshort(damage); } 93 if(id>0){ writeBytes(nbt); } 94 } 95 } 96 97 public pure nothrow @safe void decode(Buffer buffer) { 98 with(buffer) { 99 id=readBigEndianShort(); 100 if(id>0){ count=readBigEndianUbyte(); } 101 if(id>0){ damage=readBigEndianUshort(); } 102 if(id>0){ nbt=_buffer[_index..$].dup; _index=_buffer.length; } 103 } 104 } 105 106 public string toString() { 107 return "Slot(id: " ~ std.conv.to!string(this.id) ~ ", count: " ~ std.conv.to!string(this.count) ~ ", damage: " ~ std.conv.to!string(this.damage) ~ ", nbt: " ~ std.conv.to!string(this.nbt) ~ ")"; 108 } 109 110 } 111 112 struct Icon { 113 114 // direction and type 115 public enum ubyte WHITE_ARROW = 0; 116 public enum ubyte GREEN_ARROW = 1; 117 public enum ubyte RED_ARROW = 2; 118 public enum ubyte BLUE_ARROW = 3; 119 public enum ubyte WHITE_CROSS = 4; 120 public enum ubyte RED_POINTER = 5; 121 public enum ubyte WHITE_CIRCLE = 6; 122 123 public enum string[] FIELDS = ["directionAndType", "position"]; 124 125 public ubyte directionAndType; 126 public Tuple!(ubyte, "x", ubyte, "z") position; 127 128 public pure nothrow @safe void encode(Buffer buffer) { 129 with(buffer) { 130 writeBigEndianUbyte(directionAndType); 131 writeBigEndianUbyte(position.x); writeBigEndianUbyte(position.z); 132 } 133 } 134 135 public pure nothrow @safe void decode(Buffer buffer) { 136 with(buffer) { 137 directionAndType=readBigEndianUbyte(); 138 position.x=readBigEndianUbyte(); position.z=readBigEndianUbyte(); 139 } 140 } 141 142 public string toString() { 143 return "Icon(directionAndType: " ~ std.conv.to!string(this.directionAndType) ~ ", position: " ~ std.conv.to!string(this.position) ~ ")"; 144 } 145 146 } 147 148 struct Property { 149 150 public enum string[] FIELDS = ["name", "value", "signed", "signature"]; 151 152 public string name; 153 public string value; 154 public bool signed; 155 public string signature; 156 157 public pure nothrow @safe void encode(Buffer buffer) { 158 with(buffer) { 159 writeBytes(varuint.encode(cast(uint)name.length)); writeString(name); 160 writeBytes(varuint.encode(cast(uint)value.length)); writeString(value); 161 writeBigEndianBool(signed); 162 if(signed==true){ writeBytes(varuint.encode(cast(uint)signature.length)); writeString(signature); } 163 } 164 } 165 166 public pure nothrow @safe void decode(Buffer buffer) { 167 with(buffer) { 168 uint bfz=varuint.decode(_buffer, &_index); name=readString(bfz); 169 uint dfdu=varuint.decode(_buffer, &_index); value=readString(dfdu); 170 signed=readBigEndianBool(); 171 if(signed==true){ uint clbfdj=varuint.decode(_buffer, &_index); signature=readString(clbfdj); } 172 } 173 } 174 175 public string toString() { 176 return "Property(name: " ~ std.conv.to!string(this.name) ~ ", value: " ~ std.conv.to!string(this.value) ~ ", signed: " ~ std.conv.to!string(this.signed) ~ ", signature: " ~ std.conv.to!string(this.signature) ~ ")"; 177 } 178 179 } 180 181 struct ListAddPlayer { 182 183 // gamemode 184 public enum uint SURVIVAL = 0; 185 public enum uint CREATIVE = 1; 186 public enum uint ADVENTURE = 2; 187 public enum uint SPECTATOR = 3; 188 189 public enum string[] FIELDS = ["uuid", "name", "properties", "gamemode", "latency", "hasDisplayName", "displayName"]; 190 191 public UUID uuid; 192 public string name; 193 public sul.protocol.java210.types.Property[] properties; 194 public uint gamemode; 195 public uint latency; 196 public bool hasDisplayName; 197 public string displayName; 198 199 public pure nothrow @safe void encode(Buffer buffer) { 200 with(buffer) { 201 writeBytes(uuid.data); 202 writeBytes(varuint.encode(cast(uint)name.length)); writeString(name); 203 writeBytes(varuint.encode(cast(uint)properties.length)); foreach(cjcvdlc;properties){ cjcvdlc.encode(bufferInstance); } 204 writeBytes(varuint.encode(gamemode)); 205 writeBytes(varuint.encode(latency)); 206 writeBigEndianBool(hasDisplayName); 207 if(hasDisplayName==true){ writeBytes(varuint.encode(cast(uint)displayName.length)); writeString(displayName); } 208 } 209 } 210 211 public pure nothrow @safe void decode(Buffer buffer) { 212 with(buffer) { 213 if(_buffer.length>=_index+16){ ubyte[16] dvz=_buffer[_index.._index+16].dup; _index+=16; uuid=UUID(dvz); } 214 uint bfz=varuint.decode(_buffer, &_index); name=readString(bfz); 215 properties.length=varuint.decode(_buffer, &_index); foreach(ref cjcvdlc;properties){ cjcvdlc.decode(bufferInstance); } 216 gamemode=varuint.decode(_buffer, &_index); 217 latency=varuint.decode(_buffer, &_index); 218 hasDisplayName=readBigEndianBool(); 219 if(hasDisplayName==true){ uint zlcxe5bu=varuint.decode(_buffer, &_index); displayName=readString(zlcxe5bu); } 220 } 221 } 222 223 public string toString() { 224 return "ListAddPlayer(uuid: " ~ std.conv.to!string(this.uuid) ~ ", name: " ~ std.conv.to!string(this.name) ~ ", properties: " ~ std.conv.to!string(this.properties) ~ ", gamemode: " ~ std.conv.to!string(this.gamemode) ~ ", latency: " ~ std.conv.to!string(this.latency) ~ ", hasDisplayName: " ~ std.conv.to!string(this.hasDisplayName) ~ ", displayName: " ~ std.conv.to!string(this.displayName) ~ ")"; 225 } 226 227 } 228 229 struct ListUpdateGamemode { 230 231 // gamemode 232 public enum uint SURVIVAL = 0; 233 public enum uint CREATIVE = 1; 234 public enum uint ADVENTURE = 2; 235 public enum uint SPECTATOR = 3; 236 237 public enum string[] FIELDS = ["uuid", "gamemode"]; 238 239 public UUID uuid; 240 public uint gamemode; 241 242 public pure nothrow @safe void encode(Buffer buffer) { 243 with(buffer) { 244 writeBytes(uuid.data); 245 writeBytes(varuint.encode(gamemode)); 246 } 247 } 248 249 public pure nothrow @safe void decode(Buffer buffer) { 250 with(buffer) { 251 if(_buffer.length>=_index+16){ ubyte[16] dvz=_buffer[_index.._index+16].dup; _index+=16; uuid=UUID(dvz); } 252 gamemode=varuint.decode(_buffer, &_index); 253 } 254 } 255 256 public string toString() { 257 return "ListUpdateGamemode(uuid: " ~ std.conv.to!string(this.uuid) ~ ", gamemode: " ~ std.conv.to!string(this.gamemode) ~ ")"; 258 } 259 260 } 261 262 struct ListUpdateLatency { 263 264 public enum string[] FIELDS = ["uuid", "latency"]; 265 266 public UUID uuid; 267 public uint latency; 268 269 public pure nothrow @safe void encode(Buffer buffer) { 270 with(buffer) { 271 writeBytes(uuid.data); 272 writeBytes(varuint.encode(latency)); 273 } 274 } 275 276 public pure nothrow @safe void decode(Buffer buffer) { 277 with(buffer) { 278 if(_buffer.length>=_index+16){ ubyte[16] dvz=_buffer[_index.._index+16].dup; _index+=16; uuid=UUID(dvz); } 279 latency=varuint.decode(_buffer, &_index); 280 } 281 } 282 283 public string toString() { 284 return "ListUpdateLatency(uuid: " ~ std.conv.to!string(this.uuid) ~ ", latency: " ~ std.conv.to!string(this.latency) ~ ")"; 285 } 286 287 } 288 289 struct ListUpdateDisplayName { 290 291 public enum string[] FIELDS = ["uuid", "hasDisplayName", "displayName"]; 292 293 public UUID uuid; 294 public bool hasDisplayName; 295 public string displayName; 296 297 public pure nothrow @safe void encode(Buffer buffer) { 298 with(buffer) { 299 writeBytes(uuid.data); 300 writeBigEndianBool(hasDisplayName); 301 if(hasDisplayName==true){ writeBytes(varuint.encode(cast(uint)displayName.length)); writeString(displayName); } 302 } 303 } 304 305 public pure nothrow @safe void decode(Buffer buffer) { 306 with(buffer) { 307 if(_buffer.length>=_index+16){ ubyte[16] dvz=_buffer[_index.._index+16].dup; _index+=16; uuid=UUID(dvz); } 308 hasDisplayName=readBigEndianBool(); 309 if(hasDisplayName==true){ uint zlcxe5bu=varuint.decode(_buffer, &_index); displayName=readString(zlcxe5bu); } 310 } 311 } 312 313 public string toString() { 314 return "ListUpdateDisplayName(uuid: " ~ std.conv.to!string(this.uuid) ~ ", hasDisplayName: " ~ std.conv.to!string(this.hasDisplayName) ~ ", displayName: " ~ std.conv.to!string(this.displayName) ~ ")"; 315 } 316 317 } 318 319 struct Modifier { 320 321 // operation 322 public enum ubyte ADD_SUBSTRACT_AMOUNT = 0; 323 public enum ubyte ADD_SUBSTRACT_AMOUNT_PERCENTAGE = 1; 324 public enum ubyte MULTIPLY_AMOUNT_PERCENTAGE = 2; 325 326 public enum string[] FIELDS = ["uuid", "amount", "operation"]; 327 328 public UUID uuid; 329 public double amount; 330 public ubyte operation; 331 332 public pure nothrow @safe void encode(Buffer buffer) { 333 with(buffer) { 334 writeBytes(uuid.data); 335 writeBigEndianDouble(amount); 336 writeBigEndianUbyte(operation); 337 } 338 } 339 340 public pure nothrow @safe void decode(Buffer buffer) { 341 with(buffer) { 342 if(_buffer.length>=_index+16){ ubyte[16] dvz=_buffer[_index.._index+16].dup; _index+=16; uuid=UUID(dvz); } 343 amount=readBigEndianDouble(); 344 operation=readBigEndianUbyte(); 345 } 346 } 347 348 public string toString() { 349 return "Modifier(uuid: " ~ std.conv.to!string(this.uuid) ~ ", amount: " ~ std.conv.to!string(this.amount) ~ ", operation: " ~ std.conv.to!string(this.operation) ~ ")"; 350 } 351 352 } 353 354 struct Attribute { 355 356 public enum string[] FIELDS = ["key", "value", "modifiers"]; 357 358 public string key; 359 public double value; 360 public sul.protocol.java210.types.Modifier[] modifiers; 361 362 public pure nothrow @safe void encode(Buffer buffer) { 363 with(buffer) { 364 writeBytes(varuint.encode(cast(uint)key.length)); writeString(key); 365 writeBigEndianDouble(value); 366 writeBytes(varuint.encode(cast(uint)modifiers.length)); foreach(b9azzj;modifiers){ b9azzj.encode(bufferInstance); } 367 } 368 } 369 370 public pure nothrow @safe void decode(Buffer buffer) { 371 with(buffer) { 372 uint av=varuint.decode(_buffer, &_index); key=readString(av); 373 value=readBigEndianDouble(); 374 modifiers.length=varuint.decode(_buffer, &_index); foreach(ref b9azzj;modifiers){ b9azzj.decode(bufferInstance); } 375 } 376 } 377 378 public string toString() { 379 return "Attribute(key: " ~ std.conv.to!string(this.key) ~ ", value: " ~ std.conv.to!string(this.value) ~ ", modifiers: " ~ std.conv.to!string(this.modifiers) ~ ")"; 380 } 381 382 } 383 384 struct OptionalPosition { 385 386 public enum string[] FIELDS = ["hasPosition", "position"]; 387 388 public bool hasPosition; 389 public ulong position; 390 391 public pure nothrow @safe void encode(Buffer buffer) { 392 with(buffer) { 393 writeBigEndianBool(hasPosition); 394 if(hasPosition==true){ writeBigEndianUlong(position); } 395 } 396 } 397 398 public pure nothrow @safe void decode(Buffer buffer) { 399 with(buffer) { 400 hasPosition=readBigEndianBool(); 401 if(hasPosition==true){ position=readBigEndianUlong(); } 402 } 403 } 404 405 public string toString() { 406 return "OptionalPosition(hasPosition: " ~ std.conv.to!string(this.hasPosition) ~ ", position: " ~ std.conv.to!string(this.position) ~ ")"; 407 } 408 409 } 410 411 struct OptionalUuid { 412 413 public enum string[] FIELDS = ["hasUuid", "uuid"]; 414 415 public bool hasUuid; 416 public UUID uuid; 417 418 public pure nothrow @safe void encode(Buffer buffer) { 419 with(buffer) { 420 writeBigEndianBool(hasUuid); 421 writeBytes(uuid.data); 422 } 423 } 424 425 public pure nothrow @safe void decode(Buffer buffer) { 426 with(buffer) { 427 hasUuid=readBigEndianBool(); 428 if(_buffer.length>=_index+16){ ubyte[16] dvz=_buffer[_index.._index+16].dup; _index+=16; uuid=UUID(dvz); } 429 } 430 } 431 432 public string toString() { 433 return "OptionalUuid(hasUuid: " ~ std.conv.to!string(this.hasUuid) ~ ", uuid: " ~ std.conv.to!string(this.uuid) ~ ")"; 434 } 435 436 } 437