Merge branch '3.5'

This commit is contained in:
Dylan K. Taylor 2019-01-29 14:05:00 +00:00
commit c5f0665853
4 changed files with 28 additions and 19 deletions

View File

@ -158,6 +158,7 @@ use function min;
use function preg_match; use function preg_match;
use function round; use function round;
use function spl_object_id; use function spl_object_id;
use function sqrt;
use function strlen; use function strlen;
use function strpos; use function strpos;
use function strtolower; use function strtolower;
@ -411,8 +412,11 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
} }
public function setFlying(bool $value){ public function setFlying(bool $value){
$this->flying = $value; if($this->flying !== $value){
$this->sendSettings(); $this->flying = $value;
$this->resetFallDistance();
$this->sendSettings();
}
} }
public function isFlying() : bool{ public function isFlying() : bool{
@ -1332,20 +1336,18 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
$this->allowFlight = $this->isCreative(); $this->allowFlight = $this->isCreative();
if($this->isSpectator()){ if($this->isSpectator()){
$this->flying = true; $this->setFlying(true);
$this->keepMovement = true; $this->keepMovement = true;
$this->despawnFromAll(); $this->despawnFromAll();
}else{ }else{
$this->keepMovement = $this->allowMovementCheats; $this->keepMovement = $this->allowMovementCheats;
if($this->isSurvival()){ if($this->isSurvival()){
$this->flying = false; $this->setFlying(false);
} }
$this->spawnToAll(); $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(); $this->sendGamemode();
}else{ }else{
Command::broadcastCommandMessage($this, new TranslationContainer("commands.gamemode.success.self", [GameMode::toTranslation($gm)])); 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{ }else{
$this->broadcastMovement(); $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) //TODO: check swimming (adds 0.015 exhaustion in MCPE)
if($this->isSprinting()){ if($this->isSprinting()){
$this->exhaust(0.1 * $distance, PlayerExhaustEvent::CAUSE_SPRINTING); $this->exhaust(0.1 * $distance, PlayerExhaustEvent::CAUSE_SPRINTING);
@ -1589,6 +1591,12 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
$this->newPosition = null; $this->newPosition = null;
} }
public function fall(float $fallDistance) : void{
if(!$this->flying){
parent::fall($fallDistance);
}
}
public function jump() : void{ public function jump() : void{
(new PlayerJumpEvent($this))->call(); (new PlayerJumpEvent($this))->call();
parent::jump(); parent::jump();
@ -2398,8 +2406,9 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
$ev->call(); $ev->call();
if($ev->isCancelled()){ if($ev->isCancelled()){
$this->sendSettings(); $this->sendSettings();
}else{ }else{ //don't use setFlying() here, to avoid feedback loops
$this->setFlying($fly); $this->flying = $fly;
$this->resetFallDistance();
} }
} }

View File

@ -61,7 +61,7 @@ abstract class Crops extends Flowable{
public function onActivate(Item $item, Player $player = null) : bool{ 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 = clone $this;
$block->age += mt_rand(2, 5); $block->age += mt_rand(2, 5);
if($block->age > 7){ if($block->age > 7){

View File

@ -220,11 +220,10 @@ class Explosion{
$t = $this->level->getTileAt($block->x, $block->y, $block->z); $t = $this->level->getTileAt($block->x, $block->y, $block->z);
if($t instanceof Tile){ if($t instanceof Tile){
if($t instanceof Chest){
$t->unpair();
}
if($yieldDrops and $t instanceof Container){ 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)); $t->getInventory()->dropContents($this->level, $t->add(0.5, 0.5, 0.5));
} }

View File

@ -75,10 +75,6 @@ class SetupWizard{
} }
}while($lang === null); }while($lang === null);
$config = new Config(\pocketmine\DATA . "server.properties", Config::PROPERTIES);
$config->set("language", $lang);
$config->save();
$this->lang = new Language($lang); $this->lang = new Language($lang);
$this->message($this->lang->get("language_has_been_selected")); $this->message($this->lang->get("language_has_been_selected"));
@ -87,6 +83,11 @@ class SetupWizard{
return false; 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"){ if(strtolower($this->getInput($this->lang->get("skip_installer"), "n", "y/N")) === "y"){
return true; return true;
} }