mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-05 17:36:12 +00:00
More broken mess to spawn 1.2
This commit is contained in:
@ -27,6 +27,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\protocol\types\PlayerPermissions;
|
||||
|
||||
class AdventureSettingsPacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::ADVENTURE_SETTINGS_PACKET;
|
||||
@ -37,53 +38,75 @@ class AdventureSettingsPacket extends DataPacket{
|
||||
const PERMISSION_AUTOMATION = 3;
|
||||
const PERMISSION_ADMIN = 4;
|
||||
|
||||
public $worldImmutable = false;
|
||||
public $noPvp = false;
|
||||
public $noPvm = false;
|
||||
public $noMvp = false;
|
||||
//TODO: check level 3
|
||||
|
||||
public $autoJump = true;
|
||||
public $allowFlight = false;
|
||||
public $noClip = false;
|
||||
public $worldBuilder = false;
|
||||
public $isFlying = false;
|
||||
public $muted = false;
|
||||
/**
|
||||
* This constant is used to identify flags that should be set on the second field. In a sensible world, these
|
||||
* flags would all be set on the same packet field, but as of MCPE 1.2, the new abilities flags have for some
|
||||
* reason been assigned a separate field.
|
||||
*/
|
||||
const BITFLAG_SECOND_SET = 1 << 16;
|
||||
|
||||
const WORLD_IMMUTABLE = 0x01;
|
||||
const NO_PVP = 0x02;
|
||||
|
||||
const AUTO_JUMP = 0x20;
|
||||
const ALLOW_FLIGHT = 0x40;
|
||||
const NO_CLIP = 0x80;
|
||||
const WORLD_BUILDER = 0x100;
|
||||
const FLYING = 0x200;
|
||||
const MUTED = 0x400;
|
||||
|
||||
const BUILD_AND_MINE = 0x01 | self::BITFLAG_SECOND_SET;
|
||||
const DOORS_AND_SWITCHES = 0x02 | self::BITFLAG_SECOND_SET;
|
||||
const OPEN_CONTAINERS = 0x04 | self::BITFLAG_SECOND_SET;
|
||||
const ATTACK_PLAYERS = 0x08 | self::BITFLAG_SECOND_SET;
|
||||
const ATTACK_MOBS = 0x10 | self::BITFLAG_SECOND_SET;
|
||||
const OPERATOR = 0x20 | self::BITFLAG_SECOND_SET;
|
||||
const TELEPORT = 0x80 | self::BITFLAG_SECOND_SET;
|
||||
|
||||
public $flags = 0;
|
||||
public $userPermission;
|
||||
public $commandPermission = self::PERMISSION_NORMAL;
|
||||
public $flags2 = -1;
|
||||
public $playerPermission = PlayerPermissions::MEMBER;
|
||||
public $long1 = 0;
|
||||
|
||||
public function decodePayload(){
|
||||
$this->flags = $this->getUnsignedVarInt();
|
||||
$this->userPermission = $this->getUnsignedVarInt();
|
||||
|
||||
$this->worldImmutable = (bool) ($this->flags & 1);
|
||||
$this->noPvp = (bool) ($this->flags & (1 << 1));
|
||||
$this->noPvm = (bool) ($this->flags & (1 << 2));
|
||||
$this->noMvp = (bool) ($this->flags & (1 << 3));
|
||||
|
||||
$this->autoJump = (bool) ($this->flags & (1 << 5));
|
||||
$this->allowFlight = (bool) ($this->flags & (1 << 6));
|
||||
$this->noClip = (bool) ($this->flags & (1 << 7));
|
||||
$this->worldBuilder = (bool) ($this->flags & (1 << 8));
|
||||
$this->isFlying = (bool) ($this->flags & (1 << 9));
|
||||
$this->muted = (bool) ($this->flags & (1 << 10));
|
||||
$this->commandPermission = $this->getUnsignedVarInt();
|
||||
$this->flags2 = $this->getUnsignedVarInt();
|
||||
$this->playerPermission = $this->getUnsignedVarInt();
|
||||
$this->long1 = $this->getLLong();
|
||||
}
|
||||
|
||||
public function encodePayload(){
|
||||
$this->flags |= ((int) $this->worldImmutable);
|
||||
$this->flags |= ((int) $this->noPvp) << 1;
|
||||
$this->flags |= ((int) $this->noPvm) << 2;
|
||||
$this->flags |= ((int) $this->noMvp) << 3;
|
||||
|
||||
$this->flags |= ((int) $this->autoJump) << 5;
|
||||
$this->flags |= ((int) $this->allowFlight) << 6;
|
||||
$this->flags |= ((int) $this->noClip) << 7;
|
||||
$this->flags |= ((int) $this->worldBuilder) << 8;
|
||||
$this->flags |= ((int) $this->isFlying) << 9;
|
||||
$this->flags |= ((int) $this->muted) << 10;
|
||||
|
||||
$this->putUnsignedVarInt($this->flags);
|
||||
$this->putUnsignedVarInt($this->userPermission);
|
||||
$this->putUnsignedVarInt($this->commandPermission);
|
||||
$this->putUnsignedVarInt($this->flags2);
|
||||
$this->putUnsignedVarInt($this->playerPermission);
|
||||
$this->putLLong($this->long1);
|
||||
}
|
||||
|
||||
public function getFlag(int $flag) : bool{
|
||||
if($flag & self::BITFLAG_SECOND_SET){
|
||||
return ($this->flags2 & $flag) !== 0;
|
||||
}
|
||||
|
||||
return ($this->flags & $flag) !== 0;
|
||||
}
|
||||
|
||||
public function setFlag(int $flag, bool $value){
|
||||
if($flag & self::BITFLAG_SECOND_SET){
|
||||
$flagSet =& $this->flags2;
|
||||
}else{
|
||||
$flagSet =& $this->flags;
|
||||
}
|
||||
|
||||
if($value){
|
||||
$flagSet |= $flag;
|
||||
}else{
|
||||
$flagSet &= ~$flag;
|
||||
}
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
|
Reference in New Issue
Block a user