Generalize runtime block data serialization

we want to reuse this code for item type data
This commit is contained in:
Dylan K. Taylor
2022-07-05 14:13:37 +01:00
parent 1714e2fd35
commit 325f1cf82e
80 changed files with 494 additions and 608 deletions

View File

@ -28,8 +28,8 @@ use pocketmine\block\utils\AnalogRedstoneSignalEmitterTrait;
use pocketmine\block\utils\HorizontalFacingTrait;
use pocketmine\block\utils\PoweredByRedstoneTrait;
use pocketmine\block\utils\SupportType;
use pocketmine\data\runtime\block\BlockDataReader;
use pocketmine\data\runtime\block\BlockDataWriter;
use pocketmine\data\runtime\RuntimeDataReader;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\item\Item;
use pocketmine\math\AxisAlignedBB;
use pocketmine\math\Facing;
@ -47,14 +47,14 @@ class RedstoneComparator extends Flowable{
public function getRequiredStateDataBits() : int{ return 4; }
protected function decodeState(BlockDataReader $r) : void{
protected function decodeState(RuntimeDataReader $r) : void{
$this->facing = $r->readHorizontalFacing();
$this->isSubtractMode = $r->readBool();
$this->powered = $r->readBool();
//TODO: this doesn't call the decoder from AnalogRedstoneSignalEmitter
}
protected function encodeState(BlockDataWriter $w) : void{
protected function encodeState(RuntimeDataWriter $w) : void{
$w->writeHorizontalFacing($this->facing);
$w->writeBool($this->isSubtractMode);
$w->writeBool($this->powered);