mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-23 00:55:57 +00:00
Merge branch 'master' into new-version-format
This commit is contained in:
commit
fe32e6f5d0
@ -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)){
|
||||
@ -2001,6 +2003,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;
|
||||
|
@ -71,7 +71,7 @@ namespace pocketmine {
|
||||
use pocketmine\wizard\Installer;
|
||||
|
||||
const VERSION = "1.4dev";
|
||||
const API_VERSION = "1.9.0";
|
||||
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);
|
||||
|
@ -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)){
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
@ -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,6 +1755,7 @@ 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);
|
||||
if($chunk !== null and ($oldChunk === null or $oldChunk->isPopulated() === false) and $chunk->isPopulated()){
|
||||
$this->server->getPluginManager()->callEvent(new ChunkPopulateEvent($chunk));
|
||||
|
@ -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
|
||||
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 2016c58c531fec30ec095e9215d771a5ccabe4ce
|
||||
Subproject commit 658529ec44f30ce210f5cf42d2280e51332fe3d0
|
Loading…
x
Reference in New Issue
Block a user