mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-10-20 07:39:42 +00:00
Player: allow controlling client-sided block collisions irrespective of Spectator Mode (#4563)
- Added the following API methods: - `Player::hasBlockCollision()` - `Player::setHasBlockCollision()` This enables spectator-like noclip behaviour in other gamemodes (could be useful for builders).
This commit is contained in:
@@ -234,6 +234,7 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
|
||||
//TODO: Abilities
|
||||
protected bool $autoJump = true;
|
||||
protected bool $allowFlight = false;
|
||||
protected bool $blockCollision = true;
|
||||
protected bool $flying = false;
|
||||
|
||||
protected ?int $lineHeight = null;
|
||||
@@ -394,6 +395,15 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
|
||||
return $this->allowFlight;
|
||||
}
|
||||
|
||||
public function setHasBlockCollision(bool $value) : void{
|
||||
$this->blockCollision = $value;
|
||||
$this->getNetworkSession()->syncAdventureSettings($this);
|
||||
}
|
||||
|
||||
public function hasBlockCollision() : bool{
|
||||
return $this->blockCollision;
|
||||
}
|
||||
|
||||
public function setFlying(bool $value) : void{
|
||||
if($this->flying !== $value){
|
||||
$this->flying = $value;
|
||||
@@ -970,6 +980,7 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
|
||||
|
||||
if($this->isSpectator()){
|
||||
$this->setFlying(true);
|
||||
$this->setHasBlockCollision(false);
|
||||
$this->setSilent();
|
||||
$this->onGround = false;
|
||||
|
||||
@@ -980,6 +991,7 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
|
||||
if($this->isSurvival()){
|
||||
$this->setFlying(false);
|
||||
}
|
||||
$this->setHasBlockCollision(true);
|
||||
$this->setSilent(false);
|
||||
$this->checkGroundState(0, 0, 0, 0, 0, 0);
|
||||
}
|
||||
|
Reference in New Issue
Block a user