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/metadata/pocket105.xml
8  */
9 module sul.metadata.pocket105;
10 
11 import std.typecons : Tuple, tuple;
12 
13 import sul.utils.buffer : Buffer;
14 import sul.utils.metadataflags;
15 import sul.utils.var;
16 
17 static import sul.protocol.pocket105.types;
18 
19 alias Changed(T) = Tuple!(T, "value", bool, "changed");
20 
21 enum MetadataType : uint {
22 
23 	BYTE = 0,
24 	SHORT = 1,
25 	INT = 2,
26 	FLOAT = 3,
27 	STRING = 4,
28 	SLOT = 5,
29 	BLOCK_POSITION = 6,
30 	LONG = 7,
31 	ENTITY_POSITION = 8,
32 }
33 
34 class Metadata {
35 
36 	public enum ENTITY_FLAGS : size_t {
37 		ON_FIRE = 0,
38 		SNEAKING = 1,
39 		RIDING = 2,
40 		SPRINTING = 3,
41 		USING_ITEM = 4,
42 		INVISIBLE = 5,
43 		TEMPTED = 6,
44 		IN_LOVE = 7,
45 		SADDLED = 8,
46 		POWERED = 9,
47 		IGNITED = 10,
48 		BABY = 11,
49 		CONVERTING = 12,
50 		CRITICAL = 13,
51 		SHOW_NAMETAG = 14,
52 		ALWAYS_SHOW_NAMETAG = 15,
53 		NO_AI = 16,
54 		SILENT = 17,
55 		CLIMBING = 18,
56 		RESTING = 19,
57 		SITTING = 20,
58 		ANGRY = 21,
59 		INTERESTED = 22,
60 		CHARGED = 23,
61 		TAMED = 24,
62 		LEASHED = 25,
63 		SHEARED = 26,
64 		GLIDING = 27,
65 		ELDER = 28,
66 		MOVING = 29,
67 		BREATHING = 30,
68 		CHESTED = 31,
69 		STACKABLE = 32,
70 		IDLING = 36,
71 	}
72 	public enum uint VARIANT = 2;
73 	public enum uint COLOR = 3;
74 	public enum uint NAMETAG = 4;
75 	public enum uint OWNER = 5;
76 	public enum uint AIR = 7;
77 	public enum uint POTION_COLOR = 8;
78 	public enum uint POTION_AMBIENT = 9;
79 	public enum uint SLIME_SIZE = 16;
80 	public enum PLAYER_FLAGS : size_t {
81 		ASLEEP = 1,
82 	}
83 	public enum uint PLAYER_INDEX = 28;
84 	public enum uint BED_POSITION = 29;
85 	public enum uint LEAD_HOLDER = 38;
86 	public enum uint SCALE = 39;
87 	public enum uint INTERACTIVE_TAG = 40;
88 	public enum uint INTERACTIVE_TAG_URL = 43;
89 	public enum uint MAX_AIR = 44;
90 	public enum uint MARK_VARIANT = 45;
91 	public enum uint BOUNDING_BOX_WIDTH = 54;
92 	public enum uint BOUNDING_BOX_HEIGHT = 55;
93 	public enum uint FUSE_LENGTH = 56;
94 	public enum uint AREA_EFFECT_CLOUD_RADIUS = 61;
95 	public enum uint AREA_EFFECT_CLOUD_WAITING = 62;
96 	public enum uint AREA_EFFECT_CLOUD_PARTICLE = 63;
97 	public enum uint TRADING_PLAYER = 68;
98 
99 	public DecodedMetadata[] decoded;
100 
101 	private bool _cached = false;
102 	private ubyte[] _cache;
103 
104 	private void delegate(Buffer) pure nothrow @safe[] _changed;
105 
106 	private MetadataFlags!(long) _entityFlags = cast(MetadataFlags!(long))0;
107 	private Changed!(int) _variant;
108 	private Changed!(byte) _color;
109 	private Changed!(string) _nametag;
110 	private Changed!(long) _owner = tuple(cast(long)-1, false);
111 	private short _air = cast(short)0;
112 	private Changed!(int) _potionColor;
113 	private Changed!(byte) _potionAmbient;
114 	private Changed!(byte) _slimeSize = tuple(cast(byte)1, false);
115 	private Changed!(MetadataFlags!(byte)) _playerFlags;
116 	private Changed!(int) _playerIndex;
117 	private Changed!(Tuple!(int, "x", int, "y", int, "z")) _bedPosition;
118 	private long _leadHolder = cast(long)-1;
119 	private Changed!(float) _scale = tuple(cast(float)1, false);
120 	private Changed!(string) _interactiveTag;
121 	private Changed!(string) _interactiveTagUrl;
122 	private Changed!(short) _maxAir;
123 	private Changed!(int) _markVariant;
124 	private Changed!(float) _boundingBoxWidth;
125 	private Changed!(float) _boundingBoxHeight;
126 	private Changed!(int) _fuseLength;
127 	private Changed!(float) _areaEffectCloudRadius;
128 	private Changed!(int) _areaEffectCloudWaiting;
129 	private Changed!(int) _areaEffectCloudParticle;
130 	private Changed!(long) _tradingPlayer;
131 
132 	public pure nothrow @safe this() {
133 		this.reset();
134 	}
135 
136 	public pure nothrow @safe void reset() {
137 		this._changed = [
138 			&this.encodeEntityFlags,
139 			&this.encodeAir,
140 			&this.encodeLeadHolder,
141 		];
142 	}
143 
144 	public pure nothrow @property @safe @nogc long entityFlags() {
145 		return _entityFlags;
146 	}
147 
148 	public pure nothrow @property @safe long entityFlags(long value) {
149 		this._cached = false;
150 		this._entityFlags = value;
151 		return value;
152 	}
153 
154 	public pure nothrow @safe encodeEntityFlags(Buffer buffer) {
155 		with(buffer) {
156 			writeBytes(varuint.encode(0));
157 			writeBytes(varuint.encode(7));
158 			writeBytes(varlong.encode(this._entityFlags));
159 		}
160 	}
161 
162 	public pure nothrow @property @safe bool onFire() {
163 		return _entityFlags._0;
164 	}
165 
166 	public pure nothrow @property @safe bool onFire(bool value) {
167 		_entityFlags._0 = value;
168 		return value;
169 	}
170 
171 	public pure nothrow @property @safe bool sneaking() {
172 		return _entityFlags._1;
173 	}
174 
175 	public pure nothrow @property @safe bool sneaking(bool value) {
176 		_entityFlags._1 = value;
177 		return value;
178 	}
179 
180 	public pure nothrow @property @safe bool riding() {
181 		return _entityFlags._2;
182 	}
183 
184 	public pure nothrow @property @safe bool riding(bool value) {
185 		_entityFlags._2 = value;
186 		return value;
187 	}
188 
189 	public pure nothrow @property @safe bool sprinting() {
190 		return _entityFlags._3;
191 	}
192 
193 	public pure nothrow @property @safe bool sprinting(bool value) {
194 		_entityFlags._3 = value;
195 		return value;
196 	}
197 
198 	public pure nothrow @property @safe bool usingItem() {
199 		return _entityFlags._4;
200 	}
201 
202 	public pure nothrow @property @safe bool usingItem(bool value) {
203 		_entityFlags._4 = value;
204 		return value;
205 	}
206 
207 	public pure nothrow @property @safe bool invisible() {
208 		return _entityFlags._5;
209 	}
210 
211 	public pure nothrow @property @safe bool invisible(bool value) {
212 		_entityFlags._5 = value;
213 		return value;
214 	}
215 
216 	public pure nothrow @property @safe bool tempted() {
217 		return _entityFlags._6;
218 	}
219 
220 	public pure nothrow @property @safe bool tempted(bool value) {
221 		_entityFlags._6 = value;
222 		return value;
223 	}
224 
225 	public pure nothrow @property @safe bool inLove() {
226 		return _entityFlags._7;
227 	}
228 
229 	public pure nothrow @property @safe bool inLove(bool value) {
230 		_entityFlags._7 = value;
231 		return value;
232 	}
233 
234 	public pure nothrow @property @safe bool saddled() {
235 		return _entityFlags._8;
236 	}
237 
238 	public pure nothrow @property @safe bool saddled(bool value) {
239 		_entityFlags._8 = value;
240 		return value;
241 	}
242 
243 	public pure nothrow @property @safe bool powered() {
244 		return _entityFlags._9;
245 	}
246 
247 	public pure nothrow @property @safe bool powered(bool value) {
248 		_entityFlags._9 = value;
249 		return value;
250 	}
251 
252 	public pure nothrow @property @safe bool ignited() {
253 		return _entityFlags._10;
254 	}
255 
256 	public pure nothrow @property @safe bool ignited(bool value) {
257 		_entityFlags._10 = value;
258 		return value;
259 	}
260 
261 	public pure nothrow @property @safe bool baby() {
262 		return _entityFlags._11;
263 	}
264 
265 	public pure nothrow @property @safe bool baby(bool value) {
266 		_entityFlags._11 = value;
267 		return value;
268 	}
269 
270 	public pure nothrow @property @safe bool converting() {
271 		return _entityFlags._12;
272 	}
273 
274 	public pure nothrow @property @safe bool converting(bool value) {
275 		_entityFlags._12 = value;
276 		return value;
277 	}
278 
279 	public pure nothrow @property @safe bool critical() {
280 		return _entityFlags._13;
281 	}
282 
283 	public pure nothrow @property @safe bool critical(bool value) {
284 		_entityFlags._13 = value;
285 		return value;
286 	}
287 
288 	public pure nothrow @property @safe bool showNametag() {
289 		return _entityFlags._14;
290 	}
291 
292 	public pure nothrow @property @safe bool showNametag(bool value) {
293 		_entityFlags._14 = value;
294 		return value;
295 	}
296 
297 	public pure nothrow @property @safe bool alwaysShowNametag() {
298 		return _entityFlags._15;
299 	}
300 
301 	public pure nothrow @property @safe bool alwaysShowNametag(bool value) {
302 		_entityFlags._15 = value;
303 		return value;
304 	}
305 
306 	public pure nothrow @property @safe bool noAi() {
307 		return _entityFlags._16;
308 	}
309 
310 	public pure nothrow @property @safe bool noAi(bool value) {
311 		_entityFlags._16 = value;
312 		return value;
313 	}
314 
315 	public pure nothrow @property @safe bool silent() {
316 		return _entityFlags._17;
317 	}
318 
319 	public pure nothrow @property @safe bool silent(bool value) {
320 		_entityFlags._17 = value;
321 		return value;
322 	}
323 
324 	public pure nothrow @property @safe bool climbing() {
325 		return _entityFlags._18;
326 	}
327 
328 	public pure nothrow @property @safe bool climbing(bool value) {
329 		_entityFlags._18 = value;
330 		return value;
331 	}
332 
333 	public pure nothrow @property @safe bool resting() {
334 		return _entityFlags._19;
335 	}
336 
337 	public pure nothrow @property @safe bool resting(bool value) {
338 		_entityFlags._19 = value;
339 		return value;
340 	}
341 
342 	public pure nothrow @property @safe bool sitting() {
343 		return _entityFlags._20;
344 	}
345 
346 	public pure nothrow @property @safe bool sitting(bool value) {
347 		_entityFlags._20 = value;
348 		return value;
349 	}
350 
351 	public pure nothrow @property @safe bool angry() {
352 		return _entityFlags._21;
353 	}
354 
355 	public pure nothrow @property @safe bool angry(bool value) {
356 		_entityFlags._21 = value;
357 		return value;
358 	}
359 
360 	public pure nothrow @property @safe bool interested() {
361 		return _entityFlags._22;
362 	}
363 
364 	public pure nothrow @property @safe bool interested(bool value) {
365 		_entityFlags._22 = value;
366 		return value;
367 	}
368 
369 	public pure nothrow @property @safe bool charged() {
370 		return _entityFlags._23;
371 	}
372 
373 	public pure nothrow @property @safe bool charged(bool value) {
374 		_entityFlags._23 = value;
375 		return value;
376 	}
377 
378 	public pure nothrow @property @safe bool tamed() {
379 		return _entityFlags._24;
380 	}
381 
382 	public pure nothrow @property @safe bool tamed(bool value) {
383 		_entityFlags._24 = value;
384 		return value;
385 	}
386 
387 	public pure nothrow @property @safe bool leashed() {
388 		return _entityFlags._25;
389 	}
390 
391 	public pure nothrow @property @safe bool leashed(bool value) {
392 		_entityFlags._25 = value;
393 		return value;
394 	}
395 
396 	public pure nothrow @property @safe bool sheared() {
397 		return _entityFlags._26;
398 	}
399 
400 	public pure nothrow @property @safe bool sheared(bool value) {
401 		_entityFlags._26 = value;
402 		return value;
403 	}
404 
405 	public pure nothrow @property @safe bool gliding() {
406 		return _entityFlags._27;
407 	}
408 
409 	public pure nothrow @property @safe bool gliding(bool value) {
410 		_entityFlags._27 = value;
411 		return value;
412 	}
413 
414 	public pure nothrow @property @safe bool elder() {
415 		return _entityFlags._28;
416 	}
417 
418 	public pure nothrow @property @safe bool elder(bool value) {
419 		_entityFlags._28 = value;
420 		return value;
421 	}
422 
423 	public pure nothrow @property @safe bool moving() {
424 		return _entityFlags._29;
425 	}
426 
427 	public pure nothrow @property @safe bool moving(bool value) {
428 		_entityFlags._29 = value;
429 		return value;
430 	}
431 
432 	public pure nothrow @property @safe bool breathing() {
433 		return _entityFlags._30;
434 	}
435 
436 	public pure nothrow @property @safe bool breathing(bool value) {
437 		_entityFlags._30 = value;
438 		return value;
439 	}
440 
441 	public pure nothrow @property @safe bool chested() {
442 		return _entityFlags._31;
443 	}
444 
445 	public pure nothrow @property @safe bool chested(bool value) {
446 		_entityFlags._31 = value;
447 		return value;
448 	}
449 
450 	public pure nothrow @property @safe bool stackable() {
451 		return _entityFlags._32;
452 	}
453 
454 	public pure nothrow @property @safe bool stackable(bool value) {
455 		_entityFlags._32 = value;
456 		return value;
457 	}
458 
459 	public pure nothrow @property @safe bool idling() {
460 		return _entityFlags._36;
461 	}
462 
463 	public pure nothrow @property @safe bool idling(bool value) {
464 		_entityFlags._36 = value;
465 		return value;
466 	}
467 
468 	public pure nothrow @property @safe @nogc int variant() {
469 		return _variant.value;
470 	}
471 
472 	public pure nothrow @property @safe int variant(int value) {
473 		this._cached = false;
474 		this._variant.value = value;
475 		if(!this._variant.changed) {
476 			this._variant.changed = true;
477 			this._changed ~= &this.encodeVariant;
478 		}
479 		return value;
480 	}
481 
482 	public pure nothrow @safe encodeVariant(Buffer buffer) {
483 		with(buffer) {
484 			writeBytes(varuint.encode(2));
485 			writeBytes(varuint.encode(2));
486 			writeBytes(varint.encode(this._variant.value));
487 		}
488 	}
489 
490 	public pure nothrow @property @safe @nogc byte color() {
491 		return _color.value;
492 	}
493 
494 	public pure nothrow @property @safe byte color(byte value) {
495 		this._cached = false;
496 		this._color.value = value;
497 		if(!this._color.changed) {
498 			this._color.changed = true;
499 			this._changed ~= &this.encodeColor;
500 		}
501 		return value;
502 	}
503 
504 	public pure nothrow @safe encodeColor(Buffer buffer) {
505 		with(buffer) {
506 			writeBytes(varuint.encode(3));
507 			writeBytes(varuint.encode(0));
508 			writeBigEndianByte(this._color.value);
509 		}
510 	}
511 
512 	public pure nothrow @property @safe @nogc string nametag() {
513 		return _nametag.value;
514 	}
515 
516 	public pure nothrow @property @safe string nametag(string value) {
517 		this._cached = false;
518 		this._nametag.value = value;
519 		if(!this._nametag.changed) {
520 			this._nametag.changed = true;
521 			this._changed ~= &this.encodeNametag;
522 		}
523 		return value;
524 	}
525 
526 	public pure nothrow @safe encodeNametag(Buffer buffer) {
527 		with(buffer) {
528 			writeBytes(varuint.encode(4));
529 			writeBytes(varuint.encode(4));
530 			writeBytes(varuint.encode(cast(uint)this._nametag.value.length)); writeString(this._nametag.value);
531 		}
532 	}
533 
534 	public pure nothrow @property @safe @nogc long owner() {
535 		return _owner.value;
536 	}
537 
538 	public pure nothrow @property @safe long owner(long value) {
539 		this._cached = false;
540 		this._owner.value = value;
541 		if(!this._owner.changed) {
542 			this._owner.changed = true;
543 			this._changed ~= &this.encodeOwner;
544 		}
545 		return value;
546 	}
547 
548 	public pure nothrow @safe encodeOwner(Buffer buffer) {
549 		with(buffer) {
550 			writeBytes(varuint.encode(5));
551 			writeBytes(varuint.encode(7));
552 			writeBytes(varlong.encode(this._owner.value));
553 		}
554 	}
555 
556 	public pure nothrow @property @safe @nogc short air() {
557 		return _air;
558 	}
559 
560 	public pure nothrow @property @safe short air(short value) {
561 		this._cached = false;
562 		this._air = value;
563 		return value;
564 	}
565 
566 	public pure nothrow @safe encodeAir(Buffer buffer) {
567 		with(buffer) {
568 			writeBytes(varuint.encode(7));
569 			writeBytes(varuint.encode(1));
570 			writeLittleEndianShort(this._air);
571 		}
572 	}
573 
574 	public pure nothrow @property @safe @nogc int potionColor() {
575 		return _potionColor.value;
576 	}
577 
578 	public pure nothrow @property @safe int potionColor(int value) {
579 		this._cached = false;
580 		this._potionColor.value = value;
581 		if(!this._potionColor.changed) {
582 			this._potionColor.changed = true;
583 			this._changed ~= &this.encodePotionColor;
584 		}
585 		return value;
586 	}
587 
588 	public pure nothrow @safe encodePotionColor(Buffer buffer) {
589 		with(buffer) {
590 			writeBytes(varuint.encode(8));
591 			writeBytes(varuint.encode(2));
592 			writeBytes(varint.encode(this._potionColor.value));
593 		}
594 	}
595 
596 	public pure nothrow @property @safe @nogc byte potionAmbient() {
597 		return _potionAmbient.value;
598 	}
599 
600 	public pure nothrow @property @safe byte potionAmbient(byte value) {
601 		this._cached = false;
602 		this._potionAmbient.value = value;
603 		if(!this._potionAmbient.changed) {
604 			this._potionAmbient.changed = true;
605 			this._changed ~= &this.encodePotionAmbient;
606 		}
607 		return value;
608 	}
609 
610 	public pure nothrow @safe encodePotionAmbient(Buffer buffer) {
611 		with(buffer) {
612 			writeBytes(varuint.encode(9));
613 			writeBytes(varuint.encode(0));
614 			writeBigEndianByte(this._potionAmbient.value);
615 		}
616 	}
617 
618 	public pure nothrow @property @safe @nogc byte slimeSize() {
619 		return _slimeSize.value;
620 	}
621 
622 	public pure nothrow @property @safe byte slimeSize(byte value) {
623 		this._cached = false;
624 		this._slimeSize.value = value;
625 		if(!this._slimeSize.changed) {
626 			this._slimeSize.changed = true;
627 			this._changed ~= &this.encodeSlimeSize;
628 		}
629 		return value;
630 	}
631 
632 	public pure nothrow @safe encodeSlimeSize(Buffer buffer) {
633 		with(buffer) {
634 			writeBytes(varuint.encode(16));
635 			writeBytes(varuint.encode(0));
636 			writeBigEndianByte(this._slimeSize.value);
637 		}
638 	}
639 
640 	public pure nothrow @property @safe @nogc byte playerFlags() {
641 		return _playerFlags.value;
642 	}
643 
644 	public pure nothrow @property @safe byte playerFlags(byte value) {
645 		this._cached = false;
646 		this._playerFlags.value = value;
647 		if(!this._playerFlags.changed) {
648 			this._playerFlags.changed = true;
649 			this._changed ~= &this.encodePlayerFlags;
650 		}
651 		return value;
652 	}
653 
654 	public pure nothrow @safe encodePlayerFlags(Buffer buffer) {
655 		with(buffer) {
656 			writeBytes(varuint.encode(27));
657 			writeBytes(varuint.encode(0));
658 			writeBigEndianByte(this._playerFlags.value);
659 		}
660 	}
661 
662 	public pure nothrow @property @safe bool asleep() {
663 		return _playerFlags.value._1;
664 	}
665 
666 	public pure nothrow @property @safe bool asleep(bool value) {
667 		_playerFlags.value._1 = value;
668 		return value;
669 	}
670 
671 	public pure nothrow @property @safe @nogc int playerIndex() {
672 		return _playerIndex.value;
673 	}
674 
675 	public pure nothrow @property @safe int playerIndex(int value) {
676 		this._cached = false;
677 		this._playerIndex.value = value;
678 		if(!this._playerIndex.changed) {
679 			this._playerIndex.changed = true;
680 			this._changed ~= &this.encodePlayerIndex;
681 		}
682 		return value;
683 	}
684 
685 	public pure nothrow @safe encodePlayerIndex(Buffer buffer) {
686 		with(buffer) {
687 			writeBytes(varuint.encode(28));
688 			writeBytes(varuint.encode(2));
689 			writeBytes(varint.encode(this._playerIndex.value));
690 		}
691 	}
692 
693 	public pure nothrow @property @safe @nogc Tuple!(int, "x", int, "y", int, "z") bedPosition() {
694 		return _bedPosition.value;
695 	}
696 
697 	public pure nothrow @property @safe Tuple!(int, "x", int, "y", int, "z") bedPosition(Tuple!(int, "x", int, "y", int, "z") value) {
698 		this._cached = false;
699 		this._bedPosition.value = value;
700 		if(!this._bedPosition.changed) {
701 			this._bedPosition.changed = true;
702 			this._changed ~= &this.encodeBedPosition;
703 		}
704 		return value;
705 	}
706 
707 	public pure nothrow @safe encodeBedPosition(Buffer buffer) {
708 		with(buffer) {
709 			writeBytes(varuint.encode(29));
710 			writeBytes(varuint.encode(6));
711 			writeBytes(varint.encode(this._bedPosition.value.x)); writeBytes(varint.encode(this._bedPosition.value.y)); writeBytes(varint.encode(this._bedPosition.value.z));
712 		}
713 	}
714 
715 	public pure nothrow @property @safe @nogc long leadHolder() {
716 		return _leadHolder;
717 	}
718 
719 	public pure nothrow @property @safe long leadHolder(long value) {
720 		this._cached = false;
721 		this._leadHolder = value;
722 		return value;
723 	}
724 
725 	public pure nothrow @safe encodeLeadHolder(Buffer buffer) {
726 		with(buffer) {
727 			writeBytes(varuint.encode(38));
728 			writeBytes(varuint.encode(7));
729 			writeBytes(varlong.encode(this._leadHolder));
730 		}
731 	}
732 
733 	public pure nothrow @property @safe @nogc float scale() {
734 		return _scale.value;
735 	}
736 
737 	public pure nothrow @property @safe float scale(float value) {
738 		this._cached = false;
739 		this._scale.value = value;
740 		if(!this._scale.changed) {
741 			this._scale.changed = true;
742 			this._changed ~= &this.encodeScale;
743 		}
744 		return value;
745 	}
746 
747 	public pure nothrow @safe encodeScale(Buffer buffer) {
748 		with(buffer) {
749 			writeBytes(varuint.encode(39));
750 			writeBytes(varuint.encode(3));
751 			writeLittleEndianFloat(this._scale.value);
752 		}
753 	}
754 
755 	public pure nothrow @property @safe @nogc string interactiveTag() {
756 		return _interactiveTag.value;
757 	}
758 
759 	public pure nothrow @property @safe string interactiveTag(string value) {
760 		this._cached = false;
761 		this._interactiveTag.value = value;
762 		if(!this._interactiveTag.changed) {
763 			this._interactiveTag.changed = true;
764 			this._changed ~= &this.encodeInteractiveTag;
765 		}
766 		return value;
767 	}
768 
769 	public pure nothrow @safe encodeInteractiveTag(Buffer buffer) {
770 		with(buffer) {
771 			writeBytes(varuint.encode(40));
772 			writeBytes(varuint.encode(4));
773 			writeBytes(varuint.encode(cast(uint)this._interactiveTag.value.length)); writeString(this._interactiveTag.value);
774 		}
775 	}
776 
777 	public pure nothrow @property @safe @nogc string interactiveTagUrl() {
778 		return _interactiveTagUrl.value;
779 	}
780 
781 	public pure nothrow @property @safe string interactiveTagUrl(string value) {
782 		this._cached = false;
783 		this._interactiveTagUrl.value = value;
784 		if(!this._interactiveTagUrl.changed) {
785 			this._interactiveTagUrl.changed = true;
786 			this._changed ~= &this.encodeInteractiveTagUrl;
787 		}
788 		return value;
789 	}
790 
791 	public pure nothrow @safe encodeInteractiveTagUrl(Buffer buffer) {
792 		with(buffer) {
793 			writeBytes(varuint.encode(43));
794 			writeBytes(varuint.encode(4));
795 			writeBytes(varuint.encode(cast(uint)this._interactiveTagUrl.value.length)); writeString(this._interactiveTagUrl.value);
796 		}
797 	}
798 
799 	public pure nothrow @property @safe @nogc short maxAir() {
800 		return _maxAir.value;
801 	}
802 
803 	public pure nothrow @property @safe short maxAir(short value) {
804 		this._cached = false;
805 		this._maxAir.value = value;
806 		if(!this._maxAir.changed) {
807 			this._maxAir.changed = true;
808 			this._changed ~= &this.encodeMaxAir;
809 		}
810 		return value;
811 	}
812 
813 	public pure nothrow @safe encodeMaxAir(Buffer buffer) {
814 		with(buffer) {
815 			writeBytes(varuint.encode(44));
816 			writeBytes(varuint.encode(1));
817 			writeLittleEndianShort(this._maxAir.value);
818 		}
819 	}
820 
821 	public pure nothrow @property @safe @nogc int markVariant() {
822 		return _markVariant.value;
823 	}
824 
825 	public pure nothrow @property @safe int markVariant(int value) {
826 		this._cached = false;
827 		this._markVariant.value = value;
828 		if(!this._markVariant.changed) {
829 			this._markVariant.changed = true;
830 			this._changed ~= &this.encodeMarkVariant;
831 		}
832 		return value;
833 	}
834 
835 	public pure nothrow @safe encodeMarkVariant(Buffer buffer) {
836 		with(buffer) {
837 			writeBytes(varuint.encode(45));
838 			writeBytes(varuint.encode(2));
839 			writeBytes(varint.encode(this._markVariant.value));
840 		}
841 	}
842 
843 	public pure nothrow @property @safe @nogc float boundingBoxWidth() {
844 		return _boundingBoxWidth.value;
845 	}
846 
847 	public pure nothrow @property @safe float boundingBoxWidth(float value) {
848 		this._cached = false;
849 		this._boundingBoxWidth.value = value;
850 		if(!this._boundingBoxWidth.changed) {
851 			this._boundingBoxWidth.changed = true;
852 			this._changed ~= &this.encodeBoundingBoxWidth;
853 		}
854 		return value;
855 	}
856 
857 	public pure nothrow @safe encodeBoundingBoxWidth(Buffer buffer) {
858 		with(buffer) {
859 			writeBytes(varuint.encode(54));
860 			writeBytes(varuint.encode(3));
861 			writeLittleEndianFloat(this._boundingBoxWidth.value);
862 		}
863 	}
864 
865 	public pure nothrow @property @safe @nogc float boundingBoxHeight() {
866 		return _boundingBoxHeight.value;
867 	}
868 
869 	public pure nothrow @property @safe float boundingBoxHeight(float value) {
870 		this._cached = false;
871 		this._boundingBoxHeight.value = value;
872 		if(!this._boundingBoxHeight.changed) {
873 			this._boundingBoxHeight.changed = true;
874 			this._changed ~= &this.encodeBoundingBoxHeight;
875 		}
876 		return value;
877 	}
878 
879 	public pure nothrow @safe encodeBoundingBoxHeight(Buffer buffer) {
880 		with(buffer) {
881 			writeBytes(varuint.encode(55));
882 			writeBytes(varuint.encode(3));
883 			writeLittleEndianFloat(this._boundingBoxHeight.value);
884 		}
885 	}
886 
887 	public pure nothrow @property @safe @nogc int fuseLength() {
888 		return _fuseLength.value;
889 	}
890 
891 	public pure nothrow @property @safe int fuseLength(int value) {
892 		this._cached = false;
893 		this._fuseLength.value = value;
894 		if(!this._fuseLength.changed) {
895 			this._fuseLength.changed = true;
896 			this._changed ~= &this.encodeFuseLength;
897 		}
898 		return value;
899 	}
900 
901 	public pure nothrow @safe encodeFuseLength(Buffer buffer) {
902 		with(buffer) {
903 			writeBytes(varuint.encode(56));
904 			writeBytes(varuint.encode(2));
905 			writeBytes(varint.encode(this._fuseLength.value));
906 		}
907 	}
908 
909 	public pure nothrow @property @safe @nogc float areaEffectCloudRadius() {
910 		return _areaEffectCloudRadius.value;
911 	}
912 
913 	public pure nothrow @property @safe float areaEffectCloudRadius(float value) {
914 		this._cached = false;
915 		this._areaEffectCloudRadius.value = value;
916 		if(!this._areaEffectCloudRadius.changed) {
917 			this._areaEffectCloudRadius.changed = true;
918 			this._changed ~= &this.encodeAreaEffectCloudRadius;
919 		}
920 		return value;
921 	}
922 
923 	public pure nothrow @safe encodeAreaEffectCloudRadius(Buffer buffer) {
924 		with(buffer) {
925 			writeBytes(varuint.encode(61));
926 			writeBytes(varuint.encode(3));
927 			writeLittleEndianFloat(this._areaEffectCloudRadius.value);
928 		}
929 	}
930 
931 	public pure nothrow @property @safe @nogc int areaEffectCloudWaiting() {
932 		return _areaEffectCloudWaiting.value;
933 	}
934 
935 	public pure nothrow @property @safe int areaEffectCloudWaiting(int value) {
936 		this._cached = false;
937 		this._areaEffectCloudWaiting.value = value;
938 		if(!this._areaEffectCloudWaiting.changed) {
939 			this._areaEffectCloudWaiting.changed = true;
940 			this._changed ~= &this.encodeAreaEffectCloudWaiting;
941 		}
942 		return value;
943 	}
944 
945 	public pure nothrow @safe encodeAreaEffectCloudWaiting(Buffer buffer) {
946 		with(buffer) {
947 			writeBytes(varuint.encode(62));
948 			writeBytes(varuint.encode(2));
949 			writeBytes(varint.encode(this._areaEffectCloudWaiting.value));
950 		}
951 	}
952 
953 	public pure nothrow @property @safe @nogc int areaEffectCloudParticle() {
954 		return _areaEffectCloudParticle.value;
955 	}
956 
957 	public pure nothrow @property @safe int areaEffectCloudParticle(int value) {
958 		this._cached = false;
959 		this._areaEffectCloudParticle.value = value;
960 		if(!this._areaEffectCloudParticle.changed) {
961 			this._areaEffectCloudParticle.changed = true;
962 			this._changed ~= &this.encodeAreaEffectCloudParticle;
963 		}
964 		return value;
965 	}
966 
967 	public pure nothrow @safe encodeAreaEffectCloudParticle(Buffer buffer) {
968 		with(buffer) {
969 			writeBytes(varuint.encode(63));
970 			writeBytes(varuint.encode(2));
971 			writeBytes(varint.encode(this._areaEffectCloudParticle.value));
972 		}
973 	}
974 
975 	public pure nothrow @property @safe @nogc long tradingPlayer() {
976 		return _tradingPlayer.value;
977 	}
978 
979 	public pure nothrow @property @safe long tradingPlayer(long value) {
980 		this._cached = false;
981 		this._tradingPlayer.value = value;
982 		if(!this._tradingPlayer.changed) {
983 			this._tradingPlayer.changed = true;
984 			this._changed ~= &this.encodeTradingPlayer;
985 		}
986 		return value;
987 	}
988 
989 	public pure nothrow @safe encodeTradingPlayer(Buffer buffer) {
990 		with(buffer) {
991 			writeBytes(varuint.encode(68));
992 			writeBytes(varuint.encode(7));
993 			writeBytes(varlong.encode(this._tradingPlayer.value));
994 		}
995 	}
996 
997 	public pure nothrow @safe encode(Buffer buffer) {
998 		with(buffer) {
999 			if(this._cached) {
1000 				buffer.writeBytes(this._cache);
1001 			} else {
1002 				immutable start = buffer._buffer.length;
1003 				writeBytes(varuint.encode(cast(uint)this._changed.length));
1004 				foreach(del ; this._changed) del(buffer);
1005 				this._cached = true;
1006 				this._cache = buffer._buffer[start..$];
1007 			}
1008 		}
1009 	}
1010 
1011 	public static pure nothrow @safe Metadata decode(Buffer buffer) {
1012 		auto metadata = new Metadata();
1013 		with(buffer) {
1014 			uint id;
1015 			size_t length=varuint.decode(_buffer, &_index);
1016 			while(length-- > 0) {
1017 				id=varuint.decode(_buffer, &_index);
1018 				switch(varuint.decode(_buffer, &_index)) {
1019 					case 0:
1020 						byte _0;
1021 						_0=readBigEndianByte();
1022 						metadata.decoded ~= DecodedMetadata.fromByte(id, _0);
1023 						break;
1024 					case 1:
1025 						short _1;
1026 						_1=readLittleEndianShort();
1027 						metadata.decoded ~= DecodedMetadata.fromShort(id, _1);
1028 						break;
1029 					case 2:
1030 						int _2;
1031 						_2=varint.decode(_buffer, &_index);
1032 						metadata.decoded ~= DecodedMetadata.fromInt(id, _2);
1033 						break;
1034 					case 3:
1035 						float _3;
1036 						_3=readLittleEndianFloat();
1037 						metadata.decoded ~= DecodedMetadata.fromFloat(id, _3);
1038 						break;
1039 					case 4:
1040 						string _4;
1041 						uint xq=varuint.decode(_buffer, &_index); _4=readString(xq);
1042 						metadata.decoded ~= DecodedMetadata.fromString(id, _4);
1043 						break;
1044 					case 5:
1045 						sul.protocol.pocket105.types.Slot _5;
1046 						_5.decode(bufferInstance);
1047 						metadata.decoded ~= DecodedMetadata.fromSlot(id, _5);
1048 						break;
1049 					case 6:
1050 						Tuple!(int, "x", int, "y", int, "z") _6;
1051 						_6.x=varint.decode(_buffer, &_index); _6.y=varint.decode(_buffer, &_index); _6.z=varint.decode(_buffer, &_index);
1052 						metadata.decoded ~= DecodedMetadata.fromBlockPosition(id, _6);
1053 						break;
1054 					case 7:
1055 						long _7;
1056 						_7=varlong.decode(_buffer, &_index);
1057 						metadata.decoded ~= DecodedMetadata.fromLong(id, _7);
1058 						break;
1059 					case 8:
1060 						Tuple!(float, "x", float, "y", float, "z") _8;
1061 						_8.x=readLittleEndianFloat(); _8.y=readLittleEndianFloat(); _8.z=readLittleEndianFloat();
1062 						metadata.decoded ~= DecodedMetadata.fromEntityPosition(id, _8);
1063 						break;
1064 					default:
1065 						break;
1066 				}
1067 			}
1068 		}
1069 		return metadata;
1070 	}
1071 
1072 }
1073 
1074 class DecodedMetadata {
1075 
1076 	public immutable uint id;
1077 	public immutable uint type;
1078 
1079 	union {
1080 		byte byte_;
1081 		short short_;
1082 		int int_;
1083 		float float_;
1084 		string string_;
1085 		sul.protocol.pocket105.types.Slot slot;
1086 		Tuple!(int, "x", int, "y", int, "z") block_position;
1087 		long long_;
1088 		Tuple!(float, "x", float, "y", float, "z") entity_position;
1089 	}
1090 
1091 	private pure nothrow @safe @nogc this(uint id, uint type) {
1092 		this.id = id;
1093 		this.type = type;
1094 	}
1095 
1096 	public static pure nothrow @trusted DecodedMetadata fromByte(uint id, byte value) {
1097 		auto ret = new DecodedMetadata(id, 0);
1098 		ret.byte_ = value;
1099 		return ret;
1100 	}
1101 
1102 	public static pure nothrow @trusted DecodedMetadata fromShort(uint id, short value) {
1103 		auto ret = new DecodedMetadata(id, 1);
1104 		ret.short_ = value;
1105 		return ret;
1106 	}
1107 
1108 	public static pure nothrow @trusted DecodedMetadata fromInt(uint id, int value) {
1109 		auto ret = new DecodedMetadata(id, 2);
1110 		ret.int_ = value;
1111 		return ret;
1112 	}
1113 
1114 	public static pure nothrow @trusted DecodedMetadata fromFloat(uint id, float value) {
1115 		auto ret = new DecodedMetadata(id, 3);
1116 		ret.float_ = value;
1117 		return ret;
1118 	}
1119 
1120 	public static pure nothrow @trusted DecodedMetadata fromString(uint id, string value) {
1121 		auto ret = new DecodedMetadata(id, 4);
1122 		ret.string_ = value;
1123 		return ret;
1124 	}
1125 
1126 	public static pure nothrow @trusted DecodedMetadata fromSlot(uint id, sul.protocol.pocket105.types.Slot value) {
1127 		auto ret = new DecodedMetadata(id, 5);
1128 		ret.slot = value;
1129 		return ret;
1130 	}
1131 
1132 	public static pure nothrow @trusted DecodedMetadata fromBlockPosition(uint id, Tuple!(int, "x", int, "y", int, "z") value) {
1133 		auto ret = new DecodedMetadata(id, 6);
1134 		ret.block_position = value;
1135 		return ret;
1136 	}
1137 
1138 	public static pure nothrow @trusted DecodedMetadata fromLong(uint id, long value) {
1139 		auto ret = new DecodedMetadata(id, 7);
1140 		ret.long_ = value;
1141 		return ret;
1142 	}
1143 
1144 	public static pure nothrow @trusted DecodedMetadata fromEntityPosition(uint id, Tuple!(float, "x", float, "y", float, "z") value) {
1145 		auto ret = new DecodedMetadata(id, 8);
1146 		ret.entity_position = value;
1147 		return ret;
1148 	}
1149 
1150 }