Merge remote-tracking branch 'upstream/stable' into stable

This commit is contained in:
Stephen
2019-12-01 21:55:50 -05:00
30 changed files with 178 additions and 120 deletions

View File

@ -157,7 +157,11 @@ class NetworkBinaryStream extends BinaryStream{
if($c !== 1){
throw new \UnexpectedValueException("Unexpected NBT count $c");
}
$nbt = (new NetworkLittleEndianNBTStream())->read($this->buffer, false, $this->offset, 512);
$decodedNBT = (new NetworkLittleEndianNBTStream())->read($this->buffer, false, $this->offset, 512);
if(!($decodedNBT instanceof CompoundTag)){
throw new \UnexpectedValueException("Unexpected root tag type for itemstack");
}
$nbt = $decodedNBT;
}elseif($nbtLen !== 0){
throw new \UnexpectedValueException("Unexpected fake NBT length $nbtLen");
}

View File

@ -227,6 +227,7 @@ class AvailableCommandsPacket extends DataPacket{
$retval->aliases = $enums[$this->getLInt()] ?? null;
for($overloadIndex = 0, $overloadCount = $this->getUnsignedVarInt(); $overloadIndex < $overloadCount; ++$overloadIndex){
$retval->overloads[$overloadIndex] = [];
for($paramIndex = 0, $paramCount = $this->getUnsignedVarInt(); $paramIndex < $paramCount; ++$paramIndex){
$parameter = new CommandParameter();
$parameter->paramName = $this->getString();

View File

@ -140,7 +140,7 @@ class CraftingDataPacket extends DataPacket{
}
$this->decodedEntries[] = $entry;
}
$this->getBool(); //cleanRecipes
$this->cleanRecipes = $this->getBool();
}
private static function writeEntry($entry, NetworkBinaryStream $stream, int $pos){

View File

@ -135,7 +135,7 @@ abstract class DataPacket extends NetworkBinaryStream{
abstract public function handle(NetworkSession $session) : bool;
public function clean(){
$this->buffer = null;
$this->buffer = "";
$this->isEncoded = false;
$this->offset = 0;
return $this;