mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-11 14:05:35 +00:00
NetworkNbtSerializer: do not assume that this format is related to the disk little-endian format
This commit is contained in:
parent
76e15016a2
commit
3cdf808da1
@ -23,11 +23,23 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol\serializer;
|
||||
|
||||
use pocketmine\nbt\LittleEndianNbtSerializer;
|
||||
use pocketmine\nbt\BaseNbtSerializer;
|
||||
use function count;
|
||||
use function strlen;
|
||||
|
||||
class NetworkNbtSerializer extends LittleEndianNbtSerializer{
|
||||
class NetworkNbtSerializer extends BaseNbtSerializer{
|
||||
|
||||
public function readShort() : int{
|
||||
return $this->buffer->getLShort();
|
||||
}
|
||||
|
||||
public function readSignedShort() : int{
|
||||
return $this->buffer->getSignedLShort();
|
||||
}
|
||||
|
||||
public function writeShort(int $v) : void{
|
||||
$this->buffer->putLShort($v);
|
||||
}
|
||||
|
||||
public function readInt() : int{
|
||||
return $this->buffer->getVarInt();
|
||||
@ -54,6 +66,22 @@ class NetworkNbtSerializer extends LittleEndianNbtSerializer{
|
||||
$this->buffer->put($v);
|
||||
}
|
||||
|
||||
public function readFloat() : float{
|
||||
return $this->buffer->getLFloat();
|
||||
}
|
||||
|
||||
public function writeFloat(float $v) : void{
|
||||
$this->buffer->putLFloat($v);
|
||||
}
|
||||
|
||||
public function readDouble() : float{
|
||||
return $this->buffer->getLDouble();
|
||||
}
|
||||
|
||||
public function writeDouble(float $v) : void{
|
||||
$this->buffer->putLDouble($v);
|
||||
}
|
||||
|
||||
public function readIntArray() : array{
|
||||
$len = $this->readInt(); //varint
|
||||
$ret = [];
|
||||
|
Loading…
x
Reference in New Issue
Block a user