mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-09 19:24:12 +00:00
Compare commits
21 Commits
Alpha_1.4d
...
1.4
Author | SHA1 | Date | |
---|---|---|---|
3de14d8ba6 | |||
5fffabe05b | |||
3128ae9736 | |||
7be4e2fa81 | |||
95b305ce87 | |||
767800662c | |||
fe32e6f5d0 | |||
2cec0d9f36 | |||
d800a21bd4 | |||
8d9fbec4ce | |||
ab72c32769 | |||
346626305c | |||
fafbd500e1 | |||
2db2e8cfc4 | |||
854479180f | |||
902ba81e02 | |||
1ac17abec0 | |||
714ea54121 | |||
aa992684ba | |||
0c58de86b7 | |||
7ecac019a9 |
@ -660,6 +660,8 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
$this->server->broadcastMessage($ev->getJoinMessage());
|
||||
}
|
||||
|
||||
$this->noDamageTicks = 60;
|
||||
|
||||
$this->spawnToAll();
|
||||
|
||||
if($this->server->getUpdater()->hasUpdate() and $this->hasPermission(Server::BROADCAST_CHANNEL_ADMINISTRATIVE)){
|
||||
@ -1101,17 +1103,25 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
|
||||
$diff = $diffX ** 2 + $diffY ** 2 + $diffZ ** 2;
|
||||
|
||||
if(!$revert and !$this->isSleeping() and $this->isSurvival()){
|
||||
if($diff > 0.0625){
|
||||
$revert = true;
|
||||
//$this->server->getLogger()->warning($this->getName()." moved wrongly!");
|
||||
}elseif($diff > 0){
|
||||
$this->x = $this->newPosition->x;
|
||||
$this->y = $this->newPosition->y;
|
||||
$this->z = $this->newPosition->z;
|
||||
$radius = $this->width / 2;
|
||||
$this->boundingBox->setBounds($this->x - $radius, $this->y + $this->ySize, $this->z - $radius, $this->x + $radius, $this->y + $this->height + $this->ySize, $this->z + $radius);
|
||||
if($this->isSurvival()){
|
||||
if(!$revert and !$this->isSleeping()){
|
||||
if($diff > 0.0625){
|
||||
$revert = true;
|
||||
$this->server->getLogger()->warning($this->getName()." moved wrongly!");
|
||||
}elseif($diff > 0){
|
||||
$this->x = $this->newPosition->x;
|
||||
$this->y = $this->newPosition->y;
|
||||
$this->z = $this->newPosition->z;
|
||||
$radius = $this->width / 2;
|
||||
$this->boundingBox->setBounds($this->x - $radius, $this->y + $this->ySize, $this->z - $radius, $this->x + $radius, $this->y + $this->height + $this->ySize, $this->z + $radius);
|
||||
}
|
||||
}
|
||||
}elseif($diff > 0){
|
||||
$this->x = $this->newPosition->x;
|
||||
$this->y = $this->newPosition->y;
|
||||
$this->z = $this->newPosition->z;
|
||||
$radius = $this->width / 2;
|
||||
$this->boundingBox->setBounds($this->x - $radius, $this->y + $this->ySize, $this->z - $radius, $this->x + $radius, $this->y + $this->height + $this->ySize, $this->z + $radius);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2001,6 +2011,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
$this->fireTicks = 0;
|
||||
$this->airTicks = 300;
|
||||
$this->deadTicks = 0;
|
||||
$this->noDamageTicks = 60;
|
||||
|
||||
$this->setHealth(20);
|
||||
$this->dead = false;
|
||||
|
@ -70,8 +70,8 @@ namespace pocketmine {
|
||||
use pocketmine\utils\Utils;
|
||||
use pocketmine\wizard\Installer;
|
||||
|
||||
const VERSION = "Alpha_1.4dev";
|
||||
const API_VERSION = "1.9.0";
|
||||
const VERSION = "1.4";
|
||||
const API_VERSION = "1.10.0";
|
||||
const CODENAME = "絶好(Zekkou)ケーキ(Cake)";
|
||||
const MINECRAFT_VERSION = "v0.10.4 alpha";
|
||||
|
||||
|
@ -300,7 +300,7 @@ class Server{
|
||||
* @return int
|
||||
*/
|
||||
public function getViewDistance(){
|
||||
return max(56, $this->getProperty("chunk-sending.max-chunks", 96));
|
||||
return max(56, $this->getProperty("chunk-sending.max-chunks", 256));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -622,6 +622,16 @@ class Server{
|
||||
$this->mainInterface->putRaw($address, $port, $payload);
|
||||
}
|
||||
|
||||
/**
|
||||
* Blocks an IP address from the main interface. Setting timeout to -1 will block it forever
|
||||
*
|
||||
* @param string $address
|
||||
* @param int $timeout
|
||||
*/
|
||||
public function blockAddress($address, $timeout = 300){
|
||||
$this->mainInterface->blockAddress($address, $timeout);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $address
|
||||
* @param int $port
|
||||
@ -633,9 +643,13 @@ class Server{
|
||||
$this->queryHandler->handle($address, $port, $payload);
|
||||
}
|
||||
}catch(\Exception $e){
|
||||
if($this->logger instanceof MainLogger){
|
||||
$this->logger->logException($e);
|
||||
if(\pocketmine\DEBUG > 1){
|
||||
if($this->logger instanceof MainLogger){
|
||||
$this->logger->logException($e);
|
||||
}
|
||||
}
|
||||
|
||||
$this->blockAddress($address, 600);
|
||||
}
|
||||
//TODO: add raw packet events
|
||||
}
|
||||
@ -1830,6 +1844,9 @@ class Server{
|
||||
$this->reloadWhitelist();
|
||||
$this->operators->reload();
|
||||
|
||||
foreach($this->getIPBans()->getEntries() as $entry){
|
||||
$this->blockAddress($entry->getName(), -1);
|
||||
}
|
||||
|
||||
$this->pluginManager->registerInterface(PharPluginLoader::class);
|
||||
$this->pluginManager->loadPlugins($this->pluginPath);
|
||||
@ -1907,6 +1924,9 @@ class Server{
|
||||
|
||||
}
|
||||
|
||||
foreach($this->getIPBans()->getEntries() as $entry){
|
||||
$this->blockAddress($entry->getName(), -1);
|
||||
}
|
||||
|
||||
if($this->getProperty("settings.send-usage", true) !== false){
|
||||
$this->scheduler->scheduleDelayedRepeatingTask(new CallbackTask([$this, "sendUsage"]), 6000, 6000);
|
||||
@ -1970,6 +1990,10 @@ class Server{
|
||||
|
||||
global $lastError;
|
||||
|
||||
if($trace === null){
|
||||
$trace = $e->getTrace();
|
||||
}
|
||||
|
||||
$errstr = $e->getMessage();
|
||||
$errfile = $e->getFile();
|
||||
$errno = $e->getCode();
|
||||
@ -1992,7 +2016,7 @@ class Server{
|
||||
"fullFile" => $e->getFile(),
|
||||
"file" => $errfile,
|
||||
"line" => $errline,
|
||||
"trace" => @getTrace($trace === null ? 3 : 0, $trace)
|
||||
"trace" => @getTrace(1, $trace)
|
||||
];
|
||||
|
||||
global $lastExceptionError, $lastError;
|
||||
@ -2077,7 +2101,7 @@ class Server{
|
||||
$level->doTick($currentTick);
|
||||
}catch(\Exception $e){
|
||||
$this->logger->critical("Could not tick level " . $level->getName() . ": " . $e->getMessage());
|
||||
if($this->logger instanceof MainLogger){
|
||||
if(\pocketmine\DEBUG > 1 and $this->logger instanceof MainLogger){
|
||||
$this->logger->logException($e);
|
||||
}
|
||||
}
|
||||
|
@ -24,10 +24,6 @@ namespace pocketmine\command;
|
||||
use pocketmine\Thread;
|
||||
|
||||
class CommandReader extends Thread{
|
||||
|
||||
public $stream;
|
||||
/** @var resource */
|
||||
private $fp;
|
||||
private $readline;
|
||||
|
||||
/** @var \Threaded */
|
||||
@ -35,17 +31,15 @@ class CommandReader extends Thread{
|
||||
|
||||
/**
|
||||
* @param \Threaded $threaded
|
||||
* @param string $stream
|
||||
*/
|
||||
public function __construct(\Threaded $threaded, $stream = "php://stdin"){
|
||||
$this->stream = $stream;
|
||||
public function __construct(\Threaded $threaded){
|
||||
$this->buffer = $threaded;
|
||||
$this->start();
|
||||
}
|
||||
|
||||
private function readLine(){
|
||||
if(!$this->readline){
|
||||
$line = trim(fgets($this->fp));
|
||||
$line = trim(fgets(fopen("php://stdin", "r")));
|
||||
}else{
|
||||
$line = trim(readline("> "));
|
||||
if($line != ""){
|
||||
@ -73,12 +67,10 @@ class CommandReader extends Thread{
|
||||
|
||||
public function run(){
|
||||
$opts = getopt("", ["disable-readline"]);
|
||||
if(extension_loaded("readline") and $this->stream === "php://stdin" and !isset($opts["disable-readline"])){
|
||||
if(extension_loaded("readline") and !isset($opts["disable-readline"])){
|
||||
$this->readline = true;
|
||||
}else{
|
||||
$this->readline = false;
|
||||
$this->fp = fopen($this->stream, "r");
|
||||
stream_set_blocking($this->fp, 1); //Non-blocking STDIN won't work on Windows
|
||||
}
|
||||
|
||||
$lastLine = microtime(true);
|
||||
|
@ -75,6 +75,8 @@ class BanIpCommand extends VanillaCommand{
|
||||
}
|
||||
}
|
||||
|
||||
$sender->getServer()->blockAddress($ip, -1);
|
||||
|
||||
Command::broadcastCommandMessage($sender, "Banned IP Address " . $ip);
|
||||
}
|
||||
}
|
@ -64,6 +64,7 @@ class HelpCommand extends VanillaCommand{
|
||||
}
|
||||
|
||||
if($command === ""){
|
||||
/** @var Command[][] $commands */
|
||||
$commands = [];
|
||||
foreach($sender->getServer()->getCommandMap()->getCommands() as $command){
|
||||
if($command->testPermissionSilent($sender)){
|
||||
|
@ -931,18 +931,13 @@ abstract class Entity extends Location implements Metadatable{
|
||||
|
||||
$this->boundingBox->setBB($axisalignedbb);
|
||||
|
||||
$list = $this->level->getCollisionCubes($this, $this->boundingBox->addCoord($movX, $dy, $movZ), false);
|
||||
$list = $this->level->getCollisionCubes($this, $this->boundingBox->addCoord($dx, $dy, $dz), false);
|
||||
|
||||
foreach($list as $bb){
|
||||
$dy = $bb->calculateYOffset($this->boundingBox, $dy);
|
||||
}
|
||||
|
||||
$this->boundingBox->offset(0, $dy, 0);
|
||||
if($movY != $dy){
|
||||
$dx = 0;
|
||||
$dy = 0;
|
||||
$dz = 0;
|
||||
}
|
||||
|
||||
foreach($list as $bb){
|
||||
$dx = $bb->calculateXOffset($this->boundingBox, $dx);
|
||||
@ -966,7 +961,7 @@ abstract class Entity extends Location implements Metadatable{
|
||||
$dz = 0;
|
||||
}
|
||||
|
||||
if($movY != $dy){
|
||||
if($dy == 0){
|
||||
$dx = 0;
|
||||
$dy = 0;
|
||||
$dz = 0;
|
||||
@ -1009,7 +1004,7 @@ abstract class Entity extends Location implements Metadatable{
|
||||
if($this instanceof Player){
|
||||
if(!$this->onGround or $movY != 0){
|
||||
$bb = clone $this->boundingBox;
|
||||
$bb->maxY = $bb->minY + 1;
|
||||
$bb->minY -= 1;
|
||||
if(count($this->level->getCollisionBlocks($bb->expand(0.01, 0.01, 0.01))) > 0){
|
||||
$this->onGround = true;
|
||||
}else{
|
||||
|
@ -72,7 +72,7 @@ class CraftingManager{
|
||||
|
||||
$this->registerRecipe((new BigShapelessRecipe(Item::get(Item::BED, 0, 1)))->addIngredient(Item::get(Item::WOOL, null, 3))->addIngredient(Item::get(Item::WOODEN_PLANK, null, 3)));
|
||||
$this->registerRecipe((new BigShapelessRecipe(Item::get(Item::CHEST, 0, 1)))->addIngredient(Item::get(Item::WOODEN_PLANK, null, 8)));
|
||||
$this->registerRecipe((new BigShapelessRecipe(Item::get(Item::FENCE, 0, 3)))->addIngredient(Item::get(Item::STICK, 0, 4))->addIngredient(Item::get(Item::WOODEN_PLANK, Planks::OAK, 2)));
|
||||
$this->registerRecipe((new BigShapelessRecipe(Item::get(Item::FENCE, 0, 3)))->addIngredient(Item::get(Item::STICK, 0, 2))->addIngredient(Item::get(Item::WOODEN_PLANK, Planks::OAK, 4)));
|
||||
$this->registerRecipe((new BigShapelessRecipe(Item::get(Item::FENCE_SPRUCE, 0, 3)))->addIngredient(Item::get(Item::STICK, 0, 2))->addIngredient(Item::get(Item::WOODEN_PLANK, Planks::SPRUCE, 4)));
|
||||
$this->registerRecipe((new BigShapelessRecipe(Item::get(Item::FENCE_BIRCH, 0, 3)))->addIngredient(Item::get(Item::STICK, 0, 2))->addIngredient(Item::get(Item::WOODEN_PLANK, Planks::BIRCH, 4)));
|
||||
$this->registerRecipe((new BigShapelessRecipe(Item::get(Item::FENCE_JUNGLE, 0, 3)))->addIngredient(Item::get(Item::STICK, 0, 2))->addIngredient(Item::get(Item::WOODEN_PLANK, Planks::JUNGLE, 4)));
|
||||
|
@ -294,8 +294,8 @@ class Level implements ChunkManager, Metadatable{
|
||||
$this->updateQueue->setExtractFlags(\SplPriorityQueue::EXTR_BOTH);
|
||||
$this->time = (int) $this->provider->getTime();
|
||||
|
||||
$this->chunkTickRadius = min($this->server->getViewDistance(), max(1, (int) $this->server->getProperty("chunk-ticking.tick-radius", 3)));
|
||||
$this->chunksPerTick = (int) $this->server->getProperty("chunk-ticking.per-tick", 80);
|
||||
$this->chunkTickRadius = min($this->server->getViewDistance(), max(1, (int) $this->server->getProperty("chunk-ticking.tick-radius", 4)));
|
||||
$this->chunksPerTick = (int) $this->server->getProperty("chunk-ticking.per-tick", 260);
|
||||
$this->chunkTickList = [];
|
||||
$this->clearChunksOnTick = (bool) $this->server->getProperty("chunk-ticking.clear-tick-list", false);
|
||||
|
||||
@ -589,6 +589,7 @@ class Level implements ChunkManager, Metadatable{
|
||||
|
||||
private function tickChunks(){
|
||||
if($this->chunksPerTick <= 0 or count($this->players) === 0){
|
||||
$this->chunkTickList = [];
|
||||
return;
|
||||
}
|
||||
|
||||
@ -966,7 +967,7 @@ class Level implements ChunkManager, Metadatable{
|
||||
$fullState = 0;
|
||||
}
|
||||
|
||||
$block = clone $this->blockStates[$fullState];
|
||||
$block = clone $this->blockStates[$fullState & 0xfff];
|
||||
|
||||
$block->x = $pos->x;
|
||||
$block->y = $pos->y;
|
||||
@ -1208,7 +1209,7 @@ class Level implements ChunkManager, Metadatable{
|
||||
if($player instanceof Player){
|
||||
$ev = new BlockBreakEvent($player, $target, $item, ($player->getGamemode() & 0x01) === 1 ? true : false);
|
||||
|
||||
if($item instanceof Item and !$target->isBreakable($item)){
|
||||
if($player->isSurvival() and $item instanceof Item and !$target->isBreakable($item)){
|
||||
$ev->setCancelled();
|
||||
}
|
||||
|
||||
@ -1754,7 +1755,9 @@ class Level implements ChunkManager, Metadatable{
|
||||
public function generateChunkCallback($x, $z, FullChunk $chunk){
|
||||
$oldChunk = $this->getChunk($x, $z, false);
|
||||
unset($this->chunkGenerationQueue[Level::chunkHash($x, $z)]);
|
||||
$chunk->setProvider($this->provider);
|
||||
$this->setChunk($x, $z, $chunk);
|
||||
$chunk = $this->getChunk($x, $z, false);
|
||||
if($chunk !== null and ($oldChunk === null or $oldChunk->isPopulated() === false) and $chunk->isPopulated()){
|
||||
$this->server->getPluginManager()->callEvent(new ChunkPopulateEvent($chunk));
|
||||
}
|
||||
|
@ -88,6 +88,12 @@ class RegionLoader extends \pocketmine\level\format\mcregion\RegionLoader{
|
||||
$compression = ord(fgetc($this->filePointer));
|
||||
}
|
||||
|
||||
if($length >= self::MAX_SECTOR_LENGTH){
|
||||
MainLogger::getLogger()->error("Corrupted chunk header detected");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if($length > ($this->locationTable[$index][1] << 12)){ //Invalid chunk, bigger than defined number of sectors
|
||||
MainLogger::getLogger()->error("Corrupted chunk detected");
|
||||
$this->locationTable[$index][1] = $length >> 12;
|
||||
|
@ -38,6 +38,7 @@ class RegionLoader{
|
||||
const VERSION = 1;
|
||||
const COMPRESSION_GZIP = 1;
|
||||
const COMPRESSION_ZLIB = 2;
|
||||
const MAX_SECTOR_LENGTH = 32 << 12; //32 sectors
|
||||
public static $COMPRESSION_LEVEL = 7;
|
||||
|
||||
protected $x;
|
||||
@ -109,6 +110,12 @@ class RegionLoader{
|
||||
$compression = ord(fgetc($this->filePointer));
|
||||
}
|
||||
|
||||
if($length >= self::MAX_SECTOR_LENGTH){
|
||||
MainLogger::getLogger()->error("Corrupted chunk header detected");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if($length > ($this->locationTable[$index][1] << 12)){ //Invalid chunk, bigger than defined number of sectors
|
||||
MainLogger::getLogger()->error("Corrupted bigger chunk detected");
|
||||
$this->locationTable[$index][1] = $length >> 12;
|
||||
|
@ -163,7 +163,7 @@ class GenerationChunkManager implements ChunkManager{
|
||||
try{
|
||||
$chunk = $this->getChunk($chunkX, $chunkZ);
|
||||
$chunk->setGenerated(true);
|
||||
$this->changes["$chunkX:$chunkZ"] = $chunk;
|
||||
$this->changes[Level::chunkHash($chunkX, $chunkZ)] = $chunk;
|
||||
}catch(\Exception $e){
|
||||
}
|
||||
}
|
||||
@ -172,7 +172,7 @@ class GenerationChunkManager implements ChunkManager{
|
||||
try{
|
||||
$chunk = $this->getChunk($chunkX, $chunkZ);
|
||||
$chunk->setPopulated(true);
|
||||
$this->changes["$chunkX:$chunkZ"] = $chunk;
|
||||
$this->changes[Level::chunkHash($chunkX, $chunkZ)] = $chunk;
|
||||
}catch(\Exception $e){
|
||||
}
|
||||
}
|
||||
|
@ -49,9 +49,9 @@ class Normal extends Generator{
|
||||
private $random;
|
||||
private $worldHeight = 65;
|
||||
private $waterHeight = 63;
|
||||
/** @var Simplex */
|
||||
private $noiseHills;
|
||||
private $noisePatches;
|
||||
private $noisePatchesSmall;
|
||||
/** @var Simplex */
|
||||
private $noiseBase;
|
||||
|
||||
public function __construct(array $options = []){
|
||||
@ -70,10 +70,8 @@ class Normal extends Generator{
|
||||
$this->level = $level;
|
||||
$this->random = $random;
|
||||
$this->random->setSeed($this->level->getSeed());
|
||||
$this->noiseHills = new Simplex($this->random, 3, 0.11, 12);
|
||||
$this->noisePatches = new Simplex($this->random, 2, 0.03, 16);
|
||||
$this->noisePatchesSmall = new Simplex($this->random, 2, 0.5, 4);
|
||||
$this->noiseBase = new Simplex($this->random, 16, 0.7, 16);
|
||||
$this->noiseHills = new Simplex($this->random, 3, 0.1, 12);
|
||||
$this->noiseBase = new Simplex($this->random, 16, 0.6, 16);
|
||||
|
||||
|
||||
$ores = new Ore();
|
||||
@ -90,8 +88,8 @@ class Normal extends Generator{
|
||||
$this->populators[] = $ores;
|
||||
|
||||
$trees = new Tree();
|
||||
$trees->setBaseAmount(3);
|
||||
$trees->setRandomAmount(0);
|
||||
$trees->setBaseAmount(1);
|
||||
$trees->setRandomAmount(1);
|
||||
$this->populators[] = $trees;
|
||||
|
||||
$tallGrass = new TallGrass();
|
||||
@ -103,15 +101,11 @@ class Normal extends Generator{
|
||||
public function generateChunk($chunkX, $chunkZ){
|
||||
$this->random->setSeed(0xdeadbeef ^ ($chunkX << 8) ^ $chunkZ ^ $this->level->getSeed());
|
||||
$hills = [];
|
||||
$patches = [];
|
||||
$patchesSmall = [];
|
||||
$base = [];
|
||||
for($z = 0; $z < 16; ++$z){
|
||||
for($x = 0; $x < 16; ++$x){
|
||||
$i = ($z << 4) + $x;
|
||||
$hills[$i] = $this->noiseHills->noise2D($x + ($chunkX << 4), $z + ($chunkZ << 4), true);
|
||||
$patches[$i] = $this->noisePatches->noise2D($x + ($chunkX << 4), $z + ($chunkZ << 4), true);
|
||||
$patchesSmall[$i] = $this->noisePatchesSmall->noise2D($x + ($chunkX << 4), $z + ($chunkZ << 4), true);
|
||||
$base[$i] = $this->noiseBase->noise2D($x + ($chunkX << 4), $z + ($chunkZ << 4), true);
|
||||
|
||||
if($base[$i] < 0){
|
||||
@ -122,55 +116,33 @@ class Normal extends Generator{
|
||||
|
||||
$chunk = $this->level->getChunk($chunkX, $chunkZ);
|
||||
|
||||
for($chunkY = 0; $chunkY < 8; ++$chunkY){
|
||||
$startY = $chunkY << 4;
|
||||
$endY = $startY + 16;
|
||||
for($z = 0; $z < 16; ++$z){
|
||||
for($x = 0; $x < 16; ++$x){
|
||||
$i = ($z << 4) + $x;
|
||||
$height = $this->worldHeight + $hills[$i] * 14 + $base[$i] * 7;
|
||||
$height = (int) $height;
|
||||
for($z = 0; $z < 16; ++$z){
|
||||
for($x = 0; $x < 16; ++$x){
|
||||
$i = ($z << 4) + $x;
|
||||
$height = $this->worldHeight + $hills[$i] * 14 + $base[$i] * 7;
|
||||
$height = (int) $height;
|
||||
|
||||
for($y = $startY; $y < $endY; ++$y){
|
||||
$diff = $height - $y;
|
||||
if($y <= 4 and ($y === 0 or $this->random->nextFloat() < 0.75)){
|
||||
$chunk->setBlockId($x, $y, $z, Block::BEDROCK);
|
||||
}elseif($diff > 2){
|
||||
$chunk->setBlockId($x, $y, $z, Block::STONE);
|
||||
}elseif($diff > 0){
|
||||
if($patches[$i] > 0.7){
|
||||
$chunk->setBlockId($x, $y, $z, Block::STONE);
|
||||
}elseif($patches[$i] < -0.8){
|
||||
$chunk->setBlockId($x, $y, $z, Block::GRAVEL);
|
||||
}else{
|
||||
$chunk->setBlockId($x, $y, $z, Block::DIRT);
|
||||
}
|
||||
}elseif($y <= $this->waterHeight){
|
||||
if(($this->waterHeight - $y) <= 1 and $diff === 0){
|
||||
$chunk->setBlockId($x, $y, $z, Block::SAND);
|
||||
}elseif($diff === 0){
|
||||
if($patchesSmall[$i] > 0.3){
|
||||
$chunk->setBlockId($x, $y, $z, Block::GRAVEL);
|
||||
}elseif($patchesSmall[$i] < -0.45){
|
||||
$chunk->setBlockId($x, $y, $z, Block::SAND);
|
||||
}else{
|
||||
$chunk->setBlockId($x, $y, $z, Block::DIRT);
|
||||
}
|
||||
}else{
|
||||
$chunk->setBlockId($x, $y, $z, Block::STILL_WATER);
|
||||
}
|
||||
for($y = 0; $y < 128; ++$y){
|
||||
$diff = $height - $y;
|
||||
if($y <= 4 and ($y === 0 or $this->random->nextFloat() < 0.75)){
|
||||
$chunk->setBlockId($x, $y, $z, Block::BEDROCK);
|
||||
}elseif($diff > 2){
|
||||
$chunk->setBlockId($x, $y, $z, Block::STONE);
|
||||
}elseif($diff > 0){
|
||||
$chunk->setBlockId($x, $y, $z, Block::DIRT);
|
||||
}elseif($y <= $this->waterHeight){
|
||||
if(($this->waterHeight - $y) <= 1 and $diff === 0){
|
||||
$chunk->setBlockId($x, $y, $z, Block::SAND);
|
||||
}elseif($diff === 0){
|
||||
if($patches[$i] > 0.7){
|
||||
$chunk->setBlockId($x, $y, $z, Block::STONE);
|
||||
}elseif($patches[$i] < -0.8){
|
||||
$chunk->setBlockId($x, $y, $z, Block::GRAVEL);
|
||||
}else{
|
||||
$chunk->setBlockId($x, $y, $z, Block::GRASS);
|
||||
}
|
||||
$chunk->setBlockId($x, $y, $z, Block::DIRT);
|
||||
}else{
|
||||
$chunk->setBlockId($x, $y, $z, Block::STILL_WATER);
|
||||
}
|
||||
}elseif($diff === 0){
|
||||
$chunk->setBlockId($x, $y, $z, Block::GRASS);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -271,34 +271,27 @@ class Simplex extends Perlin{
|
||||
$gi1 = $this->perm[$ii + $i1 + $this->perm[$jj + $j1]] % 12;
|
||||
$gi2 = $this->perm[$ii + 1 + $this->perm[$jj + 1]] % 12;
|
||||
|
||||
$n = 0;
|
||||
|
||||
// Calculate the contribution from the three corners
|
||||
$t0 = 0.5 - $x0 ** 2 - $y0 ** 2;
|
||||
if($t0 < 0){
|
||||
$n0 = 0.0;
|
||||
}else{
|
||||
$t0 **= 2;
|
||||
$n0 = $t0 ** 2 * self::dot2D(self::$grad3[$gi0], $x0, $y0); // (x,y) of grad3 used for 2D gradient
|
||||
$t = 0.5 - $x0 ** 2 - $y0 ** 2;
|
||||
if($t > 0){
|
||||
$n += $t ** 4 * self::dot2D(self::$grad3[$gi0], $x0, $y0); // (x,y) of grad3 used for 2D gradient
|
||||
}
|
||||
|
||||
$t1 = 0.5 - $x1 ** 2 - $y1 ** 2;
|
||||
if($t1 < 0){
|
||||
$n1 = 0.0;
|
||||
}else{
|
||||
$t1 **= 2;
|
||||
$n1 = $t1 ** 2 * self::dot2D(self::$grad3[$gi1], $x1, $y1);
|
||||
$t = 0.5 - $x1 ** 2 - $y1 ** 2;
|
||||
if($t > 0){
|
||||
$n += $t ** 4 * self::dot2D(self::$grad3[$gi1], $x1, $y1);
|
||||
}
|
||||
|
||||
$t2 = 0.5 - $x2 ** 2 - $y2 ** 2;
|
||||
if($t2 < 0){
|
||||
$n2 = 0.0;
|
||||
}else{
|
||||
$t2 **= 2;
|
||||
$n2 = $t2 ** 2 * self::dot2D(self::$grad3[$gi2], $x2, $y2);
|
||||
$t = 0.5 - $x2 ** 2 - $y2 ** 2;
|
||||
if($t > 0){
|
||||
$n += $t ** 4 * self::dot2D(self::$grad3[$gi2], $x2, $y2);
|
||||
}
|
||||
|
||||
// Add contributions from each corner to get the noise value.
|
||||
// The result is scaled to return values in the interval [-1,1].
|
||||
return 70.0 * ($n0 + $n1 + $n2);
|
||||
return 70.0 * $n;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -188,10 +188,16 @@ class RakLibInterface implements ServerInstance, SourceInterface{
|
||||
$logger->logException($e);
|
||||
}
|
||||
}
|
||||
|
||||
$this->interface->blockAddress($this->players[$identifier]->getAddress(), 5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function blockAddress($address, $timeout = 300){
|
||||
$this->interface->blockAddress($address, $timeout);
|
||||
}
|
||||
|
||||
public function handleRaw($address, $port, $payload){
|
||||
$this->server->handlePacket($address, $port, $payload);
|
||||
}
|
||||
|
@ -34,15 +34,14 @@ chunk-sending:
|
||||
per-tick: 4
|
||||
#Compression level used when sending chunks. Higher = more CPU, less bandwidth usage
|
||||
compression-level: 8
|
||||
#Amount of chunks loaded around a player by the server, min. 56 as MC: PE 0.9.5
|
||||
#Increasing this more than 96 (as of MC: PE 0.9.5) can cause issues with the client ignoring chunks
|
||||
max-chunks: 96
|
||||
#Amount of chunks sent around each player
|
||||
max-chunks: 256
|
||||
|
||||
chunk-ticking:
|
||||
#Max amount of chunks processed each tick
|
||||
per-tick: 80
|
||||
per-tick: 260
|
||||
#Radius of chunks around a player to tick
|
||||
tick-radius: 2
|
||||
tick-radius: 4
|
||||
light-updates: false
|
||||
clear-tick-list: false
|
||||
|
||||
|
@ -103,6 +103,9 @@ class MainLogger extends \AttachableThreadedLogger{
|
||||
}
|
||||
|
||||
public function logException(\Exception $e, $trace = null){
|
||||
if($trace === null){
|
||||
$trace = $e->getTrace();
|
||||
}
|
||||
$errstr = $e->getMessage();
|
||||
$errfile = $e->getFile();
|
||||
$errno = $e->getCode();
|
||||
@ -137,8 +140,7 @@ class MainLogger extends \AttachableThreadedLogger{
|
||||
}
|
||||
$errfile = \pocketmine\cleanPath($errfile);
|
||||
$this->log($type, get_class($e) . ": \"$errstr\" ($errno) in \"$errfile\" at line $errline");
|
||||
|
||||
foreach(($trace = @\pocketmine\getTrace($trace === null ? 4 : 0, $trace)) as $i => $line){
|
||||
foreach(@\pocketmine\getTrace(1, $trace) as $i => $line){
|
||||
$this->debug($line);
|
||||
}
|
||||
}
|
||||
|
@ -26,33 +26,21 @@ namespace pocketmine\utils;
|
||||
* Manages PocketMine-MP version strings, and compares them
|
||||
*/
|
||||
class VersionString{
|
||||
public static $stageOrder = [
|
||||
"alpha" => 0,
|
||||
"a" => 0,
|
||||
"beta" => 1,
|
||||
"b" => 1,
|
||||
"final" => 2,
|
||||
"f" => 2,
|
||||
];
|
||||
private $stage;
|
||||
private $major;
|
||||
private $build;
|
||||
private $minor;
|
||||
private $development = false;
|
||||
private $generation;
|
||||
|
||||
public function __construct($version = \pocketmine\VERSION){
|
||||
if(is_int($version)){
|
||||
$this->minor = $version & 0x1F;
|
||||
$this->major = ($version >> 5) & 0x0F;
|
||||
$this->generation = ($version >> 9) & 0x0F;
|
||||
$this->stage = array_search(($version >> 13) & 0x0F, VersionString::$stageOrder, true);
|
||||
}else{
|
||||
$version = preg_split("/([A-Za-z]*)[ _\\-]([0-9]*)\\.([0-9]*)\\.{0,1}([0-9]*)(dev|)(-[\\0-9]{1,}|)/", $version, -1, PREG_SPLIT_DELIM_CAPTURE);
|
||||
$this->stage = strtolower($version[1]); //0-15
|
||||
$this->generation = (int) $version[2]; //0-15
|
||||
$this->major = (int) $version[3]; //0-15
|
||||
$this->minor = (int) $version[4]; //0-31
|
||||
$version = preg_split("/([A-Za-z]*)[ _\\-]?([0-9]*)\\.([0-9]*)\\.{0,1}([0-9]*)(dev|)(-[\\0-9]{1,}|)/", $version, -1, PREG_SPLIT_DELIM_CAPTURE);
|
||||
$this->generation = isset($version[2]) ? (int) $version[2] : 0; //0-15
|
||||
$this->major = isset($version[3]) ? (int) $version[3] : 0; //0-15
|
||||
$this->minor = isset($version[4]) ? (int) $version[4] : 0; //0-31
|
||||
$this->development = $version[5] === "dev" ? true : false;
|
||||
if($version[6] !== ""){
|
||||
$this->build = intval(substr($version[6], 1));
|
||||
@ -63,11 +51,14 @@ class VersionString{
|
||||
}
|
||||
|
||||
public function getNumber(){
|
||||
return (int) (VersionString::$stageOrder[$this->stage] << 13) + ($this->generation << 9) + ($this->major << 5) + $this->minor;
|
||||
return (int) (($this->generation << 9) + ($this->major << 5) + $this->minor);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
public function getStage(){
|
||||
return $this->stage;
|
||||
return "final";
|
||||
}
|
||||
|
||||
public function getGeneration(){
|
||||
@ -95,7 +86,7 @@ class VersionString{
|
||||
}
|
||||
|
||||
public function get($build = false){
|
||||
return ucfirst($this->stage) . "_" . $this->getRelease() . ($this->development === true ? "dev" : "") . (($this->build > 0 and $build === true) ? "-" . $this->build : "");
|
||||
return $this->getRelease() . ($this->development === true ? "dev" : "") . (($this->build > 0 and $build === true) ? "-" . $this->build : "");
|
||||
}
|
||||
|
||||
public function __toString(){
|
||||
|
Submodule src/raklib updated: 2016c58c53...658529ec44
Reference in New Issue
Block a user