remove hardcoded legacy entity type ID mapping, load from resources instead

This commit is contained in:
Dylan K. Taylor
2020-05-04 13:47:39 +01:00
parent f0dfa45172
commit 81f982a8d9
6 changed files with 10 additions and 119 deletions

View File

@ -23,11 +23,11 @@ declare(strict_types=1);
namespace pocketmine\block\tile;
use pocketmine\data\bedrock\LegacyEntityIdToStringIdMap;
use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\tag\IntTag;
use pocketmine\nbt\tag\ListTag;
use pocketmine\nbt\tag\StringTag;
use pocketmine\network\mcpe\protocol\AddActorPacket;
/**
* @deprecated
@ -97,7 +97,7 @@ class MonsterSpawner extends Spawnable{
public function readSaveData(CompoundTag $nbt) : void{
if($nbt->hasTag(self::TAG_LEGACY_ENTITY_TYPE_ID, IntTag::class)){
//TODO: this will cause unexpected results when there's no mapping for the entity
$this->entityTypeId = AddActorPacket::LEGACY_ID_MAP_BC[$nbt->getInt(self::TAG_LEGACY_ENTITY_TYPE_ID)] ?? ":";
$this->entityTypeId = LegacyEntityIdToStringIdMap::getInstance()->legacyToString($nbt->getInt(self::TAG_LEGACY_ENTITY_TYPE_ID)) ?? ":";
}elseif($nbt->hasTag(self::TAG_ENTITY_TYPE_ID, StringTag::class)){
$this->entityTypeId = $nbt->getString(self::TAG_ENTITY_TYPE_ID);
}else{