mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 00:33:59 +00:00
Lots of typos fixed, undefined variables, unused code
This commit is contained in:
parent
3d3111fef6
commit
f1b5f83fd4
@ -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;
|
||||
}
|
||||
|
@ -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,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)));
|
||||
}
|
||||
|
@ -222,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){
|
||||
@ -328,7 +327,7 @@ class Player{
|
||||
$this->chunksLoaded = array();
|
||||
$this->chunksOrder = array();
|
||||
$this->chunkCount = array();
|
||||
$this->cratingItems = array();
|
||||
$this->craftingItems = array();
|
||||
$this->received = array();
|
||||
}
|
||||
}
|
||||
@ -698,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;
|
||||
}
|
||||
@ -1377,8 +1375,8 @@ class Player{
|
||||
$inv[] = array($item[0], $item[1], 1);
|
||||
}
|
||||
}
|
||||
$this->data->set("inventory", $inv);
|
||||
}
|
||||
$this->data->set("inventory", $inv);
|
||||
}
|
||||
$this->achievements = $this->data->get("achievements");
|
||||
$this->data->set("caseusername", $this->username);
|
||||
@ -2007,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;
|
||||
@ -2374,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;
|
||||
}
|
||||
@ -2382,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;
|
||||
|
@ -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, $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,7 +54,6 @@ class PocketMinecraftServer{
|
||||
$this->schedule = array();
|
||||
$this->scheduleCnt = 1;
|
||||
$this->description = "";
|
||||
$this->whitelist = false;
|
||||
$this->memoryStats = array();
|
||||
$this->clients = array();
|
||||
$this->spawn = false;
|
||||
@ -129,7 +125,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 +312,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];
|
||||
|
@ -51,7 +51,7 @@ elif [ "$1" == "mac" ]; then
|
||||
[ -z "$march" ] && march=prescott;
|
||||
[ -z "$mtune" ] && mtune=generic;
|
||||
[ -z "$CFLAGS" ] && CFLAGS="-m32 -arch i386 -fomit-frame-pointer";
|
||||
[ -z "$LDFLAGS" ] && LDFLAGS="-undefined dynamic_lookup -Wl,-rpath,@loader_path/../lib";
|
||||
[ -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"
|
||||
@ -59,7 +59,7 @@ elif [ "$1" == "mac64" ]; then
|
||||
[ -z "$march" ] && march=core2;
|
||||
[ -z "$mtune" ] && mtune=generic;
|
||||
[ -z "$CFLAGS" ] && CFLAGS="-m64 -arch x86_64 -fomit-frame-pointer";
|
||||
[ -z "$LDFLAGS" ] && LDFLAGS="-undefined dynamic_lookup -Wl,-rpath,@loader_path/../lib";
|
||||
[ -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"
|
||||
|
@ -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);
|
||||
|
@ -140,7 +140,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 );
|
||||
@ -158,7 +158,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;
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
|
@ -43,8 +43,16 @@ class Entity 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;
|
||||
@ -526,8 +534,8 @@ class Entity 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 Entity 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 Entity 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 Entity 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;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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