PocketMine-MP 5.23.2 git-45917d495c14f3ce37bbf0848262ad8a470030f3
Loading...
Searching...
No Matches
NBT.php
1<?php
2
3/*
4 *
5 * ____ _ _ __ __ _ __ __ ____
6 * | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
7 * | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
8 * | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
9 * |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
10 *
11 * This program is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License as published by
13 * the Free Software Foundation, either version 3 of the License, or
14 * (at your option) any later version.
15 *
16 * @author PocketMine Team
17 * @link http://www.pocketmine.net/
18 *
19 *
20*/
21
22declare(strict_types=1);
23
27namespace pocketmine\nbt;
28
41
42abstract class NBT{
43
44 public const TAG_End = 0;
45 public const TAG_Byte = 1;
46 public const TAG_Short = 2;
47 public const TAG_Int = 3;
48 public const TAG_Long = 4;
49 public const TAG_Float = 5;
50 public const TAG_Double = 6;
51 public const TAG_ByteArray = 7;
52 public const TAG_String = 8;
53 public const TAG_List = 9;
54 public const TAG_Compound = 10;
55 public const TAG_IntArray = 11;
56
60 public static function createTag(int $type, NbtStreamReader $reader, ReaderTracker $tracker) : Tag{
61 switch($type){
62 case self::TAG_Byte:
63 return ByteTag::read($reader);
64 case self::TAG_Short:
65 return ShortTag::read($reader);
66 case self::TAG_Int:
67 return IntTag::read($reader);
68 case self::TAG_Long:
69 return LongTag::read($reader);
70 case self::TAG_Float:
71 return FloatTag::read($reader);
72 case self::TAG_Double:
73 return DoubleTag::read($reader);
74 case self::TAG_ByteArray:
75 return ByteArrayTag::read($reader);
76 case self::TAG_String:
77 return StringTag::read($reader);
78 case self::TAG_List:
79 return ListTag::read($reader, $tracker);
80 case self::TAG_Compound:
81 return CompoundTag::read($reader, $tracker);
82 case self::TAG_IntArray:
83 return IntArrayTag::read($reader);
84 default:
85 throw new NbtDataException("Unknown NBT tag type $type");
86 }
87 }
88}
static createTag(int $type, NbtStreamReader $reader, ReaderTracker $tracker)
Definition NBT.php:60