mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-10-18 12:04:46 +00:00
Move mob head and note instrument save IDs into pocketmine\data\bedrock
to be consistent, these shouldn't be exposed in the API like this... I'm not very happy with the whole 'type ID map' paradigm (particularly its lack of static analysis guarantees), but the most important thing right now is to get this stuff out of the API so that plugin devs don't try and abuse it. We're not going to change the whole system days before PM5 release.
This commit is contained in:
@@ -27,13 +27,13 @@ use pocketmine\block\Bed;
|
||||
use pocketmine\block\Block;
|
||||
use pocketmine\block\MobHead;
|
||||
use pocketmine\block\utils\DyeColor;
|
||||
use pocketmine\block\utils\MobHeadType;
|
||||
use pocketmine\block\VanillaBlocks as Blocks;
|
||||
use pocketmine\data\bedrock\CompoundTypeIds;
|
||||
use pocketmine\data\bedrock\DyeColorIdMap;
|
||||
use pocketmine\data\bedrock\item\ItemTypeNames as Ids;
|
||||
use pocketmine\data\bedrock\item\SavedItemData as Data;
|
||||
use pocketmine\data\bedrock\MedicineTypeIdMap;
|
||||
use pocketmine\data\bedrock\MobHeadTypeIdMap;
|
||||
use pocketmine\data\bedrock\PotionTypeIdMap;
|
||||
use pocketmine\data\bedrock\SuspiciousStewTypeIdMap;
|
||||
use pocketmine\item\Banner;
|
||||
@@ -445,14 +445,9 @@ final class ItemSerializerDeserializerRegistrar{
|
||||
Ids::SKULL,
|
||||
Blocks::MOB_HEAD(),
|
||||
function(MobHead $block, int $meta) : void{
|
||||
try{
|
||||
$skullType = MobHeadType::fromMagicNumber($meta);
|
||||
}catch(\InvalidArgumentException $e){
|
||||
throw new ItemTypeDeserializeException($e->getMessage(), 0, $e);
|
||||
}
|
||||
$block->setMobHeadType($skullType);
|
||||
$block->setMobHeadType(MobHeadTypeIdMap::getInstance()->fromId($meta) ?? throw new ItemTypeDeserializeException("Unknown mob head type ID $meta"));
|
||||
},
|
||||
fn(MobHead $block) => $block->getMobHeadType()->getMagicNumber()
|
||||
fn(MobHead $block) => MobHeadTypeIdMap::getInstance()->toId($block->getMobHeadType())
|
||||
);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user