diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index 7b03369dd..25a4664ed 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -158,6 +158,7 @@ use function min; use function preg_match; use function round; use function spl_object_id; +use function sqrt; use function strlen; use function strpos; use function strtolower; @@ -411,8 +412,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{ @@ -1332,20 +1336,18 @@ 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(); - - if(!$client){ //GameMode changed by server, do not send for client changes + if(!$client){ //Gamemode changed by server, do not send for client changes $this->sendGamemode(); }else{ Command::broadcastCommandMessage($this, new TranslationContainer("commands.gamemode.success.self", [GameMode::toTranslation($gm)])); @@ -1564,7 +1566,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); @@ -1589,6 +1591,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(); @@ -2398,8 +2406,9 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ $ev->call(); if($ev->isCancelled()){ $this->sendSettings(); - }else{ - $this->setFlying($fly); + }else{ //don't use setFlying() here, to avoid feedback loops + $this->flying = $fly; + $this->resetFallDistance(); } } diff --git a/src/pocketmine/block/Crops.php b/src/pocketmine/block/Crops.php index 516c1697c..c56c678b2 100644 --- a/src/pocketmine/block/Crops.php +++ b/src/pocketmine/block/Crops.php @@ -61,7 +61,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->age < 7 and $item->getId() === Item::DYE and $item->getDamage() === 0x0F){ //Bonemeal $block = clone $this; $block->age += mt_rand(2, 5); if($block->age > 7){ diff --git a/src/pocketmine/level/Explosion.php b/src/pocketmine/level/Explosion.php index 540b4e0fe..5251ee366 100644 --- a/src/pocketmine/level/Explosion.php +++ b/src/pocketmine/level/Explosion.php @@ -220,11 +220,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)); } diff --git a/src/pocketmine/wizard/SetupWizard.php b/src/pocketmine/wizard/SetupWizard.php index 149570053..464066994 100644 --- a/src/pocketmine/wizard/SetupWizard.php +++ b/src/pocketmine/wizard/SetupWizard.php @@ -75,10 +75,6 @@ class SetupWizard{ } }while($lang === null); - $config = new Config(\pocketmine\DATA . "server.properties", Config::PROPERTIES); - $config->set("language", $lang); - $config->save(); - $this->lang = new Language($lang); $this->message($this->lang->get("language_has_been_selected")); @@ -87,6 +83,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; }