Merge branch 'stable' into next-minor

This commit is contained in:
Dylan K. Taylor
2022-01-14 00:45:49 +00:00
9 changed files with 60 additions and 36 deletions

View File

@@ -109,6 +109,7 @@ use function base64_encode;
use function count;
use function fmod;
use function implode;
use function in_array;
use function is_infinite;
use function is_nan;
use function json_decode;
@@ -418,6 +419,8 @@ class InGamePacketHandler extends PacketHandler{
}
//TODO: end hack for client spam bug
self::validateFacing($data->getFace());
$blockPos = $data->getBlockPosition();
$vBlockPos = new Vector3($blockPos->getX(), $blockPos->getY(), $blockPos->getZ());
if(!$this->player->interactBlock($vBlockPos, $data->getFace(), $clickPos)){
@@ -449,6 +452,15 @@ class InGamePacketHandler extends PacketHandler{
return false;
}
/**
* @throws PacketHandlingException
*/
private static function validateFacing(int $facing) : void{
if(!in_array($facing, Facing::ALL, true)){
throw new PacketHandlingException("Invalid facing value $facing");
}
}
/**
* Internal function used to execute rollbacks when an action fails on a block.
*/
@@ -565,6 +577,7 @@ class InGamePacketHandler extends PacketHandler{
switch($action){
case PlayerAction::START_BREAK:
self::validateFacing($face);
if(!$this->player->attackBlock($pos, $face)){
$this->onFailedBlockAction($pos, $face);
}
@@ -582,6 +595,7 @@ class InGamePacketHandler extends PacketHandler{
$this->player->stopSleep();
break;
case PlayerAction::CRACK_BREAK:
self::validateFacing($face);
$this->player->continueBreakBlock($pos, $face);
break;
case PlayerAction::INTERACT_BLOCK: //TODO: ignored (for now)

View File

@@ -23,6 +23,7 @@ declare(strict_types=1);
namespace pocketmine\thread;
use pocketmine\scheduler\AsyncTask;
use const PTHREADS_INHERIT_NONE;
/**

View File

@@ -503,9 +503,6 @@ final class Utils{
*/
public static function parseDocComment(string $docComment) : array{
$rawDocComment = substr($docComment, 3, -2); //remove the opening and closing markers
if($rawDocComment === false){ //usually empty doc comment, but this is safer and statically analysable
return [];
}
preg_match_all('/(*ANYCRLF)^[\t ]*(?:\* )?@([a-zA-Z\-]+)(?:[\t ]+(.+?))?[\t ]*$/m', $rawDocComment, $matches);
return array_combine($matches[1], $matches[2]);