mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 08:44:01 +00:00
added protocol GameMode constants
This commit is contained in:
parent
786f416f2e
commit
3ec2994d7f
@ -146,6 +146,7 @@ use pocketmine\network\mcpe\protocol\types\CommandEnum;
|
||||
use pocketmine\network\mcpe\protocol\types\CommandParameter;
|
||||
use pocketmine\network\mcpe\protocol\types\ContainerIds;
|
||||
use pocketmine\network\mcpe\protocol\types\DimensionIds;
|
||||
use pocketmine\network\mcpe\protocol\types\GameMode;
|
||||
use pocketmine\network\mcpe\protocol\types\PersonaPieceTintColor;
|
||||
use pocketmine\network\mcpe\protocol\types\PersonaSkinPiece;
|
||||
use pocketmine\network\mcpe\protocol\types\PlayerPermissions;
|
||||
@ -1333,12 +1334,13 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
* TODO: remove this when Spectator Mode gets added properly to MCPE
|
||||
*/
|
||||
public static function getClientFriendlyGamemode(int $gamemode) : int{
|
||||
$gamemode &= 0x03;
|
||||
if($gamemode === Player::SPECTATOR){
|
||||
return Player::CREATIVE;
|
||||
}
|
||||
|
||||
return $gamemode;
|
||||
static $map = [
|
||||
self::SURVIVAL => GameMode::SURVIVAL,
|
||||
self::CREATIVE => GameMode::CREATIVE,
|
||||
self::ADVENTURE => GameMode::ADVENTURE,
|
||||
self::SPECTATOR => GameMode::CREATIVE
|
||||
];
|
||||
return $map[$gamemode & 0x3];
|
||||
}
|
||||
|
||||
/**
|
||||
|
38
src/pocketmine/network/mcpe/protocol/types/GameMode.php
Normal file
38
src/pocketmine/network/mcpe/protocol/types/GameMode.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol\types;
|
||||
|
||||
final class GameMode{
|
||||
|
||||
private function __construct(){
|
||||
//NOOP
|
||||
}
|
||||
|
||||
public const SURVIVAL = 0;
|
||||
public const CREATIVE = 1;
|
||||
public const ADVENTURE = 2;
|
||||
public const SURVIVAL_VIEWER = 3;
|
||||
public const CREATIVE_VIEWER = 4;
|
||||
public const DEFAULT = 5;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user