22declare(strict_types=1);
24namespace pocketmine\data\bedrock\block\convert\property;
43 private \Closure $getter,
44 private \Closure $setter,
45 private int $offset = 0
48 throw new \InvalidArgumentException(
"Min value cannot be greater than max value");
52 public function getName() : string{ return $this->name; }
57 public static function unused(
string $name,
int $serializedValue) : self{
58 return new self($name,
Limits::INT32_MIN,
Limits::INT32_MAX, fn() => $serializedValue, fn() => null);
62 $value = $in->readBoundedInt($this->name, $this->min, $this->max);
63 ($this->setter)($block, $value + $this->offset);
67 $value = ($this->getter)($block);
68 $out->
writeInt($this->name, $value - $this->offset);
writeInt(string $name, int $value)
__construct(private string $name, private int $min, private int $max, private \Closure $getter, private \Closure $setter, private int $offset=0)
deserialize(object $block, BlockStateReader $in)
serialize(object $block, BlockStateWriter $out)
static unused(string $name, int $serializedValue)