mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 09:56:06 +00:00
Merge commit '3ec2994d7f05f30e2519430379ae0f3106be5074'
# Conflicts: # resources/vanilla # src/pocketmine/Player.php
This commit is contained in:
@ -34,11 +34,14 @@ use pocketmine\item\ItemFactory;
|
||||
use pocketmine\item\ItemIds;
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
use pocketmine\nbt\tag\IntTag;
|
||||
use pocketmine\network\mcpe\protocol\types\GameMode as ProtocolGameMode;
|
||||
use pocketmine\network\mcpe\protocol\types\inventory\ContainerIds;
|
||||
use pocketmine\network\mcpe\protocol\types\inventory\ItemStack;
|
||||
use pocketmine\network\mcpe\protocol\types\inventory\NetworkInventoryAction;
|
||||
use pocketmine\network\mcpe\protocol\types\recipe\RecipeIngredient;
|
||||
use pocketmine\player\GameMode;
|
||||
use pocketmine\player\Player;
|
||||
use pocketmine\utils\AssumptionFailedError;
|
||||
use pocketmine\utils\SingletonTrait;
|
||||
|
||||
class TypeConverter{
|
||||
@ -47,6 +50,26 @@ class TypeConverter{
|
||||
private const DAMAGE_TAG = "Damage"; //TAG_Int
|
||||
private const DAMAGE_TAG_CONFLICT_RESOLUTION = "___Damage_ProtocolCollisionResolution___";
|
||||
|
||||
/**
|
||||
* Returns a client-friendly gamemode of the specified real gamemode
|
||||
* This function takes care of handling gamemodes known to MCPE (as of 1.1.0.3, that includes Survival, Creative and Adventure)
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
public function getClientFriendlyGamemode(GameMode $gamemode) : int{
|
||||
switch($gamemode->id()){
|
||||
case GameMode::SURVIVAL()->id():
|
||||
return ProtocolGameMode::SURVIVAL;
|
||||
case GameMode::CREATIVE()->id():
|
||||
case GameMode::SPECTATOR()->id():
|
||||
return ProtocolGameMode::CREATIVE;
|
||||
case GameMode::ADVENTURE()->id():
|
||||
return ProtocolGameMode::ADVENTURE;
|
||||
default:
|
||||
throw new AssumptionFailedError("Unknown game mode");
|
||||
}
|
||||
}
|
||||
|
||||
public function coreItemStackToRecipeIngredient(Item $itemStack) : RecipeIngredient{
|
||||
$meta = $itemStack->getMeta();
|
||||
return new RecipeIngredient($itemStack->getId(), $meta === -1 ? 0x7fff : $meta, $itemStack->getCount());
|
||||
|
Reference in New Issue
Block a user