From a150f39b023436ed335d849ef813ff82d07fdf28 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Tue, 29 Jan 2019 13:28:43 +0000 Subject: [PATCH 1/5] Fixed fall handling when flying, closes #2709 --- src/pocketmine/Player.php | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index d5be76a9c..bc70c81c2 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -476,8 +476,11 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ } public function setFlying(bool $value){ - $this->flying = $value; - $this->sendSettings(); + if($this->flying !== $value){ + $this->flying = $value; + $this->resetFallDistance(); + $this->sendSettings(); + } } public function isFlying() : bool{ @@ -1410,19 +1413,17 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ $this->allowFlight = $this->isCreative(); if($this->isSpectator()){ - $this->flying = true; + $this->setFlying(true); $this->keepMovement = true; $this->despawnFromAll(); }else{ $this->keepMovement = $this->allowMovementCheats; if($this->isSurvival()){ - $this->flying = false; + $this->setFlying(false); } $this->spawnToAll(); } - $this->resetFallDistance(); - $this->namedtag->setInt("playerGameType", $this->gamemode); if(!$client){ //Gamemode changed by server, do not send for client changes $this->sendGamemode(); @@ -1679,6 +1680,12 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ $this->newPosition = null; } + public function fall(float $fallDistance) : void{ + if(!$this->flying){ + parent::fall($fallDistance); + } + } + public function jump() : void{ (new PlayerJumpEvent($this))->call(); parent::jump(); @@ -2942,8 +2949,9 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ $ev->call(); if($ev->isCancelled()){ $this->sendSettings(); - }else{ + }else{ //don't use setFlying() here, to avoid feedback loops $this->flying = $ev->isFlying(); + $this->resetFallDistance(); } $handled = true; From fbe8485696651291ea62a1a24f4b9a916210380e Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Tue, 29 Jan 2019 13:36:24 +0000 Subject: [PATCH 2/5] Player: fixed falling causing starvation, closes #2708 --- src/pocketmine/Player.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index bc70c81c2..082c78980 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -186,6 +186,7 @@ use function min; use function preg_match; use function round; use function spl_object_hash; +use function sqrt; use function strlen; use function strpos; use function strtolower; @@ -1649,7 +1650,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ }else{ $this->broadcastMovement(); - $distance = $from->distance($to); + $distance = sqrt((($from->x - $to->x) ** 2) + (($from->z - $to->z) ** 2)); //TODO: check swimming (adds 0.015 exhaustion in MCPE) if($this->isSprinting()){ $this->exhaust(0.1 * $distance, PlayerExhaustEvent::CAUSE_SPRINTING); From 80d48161d3acf8cfdbdee6cfeb3d5d57b7631e4b Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Tue, 29 Jan 2019 13:40:29 +0000 Subject: [PATCH 3/5] Crops: fixed consuming bonemeal on fully-grown crop, closes #2704 --- src/pocketmine/block/Crops.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pocketmine/block/Crops.php b/src/pocketmine/block/Crops.php index 73b41c6b3..d8c2a6d19 100644 --- a/src/pocketmine/block/Crops.php +++ b/src/pocketmine/block/Crops.php @@ -43,7 +43,7 @@ abstract class Crops extends Flowable{ public function onActivate(Item $item, Player $player = null) : bool{ - if($item->getId() === Item::DYE and $item->getDamage() === 0x0F){ //Bonemeal + if($this->meta < 7 and $item->getId() === Item::DYE and $item->getDamage() === 0x0F){ //Bonemeal $block = clone $this; $block->meta += mt_rand(2, 5); if($block->meta > 7){ From 1099e2044b41685e51aaaa16ae209decc74e45b5 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Tue, 29 Jan 2019 13:43:13 +0000 Subject: [PATCH 4/5] SetupWizard: fixed user being able to avoid agreeing to license, closes #2703 --- src/pocketmine/wizard/SetupWizard.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/pocketmine/wizard/SetupWizard.php b/src/pocketmine/wizard/SetupWizard.php index 0cd3f1d1e..21aa3a93b 100644 --- a/src/pocketmine/wizard/SetupWizard.php +++ b/src/pocketmine/wizard/SetupWizard.php @@ -76,10 +76,6 @@ class SetupWizard{ } }while($lang === null); - $config = new Config(\pocketmine\DATA . "server.properties", Config::PROPERTIES); - $config->set("language", $lang); - $config->save(); - $this->lang = new BaseLang($lang); $this->message($this->lang->get("language_has_been_selected")); @@ -88,6 +84,11 @@ class SetupWizard{ return false; } + //this has to happen here to prevent user avoiding agreeing to license + $config = new Config(\pocketmine\DATA . "server.properties", Config::PROPERTIES); + $config->set("language", $lang); + $config->save(); + if(strtolower($this->getInput($this->lang->get("skip_installer"), "n", "y/N")) === "y"){ return true; } From 5364e4de68ec794e8821153596ef65fb3028ab41 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Tue, 29 Jan 2019 13:58:47 +0000 Subject: [PATCH 5/5] Explosion: fix chest unpairing (root cause of #2701) not ready to call this "fixed" yet because any chests that were already affected by the bug will still be affected. This change will prevent the creation of more broken chests like this. --- src/pocketmine/level/Explosion.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/pocketmine/level/Explosion.php b/src/pocketmine/level/Explosion.php index e44d3e8d3..1ff862d78 100644 --- a/src/pocketmine/level/Explosion.php +++ b/src/pocketmine/level/Explosion.php @@ -219,11 +219,10 @@ class Explosion{ $t = $this->level->getTileAt($block->x, $block->y, $block->z); if($t instanceof Tile){ + if($t instanceof Chest){ + $t->unpair(); + } if($yieldDrops and $t instanceof Container){ - if($t instanceof Chest){ - $t->unpair(); - } - $t->getInventory()->dropContents($this->level, $t->add(0.5, 0.5, 0.5)); }