Fixed glowing item frames

due to technical limitations, this requires separating them back into two different block types. However, this isn't too egregious since it's just one flag, and actually simplifies some code.

closes #5478
This commit is contained in:
Dylan K. Taylor
2023-01-12 21:52:44 +00:00
parent 9c391a6809
commit ca1f1bf09f
12 changed files with 67 additions and 52 deletions

View File

@ -25,7 +25,6 @@ namespace pocketmine\data\bedrock\item;
use pocketmine\block\Bed;
use pocketmine\block\Block;
use pocketmine\block\ItemFrame;
use pocketmine\block\Skull;
use pocketmine\block\utils\DyeColor;
use pocketmine\block\utils\SkullType;
@ -57,7 +56,6 @@ final class ItemSerializerDeserializerRegistrar{
$this->register1to1BlockWithMetaMappings();
$this->register1to1ItemWithMetaMappings();
$this->register1ToNItemMappings();
$this->registerMiscBlockMappings();
$this->registerMiscItemMappings();
}
@ -141,6 +139,8 @@ final class ItemSerializerDeserializerRegistrar{
$this->map1to1Block(Ids::CRIMSON_DOOR, Blocks::CRIMSON_DOOR());
$this->map1to1Block(Ids::DARK_OAK_DOOR, Blocks::DARK_OAK_DOOR());
$this->map1to1Block(Ids::FLOWER_POT, Blocks::FLOWER_POT());
$this->map1to1Block(Ids::FRAME, Blocks::ITEM_FRAME());
$this->map1to1Block(Ids::GLOW_FRAME, Blocks::GLOWING_ITEM_FRAME());
$this->map1to1Block(Ids::HOPPER, Blocks::HOPPER());
$this->map1to1Block(Ids::IRON_DOOR, Blocks::IRON_DOOR());
$this->map1to1Block(Ids::JUNGLE_DOOR, Blocks::JUNGLE_DOOR());
@ -502,19 +502,6 @@ final class ItemSerializerDeserializerRegistrar{
);
}
/**
* Registers serializers and deserializers for blocks that don't fit any other pattern.
* Ideally we want to get rid of this completely, if possible.
*
* Most of these are single PocketMine-MP items which map to multiple IDs depending on their properties, which is
* complex to implement in a generic way.
*/
private function registerMiscBlockMappings() : void{
$this->deserializer?->mapBlock(Ids::FRAME, fn() => Blocks::ITEM_FRAME()->setGlowing(false));
$this->deserializer?->mapBlock(Ids::GLOW_FRAME, fn() => Blocks::ITEM_FRAME()->setGlowing(true));
$this->serializer?->mapBlock(Blocks::ITEM_FRAME(), fn(ItemFrame $block) => new Data($block->isGlowing() ? Ids::GLOW_FRAME : Ids::FRAME));
}
/**
* Registers serializers and deserializers for items that don't fit any other pattern.
* Ideally we want to get rid of this completely, if possible.