From 0f261b7baa2b72083f3048786a092da4cf9056ca Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Mon, 24 Oct 2016 14:05:42 +0100 Subject: [PATCH] Fixed player flags (now can sleep!) --- src/pocketmine/Player.php | 9 +++++---- src/pocketmine/entity/Entity.php | 4 ++-- src/pocketmine/entity/Human.php | 6 +++--- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index 88619f2a0..e4443dea0 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -1016,7 +1016,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade $this->sleeping = clone $pos; $this->setDataProperty(self::DATA_PLAYER_BED_POSITION, self::DATA_TYPE_POS, [$pos->x, $pos->y, $pos->z]); - $this->setDataFlag(self::DATA_PLAYER_FLAGS, self::DATA_PLAYER_FLAG_SLEEP, true); + $this->setDataFlag(self::DATA_PLAYER_FLAGS, self::DATA_PLAYER_FLAG_SLEEP, true, self::DATA_TYPE_BYTE); $this->setSpawn($pos); @@ -1051,7 +1051,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade $this->sleeping = null; $this->setDataProperty(self::DATA_PLAYER_BED_POSITION, self::DATA_TYPE_POS, [0, 0, 0]); - $this->setDataFlag(self::DATA_PLAYER_FLAGS, self::DATA_PLAYER_FLAG_SLEEP, false); + $this->setDataFlag(self::DATA_PLAYER_FLAGS, self::DATA_PLAYER_FLAG_SLEEP, false, self::DATA_TYPE_BYTE); $this->level->sleepTicks = 0; @@ -1098,11 +1098,12 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade /** * Sets the gamemode, and if needed, kicks the Player. * - * @param int $gm + * @param int $gm + * @param bool $client if the client made this change in their GUI * * @return bool */ - public function setGamemode($gm, $client = false){ + public function setGamemode(int $gm, bool $client = false){ if($gm < 0 or $gm > 3 or $this->gamemode === $gm){ return false; } diff --git a/src/pocketmine/entity/Entity.php b/src/pocketmine/entity/Entity.php index 63286147b..935ba3450 100644 --- a/src/pocketmine/entity/Entity.php +++ b/src/pocketmine/entity/Entity.php @@ -86,8 +86,8 @@ abstract class Entity extends Location implements Metadatable{ const DATA_AIR = 7; //short /* 8 (int) * 9 (int) - * 27 (byte) something to do with beds - * 28 (int) + * 27 (byte) player-specific flags + * 28 (int) player "index"? * 29 (block coords) bed position */ const DATA_LEAD_HOLDER_EID = 38; //long const DATA_SCALE = 39; //float diff --git a/src/pocketmine/entity/Human.php b/src/pocketmine/entity/Human.php index 5b7383f13..0b330117a 100644 --- a/src/pocketmine/entity/Human.php +++ b/src/pocketmine/entity/Human.php @@ -42,10 +42,10 @@ use pocketmine\utils\UUID; class Human extends Creature implements ProjectileSource, InventoryHolder{ - const DATA_PLAYER_FLAG_SLEEP = 1; //TODO: CHECK + const DATA_PLAYER_FLAG_SLEEP = 1; const DATA_PLAYER_FLAG_DEAD = 2; //TODO: CHECK - const DATA_PLAYER_FLAGS = 16; //TODO: CHECK + const DATA_PLAYER_FLAGS = 27; const DATA_PLAYER_BED_POSITION = 29; @@ -254,7 +254,7 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{ protected function initEntity(){ - $this->setDataFlag(self::DATA_PLAYER_FLAGS, self::DATA_PLAYER_FLAG_SLEEP, false); + $this->setDataFlag(self::DATA_PLAYER_FLAGS, self::DATA_PLAYER_FLAG_SLEEP, false, self::DATA_TYPE_BYTE); $this->setDataProperty(self::DATA_PLAYER_BED_POSITION, self::DATA_TYPE_POS, [0, 0, 0], false); $this->inventory = new PlayerInventory($this);