Player: fixing ground state handling in spectator mode, closes #3552, closes #3553

This commit is contained in:
Dylan K. Taylor 2020-06-04 11:10:21 +01:00
parent 7af4e70f64
commit 03e8cd3ed4

View File

@ -1370,9 +1370,16 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
if($this->isSpectator()){
$this->setFlying(true);
$this->keepMovement = true;
$this->onGround = false;
//TODO: HACK! this syncs the onground flag with the client so that flying works properly
//this is a yucky hack but we don't have any other options :(
$this->sendPosition($this, null, null, MovePlayerPacket::MODE_TELEPORT);
$this->despawnFromAll();
}else{
$this->keepMovement = $this->allowMovementCheats;
$this->checkGroundState(0, 0, 0, 0, 0, 0);
if($this->isSurvival()){
$this->setFlying(false);
}
@ -1493,11 +1500,15 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
}
protected function checkGroundState(float $movX, float $movY, float $movZ, float $dx, float $dy, float $dz) : void{
$bb = clone $this->boundingBox;
$bb->minY = $this->y - 0.2;
$bb->maxY = $this->y + 0.2;
if($this->isSpectator()){
$this->onGround = false;
}else{
$bb = clone $this->boundingBox;
$bb->minY = $this->y - 0.2;
$bb->maxY = $this->y + 0.2;
$this->onGround = $this->isCollided = count($this->level->getCollisionBlocks($bb, true)) > 0;
$this->onGround = $this->isCollided = count($this->level->getCollisionBlocks($bb, true)) > 0;
}
}
public function canBeMovedByCurrents() : bool{