Added glowing item frames

This commit is contained in:
Dylan K. Taylor
2022-07-14 16:24:20 +01:00
parent 0c7370e564
commit 323d31005f
8 changed files with 44 additions and 15 deletions

View File

@ -908,7 +908,7 @@ final class BlockObjectToBlockStateSerializer implements BlockStateSerializer{
$this->mapSimple(Blocks::IRON_ORE(), Ids::IRON_ORE);
$this->map(Blocks::IRON_TRAPDOOR(), fn(Trapdoor $block) => Helper::encodeTrapdoor($block, new Writer(Ids::IRON_TRAPDOOR)));
$this->map(Blocks::ITEM_FRAME(), function(ItemFrame $block) : Writer{
return Writer::create(Ids::FRAME)
return Writer::create($block->isGlowing() ? Ids::GLOW_FRAME : Ids::FRAME)
->writeBool(StateNames::ITEM_FRAME_MAP_BIT, $block->hasMap())
->writeBool(StateNames::ITEM_FRAME_PHOTO_BIT, false)
->writeFacingDirection($block->getFacing());

View File

@ -36,6 +36,7 @@ use pocketmine\block\FenceGate;
use pocketmine\block\FloorCoralFan;
use pocketmine\block\FloorSign;
use pocketmine\block\GlazedTerracotta;
use pocketmine\block\ItemFrame;
use pocketmine\block\Liquid;
use pocketmine\block\RedMushroomBlock;
use pocketmine\block\RedstoneComparator;
@ -48,6 +49,7 @@ use pocketmine\block\Trapdoor;
use pocketmine\block\utils\CopperOxidation;
use pocketmine\block\utils\DyeColor;
use pocketmine\block\VanillaBlocks;
use pocketmine\block\VanillaBlocks as Blocks;
use pocketmine\block\Wall;
use pocketmine\block\WallCoralFan;
use pocketmine\block\WallSign;
@ -170,6 +172,14 @@ final class BlockStateDeserializerHelper{
->setFacing($in->readHorizontalFacing());
}
public static function decodeItemFrame(BlockStateReader $in, bool $glowing) : ItemFrame{
$in->todo(StateNames::ITEM_FRAME_PHOTO_BIT); //TODO: not sure what the point of this is
return Blocks::ITEM_FRAME()
->setFacing($in->readFacingDirection())
->setHasMap($in->readBool(StateNames::ITEM_FRAME_MAP_BIT))
->setGlowing($glowing);
}
/** @throws BlockStateDeserializeException */
public static function decodeLiquid(Liquid $block, BlockStateReader $in, bool $still) : Liquid{
$fluidHeightState = $in->readBoundedInt(BlockStateNames::LIQUID_DEPTH, 0, 15);

View File

@ -614,12 +614,7 @@ final class BlockStateToBlockObjectDeserializer implements BlockStateDeserialize
});
$this->map(Ids::FLOWING_LAVA, fn(Reader $in) => Helper::decodeFlowingLiquid(Blocks::LAVA(), $in));
$this->map(Ids::FLOWING_WATER, fn(Reader $in) => Helper::decodeFlowingLiquid(Blocks::WATER(), $in));
$this->map(Ids::FRAME, function(Reader $in) : Block{
$in->todo(StateNames::ITEM_FRAME_PHOTO_BIT); //TODO: not sure what the point of this is
return Blocks::ITEM_FRAME()
->setFacing($in->readFacingDirection())
->setHasMap($in->readBool(StateNames::ITEM_FRAME_MAP_BIT));
});
$this->map(Ids::FRAME, fn(Reader $in) => Helper::decodeItemFrame($in, false));
$this->map(Ids::FROSTED_ICE, function(Reader $in) : Block{
return Blocks::FROSTED_ICE()
->setAge($in->readBoundedInt(StateNames::AGE, 0, 3));
@ -632,6 +627,7 @@ final class BlockStateToBlockObjectDeserializer implements BlockStateDeserialize
$this->map(Ids::GILDED_BLACKSTONE, fn() => Blocks::GILDED_BLACKSTONE());
$this->map(Ids::GLASS, fn() => Blocks::GLASS());
$this->map(Ids::GLASS_PANE, fn() => Blocks::GLASS_PANE());
$this->map(Ids::GLOW_FRAME, fn(Reader $in) => Helper::decodeItemFrame($in, true));
$this->map(Ids::GLOWINGOBSIDIAN, fn() => Blocks::GLOWING_OBSIDIAN());
$this->map(Ids::GLOWSTONE, fn() => Blocks::GLOWSTONE());
$this->map(Ids::GOLD_BLOCK, fn() => Blocks::GOLD());