22declare(strict_types=1);
24namespace pocketmine\data\runtime;
26use pocketmine\block\utils\BrewingStandSlot;
32 use LegacyRuntimeEnumDescriberTrait;
34 private int $bits = 0;
36 protected function addBits(
int $bits) :
void{
40 public function getBitsUsed() :
int{
44 public function int(
int $bits,
int &$value) :
void{
45 $this->addBits($bits);
51 public function boundedInt(
int $bits,
int $min,
int $max,
int &$value) : void{
52 $currentBits = $this->bits;
54 $actualBits = $this->bits - $currentBits;
55 if($actualBits !== $bits){
56 throw new \InvalidArgumentException(
"Bits should be $actualBits for the given bounds, but received $bits. Use boundedIntAuto() for automatic bits calculation.");
61 $this->addBits(((int) log($max - $min, 2)) + 1);
64 public function bool(
bool &$value) : void{
68 public function horizontalFacing(
int &$facing) : void{
73 $this->addBits(count(
Facing::ALL));
77 $this->addBits(count(
Facing::HORIZONTAL));
80 public function facing(
int &$facing) : void{
84 public function facingExcept(
int &$facing,
int $except) : void{
85 $this->facing($facing);
88 public function axis(
int &$axis) : void{
92 public function horizontalAxis(
int &$axis) : void{
101 $this->addBits(count(BrewingStandSlot::cases()));
104 public function railShape(
int &$railShape) : void{
108 public function straightOnlyRailShape(
int &$railShape) : void{
112 public function enum(\UnitEnum &$case) :
void{
113 $metadata = RuntimeEnumMetadata::from($case);
114 $this->addBits($metadata->bits);
117 public function enumSet(array &$set, array $allCases) : void{
118 $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)