diff --git a/PocketMine-MP.php b/PocketMine-MP.php index 8f735f2aa..248ba8eaf 100644 --- a/PocketMine-MP.php +++ b/PocketMine-MP.php @@ -19,347 +19,354 @@ * */ -namespace PocketMine; - -const VERSION = "Alpha_1.4dev"; -const API_VERSION = "1.0.0"; -const CODENAME = "絶好(Zekkou)ケーキ(Cake)"; -const MINECRAFT_VERSION = "v0.8.1 alpha"; -const PHP_VERSION = "5.5"; - -\spl_autoload_register(function ($load){ - $path = explode('\\', trim($load, '\\')); - if(($parent = array_shift($path)) === "PocketMine"){ //part of the PocketMine-MP code - $className = array_pop($path); - if(count($path) > 0){ - $path = implode(DIRECTORY_SEPARATOR, array_map("strtolower", $path)) . DIRECTORY_SEPARATOR; - }else{ - $path = ""; - } - $fPath = \PocketMine\PATH . "src" . DIRECTORY_SEPARATOR . $path . $className . ".php"; - if(file_exists($fPath)){ - require_once($fPath); - } - }else{ //Try plugin - $className = array_pop($path); - if(count($path) > 0){ - $path = implode(DIRECTORY_SEPARATOR, array_map("strtolower", $path)) . DIRECTORY_SEPARATOR; - }else{ - $path = ""; - } - $fPath = \PocketMine\PATH . "plugins". DIRECTORY_SEPARATOR . $parent . DIRECTORY_SEPARATOR . "src" . DIRECTORY_SEPARATOR . $path . $className . ".php"; - if(file_exists($fPath)){ - require_once($fPath); - } +namespace{ + function console($message, $EOL = true, $log = true, $level = 1){ + return PocketMine\console($message, $EOL, $log, $level); } -}); +} -define("PocketMine\PATH", realpath(dirname(__FILE__)) . DIRECTORY_SEPARATOR); +namespace PocketMine{ + const VERSION = "Alpha_1.4dev"; + const API_VERSION = "1.0.0"; + const CODENAME = "絶好(Zekkou)ケーキ(Cake)"; + const MINECRAFT_VERSION = "v0.8.1 alpha"; + const PHP_VERSION = "5.5"; -//Startup code. Do not look at it, it can harm you. Most of them are hacks to fix date-related bugs, or basic functions used after this + \spl_autoload_register(function ($load){ + $path = explode('\\', trim($load, '\\')); + if(($parent = array_shift($path)) === "PocketMine"){ //part of the PocketMine-MP code + $className = array_pop($path); + if(count($path) > 0){ + $path = implode(DIRECTORY_SEPARATOR, array_map("strtolower", $path)) . DIRECTORY_SEPARATOR; + }else{ + $path = ""; + } + $fPath = \PocketMine\PATH . "src" . DIRECTORY_SEPARATOR . $path . $className . ".php"; + if(file_exists($fPath)){ + require_once($fPath); + } + }else{ //Try plugin + $className = array_pop($path); + if(count($path) > 0){ + $path = implode(DIRECTORY_SEPARATOR, array_map("strtolower", $path)) . DIRECTORY_SEPARATOR; + }else{ + $path = ""; + } + $fPath = \PocketMine\PATH . "plugins". DIRECTORY_SEPARATOR . $parent . DIRECTORY_SEPARATOR . "src" . DIRECTORY_SEPARATOR . $path . $className . ".php"; + if(file_exists($fPath)){ + require_once($fPath); + } + } + }); -set_time_limit(0); //Who set it to 30 seconds?!?! + define("PocketMine\PATH", realpath(dirname(__FILE__)) . DIRECTORY_SEPARATOR); -if(ini_get("date.timezone") == ""){ //No Timezone set - date_default_timezone_set("GMT"); - if(strpos(" ".strtoupper(php_uname("s")), " WIN") !== false){ - $time = time(); - $time -= $time % 60; - //TODO: Parse different time & date formats by region. ¬¬ world - //Example: USA - exec("time.exe /T", $hour); - $i = array_map("intval", explode(":", trim($hour[0]))); - exec("date.exe /T", $date); - $j = array_map("intval", explode(substr($date[0], 2, 1), trim($date[0]))); - $offset = round((mktime($i[0], $i[1], 0, $j[1], $j[0], $j[2]) - $time) / 60) * 60; - }else{ - exec("date +%s", $t); - $offset = round((intval(trim($t[0])) - time()) / 60) * 60; - } + //Startup code. Do not look at it, it can harm you. Most of them are hacks to fix date-related bugs, or basic functions used after this - $daylight = (int) date("I"); - $d = timezone_name_from_abbr("", $offset, $daylight); - @ini_set("date.timezone", $d); - date_default_timezone_set($d); -}else{ - $d = @date_default_timezone_get(); - if(strpos($d, "/") === false){ - $d = timezone_name_from_abbr($d); + set_time_limit(0); //Who set it to 30 seconds?!?! + + if(ini_get("date.timezone") == ""){ //No Timezone set + date_default_timezone_set("GMT"); + if(strpos(" ".strtoupper(php_uname("s")), " WIN") !== false){ + $time = time(); + $time -= $time % 60; + //TODO: Parse different time & date formats by region. ¬¬ world + //Example: USA + exec("time.exe /T", $hour); + $i = array_map("intval", explode(":", trim($hour[0]))); + exec("date.exe /T", $date); + $j = array_map("intval", explode(substr($date[0], 2, 1), trim($date[0]))); + $offset = round((mktime($i[0], $i[1], 0, $j[1], $j[0], $j[2]) - $time) / 60) * 60; + }else{ + exec("date +%s", $t); + $offset = round((intval(trim($t[0])) - time()) / 60) * 60; + } + + $daylight = (int) date("I"); + $d = timezone_name_from_abbr("", $offset, $daylight); @ini_set("date.timezone", $d); date_default_timezone_set($d); - } -} - -gc_enable(); -error_reporting(E_ALL | E_STRICT); -ini_set("allow_url_fopen", 1); -ini_set("display_errors", 1); -ini_set("display_startup_errors", 1); -ini_set("default_charset", "utf-8"); - -ini_set("memory_limit", "128M"); //Default -define("PocketMine\START_TIME", microtime(true)); - -$opts = getopt("", array("enable-ansi", "disable-ansi", "data-path:", "no-wizard")); -define("PocketMine\DATA", isset($opts["data-path"]) ? realpath($opts["data-path"]) . DIRECTORY_SEPARATOR : PATH); - -if((strpos(strtoupper(php_uname("s")), "WIN") or isset($opts["enable-ansi"])) and !isset($opts["disable-ansi"])){ - define("PocketMine\ANSI", true); -}else{ - define("PocketMine\ANSI", false); -} - -function dummy(){ - -} - -function safe_var_dump($var, $cnt = 0){ - switch(true){ - case is_array($var): - echo str_repeat(" ", $cnt)."array(".count($var).") {".PHP_EOL; - foreach($var as $key => $value){ - echo str_repeat(" ", $cnt + 1)."[".(is_integer($key) ? $key:'"'.$key.'"')."]=>".PHP_EOL; - safe_var_dump($value, $cnt + 1); - } - echo str_repeat(" ", $cnt)."}".PHP_EOL; - break; - case is_integer($var): - echo str_repeat(" ", $cnt)."int(".$var.")".PHP_EOL; - break; - case is_float($var): - echo str_repeat(" ", $cnt)."float(".$var.")".PHP_EOL; - break; - case is_bool($var): - echo str_repeat(" ", $cnt)."bool(".($var === true ? "true":"false").")".PHP_EOL; - break; - case is_string($var): - echo str_repeat(" ", $cnt)."string(".strlen($var).") \"$var\"".PHP_EOL; - break; - case is_resource($var): - echo str_repeat(" ", $cnt)."resource() of type (".get_resource_type($var).")".PHP_EOL; - break; - case is_object($var): - echo str_repeat(" ", $cnt)."object(".get_class($var).")".PHP_EOL; - break; - case is_null($var): - echo str_repeat(" ", $cnt)."NULL".PHP_EOL; - break; - } -} - -function kill($pid){ - switch(Utils\Utils::getOS()){ - case "win": - exec("taskkill.exe /F /PID ".((int) $pid)." > NUL"); - break; - case "mac": - case "linux": - default: - exec("kill -9 ".((int) $pid)." > /dev/null 2>&1"); - } -} - -function hard_unset(&$var){ - if(is_object($var)){ - $unset = new \ReflectionClass($var); - foreach($unset->getProperties() as $prop){ - $prop->setAccessible(true); - @hard_unset($prop->getValue($var)); - $prop->setValue($var, null); - } - $var = null; - unset($var); - }elseif(is_array($var)){ - foreach($var as $i => $v){ - hard_unset($var[$i]); - } - $var = null; - unset($var); }else{ - $var = null; - unset($var); - } -} - -function console($message, $EOL = true, $log = true, $level = 1){ - if(!defined("DEBUG") or DEBUG >= $level){ - $message .= $EOL === true ? PHP_EOL:""; - $time = (ANSI === true ? Utils\TextFormat::AQUA . date("H:i:s") . Utils\TextFormat::RESET:date("H:i:s")) . " "; - $replaced = Utils\TextFormat::clean(preg_replace('/\x1b\[[0-9;]*m/', "", $time . $message)); - if($log === true and (!defined("LOG") or LOG === true)){ - log(date("Y-m-d")." ".$replaced, "console", false, $level); + $d = @date_default_timezone_get(); + if(strpos($d, "/") === false){ + $d = timezone_name_from_abbr($d); + @ini_set("date.timezone", $d); + date_default_timezone_set($d); } - if(ANSI === true){ - $add = ""; - if(preg_match("/\[([a-zA-Z0-9]*)\]/", $message, $matches) > 0){ - switch($matches[1]){ - case "ERROR": - case "SEVERE": - $add .= Utils\TextFormat::RED; - break; - case "INTERNAL": - case "DEBUG": - $add .= Utils\TextFormat::GRAY; - break; - case "WARNING": - $add .= Utils\TextFormat::YELLOW; - break; - case "NOTICE": - $add .= Utils\TextFormat::AQUA; - break; - default: - $add = ""; - break; + } + + gc_enable(); + error_reporting(E_ALL | E_STRICT); + ini_set("allow_url_fopen", 1); + ini_set("display_errors", 1); + ini_set("display_startup_errors", 1); + ini_set("default_charset", "utf-8"); + + ini_set("memory_limit", "128M"); //Default + define("PocketMine\START_TIME", microtime(true)); + + $opts = getopt("", array("enable-ansi", "disable-ansi", "data-path:", "no-wizard")); + define("PocketMine\DATA", isset($opts["data-path"]) ? realpath($opts["data-path"]) . DIRECTORY_SEPARATOR : PATH); + + if((strpos(strtoupper(php_uname("s")), "WIN") or isset($opts["enable-ansi"])) and !isset($opts["disable-ansi"])){ + define("PocketMine\ANSI", true); + }else{ + define("PocketMine\ANSI", false); + } + + function dummy(){ + + } + + function safe_var_dump($var, $cnt = 0){ + switch(true){ + case is_array($var): + echo str_repeat(" ", $cnt)."array(".count($var).") {".PHP_EOL; + foreach($var as $key => $value){ + echo str_repeat(" ", $cnt + 1)."[".(is_integer($key) ? $key:'"'.$key.'"')."]=>".PHP_EOL; + safe_var_dump($value, $cnt + 1); + } + echo str_repeat(" ", $cnt)."}".PHP_EOL; + break; + case is_integer($var): + echo str_repeat(" ", $cnt)."int(".$var.")".PHP_EOL; + break; + case is_float($var): + echo str_repeat(" ", $cnt)."float(".$var.")".PHP_EOL; + break; + case is_bool($var): + echo str_repeat(" ", $cnt)."bool(".($var === true ? "true":"false").")".PHP_EOL; + break; + case is_string($var): + echo str_repeat(" ", $cnt)."string(".strlen($var).") \"$var\"".PHP_EOL; + break; + case is_resource($var): + echo str_repeat(" ", $cnt)."resource() of type (".get_resource_type($var).")".PHP_EOL; + break; + case is_object($var): + echo str_repeat(" ", $cnt)."object(".get_class($var).")".PHP_EOL; + break; + case is_null($var): + echo str_repeat(" ", $cnt)."NULL".PHP_EOL; + break; + } + } + + function kill($pid){ + switch(Utils\Utils::getOS()){ + case "win": + exec("taskkill.exe /F /PID ".((int) $pid)." > NUL"); + break; + case "mac": + case "linux": + default: + exec("kill -9 ".((int) $pid)." > /dev/null 2>&1"); + } + } + + function hard_unset(&$var){ + if(is_object($var)){ + $unset = new \ReflectionClass($var); + foreach($unset->getProperties() as $prop){ + $prop->setAccessible(true); + @hard_unset($prop->getValue($var)); + $prop->setValue($var, null); + } + $var = null; + unset($var); + }elseif(is_array($var)){ + foreach($var as $i => $v){ + hard_unset($var[$i]); + } + $var = null; + unset($var); + }else{ + $var = null; + unset($var); + } + } + + function console($message, $EOL = true, $log = true, $level = 1){ + if(!defined("DEBUG") or DEBUG >= $level){ + $message .= $EOL === true ? PHP_EOL:""; + $time = (ANSI === true ? Utils\TextFormat::AQUA . date("H:i:s") . Utils\TextFormat::RESET:date("H:i:s")) . " "; + $replaced = Utils\TextFormat::clean(preg_replace('/\x1b\[[0-9;]*m/', "", $time . $message)); + if($log === true and (!defined("LOG") or LOG === true)){ + log(date("Y-m-d")." ".$replaced, "console", false, $level); + } + if(ANSI === true){ + $add = ""; + if(preg_match("/\[([a-zA-Z0-9]*)\]/", $message, $matches) > 0){ + switch($matches[1]){ + case "ERROR": + case "SEVERE": + $add .= Utils\TextFormat::RED; + break; + case "INTERNAL": + case "DEBUG": + $add .= Utils\TextFormat::GRAY; + break; + case "WARNING": + $add .= Utils\TextFormat::YELLOW; + break; + case "NOTICE": + $add .= Utils\TextFormat::AQUA; + break; + default: + $add = ""; + break; + } + } + $message = Utils\TextFormat::toANSI($time . $add . $message . Utils\TextFormat::RESET); + }else{ + $message = $replaced; + } + echo $message; + } + } + + function getTrace($start = 1){ + $e = new \Exception(); + $trace = $e->getTrace(); + $messages = array(); + $j = 0; + for($i = (int) $start; isset($trace[$i]); ++$i, ++$j){ + $params = ""; + if(isset($trace[$i]["args"])){ + foreach($trace[$i]["args"] as $name => $value){ + $params .= (is_object($value) ? get_class($value)." ".(method_exists($value, "__toString") ? $value->__toString() : "object"):gettype($value)." ".@strval($value)).", "; } } - $message = Utils\TextFormat::toANSI($time . $add . $message . Utils\TextFormat::RESET); - }else{ - $message = $replaced; + $messages[] = "#$j ".(isset($trace[$i]["file"]) ? $trace[$i]["file"]:"")."(".(isset($trace[$i]["line"]) ? $trace[$i]["line"]:"")."): ".(isset($trace[$i]["class"]) ? $trace[$i]["class"].$trace[$i]["type"]:"").$trace[$i]["function"]."(".substr($params, 0, -2).")"; } - echo $message; + return $messages; } -} -function getTrace($start = 1){ - $e = new \Exception(); - $trace = $e->getTrace(); - $messages = array(); - $j = 0; - for($i = (int) $start; isset($trace[$i]); ++$i, ++$j){ - $params = ""; - if(isset($trace[$i]["args"])){ - foreach($trace[$i]["args"] as $name => $value){ - $params .= (is_object($value) ? get_class($value)." ".(method_exists($value, "__toString") ? $value->__toString() : "object"):gettype($value)." ".@strval($value)).", "; + function error_handler($errno, $errstr, $errfile, $errline){ + if(error_reporting() === 0){ //@ error-control + return false; + } + $errorConversion = array( + E_ERROR => "E_ERROR", + E_WARNING => "E_WARNING", + E_PARSE => "E_PARSE", + E_NOTICE => "E_NOTICE", + E_CORE_ERROR => "E_CORE_ERROR", + E_CORE_WARNING => "E_CORE_WARNING", + E_COMPILE_ERROR => "E_COMPILE_ERROR", + E_COMPILE_WARNING => "E_COMPILE_WARNING", + E_USER_ERROR => "E_USER_ERROR", + E_USER_WARNING => "E_USER_WARNING", + E_USER_NOTICE => "E_USER_NOTICE", + E_STRICT => "E_STRICT", + E_RECOVERABLE_ERROR => "E_RECOVERABLE_ERROR", + E_DEPRECATED => "E_DEPRECATED", + E_USER_DEPRECATED => "E_USER_DEPRECATED", + ); + $errno = isset($errorConversion[$errno]) ? $errorConversion[$errno]:$errno; + console("[ERROR] A ".$errno." error happened: \"$errstr\" in \"$errfile\" at line $errline", true, true, 0); + foreach(getTrace() as $i => $line){ + console("[TRACE] $line"); + } + return true; + } + + function log($message, $name, $EOL = true, $level = 2, $close = false){ + global $fpointers; + if((!defined("DEBUG") or DEBUG >= $level) and (!defined("LOG") or LOG === true)){ + $message .= $EOL === true ? PHP_EOL:""; + if(!isset($fpointers)){ + $fpointers = array(); + } + if(!isset($fpointers[$name]) or $fpointers[$name] === false){ + $fpointers[$name] = @fopen(\PocketMine\DATA."/".$name.".log", "ab"); + } + @fwrite($fpointers[$name], $message); + if($close === true){ + fclose($fpointers[$name]); + unset($fpointers[$name]); } } - $messages[] = "#$j ".(isset($trace[$i]["file"]) ? $trace[$i]["file"]:"")."(".(isset($trace[$i]["line"]) ? $trace[$i]["line"]:"")."): ".(isset($trace[$i]["class"]) ? $trace[$i]["class"].$trace[$i]["type"]:"").$trace[$i]["function"]."(".substr($params, 0, -2).")"; } - return $messages; -} - -function error_handler($errno, $errstr, $errfile, $errline){ - if(error_reporting() === 0){ //@ error-control - return false; - } - $errorConversion = array( - E_ERROR => "E_ERROR", - E_WARNING => "E_WARNING", - E_PARSE => "E_PARSE", - E_NOTICE => "E_NOTICE", - E_CORE_ERROR => "E_CORE_ERROR", - E_CORE_WARNING => "E_CORE_WARNING", - E_COMPILE_ERROR => "E_COMPILE_ERROR", - E_COMPILE_WARNING => "E_COMPILE_WARNING", - E_USER_ERROR => "E_USER_ERROR", - E_USER_WARNING => "E_USER_WARNING", - E_USER_NOTICE => "E_USER_NOTICE", - E_STRICT => "E_STRICT", - E_RECOVERABLE_ERROR => "E_RECOVERABLE_ERROR", - E_DEPRECATED => "E_DEPRECATED", - E_USER_DEPRECATED => "E_USER_DEPRECATED", - ); - $errno = isset($errorConversion[$errno]) ? $errorConversion[$errno]:$errno; - console("[ERROR] A ".$errno." error happened: \"$errstr\" in \"$errfile\" at line $errline", true, true, 0); - foreach(getTrace() as $i => $line){ - console("[TRACE] $line"); - } - return true; -} - -function log($message, $name, $EOL = true, $level = 2, $close = false){ - global $fpointers; - if((!defined("DEBUG") or DEBUG >= $level) and (!defined("LOG") or LOG === true)){ - $message .= $EOL === true ? PHP_EOL:""; - if(!isset($fpointers)){ - $fpointers = array(); - } - if(!isset($fpointers[$name]) or $fpointers[$name] === false){ - $fpointers[$name] = @fopen(\PocketMine\DATA."/".$name.".log", "ab"); - } - @fwrite($fpointers[$name], $message); - if($close === true){ - fclose($fpointers[$name]); - unset($fpointers[$name]); - } - } -} -set_error_handler("\PocketMine\\error_handler", E_ALL); + set_error_handler("\PocketMine\\error_handler", E_ALL); -$errors = 0; + $errors = 0; -if(version_compare("5.4.0", PHP_VERSION) > 0){ - console("[ERROR] Use PHP >= 5.4.0", true, true, 0); - ++$errors; -} - -if(php_sapi_name() !== "cli"){ - console("[ERROR] You must run PocketMine-MP using the CLI.", true, true, 0); - ++$errors; -} - -if(!extension_loaded("sockets") and @dl((PHP_SHLIB_SUFFIX === "dll" ? "php_":"") . "sockets." . PHP_SHLIB_SUFFIX) === false){ - console("[ERROR] Unable to find the Socket extension.", true, true, 0); - ++$errors; -} - -if(!extension_loaded("pthreads") and @dl((PHP_SHLIB_SUFFIX === "dll" ? "php_":"") . "pthreads." . PHP_SHLIB_SUFFIX) === false){ - console("[ERROR] Unable to find the pthreads extension.", true, true, 0); - ++$errors; -}else{ - $pthreads_version = phpversion("pthreads"); - if(substr_count($pthreads_version, ".") < 2){ - $pthreads_version = "0.$pthreads_version"; - } - if(version_compare($pthreads_version, "0.1.0") < 0){ - console("[ERROR] pthreads >= 0.1.0 is required, while you have $pthreads_version.", true, true, 0); + if(version_compare("5.4.0", PHP_VERSION) > 0){ + console("[ERROR] Use PHP >= 5.4.0", true, true, 0); ++$errors; } -} -if(!extension_loaded("curl") and @dl((PHP_SHLIB_SUFFIX === "dll" ? "php_":"") . "curl." . PHP_SHLIB_SUFFIX) === false){ - console("[ERROR] Unable to find the cURL extension.", true, true, 0); - ++$errors; -} + if(php_sapi_name() !== "cli"){ + console("[ERROR] You must run PocketMine-MP using the CLI.", true, true, 0); + ++$errors; + } -if(!extension_loaded("sqlite3") and @dl((PHP_SHLIB_SUFFIX === "dll" ? "php_":"") . "sqlite3." . PHP_SHLIB_SUFFIX) === false){ - console("[ERROR] Unable to find the SQLite3 extension.", true, true, 0); - ++$errors; -} + if(!extension_loaded("sockets") and @dl((PHP_SHLIB_SUFFIX === "dll" ? "php_":"") . "sockets." . PHP_SHLIB_SUFFIX) === false){ + console("[ERROR] Unable to find the Socket extension.", true, true, 0); + ++$errors; + } -if(!extension_loaded("yaml") and @dl((PHP_SHLIB_SUFFIX === "dll" ? "php_":"") . "yaml." . PHP_SHLIB_SUFFIX) === false){ - console("[ERROR] Unable to find the YAML extension.", true, true, 0); - ++$errors; -} + if(!extension_loaded("pthreads") and @dl((PHP_SHLIB_SUFFIX === "dll" ? "php_":"") . "pthreads." . PHP_SHLIB_SUFFIX) === false){ + console("[ERROR] Unable to find the pthreads extension.", true, true, 0); + ++$errors; + }else{ + $pthreads_version = phpversion("pthreads"); + if(substr_count($pthreads_version, ".") < 2){ + $pthreads_version = "0.$pthreads_version"; + } + if(version_compare($pthreads_version, "0.1.0") < 0){ + console("[ERROR] pthreads >= 0.1.0 is required, while you have $pthreads_version.", true, true, 0); + ++$errors; + } + } -if(!extension_loaded("zlib") and @dl((PHP_SHLIB_SUFFIX === "dll" ? "php_":"") . "zlib." . PHP_SHLIB_SUFFIX) === false){ - console("[ERROR] Unable to find the Zlib extension.", true, true, 0); - ++$errors; -} + if(!extension_loaded("curl") and @dl((PHP_SHLIB_SUFFIX === "dll" ? "php_":"") . "curl." . PHP_SHLIB_SUFFIX) === false){ + console("[ERROR] Unable to find the cURL extension.", true, true, 0); + ++$errors; + } -if($errors > 0){ - console("[ERROR] Please use the installer provided on the homepage, or recompile PHP again.", true, true, 0); - exit(1); //Exit with error -} + if(!extension_loaded("sqlite3") and @dl((PHP_SHLIB_SUFFIX === "dll" ? "php_":"") . "sqlite3." . PHP_SHLIB_SUFFIX) === false){ + console("[ERROR] Unable to find the SQLite3 extension.", true, true, 0); + ++$errors; + } -$gitsha1 = false; -if(file_exists(\PocketMine\PATH . ".git/refs/heads/master")){ //Found Git information! - define("PocketMine\GIT_COMMIT", strtolower(trim(file_get_contents(\PocketMine\PATH .".git/refs/heads/master")))); -}else{ //Unknown :( - define("PocketMine\GIT_COMMIT", str_repeat("00", 20)); -} + if(!extension_loaded("yaml") and @dl((PHP_SHLIB_SUFFIX === "dll" ? "php_":"") . "yaml." . PHP_SHLIB_SUFFIX) === false){ + console("[ERROR] Unable to find the YAML extension.", true, true, 0); + ++$errors; + } -ini_set("opcache.mmap_base", bin2hex(Utils\Utils::getRandomBytes(8, false))); //Fix OPCache address errors + if(!extension_loaded("zlib") and @dl((PHP_SHLIB_SUFFIX === "dll" ? "php_":"") . "zlib." . PHP_SHLIB_SUFFIX) === false){ + console("[ERROR] Unable to find the Zlib extension.", true, true, 0); + ++$errors; + } -require_once(\PocketMine\PATH . "src/utils/pthreads.php"); + if($errors > 0){ + console("[ERROR] Please use the installer provided on the homepage, or recompile PHP again.", true, true, 0); + exit(1); //Exit with error + } -if(!file_exists(\PocketMine\DATA . "server.properties") and !isset($opts["no-wizard"])){ - $installer = new Wizard\Installer(); -} + $gitsha1 = false; + if(file_exists(\PocketMine\PATH . ".git/refs/heads/master")){ //Found Git information! + define("PocketMine\GIT_COMMIT", strtolower(trim(file_get_contents(\PocketMine\PATH .".git/refs/heads/master")))); + }else{ //Unknown :( + define("PocketMine\GIT_COMMIT", str_repeat("00", 20)); + } -$server = new ServerAPI(); -$server->start(); + ini_set("opcache.mmap_base", bin2hex(Utils\Utils::getRandomBytes(8, false))); //Fix OPCache address errors -kill(getmypid()); //Fix for ConsoleAPI being blocked -exit(0); + require_once(\PocketMine\PATH . "src/utils/pthreads.php"); + + if(!file_exists(\PocketMine\DATA . "server.properties") and !isset($opts["no-wizard"])){ + $installer = new Wizard\Installer(); + } + + $server = new ServerAPI(); + $server->start(); + + kill(getmypid()); //Fix for ConsoleAPI being blocked + exit(0); + +} \ No newline at end of file diff --git a/src/BlockAPI.php b/src/BlockAPI.php index a1dbc9cd6..b460b7223 100644 --- a/src/BlockAPI.php +++ b/src/BlockAPI.php @@ -37,196 +37,196 @@ class BlockAPI{ private $randomUpdates = array(); public static $creative = array( //Building - [ItemItem::STONE, 0], - [ItemItem::COBBLESTONE, 0], - [ItemItem::STONE_BRICKS, 0], - [ItemItem::STONE_BRICKS, 1], - [ItemItem::STONE_BRICKS, 2], - [ItemItem::MOSS_STONE, 0], - [ItemItem::WOODEN_PLANKS, 0], - [ItemItem::WOODEN_PLANKS, 1], - [ItemItem::WOODEN_PLANKS, 2], - [ItemItem::WOODEN_PLANKS, 3], - [ItemItem::BRICKS, 0], + [Item::STONE, 0], + [Item::COBBLESTONE, 0], + [Item::STONE_BRICKS, 0], + [Item::STONE_BRICKS, 1], + [Item::STONE_BRICKS, 2], + [Item::MOSS_STONE, 0], + [Item::WOODEN_PLANKS, 0], + [Item::WOODEN_PLANKS, 1], + [Item::WOODEN_PLANKS, 2], + [Item::WOODEN_PLANKS, 3], + [Item::BRICKS, 0], - [ItemItem::DIRT, 0], - [ItemItem::GRASS, 0], - [ItemItem::CLAY_BLOCK, 0], - [ItemItem::SANDSTONE, 0], - [ItemItem::SANDSTONE, 1], - [ItemItem::SANDSTONE, 2], - [ItemItem::SAND, 0], - [ItemItem::GRAVEL, 0], - [ItemItem::TRUNK, 0], - [ItemItem::TRUNK, 1], - [ItemItem::TRUNK, 2], - [ItemItem::TRUNK, 3], - [ItemItem::NETHER_BRICKS, 0], - [ItemItem::NETHERRACK, 0], - [ItemItem::BEDROCK, 0], - [ItemItem::COBBLESTONE_STAIRS, 0], - [ItemItem::OAK_WOODEN_STAIRS, 0], - [ItemItem::SPRUCE_WOODEN_STAIRS, 0], - [ItemItem::BIRCH_WOODEN_STAIRS, 0], - [ItemItem::JUNGLE_WOODEN_STAIRS, 0], - [ItemItem::BRICK_STAIRS, 0], - [ItemItem::SANDSTONE_STAIRS, 0], - [ItemItem::STONE_BRICK_STAIRS, 0], - [ItemItem::NETHER_BRICKS_STAIRS, 0], - [ItemItem::QUARTZ_STAIRS, 0], - [ItemItem::SLAB, 0], - [ItemItem::SLAB, 1], - [ItemItem::WOODEN_SLAB, 0], - [ItemItem::WOODEN_SLAB, 1], - [ItemItem::WOODEN_SLAB, 2], - [ItemItem::WOODEN_SLAB, 3], - [ItemItem::SLAB, 3], - [ItemItem::SLAB, 4], - [ItemItem::SLAB, 5], - [ItemItem::SLAB, 6], - [ItemItem::QUARTZ_BLOCK, 0], - [ItemItem::QUARTZ_BLOCK, 1], - [ItemItem::QUARTZ_BLOCK, 2], - [ItemItem::COAL_ORE, 0], - [ItemItem::IRON_ORE, 0], - [ItemItem::GOLD_ORE, 0], - [ItemItem::DIAMOND_ORE, 0], - [ItemItem::LAPIS_ORE, 0], - [ItemItem::REDSTONE_ORE, 0], - [ItemItem::OBSIDIAN, 0], - [ItemItem::ICE, 0], - [ItemItem::SNOW_BLOCK, 0], + [Item::DIRT, 0], + [Item::GRASS, 0], + [Item::CLAY_BLOCK, 0], + [Item::SANDSTONE, 0], + [Item::SANDSTONE, 1], + [Item::SANDSTONE, 2], + [Item::SAND, 0], + [Item::GRAVEL, 0], + [Item::TRUNK, 0], + [Item::TRUNK, 1], + [Item::TRUNK, 2], + [Item::TRUNK, 3], + [Item::NETHER_BRICKS, 0], + [Item::NETHERRACK, 0], + [Item::BEDROCK, 0], + [Item::COBBLESTONE_STAIRS, 0], + [Item::OAK_WOODEN_STAIRS, 0], + [Item::SPRUCE_WOODEN_STAIRS, 0], + [Item::BIRCH_WOODEN_STAIRS, 0], + [Item::JUNGLE_WOODEN_STAIRS, 0], + [Item::BRICK_STAIRS, 0], + [Item::SANDSTONE_STAIRS, 0], + [Item::STONE_BRICK_STAIRS, 0], + [Item::NETHER_BRICKS_STAIRS, 0], + [Item::QUARTZ_STAIRS, 0], + [Item::SLAB, 0], + [Item::SLAB, 1], + [Item::WOODEN_SLAB, 0], + [Item::WOODEN_SLAB, 1], + [Item::WOODEN_SLAB, 2], + [Item::WOODEN_SLAB, 3], + [Item::SLAB, 3], + [Item::SLAB, 4], + [Item::SLAB, 5], + [Item::SLAB, 6], + [Item::QUARTZ_BLOCK, 0], + [Item::QUARTZ_BLOCK, 1], + [Item::QUARTZ_BLOCK, 2], + [Item::COAL_ORE, 0], + [Item::IRON_ORE, 0], + [Item::GOLD_ORE, 0], + [Item::DIAMOND_ORE, 0], + [Item::LAPIS_ORE, 0], + [Item::REDSTONE_ORE, 0], + [Item::OBSIDIAN, 0], + [Item::ICE, 0], + [Item::SNOW_BLOCK, 0], //Decoration - [ItemItem::COBBLESTONE_WALL, 0], - [ItemItem::COBBLESTONE_WALL, 1], - [ItemItem::GOLD_BLOCK, 0], - [ItemItem::IRON_BLOCK, 0], - [ItemItem::DIAMOND_BLOCK, 0], - [ItemItem::LAPIS_BLOCK, 0], - [ItemItem::COAL_BLOCK, 0], - [ItemItem::SNOW_LAYER, 0], - [ItemItem::GLASS, 0], - [ItemItem::GLOWSTONE_BLOCK, 0], - [ItemItem::NETHER_REACTOR, 0], - [ItemItem::WOOL, 0], - [ItemItem::WOOL, 7], - [ItemItem::WOOL, 6], - [ItemItem::WOOL, 5], - [ItemItem::WOOL, 4], - [ItemItem::WOOL, 3], - [ItemItem::WOOL, 2], - [ItemItem::WOOL, 1], - [ItemItem::WOOL, 15], - [ItemItem::WOOL, 14], - [ItemItem::WOOL, 13], - [ItemItem::WOOL, 12], - [ItemItem::WOOL, 11], - [ItemItem::WOOL, 10], - [ItemItem::WOOL, 9], - [ItemItem::WOOL, 8], - [ItemItem::LADDER, 0], - [ItemItem::SPONGE, 0], - [ItemItem::GLASS_PANE, 0], - [ItemItem::WOODEN_DOOR, 0], - [ItemItem::TRAPDOOR, 0], - [ItemItem::FENCE, 0], - [ItemItem::FENCE_GATE, 0], - [ItemItem::IRON_BARS, 0], - [ItemItem::BED, 0], - [ItemItem::BOOKSHELF, 0], - [ItemItem::PAINTING, 0], - [ItemItem::WORKBENCH, 0], - [ItemItem::STONECUTTER, 0], - [ItemItem::CHEST, 0], - [ItemItem::FURNACE, 0], - [ItemItem::DANDELION, 0], - [ItemItem::CYAN_FLOWER, 0], - [ItemItem::BROWN_MUSHROOM, 0], - [ItemItem::RED_MUSHROOM, 0], - [ItemItem::CACTUS, 0], - [ItemItem::MELON_BLOCK, 0], - [ItemItem::PUMPKIN, 0], - [ItemItem::LIT_PUMPKIN, 0], - [ItemItem::COBWEB, 0], - [ItemItem::HAY_BALE, 0], - [ItemItem::TALL_GRASS, 1], - [ItemItem::TALL_GRASS, 2], - [ItemItem::DEAD_BUSH, 0], - [ItemItem::SAPLING, 0], - [ItemItem::SAPLING, 1], - [ItemItem::SAPLING, 2], - [ItemItem::SAPLING, 3], - [ItemItem::LEAVES, 0], - [ItemItem::LEAVES, 1], - [ItemItem::LEAVES, 2], - [ItemItem::LEAVES, 3], - [ItemItem::CAKE, 0], - [ItemItem::SIGN, 0], - [ItemItem::CARPET, 0], - [ItemItem::CARPET, 7], - [ItemItem::CARPET, 6], - [ItemItem::CARPET, 5], - [ItemItem::CARPET, 4], - [ItemItem::CARPET, 3], - [ItemItem::CARPET, 2], - [ItemItem::CARPET, 1], - [ItemItem::CARPET, 15], - [ItemItem::CARPET, 14], - [ItemItem::CARPET, 13], - [ItemItem::CARPET, 12], - [ItemItem::CARPET, 11], - [ItemItem::CARPET, 10], - [ItemItem::CARPET, 9], - [ItemItem::CARPET, 8], + [Item::COBBLESTONE_WALL, 0], + [Item::COBBLESTONE_WALL, 1], + [Item::GOLD_BLOCK, 0], + [Item::IRON_BLOCK, 0], + [Item::DIAMOND_BLOCK, 0], + [Item::LAPIS_BLOCK, 0], + [Item::COAL_BLOCK, 0], + [Item::SNOW_LAYER, 0], + [Item::GLASS, 0], + [Item::GLOWSTONE_BLOCK, 0], + [Item::NETHER_REACTOR, 0], + [Item::WOOL, 0], + [Item::WOOL, 7], + [Item::WOOL, 6], + [Item::WOOL, 5], + [Item::WOOL, 4], + [Item::WOOL, 3], + [Item::WOOL, 2], + [Item::WOOL, 1], + [Item::WOOL, 15], + [Item::WOOL, 14], + [Item::WOOL, 13], + [Item::WOOL, 12], + [Item::WOOL, 11], + [Item::WOOL, 10], + [Item::WOOL, 9], + [Item::WOOL, 8], + [Item::LADDER, 0], + [Item::SPONGE, 0], + [Item::GLASS_PANE, 0], + [Item::WOODEN_DOOR, 0], + [Item::TRAPDOOR, 0], + [Item::FENCE, 0], + [Item::FENCE_GATE, 0], + [Item::IRON_BARS, 0], + [Item::BED, 0], + [Item::BOOKSHELF, 0], + [Item::PAINTING, 0], + [Item::WORKBENCH, 0], + [Item::STONECUTTER, 0], + [Item::CHEST, 0], + [Item::FURNACE, 0], + [Item::DANDELION, 0], + [Item::CYAN_FLOWER, 0], + [Item::BROWN_MUSHROOM, 0], + [Item::RED_MUSHROOM, 0], + [Item::CACTUS, 0], + [Item::MELON_BLOCK, 0], + [Item::PUMPKIN, 0], + [Item::LIT_PUMPKIN, 0], + [Item::COBWEB, 0], + [Item::HAY_BALE, 0], + [Item::TALL_GRASS, 1], + [Item::TALL_GRASS, 2], + [Item::DEAD_BUSH, 0], + [Item::SAPLING, 0], + [Item::SAPLING, 1], + [Item::SAPLING, 2], + [Item::SAPLING, 3], + [Item::LEAVES, 0], + [Item::LEAVES, 1], + [Item::LEAVES, 2], + [Item::LEAVES, 3], + [Item::CAKE, 0], + [Item::SIGN, 0], + [Item::CARPET, 0], + [Item::CARPET, 7], + [Item::CARPET, 6], + [Item::CARPET, 5], + [Item::CARPET, 4], + [Item::CARPET, 3], + [Item::CARPET, 2], + [Item::CARPET, 1], + [Item::CARPET, 15], + [Item::CARPET, 14], + [Item::CARPET, 13], + [Item::CARPET, 12], + [Item::CARPET, 11], + [Item::CARPET, 10], + [Item::CARPET, 9], + [Item::CARPET, 8], //Tools - //array(RAILS, 0), - //array(POWERED_RAILS, 0), - [ItemItem::TORCH, 0], - [ItemItem::BUCKET, 0], - [ItemItem::BUCKET, 8], - [ItemItem::BUCKET, 10], - [ItemItem::TNT, 0], - [ItemItem::IRON_HOE, 0], - [ItemItem::IRON_SWORD, 0], - [ItemItem::BOW, 0], - [ItemItem::SHEARS, 0], - [ItemItem::FLINT_AND_STEEL, 0], - [ItemItem::CLOCK, 0], - [ItemItem::COMPASS, 0], - [ItemItem::MINECART, 0], - array(SPAWN_EGG, MOB_CHICKEN), - array(SPAWN_EGG, MOB_COW), - array(SPAWN_EGG, MOB_PIG), - array(SPAWN_EGG, MOB_SHEEP), + //[Item::RAILS, 0], + //[Item::POWERED_RAILS, 0], + [Item::TORCH, 0], + [Item::BUCKET, 0], + [Item::BUCKET, 8], + [Item::BUCKET, 10], + [Item::TNT, 0], + [Item::IRON_HOE, 0], + [Item::IRON_SWORD, 0], + [Item::BOW, 0], + [Item::SHEARS, 0], + [Item::FLINT_AND_STEEL, 0], + [Item::CLOCK, 0], + [Item::COMPASS, 0], + [Item::MINECART, 0], + [Item::SPAWN_EGG, MOB_CHICKEN], + [Item::SPAWN_EGG, MOB_COW], + [Item::SPAWN_EGG, MOB_PIG], + [Item::SPAWN_EGG, MOB_SHEEP], //Seeds - [ItemItem::SUGARCANE, 0], - [ItemItem::WHEAT, 0], - [ItemItem::SEEDS, 0], - [ItemItem::MELON_SEEDS, 0], - [ItemItem::PUMPKIN_SEEDS, 0], - [ItemItem::CARROT, 0], - [ItemItem::POTATO, 0], - [ItemItem::BEETROOT_SEEDS, 0], - [ItemItem::EGG, 0], - [ItemItem::DYE, 0], - [ItemItem::DYE, 7], - [ItemItem::DYE, 6], - [ItemItem::DYE, 5], - [ItemItem::DYE, 4], - [ItemItem::DYE, 3], - [ItemItem::DYE, 2], - [ItemItem::DYE, 1], - [ItemItem::DYE, 15], - [ItemItem::DYE, 14], - [ItemItem::DYE, 13], - [ItemItem::DYE, 12], - [ItemItem::DYE, 11], - [ItemItem::DYE, 10], - [ItemItem::DYE, 9], - [ItemItem::DYE, 8], + [Item::SUGARCANE, 0], + [Item::WHEAT, 0], + [Item::SEEDS, 0], + [Item::MELON_SEEDS, 0], + [Item::PUMPKIN_SEEDS, 0], + [Item::CARROT, 0], + [Item::POTATO, 0], + [Item::BEETROOT_SEEDS, 0], + [Item::EGG, 0], + [Item::DYE, 0], + [Item::DYE, 7], + [Item::DYE, 6], + [Item::DYE, 5], + [Item::DYE, 4], + [Item::DYE, 3], + [Item::DYE, 2], + [Item::DYE, 1], + [Item::DYE, 15], + [Item::DYE, 14], + [Item::DYE, 13], + [Item::DYE, 12], + [Item::DYE, 11], + [Item::DYE, 10], + [Item::DYE, 9], + [Item::DYE, 8], ); diff --git a/src/LevelAPI.php b/src/LevelAPI.php index a09aecf19..8b5ebfb18 100644 --- a/src/LevelAPI.php +++ b/src/LevelAPI.php @@ -225,7 +225,7 @@ class LevelAPI{ switch($index){ case "Items": $tag = new Enum("Items", array()); - $tag->setTagType(NBT\TAG_Compound); + $tag->setTagType(NBT::TAG_Compound); foreach($data as $slot => $fields){ $tag[(int) $slot] = new Compound(false, array( "Count" => new Byte("Count", $fields["Count"]), diff --git a/src/Player.php b/src/Player.php index 8f68bcaa6..5462d6011 100644 --- a/src/Player.php +++ b/src/Player.php @@ -198,10 +198,10 @@ class Player extends RealHuman{ "NameTag" => new String("NameTag", $name), )); - $nbt->Pos->setTagType(NBT\TAG_Double); - $nbt->Inventory->setTagType(NBT\TAG_Compound); - $nbt->Motion->setTagType(NBT\TAG_Double); - $nbt->Rotation->setTagType(NBT\TAG_Float); + $nbt->Pos->setTagType(NBT::TAG_Double); + $nbt->Inventory->setTagType(NBT::TAG_Compound); + $nbt->Motion->setTagType(NBT::TAG_Double); + $nbt->Rotation->setTagType(NBT::TAG_Float); if(file_exists(\PocketMine\DATA . "players/" . $iname . ".yml")){ $data = new Config(\PocketMine\DATA . "players/" . $iname . ".yml", Config::YAML, array()); $nbt->playerGameType = (int) $data->get("gamemode"); @@ -257,7 +257,7 @@ class Player extends RealHuman{ } } else{ - $nbt = new NBT(NBT\BIG_ENDIAN); + $nbt = new NBT(NBT::BIG_ENDIAN); $nbt->read(file_get_contents(\PocketMine\DATA . "players/" . $iname . ".dat")); $nbt = $nbt->getData(); } @@ -269,7 +269,7 @@ class Player extends RealHuman{ public static function saveOffline($name, Compound $nbtTag){ ServerAPI::request()->handle("player.offline.save", $nbtTag); - $nbt = new NBT(NBT\BIG_ENDIAN); + $nbt = new NBT(NBT::BIG_ENDIAN); $nbt->setData($nbtTag); file_put_contents(\PocketMine\DATA . "players/" . strtolower($name) . ".dat", $nbt->write()); } @@ -1855,25 +1855,25 @@ class Player extends RealHuman{ switch($packet->event){ case 9: //Eating $items = array( - ItemItem::APPLE => 4, - ItemItem::MUSHROOM_STEW => 10, - ItemItem::BEETROOT_SOUP => 10, - ItemItem::BREAD => 5, - ItemItem::RAW_PORKCHOP => 3, - ItemItem::COOKED_PORKCHOP => 8, - ItemItem::RAW_BEEF => 3, - ItemItem::STEAK => 8, - ItemItem::COOKED_CHICKEN => 6, - ItemItem::RAW_CHICKEN => 2, - ItemItem::MELON_SLICE => 2, - ItemItem::GOLDEN_APPLE => 10, - ItemItem::PUMPKIN_PIE => 8, - ItemItem::CARROT => 4, - ItemItem::POTATO => 1, - ItemItem::BAKED_POTATO => 6, - //ItemItem::COOKIE => 2, - //ItemItem::COOKED_FISH => 5, - //ItemItem::RAW_FISH => 2, + Item::APPLE => 4, + Item::MUSHROOM_STEW => 10, + Item::BEETROOT_SOUP => 10, + Item::BREAD => 5, + Item::RAW_PORKCHOP => 3, + Item::COOKED_PORKCHOP => 8, + Item::RAW_BEEF => 3, + Item::STEAK => 8, + Item::COOKED_CHICKEN => 6, + Item::RAW_CHICKEN => 2, + Item::MELON_SLICE => 2, + Item::GOLDEN_APPLE => 10, + Item::PUMPKIN_PIE => 8, + Item::CARROT => 4, + Item::POTATO => 1, + Item::BAKED_POTATO => 6, + //Item::COOKIE => 2, + //Item::COOKED_FISH => 5, + //Item::RAW_FISH => 2, ); $slot = $this->getSlot($this->slot); if($this->entity->getHealth() < 20 and isset($items[$slot->getID()])){ @@ -1888,7 +1888,7 @@ class Player extends RealHuman{ if($slot->getCount() <= 0){ $this->setSlot($this->slot, Item::get(AIR, 0, 0)); } - if($slot->getID() === ItemItem::MUSHROOM_STEW or $slot->getID() === ItemItem::BEETROOT_SOUP){ + if($slot->getID() === Item::MUSHROOM_STEW or $slot->getID() === Item::BEETROOT_SOUP){ $this->addItem(Item::get(BOWL, 0, 1)); } } @@ -2167,7 +2167,7 @@ class Player extends RealHuman{ if($t->namedtag->creator !== $this->username){ $t->spawnTo($this); } else{ - $nbt = new NBT(NBT\LITTLE_ENDIAN); + $nbt = new NBT(NBT::LITTLE_ENDIAN); $nbt->read($packet->namedtag); if($nbt->id !== Tile::SIGN){ $t->spawnTo($this); diff --git a/src/Server.php b/src/Server.php index fadd01cd1..dd144db02 100644 --- a/src/Server.php +++ b/src/Server.php @@ -119,7 +119,7 @@ class Server{ } $this->schedule(20 * 15, array($this, "checkTicks"), array(), true); $this->schedule(20 * 60, array($this, "checkMemory"), array(), true); - $this->schedule(20 * 45, "Cache::cleanup", array(), true); + $this->schedule(20 * 45, "PocketMine\\Utils\\Cache::cleanup", array(), true); $this->schedule(20, array($this, "asyncOperationChecker"), array(), true); } diff --git a/src/block/Air.php b/src/block/Air.php index 7a782a347..97e7a379e 100644 --- a/src/block/Air.php +++ b/src/block/Air.php @@ -25,7 +25,7 @@ use PocketMine; class Air extends Transparent{ public function __construct(){ - parent::__construct(AIR, 0, "Air"); + parent::__construct(self::AIR, 0, "Air"); $this->isActivable = false; $this->breakable = false; $this->isFlowable = true; diff --git a/src/block/Bed.php b/src/block/Bed.php index 285ecd906..fb356bb72 100644 --- a/src/block/Bed.php +++ b/src/block/Bed.php @@ -28,13 +28,13 @@ use PocketMine; class Bed extends Transparent{ public function __construct($type = 0){ - parent::__construct(BED_BLOCK, $type, "Bed Block"); + parent::__construct(self::BED_BLOCK, $type, "Bed Block"); $this->isActivable = true; $this->isFullBlock = false; $this->hardness = 1; } - public function onActivate(Item $item, Player $player){ + public function onActivate(Item $item, PocketMine\Player $player){ if(ServerAPI::request()->api->time->getPhase($player->level) !== "night"){ $pk = new ChatPacket; $pk->message = "You can only sleep at night"; @@ -76,7 +76,7 @@ class Bed extends Transparent{ return true; } - public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ + public function place(Item $item, PocketMine\Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ $down = $this->getSide(0); if($down->isTransparent === false){ $faces = array( @@ -100,7 +100,7 @@ class Bed extends Transparent{ return false; } - public function onBreak(Item $item, Player $player){ + public function onBreak(Item $item, PocketMine\Player $player){ $blockNorth = $this->getSide(2); //Gets the blocks around them $blockSouth = $this->getSide(3); $blockEast = $this->getSide(5); @@ -132,7 +132,7 @@ class Bed extends Transparent{ return true; } - public function getDrops(Item $item, Player $player){ + public function getDrops(Item $item, PocketMine\Player $player){ return array( array(BED, 0, 1), ); diff --git a/src/block/Bedrock.php b/src/block/Bedrock.php index 4c7119060..dc837323c 100644 --- a/src/block/Bedrock.php +++ b/src/block/Bedrock.php @@ -26,12 +26,12 @@ use PocketMine\Item\Item as Item; class Bedrock extends Solid{ public function __construct(){ - parent::__construct(BEDROCK, 0, "Bedrock"); + parent::__construct(self::BEDROCK, 0, "Bedrock"); $this->breakable = false; $this->hardness = 18000000; } - public function isBreakable(Item $item, Player $player){ + public function isBreakable(Item $item, PocketMine\Player $player){ if(($player->gamemode & 0x01) === 0x01){ return true; } diff --git a/src/block/Beetroot.php b/src/block/Beetroot.php index 0292e3d9e..f1370a5d7 100644 --- a/src/block/Beetroot.php +++ b/src/block/Beetroot.php @@ -26,12 +26,12 @@ use PocketMine\Item\Item as Item; class Beetroot extends Flowable{ public function __construct($meta = 0){ - parent::__construct(BEETROOT_BLOCK, $meta, "Beetroot Block"); + parent::__construct(self::BEETROOT_BLOCK, $meta, "Beetroot Block"); $this->isActivable = true; $this->hardness = 0; } - public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ + public function place(Item $item, PocketMine\Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ $down = $this->getSide(0); if($down->getID() === self::FARMLAND){ $this->level->setBlock($block, $this, true, false, true); @@ -42,8 +42,8 @@ class Beetroot extends Flowable{ return false; } - public function onActivate(Item $item, Player $player){ - if($item->getID() === ItemItem::DYE and $item->getMetadata() === 0x0F){ //Bonemeal + public function onActivate(Item $item, PocketMine\Player $player){ + if($item->getID() === Item::DYE and $item->getMetadata() === 0x0F){ //Bonemeal $this->meta = 0x07; $this->level->setBlock($this, $this, true, false, true); if(($player->gamemode & 0x01) === 0){ @@ -81,13 +81,13 @@ class Beetroot extends Flowable{ return false; } - public function getDrops(Item $item, Player $player){ + public function getDrops(Item $item, PocketMine\Player $player){ $drops = array(); if($this->meta >= 0x07){ - $drops[] = array(ItemItem::BEETROOT, 0, 1); - $drops[] = array(ItemItem::BEETROOT_SEEDS, 0, mt_rand(0, 3)); + $drops[] = array(Item::BEETROOT, 0, 1); + $drops[] = array(Item::BEETROOT_SEEDS, 0, mt_rand(0, 3)); } else{ - $drops[] = array(ItemItem::BEETROOT_SEEDS, 0, 1); + $drops[] = array(Item::BEETROOT_SEEDS, 0, 1); } return $drops; diff --git a/src/block/BirchWoodStairs.php b/src/block/BirchWoodStairs.php index 2b5eeb1a3..a99d2fa38 100644 --- a/src/block/BirchWoodStairs.php +++ b/src/block/BirchWoodStairs.php @@ -26,10 +26,10 @@ use PocketMine\Item\Item as Item; class BirchWoodStairs extends Stair{ public function __construct($meta = 0){ - parent::__construct(BIRCH_WOOD_STAIRS, $meta, "Birch Wood Stairs"); + parent::__construct(self::BIRCH_WOOD_STAIRS, $meta, "Birch Wood Stairs"); } - public function getDrops(Item $item, Player $player){ + public function getDrops(Item $item, PocketMine\Player $player){ return array( array($this->id, 0, 1), ); diff --git a/src/block/Block.php b/src/block/Block.php index d1252320c..9e1f11749 100644 --- a/src/block/Block.php +++ b/src/block/Block.php @@ -24,7 +24,10 @@ */ namespace PocketMine\Block; use PocketMine; +use PocketMine\Player as Player; +use PocketMine\Item\Item as Item; use PocketMine\Level\Position as Position; +use PocketMine\Level\Level as Level; abstract class Block extends Position{ const AIR = 0; @@ -224,131 +227,131 @@ abstract class Block extends Position{ public $z = 0; public static function init(){ - if(count(self::$init) === 0){ - self::$init = array( - AIR => new Air(), - STONE => new Stone(), - GRASS => new Grass(), - DIRT => new Dirt(), - COBBLESTONE => new Cobblestone(), - PLANKS => new Planks(), - SAPLING => new Sapling(), - BEDROCK => new Bedrock(), - WATER => new Water(), - STILL_WATER => new StillWater(), - LAVA => new Lava(), - STILL_LAVA => new StillLava(), - SAND => new Sand(), - GRAVEL => new Gravel(), - GOLD_ORE => new GoldOre(), - IRON_ORE => new IronOre(), - COAL_ORE => new CoalOre(), - WOOD => new Wood(), - LEAVES => new Leaves(), - SPONGE => new Sponge(), - GLASS => new Glass(), - LAPIS_ORE => new LapisOre(), - LAPIS_BLOCK => new Lapis(), - SANDSTONE => new Sandstone(), - BED_BLOCK => new Bed(), - COBWEB => new Cobweb(), - TALL_GRASS => new TallGrass(), - DEAD_BUSH => new DeadBush(), - WOOL => new Wool(), - DANDELION => new Dandelion(), - CYAN_FLOWER => new CyanFlower(), - BROWN_MUSHROOM => new BrownMushroom(), - RED_MUSHROOM => new RedMushRoom(), - GOLD_BLOCK => new Gold(), - IRON_BLOCK => new Iron(), - DOUBLE_SLAB => new DoubleSlab(), - SLAB => new Slab(), - BRICKS_BLOCK => new Bricks(), - TNT => new TNT(), - BOOKSHELF => new Bookshelf(), - MOSS_STONE => new MossStone(), - OBSIDIAN => new Obsidian(), - TORCH => new Torch(), - FIRE => new Fire(), + if(count(self::$list) === 0){ + self::$list = array( + self::AIR => new Air(), + self::STONE => new Stone(), + self::GRASS => new Grass(), + self::DIRT => new Dirt(), + self::COBBLESTONE => new Cobblestone(), + self::PLANKS => new Planks(), + self::SAPLING => new Sapling(), + self::BEDROCK => new Bedrock(), + self::WATER => new Water(), + self::STILL_WATER => new StillWater(), + self::LAVA => new Lava(), + self::STILL_LAVA => new StillLava(), + self::SAND => new Sand(), + self::GRAVEL => new Gravel(), + self::GOLD_ORE => new GoldOre(), + self::IRON_ORE => new IronOre(), + self::COAL_ORE => new CoalOre(), + self::WOOD => new Wood(), + self::LEAVES => new Leaves(), + self::SPONGE => new Sponge(), + self::GLASS => new Glass(), + self::LAPIS_ORE => new LapisOre(), + self::LAPIS_BLOCK => new Lapis(), + self::SANDSTONE => new Sandstone(), + self::BED_BLOCK => new Bed(), + self::COBWEB => new Cobweb(), + self::TALL_GRASS => new TallGrass(), + self::DEAD_BUSH => new DeadBush(), + self::WOOL => new Wool(), + self::DANDELION => new Dandelion(), + self::CYAN_FLOWER => new CyanFlower(), + self::BROWN_MUSHROOM => new BrownMushroom(), + self::RED_MUSHROOM => new RedMushRoom(), + self::GOLD_BLOCK => new Gold(), + self::IRON_BLOCK => new Iron(), + self::DOUBLE_SLAB => new DoubleSlab(), + self::SLAB => new Slab(), + self::BRICKS_BLOCK => new Bricks(), + self::TNT => new TNT(), + self::BOOKSHELF => new Bookshelf(), + self::MOSS_STONE => new MossStone(), + self::OBSIDIAN => new Obsidian(), + self::TORCH => new Torch(), + self::FIRE => new Fire(), - WOOD_STAIRS => new WoodStairs(), - CHEST => new Chest(), + self::WOOD_STAIRS => new WoodStairs(), + self::CHEST => new Chest(), - DIAMOND_ORE => new DiamondOre(), - DIAMOND_BLOCK => new Diamond(), - WORKBENCH => new Workbench(), - WHEAT_BLOCK => new Wheat(), - FARMLAND => new Farmland(), - FURNACE => new Furnace(), - BURNING_FURNACE => new BurningFurnace(), - SIGN_POST => new SignPost(), - WOOD_DOOR_BLOCK => new WoodDoor(), - LADDER => new Ladder(), + self::DIAMOND_ORE => new DiamondOre(), + self::DIAMOND_BLOCK => new Diamond(), + self::WORKBENCH => new Workbench(), + self::WHEAT_BLOCK => new Wheat(), + self::FARMLAND => new Farmland(), + self::FURNACE => new Furnace(), + self::BURNING_FURNACE => new BurningFurnace(), + self::SIGN_POST => new SignPost(), + self::WOOD_DOOR_BLOCK => new WoodDoor(), + self::LADDER => new Ladder(), - COBBLESTONE_STAIRS => new CobblestoneStairs(), - WALL_SIGN => new WallSign(), + self::COBBLESTONE_STAIRS => new CobblestoneStairs(), + self::WALL_SIGN => new WallSign(), - IRON_DOOR_BLOCK => new IronDoor(), - REDSTONE_ORE => new RedstoneOre(), - GLOWING_REDSTONE_ORE => new GlowingRedstoneOre(), + self::IRON_DOOR_BLOCK => new IronDoor(), + self::REDSTONE_ORE => new RedstoneOre(), + self::GLOWING_REDSTONE_ORE => new GlowingRedstoneOre(), - SNOW_LAYER => new SnowLayer(), - ICE => new Ice(), - SNOW_BLOCK => new Snow(), - CACTUS => new Cactus(), - CLAY_BLOCK => new Clay(), - SUGARCANE_BLOCK => new Sugarcane(), + self::SNOW_LAYER => new SnowLayer(), + self::ICE => new Ice(), + self::SNOW_BLOCK => new Snow(), + self::CACTUS => new Cactus(), + self::CLAY_BLOCK => new Clay(), + self::SUGARCANE_BLOCK => new Sugarcane(), - FENCE => new Fence(), - PUMPKIN => new Pumpkin(), - NETHERRACK => new Netherrack(), - SOUL_SAND => new SoulSand(), - GLOWSTONE_BLOCK => new Glowstone(), + self::FENCE => new Fence(), + self::PUMPKIN => new Pumpkin(), + self::NETHERRACK => new Netherrack(), + self::SOUL_SAND => new SoulSand(), + self::GLOWSTONE_BLOCK => new Glowstone(), - LIT_PUMPKIN => new LitPumpkin(), - CAKE_BLOCK => new Cake(), + self::LIT_PUMPKIN => new LitPumpkin(), + self::CAKE_BLOCK => new Cake(), - TRAPDOOR => new Trapdoor(), + self::TRAPDOOR => new Trapdoor(), - STONE_BRICKS => new StoneBricks(), + self::STONE_BRICKS => new StoneBricks(), - IRON_BARS => new IronBars(), - GLASS_PANE => new GlassPane(), - MELON_BLOCK => new Melon(), - PUMPKIN_STEM => new PumpkinStem(), - MELON_STEM => new MelonStem(), + self::IRON_BARS => new IronBars(), + self::GLASS_PANE => new GlassPane(), + self::MELON_BLOCK => new Melon(), + self::PUMPKIN_STEM => new PumpkinStem(), + self::MELON_STEM => new MelonStem(), - FENCE_GATE => new FenceGate(), - BRICK_STAIRS => new BrickStairs(), - STONE_BRICK_STAIRS => new StoneBrickStairs(), + self::FENCE_GATE => new FenceGate(), + self::BRICK_STAIRS => new BrickStairs(), + self::STONE_BRICK_STAIRS => new StoneBrickStairs(), - NETHER_BRICKS => new NetherBricks(), + self::NETHER_BRICKS => new NetherBrick(), - NETHER_BRICKS_STAIRS => new NetherBricksStairs(), + self::NETHER_BRICKS_STAIRS => new NetherBrickStairs(), - SANDSTONE_STAIRS => new SandstoneStairs(), + self::SANDSTONE_STAIRS => new SandstoneStairs(), - SPRUCE_WOOD_STAIRS => new SpruceWoodStairs(), - BIRCH_WOOD_STAIRS => new BirchWoodStairs(), - JUNGLE_WOOD_STAIRS => new JungleWoodStairs(), - STONE_WALL => new StoneWall(), + self::SPRUCE_WOOD_STAIRS => new SpruceWoodStairs(), + self::BIRCH_WOOD_STAIRS => new BirchWoodStairs(), + self::JUNGLE_WOOD_STAIRS => new JungleWoodStairs(), + self::STONE_WALL => new StoneWall(), - CARROT_BLOCK => new Carrot(), - POTATO_BLOCK => new Potato(), + self::CARROT_BLOCK => new Carrot(), + self::POTATO_BLOCK => new Potato(), - QUARTZ_BLOCK => new Quartz(), - QUARTZ_STAIRS => new QuartzStairs(), - DOUBLE_WOOD_SLAB => new DoubleWoodSlab(), - WOOD_SLAB => new WoodSlab(), + self::QUARTZ_BLOCK => new Quartz(), + self::QUARTZ_STAIRS => new QuartzStairs(), + self::DOUBLE_WOOD_SLAB => new DoubleWoodSlab(), + self::WOOD_SLAB => new WoodSlab(), - HAY_BALE => new HayBale(), - CARPET => new Carpet(), + self::HAY_BALE => new HayBale(), + self::CARPET => new Carpet(), - COAL_BLOCK => new Coal(), + self::COAL_BLOCK => new Coal(), - BEETROOT_BLOCK => new Beetroot(), - STONECUTTER => new Stonecutter(), - GLOWING_OBSIDIAN => new GlowingObsidian(), + self::BEETROOT_BLOCK => new Beetroot(), + self::STONECUTTER => new Stonecutter(), + self::GLOWING_OBSIDIAN => new GlowingObsidian(), ); } } @@ -432,12 +435,12 @@ abstract class Block extends Position{ /** * Returns an array of Item objects to be dropped * - * @param ItemItem $item + * @param Item $item * @param Player $player * * @return array */ - public function getDrops(ItemItem $item, Player $player){ + public function getDrops(Item $item, PocketMine\Player $player){ if(!isset(self::$class[$this->id])){ //Unknown blocks return array(); } else{ @@ -450,13 +453,13 @@ abstract class Block extends Position{ /** * Returns the seconds that this block takes to be broken using an specific Item * - * @param ItemItem $item + * @param Item $item * @param Player $player * * @return float */ - public function getBreakTime(ItemItem $item, Player $player){ + public function getBreakTime(Item $item, PocketMine\Player $player){ if(($player->gamemode & 0x01) === 0x01){ return 0.15; } @@ -473,7 +476,7 @@ abstract class Block extends Position{ */ public function getSide($side){ $v = parent::getSide($side); - if($this->level instanceof LevelLevel){ + if($this->level instanceof Level){ return $this->level->getBlock($v); } @@ -487,27 +490,27 @@ abstract class Block extends Position{ /** * Returns if the item can be broken with an specific Item * - * @param ItemItem $item + * @param Item $item * @param Player $player * * @return bool */ - abstract function isBreakable(ItemItem $item, Player $player); + abstract function isBreakable(Item $item, PocketMine\Player $player); /** * Do the actions needed so the block is broken with the Item * - * @param ItemItem $item + * @param Item $item * @param Player $player * * @return mixed */ - abstract function onBreak(ItemItem $item, Player $player); + abstract function onBreak(Item $item, PocketMine\Player $player); /** * Places the Block, using block space and block target, and side. Returns if the block has been placed. * - * @param ItemItem $item + * @param Item $item * @param Player $player * @param Block $block * @param Block $target @@ -518,17 +521,17 @@ abstract class Block extends Position{ * * @return bool */ - abstract function place(ItemItem $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz); + abstract function place(Item $item, PocketMine\Player $player, Block $block, Block $target, $face, $fx, $fy, $fz); /** * Do actions when activated by Item. Returns if it has done anything * - * @param ItemItem $item + * @param Item $item * @param Player $player * * @return bool */ - abstract function onActivate(ItemItem $item, Player $player); + abstract function onActivate(Item $item, PocketMine\Player $player); /** * Fires a block update on the Block diff --git a/src/block/Bookshelf.php b/src/block/Bookshelf.php index bff2ba2ce..9e21dc5a2 100644 --- a/src/block/Bookshelf.php +++ b/src/block/Bookshelf.php @@ -25,7 +25,7 @@ use PocketMine; class Bookshelf extends Solid{ public function __construct(){ - parent::__construct(BOOKSHELF, 0, "Bookshelf"); + parent::__construct(self::BOOKSHELF, 0, "Bookshelf"); $this->hardness = 7.5; } diff --git a/src/block/BrickStairs.php b/src/block/BrickStairs.php index ee3bbde78..0553ae8df 100644 --- a/src/block/BrickStairs.php +++ b/src/block/BrickStairs.php @@ -25,7 +25,7 @@ use PocketMine; class BrickStairs extends Stair{ public function __construct($meta = 0){ - parent::__construct(BRICK_STAIRS, $meta, "Brick Stairs"); + parent::__construct(self::BRICK_STAIRS, $meta, "Brick Stairs"); } } \ No newline at end of file diff --git a/src/block/Bricks.php b/src/block/Bricks.php index 2a45ab52d..3259f1af3 100644 --- a/src/block/Bricks.php +++ b/src/block/Bricks.php @@ -26,11 +26,11 @@ use PocketMine\Item\Item as Item; class Bricks extends Solid{ public function __construct(){ - parent::__construct(BRICKS_BLOCK, 0, "Bricks"); + parent::__construct(self::BRICKS_BLOCK, 0, "Bricks"); $this->hardness = 30; } - public function getBreakTime(Item $item, Player $player){ + public function getBreakTime(Item $item, PocketMine\Player $player){ if(($player->gamemode & 0x01) === 0x01){ return 0.20; } @@ -50,7 +50,7 @@ class Bricks extends Solid{ } } - public function getDrops(Item $item, Player $player){ + public function getDrops(Item $item, PocketMine\Player $player){ if($item->isPickaxe() >= 1){ return array( array(BRICKS_BLOCK, 0, 1), diff --git a/src/block/BrownMushroom.php b/src/block/BrownMushroom.php index d374233a2..1d36a0ed4 100644 --- a/src/block/BrownMushroom.php +++ b/src/block/BrownMushroom.php @@ -26,7 +26,7 @@ use PocketMine\Item\Item as Item; class BrownMushroom extends Flowable{ public function __construct(){ - parent::__construct(BROWN_MUSHROOM, 0, "Brown Mushroom"); + parent::__construct(self::BROWN_MUSHROOM, 0, "Brown Mushroom"); $this->hardness = 0; } @@ -44,7 +44,7 @@ class BrownMushroom extends Flowable{ return false; } - public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ + public function place(Item $item, PocketMine\Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ $down = $this->getSide(0); if($down->isTransparent === false){ $this->level->setBlock($block, $this, true, false, true); diff --git a/src/block/BurningFurnace.php b/src/block/BurningFurnace.php index befb0611b..349c70207 100644 --- a/src/block/BurningFurnace.php +++ b/src/block/BurningFurnace.php @@ -32,12 +32,12 @@ use PocketMine; class BurningFurnace extends Solid{ public function __construct($meta = 0){ - parent::__construct(BURNING_FURNACE, $meta, "Burning Furnace"); + parent::__construct(self::BURNING_FURNACE, $meta, "Burning Furnace"); $this->isActivable = true; $this->hardness = 17.5; } - public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ + public function place(Item $item, PocketMine\Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ $faces = array( 0 => 4, 1 => 2, @@ -59,13 +59,13 @@ class BurningFurnace extends Solid{ return true; } - public function onBreak(Item $item, Player $player){ + public function onBreak(Item $item, PocketMine\Player $player){ $this->level->setBlock($this, new Air(), true, true, true); return true; } - public function onActivate(Item $item, Player $player){ + public function onActivate(Item $item, PocketMine\Player $player){ $t = $this->level->getTile($this); $furnace = false; @@ -92,7 +92,7 @@ class BurningFurnace extends Solid{ return true; } - public function getBreakTime(Item $item, Player $player){ + public function getBreakTime(Item $item, PocketMine\Player $player){ if(($player->gamemode & 0x01) === 0x01){ return 0.20; } @@ -112,7 +112,7 @@ class BurningFurnace extends Solid{ } } - public function getDrops(Item $item, Player $player){ + public function getDrops(Item $item, PocketMine\Player $player){ $drops = array(); if($item->isPickaxe() >= 1){ $drops[] = array(FURNACE, 0, 1); diff --git a/src/block/Cactus.php b/src/block/Cactus.php index 05f08bdf3..ca37c7daf 100644 --- a/src/block/Cactus.php +++ b/src/block/Cactus.php @@ -28,7 +28,7 @@ use PocketMine; class Cactus extends Transparent{ public function __construct($meta = 0){ - parent::__construct(CACTUS, $meta, "Cactus"); + parent::__construct(self::CACTUS, $meta, "Cactus"); $this->isFullBlock = false; $this->hardness = 2; } @@ -66,7 +66,7 @@ class Cactus extends Transparent{ return false; } - public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ + public function place(Item $item, PocketMine\Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ $down = $this->getSide(0); if($down->getID() === self::SAND or $down->getID() === self::CACTUS){ $block0 = $this->getSide(2); @@ -83,7 +83,7 @@ class Cactus extends Transparent{ return false; } - public function getDrops(Item $item, Player $player){ + public function getDrops(Item $item, PocketMine\Player $player){ return array( array($this->id, 0, 1), ); diff --git a/src/block/Cake.php b/src/block/Cake.php index 5609a0e0e..2a0c73c71 100644 --- a/src/block/Cake.php +++ b/src/block/Cake.php @@ -26,14 +26,14 @@ use PocketMine\Item\Item as Item; class Cake extends Transparent{ public function __construct($meta = 0){ - parent::__construct(CAKE_BLOCK, 0, "Cake Block"); + parent::__construct(self::CAKE_BLOCK, 0, "Cake Block"); $this->isFullBlock = false; $this->isActivable = true; $this->meta = $meta & 0x07; $this->hardness = 2.5; } - public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ + public function place(Item $item, PocketMine\Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ $down = $this->getSide(0); if($down->getID() !== self::AIR){ $this->level->setBlock($block, $this, true, false, true); @@ -56,11 +56,11 @@ class Cake extends Transparent{ return false; } - public function getDrops(Item $item, Player $player){ + public function getDrops(Item $item, PocketMine\Player $player){ return array(); } - public function onActivate(Item $item, Player $player){ + public function onActivate(Item $item, PocketMine\Player $player){ if($player->getHealth() < 20){ ++$this->meta; $player->heal(3, "cake"); diff --git a/src/block/Carpet.php b/src/block/Carpet.php index d96a68242..f5be84d82 100644 --- a/src/block/Carpet.php +++ b/src/block/Carpet.php @@ -26,7 +26,7 @@ use PocketMine\Item\Item as Item; class Carpet extends Flowable{ public function __construct($meta = 0){ - parent::__construct(CARPET, $meta, "Carpet"); + parent::__construct(self::CARPET, $meta, "Carpet"); $names = array( 0 => "White Carpet", 1 => "Orange Carpet", @@ -51,7 +51,7 @@ class Carpet extends Flowable{ $this->isSolid = true; } - public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ + public function place(Item $item, PocketMine\Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ $down = $this->getSide(0); if($down->getID() !== self::AIR){ $this->level->setBlock($block, $this, true, false, true); diff --git a/src/block/Carrot.php b/src/block/Carrot.php index ec0b333c4..304bfde46 100644 --- a/src/block/Carrot.php +++ b/src/block/Carrot.php @@ -26,12 +26,12 @@ use PocketMine\Item\Item as Item; class Carrot extends Flowable{ public function __construct($meta = 0){ - parent::__construct(CARROT_BLOCK, $meta, "Carrot Block"); + parent::__construct(self::CARROT_BLOCK, $meta, "Carrot Block"); $this->isActivable = true; $this->hardness = 0; } - public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ + public function place(Item $item, PocketMine\Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ $down = $this->getSide(0); if($down->getID() === self::FARMLAND){ $this->level->setBlock($block, $this, true, false, true); @@ -42,8 +42,8 @@ class Carrot extends Flowable{ return false; } - public function onActivate(Item $item, Player $player){ - if($item->getID() === ItemItem::DYE and $item->getMetadata() === 0x0F){ //Bonemeal + public function onActivate(Item $item, PocketMine\Player $player){ + if($item->getID() === Item::DYE and $item->getMetadata() === 0x0F){ //Bonemeal $this->meta = 0x07; $this->level->setBlock($this, $this, true, false, true); if(($player->gamemode & 0x01) === 0){ @@ -81,7 +81,7 @@ class Carrot extends Flowable{ return false; } - public function getDrops(Item $item, Player $player){ + public function getDrops(Item $item, PocketMine\Player $player){ $drops = array(); if($this->meta >= 0x07){ $drops[] = array(CARROT, 0, mt_rand(1, 4)); diff --git a/src/block/Chest.php b/src/block/Chest.php index ac3623ed1..01aeb51c7 100644 --- a/src/block/Chest.php +++ b/src/block/Chest.php @@ -32,12 +32,12 @@ use PocketMine; class Chest extends Transparent{ public function __construct($meta = 0){ - parent::__construct(CHEST, $meta, "Chest"); + parent::__construct(self::CHEST, $meta, "Chest"); $this->isActivable = true; $this->hardness = 15; } - public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ + public function place(Item $item, PocketMine\Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ $faces = array( 0 => 4, 1 => 2, @@ -82,7 +82,7 @@ class Chest extends Transparent{ return true; } - public function onBreak(Item $item, Player $player){ + public function onBreak(Item $item, PocketMine\Player $player){ $t = $this->level->getTile($this); if($t instanceof TileChest){ $t->unpair(); @@ -92,7 +92,7 @@ class Chest extends Transparent{ return true; } - public function onActivate(Item $item, Player $player){ + public function onActivate(Item $item, PocketMine\Player $player){ $top = $this->getSide(1); if($top->isTransparent !== true){ return true; @@ -124,7 +124,7 @@ class Chest extends Transparent{ return true; } - public function getDrops(Item $item, Player $player){ + public function getDrops(Item $item, PocketMine\Player $player){ $drops = array( array($this->id, 0, 1), ); diff --git a/src/block/Clay.php b/src/block/Clay.php index b03342e2a..6e80af91b 100644 --- a/src/block/Clay.php +++ b/src/block/Clay.php @@ -26,13 +26,13 @@ use PocketMine\Item\Item as Item; class Clay extends Solid{ public function __construct(){ - parent::__construct(CLAY_BLOCK, 0, "Clay Block"); + parent::__construct(self::CLAY_BLOCK, 0, "Clay Block"); $this->hardness = 3; } - public function getDrops(Item $item, Player $player){ + public function getDrops(Item $item, PocketMine\Player $player){ return array( - array(ItemItem::CLAY, 0, 4), + array(Item::CLAY, 0, 4), ); } } \ No newline at end of file diff --git a/src/block/Coal.php b/src/block/Coal.php index 0da525077..be9030b29 100644 --- a/src/block/Coal.php +++ b/src/block/Coal.php @@ -26,11 +26,11 @@ use PocketMine\Item\Item as Item; class Coal extends Solid{ public function __construct(){ - parent::__construct(COAL_BLOCK, 0, "Coal Block"); + parent::__construct(self::COAL_BLOCK, 0, "Coal Block"); $this->hardness = 30; } - public function getBreakTime(Item $item, Player $player){ + public function getBreakTime(Item $item, PocketMine\Player $player){ if(($player->gamemode & 0x01) === 0x01){ return 0.20; } @@ -50,7 +50,7 @@ class Coal extends Solid{ } } - public function getDrops(Item $item, Player $player){ + public function getDrops(Item $item, PocketMine\Player $player){ if($item->isPickaxe() >= 1){ return array( array(COAL_BLOCK, 0, 1), diff --git a/src/block/CoalOre.php b/src/block/CoalOre.php index b06980451..2d592a27d 100644 --- a/src/block/CoalOre.php +++ b/src/block/CoalOre.php @@ -26,11 +26,11 @@ use PocketMine\Item\Item as Item; class CoalOre extends Solid{ public function __construct(){ - parent::__construct(COAL_ORE, 0, "Coal Ore"); + parent::__construct(self::COAL_ORE, 0, "Coal Ore"); $this->hardness = 15; } - public function getBreakTime(Item $item, Player $player){ + public function getBreakTime(Item $item, PocketMine\Player $player){ if(($player->gamemode & 0x01) === 0x01){ return 0.20; } @@ -50,7 +50,7 @@ class CoalOre extends Solid{ } } - public function getDrops(Item $item, Player $player){ + public function getDrops(Item $item, PocketMine\Player $player){ if($item->isPickaxe() >= 1){ return array( array(COAL, 0, 1), diff --git a/src/block/Cobblestone.php b/src/block/Cobblestone.php index 3ff5d8aa9..8d2c66ab4 100644 --- a/src/block/Cobblestone.php +++ b/src/block/Cobblestone.php @@ -26,11 +26,11 @@ use PocketMine\Item\Item as Item; class Cobblestone extends Solid{ public function __construct(){ - parent::__construct(COBBLESTONE, 0, "Cobblestone"); + parent::__construct(self::COBBLESTONE, 0, "Cobblestone"); $this->hardness = 30; } - public function getBreakTime(Item $item, Player $player){ + public function getBreakTime(Item $item, PocketMine\Player $player){ if(($player->gamemode & 0x01) === 0x01){ return 0.20; } @@ -50,7 +50,7 @@ class Cobblestone extends Solid{ } } - public function getDrops(Item $item, Player $player){ + public function getDrops(Item $item, PocketMine\Player $player){ if($item->isPickaxe() >= 1){ return array( array(COBBLESTONE, 0, 1), diff --git a/src/block/CobblestoneStairs.php b/src/block/CobblestoneStairs.php index bfb1bf0fb..d824853ea 100644 --- a/src/block/CobblestoneStairs.php +++ b/src/block/CobblestoneStairs.php @@ -25,7 +25,7 @@ use PocketMine; class CobblestoneStairs extends Stair{ public function __construct($meta = 0){ - parent::__construct(COBBLESTONE_STAIRS, $meta, "Cobblestone Stairs"); + parent::__construct(self::COBBLESTONE_STAIRS, $meta, "Cobblestone Stairs"); } } \ No newline at end of file diff --git a/src/block/Cobweb.php b/src/block/Cobweb.php index b9fafdcd5..183aaba00 100644 --- a/src/block/Cobweb.php +++ b/src/block/Cobweb.php @@ -26,13 +26,13 @@ use PocketMine\Item\Item as Item; class Cobweb extends Flowable{ public function __construct(){ - parent::__construct(COBWEB, 0, "Cobweb"); + parent::__construct(self::COBWEB, 0, "Cobweb"); $this->isSolid = true; $this->isFullBlock = false; $this->hardness = 25; } - public function getDrops(Item $item, Player $player){ + public function getDrops(Item $item, PocketMine\Player $player){ return array(); } } \ No newline at end of file diff --git a/src/block/CyanFlower.php b/src/block/CyanFlower.php index ef23c0479..ca93c2359 100644 --- a/src/block/CyanFlower.php +++ b/src/block/CyanFlower.php @@ -26,11 +26,11 @@ use PocketMine\Item\Item as Item; class CyanFlower extends Flowable{ public function __construct(){ - parent::__construct(CYAN_FLOWER, 0, "Cyan Flower"); + parent::__construct(self::CYAN_FLOWER, 0, "Cyan Flower"); $this->hardness = 0; } - public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ + public function place(Item $item, PocketMine\Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ $down = $this->getSide(0); if($down->getID() === 2 or $down->getID() === 3 or $down->getID() === 60){ $this->level->setBlock($block, $this, true, false, true); diff --git a/src/block/Dandelion.php b/src/block/Dandelion.php index e1a4dcc09..446acd568 100644 --- a/src/block/Dandelion.php +++ b/src/block/Dandelion.php @@ -26,11 +26,11 @@ use PocketMine\Item\Item as Item; class Dandelion extends Flowable{ public function __construct(){ - parent::__construct(DANDELION, 0, "Dandelion"); + parent::__construct(self::DANDELION, 0, "Dandelion"); $this->hardness = 0; } - public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ + public function place(Item $item, PocketMine\Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ $down = $this->getSide(0); if($down->getID() === 2 or $down->getID() === 3 or $down->getID() === 60){ $this->level->setBlock($block, $this, true, false, true); diff --git a/src/block/DeadBush.php b/src/block/DeadBush.php index effcdc4d3..5dfe9e834 100644 --- a/src/block/DeadBush.php +++ b/src/block/DeadBush.php @@ -25,7 +25,7 @@ use PocketMine; class DeadBush extends Flowable{ public function __construct(){ - parent::__construct(DEAD_BUSH, 0, "Dead Bush"); + parent::__construct(self::DEAD_BUSH, 0, "Dead Bush"); //$this->isReplaceable = true; $this->hardness = 0; } diff --git a/src/block/Diamond.php b/src/block/Diamond.php index 2eb0efb90..5cf670563 100644 --- a/src/block/Diamond.php +++ b/src/block/Diamond.php @@ -26,11 +26,11 @@ use PocketMine\Item\Item as Item; class Diamond extends Solid{ public function __construct(){ - parent::__construct(DIAMOND_BLOCK, 0, "Diamond Block"); + parent::__construct(self::DIAMOND_BLOCK, 0, "Diamond Block"); $this->hardness = 30; } - public function getBreakTime(Item $item, Player $player){ + public function getBreakTime(Item $item, PocketMine\Player $player){ if(($player->gamemode & 0x01) === 0x01){ return 0.20; } @@ -44,7 +44,7 @@ class Diamond extends Solid{ } } - public function getDrops(Item $item, Player $player){ + public function getDrops(Item $item, PocketMine\Player $player){ if($item->isPickaxe() >= 4){ return array( array(DIAMOND_BLOCK, 0, 1), diff --git a/src/block/DiamondOre.php b/src/block/DiamondOre.php index af86f78c0..7563789cf 100644 --- a/src/block/DiamondOre.php +++ b/src/block/DiamondOre.php @@ -26,11 +26,11 @@ use PocketMine\Item\Item as Item; class DiamondOre extends Solid{ public function __construct(){ - parent::__construct(DIAMOND_ORE, 0, "Diamond Ore"); + parent::__construct(self::DIAMOND_ORE, 0, "Diamond Ore"); $this->hardness = 15; } - public function getBreakTime(Item $item, Player $player){ + public function getBreakTime(Item $item, PocketMine\Player $player){ if(($player->gamemode & 0x01) === 0x01){ return 0.20; } @@ -44,7 +44,7 @@ class DiamondOre extends Solid{ } } - public function getDrops(Item $item, Player $player){ + public function getDrops(Item $item, PocketMine\Player $player){ if($item->isPickaxe() >= 4){ return array( array(DIAMOND, 0, 1), diff --git a/src/block/Dirt.php b/src/block/Dirt.php index 96c95f359..c86de30cd 100644 --- a/src/block/Dirt.php +++ b/src/block/Dirt.php @@ -26,12 +26,12 @@ use PocketMine\Item\Item as Item; class Dirt extends Solid{ public function __construct(){ - parent::__construct(DIRT, 0, "Dirt"); + parent::__construct(self::DIRT, 0, "Dirt"); $this->isActivable = true; $this->hardness = 2.5; } - public function onActivate(Item $item, Player $player){ + public function onActivate(Item $item, PocketMine\Player $player){ if($item->isHoe()){ if(($player->gamemode & 0x01) === 0){ $item->useOn($this); diff --git a/src/block/Door.php b/src/block/Door.php index 877a09188..b69e94b0b 100644 --- a/src/block/Door.php +++ b/src/block/Door.php @@ -48,7 +48,7 @@ abstract class Door extends Transparent{ return false; } - public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ + public function place(Item $item, PocketMine\Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ if($face === 1){ $blockUp = $this->getSide(1); $blockDown = $this->getSide(0); @@ -78,7 +78,7 @@ abstract class Door extends Transparent{ return false; } - public function onBreak(Item $item, Player $player){ + public function onBreak(Item $item, PocketMine\Player $player){ if(($this->meta & 0x08) === 0x08){ $down = $this->getSide(0); if($down->getID() === $this->id){ @@ -95,7 +95,7 @@ abstract class Door extends Transparent{ return true; } - public function onActivate(Item $item, Player $player){ + public function onActivate(Item $item, PocketMine\Player $player){ if(($this->meta & 0x08) === 0x08){ //Top $down = $this->getSide(0); if($down->getID() === $this->id){ diff --git a/src/block/DoubleSlab.php b/src/block/DoubleSlab.php index b606543ca..80c90e1e0 100644 --- a/src/block/DoubleSlab.php +++ b/src/block/DoubleSlab.php @@ -26,7 +26,7 @@ use PocketMine\Item\Item as Item; class DoubleSlab extends Solid{ public function __construct($meta = 0){ - parent::__construct(DOUBLE_SLAB, $meta, "Double Slab"); + parent::__construct(self::DOUBLE_SLAB, $meta, "Double Slab"); $names = array( 0 => "Stone", 1 => "Sandstone", @@ -40,7 +40,7 @@ class DoubleSlab extends Solid{ $this->hardness = 30; } - public function getBreakTime(Item $item, Player $player){ + public function getBreakTime(Item $item, PocketMine\Player $player){ if(($player->gamemode & 0x01) === 0x01){ return 0.20; } @@ -60,7 +60,7 @@ class DoubleSlab extends Solid{ } } - public function getDrops(Item $item, Player $player){ + public function getDrops(Item $item, PocketMine\Player $player){ if($item->isPickaxe() >= 1){ return array( array(SLAB, $this->meta & 0x07, 2), diff --git a/src/block/DoubleWoodSlab.php b/src/block/DoubleWoodSlab.php index 8c16b7d94..565502bfd 100644 --- a/src/block/DoubleWoodSlab.php +++ b/src/block/DoubleWoodSlab.php @@ -26,7 +26,7 @@ use PocketMine\Item\Item as Item; class DoubleWoodSlab extends Solid{ public function __construct($meta = 0){ - parent::__construct(DOUBLE_WOOD_SLAB, $meta, "Double Wooden Slab"); + parent::__construct(self::DOUBLE_WOOD_SLAB, $meta, "Double Wooden Slab"); $names = array( 0 => "Oak", 1 => "Spruce", @@ -37,7 +37,7 @@ class DoubleWoodSlab extends Solid{ $this->hardness = 15; } - public function getBreakTime(Item $item, Player $player){ + public function getBreakTime(Item $item, PocketMine\Player $player){ if(($player->gamemode & 0x01) === 0x01){ return 0.20; } @@ -57,7 +57,7 @@ class DoubleWoodSlab extends Solid{ } } - public function getDrops(Item $item, Player $player){ + public function getDrops(Item $item, PocketMine\Player $player){ return array( array(WOOD_SLAB, $this->meta & 0x07, 2), ); diff --git a/src/block/Fallable.php b/src/block/Fallable.php index dc713402d..feedf959a 100644 --- a/src/block/Fallable.php +++ b/src/block/Fallable.php @@ -32,7 +32,7 @@ class Fallable extends Solid{ $this->hasPhysics = true; } - public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ + public function place(Item $item, PocketMine\Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ $ret = $this->level->setBlock($this, $this, true, false, true); ServerAPI::request()->api->block->blockUpdate(clone $this, BLOCK_UPDATE_NORMAL); diff --git a/src/block/Farmland.php b/src/block/Farmland.php index c5e0c824f..eeecf1bd1 100644 --- a/src/block/Farmland.php +++ b/src/block/Farmland.php @@ -26,11 +26,11 @@ use PocketMine\Item\Item as Item; class Farmland extends Solid{ public function __construct($meta = 0){ - parent::__construct(FARMLAND, $meta, "Farmland"); + parent::__construct(self::FARMLAND, $meta, "Farmland"); $this->hardness = 3; } - public function getDrops(Item $item, Player $player){ + public function getDrops(Item $item, PocketMine\Player $player){ return array( array(DIRT, 0, 1), ); diff --git a/src/block/Fence.php b/src/block/Fence.php index 74c60fbd3..c2c9c00b4 100644 --- a/src/block/Fence.php +++ b/src/block/Fence.php @@ -25,7 +25,7 @@ use PocketMine; class Fence extends Transparent{ public function __construct(){ - parent::__construct(FENCE, 0, "Fence"); + parent::__construct(self::FENCE, 0, "Fence"); $this->isFullBlock = false; $this->hardness = 15; } diff --git a/src/block/FenceGate.php b/src/block/FenceGate.php index b05c6272a..8e2f56b58 100644 --- a/src/block/FenceGate.php +++ b/src/block/FenceGate.php @@ -26,7 +26,7 @@ use PocketMine\Item\Item as Item; class FenceGate extends Transparent{ public function __construct($meta = 0){ - parent::__construct(FENCE_GATE, $meta, "Fence Gate"); + parent::__construct(self::FENCE_GATE, $meta, "Fence Gate"); $this->isActivable = true; if(($this->meta & 0x04) === 0x04){ $this->isFullBlock = true; @@ -36,7 +36,7 @@ class FenceGate extends Transparent{ $this->hardness = 15; } - public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ + public function place(Item $item, PocketMine\Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ $faces = array( 0 => 3, 1 => 0, @@ -49,13 +49,13 @@ class FenceGate extends Transparent{ return true; } - public function getDrops(Item $item, Player $player){ + public function getDrops(Item $item, PocketMine\Player $player){ return array( array($this->id, 0, 1), ); } - public function onActivate(Item $item, Player $player){ + public function onActivate(Item $item, PocketMine\Player $player){ $faces = array( 0 => 3, 1 => 0, diff --git a/src/block/Fire.php b/src/block/Fire.php index a8657adb2..260bc8783 100644 --- a/src/block/Fire.php +++ b/src/block/Fire.php @@ -26,14 +26,14 @@ use PocketMine\Item\Item as Item; class Fire extends Flowable{ public function __construct($meta = 0){ - parent::__construct(FIRE, $meta, "Fire"); + parent::__construct(self::FIRE, $meta, "Fire"); $this->isReplaceable = true; $this->breakable = false; $this->isFullBlock = true; $this->hardness = 0; } - public function getDrops(Item $item, Player $player){ + public function getDrops(Item $item, PocketMine\Player $player){ return array(); } diff --git a/src/block/Furnace.php b/src/block/Furnace.php index 08dfba402..2d0b1a295 100644 --- a/src/block/Furnace.php +++ b/src/block/Furnace.php @@ -27,7 +27,7 @@ use PocketMine; class Furnace extends BurningFurnace{ public function __construct($meta = 0){ parent::__construct($meta); - $this->id = FURNACE; + $this->id = self::FURNACE; $this->name = "Furnace"; $this->isActivable = true; } diff --git a/src/block/Generic.php b/src/block/Generic.php index 2a7b7488a..65116e0fe 100644 --- a/src/block/Generic.php +++ b/src/block/Generic.php @@ -21,6 +21,7 @@ namespace PocketMine\Block; +use PocketMine\Player as Player; use PocketMine\Item\Item as Item; use PocketMine\ServerAPI as ServerAPI; use PocketMine; @@ -36,15 +37,15 @@ class Generic extends Block{ parent::__construct($id, $meta, $name); } - public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ + public function place(Item $item, PocketMine\Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ return $this->level->setBlock($this, $this, true, false, true); } - public function isBreakable(Item $item, Player $player){ + public function isBreakable(Item $item, PocketMine\Player $player){ return $this->breakable; } - public function onBreak(Item $item, Player $player){ + public function onBreak(Item $item, PocketMine\Player $player){ return $this->level->setBlock($this, new Air(), true, false, true); } @@ -72,7 +73,7 @@ class Generic extends Block{ return false; } - public function onActivate(Item $item, Player $player){ + public function onActivate(Item $item, PocketMine\Player $player){ return $this->isActivable; } } \ No newline at end of file diff --git a/src/block/Glass.php b/src/block/Glass.php index ad9fba220..84377ffe3 100644 --- a/src/block/Glass.php +++ b/src/block/Glass.php @@ -26,11 +26,11 @@ use PocketMine\Item\Item as Item; class Glass extends Transparent{ public function __construct(){ - parent::__construct(GLASS, 0, "Glass"); + parent::__construct(self::GLASS, 0, "Glass"); $this->hardness = 1.5; } - public function getDrops(Item $item, Player $player){ + public function getDrops(Item $item, PocketMine\Player $player){ return array(); } } \ No newline at end of file diff --git a/src/block/GlassPane.php b/src/block/GlassPane.php index dd2e7d680..d37e46530 100644 --- a/src/block/GlassPane.php +++ b/src/block/GlassPane.php @@ -25,7 +25,7 @@ use PocketMine; class GlassPane extends Transparent{ public function __construct(){ - parent::__construct(GLASS_PANE, 0, "Glass Pane"); + parent::__construct(self::GLASS_PANE, 0, "Glass Pane"); $this->isFullBlock = false; $this->isSolid = false; } diff --git a/src/block/GlowingObsidian.php b/src/block/GlowingObsidian.php index c107db1c9..67690f27e 100644 --- a/src/block/GlowingObsidian.php +++ b/src/block/GlowingObsidian.php @@ -25,7 +25,7 @@ use PocketMine; class GlowingObsidian extends Solid{ public function __construct($meta = 0){ - parent::__construct(GLOWING_OBSIDIAN, $meta, "Glowing Obsidian"); + parent::__construct(self::GLOWING_OBSIDIAN, $meta, "Glowing Obsidian"); } } \ No newline at end of file diff --git a/src/block/GlowingRedstoneOre.php b/src/block/GlowingRedstoneOre.php index ff95aedd1..683db6685 100644 --- a/src/block/GlowingRedstoneOre.php +++ b/src/block/GlowingRedstoneOre.php @@ -28,7 +28,7 @@ use PocketMine; class GlowingRedstoneOre extends Solid{ public function __construct(){ - parent::__construct(GLOWING_REDSTONE_ORE, 0, "Glowing Redstone Ore"); + parent::__construct(self::GLOWING_REDSTONE_ORE, 0, "Glowing Redstone Ore"); $this->hardness = 15; } @@ -45,7 +45,7 @@ class GlowingRedstoneOre extends Solid{ } - public function getBreakTime(Item $item, Player $player){ + public function getBreakTime(Item $item, PocketMine\Player $player){ if(($player->gamemode & 0x01) === 0x01){ return 0.20; } @@ -59,10 +59,10 @@ class GlowingRedstoneOre extends Solid{ } } - public function getDrops(Item $item, Player $player){ + public function getDrops(Item $item, PocketMine\Player $player){ if($item->isPickaxe() >= 4){ return array( - array(ItemItem::REDSTONE_DUST, 0, mt_rand(4, 5)), + array(Item::REDSTONE_DUST, 0, mt_rand(4, 5)), ); } else{ return array(); diff --git a/src/block/Glowstone.php b/src/block/Glowstone.php index e1054ba11..828af866a 100644 --- a/src/block/Glowstone.php +++ b/src/block/Glowstone.php @@ -26,13 +26,13 @@ use PocketMine\Item\Item as Item; class Glowstone extends Transparent{ public function __construct(){ - parent::__construct(GLOWSTONE_BLOCK, 0, "Glowstone"); + parent::__construct(self::GLOWSTONE_BLOCK, 0, "Glowstone"); $this->hardness = 1.5; } - public function getDrops(Item $item, Player $player){ + public function getDrops(Item $item, PocketMine\Player $player){ return array( - array(ItemItem::GLOWSTONE_DUST, 0, mt_rand(2, 4)), + array(Item::GLOWSTONE_DUST, 0, mt_rand(2, 4)), ); } } \ No newline at end of file diff --git a/src/block/Gold.php b/src/block/Gold.php index cb9bb811f..ce614582e 100644 --- a/src/block/Gold.php +++ b/src/block/Gold.php @@ -26,11 +26,11 @@ use PocketMine\Item\Item as Item; class Gold extends Solid{ public function __construct(){ - parent::__construct(GOLD_BLOCK, 0, "Gold Block"); + parent::__construct(self::GOLD_BLOCK, 0, "Gold Block"); $this->hardness = 30; } - public function getBreakTime(Item $item, Player $player){ + public function getBreakTime(Item $item, PocketMine\Player $player){ if(($player->gamemode & 0x01) === 0x01){ return 0.20; } @@ -44,7 +44,7 @@ class Gold extends Solid{ } } - public function getDrops(Item $item, Player $player){ + public function getDrops(Item $item, PocketMine\Player $player){ if($item->isPickaxe() >= 4){ return array( array(GOLD_BLOCK, 0, 1), diff --git a/src/block/GoldOre.php b/src/block/GoldOre.php index 15d1d802d..64124278a 100644 --- a/src/block/GoldOre.php +++ b/src/block/GoldOre.php @@ -26,11 +26,11 @@ use PocketMine\Item\Item as Item; class GoldOre extends Solid{ public function __construct(){ - parent::__construct(GOLD_ORE, 0, "Gold Ore"); + parent::__construct(self::GOLD_ORE, 0, "Gold Ore"); $this->hardness = 15; } - public function getBreakTime(Item $item, Player $player){ + public function getBreakTime(Item $item, PocketMine\Player $player){ if(($player->gamemode & 0x01) === 0x01){ return 0.20; } @@ -44,7 +44,7 @@ class GoldOre extends Solid{ } } - public function getDrops(Item $item, Player $player){ + public function getDrops(Item $item, PocketMine\Player $player){ if($item->isPickaxe() >= 4){ return array( array(GOLD_ORE, 0, 1), diff --git a/src/block/Grass.php b/src/block/Grass.php index b1345ae32..3b6567d19 100644 --- a/src/block/Grass.php +++ b/src/block/Grass.php @@ -28,19 +28,19 @@ use PocketMine; class Grass extends Solid{ public function __construct(){ - parent::__construct(GRASS, 0, "Grass"); + parent::__construct(self::GRASS, 0, "Grass"); $this->isActivable = true; $this->hardness = 3; } - public function getDrops(Item $item, Player $player){ + public function getDrops(Item $item, PocketMine\Player $player){ return array( array(DIRT, 0, 1), ); } - public function onActivate(Item $item, Player $player){ - if($item->getID() === ItemItem::DYE and $item->getMetadata() === 0x0F){ + public function onActivate(Item $item, PocketMine\Player $player){ + if($item->getID() === Item::DYE and $item->getMetadata() === 0x0F){ if(($player->gamemode & 0x01) === 0){ $item->count--; } diff --git a/src/block/Gravel.php b/src/block/Gravel.php index 497bc7ebd..8de006e1f 100644 --- a/src/block/Gravel.php +++ b/src/block/Gravel.php @@ -26,14 +26,14 @@ use PocketMine\Item\Item as Item; class Gravel extends Fallable{ public function __construct(){ - parent::__construct(GRAVEL, 0, "Gravel"); + parent::__construct(self::GRAVEL, 0, "Gravel"); $this->hardness = 3; } - public function getDrops(Item $item, Player $player){ + public function getDrops(Item $item, PocketMine\Player $player){ if(mt_rand(1, 10) === 1){ return array( - array(ItemItem::FLINT, 0, 1), + array(Item::FLINT, 0, 1), ); } diff --git a/src/block/HayBale.php b/src/block/HayBale.php index 8d4cdcaf9..b5070200a 100644 --- a/src/block/HayBale.php +++ b/src/block/HayBale.php @@ -26,11 +26,11 @@ use PocketMine\Item\Item as Item; class HayBale extends Solid{ public function __construct($meta = 0){ - parent::__construct(HAY_BALE, $meta, "Hay Bale"); + parent::__construct(self::HAY_BALE, $meta, "Hay Bale"); $this->hardness = 10; } - public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ + public function place(Item $item, PocketMine\Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ $faces = array( 0 => 0, 1 => 0, @@ -46,7 +46,7 @@ class HayBale extends Solid{ return true; } - public function getDrops(Item $item, Player $player){ + public function getDrops(Item $item, PocketMine\Player $player){ return array( array($this->id, 0, 1), ); diff --git a/src/block/Ice.php b/src/block/Ice.php index ee3f8c2c3..ab1497519 100644 --- a/src/block/Ice.php +++ b/src/block/Ice.php @@ -26,11 +26,11 @@ use PocketMine\Item\Item as Item; class Ice extends Transparent{ public function __construct(){ - parent::__construct(ICE, 0, "Ice"); + parent::__construct(self::ICE, 0, "Ice"); $this->hardness = 2.5; } - public function onBreak(Item $item, Player $player){ + public function onBreak(Item $item, PocketMine\Player $player){ if(($player->gamemode & 0x01) === 0){ $this->level->setBlock($this, new Water(), true, false, true); } else{ @@ -40,7 +40,7 @@ class Ice extends Transparent{ return true; } - public function getBreakTime(Item $item, Player $player){ + public function getBreakTime(Item $item, PocketMine\Player $player){ if(($player->gamemode & 0x01) === 0x01){ return 0.20; } @@ -60,7 +60,7 @@ class Ice extends Transparent{ } } - public function getDrops(Item $item, Player $player){ + public function getDrops(Item $item, PocketMine\Player $player){ return array(); } } \ No newline at end of file diff --git a/src/block/Iron.php b/src/block/Iron.php index bbd9bb145..7a2817599 100644 --- a/src/block/Iron.php +++ b/src/block/Iron.php @@ -26,11 +26,11 @@ use PocketMine\Item\Item as Item; class Iron extends Solid{ public function __construct(){ - parent::__construct(IRON_BLOCK, 0, "Iron Block"); + parent::__construct(self::IRON_BLOCK, 0, "Iron Block"); $this->hardness = 30; } - public function getBreakTime(Item $item, Player $player){ + public function getBreakTime(Item $item, PocketMine\Player $player){ if(($player->gamemode & 0x01) === 0x01){ return 0.20; } @@ -46,7 +46,7 @@ class Iron extends Solid{ } } - public function getDrops(Item $item, Player $player){ + public function getDrops(Item $item, PocketMine\Player $player){ if($item->isPickaxe() >= 3){ return array( array(IRON_BLOCK, 0, 1), diff --git a/src/block/IronBars.php b/src/block/IronBars.php index 8ed96bb10..5f2f96d21 100644 --- a/src/block/IronBars.php +++ b/src/block/IronBars.php @@ -25,7 +25,7 @@ use PocketMine; class IronBars extends Transparent{ public function __construct(){ - parent::__construct(IRON_BARS, 0, "Iron Bars"); + parent::__construct(self::IRON_BARS, 0, "Iron Bars"); $this->isFullBlock = false; $this->isSolid = false; } diff --git a/src/block/IronDoor.php b/src/block/IronDoor.php index b14182141..8edb84961 100644 --- a/src/block/IronDoor.php +++ b/src/block/IronDoor.php @@ -26,12 +26,12 @@ use PocketMine\Item\Item as Item; class IronDoor extends Door{ public function __construct($meta = 0){ - parent::__construct(IRON_DOOR_BLOCK, $meta, "Iron Door Block"); + parent::__construct(self::IRON_DOOR_BLOCK, $meta, "Iron Door Block"); //$this->isActivable = true; $this->hardness = 25; } - public function getBreakTime(Item $item, Player $player){ + public function getBreakTime(Item $item, PocketMine\Player $player){ if(($player->gamemode & 0x01) === 0x01){ return 0.20; } @@ -51,10 +51,10 @@ class IronDoor extends Door{ } } - public function getDrops(Item $item, Player $player){ + public function getDrops(Item $item, PocketMine\Player $player){ if($item->isPickaxe() >= 1){ return array( - array(ItemItem::IRON_DOOR, 0, 1), + array(Item::IRON_DOOR, 0, 1), ); } else{ return array(); diff --git a/src/block/IronOre.php b/src/block/IronOre.php index b5217de13..db097f37a 100644 --- a/src/block/IronOre.php +++ b/src/block/IronOre.php @@ -26,11 +26,11 @@ use PocketMine\Item\Item as Item; class IronOre extends Solid{ public function __construct(){ - parent::__construct(IRON_ORE, 0, "Iron Ore"); + parent::__construct(self::IRON_ORE, 0, "Iron Ore"); $this->hardness = 15; } - public function getBreakTime(Item $item, Player $player){ + public function getBreakTime(Item $item, PocketMine\Player $player){ if(($player->gamemode & 0x01) === 0x01){ return 0.20; } @@ -46,7 +46,7 @@ class IronOre extends Solid{ } } - public function getDrops(Item $item, Player $player){ + public function getDrops(Item $item, PocketMine\Player $player){ if($item->isPickaxe() >= 3){ return array( array(IRON_ORE, 0, 1), diff --git a/src/block/JungleWoodStairs.php b/src/block/JungleWoodStairs.php index 2dc6c22be..323e23d74 100644 --- a/src/block/JungleWoodStairs.php +++ b/src/block/JungleWoodStairs.php @@ -26,10 +26,10 @@ use PocketMine\Item\Item as Item; class JungleWoodStairs extends Stair{ public function __construct($meta = 0){ - parent::__construct(JUNGLE_WOOD_STAIRS, $meta, "Jungle Wood Stairs"); + parent::__construct(self::JUNGLE_WOOD_STAIRS, $meta, "Jungle Wood Stairs"); } - public function getDrops(Item $item, Player $player){ + public function getDrops(Item $item, PocketMine\Player $player){ return array( array($this->id, 0, 1), ); diff --git a/src/block/Ladder.php b/src/block/Ladder.php index f6997c13c..2ac702435 100644 --- a/src/block/Ladder.php +++ b/src/block/Ladder.php @@ -26,13 +26,13 @@ use PocketMine\Item\Item as Item; class Ladder extends Transparent{ public function __construct($meta = 0){ - parent::__construct(LADDER, $meta, "Ladder"); + parent::__construct(self::LADDER, $meta, "Ladder"); $this->isSolid = false; $this->isFullBlock = false; $this->hardness = 2; } - public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ + public function place(Item $item, PocketMine\Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ if($target->isTransparent === false){ $faces = array( 2 => 2, @@ -63,7 +63,7 @@ class Ladder extends Transparent{ return false; } - public function getDrops(Item $item, Player $player){ + public function getDrops(Item $item, PocketMine\Player $player){ return array( array($this->id, 0, 1), ); diff --git a/src/block/Lapis.php b/src/block/Lapis.php index a836e4c2c..c224ce85f 100644 --- a/src/block/Lapis.php +++ b/src/block/Lapis.php @@ -26,11 +26,11 @@ use PocketMine\Item\Item as Item; class Lapis extends Solid{ public function __construct(){ - parent::__construct(LAPIS_BLOCK, 0, "Lapis Block"); + parent::__construct(self::LAPIS_BLOCK, 0, "Lapis Block"); $this->hardness = 15; } - public function getBreakTime(Item $item, Player $player){ + public function getBreakTime(Item $item, PocketMine\Player $player){ if(($player->gamemode & 0x01) === 0x01){ return 0.20; } @@ -46,7 +46,7 @@ class Lapis extends Solid{ } } - public function getDrops(Item $item, Player $player){ + public function getDrops(Item $item, PocketMine\Player $player){ if($item->isPickaxe() >= 3){ return array( array(LAPIS_BLOCK, 0, 1), diff --git a/src/block/LapisOre.php b/src/block/LapisOre.php index 94e0677c6..9c8e100dc 100644 --- a/src/block/LapisOre.php +++ b/src/block/LapisOre.php @@ -26,11 +26,11 @@ use PocketMine\Item\Item as Item; class LapisOre extends Solid{ public function __construct(){ - parent::__construct(LAPIS_ORE, 0, "Lapis Ore"); + parent::__construct(self::LAPIS_ORE, 0, "Lapis Ore"); $this->hardness = 15; } - public function getBreakTime(Item $item, Player $player){ + public function getBreakTime(Item $item, PocketMine\Player $player){ if(($player->gamemode & 0x01) === 0x01){ return 0.20; } @@ -46,10 +46,10 @@ class LapisOre extends Solid{ } } - public function getDrops(Item $item, Player $player){ + public function getDrops(Item $item, PocketMine\Player $player){ if($item->isPickaxe() >= 3){ return array( - array(ItemItem::DYE, 4, mt_rand(4, 8)), + array(Item::DYE, 4, mt_rand(4, 8)), ); } else{ return array(); diff --git a/src/block/Lava.php b/src/block/Lava.php index ea8b07c2a..945bc841a 100644 --- a/src/block/Lava.php +++ b/src/block/Lava.php @@ -28,11 +28,11 @@ use PocketMine; class Lava extends Liquid{ public function __construct($meta = 0){ - parent::__construct(LAVA, $meta, "Lava"); + parent::__construct(self::LAVA, $meta, "Lava"); $this->hardness = 0; } - public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ + public function place(Item $item, PocketMine\Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ $ret = $this->level->setBlock($this, $this, true, false, true); ServerAPI::request()->api->block->scheduleBlockUpdate(clone $this, 40, BLOCK_UPDATE_NORMAL); diff --git a/src/block/Leaves.php b/src/block/Leaves.php index 64c6afaa2..08ca0896b 100644 --- a/src/block/Leaves.php +++ b/src/block/Leaves.php @@ -32,7 +32,7 @@ class Leaves extends Transparent{ const JUNGLE = 3; public function __construct($meta = 0){ - parent::__construct(LEAVES, $meta, "Leaves"); + parent::__construct(self::LEAVES, $meta, "Leaves"); $names = array( self::OAK => "Oak Leaves", self::SPRUCE => "Spruce Leaves", @@ -140,18 +140,18 @@ class Leaves extends Transparent{ return false; } - public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ + public function place(Item $item, PocketMine\Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ $this->meta |= 0x04; $this->level->setBlock($this, $this, true, false, true); } - public function getDrops(Item $item, Player $player){ + public function getDrops(Item $item, PocketMine\Player $player){ $drops = array(); if($item->isShears()){ $drops[] = array(LEAVES, $this->meta & 0x03, 1); } else{ if(mt_rand(1, 20) === 1){ //Saplings - $drops[] = array(ItemItem::SAPLING, $this->meta & 0x03, 1); + $drops[] = array(Item::SAPLING, $this->meta & 0x03, 1); } if(($this->meta & 0x03) === self::OAK and mt_rand(1, 200) === 1){ //Apples $drops[] = array(APPLE, 0, 1); diff --git a/src/block/LitPumpkin.php b/src/block/LitPumpkin.php index e4345f1ca..65d095e44 100644 --- a/src/block/LitPumpkin.php +++ b/src/block/LitPumpkin.php @@ -26,11 +26,11 @@ use PocketMine\Item\Item as Item; class LitPumpkin extends Solid{ public function __construct(){ - parent::__construct(LIT_PUMPKIN, "Jack o'Lantern"); + parent::__construct(self::LIT_PUMPKIN, "Jack o'Lantern"); $this->hardness = 5; } - public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ + public function place(Item $item, PocketMine\Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ $faces = array( 0 => 4, 1 => 2, diff --git a/src/block/Melon.php b/src/block/Melon.php index 824753075..e350ecdce 100644 --- a/src/block/Melon.php +++ b/src/block/Melon.php @@ -26,13 +26,13 @@ use PocketMine\Item\Item as Item; class Melon extends Transparent{ public function __construct(){ - parent::__construct(MELON_BLOCK, 0, "Melon Block"); + parent::__construct(self::MELON_BLOCK, 0, "Melon Block"); $this->hardness = 5; } - public function getDrops(Item $item, Player $player){ + public function getDrops(Item $item, PocketMine\Player $player){ return array( - array(ItemItem::MELON_SLICE, 0, mt_rand(3, 7)), + array(Item::MELON_SLICE, 0, mt_rand(3, 7)), ); } } \ No newline at end of file diff --git a/src/block/MelonStem.php b/src/block/MelonStem.php index 6d902b05a..30466786b 100644 --- a/src/block/MelonStem.php +++ b/src/block/MelonStem.php @@ -26,12 +26,12 @@ use PocketMine\Item\Item as Item; class MelonStem extends Flowable{ public function __construct($meta = 0){ - parent::__construct(MELON_STEM, $meta, "Melon Stem"); + parent::__construct(self::MELON_STEM, $meta, "Melon Stem"); $this->isActivable = true; $this->hardness = 0; } - public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ + public function place(Item $item, PocketMine\Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ $down = $this->getSide(0); if($down->getID() === self::FARMLAND){ $this->level->setBlock($block, $this, true, false, true); @@ -79,8 +79,8 @@ class MelonStem extends Flowable{ return false; } - public function onActivate(Item $item, Player $player){ - if($item->getID() === ItemItem::DYE and $item->getMetadata() === 0x0F){ //Bonemeal + public function onActivate(Item $item, PocketMine\Player $player){ + if($item->getID() === Item::DYE and $item->getMetadata() === 0x0F){ //Bonemeal $this->meta = 0x07; $this->level->setBlock($this, $this, true, false, true); if(($player->gamemode & 0x01) === 0){ @@ -93,9 +93,9 @@ class MelonStem extends Flowable{ return false; } - public function getDrops(Item $item, Player $player){ + public function getDrops(Item $item, PocketMine\Player $player){ return array( - array(ItemItem::MELON_SEEDS, 0, mt_rand(0, 2)), + array(Item::MELON_SEEDS, 0, mt_rand(0, 2)), ); } } \ No newline at end of file diff --git a/src/block/MossStone.php b/src/block/MossStone.php index 2bc0095cc..b426d1c96 100644 --- a/src/block/MossStone.php +++ b/src/block/MossStone.php @@ -25,12 +25,12 @@ use PocketMine; use PocketMine\Item\Item as Item; class MossStone extends Solid{ - public function __construct($meta){ - parent::__construct(MOSS_STONE, $meta, "Moss Stone"); + public function __construct($meta = 0){ + parent::__construct(self::MOSS_STONE, $meta, "Moss Stone"); $this->hardness = 30; } - public function getBreakTime(Item $item, Player $player){ + public function getBreakTime(Item $item, PocketMine\Player $player){ if(($player->gamemode & 0x01) === 0x01){ return 0.20; } @@ -50,7 +50,7 @@ class MossStone extends Solid{ } } - public function getDrops(Item $item, Player $player){ + public function getDrops(Item $item, PocketMine\Player $player){ if($item->isPickaxe() >= 1){ return array( array(MOSS_STONE, $this->meta, 1), diff --git a/src/block/NetherBrick.php b/src/block/NetherBrick.php index 1712ea68b..c4fbac058 100644 --- a/src/block/NetherBrick.php +++ b/src/block/NetherBrick.php @@ -24,13 +24,13 @@ namespace PocketMine\Block; use PocketMine; use PocketMine\Item\Item as Item; -class NetherBricks extends Solid{ +class NetherBrick extends Solid{ public function __construct(){ - parent::__construct(NETHER_BRICKS, 0, "Nether Bricks"); + parent::__construct(self::NETHER_BRICKS, 0, "Nether Bricks"); $this->hardness = 30; } - public function getBreakTime(Item $item, Player $player){ + public function getBreakTime(Item $item, PocketMine\Player $player){ if(($player->gamemode & 0x01) === 0x01){ return 0.20; } @@ -50,7 +50,7 @@ class NetherBricks extends Solid{ } } - public function getDrops(Item $item, Player $player){ + public function getDrops(Item $item, PocketMine\Player $player){ if($item->isPickaxe() >= 1){ return array( array(NETHER_BRICKS, 0, 1), diff --git a/src/block/NetherBricksStairs.php b/src/block/NetherBrickStairs.php similarity index 86% rename from src/block/NetherBricksStairs.php rename to src/block/NetherBrickStairs.php index 903a3f06f..bfed7dbde 100644 --- a/src/block/NetherBricksStairs.php +++ b/src/block/NetherBrickStairs.php @@ -23,9 +23,9 @@ namespace PocketMine\Block; use PocketMine; -class NetherBricksStairs extends Stair{ +class NetherBrickStairs extends Stair{ public function __construct($meta = 0){ - parent::__construct(NETHER_BRICKS_STAIRS, $meta, "Nether Bricks Stairs"); + parent::__construct(self::NETHER_BRICKS_STAIRS, $meta, "Nether Bricks Stairs"); } } \ No newline at end of file diff --git a/src/block/NetherReactor.php b/src/block/NetherReactor.php index e4d4d673d..c2e75e444 100644 --- a/src/block/NetherReactor.php +++ b/src/block/NetherReactor.php @@ -25,7 +25,7 @@ use PocketMine; class NetherReactor extends Solid{ public function __construct($meta = 0){ - parent::__construct(NETHER_REACTOR, $meta, "Nether Reactor"); + parent::__construct(self::NETHER_REACTOR, $meta, "Nether Reactor"); $this->isActivable = true; } diff --git a/src/block/Netherrack.php b/src/block/Netherrack.php index fb03bc359..ab0c164cf 100644 --- a/src/block/Netherrack.php +++ b/src/block/Netherrack.php @@ -26,11 +26,11 @@ use PocketMine\Item\Item as Item; class Netherrack extends Solid{ public function __construct(){ - parent::__construct(NETHERRACK, 0, "Netherrack"); + parent::__construct(self::NETHERRACK, 0, "Netherrack"); $this->hardness = 2; } - public function getBreakTime(Item $item, Player $player){ + public function getBreakTime(Item $item, PocketMine\Player $player){ if(($player->gamemode & 0x01) === 0x01){ return 0.20; } @@ -50,7 +50,7 @@ class Netherrack extends Solid{ } } - public function getDrops(Item $item, Player $player){ + public function getDrops(Item $item, PocketMine\Player $player){ if($item->isPickaxe() >= 1){ return array( array(NETHERRACK, 0, 1), diff --git a/src/block/Obsidian.php b/src/block/Obsidian.php index 234180b55..ef5b2df74 100644 --- a/src/block/Obsidian.php +++ b/src/block/Obsidian.php @@ -26,11 +26,11 @@ use PocketMine\Item\Item as Item; class Obsidian extends Solid{ public function __construct(){ - parent::__construct(OBSIDIAN, 0, "Obsidian"); + parent::__construct(self::OBSIDIAN, 0, "Obsidian"); $this->hardness = 6000; } - public function getBreakTime(Item $item, Player $player){ + public function getBreakTime(Item $item, PocketMine\Player $player){ if(($player->gamemode & 0x01) === 0x01){ return 0.20; } @@ -41,7 +41,7 @@ class Obsidian extends Solid{ } } - public function getDrops(Item $item, Player $player){ + public function getDrops(Item $item, PocketMine\Player $player){ if($item->isPickaxe() >= 5){ return array( array(OBSIDIAN, 0, 1), diff --git a/src/block/Planks.php b/src/block/Planks.php index aaa4d5812..0da9953e4 100644 --- a/src/block/Planks.php +++ b/src/block/Planks.php @@ -25,12 +25,12 @@ use PocketMine; class Planks extends Solid{ public function __construct($meta = 0){ - parent::__construct(PLANKS, $meta, "Wooden Planks"); + parent::__construct(self::PLANKS, $meta, "Wooden Planks"); $names = array( - WoodBlock::OAK => "Oak Wooden Planks", - WoodBlock::SPRUCE => "Spruce Wooden Planks", - WoodBlock::BIRCH => "Birch Wooden Planks", - WoodBlock::JUNGLE => "Jungle Wooden Planks", + Wood::OAK => "Oak Wooden Planks", + Wood::SPRUCE => "Spruce Wooden Planks", + Wood::BIRCH => "Birch Wooden Planks", + Wood::JUNGLE => "Jungle Wooden Planks", ); $this->name = $names[$this->meta & 0x03]; $this->hardness = 15; diff --git a/src/block/Potato.php b/src/block/Potato.php index e0c6939fe..65a6a5d44 100644 --- a/src/block/Potato.php +++ b/src/block/Potato.php @@ -26,12 +26,12 @@ use PocketMine\Item\Item as Item; class Potato extends Flowable{ public function __construct($meta = 0){ - parent::__construct(POTATO_BLOCK, $meta, "Potato Block"); + parent::__construct(self::POTATO_BLOCK, $meta, "Potato Block"); $this->isActivable = true; $this->hardness = 0; } - public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ + public function place(Item $item, PocketMine\Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ $down = $this->getSide(0); if($down->getID() === self::FARMLAND){ $this->level->setBlock($block, $this, true, false, true); @@ -42,8 +42,8 @@ class Potato extends Flowable{ return false; } - public function onActivate(Item $item, Player $player){ - if($item->getID() === ItemItem::DYE and $item->getMetadata() === 0x0F){ //Bonemeal + public function onActivate(Item $item, PocketMine\Player $player){ + if($item->getID() === Item::DYE and $item->getMetadata() === 0x0F){ //Bonemeal $this->meta = 0x07; $this->level->setBlock($this, $this, true, false, true); if(($player->gamemode & 0x01) === 0){ @@ -81,7 +81,7 @@ class Potato extends Flowable{ return false; } - public function getDrops(Item $item, Player $player){ + public function getDrops(Item $item, PocketMine\Player $player){ $drops = array(); if($this->meta >= 0x07){ $drops[] = array(POTATO, 0, mt_rand(1, 4)); diff --git a/src/block/Pumpkin.php b/src/block/Pumpkin.php index cef654b78..239747a61 100644 --- a/src/block/Pumpkin.php +++ b/src/block/Pumpkin.php @@ -25,7 +25,7 @@ use PocketMine; class Pumpkin extends Solid{ public function __construct(){ - parent::__construct(PUMPKIN, "Pumpkin"); + parent::__construct(self::PUMPKIN, "Pumpkin"); $this->hardness = 5; } diff --git a/src/block/PumpkinStem.php b/src/block/PumpkinStem.php index cd869cf1d..c8833228c 100644 --- a/src/block/PumpkinStem.php +++ b/src/block/PumpkinStem.php @@ -26,12 +26,12 @@ use PocketMine\Item\Item as Item; class PumpkinStem extends Flowable{ public function __construct($meta = 0){ - parent::__construct(PUMPKIN_STEM, $meta, "Pumpkin Stem"); + parent::__construct(self::PUMPKIN_STEM, $meta, "Pumpkin Stem"); $this->isActivable = true; $this->hardness = 0; } - public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ + public function place(Item $item, PocketMine\Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ $down = $this->getSide(0); if($down->getID() === self::FARMLAND){ $this->level->setBlock($block, $this, true, false, true); @@ -79,8 +79,8 @@ class PumpkinStem extends Flowable{ return false; } - public function onActivate(Item $item, Player $player){ - if($item->getID() === ItemItem::DYE and $item->getMetadata() === 0x0F){ //Bonemeal + public function onActivate(Item $item, PocketMine\Player $player){ + if($item->getID() === Item::DYE and $item->getMetadata() === 0x0F){ //Bonemeal $this->meta = 0x07; $this->level->setBlock($this, $this, true, false, true); if(($player->gamemode & 0x01) === 0){ @@ -93,9 +93,9 @@ class PumpkinStem extends Flowable{ return false; } - public function getDrops(Item $item, Player $player){ + public function getDrops(Item $item, PocketMine\Player $player){ return array( - array(ItemItem::PUMPKIN_SEEDS, 0, mt_rand(0, 2)), + array(Item::PUMPKIN_SEEDS, 0, mt_rand(0, 2)), ); } } \ No newline at end of file diff --git a/src/block/Quartz.php b/src/block/Quartz.php index b0d5fad80..7f4ba9fdf 100644 --- a/src/block/Quartz.php +++ b/src/block/Quartz.php @@ -26,7 +26,7 @@ use PocketMine\Item\Item as Item; class Quartz extends Solid{ public function __construct($meta = 0){ - parent::__construct(QUARTZ_BLOCK, $meta, "Quartz Block"); + parent::__construct(self::QUARTZ_BLOCK, $meta, "Quartz Block"); $names = array( 0 => "Quartz Block", 1 => "Chiseled Quartz Block", @@ -36,7 +36,7 @@ class Quartz extends Solid{ $this->name = $names[$this->meta & 0x03]; } - public function getBreakTime(Item $item, Player $player){ + public function getBreakTime(Item $item, PocketMine\Player $player){ if(($player->gamemode & 0x01) === 0x01){ return 0.20; } @@ -56,7 +56,7 @@ class Quartz extends Solid{ } } - public function getDrops(Item $item, Player $player){ + public function getDrops(Item $item, PocketMine\Player $player){ if($item->isPickaxe() >= 1){ return array( array(QUARTZ_BLOCK, $this->meta & 0x03, 1), diff --git a/src/block/QuartzStairs.php b/src/block/QuartzStairs.php index 0438df077..5d10eb8ad 100644 --- a/src/block/QuartzStairs.php +++ b/src/block/QuartzStairs.php @@ -25,7 +25,7 @@ use PocketMine; class QuartzStairs extends Stair{ public function __construct($meta = 0){ - parent::__construct(QUARTZ_STAIRS, $meta, "Quartz Stairs"); + parent::__construct(self::QUARTZ_STAIRS, $meta, "Quartz Stairs"); } } \ No newline at end of file diff --git a/src/block/RedMushroom.php b/src/block/RedMushroom.php index 5e88573fb..ae1c20c01 100644 --- a/src/block/RedMushroom.php +++ b/src/block/RedMushroom.php @@ -26,7 +26,7 @@ use PocketMine\Item\Item as Item; class RedMushroom extends Flowable{ public function __construct(){ - parent::__construct(RED_MUSHROOM, 0, "Red Mushroom"); + parent::__construct(self::RED_MUSHROOM, 0, "Red Mushroom"); $this->hardness = 0; } @@ -44,7 +44,7 @@ class RedMushroom extends Flowable{ return false; } - public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ + public function place(Item $item, PocketMine\Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ $down = $this->getSide(0); if($down->isTransparent === false){ $this->level->setBlock($block, $this, true, false, true); diff --git a/src/block/RedstoneOre.php b/src/block/RedstoneOre.php index 0eb31b473..77bec6d86 100644 --- a/src/block/RedstoneOre.php +++ b/src/block/RedstoneOre.php @@ -26,7 +26,7 @@ use PocketMine\Item\Item as Item; class RedstoneOre extends Solid{ public function __construct(){ - parent::__construct(REDSTONE_ORE, 0, "Redstone Ore"); + parent::__construct(self::REDSTONE_ORE, 0, "Redstone Ore"); $this->hardness = 15; } @@ -41,7 +41,7 @@ class RedstoneOre extends Solid{ return false; } - public function getDrops(Item $item, Player $player){ + public function getDrops(Item $item, PocketMine\Player $player){ if($item->isPickaxe() >= 2){ return array( array(Redstone\REDSTONE_DUST, 0, mt_rand(4, 5)), diff --git a/src/block/Sand.php b/src/block/Sand.php index d6ac1c240..ab9fd986a 100644 --- a/src/block/Sand.php +++ b/src/block/Sand.php @@ -25,7 +25,7 @@ use PocketMine; class Sand extends Fallable{ public function __construct(){ - parent::__construct(SAND, 0, "Sand"); + parent::__construct(self::SAND, 0, "Sand"); $this->hardness = 2.5; } diff --git a/src/block/Sandstone.php b/src/block/Sandstone.php index 96e81d5b9..9f717e43c 100644 --- a/src/block/Sandstone.php +++ b/src/block/Sandstone.php @@ -26,7 +26,7 @@ use PocketMine\Item\Item as Item; class Sandstone extends Solid{ public function __construct($meta = 0){ - parent::__construct(SANDSTONE, $meta, "Sandstone"); + parent::__construct(self::SANDSTONE, $meta, "Sandstone"); $names = array( 0 => "Sandstone", 1 => "Chiseled Sandstone", @@ -36,7 +36,7 @@ class Sandstone extends Solid{ $this->hardness = 4; } - public function getBreakTime(Item $item, Player $player){ + public function getBreakTime(Item $item, PocketMine\Player $player){ if(($player->gamemode & 0x01) === 0x01){ return 0.20; } @@ -56,7 +56,7 @@ class Sandstone extends Solid{ } } - public function getDrops(Item $item, Player $player){ + public function getDrops(Item $item, PocketMine\Player $player){ if($item->isPickaxe() >= 1){ return array( array(SANDSTONE, $this->meta & 0x03, 1), diff --git a/src/block/SandstoneStairs.php b/src/block/SandstoneStairs.php index fb2f437ef..d139b8900 100644 --- a/src/block/SandstoneStairs.php +++ b/src/block/SandstoneStairs.php @@ -25,7 +25,7 @@ use PocketMine; class SandstoneStairs extends Stair{ public function __construct($meta = 0){ - parent::__construct(SANDSTONE_STAIRS, $meta, "Sandstone Stairs"); + parent::__construct(self::SANDSTONE_STAIRS, $meta, "Sandstone Stairs"); } } \ No newline at end of file diff --git a/src/block/Sapling.php b/src/block/Sapling.php index 264ae70f8..d57f9fd1c 100644 --- a/src/block/Sapling.php +++ b/src/block/Sapling.php @@ -34,7 +34,7 @@ class Sapling extends Flowable{ const BURN_TIME = 5; public function __construct($meta = Sapling::OAK){ - parent::__construct(SAPLING, $meta, "Sapling"); + parent::__construct(self::SAPLING, $meta, "Sapling"); $this->isActivable = true; $names = array( 0 => "Oak Sapling", @@ -46,7 +46,7 @@ class Sapling extends Flowable{ $this->hardness = 0; } - public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ + public function place(Item $item, PocketMine\Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ $down = $this->getSide(0); if($down->getID() === self::GRASS or $down->getID() === self::DIRT or $down->getID() === self::FARMLAND){ $this->level->setBlock($block, $this, true, false, true); @@ -57,8 +57,8 @@ class Sapling extends Flowable{ return false; } - public function onActivate(Item $item, Player $player){ - if($item->getID() === ItemItem::DYE and $item->getMetadata() === 0x0F){ //Bonemeal + public function onActivate(Item $item, PocketMine\Player $player){ + if($item->getID() === Item::DYE and $item->getMetadata() === 0x0F){ //Bonemeal Tree::growTree($this->level, $this, new Random(), $this->meta & 0x03); if(($player->gamemode & 0x01) === 0){ $item->count--; @@ -97,7 +97,7 @@ class Sapling extends Flowable{ return false; } - public function getDrops(Item $item, Player $player){ + public function getDrops(Item $item, PocketMine\Player $player){ return array( array($this->id, $this->meta & 0x03, 1), ); diff --git a/src/block/SignPost.php b/src/block/SignPost.php index 515df35fd..46b3b728d 100644 --- a/src/block/SignPost.php +++ b/src/block/SignPost.php @@ -26,13 +26,13 @@ use PocketMine\Item\Item as Item; class SignPost extends Transparent{ public function __construct($meta = 0){ - parent::__construct(SIGN_POST, $meta, "Sign Post"); + parent::__construct(self::SIGN_POST, $meta, "Sign Post"); $this->isSolid = false; $this->isFullBlock = false; $this->hardness = 5; } - public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ + public function place(Item $item, PocketMine\Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ if($face !== 0){ $faces = array( 2 => 2, @@ -70,15 +70,15 @@ class SignPost extends Transparent{ return false; } - public function onBreak(Item $item, Player $player){ + public function onBreak(Item $item, PocketMine\Player $player){ $this->level->setBlock($this, new Air(), true, true, true); return true; } - public function getDrops(Item $item, Player $player){ + public function getDrops(Item $item, PocketMine\Player $player){ return array( - array(ItemItem::SIGN, 0, 1), + array(Item::SIGN, 0, 1), ); } } \ No newline at end of file diff --git a/src/block/Slab.php b/src/block/Slab.php index f3c15e1a8..3ef977b87 100644 --- a/src/block/Slab.php +++ b/src/block/Slab.php @@ -26,7 +26,7 @@ use PocketMine\Item\Item as Item; class Slab extends Transparent{ public function __construct($meta = 0){ - parent::__construct(SLAB, $meta, "Slab"); + parent::__construct(self::SLAB, $meta, "Slab"); $names = array( 0 => "Stone", 1 => "Sandstone", @@ -46,7 +46,7 @@ class Slab extends Transparent{ $this->hardness = 30; } - public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ + public function place(Item $item, PocketMine\Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ $this->meta &= 0x07; if($face === 0){ if($target->getID() === self::SLAB and ($target->getMetadata() & 0x08) === 0x08 and ($target->getMetadata() & 0x07) === ($this->meta & 0x07)){ @@ -95,7 +95,7 @@ class Slab extends Transparent{ return true; } - public function getBreakTime(Item $item, Player $player){ + public function getBreakTime(Item $item, PocketMine\Player $player){ if(($player->gamemode & 0x01) === 0x01){ return 0.20; } @@ -115,7 +115,7 @@ class Slab extends Transparent{ } } - public function getDrops(Item $item, Player $player){ + public function getDrops(Item $item, PocketMine\Player $player){ if($item->isPickaxe() >= 1){ return array( array($this->id, $this->meta & 0x07, 1), diff --git a/src/block/Snow.php b/src/block/Snow.php index be9069792..05fb45a4e 100644 --- a/src/block/Snow.php +++ b/src/block/Snow.php @@ -25,7 +25,7 @@ use PocketMine; class Snow extends Solid{ public function __construct(){ - parent::__construct(SNOW_BLOCK, 0, "Snow Block"); + parent::__construct(self::SNOW_BLOCK, 0, "Snow Block"); $this->hardness = 1; } diff --git a/src/block/SnowLayer.php b/src/block/SnowLayer.php index 12e9a04d2..3e7e9c41a 100644 --- a/src/block/SnowLayer.php +++ b/src/block/SnowLayer.php @@ -26,14 +26,14 @@ use PocketMine\Item\Item as Item; class SnowLayer extends Flowable{ public function __construct($meta = 0){ - parent::__construct(SNOW_LAYER, $meta, "Snow Layer"); + parent::__construct(self::SNOW_LAYER, $meta, "Snow Layer"); $this->isReplaceable = true; $this->isSolid = false; $this->isFullBlock = false; $this->hardness = 0.5; } - public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ + public function place(Item $item, PocketMine\Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ $down = $this->getSide(0); if($down instanceof Solid){ $this->level->setBlock($block, $this, true, false, true); @@ -56,10 +56,10 @@ class SnowLayer extends Flowable{ return false; } - public function getDrops(Item $item, Player $player){ + public function getDrops(Item $item, PocketMine\Player $player){ if($item->isShovel() !== false){ return array( - array(ItemItem::SNOWBALL, 0, 1), + array(Item::SNOWBALL, 0, 1), ); } diff --git a/src/block/SoulSand.php b/src/block/SoulSand.php index 3c829a5eb..f9dbab115 100644 --- a/src/block/SoulSand.php +++ b/src/block/SoulSand.php @@ -25,7 +25,7 @@ use PocketMine; class SoulSand extends Solid{ public function __construct(){ - parent::__construct(SOUL_SAND, 0, "Soul Sand"); + parent::__construct(self::SOUL_SAND, 0, "Soul Sand"); $this->hardness = 2.5; } diff --git a/src/block/Sponge.php b/src/block/Sponge.php index 1536fd5fd..4cb9117da 100644 --- a/src/block/Sponge.php +++ b/src/block/Sponge.php @@ -25,7 +25,7 @@ use PocketMine; class Sponge extends Solid{ public function __construct(){ - parent::__construct(SPONGE, "Sponge"); + parent::__construct(self::SPONGE, "Sponge"); $this->hardness = 3; } diff --git a/src/block/SpruceWoodStairs.php b/src/block/SpruceWoodStairs.php index 47a5561d5..803eb47fd 100644 --- a/src/block/SpruceWoodStairs.php +++ b/src/block/SpruceWoodStairs.php @@ -26,10 +26,10 @@ use PocketMine\Item\Item as Item; class SpruceWoodStairs extends Stair{ public function __construct($meta = 0){ - parent::__construct(SPRUCE_WOOD_STAIRS, $meta, "Spruce Wood Stairs"); + parent::__construct(self::SPRUCE_WOOD_STAIRS, $meta, "Spruce Wood Stairs"); } - public function getDrops(Item $item, Player $player){ + public function getDrops(Item $item, PocketMine\Player $player){ return array( array($this->id, 0, 1), ); diff --git a/src/block/Stair.php b/src/block/Stair.php index f3b1cd919..c752a08e5 100644 --- a/src/block/Stair.php +++ b/src/block/Stair.php @@ -36,7 +36,7 @@ class Stair extends Transparent{ $this->hardness = 30; } - public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ + public function place(Item $item, PocketMine\Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ $faces = array( 0 => 0, 1 => 2, @@ -52,7 +52,7 @@ class Stair extends Transparent{ return true; } - public function getDrops(Item $item, Player $player){ + public function getDrops(Item $item, PocketMine\Player $player){ if($item->isPickaxe() >= 1){ return array( array($this->id, 0, 1), diff --git a/src/block/StillLava.php b/src/block/StillLava.php index f193c472b..fefa095a9 100644 --- a/src/block/StillLava.php +++ b/src/block/StillLava.php @@ -25,7 +25,7 @@ use PocketMine; class StillLava extends Liquid{ public function __construct($meta = 0){ - parent::__construct(STILL_LAVA, $meta, "Still Lava"); + parent::__construct(self::STILL_LAVA, $meta, "Still Lava"); $this->hardness = 500; } diff --git a/src/block/StillWater.php b/src/block/StillWater.php index 54f044c3d..057266d46 100644 --- a/src/block/StillWater.php +++ b/src/block/StillWater.php @@ -25,7 +25,7 @@ use PocketMine; class StillWater extends Water{ public function __construct($meta = 0){ - LiquidBlock::__construct(STILL_WATER, $meta, "Still Water"); + Liquid::__construct(self::STILL_WATER, $meta, "Still Water"); $this->hardness = 500; } diff --git a/src/block/Stone.php b/src/block/Stone.php index 29910312e..9d65b9647 100644 --- a/src/block/Stone.php +++ b/src/block/Stone.php @@ -26,11 +26,11 @@ use PocketMine\Item\Item as Item; class Stone extends Solid{ public function __construct(){ - parent::__construct(STONE, 0, "Stone"); + parent::__construct(self::STONE, 0, "Stone"); $this->hardness = 30; } - public function getBreakTime(Item $item, Player $player){ + public function getBreakTime(Item $item, PocketMine\Player $player){ if(($player->gamemode & 0x01) === 0x01){ return 0.20; } @@ -50,7 +50,7 @@ class Stone extends Solid{ } } - public function getDrops(Item $item, Player $player){ + public function getDrops(Item $item, PocketMine\Player $player){ if($item->isPickaxe() >= 1){ return array( array(COBBLESTONE, 0, 1), diff --git a/src/block/StoneBrickStairs.php b/src/block/StoneBrickStairs.php index ad28ebe6a..356a7cf4c 100644 --- a/src/block/StoneBrickStairs.php +++ b/src/block/StoneBrickStairs.php @@ -25,7 +25,7 @@ use PocketMine; class StoneBrickStairs extends Stair{ public function __construct($meta = 0){ - parent::__construct(STONE_BRICK_STAIRS, $meta, "Stone Brick Stairs"); + parent::__construct(self::STONE_BRICK_STAIRS, $meta, "Stone Brick Stairs"); } } \ No newline at end of file diff --git a/src/block/StoneBricks.php b/src/block/StoneBricks.php index acb6dca7b..9e1d49828 100644 --- a/src/block/StoneBricks.php +++ b/src/block/StoneBricks.php @@ -26,7 +26,7 @@ use PocketMine\Item\Item as Item; class StoneBricks extends Solid{ public function __construct($meta = 0){ - parent::__construct(STONE_BRICKS, $meta, "Stone Bricks"); + parent::__construct(self::STONE_BRICKS, $meta, "Stone Bricks"); $names = array( 0 => "Stone Bricks", 1 => "Mossy Stone Bricks", @@ -37,7 +37,7 @@ class StoneBricks extends Solid{ $this->hardness = 30; } - public function getBreakTime(Item $item, Player $player){ + public function getBreakTime(Item $item, PocketMine\Player $player){ if(($player->gamemode & 0x01) === 0x01){ return 0.20; } @@ -57,7 +57,7 @@ class StoneBricks extends Solid{ } } - public function getDrops(Item $item, Player $player){ + public function getDrops(Item $item, PocketMine\Player $player){ if($item->isPickaxe() >= 1){ return array( array(STONE_BRICKS, $this->meta & 0x03, 1), diff --git a/src/block/StoneWall.php b/src/block/StoneWall.php index 1823e0e44..761124b17 100644 --- a/src/block/StoneWall.php +++ b/src/block/StoneWall.php @@ -26,7 +26,7 @@ use PocketMine; class StoneWall extends Transparent{ public function __construct($meta = 0){ $meta &= 0x01; - parent::__construct(STONE_WALL, $meta, "Cobblestone Wall"); + parent::__construct(self::STONE_WALL, $meta, "Cobblestone Wall"); if($meta === 1){ $this->name = "Mossy Cobblestone Wall"; } diff --git a/src/block/Stonecutter.php b/src/block/Stonecutter.php index 672e23e01..de1bfc021 100644 --- a/src/block/Stonecutter.php +++ b/src/block/Stonecutter.php @@ -26,17 +26,17 @@ use PocketMine\Item\Item as Item; class Stonecutter extends Solid{ public function __construct($meta = 0){ - parent::__construct(STONECUTTER, $meta, "Stonecutter"); + parent::__construct(self::STONECUTTER, $meta, "Stonecutter"); $this->isActivable = true; } - public function onActivate(Item $item, Player $player){ + public function onActivate(Item $item, PocketMine\Player $player){ $player->toCraft[-1] = 2; return true; } - public function getDrops(Item $item, Player $player){ + public function getDrops(Item $item, PocketMine\Player $player){ return array( array($this->id, 0, 1), ); diff --git a/src/block/Sugarcane.php b/src/block/Sugarcane.php index 5ababb3a5..984d7b237 100644 --- a/src/block/Sugarcane.php +++ b/src/block/Sugarcane.php @@ -27,17 +27,17 @@ use PocketMine; class Sugarcane extends Flowable{ public function __construct($meta = 0){ - parent::__construct(SUGARCANE_BLOCK, $meta, "Sugarcane"); + parent::__construct(self::SUGARCANE_BLOCK, $meta, "Sugarcane"); $this->hardness = 0; } - public function getDrops(Item $item, Player $player){ + public function getDrops(Item $item, PocketMine\Player $player){ return array( array(SUGARCANE, 0, 1), ); } - public function onActivate(Item $item, Player $player){ + public function onActivate(Item $item, PocketMine\Player $player){ if($item->getID() === self::DYE and $item->getMetadata() === 0x0F){ //Bonemeal if($this->getSide(0)->getID() !== self::SUGARCANE_BLOCK){ for($y = 1; $y < 3; ++$y){ @@ -94,7 +94,7 @@ class Sugarcane extends Flowable{ return false; } - public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ + public function place(Item $item, PocketMine\Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ $down = $this->getSide(0); if($down->getID() === self::SUGARCANE_BLOCK){ $this->level->setBlock($block, new Sugarcane(), true, false, true); diff --git a/src/block/TNT.php b/src/block/TNT.php index b9cf29581..96d944396 100644 --- a/src/block/TNT.php +++ b/src/block/TNT.php @@ -26,13 +26,13 @@ use PocketMine\Item\Item as Item; class TNT extends Solid{ public function __construct(){ - parent::__construct(TNT, 0, "TNT"); + parent::__construct(self::TNT, 0, "TNT"); $this->hardness = 0; $this->isActivable = true; } - public function onActivate(Item $item, Player $player){ - if($item->getID() === ItemItem::FLINT_STEEL){ + public function onActivate(Item $item, PocketMine\Player $player){ + if($item->getID() === Item::FLINT_STEEL){ if(($player->gamemode & 0x01) === 0){ $item->useOn($this); } diff --git a/src/block/TallGrass.php b/src/block/TallGrass.php index d020e36dd..8f8df469a 100644 --- a/src/block/TallGrass.php +++ b/src/block/TallGrass.php @@ -19,9 +19,14 @@ * */ +namespace PocketMine\Block; + +use PocketMine\Item\Item as Item; +use PocketMine; + class TallGrass extends Flowable{ public function __construct($meta = 1){ - parent::__construct(TALL_GRASS, $meta, "Tall Grass"); + parent::__construct(self::TALL_GRASS, $meta, "Tall Grass"); $this->isReplaceable = true; $names = array( 0 => "Dead Shrub", @@ -44,15 +49,15 @@ class TallGrass extends Flowable{ return false; } - public function getDrops(Item\Item $item, Player $player){ + public function getDrops(Item $item, PocketMine\Player $player){ $drops = array(); $possibleDrops = array( - array(Item\Item::WHEAT_SEEDS, 0, 1), - array(Item\Item::CARROT, 0, 1), - array(Item\Item::POTATO, 0, 1), - array(Item\Item::BEETROOT_SEEDS, 0, 1), - array(Item\Item::MELON_SEEDS, 0, 1), - array(Item\Item::PUMPKIN_SEEDS, 0, 1), + array(Item::WHEAT_SEEDS, 0, 1), + array(Item::CARROT, 0, 1), + array(Item::POTATO, 0, 1), + array(Item::BEETROOT_SEEDS, 0, 1), + array(Item::MELON_SEEDS, 0, 1), + array(Item::PUMPKIN_SEEDS, 0, 1), 0, 0, 0, diff --git a/src/block/Torch.php b/src/block/Torch.php index 17c9cdcca..2a9d27d0b 100644 --- a/src/block/Torch.php +++ b/src/block/Torch.php @@ -26,7 +26,7 @@ use PocketMine\Item\Item as Item; class Torch extends Flowable{ public function __construct($meta = 0){ - parent::__construct(TORCH, $meta, "Torch"); + parent::__construct(self::TORCH, $meta, "Torch"); $this->hardness = 0; } @@ -55,7 +55,7 @@ class Torch extends Flowable{ return false; } - public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ + public function place(Item $item, PocketMine\Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ if($target->isTransparent === false and $face !== 0){ $faces = array( 1 => 5, @@ -78,7 +78,7 @@ class Torch extends Flowable{ return false; } - public function getDrops(Item $item, Player $player){ + public function getDrops(Item $item, PocketMine\Player $player){ return array( array($this->id, 0, 1), ); diff --git a/src/block/Trapdoor.php b/src/block/Trapdoor.php index f1ca5ea24..0550cdb83 100644 --- a/src/block/Trapdoor.php +++ b/src/block/Trapdoor.php @@ -26,7 +26,7 @@ use PocketMine\Item\Item as Item; class Trapdoor extends Transparent{ public function __construct($meta = 0){ - parent::__construct(TRAPDOOR, $meta, "Trapdoor"); + parent::__construct(self::TRAPDOOR, $meta, "Trapdoor"); $this->isActivable = true; if(($this->meta & 0x04) === 0x04){ $this->isFullBlock = false; @@ -36,7 +36,7 @@ class Trapdoor extends Transparent{ $this->hardness = 15; } - public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ + public function place(Item $item, PocketMine\Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ if(($target->isTransparent === false or $target->getID() === self::SLAB) and $face !== 0 and $face !== 1){ $faces = array( 2 => 0, @@ -56,13 +56,13 @@ class Trapdoor extends Transparent{ return false; } - public function getDrops(Item $item, Player $player){ + public function getDrops(Item $item, PocketMine\Player $player){ return array( array($this->id, 0, 1), ); } - public function onActivate(Item $item, Player $player){ + public function onActivate(Item $item, PocketMine\Player $player){ $this->meta ^= 0x04; $this->level->setBlock($this, $this, true, false, true); diff --git a/src/block/WallSign.php b/src/block/WallSign.php index 77cfbebd4..c68fea781 100644 --- a/src/block/WallSign.php +++ b/src/block/WallSign.php @@ -25,7 +25,7 @@ use PocketMine; class WallSign extends SignPost{ public function __construct($meta = 0){ - TransparentBlock::__construct(WALL_SIGN, $meta, "Wall Sign"); + Transparent::__construct(self::WALL_SIGN, $meta, "Wall Sign"); } public function onUpdate($type){ diff --git a/src/block/Water.php b/src/block/Water.php index 340f6b751..37f1810e2 100644 --- a/src/block/Water.php +++ b/src/block/Water.php @@ -27,11 +27,11 @@ use PocketMine; class Water extends Liquid{ public function __construct($meta = 0){ - parent::__construct(WATER, $meta, "Water"); + parent::__construct(self::WATER, $meta, "Water"); $this->hardness = 500; } - public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ + public function place(Item $item, PocketMine\Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ $ret = $this->level->setBlock($this, $this, true, false, true); ServerAPI::request()->api->block->scheduleBlockUpdate(clone $this, 10, BLOCK_UPDATE_NORMAL); diff --git a/src/block/Wheat.php b/src/block/Wheat.php index 42e8b6a1f..f2b245560 100644 --- a/src/block/Wheat.php +++ b/src/block/Wheat.php @@ -26,12 +26,12 @@ use PocketMine\Item\Item as Item; class Wheat extends Flowable{ public function __construct($meta = 0){ - parent::__construct(WHEAT_BLOCK, $meta, "Wheat Block"); + parent::__construct(self::WHEAT_BLOCK, $meta, "Wheat Block"); $this->isActivable = true; $this->hardness = 0; } - public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ + public function place(Item $item, PocketMine\Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ $down = $this->getSide(0); if($down->getID() === self::FARMLAND){ $this->level->setBlock($block, $this, true, false, true); @@ -42,8 +42,8 @@ class Wheat extends Flowable{ return false; } - public function onActivate(Item $item, Player $player){ - if($item->getID() === ItemItem::DYE and $item->getMetadata() === 0x0F){ //Bonemeal + public function onActivate(Item $item, PocketMine\Player $player){ + if($item->getID() === Item::DYE and $item->getMetadata() === 0x0F){ //Bonemeal $this->meta = 0x07; $this->level->setBlock($this, $this, true, false, true); if(($player->gamemode & 0x01) === 0){ @@ -77,13 +77,13 @@ class Wheat extends Flowable{ return false; } - public function getDrops(Item $item, Player $player){ + public function getDrops(Item $item, PocketMine\Player $player){ $drops = array(); if($this->meta >= 0x07){ - $drops[] = array(ItemItem::WHEAT, 0, 1); - $drops[] = array(ItemItem::WHEAT_SEEDS, 0, mt_rand(0, 3)); + $drops[] = array(Item::WHEAT, 0, 1); + $drops[] = array(Item::WHEAT_SEEDS, 0, mt_rand(0, 3)); } else{ - $drops[] = array(ItemItem::WHEAT_SEEDS, 0, 1); + $drops[] = array(Item::WHEAT_SEEDS, 0, 1); } return $drops; diff --git a/src/block/Wood.php b/src/block/Wood.php index 68e7c4249..d4acc272c 100644 --- a/src/block/Wood.php +++ b/src/block/Wood.php @@ -31,18 +31,18 @@ class Wood extends Solid{ const JUNGLE = 3; public function __construct($meta = 0){ - parent::__construct(WOOD, $meta, "Wood"); + parent::__construct(self::WOOD, $meta, "Wood"); $names = array( - WoodBlock::OAK => "Oak Wood", - WoodBlock::SPRUCE => "Spruce Wood", - WoodBlock::BIRCH => "Birch Wood", - WoodBlock::JUNGLE => "Jungle Wood", + self::OAK => "Oak Wood", + self::SPRUCE => "Spruce Wood", + self::BIRCH => "Birch Wood", + self::JUNGLE => "Jungle Wood", ); $this->name = $names[$this->meta & 0x03]; $this->hardness = 10; } - public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ + public function place(Item $item, PocketMine\Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ $faces = array( 0 => 0, 1 => 0, @@ -58,7 +58,7 @@ class Wood extends Solid{ return true; } - public function getDrops(Item $item, Player $player){ + public function getDrops(Item $item, PocketMine\Player $player){ return array( array($this->id, $this->meta & 0x03, 1), ); diff --git a/src/block/WoodDoor.php b/src/block/WoodDoor.php index cfe864b42..c3d7c1bee 100644 --- a/src/block/WoodDoor.php +++ b/src/block/WoodDoor.php @@ -26,14 +26,14 @@ use PocketMine\Item\Item as Item; class WoodDoor extends Door{ public function __construct($meta = 0){ - parent::__construct(WOOD_DOOR_BLOCK, $meta, "Wood Door Block"); + parent::__construct(self::WOOD_DOOR_BLOCK, $meta, "Wood Door Block"); $this->isActivable = true; $this->hardness = 15; } - public function getDrops(Item $item, Player $player){ + public function getDrops(Item $item, PocketMine\Player $player){ return array( - array(ItemItem::WOODEN_DOOR, 0, 1), + array(Item::WOODEN_DOOR, 0, 1), ); } } \ No newline at end of file diff --git a/src/block/WoodSlab.php b/src/block/WoodSlab.php index 4c0f70789..aec6cdc19 100644 --- a/src/block/WoodSlab.php +++ b/src/block/WoodSlab.php @@ -26,7 +26,7 @@ use PocketMine\Item\Item as Item; class WoodSlab extends Transparent{ public function __construct($meta = 0){ - parent::__construct(WOOD_SLAB, $meta, "Wooden Slab"); + parent::__construct(self::WOOD_SLAB, $meta, "Wooden Slab"); $names = array( 0 => "Oak", 1 => "Spruce", @@ -42,7 +42,7 @@ class WoodSlab extends Transparent{ $this->hardness = 15; } - public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ + public function place(Item $item, PocketMine\Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ $this->meta &= 0x07; if($face === 0){ if($target->getID() === self::WOOD_SLAB and ($target->getMetadata() & 0x08) === 0x08 and ($target->getMetadata() & 0x07) === ($this->meta & 0x07)){ @@ -91,7 +91,7 @@ class WoodSlab extends Transparent{ return true; } - public function getBreakTime(Item $item, Player $player){ + public function getBreakTime(Item $item, PocketMine\Player $player){ if(($player->gamemode & 0x01) === 0x01){ return 0.20; } @@ -111,7 +111,7 @@ class WoodSlab extends Transparent{ } } - public function getDrops(Item $item, Player $player){ + public function getDrops(Item $item, PocketMine\Player $player){ return array( array($this->id, $this->meta & 0x07, 1), ); diff --git a/src/block/WoodStairs.php b/src/block/WoodStairs.php index fc12048ee..718e36df8 100644 --- a/src/block/WoodStairs.php +++ b/src/block/WoodStairs.php @@ -26,10 +26,10 @@ use PocketMine\Item\Item as Item; class WoodStairs extends Stair{ public function __construct($meta = 0){ - parent::__construct(WOOD_STAIRS, $meta, "Wood Stairs"); + parent::__construct(self::WOOD_STAIRS, $meta, "Wood Stairs"); } - public function getBreakTime(Item $item, Player $player){ + public function getBreakTime(Item $item, PocketMine\Player $player){ if(($player->gamemode & 0x01) === 0x01){ return 0.20; } @@ -49,7 +49,7 @@ class WoodStairs extends Stair{ } } - public function getDrops(Item $item, Player $player){ + public function getDrops(Item $item, PocketMine\Player $player){ return array( array($this->id, 0, 1), ); diff --git a/src/block/Wool.php b/src/block/Wool.php index 791d38f9d..e15955be4 100644 --- a/src/block/Wool.php +++ b/src/block/Wool.php @@ -25,7 +25,7 @@ use PocketMine; class Wool extends Solid{ public function __construct($meta = 0){ - parent::__construct(WOOL, $meta, "Wool"); + parent::__construct(self::WOOL, $meta, "Wool"); $names = array( 0 => "White Wool", 1 => "Orange Wool", diff --git a/src/block/Workbench.php b/src/block/Workbench.php index b44745424..1a9b2b893 100644 --- a/src/block/Workbench.php +++ b/src/block/Workbench.php @@ -26,18 +26,18 @@ use PocketMine\Item\Item as Item; class Workbench extends Solid{ public function __construct($meta = 0){ - parent::__construct(WORKBENCH, $meta, "Crafting Table"); + parent::__construct(self::WORKBENCH, $meta, "Crafting Table"); $this->isActivable = true; $this->hardness = 15; } - public function onActivate(Item $item, Player $player){ + public function onActivate(Item $item, PocketMine\Player $player){ $player->toCraft[-1] = 1; return true; } - public function getDrops(Item $item, Player $player){ + public function getDrops(Item $item, PocketMine\Player $player){ return array( array($this->id, 0, 1), ); diff --git a/src/entity/Human.php b/src/entity/Human.php index 62348a33d..26d33f3d8 100644 --- a/src/entity/Human.php +++ b/src/entity/Human.php @@ -34,6 +34,7 @@ use PocketMine\Network\Protocol\ContainerSetContentPacket as ContainerSetContent use PocketMine\Network\Protocol\PlayerEquipmentPacket as PlayerEquipmentPacket; use PocketMine\Network\Protocol\RemovePlayerPacket as RemovePlayerPacket; use PocketMine\Network\Protocol\SetEntityMotionPacket as SetEntityMotionPacket; +use PocketMine\Player; use PocketMine; class Human extends Creature implements ProjectileSource, InventorySource{ diff --git a/src/entity/RealHuman.php b/src/entity/RealHuman.php index 429cae771..26c5237ac 100644 --- a/src/entity/RealHuman.php +++ b/src/entity/RealHuman.php @@ -21,6 +21,7 @@ namespace PocketMine\Entity; +use PocketMine\Player; use PocketMine; abstract class RealHuman extends Human{ diff --git a/src/item/Apple.php b/src/item/Apple.php index 1efa47059..a59a26b62 100644 --- a/src/item/Apple.php +++ b/src/item/Apple.php @@ -25,7 +25,7 @@ use PocketMine; class Apple extends Item{ public function __construct($meta = 0, $count = 1){ - parent::__construct(APPLE, 0, $count, "Apple"); + parent::__construct(self::APPLE, 0, $count, "Apple"); } } \ No newline at end of file diff --git a/src/item/Bed.php b/src/item/Bed.php index 7162bdf93..28a065fd6 100644 --- a/src/item/Bed.php +++ b/src/item/Bed.php @@ -26,8 +26,8 @@ use PocketMine\Block\Block as Block; class Bed extends Item{ public function __construct($meta = 0, $count = 1){ - $this->block = Block::get(BED_BLOCK); - parent::__construct(BED, 0, $count, "Bed"); + $this->block = Block::get(Item::BED_BLOCK); + parent::__construct(self::BED, 0, $count, "Bed"); $this->maxStackSize = 1; } } \ No newline at end of file diff --git a/src/item/BeetrootSeeds.php b/src/item/BeetrootSeeds.php index a7946e91a..b8c14a9d6 100644 --- a/src/item/BeetrootSeeds.php +++ b/src/item/BeetrootSeeds.php @@ -26,7 +26,7 @@ use PocketMine\Block\Block as Block; class BeetrootSeeds extends Item{ public function __construct($meta = 0, $count = 1){ - $this->block = Block::get(BEETROOT_BLOCK); - parent::__construct(BEETROOT_SEEDS, 0, $count, "Beetroot Seeds"); + $this->block = Block::get(Item::BEETROOT_BLOCK); + parent::__construct(self::BEETROOT_SEEDS, 0, $count, "Beetroot Seeds"); } } \ No newline at end of file diff --git a/src/item/BeetrootSoup.php b/src/item/BeetrootSoup.php index 4684321c2..e8e8431d0 100644 --- a/src/item/BeetrootSoup.php +++ b/src/item/BeetrootSoup.php @@ -25,7 +25,7 @@ use PocketMine; class BeetrootSoup extends Item{ public function __construct($meta = 0, $count = 1){ - parent::__construct(BEETROOT_SOUP, 0, $count, "Beetroot Soup"); + parent::__construct(self::BEETROOT_SOUP, 0, $count, "Beetroot Soup"); $this->maxStackSize = 1; } diff --git a/src/item/Bowl.php b/src/item/Bowl.php index 1f2399abb..78d8f82f7 100644 --- a/src/item/Bowl.php +++ b/src/item/Bowl.php @@ -25,7 +25,7 @@ use PocketMine; class Bowl extends Item{ public function __construct($meta = 0, $count = 1){ - parent::__construct(BOWL, 0, $count, "Bowl"); + parent::__construct(self::BOWL, 0, $count, "Bowl"); } } \ No newline at end of file diff --git a/src/item/Brick.php b/src/item/Brick.php index dea29c4d8..ccdf624ac 100644 --- a/src/item/Brick.php +++ b/src/item/Brick.php @@ -25,7 +25,7 @@ use PocketMine; class Brick extends Item{ public function __construct($meta = 0, $count = 1){ - parent::__construct(BRICK, 0, $count, "Brick"); + parent::__construct(self::BRICK, 0, $count, "Brick"); } } \ No newline at end of file diff --git a/src/item/Bucket.php b/src/item/Bucket.php index 43b845dea..6b2f54b9f 100644 --- a/src/item/Bucket.php +++ b/src/item/Bucket.php @@ -31,7 +31,7 @@ use PocketMine; class Bucket extends Item{ public function __construct($meta = 0, $count = 1){ - parent::__construct(BUCKET, $meta, $count, "Bucket"); + parent::__construct(self::BUCKET, $meta, $count, "Bucket"); $this->isActivable = true; $this->maxStackSize = 1; } diff --git a/src/item/Cake.php b/src/item/Cake.php index 96a62d0aa..7a9fe0062 100644 --- a/src/item/Cake.php +++ b/src/item/Cake.php @@ -26,8 +26,8 @@ use PocketMine\Block\Block as Block; class Cake extends Item{ public function __construct($meta = 0, $count = 1){ - $this->block = Block::get(CAKE_BLOCK); + $this->block = Block::get(Item::CAKE_BLOCK); $this->maxStackSize = 1; - parent::__construct(CAKE, 0, $count, "Cake"); + parent::__construct(self::CAKE, 0, $count, "Cake"); } } \ No newline at end of file diff --git a/src/item/Carrot.php b/src/item/Carrot.php index 93eab6736..fd4fce188 100644 --- a/src/item/Carrot.php +++ b/src/item/Carrot.php @@ -26,7 +26,7 @@ use PocketMine\Block\Block as Block; class Carrot extends Item{ public function __construct($meta = 0, $count = 1){ - $this->block = Block::get(CARROT_BLOCK); - parent::__construct(CARROT, 0, $count, "Carrot"); + $this->block = Block::get(Item::CARROT_BLOCK); + parent::__construct(self::CARROT, 0, $count, "Carrot"); } } \ No newline at end of file diff --git a/src/item/Coal.php b/src/item/Coal.php index 490626657..9c9a8f515 100644 --- a/src/item/Coal.php +++ b/src/item/Coal.php @@ -25,7 +25,7 @@ use PocketMine; class Coal extends Item{ public function __construct($meta = 0, $count = 1){ - parent::__construct(COAL, $meta & 0x01, $count, "Coal"); + parent::__construct(self::COAL, $meta & 0x01, $count, "Coal"); if($this->meta === 1){ $this->name = "Charcoal"; } diff --git a/src/item/Diamond.php b/src/item/Diamond.php index 91fad34ea..2e28b5013 100644 --- a/src/item/Diamond.php +++ b/src/item/Diamond.php @@ -25,7 +25,7 @@ use PocketMine; class Diamond extends Item{ public function __construct($meta = 0, $count = 1){ - parent::__construct(DIAMOND, 0, $count, "Diamond"); + parent::__construct(self::DIAMOND, 0, $count, "Diamond"); } } \ No newline at end of file diff --git a/src/item/Feather.php b/src/item/Feather.php index 3e9d83775..a15779d09 100644 --- a/src/item/Feather.php +++ b/src/item/Feather.php @@ -25,7 +25,7 @@ use PocketMine; class Feather extends Item{ public function __construct($meta = 0, $count = 1){ - parent::__construct(FEATHER, 0, $count, "Feather"); + parent::__construct(self::FEATHER, 0, $count, "Feather"); } } \ No newline at end of file diff --git a/src/item/FlintSteel.php b/src/item/FlintSteel.php index a1d3077c9..7d0ebb533 100644 --- a/src/item/FlintSteel.php +++ b/src/item/FlintSteel.php @@ -29,7 +29,7 @@ use PocketMine; class FlintSteel extends Item{ public function __construct($meta = 0, $count = 1){ - parent::__construct(FLINT_STEEL, $meta, $count, "Flint and Steel"); + parent::__construct(self::FLINT_STEEL, $meta, $count, "Flint and Steel"); $this->isActivable = true; $this->maxStackSize = 1; } diff --git a/src/item/GoldIngot.php b/src/item/GoldIngot.php index 1f2eb4ece..dc2007f1f 100644 --- a/src/item/GoldIngot.php +++ b/src/item/GoldIngot.php @@ -25,7 +25,7 @@ use PocketMine; class GoldIngot extends Item{ public function __construct($meta = 0, $count = 1){ - parent::__construct(GOLD_INGOT, 0, $count, "Gold Ingot"); + parent::__construct(self::GOLD_INGOT, 0, $count, "Gold Ingot"); } } \ No newline at end of file diff --git a/src/item/IronAxe.php b/src/item/IronAxe.php index 7a3a2a2d8..894a24eb4 100644 --- a/src/item/IronAxe.php +++ b/src/item/IronAxe.php @@ -25,7 +25,7 @@ use PocketMine; class IronAxe extends Item{ public function __construct($meta = 0, $count = 1){ - parent::__construct(IRON_AXE, 0, $count, "Iron Axe"); + parent::__construct(self::IRON_AXE, 0, $count, "Iron Axe"); } } \ No newline at end of file diff --git a/src/item/IronDoor.php b/src/item/IronDoor.php index d86333852..31d7ea063 100644 --- a/src/item/IronDoor.php +++ b/src/item/IronDoor.php @@ -26,8 +26,8 @@ use PocketMine\Block\Block as Block; class IronDoor extends Item{ public function __construct($meta = 0, $count = 1){ - $this->block = Block::get(IRON_DOOR_BLOCK); - parent::__construct(IRON_DOOR, 0, $count, "Iron Door"); + $this->block = Block::get(Item::IRON_DOOR_BLOCK); + parent::__construct(self::IRON_DOOR, 0, $count, "Iron Door"); $this->maxStackSize = 1; } } \ No newline at end of file diff --git a/src/item/IronHoe.php b/src/item/IronHoe.php index 1cde19b67..d432fa5a4 100644 --- a/src/item/IronHoe.php +++ b/src/item/IronHoe.php @@ -25,7 +25,7 @@ use PocketMine; class IronHoe extends Item{ public function __construct($meta = 0, $count = 1){ - parent::__construct(IRON_HOE, 0, $count, "Iron Hoe"); + parent::__construct(self::IRON_HOE, 0, $count, "Iron Hoe"); } } \ No newline at end of file diff --git a/src/item/IronIngot.php b/src/item/IronIngot.php index 2698aa5ac..c45200140 100644 --- a/src/item/IronIngot.php +++ b/src/item/IronIngot.php @@ -25,7 +25,7 @@ use PocketMine; class IronIngot extends Item{ public function __construct($meta = 0, $count = 1){ - parent::__construct(IRON_INGOT, 0, $count, "Iron Ingot"); + parent::__construct(self::IRON_INGOT, 0, $count, "Iron Ingot"); } } \ No newline at end of file diff --git a/src/item/IronPickaxe.php b/src/item/IronPickaxe.php index e62c98966..433995629 100644 --- a/src/item/IronPickaxe.php +++ b/src/item/IronPickaxe.php @@ -25,7 +25,7 @@ use PocketMine; class IronPickaxe extends Item{ public function __construct($meta = 0, $count = 1){ - parent::__construct(IRON_PICKAXE, 0, $count, "Iron Pickaxe"); + parent::__construct(self::IRON_PICKAXE, 0, $count, "Iron Pickaxe"); } } \ No newline at end of file diff --git a/src/item/IronShovel.php b/src/item/IronShovel.php index a9f6a6847..9bf046fb7 100644 --- a/src/item/IronShovel.php +++ b/src/item/IronShovel.php @@ -25,7 +25,7 @@ use PocketMine; class IronShovel extends Item{ public function __construct($meta = 0, $count = 1){ - parent::__construct(IRON_SHOVEL, 0, $count, "Iron Shovel"); + parent::__construct(self::IRON_SHOVEL, 0, $count, "Iron Shovel"); } } \ No newline at end of file diff --git a/src/item/Item.php b/src/item/Item.php index 5d12760fd..7b5ef3330 100644 --- a/src/item/Item.php +++ b/src/item/Item.php @@ -368,43 +368,43 @@ class Item{ public $isActivable = false; public static function init(){ - if(count(self::$init) === 0){ - self::$init = array( - SUGARCANE => new Sugarcane(), - WHEAT_SEEDS => new WheatSeeds(), - PUMPKIN_SEEDS => new PumpkinSeeds(), - MELON_SEEDS => new MelonSeeds(), - MUSHROOM_STEW => new MushroomStew(), - BEETROOT_SOUP => new BeetrootSoup(), - CARROT => new Carrot(), - POTATO => new Potato(), - BEETROOT_SEEDS => new BeetrootSeeds(), - SIGN => new Sign(), - WOODEN_DOOR => new WoodenDoor(), - BUCKET => new Bucket(), - IRON_DOOR => new IronDoor(), - CAKE => new Cake(), - BED => new Bed(), - PAINTING => new Painting(), - COAL => new Coal(), - APPLE => new Apple(), - SPAWN_EGG => new SpawnEgg(), - DIAMOND => new Diamond(), - STICK => new Stick(), - BOWL => new Bowl(), - FEATHER => new Feather(), - BRICK => new Brick(), - IRON_INGOT => new IronIngot(), - GOLD_INGOT => new GoldIngot(), - IRON_SHOVEL => new IronShovel(), - IRON_PICKAXE => new IronPickaxe(), - IRON_AXE => new IronAxe(), - IRON_HOE => new IronHoe(), - WOODEN_SWORD => new WoodenSword(), - WOODEN_SHOVEL => new WoodenShovel(), - WOODEN_PICKAXE => new WoodenPickaxe(), - WOODEN_AXE => new WoodenAxe(), - FLINT_STEEL => new FlintSteel(), + if(count(self::$list) === 0){ + self::$list = array( + self::SUGARCANE => new Sugarcane(), + self::WHEAT_SEEDS => new WheatSeeds(), + self::PUMPKIN_SEEDS => new PumpkinSeeds(), + self::MELON_SEEDS => new MelonSeeds(), + self::MUSHROOM_STEW => new MushroomStew(), + self::BEETROOT_SOUP => new BeetrootSoup(), + self::CARROT => new Carrot(), + self::POTATO => new Potato(), + self::BEETROOT_SEEDS => new BeetrootSeeds(), + self::SIGN => new Sign(), + self::WOODEN_DOOR => new WoodenDoor(), + self::BUCKET => new Bucket(), + self::IRON_DOOR => new IronDoor(), + self::CAKE => new Cake(), + self::BED => new Bed(), + self::PAINTING => new Painting(), + self::COAL => new Coal(), + self::APPLE => new Apple(), + self::SPAWN_EGG => new SpawnEgg(), + self::DIAMOND => new Diamond(), + self::STICK => new Stick(), + self::BOWL => new Bowl(), + self::FEATHER => new Feather(), + self::BRICK => new Brick(), + self::IRON_INGOT => new IronIngot(), + self::GOLD_INGOT => new GoldIngot(), + self::IRON_SHOVEL => new IronShovel(), + self::IRON_PICKAXE => new IronPickaxe(), + self::IRON_AXE => new IronAxe(), + self::IRON_HOE => new IronHoe(), + self::WOODEN_SWORD => new WoodenSword(), + self::WOODEN_SHOVEL => new WoodenShovel(), + self::WOODEN_PICKAXE => new WoodenPickaxe(), + self::WOODEN_AXE => new WoodenAxe(), + self::FLINT_STEEL => new FlintSteel(), ); foreach(Block::$list as $id => $class){ self::$list[$id] = new ItemBlock($class); @@ -459,7 +459,7 @@ class Item{ $this->meta = (int) $meta; $this->count = (int) $count; $this->name = $name; - if(!isset($this->block) and $this->id <= 0xff and isset(Block::$class[$this->id])){ + if(!isset($this->block) and $this->id <= 0xff and isset(Block::$list[$this->id])){ $this->block = Block::get($this->id, $this->meta); $this->name = $this->block->getName(); } diff --git a/src/item/MelonSeeds.php b/src/item/MelonSeeds.php index c71afedd9..d539a2728 100644 --- a/src/item/MelonSeeds.php +++ b/src/item/MelonSeeds.php @@ -26,7 +26,7 @@ use PocketMine\Block\Block as Block; class MelonSeeds extends Item{ public function __construct($meta = 0, $count = 1){ - $this->block = Block::get(MELON_STEM); - parent::__construct(MELON_SEEDS, 0, $count, "Melon Seeds"); + $this->block = Block::get(Item::MELON_STEM); + parent::__construct(self::MELON_SEEDS, 0, $count, "Melon Seeds"); } } \ No newline at end of file diff --git a/src/item/MushroomStew.php b/src/item/MushroomStew.php index 6f721f1a8..c2ab3fc46 100644 --- a/src/item/MushroomStew.php +++ b/src/item/MushroomStew.php @@ -25,7 +25,7 @@ use PocketMine; class MushroomStew extends Item{ public function __construct($meta = 0, $count = 1){ - parent::__construct(MUSHROOM_STEW, 0, $count, "Mushroom Stew"); + parent::__construct(self::MUSHROOM_STEW, 0, $count, "Mushroom Stew"); $this->maxStackSize = 1; } diff --git a/src/item/Painting.php b/src/item/Painting.php index 32fc4ed8c..1f05eb6f8 100644 --- a/src/item/Painting.php +++ b/src/item/Painting.php @@ -28,7 +28,7 @@ use PocketMine; class Painting extends Item{ public function __construct($meta = 0, $count = 1){ - parent::__construct(PAINTING, 0, $count, "Painting"); + parent::__construct(self::PAINTING, 0, $count, "Painting"); $this->isActivable = true; } diff --git a/src/item/Potato.php b/src/item/Potato.php index d0b807f5e..72fea4483 100644 --- a/src/item/Potato.php +++ b/src/item/Potato.php @@ -26,7 +26,7 @@ use PocketMine\Block\Block as Block; class Potato extends Item{ public function __construct($meta = 0, $count = 1){ - $this->block = Block::get(POTATO_BLOCK); - parent::__construct(POTATO, 0, $count, "Potato"); + $this->block = Block::get(Item::POTATO_BLOCK); + parent::__construct(self::POTATO, 0, $count, "Potato"); } } \ No newline at end of file diff --git a/src/item/PumpkinSeeds.php b/src/item/PumpkinSeeds.php index 9e7747d36..569183b8d 100644 --- a/src/item/PumpkinSeeds.php +++ b/src/item/PumpkinSeeds.php @@ -26,7 +26,7 @@ use PocketMine\Block\Block as Block; class PumpkinSeeds extends Item{ public function __construct($meta = 0, $count = 1){ - $this->block = Block::get(PUMPKIN_STEM); - parent::__construct(PUMPKIN_SEEDS, 0, $count, "Pumpkin Seeds"); + $this->block = Block::get(Item::PUMPKIN_STEM); + parent::__construct(self::PUMPKIN_SEEDS, 0, $count, "Pumpkin Seeds"); } } \ No newline at end of file diff --git a/src/item/SignItem.php b/src/item/Sign.php similarity index 90% rename from src/item/SignItem.php rename to src/item/Sign.php index ad8bfc277..17c047cad 100644 --- a/src/item/SignItem.php +++ b/src/item/Sign.php @@ -26,8 +26,8 @@ use PocketMine\Block\Block as Block; class Sign extends Item{ public function __construct($meta = 0, $count = 1){ - $this->block = Block::get(SIGN_POST); + $this->block = Block::get(Item::SIGN_POST); $this->maxStackSize = 16; - parent::__construct(SIGN, 0, $count, "Sign"); + parent::__construct(self::SIGN, 0, $count, "Sign"); } } \ No newline at end of file diff --git a/src/item/SpawnEgg.php b/src/item/SpawnEgg.php index 3b378b1b6..064eee043 100644 --- a/src/item/SpawnEgg.php +++ b/src/item/SpawnEgg.php @@ -27,7 +27,7 @@ use PocketMine; class SpawnEgg extends Item{ public function __construct($meta = 0, $count = 1){ - parent::__construct(SPAWN_EGG, 0, $count, "Spawn Egg"); + parent::__construct(self::SPAWN_EGG, 0, $count, "Spawn Egg"); $this->meta = $meta; $this->isActivable = true; } diff --git a/src/item/Stick.php b/src/item/Stick.php index c4cdec2d0..40941afe8 100644 --- a/src/item/Stick.php +++ b/src/item/Stick.php @@ -25,7 +25,7 @@ use PocketMine; class Stick extends Item{ public function __construct($meta = 0, $count = 1){ - parent::__construct(STICK, 0, $count, "Stick"); + parent::__construct(self::STICK, 0, $count, "Stick"); } } \ No newline at end of file diff --git a/src/item/Sugarcane.php b/src/item/Sugarcane.php index 85f7c090d..d0b5397b9 100644 --- a/src/item/Sugarcane.php +++ b/src/item/Sugarcane.php @@ -26,7 +26,7 @@ use PocketMine\Block\Block as Block; class Sugarcane extends Item{ public function __construct($meta = 0, $count = 1){ - $this->block = Block::get(SUGARCANE_BLOCK); - parent::__construct(SUGARCANE, 0, $count, "Sugar Cane"); + $this->block = Block::get(Item::SUGARCANE_BLOCK); + parent::__construct(self::SUGARCANE, 0, $count, "Sugar Cane"); } } \ No newline at end of file diff --git a/src/item/WheatSeeds.php b/src/item/WheatSeeds.php index d700ff5da..7c4fe7311 100644 --- a/src/item/WheatSeeds.php +++ b/src/item/WheatSeeds.php @@ -26,7 +26,7 @@ use PocketMine\Block\Block as Block; class WheatSeeds extends Item{ public function __construct($meta = 0, $count = 1){ - $this->block = Block::get(WHEAT_BLOCK); - parent::__construct(WHEAT_SEEDS, 0, $count, "Wheat Seeds"); + $this->block = Block::get(Item::WHEAT_BLOCK); + parent::__construct(self::WHEAT_SEEDS, 0, $count, "Wheat Seeds"); } } \ No newline at end of file diff --git a/src/item/WoodenAxe.php b/src/item/WoodenAxe.php index db90c3f24..6dd0e81fd 100644 --- a/src/item/WoodenAxe.php +++ b/src/item/WoodenAxe.php @@ -25,7 +25,7 @@ use PocketMine; class WoodenAxe extends Item{ public function __construct($meta = 0, $count = 1){ - parent::__construct(WOODEN_AXE, 0, $count, "Wooden Axe"); + parent::__construct(self::WOODEN_AXE, 0, $count, "Wooden Axe"); } } diff --git a/src/item/WoodenDoor.php b/src/item/WoodenDoor.php index 6a2a200fc..8aa477f75 100644 --- a/src/item/WoodenDoor.php +++ b/src/item/WoodenDoor.php @@ -26,8 +26,8 @@ use PocketMine\Block\Block as Block; class WoodenDoor extends Item{ public function __construct($meta = 0, $count = 1){ - $this->block = Block::get(WOODEN_DOOR_BLOCK); - parent::__construct(WOODEN_DOOR, 0, $count, "Wooden Door"); + $this->block = Block::get(Item::WOODEN_DOOR_BLOCK); + parent::__construct(self::WOODEN_DOOR, 0, $count, "Wooden Door"); $this->maxStackSize = 1; } } \ No newline at end of file diff --git a/src/item/WoodenPickaxe.php b/src/item/WoodenPickaxe.php index 58ff5a096..59b126903 100644 --- a/src/item/WoodenPickaxe.php +++ b/src/item/WoodenPickaxe.php @@ -25,7 +25,7 @@ use PocketMine; class WoodenPickaxe extends Item{ public function __construct($meta = 0, $count = 1){ - parent::__construct(WOODEN_PICKAXE, 0, $count, "Wooden Pickaxe"); + parent::__construct(self::WOODEN_PICKAXE, 0, $count, "Wooden Pickaxe"); } } diff --git a/src/item/WoodenShovel.php b/src/item/WoodenShovel.php index 1620b8e2d..e1b97bef6 100644 --- a/src/item/WoodenShovel.php +++ b/src/item/WoodenShovel.php @@ -25,7 +25,7 @@ use PocketMine; class WoodenShovel extends Item{ public function __construct($meta = 0, $count = 1){ - parent::__construct(WOODEN_SHOVEL, 0, $count, "Wooden Shovel"); + parent::__construct(self::WOODEN_SHOVEL, 0, $count, "Wooden Shovel"); } } diff --git a/src/item/WoodenSword.php b/src/item/WoodenSword.php index d0f82fb14..97a99be51 100644 --- a/src/item/WoodenSword.php +++ b/src/item/WoodenSword.php @@ -25,7 +25,7 @@ use PocketMine; class WoodenSword extends Item{ public function __construct($meta = 0, $count = 1){ - parent::__construct(WOODEN_SWORD, 0, $count, "Wooden Sword"); + parent::__construct(self::WOODEN_SWORD, 0, $count, "Wooden Sword"); } } diff --git a/src/level/Level.php b/src/level/Level.php index c49cf21f2..8df020e79 100644 --- a/src/level/Level.php +++ b/src/level/Level.php @@ -26,6 +26,7 @@ namespace PocketMine\Level; use PocketMine\Block\Air as Air; use PocketMine\Block\Block as Block; +use PocketMine\Item\Item as Item; use PocketMine\Level\Generator\Generator as Generator; use PocketMine\Math\Vector3 as Vector3; use PocketMine\NBT\Tag\Compound as Compound; @@ -253,13 +254,13 @@ class Level{ protected function doSaveRoundExtra(){ foreach($this->usedChunks as $index => $d){ LevelFormat::getXZ($index, $X, $Z); - $nbt = new NBT(NBT\BIG_ENDIAN); + $nbt = new NBT(NBT::BIG_ENDIAN); $nbt->setData(new Compound("", array( "Entities" => new Enum("Entities", array()), "TileEntities" => new Enum("TileEntities", array()), ))); - $nbt->Entities->setTagType(NBT\TAG_Compound); - $nbt->TileEntities->setTagType(NBT\TAG_Compound); + $nbt->Entities->setTagType(NBT::TAG_Compound); + $nbt->TileEntities->setTagType(NBT::TAG_Compound); $i = 0; foreach($this->chunkEntities[$index] as $entity){ @@ -285,7 +286,7 @@ class Level{ public function getBlockRaw(Vector3 $pos){ $b = $this->level->getBlock($pos->x, $pos->y, $pos->z); - return BlockBlock::get($b[0], $b[1], new Position($pos->x, $pos->y, $pos->z, $this)); + return Block::get($b[0], $b[1], new Position($pos->x, $pos->y, $pos->z, $this)); } public function getBlock(Vector3 $pos){ @@ -294,7 +295,7 @@ class Level{ } $b = $this->level->getBlock($pos->x, $pos->y, $pos->z); - return BlockBlock::get($b[0], $b[1], new Position($pos->x, $pos->y, $pos->z, $this)); + return Block::get($b[0], $b[1], new Position($pos->x, $pos->y, $pos->z, $this)); } public function setBlockRaw(Vector3 $pos, Block $block, $direct = true, $send = true){ diff --git a/src/level/LevelImport.php b/src/level/LevelImport.php index b074cfc58..abf794d2e 100644 --- a/src/level/LevelImport.php +++ b/src/level/LevelImport.php @@ -41,7 +41,7 @@ class LevelImport{ $tiles = new Config($this->path . "tiles.yml", Config::YAML, unserialize(file_get_contents($this->path . "tileEntities.dat"))); $tiles->save(); } elseif(file_exists($this->path . "chunks.dat") and file_exists($this->path . "level.dat")){ //Pocket - $nbt = new NBT(NBT\LITTLE_ENDIAN); + $nbt = new NBT(NBT::LITTLE_ENDIAN); $nbt->read(substr(file_get_contents($this->path . "level.dat"), 8)); $level = $nbt->getData(); if($level->LevelName == ""){ diff --git a/src/level/generator/noise/Perlin.php b/src/level/generator/noise/Perlin.php index 4eb42a8a6..72d6e11ec 100644 --- a/src/level/generator/noise/Perlin.php +++ b/src/level/generator/noise/Perlin.php @@ -20,7 +20,7 @@ */ namespace PocketMine\Level\Generator\Noise; - +use PocketMine\Utils\Random as Random; use PocketMine; class Perlin extends Generator{ diff --git a/src/level/generator/noise/Simplex.php b/src/level/generator/noise/Simplex.php index c105c44b9..cca88b956 100644 --- a/src/level/generator/noise/Simplex.php +++ b/src/level/generator/noise/Simplex.php @@ -22,7 +22,7 @@ namespace PocketMine\Level\Generator\Noise; use PocketMine; -use PocketMine\Level; +use PocketMine\Utils\Random as Random; /** * Generates simplex-based noise. diff --git a/src/level/generator/object/Ore.php b/src/level/generator/object/Ore.php index 1dbb4929b..db559c805 100644 --- a/src/level/generator/object/Ore.php +++ b/src/level/generator/object/Ore.php @@ -41,7 +41,7 @@ class Ore{ } public function canPlaceObject(Level $level, $x, $y, $z){ - return ($level->level->getBlockID($x, $y, $z) != AIR); + return ($level->level->getBlockID($x, $y, $z) !== 0); } public function placeObject(Level $level, Vector3 $pos){ @@ -81,7 +81,7 @@ class Ore{ $sizeZ = ($z + 0.5 - $seedZ) / $size; $sizeZ *= $sizeZ; - if(($sizeX + $sizeY + $sizeZ) < 1 and $level->level->getBlockID($x, $y, $z) === STONE){ + if(($sizeX + $sizeY + $sizeZ) < 1 and $level->level->getBlockID($x, $y, $z) === 1){ $level->setBlockRaw(new Vector3($x, $y, $z), $this->type->material); } } diff --git a/src/level/generator/object/TallGrass.php b/src/level/generator/object/TallGrass.php index a36111443..7441a7cb1 100644 --- a/src/level/generator/object/TallGrass.php +++ b/src/level/generator/object/TallGrass.php @@ -29,18 +29,18 @@ use PocketMine\Math\Vector3 as Vector3; class TallGrass{ public static function growGrass(Level $level, Vector3 $pos, Random $random, $count = 15, $radius = 10){ $arr = array( - Block::get(DANDELION, 0), - Block::get(CYAN_FLOWER, 0), - Block::get(TALL_GRASS, 1), - Block::get(TALL_GRASS, 1), - Block::get(TALL_GRASS, 1), - Block::get(TALL_GRASS, 1) + Block::get(Block::DANDELION, 0), + Block::get(Block::CYAN_FLOWER, 0), + Block::get(Block::TALL_GRASS, 1), + Block::get(Block::TALL_GRASS, 1), + Block::get(Block::TALL_GRASS, 1), + Block::get(Block::TALL_GRASS, 1) ); $arrC = count($arr) - 1; for($c = 0; $c < $count; ++$c){ $x = $random->nextRange($pos->x - $radius, $pos->x + $radius); $z = $random->nextRange($pos->z - $radius, $pos->z + $radius); - if($level->level->getBlockID($x, $pos->y + 1, $z) === AIR and $level->level->getBlockID($x, $pos->y, $z) === GRASS){ + if($level->level->getBlockID($x, $pos->y + 1, $z) === Block::AIR and $level->level->getBlockID($x, $pos->y, $z) === Block::GRASS){ $t = $arr[$random->nextRange(0, $arrC)]; $level->setBlockRaw(new Vector3($x, $pos->y + 1, $z), $t); } diff --git a/src/level/generator/object/Tree.php b/src/level/generator/object/Tree.php index 546f63999..383e5cf16 100644 --- a/src/level/generator/object/Tree.php +++ b/src/level/generator/object/Tree.php @@ -24,6 +24,8 @@ namespace PocketMine\Level\Generator\Object; use PocketMine\Block\Sapling as Sapling; use PocketMine\Level\Level as Level; use PocketMine\Math\Vector3 as Vector3; +use PocketMine\Block\Block as Block; +use PocketMine\Utils\Random as Random; use PocketMine; class Tree{ @@ -36,24 +38,24 @@ class Tree{ 18 => true, ); - public static function growTree(Level $level, Vector3 $pos, Level\Random $random, $type = 0){ + public static function growTree(Level $level, Vector3 $pos, Random $random, $type = 0){ switch($type & 0x03){ - case SaplingBlock::SPRUCE: + case Sapling::SPRUCE: if($random->nextRange(0, 1) === 1){ $tree = new SpruceTree(); } else{ $tree = new PineTree(); } break; - case SaplingBlock::BIRCH: + case Sapling::BIRCH: $tree = new SmallTree(); $tree->type = Sapling::BIRCH; break; - case SaplingBlock::JUNGLE: + case Sapling::JUNGLE: $tree = new SmallTree(); $tree->type = Sapling::JUNGLE; break; - case SaplingBlock::OAK: + case Sapling::OAK: default: /*if($random->nextRange(0, 9) === 0){ $tree = new BigTree(); diff --git a/src/level/generator/populator/TallGrass.php b/src/level/generator/populator/TallGrass.php index 181f87c6a..03ea1d01b 100644 --- a/src/level/generator/populator/TallGrass.php +++ b/src/level/generator/populator/TallGrass.php @@ -23,6 +23,9 @@ namespace PocketMine\Level\Generator\Populator; use PocketMine\Block\TallGrass as BlockTallGrass; use PocketMine\Math\Vector3 as Vector3; +use PocketMine\Level\Level as Level; +use PocketMine\Utils\Random as Random; +use PocketMine\Block\Block as Block; use PocketMine; class TallGrass extends Populator{ @@ -57,13 +60,13 @@ class TallGrass extends Populator{ } private function canTallGrassStay(Block $block){ - return $block->getID() === AIR and $block->getSide(0)->getID() === GRASS; + return $block->getID() === Block::AIR and $block->getSide(0)->getID() === Block::GRASS; } private function getHighestWorkableBlock($x, $z){ for($y = 128; $y > 0; --$y){ $b = $this->level->getBlockRaw(new Vector3($x, $y, $z)); - if($b->getID() === AIR or $b->getID() === LEAVES){ + if($b->getID() === Block::AIR or $b->getID() === Block::LEAVES){ if(--$y <= 0){ return -1; } diff --git a/src/level/generator/populator/Tree.php b/src/level/generator/populator/Tree.php index c7c3f34e5..1003fab92 100644 --- a/src/level/generator/populator/Tree.php +++ b/src/level/generator/populator/Tree.php @@ -24,6 +24,9 @@ namespace PocketMine\Level\Generator\Populator; use PocketMine\Level\Level as Level; use PocketMine\Math\Vector3 as Vector3; use PocketMine\Utils\Random as Random; +use PocketMine\Block\Block as Block; +use PocketMine\Block\Sapling as Sapling; +use PocketMine\Level\Generator\Object\Tree as ObjectTree; use PocketMine; class Tree extends Populator{ @@ -50,18 +53,18 @@ class Tree extends Populator{ continue; } if($random->nextFloat() > 0.75){ - $meta = SaplingBlock::BIRCH; + $meta = Sapling::BIRCH; } else{ - $meta = SaplingBlock::OAK; + $meta = Sapling::OAK; } - TreeObject::growTree($this->level, new Vector3($x, $y, $z), $random, $meta); + ObjectTree::growTree($this->level, new Vector3($x, $y, $z), $random, $meta); } } private function getHighestWorkableBlock($x, $z){ for($y = 128; $y > 0; --$y){ $b = $this->level->getBlockRaw(new Vector3($x, $y, $z)); - if($b->getID() !== DIRT and $b->getID() !== GRASS){ + if($b->getID() !== Block::DIRT and $b->getID() !== Block::GRASS){ if(--$y <= 0){ return -1; } diff --git a/src/nbt/NBT.php b/src/nbt/NBT.php index 6b0cffc42..e007add2c 100644 --- a/src/nbt/NBT.php +++ b/src/nbt/NBT.php @@ -23,20 +23,6 @@ * Named Binary Tag handling classes */ namespace PocketMine\NBT; -const LITTLE_ENDIAN = 0; -const BIG_ENDIAN = 1; -const TAG_End = 0; -const TAG_Byte = 1; -const TAG_Short = 2; -const TAG_Int = 3; -const TAG_Long = 4; -const TAG_Float = 5; -const TAG_Double = 6; -const TAG_Byte_Array = 7; -const TAG_String = 8; -const TAG_Enum = 9; -const TAG_Compound = 10; -const TAG_Int_Array = 11; use PocketMine\NBT\Tag\Byte as Byte; use PocketMine\NBT\Tag\Byte_Array as Byte_Array; use PocketMine\NBT\Tag\Compound as Compound; @@ -55,6 +41,21 @@ use PocketMine\Utils\Utils as Utils; use PocketMine; class NBT implements \ArrayAccess{ + const LITTLE_ENDIAN = 0; + const BIG_ENDIAN = 1; + const TAG_End = 0; + const TAG_Byte = 1; + const TAG_Short = 2; + const TAG_Int = 3; + const TAG_Long = 4; + const TAG_Float = 5; + const TAG_Double = 6; + const TAG_Byte_Array = 7; + const TAG_String = 8; + const TAG_Enum = 9; + const TAG_Compound = 10; + const TAG_Int_Array = 11; + private $buffer; private $offset; private $endianness; @@ -84,7 +85,7 @@ class NBT implements \ArrayAccess{ return !isset($this->buffer{$this->offset}); } - public function __construct($endianness = NBT\LITTLE_ENDIAN){ + public function __construct($endianness = NBT\NBT::LITTLE_ENDIAN){ $this->offset = 0; $this->endianness = $endianness & 0x01; } @@ -109,52 +110,52 @@ class NBT implements \ArrayAccess{ public function readTag(){ switch($this->getByte()){ - case NBT\TAG_Byte: + case NBT::TAG_Byte: $tag = new Byte($this->getString()); $tag->read($this); break; - case NBT\TAG_Short: + case NBT::TAG_Short: $tag = new Short($this->getString()); $tag->read($this); break; - case NBT\TAG_Int: + case NBT::TAG_Int: $tag = new Int($this->getString()); $tag->read($this); break; - case NBT\TAG_Long: + case NBT::TAG_Long: $tag = new Long($this->getString()); $tag->read($this); break; - case NBT\TAG_Float: + case NBT::TAG_Float: $tag = new Float($this->getString()); $tag->read($this); break; - case NBT\TAG_Double: + case NBT::TAG_Double: $tag = new Double($this->getString()); $tag->read($this); break; - case NBT\TAG_Byte_Array: + case NBT::TAG_Byte_Array: $tag = new Byte_Array($this->getString()); $tag->read($this); break; - case NBT\TAG_String: + case NBT::TAG_String: $tag = new String($this->getString()); $tag->read($this); break; - case NBT\TAG_Enum: + case NBT::TAG_Enum: $tag = new Enum($this->getString()); $tag->read($this); break; - case NBT\TAG_Compound: + case NBT::TAG_Compound: $tag = new Compound($this->getString()); $tag->read($this); break; - case NBT\TAG_Int_Array: + case NBT::TAG_Int_Array: $tag = new Int_Array($this->getString()); $tag->read($this); break; - case NBT\TAG_End: //No named tag + case NBT::TAG_End: //No named tag default: $tag = new End; break; @@ -179,43 +180,43 @@ class NBT implements \ArrayAccess{ } public function getShort(){ - return $this->endianness === BIG_ENDIAN ? Utils::readShort($this->get(2)) : Utils::readLShort($this->get(2)); + return $this->endianness === self::BIG_ENDIAN ? Utils::readShort($this->get(2)) : Utils::readLShort($this->get(2)); } public function putShort($v){ - $this->buffer .= $this->endianness === BIG_ENDIAN ? Utils::writeShort($v) : Utils::writeLShort($v); + $this->buffer .= $this->endianness === self::BIG_ENDIAN ? Utils::writeShort($v) : Utils::writeLShort($v); } public function getInt(){ - return $this->endianness === BIG_ENDIAN ? Utils::readInt($this->get(4)) : Utils::readLInt($this->get(4)); + return $this->endianness === self::BIG_ENDIAN ? Utils::readInt($this->get(4)) : Utils::readLInt($this->get(4)); } public function putInt($v){ - $this->buffer .= $this->endianness === BIG_ENDIAN ? Utils::writeInt($v) : Utils::writeLInt($v); + $this->buffer .= $this->endianness === self::BIG_ENDIAN ? Utils::writeInt($v) : Utils::writeLInt($v); } public function getLong(){ - return $this->endianness === BIG_ENDIAN ? Utils::readLong($this->get(8)) : Utils::readLLong($this->get(8)); + return $this->endianness === self::BIG_ENDIAN ? Utils::readLong($this->get(8)) : Utils::readLLong($this->get(8)); } public function putLong($v){ - $this->buffer .= $this->endianness === BIG_ENDIAN ? Utils::writeLong($v) : Utils::writeLLong($v); + $this->buffer .= $this->endianness === self::BIG_ENDIAN ? Utils::writeLong($v) : Utils::writeLLong($v); } public function getFloat(){ - return $this->endianness === BIG_ENDIAN ? Utils::readFloat($this->get(4)) : Utils::readLFloat($this->get(4)); + return $this->endianness === self::BIG_ENDIAN ? Utils::readFloat($this->get(4)) : Utils::readLFloat($this->get(4)); } public function putFloat($v){ - $this->buffer .= $this->endianness === BIG_ENDIAN ? Utils::writeFloat($v) : Utils::writeLFloat($v); + $this->buffer .= $this->endianness === self::BIG_ENDIAN ? Utils::writeFloat($v) : Utils::writeLFloat($v); } public function getDouble(){ - return $this->endianness === BIG_ENDIAN ? Utils::readDouble($this->get(8)) : Utils::readLDouble($this->get(8)); + return $this->endianness === self::BIG_ENDIAN ? Utils::readDouble($this->get(8)) : Utils::readLDouble($this->get(8)); } public function putDouble($v){ - $this->buffer .= $this->endianness === BIG_ENDIAN ? Utils::writeDouble($v) : Utils::writeLDouble($v); + $this->buffer .= $this->endianness === self::BIG_ENDIAN ? Utils::writeDouble($v) : Utils::writeLDouble($v); } public function getString(){ diff --git a/src/nbt/tag/Byte.php b/src/nbt/tag/Byte.php index 001029176..4e575afb2 100644 --- a/src/nbt/tag/Byte.php +++ b/src/nbt/tag/Byte.php @@ -22,12 +22,12 @@ namespace PocketMine\NBT\Tag; use PocketMine; -use PocketMine\NBT; +use PocketMine\NBT\NBT as NBT; class Byte extends NamedTag{ public function getType(){ - return NBT\TAG_Byte; + return NBT::TAG_Byte; } public function read(NBT $nbt){ diff --git a/src/nbt/tag/Byte_Array.php b/src/nbt/tag/Byte_Array.php index af063e0e1..cbbb4d2ad 100644 --- a/src/nbt/tag/Byte_Array.php +++ b/src/nbt/tag/Byte_Array.php @@ -22,12 +22,12 @@ namespace PocketMine\NBT\Tag; use PocketMine; -use PocketMine\NBT; +use PocketMine\NBT\NBT as NBT; class Byte_Array extends NamedTag{ public function getType(){ - return NBT\TAG_Byte_Array; + return NBT::TAG_Byte_Array; } public function read(NBT $nbt){ diff --git a/src/nbt/tag/Compound.php b/src/nbt/tag/Compound.php index 01e41b235..691afc5f8 100644 --- a/src/nbt/tag/Compound.php +++ b/src/nbt/tag/Compound.php @@ -22,19 +22,17 @@ namespace PocketMine\NBT\Tag; use PocketMine; -use PocketMine\NBT; +use PocketMine\NBT\NBT as NBT; class Compound extends NamedTag implements \ArrayAccess, \Iterator{ public function __construct($name = "", $value = array()){ $this->name = $name; - if($value !== false){ - $this->value = $value; - } + $this->value = $value; } public function getType(){ - return NBT\TAG_Compound; + return NBT::TAG_Compound; } public function rewind(){ @@ -77,7 +75,7 @@ class Compound extends NamedTag implements \ArrayAccess, \Iterator{ public function &__get($name){ $ret = isset($this->value[$name]) ? $this->value[$name] : false; - if(!is_object($ret) or $ret instanceof ArrayAccess){ + if(!is_object($ret) or $ret instanceof \ArrayAccess){ return $ret; } else{ return $ret->getValue(); @@ -85,10 +83,10 @@ class Compound extends NamedTag implements \ArrayAccess, \Iterator{ } public function __set($name, $value){ - if($value instanceof NBTTag){ + if($value instanceof Tag){ $this->value[$name] = $value; } elseif(isset($this->value[$name])){ - if($value instanceof NamedNBTTag and $value->getName() !== "" and $value->getName() !== false){ + if($value instanceof NamedTag and $value->getName() !== "" and $value->getName() !== false){ $this->value[$value->getName()]->setValue($value); } else{ $this->value[$name]->setValue($value); @@ -108,7 +106,7 @@ class Compound extends NamedTag implements \ArrayAccess, \Iterator{ $this->value = array(); do{ $tag = $nbt->readTag(); - if($tag instanceof NamedNBTTag and $tag->getName() !== ""){ + if($tag instanceof NamedTag and $tag->getName() !== ""){ $this->value[$tag->getName()] = $tag; } elseif(!($tag instanceof End)){ $this->value[] = $tag; diff --git a/src/nbt/tag/Double.php b/src/nbt/tag/Double.php index 38c7d5483..9a1ba89d6 100644 --- a/src/nbt/tag/Double.php +++ b/src/nbt/tag/Double.php @@ -22,12 +22,12 @@ namespace PocketMine\NBT\Tag; use PocketMine; -use PocketMine\NBT; +use PocketMine\NBT\NBT as NBT; class Double extends NamedTag{ public function getType(){ - return NBT\TAG_Double; + return NBT::TAG_Double; } public function read(NBT $nbt){ diff --git a/src/nbt/tag/End.php b/src/nbt/tag/End.php index 2431f24e5..7f42b4bb2 100644 --- a/src/nbt/tag/End.php +++ b/src/nbt/tag/End.php @@ -22,12 +22,12 @@ namespace PocketMine\NBT\Tag; use PocketMine; -use PocketMine\NBT; +use PocketMine\NBT\NBT as NBT; class End extends Tag{ public function getType(){ - return NBT\TAG_End; + return NBT::TAG_End; } public function read(NBT $nbt){ diff --git a/src/nbt/tag/Enum.php b/src/nbt/tag/Enum.php index 8a5225564..0a09a2f1e 100644 --- a/src/nbt/tag/Enum.php +++ b/src/nbt/tag/Enum.php @@ -23,7 +23,7 @@ namespace PocketMine\NBT\Tag; use PocketMine\NBT\Tag\Enum as TagEnum; use PocketMine; -use PocketMine\NBT; +use PocketMine\NBT\NBT as NBT; class Enum extends NamedTag implements \ArrayAccess, \Iterator{ @@ -31,13 +31,11 @@ class Enum extends NamedTag implements \ArrayAccess, \Iterator{ public function __construct($name = "", $value = array()){ $this->name = $name; - if($value !== false){ - $this->value = $value; - } + $this->value = $value; } public function getType(){ - return NBT\TAG_Enum; + return NBT::TAG_Enum; } public function setTagType($type){ @@ -88,7 +86,7 @@ class Enum extends NamedTag implements \ArrayAccess, \Iterator{ public function &__get($name){ $ret = isset($this->value[$name]) ? $this->value[$name] : false; - if(!is_object($ret) or $ret instanceof ArrayAccess){ + if(!is_object($ret) or $ret instanceof \ArrayAccess){ return $ret; } else{ return $ret->getValue(); @@ -96,7 +94,7 @@ class Enum extends NamedTag implements \ArrayAccess, \Iterator{ } public function __set($name, $value){ - if($value instanceof NBTTag){ + if($value instanceof Tag){ $this->value[$name] = $value; } elseif(isset($this->value[$name])){ $this->value[$name]->setValue($value); @@ -117,57 +115,57 @@ class Enum extends NamedTag implements \ArrayAccess, \Iterator{ $size = $nbt->getInt(); for($i = 0; $i < $size and !$nbt->feof(); ++$i){ switch($this->tagType){ - case NBT\TAG_Byte: + case NBT::TAG_Byte: $tag = new Byte(false); $tag->read($nbt); $this->value[] = $tag; break; - case NBT\TAG_Short: + case NBT::TAG_Short: $tag = new Short(false); $tag->read($nbt); $this->value[] = $tag; break; - case NBT\TAG_Int: + case NBT::TAG_Int: $tag = new Int(false); $tag->read($nbt); $this->value[] = $tag; break; - case NBT\TAG_Long: + case NBT::TAG_Long: $tag = new Long(false); $tag->read($nbt); $this->value[] = $tag; break; - case NBT\TAG_Float: + case NBT::TAG_Float: $tag = new Float(false); $tag->read($nbt); $this->value[] = $tag; break; - case NBT\TAG_Double: + case NBT::TAG_Double: $tag = new Double(false); $tag->read($nbt); $this->value[] = $tag; break; - case NBT\TAG_Byte_Array: + case NBT::TAG_Byte_Array: $tag = new Byte_Array(false); $tag->read($nbt); $this->value[] = $tag; break; - case NBT\TAG_String: + case NBT::TAG_String: $tag = new String(false); $tag->read($nbt); $this->value[] = $tag; break; - case NBT\TAG_Enum: + case NBT::TAG_Enum: $tag = new TagEnum(false); $tag->read($nbt); $this->value[] = $tag; break; - case NBT\TAG_Compound: + case NBT::TAG_Compound: $tag = new Compound(false); $tag->read($nbt); $this->value[] = $tag; break; - case NBT\TAG_Int_Array: + case NBT::TAG_Int_Array: $tag = new Int_Array(false); $tag->read($nbt); $this->value[] = $tag; @@ -191,7 +189,7 @@ class Enum extends NamedTag implements \ArrayAccess, \Iterator{ $nbt->putByte($this->tagType); $nbt->putInt(count($this->value)); foreach($this->value as $tag){ - if($tag instanceof NBTTag){ + if($tag instanceof Tag){ $tag->write($nbt); } } diff --git a/src/nbt/tag/Float.php b/src/nbt/tag/Float.php index 37ee7a098..3b1fdc231 100644 --- a/src/nbt/tag/Float.php +++ b/src/nbt/tag/Float.php @@ -22,12 +22,12 @@ namespace PocketMine\NBT\Tag; use PocketMine; -use PocketMine\NBT; +use PocketMine\NBT\NBT as NBT; class Float extends NamedTag{ public function getType(){ - return NBT\TAG_Float; + return NBT::TAG_Float; } public function read(NBT $nbt){ diff --git a/src/nbt/tag/Int.php b/src/nbt/tag/Int.php index 85464f960..9620476a5 100644 --- a/src/nbt/tag/Int.php +++ b/src/nbt/tag/Int.php @@ -22,12 +22,12 @@ namespace PocketMine\NBT\Tag; use PocketMine; -use PocketMine\NBT; +use PocketMine\NBT\NBT as NBT; class Int extends NamedTag{ public function getType(){ - return NBT\TAG_Int; + return NBT::TAG_Int; } public function read(NBT $nbt){ diff --git a/src/nbt/tag/Int_Array.php b/src/nbt/tag/Int_Array.php index 8f06a3c52..838f9e7fb 100644 --- a/src/nbt/tag/Int_Array.php +++ b/src/nbt/tag/Int_Array.php @@ -22,12 +22,12 @@ namespace PocketMine\NBT\Tag; use PocketMine; -use PocketMine\NBT; +use PocketMine\NBT\NBT as NBT; class Int_Array extends NamedTag{ public function getType(){ - return NBT\TAG_Int_Array; + return NBT::TAG_Int_Array; } public function read(NBT $nbt){ diff --git a/src/nbt/tag/Long.php b/src/nbt/tag/Long.php index 258aaeb90..c1c5249f2 100644 --- a/src/nbt/tag/Long.php +++ b/src/nbt/tag/Long.php @@ -22,12 +22,12 @@ namespace PocketMine\NBT\Tag; use PocketMine; -use PocketMine\NBT; +use PocketMine\NBT\NBT as NBT; class Long extends NamedTag{ public function getType(){ - return NBT\TAG_Long; + return NBT::TAG_Long; } public function read(NBT $nbt){ diff --git a/src/nbt/tag/Short.php b/src/nbt/tag/Short.php index a0e3181fe..f198b0b97 100644 --- a/src/nbt/tag/Short.php +++ b/src/nbt/tag/Short.php @@ -22,12 +22,12 @@ namespace PocketMine\NBT\Tag; use PocketMine; -use PocketMine\NBT; +use PocketMine\NBT\NBT as NBT; class Short extends NamedTag{ public function getType(){ - return NBT\TAG_Short; + return NBT::TAG_Short; } public function read(NBT $nbt){ diff --git a/src/nbt/tag/String.php b/src/nbt/tag/String.php index 1eecd9396..16bb636d9 100644 --- a/src/nbt/tag/String.php +++ b/src/nbt/tag/String.php @@ -22,12 +22,12 @@ namespace PocketMine\NBT\Tag; use PocketMine; -use PocketMine\NBT; +use PocketMine\NBT\NBT as NBT; class String extends NamedTag{ public function getType(){ - return NBT\TAG_String; + return NBT::TAG_String; } public function read(NBT $nbt){ diff --git a/src/nbt/tag/Tag.php b/src/nbt/tag/Tag.php index b74044d58..9b1602eef 100644 --- a/src/nbt/tag/Tag.php +++ b/src/nbt/tag/Tag.php @@ -23,6 +23,7 @@ * All the NBT Tags */ namespace PocketMine\NBT\Tag; +use PocketMine\NBT\NBT as NBT; use PocketMine; abstract class Tag{ diff --git a/src/network/query/QueryHandler.php b/src/network/query/QueryHandler.php index f523200b0..d9c0f1e84 100644 --- a/src/network/query/QueryHandler.php +++ b/src/network/query/QueryHandler.php @@ -57,7 +57,7 @@ class QueryHandler{ public function regenerateInfo(){ $str = ""; - $plist = "PocketMine-MP " . VERSION; + $plist = "PocketMine-MP " . PocketMine\VERSION; $pl = $this->server->api->plugin->getList(); if(count($pl) > 0){ $plist .= ":"; @@ -71,8 +71,8 @@ class QueryHandler{ "hostname" => $this->server->name, "gametype" => ($this->server->gamemode & 0x01) === 0 ? "SMP" : "CMP", "game_id" => "MINECRAFTPE", - "version" => MINECRAFT_VERSION, - "server_engine" => "PocketMine-MP " . VERSION, + "version" => PocketMine\MINECRAFT_VERSION, + "server_engine" => "PocketMine-MP " . PocketMine\VERSION, "plugins" => $plist, "map" => $this->server->api->level->getDefault()->getName(), "numplayers" => count(Player::$list), diff --git a/src/pmf/LevelFormat.php b/src/pmf/LevelFormat.php index 2b51e61e9..0c93e17c6 100644 --- a/src/pmf/LevelFormat.php +++ b/src/pmf/LevelFormat.php @@ -22,6 +22,7 @@ namespace PocketMine\PMF; use PocketMine\Level\Level as Level; +use PocketMine\NBT\NBT as NBT; use PocketMine\NBT\Tag\Compound as Compound; use PocketMine\NBT\Tag\Enum as Enum; use PocketMine\Utils\Utils as Utils; @@ -183,13 +184,13 @@ class LevelFormat extends PMF{ private function upgrade_From1_To2(){ console("[NOTICE] Old PMF Level format version #1 detected, upgrading to version #2"); - $nbt = new NBT(NBT\BIG_ENDIAN); + $nbt = new NBT(NBT::BIG_ENDIAN); $nbt->setData(new Compound("", array( "Entities" => new Enum("Entities", array()), "TileEntities" => new Enum("TileEntities", array()) ))); - $nbt->Entities->setTagType(NBT\TAG_Compound); - $nbt->TileEntities->setTagType(NBT\TAG_Compound); + $nbt->Entities->setTagType(NBT::TAG_Compound); + $nbt->TileEntities->setTagType(NBT::TAG_Compound); $namedtag = $nbt->write(); $namedtag = Utils::writeInt(strlen($namedtag)) . $namedtag; foreach(glob(dirname($this->file) . "/chunks/*/*.*.pmc") as $chunkFile){ @@ -291,7 +292,7 @@ class LevelFormat extends PMF{ $offset += 5; $len = Utils::readInt(substr($chunk, $offset, 4)); $offset += 4; - $nbt = new NBT(NBT\BIG_ENDIAN); + $nbt = new NBT(NBT::BIG_ENDIAN); $nbt->read(substr($chunk, $offset, $len)); $this->chunkInfo[$index][2] = $nbt; $offset += $len; @@ -414,13 +415,13 @@ class LevelFormat extends PMF{ 6 => 8192, 7 => 8192, ); - $nbt = new NBT(NBT\BIG_ENDIAN); + $nbt = new NBT(NBT::BIG_ENDIAN); $nbt->setData(new Compound("", array( "Entities" => new Enum("Entities", array()), "TileEntities" => new Enum("TileEntities", array()) ))); - $nbt->Entities->setTagType(NBT\TAG_Compound); - $nbt->TileEntities->setTagType(NBT\TAG_Compound); + $nbt->Entities->setTagType(NBT::TAG_Compound); + $nbt->TileEntities->setTagType(NBT::TAG_Compound); $this->chunkInfo[$index] = array( 0 => 0, 1 => 0, @@ -588,13 +589,13 @@ class LevelFormat extends PMF{ $Z = $z >> 4; $Y = $y >> 4; if($y < 0 or $y > 127){ - return array(AIR, 0); + return array(0, 0); } $index = self::getIndex($X, $Z); if(!isset($this->chunks[$index]) and $this->loadChunk($X, $Z) === false){ - return array(AIR, 0); + return array(0, 0); } elseif($this->chunks[$index][$Y] === false){ - return array(AIR, 0); + return array(0, 0); } $aX = $x - ($X << 4); $aZ = $z - ($Z << 4); diff --git a/src/recipes/Crafting.php b/src/recipes/Crafting.php index 48bb99c4a..9bb974edc 100644 --- a/src/recipes/Crafting.php +++ b/src/recipes/Crafting.php @@ -26,6 +26,7 @@ namespace PocketMine\Recipes; use PocketMine\BlockAPI as BlockAPI; use PocketMine\ServerAPI as ServerAPI; +use PocketMine\Item\Item as Item; use PocketMine; abstract class Crafting{ @@ -256,26 +257,26 @@ abstract class Crafting{ public static function init(){ $server = ServerAPI::request(); $id = 1; - foreach(CraftingRecipes::$small as $recipe){ - $recipe = CraftingRecipes::parseRecipe($recipe); + foreach(self::$small as $recipe){ + $recipe = self::parseRecipe($recipe); $recipe[3] = 0; //Type - CraftingRecipes::$recipes[$id] = $recipe; + self::$recipes[$id] = $recipe; ++$id; } - foreach(CraftingRecipes::$big as $recipe){ - $recipe = CraftingRecipes::parseRecipe($recipe); + foreach(self::$big as $recipe){ + $recipe = self::parseRecipe($recipe); $recipe[3] = 1; - CraftingRecipes::$recipes[$id] = $recipe; + self::$recipes[$id] = $recipe; ++$id; } - foreach(CraftingRecipes::$stone as $recipe){ - $recipe = CraftingRecipes::parseRecipe($recipe); + foreach(self::$stone as $recipe){ + $recipe = self::parseRecipe($recipe); $recipe[3] = 2; - CraftingRecipes::$recipes[$id] = $recipe; + self::$recipes[$id] = $recipe; ++$id; } - foreach(CraftingRecipes::$recipes as $id => $recipe){ + foreach(self::$recipes as $id => $recipe){ $server->query("INSERT INTO recipes (id, type, recipe) VALUES (" . $id . ", " . $recipe[3] . ", '" . $recipe[2] . "');"); } @@ -296,7 +297,7 @@ abstract class Crafting{ $continue = true; while(($r = $result->fetchArray(SQLITE3_NUM)) !== false){ $continue = true; - $recipe = CraftingRecipes::$recipes[$r[0]]; + $recipe = self::$recipes[$r[0]]; foreach($recipe[0] as $item){ if(!isset($recipeItems[$item[0]])){ $continue = false; diff --git a/src/tile/Chest.php b/src/tile/Chest.php index 77e933c97..a6cd13a7f 100644 --- a/src/tile/Chest.php +++ b/src/tile/Chest.php @@ -97,7 +97,7 @@ class Chest extends Spawnable{ return false; } - $nbt = new NBT(NBT\LITTLE_ENDIAN); + $nbt = new NBT(NBT::LITTLE_ENDIAN); if($this->isPaired()){ $nbt->setData(new Compound("", array( new String("id", Tile::CHEST), diff --git a/src/tile/Sign.php b/src/tile/Sign.php index d4f494a75..233f6e660 100644 --- a/src/tile/Sign.php +++ b/src/tile/Sign.php @@ -60,7 +60,7 @@ class Sign extends Spawnable{ return false; } - $nbt = new NBT(NBT\LITTLE_ENDIAN); + $nbt = new NBT(NBT::LITTLE_ENDIAN); $nbt->setData(new Compound("", array( new String("Text1", $this->namedtag->Text1), new String("Text2", $this->namedtag->Text2), diff --git a/src/tile/Tile.php b/src/tile/Tile.php index 283d2d4c7..e59e2f205 100644 --- a/src/tile/Tile.php +++ b/src/tile/Tile.php @@ -29,6 +29,7 @@ use PocketMine\Level\Level as Level; use PocketMine\NBT\Tag\Compound as Compound; use PocketMine\PMF\LevelFormat as LevelFormat; use PocketMine\ServerAPI as ServerAPI; +use PocketMine\Level\Position; use PocketMine; abstract class Tile extends Position{ diff --git a/src/utils/Utils.php b/src/utils/Utils.php index 0c4ac4f99..6cd6a03e1 100644 --- a/src/utils/Utils.php +++ b/src/utils/Utils.php @@ -659,4 +659,4 @@ class Utils{ } -define('Utils\ENDIANNESS', (pack("d", 1) === "\77\360\0\0\0\0\0\0" ? Utils::BIG_ENDIAN : Utils::LITTLE_ENDIAN)); \ No newline at end of file +define("PocketMine\\Utils\\ENDIANNESS", (pack("d", 1) === "\77\360\0\0\0\0\0\0" ? Utils::BIG_ENDIAN : Utils::LITTLE_ENDIAN)); \ No newline at end of file diff --git a/src/utils/pthreads.php b/src/utils/pthreads.php index 1551f2e82..242517e71 100644 --- a/src/utils/pthreads.php +++ b/src/utils/pthreads.php @@ -74,36 +74,36 @@ class AsyncMultipleQueue extends Thread{ public function run(){ while($this->stop === false){ if(isset($this->input{5})){ //len 6 min - $rID = Utils::readInt($this->get(4)); - switch(Utils::readShort($this->get(2), false)){ + $rID = \PocketMine\Utils\Utils::readInt($this->get(4)); + switch(\PocketMine\Utils\Utils::readShort($this->get(2), false)){ case ASYNC_CURL_GET: - $url = $this->get(Utils::readShort($this->get(2), false)); - $timeout = Utils::readShort($this->get(2)); + $url = $this->get(\PocketMine\Utils\Utils::readShort($this->get(2), false)); + $timeout = \PocketMine\Utils\Utils::readShort($this->get(2)); - $res = (string) Utils::curl_get($url, $timeout); + $res = (string) \PocketMine\Utils\Utils::curl_get($url, $timeout); $this->lock(); - $this->output .= Utils::writeInt($rID) . Utils::writeShort(ASYNC_CURL_GET) . Utils::writeInt(strlen($res)) . $res; + $this->output .= \PocketMine\Utils\Utils::writeInt($rID) . \PocketMine\Utils\Utils::writeShort(ASYNC_CURL_GET) . \PocketMine\Utils\Utils::writeInt(strlen($res)) . $res; $this->unlock(); break; case ASYNC_CURL_POST: - $url = $this->get(Utils::readShort($this->get(2), false)); - $timeout = Utils::readShort($this->get(2)); - $cnt = Utils::readShort($this->get(2), false); + $url = $this->get(\PocketMine\Utils\Utils::readShort($this->get(2), false)); + $timeout = \PocketMine\Utils\Utils::readShort($this->get(2)); + $cnt = \PocketMine\Utils\Utils::readShort($this->get(2), false); $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))); + $key = $this->get(\PocketMine\Utils\Utils::readShort($this->get(2), false)); + $d[$key] = $this->get(\PocketMine\Utils\Utils::readInt($this->get(4))); } - $res = (string) Utils::curl_post($url, $d, $timeout); + $res = (string) \PocketMine\Utils\Utils::curl_post($url, $d, $timeout); $this->lock(); - $this->output .= Utils::writeInt($rID) . Utils::writeShort(ASYNC_CURL_POST) . Utils::writeInt(strlen($res)) . $res; + $this->output .= \PocketMine\Utils\Utils::writeInt($rID) . \PocketMine\Utils\Utils::writeShort(ASYNC_CURL_POST) . \PocketMine\Utils\Utils::writeInt(strlen($res)) . $res; $this->unlock(); break; case ASYNC_FUNCTION: - $function = $this->get(Utils::readShort($this->get(2), false)); - $params = unserialize($this->get(Utils::readInt($this->get(4)))); + $function = $this->get(\PocketMine\Utils\Utils::readShort($this->get(2), false)); + $params = unserialize($this->get(\PocketMine\Utils\Utils::readInt($this->get(4)))); $res = serialize(@call_user_func_array($function, $params)); - $this->output .= Utils::writeInt($rID) . Utils::writeShort(ASYNC_FUNCTION) . Utils::writeInt(strlen($res)) . $res; + $this->output .= \PocketMine\Utils\Utils::writeInt($rID) . \PocketMine\Utils\Utils::writeShort(ASYNC_FUNCTION) . \PocketMine\Utils\Utils::writeInt(strlen($res)) . $res; break; } }