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