mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-16 16:34:05 +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::NO_PVP, $for->isSpectator());
|
||||||
$pk->setFlag(AdventureSettingsPacket::AUTO_JUMP, $for->hasAutoJump());
|
$pk->setFlag(AdventureSettingsPacket::AUTO_JUMP, $for->hasAutoJump());
|
||||||
$pk->setFlag(AdventureSettingsPacket::ALLOW_FLIGHT, $for->getAllowFlight());
|
$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());
|
$pk->setFlag(AdventureSettingsPacket::FLYING, $for->isFlying());
|
||||||
|
|
||||||
//TODO: permission flags
|
//TODO: permission flags
|
||||||
|
@ -234,6 +234,7 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
|
|||||||
//TODO: Abilities
|
//TODO: Abilities
|
||||||
protected bool $autoJump = true;
|
protected bool $autoJump = true;
|
||||||
protected bool $allowFlight = false;
|
protected bool $allowFlight = false;
|
||||||
|
protected bool $blockCollision = true;
|
||||||
protected bool $flying = false;
|
protected bool $flying = false;
|
||||||
|
|
||||||
protected ?int $lineHeight = null;
|
protected ?int $lineHeight = null;
|
||||||
@ -394,6 +395,15 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
|
|||||||
return $this->allowFlight;
|
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{
|
public function setFlying(bool $value) : void{
|
||||||
if($this->flying !== $value){
|
if($this->flying !== $value){
|
||||||
$this->flying = $value;
|
$this->flying = $value;
|
||||||
@ -970,6 +980,7 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
|
|||||||
|
|
||||||
if($this->isSpectator()){
|
if($this->isSpectator()){
|
||||||
$this->setFlying(true);
|
$this->setFlying(true);
|
||||||
|
$this->setHasBlockCollision(false);
|
||||||
$this->setSilent();
|
$this->setSilent();
|
||||||
$this->onGround = false;
|
$this->onGround = false;
|
||||||
|
|
||||||
@ -980,6 +991,7 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
|
|||||||
if($this->isSurvival()){
|
if($this->isSurvival()){
|
||||||
$this->setFlying(false);
|
$this->setFlying(false);
|
||||||
}
|
}
|
||||||
|
$this->setHasBlockCollision(true);
|
||||||
$this->setSilent(false);
|
$this->setSilent(false);
|
||||||
$this->checkGroundState(0, 0, 0, 0, 0, 0);
|
$this->checkGroundState(0, 0, 0, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user