mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-09 03:06:55 +00:00
Make Block::decodeState() and encodeState() more codegen-friendly
This commit is contained in:
@ -23,6 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\data\runtime;
|
||||
|
||||
use pocketmine\block\utils\BrewingStandSlot;
|
||||
use pocketmine\block\utils\WallConnectionType;
|
||||
use pocketmine\math\Axis;
|
||||
use pocketmine\math\Facing;
|
||||
@ -71,6 +72,20 @@ final class RuntimeDataReader{
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int[]
|
||||
*/
|
||||
public function readHorizontalFacingFlags() : array{
|
||||
$result = [];
|
||||
foreach(Facing::HORIZONTAL as $facing){
|
||||
if($this->readBool()){
|
||||
$result[$facing] = $facing;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function readFacing() : int{
|
||||
return match($this->readInt(3)){
|
||||
0 => Facing::DOWN,
|
||||
@ -121,5 +136,24 @@ final class RuntimeDataReader{
|
||||
return $connections;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BrewingStandSlot[]
|
||||
* @phpstan-return array<int, BrewingStandSlot>
|
||||
*/
|
||||
public function readBrewingStandSlots() : array{
|
||||
$result = [];
|
||||
foreach([
|
||||
BrewingStandSlot::EAST(),
|
||||
BrewingStandSlot::NORTHWEST(),
|
||||
BrewingStandSlot::SOUTHWEST(),
|
||||
] as $member){
|
||||
if($this->readBool()){
|
||||
$result[$member->id()] = $member;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getOffset() : int{ return $this->offset; }
|
||||
}
|
||||
|
Reference in New Issue
Block a user