mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-17 11:18:52 +00:00
Merge remote-tracking branch 'origin/master' into Entities
This commit is contained in:
commit
b36d754e5b
@ -32,7 +32,7 @@ class BanAPI{
|
||||
private $ops;
|
||||
/** @var Config */
|
||||
private $bannedIPs;
|
||||
private $cmdWL = array();//Command WhiteList
|
||||
private $cmdWhitelist = array();//Command WhiteList
|
||||
function __construct(){
|
||||
$this->server = ServerAPI::request();
|
||||
}
|
||||
@ -104,7 +104,6 @@ class BanAPI{
|
||||
}
|
||||
}
|
||||
return;
|
||||
break;
|
||||
case "console.command"://Checks if a command is allowed with the current user permissions.
|
||||
if(isset($this->cmdWhitelist[$data["cmd"]])){
|
||||
return;
|
||||
@ -118,7 +117,6 @@ class BanAPI{
|
||||
return;
|
||||
}
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -152,7 +150,7 @@ class BanAPI{
|
||||
$player = $this->server->api->player->get($user);
|
||||
if(!($player instanceof Player)){
|
||||
$this->ops->set($user);
|
||||
$this->ops->save($user);
|
||||
$this->ops->save();
|
||||
$output .= $user." is now op\n";
|
||||
break;
|
||||
}
|
||||
|
@ -341,7 +341,7 @@ class BlockAPI{
|
||||
}
|
||||
}
|
||||
|
||||
if((!$target->isBreakable($item, $player) and $this->server->api->dhandle("player.block.break.invalid", array("player" => $player, "target" => $target, "item" => $item)) !== true) or ($player->gamemode & 0x02) === 0x02 or (($player->lastBreak - $player->getLag() / 1000) + $target->getBreakTime($item, $player) - 0.1) >= microtime(true)){
|
||||
if((!$target->isBreakable($item, $player) and $this->server->api->dhandle("player.block.break.invalid", array("player" => $player, "target" => $target, "item" => $item)) !== true) or ($player->gamemode & 0x02) === 0x02 or (($player->lastBreak - $player->getLag() / 1000) + $target->getBreakTime($item, $player) - 0.2) >= microtime(true)){
|
||||
if($this->server->api->dhandle("player.block.break.bypass", array("player" => $player, "target" => $target, "item" => $item)) !== true){
|
||||
return $this->cancelAction($target, $player, false);
|
||||
}
|
||||
@ -516,13 +516,9 @@ class BlockAPI{
|
||||
|
||||
public function nextRandomUpdate(Position $pos){
|
||||
if(!isset($this->scheduledUpdates[$pos->x.".".$pos->y.".".$pos->z.".".$pos->level->getName().".".BLOCK_UPDATE_RANDOM])){
|
||||
$X = (($pos->x >> 4) << 4);
|
||||
$Y = (($pos->y >> 4) << 4);
|
||||
$Z = (($pos->z >> 4) << 4);
|
||||
$time = microtime(true);
|
||||
$i = 0;
|
||||
$offset = 0;
|
||||
while(true){
|
||||
do{
|
||||
$t = $offset + Utils::getRandomUpdateTicks() * 0.05;
|
||||
$update = $this->server->query("SELECT COUNT(*) FROM blockUpdates WHERE level = '".$pos->level->getName()."' AND type = ".BLOCK_UPDATE_RANDOM." AND delay >= ".($time + $t - 1)." AND delay <= ".($time + $t + 1).";");
|
||||
if($update instanceof SQLite3Result){
|
||||
@ -534,7 +530,7 @@ class BlockAPI{
|
||||
break;
|
||||
}
|
||||
$offset += mt_rand(25, 75);
|
||||
}
|
||||
}while(true);
|
||||
$this->scheduleBlockUpdate($pos, $t / 0.05, BLOCK_UPDATE_RANDOM);
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,6 @@ class ConsoleAPI{
|
||||
$this->cmds = array();
|
||||
$this->alias = array();
|
||||
$this->server = ServerAPI::request();
|
||||
$this->last = microtime(true);
|
||||
}
|
||||
|
||||
public function init(){
|
||||
@ -250,7 +249,7 @@ class ConsoleAPI{
|
||||
if(($d1 = $this->server->api->dhandle("console.command.".$cmd, array("cmd" => $cmd, "parameters" => $params, "issuer" => $issuer, "alias" => $alias))) === false
|
||||
or ($d2 = $this->server->api->dhandle("console.command", array("cmd" => $cmd, "parameters" => $params, "issuer" => $issuer, "alias" => $alias))) === false){
|
||||
$output = "You don't have permissions to use this command.\n";
|
||||
}elseif($d1 !== true and $d2 !== true){
|
||||
}elseif($d1 !== true and (isset($d2) and $d2 !== true)){
|
||||
if(isset($this->cmds[$cmd]) and is_callable($this->cmds[$cmd])){
|
||||
$output = @call_user_func($this->cmds[$cmd], $cmd, $params, $issuer, $alias);
|
||||
}elseif($this->server->api->dhandle("console.command.unknown", array("cmd" => $cmd, "params" => $params, "issuer" => $issuer, "alias" => $alias)) !== false){
|
||||
@ -326,7 +325,7 @@ class ConsoleLoop extends Thread{
|
||||
}
|
||||
|
||||
if(!extension_loaded("readline")){
|
||||
@fclose($fp);
|
||||
@fclose($this->fp);
|
||||
}
|
||||
exit(0);
|
||||
}
|
||||
|
@ -198,7 +198,6 @@ class LevelAPI{
|
||||
$t = $this->server->api->tile->add($this->levels[$name], $tile["id"], $tile["x"], $tile["y"], $tile["z"], $tile);
|
||||
}
|
||||
|
||||
$timeu = microtime(true);
|
||||
foreach($blockUpdates->getAll() as $bupdate){
|
||||
$this->server->api->block->scheduleBlockUpdate(new Position((int) $bupdate["x"],(int) $bupdate["y"],(int) $bupdate["z"], $this->levels[$name]), (float) $bupdate["delay"], (int) $bupdate["type"]);
|
||||
}
|
||||
|
@ -111,7 +111,6 @@ class PlayerAPI{
|
||||
}
|
||||
$this->server->api->chat->broadcast($data["player"]->username . $message);
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -196,9 +195,6 @@ class PlayerAPI{
|
||||
"spectator" => VIEW,
|
||||
"v" => VIEW,
|
||||
);
|
||||
if($issuer instanceof Player){
|
||||
$player = $issuer;
|
||||
}
|
||||
if(isset($params[1])){
|
||||
if($this->server->api->player->get($params[1]) instanceof Player){
|
||||
$player = $this->server->api->player->get($params[1]);
|
||||
@ -210,7 +206,15 @@ class PlayerAPI{
|
||||
$output .= "Usage: /$cmd <mode> [player] or /$cmd [player] <mode>\n";
|
||||
break;
|
||||
}
|
||||
}elseif(isset($params[0])){
|
||||
if(!($this->server->api->player->get($params[0]) instanceof Player)){
|
||||
if($issuer instanceof Player){
|
||||
$setgm = $params[0];
|
||||
$player = $issuer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!($player instanceof Player) or !isset($gms[strtolower($setgm)])){
|
||||
$output .= "Usage: /$cmd <mode> [player] or /$cmd [player] <mode>\n";
|
||||
break;
|
||||
|
@ -196,19 +196,6 @@ class PluginAPI extends stdClass{
|
||||
return $path;
|
||||
}
|
||||
|
||||
private function fillDefaults($default, &$yaml){
|
||||
foreach($default as $k => $v){
|
||||
if(is_array($v)){
|
||||
if(!isset($yaml[$k]) or !is_array($yaml[$k])){
|
||||
$yaml[$k] = array();
|
||||
}
|
||||
$this->fillDefaults($v, $yaml[$k]);
|
||||
}elseif(!isset($yaml[$k])){
|
||||
$yaml[$k] = $v;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function readYAML($file){
|
||||
return yaml_parse(preg_replace("#^([ ]*)([a-zA-Z_]{1}[^\:]*)\:#m", "$1\"$2\":", file_get_contents($file)));
|
||||
}
|
||||
|
@ -43,8 +43,16 @@ class EntityOLD extends Position{
|
||||
public $attach;
|
||||
public $closed;
|
||||
public $player;
|
||||
public $status;
|
||||
public $fallY;
|
||||
public $health;
|
||||
public $fire;
|
||||
public $crouched;
|
||||
public $invincible;
|
||||
public $fallStart;
|
||||
public $stack;
|
||||
public $meta;
|
||||
private $position;
|
||||
private $tickCounter;
|
||||
private $speedMeasure = array(0, 0, 0, 0, 0, 0, 0);
|
||||
private $server;
|
||||
@ -164,7 +172,7 @@ class EntityOLD extends Position{
|
||||
}
|
||||
|
||||
public function getDrops(){
|
||||
if($this->class === ENTITY_PLAYER and ($this->player->gamemode & 0x01) === 0){
|
||||
if($this->class === ENTITY_PLAYER and $this->player instanceof Player and ($this->player->gamemode & 0x01) === 0){
|
||||
$inv = array();
|
||||
for($i = 0; $i < PLAYER_SURVIVAL_SLOTS; ++$i){
|
||||
$slot = $this->player->getSlot($i);
|
||||
@ -526,8 +534,8 @@ class EntityOLD extends Position{
|
||||
}
|
||||
}elseif($this->fallY !== false){ //Fall damage!
|
||||
if($y < $this->fallY){
|
||||
$d = $this->level->getBlock(new Vector3($x, $y + 1, $z));
|
||||
$d2 = $this->level->getBlock(new Vector3($x, $y + 2, $z));
|
||||
$d = $this->level->getBlock(new Vector3($this->x, $y + 1, $this->z));
|
||||
$d2 = $this->level->getBlock(new Vector3($this->x, $y + 2, $this->z));
|
||||
$dmg = ($this->fallY - $y) - 3;
|
||||
if($dmg > 0 and !($d instanceof LiquidBlock) and $d->getID() !== LADDER and $d->getID() !== COBWEB and !($d2 instanceof LiquidBlock) and $d2->getID() !== LADDER and $d2->getID() !== COBWEB){
|
||||
$this->harm($dmg, "fall");
|
||||
@ -562,10 +570,10 @@ class EntityOLD extends Position{
|
||||
if($this->isStatic === false and ($this->last[0] != $this->x or $this->last[1] != $this->y or $this->last[2] != $this->z or $this->last[3] != $this->yaw or $this->last[4] != $this->pitch)){
|
||||
if($this->class === ENTITY_PLAYER or ($this->last[5] + 8) < $now){
|
||||
if($this->server->api->handle("entity.move", $this) === false){
|
||||
if($this->class === ENTITY_PLAYER){
|
||||
if($this->class === ENTITY_PLAYER and $this->player instanceof Player){
|
||||
$this->player->teleport(new Vector3($this->last[0], $this->last[1], $this->last[2]), $this->last[3], $this->last[4]);
|
||||
}else{
|
||||
$this->setPosition($this->last[0], $this->last[1], $this->last[2], $this->last[3], $this->last[4]);
|
||||
$this->setPosition(new Vector3($this->last[0], $this->last[1], $this->last[2]), $this->last[3], $this->last[4]);
|
||||
}
|
||||
}else{
|
||||
$this->updateLast();
|
||||
@ -593,7 +601,7 @@ class EntityOLD extends Position{
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$this->updatePosition($this->x, $this->y, $this->z, $this->yaw, $this->pitch);
|
||||
$this->updatePosition();
|
||||
}
|
||||
}
|
||||
$this->lastUpdate = $now;
|
||||
@ -658,7 +666,7 @@ class EntityOLD extends Position{
|
||||
}
|
||||
switch($this->class){
|
||||
case ENTITY_PLAYER:
|
||||
if($this->player->connected !== true or $this->player->spawned === false){
|
||||
if(!($this->player instanceof Player) or $this->player->connected !== true or $this->player->spawned === false){
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -63,6 +63,7 @@ class Player{
|
||||
public $blocked = true;
|
||||
public $achievements = array();
|
||||
public $chunksLoaded = array();
|
||||
private $viewDistance;
|
||||
private $chunksOrder = array();
|
||||
private $lastMeasure = 0;
|
||||
private $bandwidthRaw = 0;
|
||||
@ -112,6 +113,7 @@ class Player{
|
||||
$this->armor = array();
|
||||
$this->gamemode = $this->server->gamemode;
|
||||
$this->level = $this->server->api->level->getDefault();
|
||||
$this->viewDistance = (int) $this->server->api->getProperty("view-distance");
|
||||
$this->slot = 0;
|
||||
$this->hotbar = array(0, -1, -1, -1, -1, -1, -1, -1, -1);
|
||||
$this->packetStats = array(0,0);
|
||||
@ -148,22 +150,35 @@ class Player{
|
||||
if(!($this->entity instanceof Entity) or $this->connected === false){
|
||||
return false;
|
||||
}
|
||||
$X = ($this->entity->x - 0.5) / 16;
|
||||
$Z = ($this->entity->z - 0.5) / 16;
|
||||
$v = new Vector2($X, $Z);
|
||||
$this->chunksOrder = array();
|
||||
for($x = 0; $x < 16; ++$x){
|
||||
for($z = 0; $z < 16; ++$z){
|
||||
$dist = $v->distance(new Vector2($x, $z));
|
||||
for($y = 0; $y < 8; ++$y){
|
||||
$d = $x.":".$y.":".$z;
|
||||
if(!isset($this->chunksLoaded[$d])){
|
||||
$this->chunksOrder[$d] = $dist;
|
||||
|
||||
$newOrder = array();
|
||||
$lastLoaded = $this->chunksLoaded;
|
||||
$centerX = intval(($this->entity->x - 0.5) / 16);
|
||||
$centerZ = intval(($this->entity->z - 0.5) / 16);
|
||||
$startX = $centerX - $this->viewDistance;
|
||||
$startZ = $centerZ - $this->viewDistance;
|
||||
$finalX = $centerX + $this->viewDistance;
|
||||
$finalZ = $centerZ + $this->viewDistance;
|
||||
for($X = $startX; $X <= $finalX; ++$X){
|
||||
for($Z = $startZ; $Z <= $finalZ; ++$Z){
|
||||
$distance = abs($X - $centerX) + abs($Z - $centerZ);
|
||||
for($Y = 0; $Y < 8; ++$Y){
|
||||
$index = "$X:$Y:$Z";
|
||||
if(!isset($lastLoaded[$index])){
|
||||
$newOrder[$index] = $distance;
|
||||
}else{
|
||||
unset($lastLoaded[$index]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
asort($this->chunksOrder);
|
||||
asort($newOrder);
|
||||
$this->chunksOrder = $newOrder;
|
||||
foreach($lastLoaded as $index => $distance){
|
||||
$id = explode(":", $index);
|
||||
$this->level->freeChunk($id[0], $id[2], $this);
|
||||
unset($this->chunksLoaded[$index]);
|
||||
}
|
||||
}
|
||||
|
||||
public function getNextChunk(){
|
||||
@ -195,8 +210,8 @@ class Player{
|
||||
|
||||
$c = key($this->chunksOrder);
|
||||
$d = @$this->chunksOrder[$c];
|
||||
if($c === null or $d > $this->server->api->getProperty("view-distance")){
|
||||
$this->server->schedule(50, array($this, "getNextChunk"));
|
||||
if($c === null or $d === null){
|
||||
$this->server->schedule(40, array($this, "getNextChunk"));
|
||||
return false;
|
||||
}
|
||||
unset($this->chunksOrder[$c]);
|
||||
@ -207,7 +222,6 @@ class Player{
|
||||
$Y = $id[1];
|
||||
$x = $X << 4;
|
||||
$z = $Z << 4;
|
||||
$y = $Y << 4;
|
||||
$this->level->useChunk($X, $Z, $this);
|
||||
$Yndex = 1 << $Y;
|
||||
for($iY = 0; $iY < 8; ++$iY){
|
||||
@ -313,7 +327,7 @@ class Player{
|
||||
$this->chunksLoaded = array();
|
||||
$this->chunksOrder = array();
|
||||
$this->chunkCount = array();
|
||||
$this->cratingItems = array();
|
||||
$this->craftingItems = array();
|
||||
$this->received = array();
|
||||
}
|
||||
}
|
||||
@ -683,11 +697,10 @@ class Player{
|
||||
return;
|
||||
}else{
|
||||
$message = $data->get();
|
||||
$this->sendChat(preg_replace('/\x1b\[[0-9;]*m/', "", $message["message"]), $message["player"]); //Remove ANSI codes from chat
|
||||
$this->sendChat($message["message"], $message["player"]);
|
||||
}
|
||||
}else{
|
||||
$message = (string) $data;
|
||||
$this->sendChat(preg_replace('/\x1b\[[0-9;]*m/', "", (string) $data)); //Remove ANSI codes from chat
|
||||
$this->sendChat((string) $data);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -1311,7 +1324,7 @@ class Player{
|
||||
$this->close("Incorrect protocol #".$packet->protocol1, false);
|
||||
return;
|
||||
}
|
||||
if(preg_match('#[^a-zA-Z0-9_]#', $this->username) > 0 or $this->username === "" or $this->iusername === "rcon" or $this->iusername === "console"){
|
||||
if(preg_match('#^[a-zA-Z0-9_]{3,16}$#', $this->username) == 0 or $this->username === "" or $this->iusername === "rcon" or $this->iusername === "console"){
|
||||
$this->close("Bad username", false);
|
||||
return;
|
||||
}
|
||||
@ -1362,9 +1375,9 @@ class Player{
|
||||
$inv[] = array($item[0], $item[1], 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->data->set("inventory", $inv);
|
||||
}
|
||||
}
|
||||
$this->achievements = $this->data->get("achievements");
|
||||
$this->data->set("caseusername", $this->username);
|
||||
$this->inventory = array();
|
||||
@ -1468,7 +1481,7 @@ class Player{
|
||||
}
|
||||
$this->sendInventory();
|
||||
$this->sendSettings();
|
||||
$this->server->schedule(50, array($this, "orderChunks"), array(), true);
|
||||
$this->server->schedule(30, array($this, "orderChunks"), array(), true);
|
||||
$this->blocked = false;
|
||||
|
||||
$pk = new SetTimePacket;
|
||||
@ -1645,7 +1658,7 @@ class Player{
|
||||
$this->entity->updateMetadata();
|
||||
}
|
||||
|
||||
if($this->blocked === true or ($this->entity->position instanceof Vector3 and $blockVector->distance($this->entity->position) > 10)){
|
||||
if($this->blocked === true or ($this->entity instanceof Entity and $blockVector->distance($this->entity) > 10)){
|
||||
|
||||
}elseif($this->getSlot($this->slot)->getID() !== $packet->item or ($this->getSlot($this->slot)->isTool() === false and $this->getSlot($this->slot)->getMetadata() !== $packet->meta)){
|
||||
$this->sendInventorySlot($this->slot);
|
||||
@ -1992,6 +2005,7 @@ class Player{
|
||||
$packet->item = $this->getSlot($this->slot);
|
||||
$this->craftingItems = array();
|
||||
$this->toCraft = array();
|
||||
$data = array();
|
||||
$data["eid"] = $packet->eid;
|
||||
$data["unknown"] = $packet->unknown;
|
||||
$data["item"] = $packet->item;
|
||||
@ -2155,6 +2169,7 @@ class Player{
|
||||
if($item->getID() !== AIR and $slot->getID() == $item->getID()){
|
||||
if($slot->count < $item->count){
|
||||
if($this->removeItem($item->getID(), $item->getMetadata(), $item->count - $slot->count, false) === false){
|
||||
$this->sendInventory();
|
||||
break;
|
||||
}
|
||||
}elseif($slot->count > $item->count){
|
||||
@ -2162,6 +2177,7 @@ class Player{
|
||||
}
|
||||
}else{
|
||||
if($this->removeItem($item->getID(), $item->getMetadata(), $item->count, false) === false){
|
||||
$this->sendInventory();
|
||||
break;
|
||||
}
|
||||
$this->addItem($slot->getID(), $slot->getMetadata(), $slot->count, false);
|
||||
@ -2201,6 +2217,7 @@ class Player{
|
||||
if($item->getID() !== AIR and $slot->getID() == $item->getID()){
|
||||
if($slot->count < $item->count){
|
||||
if($this->removeItem($item->getID(), $item->getMetadata(), $item->count - $slot->count, false) === false){
|
||||
$this->sendInventory();
|
||||
break;
|
||||
}
|
||||
}elseif($slot->count > $item->count){
|
||||
@ -2208,6 +2225,7 @@ class Player{
|
||||
}
|
||||
}else{
|
||||
if($this->removeItem($item->getID(), $item->getMetadata(), $item->count, false) === false){
|
||||
$this->sendInventory();
|
||||
break;
|
||||
}
|
||||
$this->addItem($slot->getID(), $slot->getMetadata(), $slot->count, false);
|
||||
@ -2307,6 +2325,7 @@ class Player{
|
||||
}
|
||||
|
||||
public function sendBuffer(){
|
||||
if($this->connected === true){
|
||||
if($this->bufferLen > 0 and $this->buffer instanceof RakNetPacket){
|
||||
$this->buffer->seqNumber = $this->counter[0]++;
|
||||
$this->send($this->buffer);
|
||||
@ -2316,6 +2335,7 @@ class Player{
|
||||
$this->buffer->data = array();
|
||||
$this->nextBuffer = microtime(true) + 0.1;
|
||||
}
|
||||
}
|
||||
|
||||
private function directBigRawPacket(RakNetDataPacket $packet){
|
||||
if($this->connected === false){
|
||||
@ -2353,7 +2373,7 @@ class Player{
|
||||
return $cnts;
|
||||
}
|
||||
|
||||
public function directDataPacket(RakNetDataPacket $packet, $reliability = 0, $recover = true){
|
||||
public function directDataPacket(RakNetDataPacket $packet, $recover = true){
|
||||
if($this->connected === false){
|
||||
return false;
|
||||
}
|
||||
@ -2361,7 +2381,6 @@ class Player{
|
||||
if(EventHandler::callEvent(new DataPacketSendEvent($this, $packet)) === BaseEvent::DENY){
|
||||
return array();
|
||||
}
|
||||
|
||||
$packet->encode();
|
||||
$pk = new RakNetPacket(RakNetInfo::DATA_PACKET_0);
|
||||
$pk->data[] = $packet;
|
||||
@ -2403,7 +2422,7 @@ class Player{
|
||||
|
||||
$packet->messageIndex = $this->counter[3]++;
|
||||
$packet->reliability = 2;
|
||||
$this->buffer->data[] = $packet;
|
||||
@$this->buffer->data[] = $packet;
|
||||
$this->bufferLen += 6 + $len;
|
||||
return array();
|
||||
}
|
||||
|
@ -21,8 +21,8 @@
|
||||
|
||||
class PocketMinecraftServer{
|
||||
public $tCnt;
|
||||
public $serverID, $interface, $database, $version, $invisible, $tickMeasure, $preparedSQL, $seed, $gamemode, $name, $maxClients, $clients, $eidCnt, $custom, $description, $motd, $port, $saveEnabled;
|
||||
private $serverip, $evCnt, $handCnt, $events, $eventsID, $handlers, $serverType, $lastTick, $ticks, $memoryStats, $async = array(), $asyncID = 0;
|
||||
public $serverID, $interface, $database, $version, $invisible, $tickMeasure, $preparedSQL, $spawn, $whitelist, $seed, $stop, $gamemode, $difficulty, $name, $maxClients, $clients, $eidCnt, $custom, $description, $motd, $port, $saveEnabled;
|
||||
private $serverip, $evCnt, $handCnt, $events, $eventsID, $handlers, $serverType, $lastTick, $doTick, $ticks, $memoryStats, $schedule, $asyncThread, $async = array(), $asyncID = 0;
|
||||
|
||||
/**
|
||||
* @var ServerAPI
|
||||
@ -45,10 +45,7 @@ class PocketMinecraftServer{
|
||||
$this->eventsID = array();
|
||||
$this->handlers = array();
|
||||
$this->invisible = false;
|
||||
$this->levelData = false;
|
||||
$this->difficulty = 1;
|
||||
$this->tiles = array();
|
||||
$this->entities = array();
|
||||
$this->custom = array();
|
||||
$this->evCnt = 1;
|
||||
$this->handCnt = 1;
|
||||
@ -57,11 +54,11 @@ class PocketMinecraftServer{
|
||||
$this->schedule = array();
|
||||
$this->scheduleCnt = 1;
|
||||
$this->description = "";
|
||||
$this->whitelist = false;
|
||||
$this->memoryStats = array();
|
||||
$this->clients = array();
|
||||
$this->spawn = false;
|
||||
$this->saveEnabled = true;
|
||||
$this->whitelist = false;
|
||||
$this->tickMeasure = array_fill(0, 40, 0);
|
||||
$this->setType("normal");
|
||||
$this->interface = new MinecraftInterface("255.255.255.255", $this->port, $this->serverip);
|
||||
@ -129,7 +126,7 @@ class PocketMinecraftServer{
|
||||
public function startDatabase(){
|
||||
$this->preparedSQL = new stdClass();
|
||||
$this->preparedSQL->entity = new stdClass();
|
||||
$this->database = new SQLite3(":memory:");
|
||||
$this->database = new SQLite3(":memory:", SQLITE3_OPEN_READWRITE | SQLITE3_OPEN_CREATE);
|
||||
$this->query("PRAGMA journal_mode = OFF;");
|
||||
$this->query("PRAGMA encoding = \"UTF-8\";");
|
||||
$this->query("PRAGMA secure_delete = OFF;");
|
||||
@ -316,7 +313,6 @@ class PocketMinecraftServer{
|
||||
$handlers->finalize();
|
||||
foreach($call as $hnid => $boolean){
|
||||
if($result !== false and $result !== true){
|
||||
$called[$hnid] = true;
|
||||
$handler = $this->handlers[$hnid];
|
||||
if(is_array($handler)){
|
||||
$method = $handler[1];
|
||||
|
@ -1,17 +1,16 @@
|
||||
#!/bin/bash
|
||||
COMPILER_VERSION="0.16"
|
||||
|
||||
PHP_VERSION="5.5.9"
|
||||
ZEND_VM="GOTO"
|
||||
|
||||
LIBEDIT_VERSION="0.3"
|
||||
ZLIB_VERSION="1.2.8"
|
||||
OPENSSL_VERSION="0.9.8y"
|
||||
CURL_VERSION="curl-7_35_0"
|
||||
LIBEDIT_VERSION="0.3"
|
||||
PTHREADS_VERSION="0.1.0"
|
||||
PHPYAML_VERSION="1.1.1"
|
||||
YAML_VERSION="0.1.4"
|
||||
CURL_VERSION="curl-7_35_0"
|
||||
|
||||
echo "[PocketMine] PHP installer and compiler for Linux & Mac"
|
||||
echo "[PocketMine] PHP compiler for Linux, MacOS and Android"
|
||||
DIR="$(pwd)"
|
||||
date > "$DIR/install.log" 2>&1
|
||||
uname -a >> "$DIR/install.log" 2>&1
|
||||
@ -46,16 +45,29 @@ if [ "$1" == "rpi" ]; then
|
||||
[ -z "$march" ] && march=armv6zk;
|
||||
[ -z "$mtune" ] && mtune=arm1176jzf-s;
|
||||
[ -z "$CFLAGS" ] && CFLAGS="-mfloat-abi=hard -mfpu=vfp";
|
||||
OPENSSL_TARGET="linux-armv4"
|
||||
echo "[INFO] Compiling for Raspberry Pi ARMv6zk hard float"
|
||||
elif [ "$1" == "mac" ]; then
|
||||
[ -z "$march" ] && march=prescott;
|
||||
[ -z "$mtune" ] && mtune=generic;
|
||||
[ -z "$CFLAGS" ] && CFLAGS="-fomit-frame-pointer";
|
||||
echo "[INFO] Compiling for Intel MacOS"
|
||||
[ -z "$CFLAGS" ] && CFLAGS="-m32 -arch i386 -fomit-frame-pointer -mmacosx-version-min=10.5";
|
||||
[ -z "$LDFLAGS" ] && LDFLAGS="-Wl,-rpath,@loader_path/../lib";
|
||||
export DYLD_LIBRARY_PATH="@loader_path/../lib"
|
||||
OPENSSL_TARGET="darwin-i386-cc"
|
||||
echo "[INFO] Compiling for Intel MacOS x86"
|
||||
elif [ "$1" == "mac64" ]; then
|
||||
[ -z "$march" ] && march=core2;
|
||||
[ -z "$mtune" ] && mtune=generic;
|
||||
[ -z "$CFLAGS" ] && CFLAGS="-m64 -arch x86_64 -fomit-frame-pointer -mmacosx-version-min=10.5";
|
||||
[ -z "$LDFLAGS" ] && LDFLAGS="-Wl,-rpath,@loader_path/../lib";
|
||||
export DYLD_LIBRARY_PATH="@loader_path/../lib"
|
||||
OPENSSL_TARGET="darwin64-x86_64-cc"
|
||||
echo "[INFO] Compiling for Intel MacOS x86_64"
|
||||
elif [ "$1" == "ios" ]; then
|
||||
[ -z "$march" ] && march=armv6;
|
||||
[ -z "$mtune" ] && mtune=cortex-a8;
|
||||
echo "[INFO] Compiling for iOS ARMv6"
|
||||
OPENSSL_TARGET="linux-armv4"
|
||||
elif [ "$1" == "crosscompile" ]; then
|
||||
HAVE_MYSQLI="--without-mysqli"
|
||||
if [ "$2" == "android" ] || [ "$2" == "android-armv6" ]; then
|
||||
@ -65,9 +77,9 @@ elif [ "$1" == "crosscompile" ]; then
|
||||
TOOLCHAIN_PREFIX="arm-unknown-linux-uclibcgnueabi"
|
||||
export CC="$TOOLCHAIN_PREFIX-gcc"
|
||||
CONFIGURE_FLAGS="--host=$TOOLCHAIN_PREFIX --enable-static-link --disable-ipv6"
|
||||
CFLAGS="-uclibc --static $CFLAGS";
|
||||
LDFLAGS="--static"
|
||||
CFLAGS="-static -uclibc -Wl,-Bdynamic $CFLAGS"
|
||||
echo "[INFO] Cross-compiling for Android ARMv6"
|
||||
OPENSSL_TARGET="android"
|
||||
elif [ "$2" == "android-armv7" ]; then
|
||||
COMPILE_FOR_ANDROID=yes
|
||||
[ -z "$march" ] && march=armv7-a;
|
||||
@ -75,9 +87,9 @@ elif [ "$1" == "crosscompile" ]; then
|
||||
TOOLCHAIN_PREFIX="arm-unknown-linux-uclibcgnueabi"
|
||||
export CC="$TOOLCHAIN_PREFIX-gcc"
|
||||
CONFIGURE_FLAGS="--host=$TOOLCHAIN_PREFIX --enable-static-link --disable-ipv6"
|
||||
CFLAGS="-uclibc --static $CFLAGS";
|
||||
LDFLAGS="--static"
|
||||
CFLAGS="-static -uclibc -Wl,-Bdynamic $CFLAGS"
|
||||
echo "[INFO] Cross-compiling for Android ARMv7"
|
||||
OPENSSL_TARGET="android-armv7"
|
||||
elif [ "$2" == "rpi" ]; then
|
||||
TOOLCHAIN_PREFIX="arm-linux-gnueabihf"
|
||||
[ -z "$march" ] && march=armv6zk;
|
||||
@ -86,6 +98,7 @@ elif [ "$1" == "crosscompile" ]; then
|
||||
export CC="$TOOLCHAIN_PREFIX-gcc"
|
||||
CONFIGURE_FLAGS="--host=$TOOLCHAIN_PREFIX"
|
||||
[ -z "$CFLAGS" ] && CFLAGS="-uclibc";
|
||||
OPENSSL_TARGET="linux-armv4"
|
||||
echo "[INFO] Cross-compiling for Raspberry Pi ARMv6zk hard float"
|
||||
elif [ "$2" == "mac" ]; then
|
||||
[ -z "$march" ] && march=prescott;
|
||||
@ -96,33 +109,39 @@ elif [ "$1" == "crosscompile" ]; then
|
||||
CONFIGURE_FLAGS="--host=$TOOLCHAIN_PREFIX"
|
||||
#zlib doesn't use the correct ranlib
|
||||
RANLIB=$TOOLCHAIN_PREFIX-ranlib
|
||||
OPENSSL_TARGET="darwin64-x86_64-cc"
|
||||
echo "[INFO] Cross-compiling for Intel MacOS"
|
||||
elif [ "$2" == "ios" ] || [ "$2" == "ios-armv6" ]; then
|
||||
[ -z "$march" ] && march=armv6;
|
||||
[ -z "$mtune" ] && mtune=generic-armv6;
|
||||
CONFIGURE_FLAGS="--target=arm-apple-darwin10"
|
||||
OPENSSL_TARGET="linux-armv4"
|
||||
elif [ "$2" == "ios-armv7" ]; then
|
||||
[ -z "$march" ] && march=armv7-a;
|
||||
[ -z "$mtune" ] && mtune=generic-armv7-a;
|
||||
CONFIGURE_FLAGS="--target=arm-apple-darwin10"
|
||||
OPENSSL_TARGET="linux-armv4"
|
||||
else
|
||||
echo "Please supply a proper platform [android android-armv6 android-armv7 rpi mac ios ios-armv6 ios-armv7] to cross-compile"
|
||||
exit 1
|
||||
fi
|
||||
elif [ -z "$CFLAGS" ]; then
|
||||
if [ `getconf LONG_BIT` = "64" ]; then
|
||||
if [ `getconf LONG_BIT` == "64" ]; then
|
||||
echo "[INFO] Compiling for current machine using 64-bit"
|
||||
CFLAGS="-m64 $CFLAGS"
|
||||
OPENSSL_TARGET="linux-x86_64"
|
||||
else
|
||||
echo "[INFO] Compiling for current machine using 32-bit"
|
||||
CFLAGS="-m32 $CFLAGS"
|
||||
OPENSSL_TARGET="linux-generic32"
|
||||
fi
|
||||
fi
|
||||
|
||||
cat > test.c <<'CTEST'
|
||||
#include <stdio.h>
|
||||
main(){
|
||||
int main(void){
|
||||
printf("Hello world\n");
|
||||
return 0;
|
||||
}
|
||||
CTEST
|
||||
|
||||
@ -133,7 +152,7 @@ type $CC >> "$DIR/install.log" 2>&1 || { echo >&2 "[ERROR] Please install \"$CC\
|
||||
[ -z "$march" ] && march=native;
|
||||
[ -z "$mtune" ] && mtune=native;
|
||||
[ -z "$CFLAGS" ] && CFLAGS="";
|
||||
[ -z "$LDFLAGS" ] && LDFLAGS="";
|
||||
[ -z "$LDFLAGS" ] && LDFLAGS="-Wl,-rpath='\$\$ORIGIN/../lib'";
|
||||
[ -z "$CONFIGURE_FLAGS" ] && CONFIGURE_FLAGS="";
|
||||
|
||||
|
||||
@ -149,16 +168,17 @@ else
|
||||
fi
|
||||
fi
|
||||
|
||||
rm test.* >> "$DIR/install.log" 2>&1
|
||||
rm test >> "$DIR/install.log" 2>&1
|
||||
rm test.c >> "$DIR/install.log" 2>&1
|
||||
|
||||
export CFLAGS="-O2 $CFLAGS"
|
||||
export LDFLAGS="$LDFLAGS"
|
||||
|
||||
rm -r -f install_data/ >> "$DIR/install.log" 2>&1
|
||||
rm -r -f bin/ >> "$DIR/install.log" 2>&1
|
||||
mkdir -m 0777 install_data >> "$DIR/install.log" 2>&1
|
||||
mkdir -m 0777 bin >> "$DIR/install.log" 2>&1
|
||||
mkdir -m 0755 install_data >> "$DIR/install.log" 2>&1
|
||||
mkdir -m 0755 bin >> "$DIR/install.log" 2>&1
|
||||
mkdir -m 0755 bin/php5 >> "$DIR/install.log" 2>&1
|
||||
cd install_data
|
||||
set -e
|
||||
|
||||
@ -168,38 +188,43 @@ download_file "http://php.net/get/php-$PHP_VERSION.tar.gz/from/this/mirror" | ta
|
||||
mv php-$PHP_VERSION php
|
||||
echo " done!"
|
||||
|
||||
if [ 1 ] || [ "$1" == "crosscompile" ] || [ "$1" == "rpi" ]; then
|
||||
HAVE_LIBEDIT="--without-libedit"
|
||||
if [ "$1" == "crosscompile" ] || [ "$1" == "rpi" ] || [ "$1" == "mac" ]; then
|
||||
HAVE_LIBEDIT="--without-readline --without-libedit"
|
||||
else
|
||||
#libedit
|
||||
set +e
|
||||
echo -n "[libedit] downloading $LIBEDIT_VERSION..."
|
||||
download_file "http://download.sourceforge.net/project/libedit/libedit/libedit-$LIBEDIT_VERSION/libedit-$LIBEDIT_VERSION.tar.gz" | tar -zx >> "$DIR/install.log" 2>&1
|
||||
echo -n " checking..."
|
||||
cd libedit
|
||||
./configure --prefix="$DIR/install_data/php/ext/libedit" --enable-static >> "$DIR/install.log" 2>&1
|
||||
./configure --prefix="$DIR/bin/php5" \
|
||||
--enable-shared=yes \
|
||||
--enable-static=no \
|
||||
$CONFIGURE_FLAGS >> "$DIR/install.log" 2>&1
|
||||
echo -n " compiling..."
|
||||
if make -j $THREADS >> "$DIR/install.log" 2>&1; then
|
||||
echo -n " installing..."
|
||||
make install >> "$DIR/install.log" 2>&1
|
||||
HAVE_LIBEDIT="--with-libedit=\"$DIR/install_data/php/ext/libedit\""
|
||||
HAVE_LIBEDIT="--without-readline --with-libedit=\"$DIR/bin/php5\""
|
||||
else
|
||||
echo -n " disabling..."
|
||||
HAVE_LIBEDIT="--without-libedit"
|
||||
HAVE_LIBEDIT="--without-readline --without-libedit"
|
||||
fi
|
||||
echo -n " cleaning..."
|
||||
cd ..
|
||||
rm -r -f ./libedit
|
||||
echo " done!"
|
||||
set -e
|
||||
fi
|
||||
|
||||
#zlib
|
||||
download_file "https://github.com/madler/zlib/archive/v$ZLIB_VERSION.tar.gz" | tar -zx >> "$DIR/install.log" 2>&1
|
||||
echo -n "[zlib] downloading $ZLIB_VERSION..."
|
||||
download_file "http://zlib.net/zlib-$ZLIB_VERSION.tar.gz" | tar -zx >> "$DIR/install.log" 2>&1
|
||||
mv zlib-$ZLIB_VERSION zlib
|
||||
echo -n " checking..."
|
||||
cd zlib
|
||||
RANLIB=$RANLIB ./configure --prefix="$DIR/install_data/php/ext/zlib" \
|
||||
--static >> "$DIR/install.log" 2>&1
|
||||
RANLIB=$RANLIB ./configure --prefix="$DIR/bin/php5" \
|
||||
--shared >> "$DIR/install.log" 2>&1
|
||||
echo -n " compiling..."
|
||||
make -j $THREADS >> "$DIR/install.log" 2>&1
|
||||
echo -n " installing..."
|
||||
@ -209,6 +234,45 @@ cd ..
|
||||
rm -r -f ./zlib
|
||||
echo " done!"
|
||||
|
||||
if [ "$2" == "openssl" ] || [ "$2" == "curl" ] && [ "$1" != "crosscompile" ]; then
|
||||
#OpenSSL
|
||||
WITH_SSL="--with-ssl=$DIR/bin/php5"
|
||||
WITH_OPENSSL="--with-openssl=$DIR/bin/php5"
|
||||
echo -n "[OpenSSL] downloading $OPENSSL_VERSION..."
|
||||
download_file "http://www.openssl.org/source/openssl-$OPENSSL_VERSION.tar.gz" | tar -zx >> "$DIR/install.log" 2>&1
|
||||
mv openssl-$OPENSSL_VERSION openssl
|
||||
echo -n " checking..."
|
||||
cd openssl
|
||||
RANLIB=$RANLIB ./Configure \
|
||||
$OPENSSL_TARGET \
|
||||
--prefix="$DIR/bin/php5" \
|
||||
--openssldir="$DIR/bin/php5" \
|
||||
--with-zlib-lib="$DIR/bin/php5/lib" \
|
||||
--with-zlib-include="$DIR/bin/php5/include" \
|
||||
zlib-dynamic \
|
||||
shared \
|
||||
no-asm \
|
||||
no-hw \
|
||||
no-engines \
|
||||
no-static \
|
||||
$CONFIGURE_FLAGS >> "$DIR/install.log" 2>&1
|
||||
echo -n " compiling..."
|
||||
make depend >> "$DIR/install.log" 2>&1
|
||||
make >> "$DIR/install.log" 2>&1
|
||||
echo -n " installing..."
|
||||
make install >> "$DIR/install.log" 2>&1
|
||||
echo -n " cleaning..."
|
||||
cd ..
|
||||
rm -r -f ./openssh
|
||||
echo " done!"
|
||||
else
|
||||
WITH_SSL="--with-ssl"
|
||||
WITH_OPENSSL="--without-ssl"
|
||||
if [ "$(uname -s)" == "Darwin" ] && [ "$1" != "crosscompile" ]; then
|
||||
WITH_SSL="--with-darwinssl"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$(uname -s)" == "Darwin" ] && [ "$1" != "crosscompile" ] && [ "$2" != "curl" ]; then
|
||||
HAVE_CURL="shared,/usr"
|
||||
else
|
||||
@ -221,13 +285,14 @@ else
|
||||
if [ ! -f ./configure ]; then
|
||||
./buildconf --force >> "$DIR/install.log" 2>&1
|
||||
fi
|
||||
./configure --disable-dependency-tracking \
|
||||
RANLIB=$RANLIB ./configure --disable-dependency-tracking \
|
||||
--enable-ipv6 \
|
||||
--enable-optimize \
|
||||
--enable-http \
|
||||
--enable-ftp \
|
||||
--disable-dict \
|
||||
--enable-file \
|
||||
--without-librtmp \
|
||||
--disable-gopher \
|
||||
--disable-imap \
|
||||
--disable-pop3 \
|
||||
@ -238,8 +303,10 @@ else
|
||||
--disable-ldap \
|
||||
--disable-ldaps \
|
||||
--without-libidn \
|
||||
--with-zlib="$DIR/bin/php5" \
|
||||
$WITH_SSL \
|
||||
--enable-threaded-resolver \
|
||||
--prefix="$DIR/install_data/php/ext/curl" \
|
||||
--prefix="$DIR/bin/php5" \
|
||||
--disable-shared \
|
||||
--enable-static \
|
||||
$CONFIGURE_FLAGS >> "$DIR/install.log" 2>&1
|
||||
@ -251,7 +318,7 @@ else
|
||||
cd ..
|
||||
rm -r -f ./curl
|
||||
echo " done!"
|
||||
HAVE_CURL="$DIR/install_data/php/ext/curl"
|
||||
HAVE_CURL="$DIR/bin/php5"
|
||||
fi
|
||||
|
||||
#pthreads
|
||||
@ -273,9 +340,9 @@ mv yaml-$YAML_VERSION yaml
|
||||
echo -n " checking..."
|
||||
cd yaml
|
||||
RANLIB=$RANLIB ./configure \
|
||||
--prefix="$DIR/install_data/php/ext/yaml" \
|
||||
--enable-static \
|
||||
--disable-shared \
|
||||
--prefix="$DIR/bin/php5" \
|
||||
--disable-static \
|
||||
--enable-shared \
|
||||
$CONFIGURE_FLAGS >> "$DIR/install.log" 2>&1
|
||||
echo -n " compiling..."
|
||||
make -j $THREADS >> "$DIR/install.log" 2>&1
|
||||
@ -293,7 +360,7 @@ if which free >/dev/null; then
|
||||
else
|
||||
MAX_MEMORY=$(top -l 1 | grep PhysMem: | awk '{print $10}' | tr -d 'a-zA-Z')
|
||||
fi
|
||||
if [ $MAX_MEMORY -gt 512 ] && [ "$1" != "crosscompile" ]; then
|
||||
if [ $MAX_MEMORY -gt 512 2>> /dev/null ] && [ "$1" != "crosscompile" ]; then
|
||||
echo -n " enabling optimizations..."
|
||||
OPTIMIZATION="--enable-inline-optimization "
|
||||
else
|
||||
@ -310,14 +377,12 @@ if [ "$1" == "crosscompile" ]; then
|
||||
sed -i 's/pthreads_working=no/pthreads_working=yes/' ./configure
|
||||
export LIBS="-lpthread -ldl"
|
||||
CONFIGURE_FLAGS="$CONFIGURE_FLAGS --enable-opcache=no"
|
||||
|
||||
fi
|
||||
./configure $OPTIMIZATION--prefix="$DIR/bin/php5" \
|
||||
RANLIB=$RANLIB ./configure $OPTIMIZATION--prefix="$DIR/bin/php5" \
|
||||
--exec-prefix="$DIR/bin/php5" \
|
||||
--with-curl="$HAVE_CURL" \
|
||||
--with-zlib="$DIR/install_data/php/ext/zlib" \
|
||||
--with-zlib-dir="$DIR/install_data/php/ext/zlib" \
|
||||
--with-yaml="$DIR/install_data/php/ext/yaml" \
|
||||
--with-zlib="$DIR/bin/php5" \
|
||||
--with-yaml="$DIR/bin/php5" \
|
||||
$HAVE_LIBEDIT \
|
||||
--disable-libxml \
|
||||
--disable-xml \
|
||||
@ -356,33 +421,53 @@ fi
|
||||
make -j $THREADS >> "$DIR/install.log" 2>&1
|
||||
echo -n " installing..."
|
||||
make install >> "$DIR/install.log" 2>&1
|
||||
echo " generating php.ini..."
|
||||
|
||||
if [ "$(uname -s)" == "Darwin" ] && [ "$1" != "crosscompile" ]; then
|
||||
set +e
|
||||
install_name_tool -delete_rpath "$DIR/bin/php5/lib" "$DIR/bin/php5/bin/php" >> "$DIR/install.log" 2>&1
|
||||
install_name_tool -change "$DIR/bin/php5/lib/libz.1.dylib" "@loader_path/../lib/libz.1.dylib" "$DIR/bin/php5/bin/php" >> "$DIR/install.log" 2>&1
|
||||
install_name_tool -change "$DIR/bin/php5/lib/libyaml-0.2.dylib" "@loader_path/../lib/libyaml-0.2.dylib" "$DIR/bin/php5/bin/php" >> "$DIR/install.log" 2>&1
|
||||
install_name_tool -change "$DIR/bin/php5/lib/libssl.1.0.0.dylib" "@loader_path/../lib/libssl.1.0.0.dylib" "$DIR/bin/php5/bin/php" >> "$DIR/install.log" 2>&1
|
||||
install_name_tool -change "$DIR/bin/php5/lib/libcrypto.1.0.0.dylib" "@loader_path/../lib/libcrypto.1.0.0.dylib" "$DIR/bin/php5/bin/php" >> "$DIR/install.log" 2>&1
|
||||
chmod 0777 "$DIR/bin/php5/lib/libssl.1.0.0.dylib" >> "$DIR/install.log" 2>&1
|
||||
install_name_tool -change "$DIR/bin/php5/lib/libcrypto.1.0.0.dylib" "@loader_path/libcrypto.1.0.0.dylib" "$DIR/bin/php5/lib/libssl.1.0.0.dylib" >> "$DIR/install.log" 2>&1
|
||||
chmod 0755 "$DIR/bin/php5/lib/libssl.1.0.0.dylib" >> "$DIR/install.log" 2>&1
|
||||
set -e
|
||||
fi
|
||||
|
||||
echo -n " generating php.ini..."
|
||||
|
||||
TIMEZONE=$(date +%Z)
|
||||
touch "$DIR/bin/php5/lib/php.ini"
|
||||
echo "date.timezone=$TIMEZONE" > "$DIR/bin/php5/bin/php.ini"
|
||||
echo "short_open_tag=0" >> "$DIR/bin/php5/bin/php.ini"
|
||||
echo "asp_tags=0" >> "$DIR/bin/php5/bin/php.ini"
|
||||
if [ "$1" != "crosscompile" ]; then
|
||||
OPCACHE_PATH=$(find "$DIR/bin/php5" -name opcache.so)
|
||||
echo "zend_extension=\"$OPCACHE_PATH\"" >> "$DIR/bin/php5/lib/php.ini"
|
||||
echo "opcache.enable=1" >> "$DIR/bin/php5/lib/php.ini"
|
||||
echo "opcache.enable_cli=1" >> "$DIR/bin/php5/lib/php.ini"
|
||||
echo "opcache.save_comments=0" >> "$DIR/bin/php5/lib/php.ini"
|
||||
echo "opcache.fast_shutdown=1" >> "$DIR/bin/php5/lib/php.ini"
|
||||
echo "opcache.max_accelerated_files=4096" >> "$DIR/bin/php5/lib/php.ini"
|
||||
echo "opcache.interned_strings_buffer=8" >> "$DIR/bin/php5/lib/php.ini"
|
||||
echo "opcache.memory_consumption=128" >> "$DIR/bin/php5/lib/php.ini"
|
||||
echo "opcache.optimization_level=0xffffffff" >> "$DIR/bin/php5/lib/php.ini"
|
||||
echo "zend_extension=opcache.so" >> "$DIR/bin/php5/bin/php.ini"
|
||||
echo "opcache.enable=1" >> "$DIR/bin/php5/bin/php.ini"
|
||||
echo "opcache.enable_cli=1" >> "$DIR/bin/php5/bin/php.ini"
|
||||
echo "opcache.save_comments=0" >> "$DIR/bin/php5/bin/php.ini"
|
||||
echo "opcache.fast_shutdown=1" >> "$DIR/bin/php5/bin/php.ini"
|
||||
echo "opcache.max_accelerated_files=4096" >> "$DIR/bin/php5/bin/php.ini"
|
||||
echo "opcache.interned_strings_buffer=8" >> "$DIR/bin/php5/bin/php.ini"
|
||||
echo "opcache.memory_consumption=128" >> "$DIR/bin/php5/bin/php.ini"
|
||||
echo "opcache.optimization_level=0xffffffff" >> "$DIR/bin/php5/bin/php.ini"
|
||||
fi
|
||||
if [ "$HAVE_CURL" == "shared,/usr" ]; then
|
||||
echo "extension=curl.so" >> "$DIR/bin/php5/lib/php.ini"
|
||||
echo "extension=curl.so" >> "$DIR/bin/php5/bin/php.ini"
|
||||
fi
|
||||
echo "date.timezone=$TIMEZONE" >> "$DIR/bin/php5/lib/php.ini"
|
||||
echo "short_open_tag=0" >> "$DIR/bin/php5/lib/php.ini"
|
||||
echo "asp_tags=0" >> "$DIR/bin/php5/lib/php.ini"
|
||||
|
||||
echo " done!"
|
||||
cd "$DIR"
|
||||
echo -n "[INFO] Cleaning up..."
|
||||
rm -r -f install_data/ >> "$DIR/install.log" 2>&1
|
||||
rm -f bin/php5/bin/curl >> "$DIR/install.log" 2>&1
|
||||
rm -f bin/php5/bin/curl-config >> "$DIR/install.log" 2>&1
|
||||
rm -f bin/php5/bin/c_rehash >> "$DIR/install.log" 2>&1
|
||||
rm -f bin/php5/bin/openssl >> "$DIR/install.log" 2>&1
|
||||
rm -r -f bin/php5/man >> "$DIR/install.log" 2>&1
|
||||
rm -r -f bin/php5/php >> "$DIR/install.log" 2>&1
|
||||
rm -r -f bin/php5/share >> "$DIR/install.log" 2>&1
|
||||
rm -r -f bin/php5/misc >> "$DIR/install.log" 2>&1
|
||||
date >> "$DIR/install.log" 2>&1
|
||||
echo " done!"
|
||||
echo "[PocketMine] You should start the server now using \"./start.sh.\""
|
||||
|
@ -1,10 +1,17 @@
|
||||
#!/bin/bash
|
||||
PMMP_VERSION=""
|
||||
MAC_BUILD="PHP_5.5.9_x86_MacOS"
|
||||
LINUX_32_BUILD="PHP_5.5.9_x86_Linux"
|
||||
LINUX_64_BUILD="PHP_5.5.9_x86-64_Linux"
|
||||
MAC_32_BUILD="PHP_5.5.9_x86_MacOS"
|
||||
MAC_64_BUILD="PHP_5.5.9_x86-64_MacOS"
|
||||
RPI_BUILD="PHP_5.5.9_ARM_Raspbian_hard"
|
||||
# Temporal build
|
||||
ODROID_BUILD="PHP_5.5.9_ARM_Raspbian_hard"
|
||||
AND_BUILD="PHP_5.5.9_ARMv7_Android"
|
||||
IOS_BUILD="PHP_5.5.9_ARMv6_iOS"
|
||||
update=off
|
||||
forcecompile=off
|
||||
alldone=no
|
||||
|
||||
#Needed to use aliases
|
||||
shopt -s expand_aliases
|
||||
@ -21,11 +28,14 @@ else
|
||||
fi
|
||||
|
||||
|
||||
while getopts "udv:" opt; do
|
||||
while getopts "ucdv:" opt; do
|
||||
case $opt in
|
||||
u)
|
||||
update=on
|
||||
;;
|
||||
c)
|
||||
forcecompile=on
|
||||
;;
|
||||
d)
|
||||
PMMP_VERSION="master"
|
||||
;;
|
||||
@ -58,7 +68,6 @@ rm -f LICENSE
|
||||
rm -f start.sh
|
||||
rm -f start.bat
|
||||
echo "[1/3] Downloading PocketMine-MP $PMMP_VERSION..."
|
||||
set -e
|
||||
download_file "https://github.com/PocketMine/PocketMine-MP/archive/$PMMP_VERSION.tar.gz" | tar -zx > /dev/null
|
||||
mv -f PocketMine-MP-$PMMP_VERSION/* ./
|
||||
rm -f -r PocketMine-MP-$PMMP_VERSION/
|
||||
@ -70,67 +79,151 @@ if [ $update == on ]; then
|
||||
else
|
||||
echo -n "[3/3] Obtaining PHP:"
|
||||
echo " detecting if build is available..."
|
||||
if [ "$(uname -s)" == "Darwin" ]; then
|
||||
if [ "$forcecompile" == "off" ] && [ "$(uname -s)" == "Darwin" ]; then
|
||||
set +e
|
||||
UNAME_M=$(uname -m)
|
||||
IS_IOS=$(expr match $UNAME_M 'iP[a-zA-Z0-9,]*')
|
||||
IS_IOS=$(expr match $UNAME_M 'iP[a-zA-Z0-9,]*' 2> /dev/null)
|
||||
set -e
|
||||
if [ $IS_IOS -gt 0 ]; then
|
||||
if [[ $IS_IOS -gt 0 ]]; then
|
||||
rm -r -f bin/ >> /dev/null 2>&1
|
||||
echo -n "[3/3] iOS PHP build available, downloading $IOS_BUILD.tar.gz..."
|
||||
download_file "http://sourceforge.net/projects/pocketmine/files/builds/$IOS_BUILD.tar.gz" | tar -zx > /dev/null 2>&1
|
||||
chmod +x ./bin/php5/bin/*
|
||||
echo -n " checking..."
|
||||
if [ $(./bin/php5/bin/php -r 'echo "yes";' 2>/dev/null) == "yes" ]; then
|
||||
echo -n " regenerating php.ini..."
|
||||
echo "date.timezone=$TIMEZONE" >> "./bin/php5/lib/php.ini"
|
||||
echo "short_open_tag=0" >> "./bin/php5/lib/php.ini"
|
||||
echo "asp_tags=0" >> "./bin/php5/lib/php.ini"
|
||||
echo "date.timezone=$TIMEZONE" >> "./bin/php5/bin/php.ini"
|
||||
echo "short_open_tag=0" >> "./bin/php5/bin/php.ini"
|
||||
echo "asp_tags=0" >> "./bin/php5/bin/php.ini"
|
||||
echo " done"
|
||||
alldone=yes
|
||||
else
|
||||
rm -r -f bin/ >> /dev/null 2>&1
|
||||
echo -n "[3/3] Mac OSX PHP build available, downloading $MAC_BUILD.tar.gz..."
|
||||
download_file "http://sourceforge.net/projects/pocketmine/files/builds/$MAC_BUILD.tar.gz" | tar -zx > /dev/null 2>&1
|
||||
chmod +x ./bin/php5/bin/*
|
||||
echo -n " regenerating php.ini..."
|
||||
OPCACHE_PATH=$(find "./bin/php5" -name opcache.so)
|
||||
echo "zend_extension=\"$OPCACHE_PATH\"" > "./bin/php5/lib/php.ini"
|
||||
echo "opcache.enable=1" >> "./bin/php5/lib/php.ini"
|
||||
echo "opcache.enable_cli=1" >> "./bin/php5/lib/php.ini"
|
||||
echo "opcache.save_comments=0" >> "./bin/php5/lib/php.ini"
|
||||
echo "opcache.fast_shutdown=1" >> "./bin/php5/lib/php.ini"
|
||||
echo "opcache.max_accelerated_files=4096" >> "./bin/php5/lib/php.ini"
|
||||
echo "opcache.interned_strings_buffer=8" >> "./bin/php5/lib/php.ini"
|
||||
echo "opcache.memory_consumption=128" >> "./bin/php5/lib/php.ini"
|
||||
echo "opcache.optimization_level=0xffffffff" >> "./bin/php5/lib/php.ini"
|
||||
echo "date.timezone=$TIMEZONE" >> "./bin/php5/lib/php.ini"
|
||||
echo "short_open_tag=0" >> "./bin/php5/lib/php.ini"
|
||||
echo "asp_tags=0" >> "./bin/php5/lib/php.ini"
|
||||
echo " done"
|
||||
echo " invalid build detected"
|
||||
fi
|
||||
else
|
||||
rm -r -f bin/ >> /dev/null 2>&1
|
||||
if [ `getconf LONG_BIT` == "64" ]; then
|
||||
echo -n "[3/3] MacOS 64-bit PHP build available, downloading $MAC_64_BUILD.tar.gz..."
|
||||
MAC_BUILD=$MAC_64_BUILD
|
||||
else
|
||||
echo -n "[3/3] MacOS 32-bit PHP build available, downloading $MAC_32_BUILD.tar.gz..."
|
||||
MAC_BUILD=$MAC_32_BUILD
|
||||
fi
|
||||
download_file "http://sourceforge.net/projects/pocketmine/files/builds/$MAC_BUILD.tar.gz" | tar -zx > /dev/null 2>&1
|
||||
chmod +x ./bin/php5/bin/*
|
||||
echo -n " checking..."
|
||||
if [ $(./bin/php5/bin/php -r 'echo "yes";' 2>/dev/null) == "yes" ]; then
|
||||
echo -n " regenerating php.ini..."
|
||||
OPCACHE_PATH="$(find $(pwd) -name opcache.so)"
|
||||
echo "zend_extension=\"$OPCACHE_PATH\"" > "./bin/php5/bin/php.ini"
|
||||
echo "opcache.enable=1" >> "./bin/php5/bin/php.ini"
|
||||
echo "opcache.enable_cli=1" >> "./bin/php5/bin/php.ini"
|
||||
echo "opcache.save_comments=0" >> "./bin/php5/bin/php.ini"
|
||||
echo "opcache.fast_shutdown=1" >> "./bin/php5/bin/php.ini"
|
||||
echo "opcache.max_accelerated_files=4096" >> "./bin/php5/bin/php.ini"
|
||||
echo "opcache.interned_strings_buffer=8" >> "./bin/php5/bin/php.ini"
|
||||
echo "opcache.memory_consumption=128" >> "./bin/php5/bin/php.ini"
|
||||
echo "opcache.optimization_level=0xffffffff" >> "./bin/php5/bin/php.ini"
|
||||
echo "date.timezone=$TIMEZONE" >> "./bin/php5/bin/php.ini"
|
||||
echo "short_open_tag=0" >> "./bin/php5/bin/php.ini"
|
||||
echo "asp_tags=0" >> "./bin/php5/bin/php.ini"
|
||||
echo " done"
|
||||
alldone=yes
|
||||
else
|
||||
echo " invalid build detected"
|
||||
fi
|
||||
fi
|
||||
else
|
||||
set +e
|
||||
grep -q BCM2708 /proc/cpuinfo > /dev/null 2>&1
|
||||
if [ $? -eq 0 ]; then
|
||||
set -e
|
||||
IS_RPI=$?
|
||||
grep -q ODROID /proc/cpuinfo > /dev/null 2>&1
|
||||
IS_ODROID=$?
|
||||
if [ $IS_RPI -eq 0 ] && [ "$forcecompile" == "off" ]; then
|
||||
rm -r -f bin/ >> /dev/null 2>&1
|
||||
echo -n "[3/3] Raspberry Pi PHP build available, downloading $RPI_BUILD.tar.gz..."
|
||||
download_file "http://sourceforge.net/projects/pocketmine/files/builds/$RPI_BUILD.tar.gz" | tar -zx > /dev/null 2>&1
|
||||
chmod +x ./bin/php5/bin/*
|
||||
echo -n " checking..."
|
||||
if [ $(./bin/php5/bin/php -r 'echo "yes";' 2>/dev/null) == "yes" ]; then
|
||||
echo -n " regenerating php.ini..."
|
||||
OPCACHE_PATH=$(find "./bin/php5" -name opcache.so)
|
||||
echo "zend_extension=\"$OPCACHE_PATH\"" > "./bin/php5/lib/php.ini"
|
||||
echo "opcache.enable=1" >> "./bin/php5/lib/php.ini"
|
||||
echo "opcache.enable_cli=1" >> "./bin/php5/lib/php.ini"
|
||||
echo "opcache.save_comments=0" >> "./bin/php5/lib/php.ini"
|
||||
echo "opcache.fast_shutdown=1" >> "./bin/php5/lib/php.ini"
|
||||
echo "opcache.max_accelerated_files=4096" >> "./bin/php5/lib/php.ini"
|
||||
echo "opcache.interned_strings_buffer=8" >> "./bin/php5/lib/php.ini"
|
||||
echo "opcache.memory_consumption=128" >> "./bin/php5/lib/php.ini"
|
||||
echo "opcache.optimization_level=0xffffffff" >> "./bin/php5/lib/php.ini"
|
||||
echo "date.timezone=$TIMEZONE" >> "./bin/php5/lib/php.ini"
|
||||
echo "short_open_tag=0" >> "./bin/php5/lib/php.ini"
|
||||
echo "asp_tags=0" >> "./bin/php5/lib/php.ini"
|
||||
OPCACHE_PATH="$(find $(pwd) -name opcache.so)"
|
||||
echo "zend_extension=\"$OPCACHE_PATH\"" > "./bin/php5/bin/php.ini"
|
||||
echo "opcache.enable=1" >> "./bin/php5/bin/php.ini"
|
||||
echo "opcache.enable_cli=1" >> "./bin/php5/bin/php.ini"
|
||||
echo "opcache.save_comments=0" >> "./bin/php5/bin/php.ini"
|
||||
echo "opcache.fast_shutdown=1" >> "./bin/php5/bin/php.ini"
|
||||
echo "opcache.max_accelerated_files=4096" >> "./bin/php5/bin/php.ini"
|
||||
echo "opcache.interned_strings_buffer=8" >> "./bin/php5/bin/php.ini"
|
||||
echo "opcache.memory_consumption=128" >> "./bin/php5/bin/php.ini"
|
||||
echo "opcache.optimization_level=0xffffffff" >> "./bin/php5/bin/php.ini"
|
||||
echo "date.timezone=$TIMEZONE" >> "./bin/php5/bin/php.ini"
|
||||
echo "short_open_tag=0" >> "./bin/php5/bin/php.ini"
|
||||
echo "asp_tags=0" >> "./bin/php5/bin/php.ini"
|
||||
echo " done"
|
||||
alldone=yes
|
||||
else
|
||||
echo " invalid build detected"
|
||||
fi
|
||||
elif [ $IS_ODROID -eq 0 ] && [ "$forcecompile" == "off" ]; then
|
||||
rm -r -f bin/ >> /dev/null 2>&1
|
||||
echo -n "[3/3] ODROID PHP build available, downloading $ODROID_BUILD.tar.gz..."
|
||||
download_file "http://sourceforge.net/projects/pocketmine/files/builds/$ODROID_BUILD.tar.gz" | tar -zx > /dev/null 2>&1
|
||||
chmod +x ./bin/php5/bin/*
|
||||
echo -n " checking..."
|
||||
if [ $(./bin/php5/bin/php -r 'echo "yes";' 2>/dev/null) == "yes" ]; then
|
||||
echo -n " regenerating php.ini..."
|
||||
OPCACHE_PATH="$(find $(pwd) -name opcache.so)"
|
||||
echo "zend_extension=\"$OPCACHE_PATH\"" > "./bin/php5/bin/php.ini"
|
||||
echo "opcache.enable=1" >> "./bin/php5/bin/php.ini"
|
||||
echo "opcache.enable_cli=1" >> "./bin/php5/bin/php.ini"
|
||||
echo "opcache.save_comments=0" >> "./bin/php5/bin/php.ini"
|
||||
echo "opcache.fast_shutdown=1" >> "./bin/php5/bin/php.ini"
|
||||
echo "opcache.max_accelerated_files=4096" >> "./bin/php5/bin/php.ini"
|
||||
echo "opcache.interned_strings_buffer=8" >> "./bin/php5/bin/php.ini"
|
||||
echo "opcache.memory_consumption=128" >> "./bin/php5/bin/php.ini"
|
||||
echo "opcache.optimization_level=0xffffffff" >> "./bin/php5/bin/php.ini"
|
||||
echo "date.timezone=$TIMEZONE" >> "./bin/php5/bin/php.ini"
|
||||
echo "short_open_tag=0" >> "./bin/php5/bin/php.ini"
|
||||
echo "asp_tags=0" >> "./bin/php5/bin/php.ini"
|
||||
echo " done"
|
||||
alldone=yes
|
||||
else
|
||||
echo " invalid build detected"
|
||||
fi
|
||||
elif [ "$forcecompile" == "off" ] && [ "$(uname -s)" == "Linux" ]; then
|
||||
rm -r -f bin/ >> /dev/null 2>&1
|
||||
if [ `getconf LONG_BIT` = "64" ]; then
|
||||
echo -n "[3/3] Linux 64-bit PHP build available, downloading $LINUX_64_BUILD.tar.gz..."
|
||||
LINUX_BUILD=$LINUX_64_BUILD
|
||||
else
|
||||
echo -n "[3/3] Linux 32-bit PHP build available, downloading $LINUX_32_BUILD.tar.gz..."
|
||||
LINUX_BUILD=$LINUX_32_BUILD
|
||||
fi
|
||||
download_file "http://sourceforge.net/projects/pocketmine/files/builds/$LINUX_BUILD.tar.gz" | tar -zx > /dev/null 2>&1
|
||||
chmod +x ./bin/php5/bin/*
|
||||
echo -n " checking..."
|
||||
if [ $(./bin/php5/bin/php -r 'echo "yes";' 2>/dev/null) == "yes" ]; then
|
||||
echo -n " regenerating php.ini..."
|
||||
OPCACHE_PATH="$(find $(pwd) -name opcache.so)"
|
||||
echo "zend_extension=\"$OPCACHE_PATH\"" > "./bin/php5/bin/php.ini"
|
||||
echo "opcache.enable=1" >> "./bin/php5/bin/php.ini"
|
||||
echo "opcache.enable_cli=1" >> "./bin/php5/bin/php.ini"
|
||||
echo "opcache.save_comments=0" >> "./bin/php5/bin/php.ini"
|
||||
echo "opcache.fast_shutdown=1" >> "./bin/php5/bin/php.ini"
|
||||
echo "opcache.max_accelerated_files=4096" >> "./bin/php5/bin/php.ini"
|
||||
echo "opcache.interned_strings_buffer=8" >> "./bin/php5/bin/php.ini"
|
||||
echo "opcache.memory_consumption=128" >> "./bin/php5/bin/php.ini"
|
||||
echo "opcache.optimization_level=0xffffffff" >> "./bin/php5/bin/php.ini"
|
||||
echo "date.timezone=$TIMEZONE" >> "./bin/php5/bin/php.ini"
|
||||
echo "short_open_tag=0" >> "./bin/php5/bin/php.ini"
|
||||
echo "asp_tags=0" >> "./bin/php5/bin/php.ini"
|
||||
echo " done"
|
||||
alldone=yes
|
||||
else
|
||||
echo " invalid build detected"
|
||||
fi
|
||||
fi
|
||||
if [ "$alldone" == "no" ]; then
|
||||
set -e
|
||||
echo "[3/3] no build found, compiling PHP"
|
||||
exec ./src/build/compile.sh
|
||||
|
@ -1,6 +1,7 @@
|
||||
#!/bin/bash -x
|
||||
export PATH=/opt/arm-2013.05/bin:/opt/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin:/opt/arm-unknown-linux-uclibcgnueabi/bin:$PATH
|
||||
export PATH="/opt/arm-2013.05/bin:/opt/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin:/opt/arm-unknown-linux-uclibcgnueabi/bin:$PATH"
|
||||
export THREADS=2
|
||||
PHP_VERSION="5.5.9"
|
||||
|
||||
#Needed to use aliases
|
||||
shopt -s expand_aliases
|
||||
@ -31,9 +32,10 @@ then
|
||||
mkdir -p {$COMPILEDIR,$ARCHIVE}/linux/32bit
|
||||
cd $COMPILEDIR/linux/32bit
|
||||
|
||||
CFLAGS=-m32 march=i686 mtune=generic $SCRIPT
|
||||
OPENSSL_TARGET="linux-generic32" CFLAGS="-m32" march=i386 mtune=none $SCRIPT linux openssl
|
||||
|
||||
cp -r $COMPILEDIR/linux/32bit/{install.log,bin/*,install_data/*} $ARCHIVE/linux/32bit/
|
||||
tar -czf PHP_${PHP_VERSION}_x86_Linux.tar.gz bin/
|
||||
cp -r $COMPILEDIR/linux/32bit/{install.log,PHP_${PHP_VERSION}_x86_Linux.tar.gz,install_data/*} $ARCHIVE/linux/32bit/
|
||||
if [ ! -f $COMPILEDIR/linux/32bit/bin/php5/bin/php ]; then
|
||||
exit 1
|
||||
fi
|
||||
@ -44,18 +46,19 @@ then
|
||||
mkdir -p {$COMPILEDIR,$ARCHIVE}/linux/64bit
|
||||
cd $COMPILEDIR/linux/64bit
|
||||
|
||||
$SCRIPT
|
||||
OPENSSL_TARGET="linux-x86_64" CFLAGS="-m64" march=x86-64 mtune=none $SCRIPT linux openssl
|
||||
|
||||
cp -r $COMPILEDIR/linux/64bit/{install.log,bin/*,install_data/*} $ARCHIVE/linux/64bit/
|
||||
tar -czf PHP_${PHP_VERSION}_x86-64_Linux.tar.gz bin/
|
||||
cp -r $COMPILEDIR/linux/64bit/{install.log,PHP_${PHP_VERSION}_x86-64_Linux.tar.gz,install_data/*} $ARCHIVE/linux/64bit/
|
||||
if [ ! -f $COMPILEDIR/linux/64bit/bin/php5/bin/php ]; then
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$COMPILE_MAC" = "true" ];
|
||||
if [ "$COMPILE_MAC_32" = "true" ];
|
||||
then
|
||||
mkdir -p {$COMPILEDIR,$ARCHIVE}/mac
|
||||
cd $COMPILEDIR/mac
|
||||
mkdir -p {$COMPILEDIR,$ARCHIVE}/mac32
|
||||
cd $COMPILEDIR/mac32
|
||||
|
||||
curl -L http://ftpmirror.gnu.org/libtool/libtool-2.4.2.tar.gz | tar -xz > /dev/null
|
||||
cd libtool-2.4.2
|
||||
@ -68,8 +71,32 @@ then
|
||||
export LIBTOOLIZE="$COMPILEDIR/mac/libtool/bin/libtoolize"
|
||||
$SCRIPT mac curl
|
||||
|
||||
cp -r $COMPILEDIR/mac/{install.log,bin/*,install_data/*} $ARCHIVE/mac/
|
||||
if [ ! -f $COMPILEDIR/mac/bin/php5/bin/php ]; then
|
||||
tar -czf PHP_${PHP_VERSION}_x86_MacOS.tar.gz bin/
|
||||
cp -r $COMPILEDIR/mac32/{install.log,PHP_${PHP_VERSION}_x86_MacOS.tar.gz,install_data/*} $ARCHIVE/mac32/
|
||||
if [ ! -f $COMPILEDIR/mac32/bin/php5/bin/php ]; then
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$COMPILE_MAC_64" = "true" ];
|
||||
then
|
||||
mkdir -p {$COMPILEDIR,$ARCHIVE}/mac64
|
||||
cd $COMPILEDIR/mac64
|
||||
|
||||
curl -L http://ftpmirror.gnu.org/libtool/libtool-2.4.2.tar.gz | tar -xz > /dev/null
|
||||
cd libtool-2.4.2
|
||||
./configure --prefix="$COMPILEDIR/mac/libtool" > /dev/null
|
||||
make > /dev/null
|
||||
make install
|
||||
cd ../
|
||||
rm -rf libtool-2.4.2
|
||||
export LIBTOOL="$COMPILEDIR/mac/libtool/bin/libtool"
|
||||
export LIBTOOLIZE="$COMPILEDIR/mac/libtool/bin/libtoolize"
|
||||
$SCRIPT mac64 curl
|
||||
|
||||
tar -czf PHP_${PHP_VERSION}_x86-64_MacOS.tar.gz bin/
|
||||
cp -r $COMPILEDIR/mac64/{install.log,PHP_${PHP_VERSION}_x86-64_MacOS.tar.gz,install_data/*} $ARCHIVE/mac64
|
||||
if [ ! -f $COMPILEDIR/mac64/bin/php5/bin/php ]; then
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
@ -81,7 +108,8 @@ then
|
||||
|
||||
$SCRIPT rpi
|
||||
|
||||
cp -r $COMPILEDIR/rpi/{install.log,bin/*,install_data/*} $ARCHIVE/rpi/
|
||||
tar -czf PHP_${PHP_VERSION}_ARM_Raspbian_hard.tar.gz bin/
|
||||
cp -r $COMPILEDIR/rpi/{install.log,PHP_${PHP_VERSION}_ARM_Raspbian_hard.tar.gz,install_data/*} $ARCHIVE/rpi/
|
||||
if [ ! -f $COMPILEDIR/rpi/bin/php5/bin/php ]; then
|
||||
exit 1
|
||||
fi
|
||||
@ -94,7 +122,8 @@ then
|
||||
|
||||
$SCRIPT crosscompile android-armv6
|
||||
|
||||
cp -r $COMPILEDIR/crosscompile/android-armv6/{install.log,bin/*,install_data/*} $ARCHIVE/crosscompile/android-armv6/
|
||||
tar -czf PHP_${PHP_VERSION}_ARMv6_Android.tar.gz bin/
|
||||
cp -r $COMPILEDIR/crosscompile/android-armv6/{install.log,PHP_${PHP_VERSION}_ARMv6_Android.tar.gz,install_data/*} $ARCHIVE/crosscompile/android-armv6/
|
||||
if [ ! -f $COMPILEDIR/crosscompile/android-armv6/bin/php5/bin/php ]; then
|
||||
exit 1
|
||||
fi
|
||||
@ -107,7 +136,8 @@ then
|
||||
|
||||
$SCRIPT crosscompile android-armv7
|
||||
|
||||
cp -r $COMPILEDIR/crosscompile/android-armv7/{install.log,bin/*,install_data/*} $ARCHIVE/crosscompile/android-armv7/
|
||||
tar -czf PHP_${PHP_VERSION}_ARMv7_Android.tar.gz bin/
|
||||
cp -r $COMPILEDIR/crosscompile/android-armv7/{install.log,PHP_${PHP_VERSION}_ARMv7_Android.tar.gz,install_data/*} $ARCHIVE/crosscompile/android-armv7/
|
||||
if [ ! -f $COMPILEDIR/crosscompile/android-armv7/bin/php5/bin/php ]; then
|
||||
exit 1
|
||||
fi
|
||||
@ -162,7 +192,8 @@ then
|
||||
|
||||
$SCRIPT crosscompile rpi
|
||||
|
||||
cp -r $COMPILEDIR/crosscompile/rpi/{install.log,bin/*,install_data/*} $ARCHIVE/crosscompile/rpi/
|
||||
tar -czf PHP_${PHP_VERSION}_ARM_Raspbian_hard.tar.gz bin/
|
||||
cp -r $COMPILEDIR/crosscompile/rpi/{install.log,PHP_${PHP_VERSION}_ARM_Raspbian_hard.tar.gz,install_data/*} $ARCHIVE/crosscompile/rpi/
|
||||
if [ ! -f $COMPILEDIR/crosscompile/rpi/bin/php5/bin/php ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
@ -22,7 +22,6 @@
|
||||
abstract class EventHandler{
|
||||
|
||||
public static function callEvent(BaseEvent $event){
|
||||
$status = BaseEvent::NORMAL;
|
||||
foreach($event::$handlerPriority as $priority => $handlerList){
|
||||
if(count($handlerList) > 0){
|
||||
$event->setPrioritySlot($priority);
|
||||
|
@ -139,7 +139,7 @@ function arguments ( $args ){
|
||||
$args = array();
|
||||
}
|
||||
array_shift( $args );
|
||||
$args = join( $args, ' ' );
|
||||
$args = implode(' ', $args);
|
||||
|
||||
preg_match_all('/ (--[\w\-]+ (?:[= ] [^-\s]+ )? ) | (-\w+) | (\w+) /x', $args, $match );
|
||||
$args = array_shift( $match );
|
||||
@ -157,7 +157,7 @@ function arguments ( $args ){
|
||||
|
||||
$value = preg_split( '/[= ]/', $arg, 2 );
|
||||
$com = substr( array_shift($value), 2 );
|
||||
$value = join($value);
|
||||
$value = implode($value);
|
||||
|
||||
$ret['commands'][$com] = !empty($value) ? $value : true;
|
||||
continue;
|
||||
|
@ -41,7 +41,7 @@ class SignPostBlock extends TransparentBlock{
|
||||
return true;
|
||||
}else{
|
||||
$this->meta = $faces[$face];
|
||||
$this->level->setBlock($block, BlockAPI::get(WALL_SIGN, $this->meta, true, false, true));
|
||||
$this->level->setBlock($block, BlockAPI::get(WALL_SIGN, $this->meta), true, false, true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,7 @@
|
||||
class TallGrassBlock extends FlowableBlock{
|
||||
public function __construct($meta = 1){
|
||||
parent::__construct(TALL_GRASS, $meta, "Tall Grass");
|
||||
//$this->isReplaceable = true;
|
||||
$this->isReplaceable = true;
|
||||
$names = array(
|
||||
0 => "Dead Shrub",
|
||||
1 => "Tall Grass",
|
||||
|
@ -43,7 +43,6 @@ class SpawnEggItem extends Item{
|
||||
--$this->count;
|
||||
}
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -30,7 +30,6 @@ class MinecraftInterface{
|
||||
exit(1);
|
||||
}
|
||||
$this->bandwidth = array(0, 0, microtime(true));
|
||||
$this->start = microtime(true);
|
||||
$this->packets = array();
|
||||
}
|
||||
|
||||
@ -90,7 +89,7 @@ class MinecraftInterface{
|
||||
if(EventHandler::callEvent(new PacketSendEvent($packet)) === BaseEvent::DENY){
|
||||
return 0;
|
||||
}elseif($packet instanceof RakNetPacket){
|
||||
$codec = new RakNetCodec($packet);
|
||||
new RakNetCodec($packet);
|
||||
}
|
||||
$write = $this->socket->write($packet->buffer, $packet->ip, $packet->port);
|
||||
$this->bandwidth[1] += $write;
|
||||
|
@ -22,7 +22,7 @@
|
||||
|
||||
|
||||
class UDPSocket{
|
||||
public $connected, $sock, $server;
|
||||
public $connected, $sock, $server, $port;
|
||||
function __construct($server, $port, $listen = false, $serverip = "0.0.0.0"){
|
||||
$this->server = $server;
|
||||
$this->port = $port;
|
||||
|
@ -21,6 +21,7 @@
|
||||
|
||||
class RakNetCodec{
|
||||
public $packet;
|
||||
private $buffer;
|
||||
public function __construct(RakNetPacket $packet){
|
||||
$this->packet = $packet;
|
||||
$this->buffer =& $this->packet->buffer;
|
||||
|
@ -76,8 +76,8 @@ abstract class RakNetDataPacket extends stdClass{
|
||||
$this->buffer .= Utils::writeLong($v);
|
||||
}
|
||||
|
||||
protected function getInt($unsigned = false){
|
||||
return Utils::readInt($this->get(4), $unsigned);
|
||||
protected function getInt(){
|
||||
return Utils::readInt($this->get(4));
|
||||
}
|
||||
|
||||
protected function putInt($v){
|
||||
|
@ -50,8 +50,8 @@ class RakNetParser{
|
||||
return Utils::readLong($this->get(8), $unsigned);
|
||||
}
|
||||
|
||||
private function getInt($unsigned = false){
|
||||
return Utils::readInt($this->get(4), $unsigned);
|
||||
private function getInt(){
|
||||
return Utils::readInt($this->get(4));
|
||||
}
|
||||
|
||||
private function getShort($unsigned = false){
|
||||
|
@ -95,7 +95,7 @@ class PMFLevel extends PMF{
|
||||
}
|
||||
|
||||
private function createBlank(){
|
||||
$this->saveData(false);
|
||||
$this->saveData();
|
||||
@mkdir(dirname($this->file)."/chunks/", 0755);
|
||||
if(!file_exists(dirname($this->file)."/entities.yml")){
|
||||
$entities = new Config(dirname($this->file)."/entities.yml", CONFIG_YAML);
|
||||
@ -169,12 +169,12 @@ class PMFLevel extends PMF{
|
||||
}
|
||||
|
||||
public static function getIndex($X, $Z){
|
||||
return ($Z << 16) | ($X < 0 ? (~--$X & 0x7fff) | 0x1000 : $X & 0xFFFF);
|
||||
return ($Z << 16) | ($X < 0 ? (~--$X & 0x7fff) | 0x8000 : $X & 0x7fff);
|
||||
}
|
||||
|
||||
public static function getXZ($index, &$X = null, &$Z = null){
|
||||
$Z = $index >> 16;
|
||||
$X = $index & 0xFFFF;
|
||||
$X = ($index & 0x8000) === 0x8000 ? -($index & 0x7fff) : $index & 0x7fff;
|
||||
return array($X, $Z);
|
||||
}
|
||||
|
||||
@ -218,20 +218,19 @@ class PMFLevel extends PMF{
|
||||
}
|
||||
|
||||
public function loadChunk($X, $Z){
|
||||
$X = (int) $X;
|
||||
$Z = (int) $Z;
|
||||
$index = self::getIndex($X, $Z);
|
||||
if($this->isChunkLoaded($X, $Z)){
|
||||
return true;
|
||||
}
|
||||
$index = self::getIndex($X, $Z);
|
||||
$path = $this->getChunkPath($X, $Z);
|
||||
if(!file_exists($path)){
|
||||
if($this->generateChunk($X, $Z) === false){
|
||||
return false;
|
||||
}elseif($this->isGenerating === 0){
|
||||
$this->populateChunk($X, $Z);
|
||||
return true;
|
||||
}
|
||||
if($this->isGenerating === 0){
|
||||
$this->populateChunk($X, $Z);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
$chunk = @gzopen($path, "rb");
|
||||
|
@ -76,7 +76,6 @@ class Config{
|
||||
*/
|
||||
public function __construct($file, $type = CONFIG_DETECT, $default = array(), &$correct = null){
|
||||
$this->load($file, $type, $default);
|
||||
$correct = $this->check();
|
||||
}
|
||||
|
||||
public function reload(){
|
||||
@ -84,7 +83,6 @@ class Config{
|
||||
unset($this->correct);
|
||||
unset($this->type);
|
||||
$this->load($this->file);
|
||||
$correct = $this->check();
|
||||
}
|
||||
|
||||
public function fixYAMLIndexes($str){
|
||||
@ -141,7 +139,6 @@ class Config{
|
||||
default:
|
||||
$this->correct = false;
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
if(!is_array($this->config)){
|
||||
$this->config = $default;
|
||||
|
@ -107,7 +107,7 @@ class NBT{
|
||||
}
|
||||
|
||||
public function writeTAG_FLOAT($v){
|
||||
$this->binary .= Utils::writeLFloar($v);
|
||||
$this->binary .= Utils::writeLFloat($v);
|
||||
}
|
||||
|
||||
public function writeTAG_DOUBLE($v){
|
||||
|
@ -620,7 +620,7 @@ class Utils{
|
||||
}
|
||||
|
||||
public static function writeLLong($value){
|
||||
return strrev(Utils::writeLong($str));
|
||||
return strrev(Utils::writeLong($value));
|
||||
}
|
||||
|
||||
|
||||
|
@ -33,6 +33,7 @@ class VersionString{
|
||||
private $release;
|
||||
private $minor;
|
||||
private $development = false;
|
||||
private $generation;
|
||||
public function __construct($version = MAJOR_VERSION){
|
||||
if(is_int($version)){
|
||||
$this->minor = $version & 0x1F;
|
||||
|
@ -87,7 +87,7 @@ class AsyncMultipleQueue extends Thread{
|
||||
$d = array();
|
||||
for($c = 0; $c < $cnt; ++$c){
|
||||
$key = $this->get(Utils::readShort($this->get(2), false));
|
||||
$d[$key] = $this->get(Utils::readInt($this->get(4), false));
|
||||
$d[$key] = $this->get(Utils::readInt($this->get(4)));
|
||||
}
|
||||
$res = (string) Utils::curl_post($url, $d, $timeout);
|
||||
$this->lock();
|
||||
|
@ -77,6 +77,10 @@ class Level{
|
||||
unset($this->usedChunks[$X.".".$Z][$player->CID]);
|
||||
}
|
||||
|
||||
public function isChunkPopulated($X, $Z){
|
||||
return $this->level->isPopulated($X, $Z);
|
||||
}
|
||||
|
||||
public function checkTime(){
|
||||
if(!isset($this->level)){
|
||||
return false;
|
||||
@ -138,8 +142,11 @@ class Level{
|
||||
if(count($c) === 0){
|
||||
unset($this->usedChunks[$i]);
|
||||
$X = explode(".", $i);
|
||||
$Z = array_pop($X);
|
||||
$this->level->unloadChunk((int) array_pop($X), (int) $Z, $this->server->saveEnabled);
|
||||
$Z = (int) array_pop($X);
|
||||
$X = (int) array_pop($X);
|
||||
if(!$this->isSpawnChunk($X, $Z)){
|
||||
$this->level->unloadChunk($X, $Z, $this->server->saveEnabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->save(false, false);
|
||||
@ -408,14 +415,24 @@ class Level{
|
||||
return $this->level->loadChunk($X, $Z);
|
||||
}
|
||||
|
||||
public function unloadChunk($X, $Z){
|
||||
public function unloadChunk($X, $Z, $force = false){
|
||||
if(!isset($this->level)){
|
||||
return false;
|
||||
}
|
||||
|
||||
if($force !== true and $this->isSpawnChunk($X, $Z)){
|
||||
return false;
|
||||
}
|
||||
Cache::remove("world:{$this->name}:$X:$Z");
|
||||
return $this->level->unloadChunk($X, $Z, $this->server->saveEnabled);
|
||||
}
|
||||
|
||||
public function isSpawnChunk($X, $Z){
|
||||
$spawnX = $this->level->getData("spawnX") >> 4;
|
||||
$spawnZ = $this->level->getData("spawnZ") >> 4;
|
||||
return abs($X - $spawnX) <= 1 and abs($Z - $spawnZ) <= 1;
|
||||
}
|
||||
|
||||
public function getOrderedChunk($X, $Z, $Yndex){
|
||||
if(!isset($this->level)){
|
||||
return false;
|
||||
|
@ -19,14 +19,19 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* WARNING: This code is old, and only supports the file format partially (reverse engineering)
|
||||
* It can break, lock, or hit you in the face in any moment.
|
||||
*
|
||||
*/
|
||||
|
||||
class PocketChunkParser{
|
||||
private $location, $raw = b"", $file;
|
||||
var $sectorLength = 4096; //16 * 16 * 16
|
||||
var $chunkLength = 86016; //21 * $sectorLength
|
||||
var $map;
|
||||
public $sectorLength = 4096; //16 * 16 * 16
|
||||
public $chunkLength = 86016; //21 * $sectorLength
|
||||
public $map = array();
|
||||
|
||||
function __construct(){
|
||||
$map = array();
|
||||
public function __construct(){
|
||||
}
|
||||
|
||||
private function loadLocationTable(){
|
||||
|
@ -31,6 +31,8 @@ class Tile extends Position{
|
||||
public $attach;
|
||||
public $metadata;
|
||||
public $closed;
|
||||
private $lastUpdate;
|
||||
private $scheduledUpdate;
|
||||
private $server;
|
||||
function __construct(Level $level, $id, $class, $x, $y, $z, $data = array()){
|
||||
$this->server = ServerAPI::request();
|
||||
|
@ -80,6 +80,7 @@ class NormalGenerator implements LevelGenerator{
|
||||
public function generateChunk($chunkX, $chunkZ){
|
||||
$this->random->setSeed(0xdeadbeef ^ ($chunkX << 8) ^ $chunkZ ^ $this->level->getSeed());
|
||||
$hills = array();
|
||||
$patches = array();
|
||||
$patchesSmall = array();
|
||||
$base = array();
|
||||
for($z = 0; $z < 16; ++$z){
|
||||
|
@ -24,7 +24,7 @@ require_once("LevelGenerator.php");
|
||||
/***REM_END***/
|
||||
|
||||
class SuperflatGenerator implements LevelGenerator{
|
||||
private $level, $random, $structure, $chunks, $options, $floorLevel, $populators = array();
|
||||
private $level, $random, $structure, $chunks, $options, $floorLevel, $preset, $populators = array();
|
||||
|
||||
public function getSettings(){
|
||||
return $this->options;
|
||||
|
@ -20,7 +20,7 @@
|
||||
*/
|
||||
|
||||
class WorldGenerator{
|
||||
private $seed, $level, $path, $random, $generator, $width;
|
||||
private $seed, $level, $path, $random, $generator, $height;
|
||||
public function __construct(LevelGenerator $generator, $name, $seed = false, $height = 8){
|
||||
$this->seed = $seed !== false ? (int) $seed:Utils::readInt(Utils::getRandomBytes(4, false));
|
||||
$this->random = new Random($this->seed);
|
||||
@ -50,7 +50,7 @@ class WorldGenerator{
|
||||
|
||||
//Generate 4 chunks for spawning players
|
||||
for($Z = 7; $Z <= 8; ++$Z){
|
||||
for($X = 7; $X <= 8; ++$X){
|
||||
for($X = 7; $X <= 9; ++$X){
|
||||
$this->level->level->loadChunk($X, $Z);
|
||||
}
|
||||
}
|
||||
|
@ -1,108 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
abstract class OctaveGenerator{
|
||||
protected $octaves;
|
||||
protected $xScale = 1;
|
||||
protected $yScale = 1;
|
||||
protected $zScale = 1;
|
||||
|
||||
public function __construct(array $octaves){
|
||||
$this->octaves = $octaves;
|
||||
}
|
||||
|
||||
public function setScale($scale){
|
||||
$this->setXScale($scale);
|
||||
$this->setYScale($scale);
|
||||
$this->setZScale($scale);
|
||||
}
|
||||
|
||||
public function getXScale(){
|
||||
return $this->xScale;
|
||||
}
|
||||
|
||||
public function setXScale($scale){
|
||||
$this->xScale = $scale;
|
||||
}
|
||||
|
||||
public function getYScale(){
|
||||
return $this->yScale;
|
||||
}
|
||||
|
||||
public function setYScale($scale){
|
||||
$this->yScale = $scale;
|
||||
}
|
||||
|
||||
public function getZScale(){
|
||||
return $this->zScale;
|
||||
}
|
||||
|
||||
public function setZScale($scale){
|
||||
$this->zScale = $scale;
|
||||
}
|
||||
|
||||
public function getOctaves(){
|
||||
$array = array();
|
||||
foreach($this->octaves as $index => $value){
|
||||
$array[$index] = clone $value;
|
||||
}
|
||||
return $array;
|
||||
}
|
||||
|
||||
//1D-noise
|
||||
public function noise1D($x, $frequency, $amplitude, $normalized = false){
|
||||
return $this->noise3D($x, 0, 0, $frequency, $amplitude, $normalized);
|
||||
}
|
||||
|
||||
//2D-noise
|
||||
public function noise2D($x, $y, $frequency, $amplitude, $normalized = false){
|
||||
return $this->noise3D($x, $y, 0, $frequency, $amplitude, $normalized);
|
||||
}
|
||||
|
||||
//3D-noise
|
||||
public function noise3D($x, $y, $z, $frequency, $amplitude, $normalized = false){
|
||||
$result = 0;
|
||||
$amp = 1;
|
||||
$freq = 1;
|
||||
$max = 0;
|
||||
|
||||
$x *= $this->xScale;
|
||||
$y *= $this->yScale;
|
||||
$z *= $this->zScale;
|
||||
|
||||
foreach($this->octaves as $noiseGenerator){
|
||||
$result += $octave->noise($x * $freq, $y * $freq, $z * $freq) * $amp;
|
||||
$max += $amp;
|
||||
$freq *= $frequency;
|
||||
$amp *= $amplitude;
|
||||
}
|
||||
if($normalized === true){
|
||||
$result /= $max;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/*public function generateNoiseOctaves($x, $y, $z, $frequency, $amplitude){
|
||||
|
||||
}*/
|
||||
}
|
@ -1,63 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
/***REM_START***/
|
||||
require_once("OctaveGenerator.php");
|
||||
/***REM_END***/
|
||||
|
||||
class PerlinOctaveGenerator extends OctaveGenerator{
|
||||
public function __construct(Random $random, $octaves){
|
||||
$this->octaves = array();
|
||||
for($o = 0; $o < $octaves; ++$o){
|
||||
$this->octaves[$o] = new NoiseGeneratorPerlin($random);
|
||||
}
|
||||
}
|
||||
|
||||
/*public function generateNoiseOctaves($x, $y, $z, $sizeX, $sizeY, $sizeZ, $fX, $fY, $fZ){
|
||||
$adouble = array_fill(0, $sizeX * $sizeY * $sizeZ, 0.0);
|
||||
|
||||
$d3 = 1.0;
|
||||
|
||||
foreach($this->octaves as $octave){
|
||||
$dX = $x * $d3 * $fX;
|
||||
$dY = $y * $d3 * $fY;
|
||||
$dZ = $x * $d3 * $fZ;
|
||||
|
||||
$x1 = NoiseGenerator::floor($dX);
|
||||
$z1 = NoiseGenerator::floor($dZ);
|
||||
|
||||
$dX -= $x1;
|
||||
$dZ -= $z1;
|
||||
|
||||
$x1 %= 16777216;
|
||||
$z1 %= 16777216;
|
||||
//$x1 &= 0xFFFFFF;
|
||||
//$z1 &= 0xFFFFFF;
|
||||
|
||||
$dX += $x1;
|
||||
$dZ += $z1;
|
||||
$octave->populateNoiseArray($adouble, $dX, $dY, $dZ, $sizeX, $sizeY, $sizeZ, $fX * $d3, $fY * $d3, $fZ * $d3, $d3);
|
||||
$d3 *= 0.5;
|
||||
}
|
||||
|
||||
return $adouble;
|
||||
}*/
|
||||
}
|
@ -55,7 +55,7 @@ class SpruceTreeObject extends TreeObject{
|
||||
|
||||
public function placeObject(Level $level, Vector3 $pos, Random $random){
|
||||
if($this->leavesBottomY === -1 or $this->leavesMaxRadius === -1) {
|
||||
$this->findRandomLeavesSize();
|
||||
$this->findRandomLeavesSize($random);
|
||||
}
|
||||
$level->setBlockRaw(new Vector3($pos->x, $pos->y - 1, $pos->z), new DirtBlock());
|
||||
$leavesRadius = 0;
|
||||
|
@ -47,8 +47,8 @@ class TreeObject{
|
||||
$tree = new SmallTreeObject();
|
||||
$tree->type = SaplingBlock::JUNGLE;
|
||||
break;
|
||||
default:
|
||||
case SaplingBlock::OAK:
|
||||
default:
|
||||
/*if($random->nextRange(0, 9) === 0){
|
||||
$tree = new BigTreeObject();
|
||||
}else{*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user