24 public function __construct(
29 self::clampOffset($this->xOffset);
30 self::clampOffset($this->yOffset);
31 self::clampOffset($this->zOffset);
34 private static function clampOffset(
int $v) :
void{
35 if($v < Limits::INT8_MIN || $v > Limits::INT8_MAX){
36 throw new \InvalidArgumentException(
"Offsets must be within the range of a byte (" . Limits::INT8_MIN .
" ... " . Limits::INT8_MAX .
")");
40 public function getXOffset() :
int{
return $this->xOffset; }
42 public function getYOffset() :
int{
return $this->yOffset; }
44 public function getZOffset() :
int{
return $this->zOffset; }
46 public static function read(ByteBufferReader $in) :
self{
47 $xOffset = Byte::readSigned($in);
48 $yOffset = Byte::readSigned($in);
49 $zOffset = Byte::readSigned($in);
51 return new self($xOffset, $yOffset, $zOffset);
54 public function write(ByteBufferWriter $out) :
void{
55 Byte::writeSigned($out, $this->xOffset);
56 Byte::writeSigned($out, $this->yOffset);
57 Byte::writeSigned($out, $this->zOffset);