22declare(strict_types=1);
24namespace pocketmine\data\runtime;
26use pocketmine\block\utils\BrewingStandSlot;
32 private int $bits = 0;
34 protected function addBits(
int $bits) :
void{
38 public function getBitsUsed() :
int{
42 public function int(
int $bits,
int &$value) :
void{
43 $this->addBits($bits);
49 public function boundedInt(
int $bits,
int $min,
int $max,
int &$value) : void{
50 $currentBits = $this->bits;
52 $actualBits = $this->bits - $currentBits;
53 if($actualBits !== $bits){
54 throw new \InvalidArgumentException(
"Bits should be $actualBits for the given bounds, but received $bits. Use boundedIntAuto() for automatic bits calculation.");
59 $this->addBits(((int) log($max - $min, 2)) + 1);
62 public function bool(
bool &$value) : void{
66 public function horizontalFacing(
int &$facing) : void{
71 $this->addBits(count(
Facing::ALL));
75 $this->addBits(count(
Facing::HORIZONTAL));
78 public function facing(
int &$facing) : void{
82 public function facingExcept(
int &$facing,
int $except) : void{
83 $this->facing($facing);
86 public function axis(
int &$axis) : void{
90 public function horizontalAxis(
int &$axis) : void{
99 $this->addBits(count(BrewingStandSlot::cases()));
102 public function railShape(
int &$railShape) : void{
106 public function straightOnlyRailShape(
int &$railShape) : void{
110 public function enum(\UnitEnum &$case) :
void{
111 $metadata = RuntimeEnumMetadata::from($case);
112 $this->addBits($metadata->bits);
115 public function enumSet(array &$set, array $allCases) : void{
116 $this->addBits(count($allCases));
boundedIntAuto(int $min, int $max, int &$value)
facingFlags(array &$faces)
boundedInt(int $bits, int $min, int $max, int &$value)
enumSet(array &$set, array $allCases)
wallConnections(array &$connections)
brewingStandSlots(array &$slots)
horizontalFacingFlags(array &$faces)