45    private array $knownTiles = [];
 
   50    private array $saveNames = [];
 
   52    public function __construct(){
 
   53        $this->
register(Barrel::class, [
"Barrel", 
"minecraft:barrel"]);
 
   54        $this->
register(Banner::class, [
"Banner", 
"minecraft:banner"]);
 
   55        $this->
register(Beacon::class, [
"Beacon", 
"minecraft:beacon"]);
 
   56        $this->
register(Bed::class, [
"Bed", 
"minecraft:bed"]);
 
   57        $this->
register(Bell::class, [
"Bell", 
"minecraft:bell"]);
 
   58        $this->
register(BlastFurnace::class, [
"BlastFurnace", 
"minecraft:blast_furnace"]);
 
   59        $this->
register(BrewingStand::class, [
"BrewingStand", 
"minecraft:brewing_stand"]);
 
   60        $this->
register(Campfire::class, [
"Campfire", 
"minecraft:campfire"]);
 
   61        $this->
register(Cauldron::class, [
"Cauldron", 
"minecraft:cauldron"]);
 
   62        $this->
register(Chest::class, [
"Chest", 
"minecraft:chest"]);
 
   63        $this->
register(ChiseledBookshelf::class, [
"ChiseledBookshelf", 
"minecraft:chiseled_bookshelf"]);
 
   64        $this->
register(Comparator::class, [
"Comparator", 
"minecraft:comparator"]);
 
   65        $this->
register(DaylightSensor::class, [
"DaylightDetector", 
"minecraft:daylight_detector"]);
 
   66        $this->
register(EnchantTable::class, [
"EnchantTable", 
"minecraft:enchanting_table"]);
 
   67        $this->
register(EnderChest::class, [
"EnderChest", 
"minecraft:ender_chest"]);
 
   68        $this->
register(FlowerPot::class, [
"FlowerPot", 
"minecraft:flower_pot"]);
 
   69        $this->
register(NormalFurnace::class, [
"Furnace", 
"minecraft:furnace"]);
 
   70        $this->
register(Hopper::class, [
"Hopper", 
"minecraft:hopper"]);
 
   71        $this->
register(ItemFrame::class, [
"ItemFrame"]); 
 
   72        $this->
register(Jukebox::class, [
"Jukebox", 
"RecordPlayer", 
"minecraft:jukebox"]);
 
   73        $this->
register(Lectern::class, [
"Lectern", 
"minecraft:lectern"]);
 
   74        $this->
register(MonsterSpawner::class, [
"MobSpawner", 
"minecraft:mob_spawner"]);
 
   75        $this->
register(Note::class, [
"Music", 
"minecraft:noteblock"]);
 
   76        $this->
register(ShulkerBox::class, [
"ShulkerBox", 
"minecraft:shulker_box"]);
 
   77        $this->
register(Sign::class, [
"Sign", 
"minecraft:sign"]);
 
   78        $this->
register(Smoker::class, [
"Smoker", 
"minecraft:smoker"]);
 
   79        $this->
register(SporeBlossom::class, [
"SporeBlossom", 
"minecraft:spore_blossom"]);
 
   80        $this->
register(MobHead::class, [
"Skull", 
"minecraft:skull"]);
 
   81        $this->
register(GlowingItemFrame::class, [
"GlowItemFrame"]);
 
   82        $this->
register(HangingSign::class, [
"HangingSign", 
"minecraft:hanging_sign"]);
 
  103    public function register(
string $className, array $saveNames = []) : void{
 
  104        Utils::testValidInstance($className, 
Tile::class);
 
  106        $shortName = (new \ReflectionClass($className))->getShortName();
 
  107        if(!in_array($shortName, $saveNames, 
true)){
 
  108            $saveNames[] = $shortName;
 
  111        foreach($saveNames as $name){
 
  112            $this->knownTiles[$name] = $className;
 
  115        $this->saveNames[$className] = reset($saveNames);
 
 
  122        return isset($this->saveNames[$class]);
 
 
  131            $type = $nbt->getString(
Tile::TAG_ID, 
"");
 
  132            if(!isset($this->knownTiles[$type])){
 
  135            $class = $this->knownTiles[$type];
 
  136            assert(is_a($class, Tile::class, 
true));
 
  141            $tile = 
new $class($world, 
new Vector3($nbt->getInt(Tile::TAG_X), $nbt->getInt(Tile::TAG_Y), $nbt->getInt(Tile::TAG_Z)));
 
  142            $tile->readSaveData($nbt);
 
  143        }
catch(NbtException $e){
 
  144            throw new SavedDataLoadingException($e->getMessage(), 0, $e);
 
  154        if(isset($this->saveNames[$class])){
 
  155            return $this->saveNames[$class];
 
  157        throw new \InvalidArgumentException(
"Tile $class is not registered");