mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 16:51: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:
parent
cd850b111d
commit
ce54d268f2
@ -797,7 +797,7 @@ class NetworkSession{
|
||||
$pk->setFlag(AdventureSettingsPacket::NO_PVP, $for->isSpectator());
|
||||
$pk->setFlag(AdventureSettingsPacket::AUTO_JUMP, $for->hasAutoJump());
|
||||
$pk->setFlag(AdventureSettingsPacket::ALLOW_FLIGHT, $for->getAllowFlight());
|
||||
$pk->setFlag(AdventureSettingsPacket::NO_CLIP, $for->isSpectator());
|
||||
$pk->setFlag(AdventureSettingsPacket::NO_CLIP, !$for->hasBlockCollision());
|
||||
$pk->setFlag(AdventureSettingsPacket::FLYING, $for->isFlying());
|
||||
|
||||
//TODO: permission flags
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user