From 6a637d909935ae7777fb85779002fb16bffa49e2 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Thu, 12 Jul 2018 17:23:52 +0100 Subject: [PATCH 1/3] update pthreads version for travis --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7590cb540..4196f2c2e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,9 +6,9 @@ php: before_script: # - pecl install channel://pecl.php.net/pthreads-3.1.6 - echo | pecl install channel://pecl.php.net/yaml-2.0.2 - - git clone https://github.com/krakjoe/pthreads.git + - git clone https://github.com/pmmp/pthreads.git - cd pthreads - - git checkout d32079fb4a88e6e008104d36dbbf0c2dd7deb403 + - git checkout c8cfacda84f21032d6014b53e72bf345ac901dac - phpize - ./configure - make From 8aa8280a63d6037ba0d195564e885481ab837899 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Thu, 12 Jul 2018 17:25:05 +0100 Subject: [PATCH 2/3] Level: Make spawn protection always active regardless of op count (#2290) I don't care if this matches PC behaviour or not. bugs.mojang.com is full of bug reports about this. Just search for "minecraft spawn protection not working" and you'll see what I mean. If you want to disable spawn protection, actually disable it. This behaviour is something that most users are not aware of and find astonishing when they discover it. This behaviour was copied from Minecraft PC, and it's nearly as unexpected there as it is here. This commit reverses the stupidity done in eb0525e892219508d0c0e4602e835d5ddbacaf45. --- src/pocketmine/level/Level.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pocketmine/level/Level.php b/src/pocketmine/level/Level.php index cf29c43f0..d2aa56205 100644 --- a/src/pocketmine/level/Level.php +++ b/src/pocketmine/level/Level.php @@ -1627,7 +1627,7 @@ class Level implements ChunkManager, Metadatable{ $spawnLocation = $this->getSpawnLocation(); $s = new Vector2($spawnLocation->x, $spawnLocation->z); - if(count($this->server->getOps()->getAll()) > 0 and $t->distance($s) <= $distance){ + if($t->distance($s) <= $distance){ return true; } } From ebbbc581caf301e76fd2cf9f64259b323c52470a Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Thu, 12 Jul 2018 17:50:50 +0100 Subject: [PATCH 3/3] Player: clean up cursor inventory when closing main inventory --- src/pocketmine/Player.php | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index e9372b2d4..4436ac534 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -2168,7 +2168,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ return false; } - $this->resetCraftingGridType(); + $this->doCloseInventory(); $message = TextFormat::clean($message, $this->removeFormat); foreach(explode("\n", $message) as $messagePart){ @@ -2243,7 +2243,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ if(!$this->spawned or !$this->isAlive()){ return true; } - $this->resetCraftingGridType(); + $this->doCloseInventory(); switch($packet->event){ case EntityEventPacket::EATING_ITEM: @@ -2394,7 +2394,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ return true; case InventoryTransactionPacket::USE_ITEM_ACTION_BREAK_BLOCK: - $this->resetCraftingGridType(); + $this->doCloseInventory(); $item = $this->inventory->getItemInHand(); $oldItem = clone $item; @@ -2635,7 +2635,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ return true; } - $this->resetCraftingGridType(); + $this->doCloseInventory(); $target = $this->level->getEntity($packet->target); if($target === null){ @@ -2849,7 +2849,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ return true; } - $this->resetCraftingGridType(); + $this->doCloseInventory(); if(isset($this->windowIndex[$packet->windowId])){ $this->server->getPluginManager()->callEvent(new InventoryCloseEvent($this->windowIndex[$packet->windowId], $this)); @@ -2899,7 +2899,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ if(!$this->spawned or !$this->isAlive()){ return true; } - $this->resetCraftingGridType(); + $this->doCloseInventory(); $pos = new Vector3($packet->x, $packet->y, $packet->z); if($pos->distanceSquared($this) > 10000 or $this->level->checkSpawnProtection($this, $pos)){ @@ -3617,7 +3617,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ //Crafting grid must always be evacuated even if keep-inventory is true. This dumps the contents into the //main inventory and drops the rest on the ground. - $this->resetCraftingGridType(); + $this->doCloseInventory(); $this->server->getPluginManager()->callEvent($ev = new PlayerDeathEvent($this, $this->getDrops(), new TranslationContainer($message, $params))); @@ -3800,15 +3800,19 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ $this->craftingGrid = $grid; } - public function resetCraftingGridType() : void{ - $contents = $this->craftingGrid->getContents(); - if(count($contents) > 0){ - $drops = $this->inventory->addItem(...$contents); - foreach($drops as $drop){ - $this->dropItem($drop); - } + public function doCloseInventory() : void{ + /** @var Inventory[] $inventories */ + $inventories = [$this->craftingGrid, $this->cursorInventory]; + foreach($inventories as $inventory){ + $contents = $inventory->getContents(); + if(count($contents) > 0){ + $drops = $this->inventory->addItem(...$contents); + foreach($drops as $drop){ + $this->dropItem($drop); + } - $this->craftingGrid->clearAll(); + $inventory->clearAll(); + } } if($this->craftingGrid->getGridWidth() > CraftingGrid::SIZE_SMALL){