Merge branch '3.5' into master-rollback

This commit is contained in:
Dylan K. Taylor 2019-02-04 19:47:21 +00:00
commit c9f9f551f4
4 changed files with 18 additions and 10 deletions

View File

@ -44,6 +44,7 @@ use pocketmine\plugin\Plugin;
use function array_merge;
use function assert;
use function dechex;
use function get_class;
use const PHP_INT_MAX;
class Block extends Position implements BlockIds, Metadatable{
@ -324,6 +325,7 @@ class Block extends Position implements BlockIds, Metadatable{
* @param Item $item
*
* @return float
* @throws \InvalidArgumentException if the item efficiency is not a positive number
*/
public function getBreakTime(Item $item) : float{
$base = $this->getHardness();
@ -335,7 +337,7 @@ class Block extends Position implements BlockIds, Metadatable{
$efficiency = $item->getMiningEfficiency($this);
if($efficiency <= 0){
throw new \RuntimeException("Item efficiency is invalid");
throw new \InvalidArgumentException(get_class($item) . " has invalid mining efficiency: expected >= 0, got $efficiency");
}
$base /= $efficiency;

View File

@ -89,7 +89,7 @@ class SplashPotion extends Throwable{
if(!$this->willLinger()){
foreach($this->level->getNearbyEntities($this->boundingBox->expandedCopy(4.125, 2.125, 4.125), $this) as $entity){
if($entity instanceof Living and $entity->isAlive()){
$distanceSquared = $entity->distanceSquared($this);
$distanceSquared = $entity->add(0, $entity->getEyeHeight(), 0)->distanceSquared($this);
if($distanceSquared > 16){ //4 blocks
continue;
}

View File

@ -561,7 +561,10 @@ class Level implements ChunkManager, Metadatable{
}
/**
* Gets the players being used in a specific chunk
* @deprecated WARNING: This function has a misleading name. Contrary to what the name might imply, this function
* DOES NOT return players who are IN a chunk, rather, it returns players who can SEE the chunk.
*
* Returns a list of players who have the target chunk within their view distance.
*
* @param int $chunkX
* @param int $chunkZ
@ -678,8 +681,7 @@ class Level implements ChunkManager, Metadatable{
}
/**
* WARNING: Do not use this, it's only for internal use.
* Changes to this function won't be recorded on the version.
* @internal
*
* @param Player ...$targets If empty, will send to all players in the level.
*/
@ -699,8 +701,7 @@ class Level implements ChunkManager, Metadatable{
}
/**
* WARNING: Do not use this, it's only for internal use.
* Changes to this function won't be recorded on the version.
* @internal
*
* @param int $currentTick
*
@ -2262,8 +2263,10 @@ class Level implements ChunkManager, Metadatable{
$oldChunk = $this->getChunk($chunkX, $chunkZ, false);
if($oldChunk !== null and $oldChunk !== $chunk){
if($deleteEntitiesAndTiles){
$players = $this->getChunkPlayers($chunkX, $chunkZ);
foreach($players as $player){
foreach($oldChunk->getEntities() as $player){
if(!($player instanceof Player)){
continue;
}
$chunk->addEntity($player);
$oldChunk->removeEntity($player);
$player->chunk = $chunk;
@ -2618,6 +2621,7 @@ class Level implements ChunkManager, Metadatable{
$loader->onChunkLoaded($chunk);
}
}else{
$this->server->getLogger()->debug("Newly loaded chunk $x $z has no loaders registered, will be unloaded at next available opportunity");
$this->unloadChunkRequest($x, $z);
}

View File

@ -94,7 +94,9 @@ class StartGamePacket extends DataPacket implements ClientboundPacket{
/** @var bool */
public $isTexturePacksRequired = true;
/** @var array */
public $gameRules = []; //TODO: implement this
public $gameRules = [ //TODO: implement this
"naturalregeneration" => [1, false] //Hack for client side regeneration
];
/** @var bool */
public $hasBonusChestEnabled = false;
/** @var bool */