35 return $this->buffer->getShort();
39 return $this->buffer->getSignedShort();
42 public function writeShort(
int $v) : void{
43 $this->buffer->putShort($v);
47 return $this->buffer->getInt();
50 public function writeInt(
int $v) : void{
51 $this->buffer->putInt($v);
55 return $this->buffer->getLong();
58 public function writeLong(
int $v) : void{
59 $this->buffer->putLong($v);
63 return $this->buffer->getFloat();
66 public function writeFloat(
float $v) : void{
67 $this->buffer->putFloat($v);
71 return $this->buffer->getDouble();
74 public function writeDouble(
float $v) : void{
75 $this->buffer->putDouble($v);
79 $len = $this->readInt();
81 throw new NbtDataException(
"Array length cannot be less than zero ($len < 0)");
83 $unpacked = unpack(
"N*", $this->buffer->get($len * 4));
84 assert($unpacked !==
false,
"The formatting string is valid, and we gave a multiple of 4 bytes");
85 return array_values($unpacked);
89 $this->writeInt(count($array));
90 $this->buffer->put(pack(
"N*", ...$array));