NetworkBinaryStream: unknown byte preceding NBT is a version, not a count

This commit is contained in:
Dylan K. Taylor 2020-06-26 11:47:08 +01:00
parent 22b52f03d1
commit 60b26a7ea8

View File

@ -200,9 +200,9 @@ class NetworkBinaryStream extends BinaryStream{
/** @var CompoundTag|null $nbt */ /** @var CompoundTag|null $nbt */
$nbt = null; $nbt = null;
if($nbtLen === 0xffff){ if($nbtLen === 0xffff){
$c = $this->getByte(); $nbtDataVersion = $this->getByte();
if($c !== 1){ if($nbtDataVersion !== 1){
throw new \UnexpectedValueException("Unexpected NBT count $c"); throw new \UnexpectedValueException("Unexpected NBT data version $nbtDataVersion");
} }
$decodedNBT = (new NetworkLittleEndianNBTStream())->read($this->buffer, false, $this->offset, 512); $decodedNBT = (new NetworkLittleEndianNBTStream())->read($this->buffer, false, $this->offset, 512);
if(!($decodedNBT instanceof CompoundTag)){ if(!($decodedNBT instanceof CompoundTag)){
@ -275,7 +275,7 @@ class NetworkBinaryStream extends BinaryStream{
if($nbt !== null){ if($nbt !== null){
$this->putLShort(0xffff); $this->putLShort(0xffff);
$this->putByte(1); //TODO: some kind of count field? always 1 as of 1.9.0 $this->putByte(1); //TODO: NBT data version (?)
$this->put((new NetworkLittleEndianNBTStream())->write($nbt)); $this->put((new NetworkLittleEndianNBTStream())->write($nbt));
}else{ }else{
$this->putLShort(0); $this->putLShort(0);