diff --git a/.gitattributes b/.gitattributes
deleted file mode 100644
index bcbb3fc3..00000000
--- a/.gitattributes
+++ /dev/null
@@ -1,27 +0,0 @@
-# Auto detect text files and perform LF normalization
-* text=auto
-*.php text eol=lf
-*.sh text eol=lf
-*.txt text eol=lf
-*.properties text eol=lf
-*.bat text eol=crlf
-
-# Custom for Visual Studio
-*.cs diff=csharp
-*.sln merge=union
-*.csproj merge=union
-*.vbproj merge=union
-*.fsproj merge=union
-*.dbproj merge=union
-
-# Standard to msysgit
-*.doc diff=astextplain
-*.DOC diff=astextplain
-*.docx diff=astextplain
-*.DOCX diff=astextplain
-*.dot diff=astextplain
-*.DOT diff=astextplain
-*.pdf diff=astextplain
-*.PDF diff=astextplain
-*.rtf diff=astextplain
-*.RTF diff=astextplain
diff --git a/.gitignore b/.gitignore
deleted file mode 100644
index 5ae955ca..00000000
--- a/.gitignore
+++ /dev/null
@@ -1,24 +0,0 @@
-players/*
-worlds/*
-plugins/*
-logs/*
-bin/*
-.idea/*
-*.log
-*.pmf
-*.txt
-*.properties
-
-
-############
-## Windows
-############
-
-# Windows image file caches
-Thumbs.db
-
-# Folder config file
-Desktop.ini
-
-# Mac crap
-.DS_Store
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 1c46d5ed..00000000
--- a/.travis.yml
+++ /dev/null
@@ -1,14 +0,0 @@
-language: php
-
-php:
- - 5.4
-
-before_script:
- - pecl install channel://pecl.php.net/pthreads-0.0.44
-
-script:
- - php src/tests/ServerSuiteTest.php
-
-notifications:
- email: false
- webhooks: http://n.tkte.ch/h/214/wsNvmG43-ncxUVRrFPwSM-r0
\ No newline at end of file
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
deleted file mode 100644
index 0eec3d5b..00000000
--- a/CONTRIBUTING.md
+++ /dev/null
@@ -1,68 +0,0 @@
-
-
-# NostalgiaCore Contribution Guidelines
-
-Before contributing to NostalgiaCore, please read this.
-
-## I want to create an issue
-* First, use the [Issue Search](https://github.com/kotyaralih/NostalgiaCore/search?ref=cmdform&type=Issues) to check if anyone has reported it.
-* Is your issue related to a Plugin? If so, please contact their original author instead of reporting it here.
-* And no, we won't update a Plugin because you need it.
-* When reporting, give as much info as you can, and if the Issue is a crash, give the Crash Dump.
-* Issues should be written in English.
-
-## I want to contribute code
-* Use the [Pull Request](https://github.com/kotyaralih/NostalgiaCore/pull/new) system, your request will be checked and discussed.
-* __Create a single branch for that pull request__
-* If you want to be part of NostalgiaCore, we will ask you to.
-* Code using the syntax as in NostalgiaCore. See below for an example.
-* The code must be clear and written in English, comments included.
-
-
-__Thanks for contributing to NostalgiaCore!__
-
-
-
-
-#### Code syntax
-
-It is mainly [PSR-2](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-1-basic-coding-standard.md) with a few exceptions.
-* Opening braces MUST go on the same line.
-* `else if` MUST be written as `elseif`. _(It is in PSR-2, but using a SHOULD)_
-* Control structure keywords or opening braces MUST NOT have one space after them.
-* Code MUST use tabs for indenting.
-* Long arrays MAY be split across multiple lines, where each subsequent line is indented once.
-* Files MUST use only the `` tag.
-* Code MUST NOT use namespaces. _(This restriction maybe will be lifted)_
-* Strings SHOULD use the double quote `"` except when the single quote is required.
-* Arrays SHOULD be declared using `[]`, not the `array()` shortcut.
-* Argument lists MAY NOT be split across multiple lines, except long arrays.
-
-```php
- "value1",
- 1 => "value2",
- 2 => "value3",
- 3 => "value4",
- 4 => "value5",
- 5 => "value6"
- ];
- }
- }
- }
-
-}
-```
diff --git a/LICENSE b/LICENSE
deleted file mode 100644
index 02bbb60b..00000000
--- a/LICENSE
+++ /dev/null
@@ -1,165 +0,0 @@
- GNU LESSER GENERAL PUBLIC LICENSE
- Version 3, 29 June 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc.
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-
- This version of the GNU Lesser General Public License incorporates
-the terms and conditions of version 3 of the GNU General Public
-License, supplemented by the additional permissions listed below.
-
- 0. Additional Definitions.
-
- As used herein, "this License" refers to version 3 of the GNU Lesser
-General Public License, and the "GNU GPL" refers to version 3 of the GNU
-General Public License.
-
- "The Library" refers to a covered work governed by this License,
-other than an Application or a Combined Work as defined below.
-
- An "Application" is any work that makes use of an interface provided
-by the Library, but which is not otherwise based on the Library.
-Defining a subclass of a class defined by the Library is deemed a mode
-of using an interface provided by the Library.
-
- A "Combined Work" is a work produced by combining or linking an
-Application with the Library. The particular version of the Library
-with which the Combined Work was made is also called the "Linked
-Version".
-
- The "Minimal Corresponding Source" for a Combined Work means the
-Corresponding Source for the Combined Work, excluding any source code
-for portions of the Combined Work that, considered in isolation, are
-based on the Application, and not on the Linked Version.
-
- The "Corresponding Application Code" for a Combined Work means the
-object code and/or source code for the Application, including any data
-and utility programs needed for reproducing the Combined Work from the
-Application, but excluding the System Libraries of the Combined Work.
-
- 1. Exception to Section 3 of the GNU GPL.
-
- You may convey a covered work under sections 3 and 4 of this License
-without being bound by section 3 of the GNU GPL.
-
- 2. Conveying Modified Versions.
-
- If you modify a copy of the Library, and, in your modifications, a
-facility refers to a function or data to be supplied by an Application
-that uses the facility (other than as an argument passed when the
-facility is invoked), then you may convey a copy of the modified
-version:
-
- a) under this License, provided that you make a good faith effort to
- ensure that, in the event an Application does not supply the
- function or data, the facility still operates, and performs
- whatever part of its purpose remains meaningful, or
-
- b) under the GNU GPL, with none of the additional permissions of
- this License applicable to that copy.
-
- 3. Object Code Incorporating Material from Library Header Files.
-
- The object code form of an Application may incorporate material from
-a header file that is part of the Library. You may convey such object
-code under terms of your choice, provided that, if the incorporated
-material is not limited to numerical parameters, data structure
-layouts and accessors, or small macros, inline functions and templates
-(ten or fewer lines in length), you do both of the following:
-
- a) Give prominent notice with each copy of the object code that the
- Library is used in it and that the Library and its use are
- covered by this License.
-
- b) Accompany the object code with a copy of the GNU GPL and this license
- document.
-
- 4. Combined Works.
-
- You may convey a Combined Work under terms of your choice that,
-taken together, effectively do not restrict modification of the
-portions of the Library contained in the Combined Work and reverse
-engineering for debugging such modifications, if you also do each of
-the following:
-
- a) Give prominent notice with each copy of the Combined Work that
- the Library is used in it and that the Library and its use are
- covered by this License.
-
- b) Accompany the Combined Work with a copy of the GNU GPL and this license
- document.
-
- c) For a Combined Work that displays copyright notices during
- execution, include the copyright notice for the Library among
- these notices, as well as a reference directing the user to the
- copies of the GNU GPL and this license document.
-
- d) Do one of the following:
-
- 0) Convey the Minimal Corresponding Source under the terms of this
- License, and the Corresponding Application Code in a form
- suitable for, and under terms that permit, the user to
- recombine or relink the Application with a modified version of
- the Linked Version to produce a modified Combined Work, in the
- manner specified by section 6 of the GNU GPL for conveying
- Corresponding Source.
-
- 1) Use a suitable shared library mechanism for linking with the
- Library. A suitable mechanism is one that (a) uses at run time
- a copy of the Library already present on the user's computer
- system, and (b) will operate properly with a modified version
- of the Library that is interface-compatible with the Linked
- Version.
-
- e) Provide Installation Information, but only if you would otherwise
- be required to provide such information under section 6 of the
- GNU GPL, and only to the extent that such information is
- necessary to install and execute a modified version of the
- Combined Work produced by recombining or relinking the
- Application with a modified version of the Linked Version. (If
- you use option 4d0, the Installation Information must accompany
- the Minimal Corresponding Source and Corresponding Application
- Code. If you use option 4d1, you must provide the Installation
- Information in the manner specified by section 6 of the GNU GPL
- for conveying Corresponding Source.)
-
- 5. Combined Libraries.
-
- You may place library facilities that are a work based on the
-Library side by side in a single library together with other library
-facilities that are not Applications and are not covered by this
-License, and convey such a combined library under terms of your
-choice, if you do both of the following:
-
- a) Accompany the combined library with a copy of the same work based
- on the Library, uncombined with any other library facilities,
- conveyed under the terms of this License.
-
- b) Give prominent notice with the combined library that part of it
- is a work based on the Library, and explaining where to find the
- accompanying uncombined form of the same work.
-
- 6. Revised Versions of the GNU Lesser General Public License.
-
- The Free Software Foundation may publish revised and/or new versions
-of the GNU Lesser General Public License from time to time. Such new
-versions will be similar in spirit to the present version, but may
-differ in detail to address new problems or concerns.
-
- Each version is given a distinguishing version number. If the
-Library as you received it specifies that a certain numbered version
-of the GNU Lesser General Public License "or any later version"
-applies to it, you have the option of following the terms and
-conditions either of that published version or of any later version
-published by the Free Software Foundation. If the Library as you
-received it does not specify a version number of the GNU Lesser
-General Public License, you may choose any version of the GNU Lesser
-General Public License ever published by the Free Software Foundation.
-
- If the Library as you received it specifies that a proxy can decide
-whether future versions of the GNU Lesser General Public License shall
-apply, that proxy's public statement of acceptance of any version is
-permanent authorization for you to choose that version for the
-Library.
\ No newline at end of file
diff --git a/PocketMine-MP.php b/PocketMine-MP.php
deleted file mode 100644
index c2572794..00000000
--- a/PocketMine-MP.php
+++ /dev/null
@@ -1,34 +0,0 @@
-start();
-
-kill(getmypid()); //Fix for ConsoleAPI being blocked
-exit(0);
diff --git a/README.md b/README.md
index 07d2bf03..73d67efc 100644
--- a/README.md
+++ b/README.md
@@ -1,42 +1,2 @@

-
-# NostalgiaCore
-
-NostalgiaCore is a fork of Legacy PocketMine-MP 1.3.12, which fixes bugs of Legacy PocketMine-MP, and adds new content
-
-Supported MCPE versions: 0.9.5 and maybe other 0.9.x versions
-
-(Special thx to GullCraft Network and DartMiner43)
-
-
Why should you use NostalgiaCore to run a Minecraft Pocket Edition 0.9.5 server?
-You should not use it now.
- Download Stable NostalgiaCore
-
-https://github.com/kotyaralih/NostalgiaCore/releases/
- PHP binaries download
-
-* https://github.com/pmmp/PHP-Binaries/releases/tag/php-8.0-latest PHP8 (Use PM4 version)
-* https://github.com/DaisukeDaisuke/AndroidPHP/releases/tag/8.0.28 PHP8 for ARMv8
- How to use auto-restart?
-
-Simply start your server using ./start.sh -l
-
- Our discord server
-
-https://discord.gg/uSHEWe6NC3
-
-# Want to contribute?
-* Check the [Contributing Guidelines](CONTRIBUTING.md)
-
-# Third-party Libraries/Protocols Used
-* __[PHP Sockets](http://php.net/manual/en/book.sockets.php)__
-* __[PHP SQLite3](http://php.net/manual/en/book.sqlite3.php)__
-* __[PHP BCMath](http://php.net/manual/en/book.bc.php)__
-* __[PHP pthreads](https://github.com/krakjoe/pthreads)__ by _[krakjoe](https://github.com/krakjoe)_: Threading for PHP - Share Nothing, Do Everything.
-* __[PHP YAML](https://code.google.com/p/php-yaml/)__ by _Bryan Davis_: The Yaml PHP Extension provides a wrapper to the LibYAML library.
-* __[LibYAML](http://pyyaml.org/wiki/LibYAML)__ by _Kirill Simonov_: A YAML 1.1 parser and emitter written in C.
-* __[mintty](https://code.google.com/p/mintty/)__ : xterm Terminal Emulator
-* __[cURL](http://curl.haxx.se/)__: cURL is a command line tool for transferring data with URL syntax
-* __[Zlib](http://www.zlib.net/)__: A Massively Spiffy Yet Delicately Unobtrusive Compression Library
-* __[Source RCON Protocol](https://developer.valvesoftware.com/wiki/Source_RCON_Protocol)__
-* __[UT3 Query Protocol](http://wiki.unrealadmin.org/UT3_query_protocol)__
+## NostalgiaCore 0.9.5 was moved to https://github.com/oldminecraftcommunity/NostalgiaCore-0.9.5
diff --git a/src/API/AchievementAPI.php b/src/API/AchievementAPI.php
deleted file mode 100644
index ee1d87a2..00000000
--- a/src/API/AchievementAPI.php
+++ /dev/null
@@ -1,203 +0,0 @@
- array(
- "name" => "Taking Inventory",
- "requires" => array(),
- ),*/
- "mineWood" => [
- "name" => "Getting Wood",
- "requires" => [
- //"openInventory",
- ],
- ],
- "buildWorkBench" => [
- "name" => "Benchmarking",
- "requires" => [
- "mineWood",
- ],
- ],
- "buildPickaxe" => [
- "name" => "Time to Mine!",
- "requires" => [
- "buildWorkBench",
- ],
- ],
- "buildFurnace" => [
- "name" => "Hot Topic",
- "requires" => [
- "buildPickaxe",
- ],
- ],
- "acquireIron" => [
- "name" => "Acquire hardware",
- "requires" => [
- "buildFurnace",
- ],
- ],
- "buildHoe" => [
- "name" => "Time to Farm!",
- "requires" => [
- "buildWorkBench",
- ],
- ],
- "makeBread" => [
- "name" => "Bake Bread",
- "requires" => [
- "buildHoe",
- ],
- ],
- "bakeCake" => [
- "name" => "The Lie",
- "requires" => [
- "buildHoe",
- ],
- ],
- "buildBetterPickaxe" => [
- "name" => "Getting an Upgrade",
- "requires" => [
- "buildPickaxe",
- ],
- ],
- "buildSword" => [
- "name" => "Time to Strike!",
- "requires" => [
- "buildWorkBench",
- ],
- ],
- "diamond" => [
- "name" => "DIAMONDS!",
- "requires" => [
- "acquireIron",
- ],
- ],
- "leather" => [
- "name" => "Cow Tipper",
- "requires" => [
- "buildSword",
- ],
- ],
-
- ];
-
- private $server;
-
- function __construct(){
- $this->server = ServerAPI::request();
- }
-
- /**
- * Add an achievement
- * @param string $achievementId
- * @param string $achievementName
- * @param array $requires
- * @return boolean
- */
- public static function addAchievement($achievementId, $achievementName, array $requires = []){
- if(!isset(self::$achievements[$achievementId])){
- self::$achievements[$achievementId] = [
- "name" => $achievementName,
- "requires" => $requires,
- ];
- return true;
- }
- return false;
- }
-
- public static function grantAchievement(Player $player, $achievementId){
- if(isset(self::$achievements[$achievementId]) and !self::hasAchievement($player, $achievementId)){
- foreach(self::$achievements[$achievementId]["requires"] as $requerimentId){
- if(!self::hasAchievement($player, $requerimentId)){
- return false;
- }
- }
- if(ServerAPI::request()->api->dhandle("achievement.grant", ["player" => $player, "achievementId" => $achievementId]) !== false){
- $player->achievements[$achievementId] = true;
- self::broadcastAchievement($player, $achievementId);
- return true;
- }else{
- return false;
- }
- }
- return false;
- }
-
- public static function hasAchievement(Player $player, $achievementId){
- if(!isset(self::$achievements[$achievementId]) or !isset($player->achievements)){
- $player->achievements = [];
- return false;
- }
-
- if(!isset($player->achievements[$achievementId]) or $player->achievements[$achievementId] == false){
- return false;
- }
- return true;
- }
-
- public static function broadcastAchievement(Player $player, $achievementId){
- if(isset(self::$achievements[$achievementId])){
- $result = ServerAPI::request()->api->dhandle("achievement.broadcast", ["player" => $player, "achievementId" => $achievementId]);
- if($result !== false and $result !== true){
- if(ServerAPI::request()->api->getProperty("announce-player-achievements") == true){
- ServerAPI::request()->api->chat->broadcast($player->username . " has just earned the achievement [" . self::$achievements[$achievementId]["name"] . "]");
- }else{
- $player->sendChat("You have just earned the achievement [" . self::$achievements[$achievementId]["name"] . "]");
- }
- }
- return true;
- }
- return false;
- }
-
- public static function removeAchievement(Player $player, $achievementId){
- if(self::hasAchievement($player, $achievementId)){
- $player->achievements[$achievementId] = false;
- }
- }
-
- public function viewAchievements($cmd, $params, $issuer, $alias)
- {
- if(!($issuer instanceof Player) && !isset($params[0])){
- return "Please enter a nickname.";
- } else{
- if(! ($issuer instanceof Player) || (isset($params[0]) && $this->server->api->ban->isOp($issuer->username))){
- $player = $this->server->api->player->get($params[0]);
- if($player instanceof Player){
- $data = $player->data;
- } else{
- $data = $this->server->api->player->getOffline(trim($params[0]), false);
- }
- } else{
- $data = $issuer->achievements;
- }
- }
- if($data === false){
- return "Player {$params[0]} is not found.";
- }
- if($data instanceof Config){
- $achs = $data->get("achievements");
- }else{
- $achs = $data;
- }
-
- if(count($achs) <= 0){
- return "Player {$params[0]} unlocked 0 achievements";
- }
- $output = "Unlocked Achievements(".count($achs)."/".count(self::$achievements)."): ";
- foreach($achs as $achievement => $unlocked){
- if($unlocked && isset(self::$achievements[$achievement])){
- $info = self::$achievements[$achievement];
- $output .= "{$info["name"]}, ";
- }
- }
- return substr($output, 0, - 2);
- }
-
- public function init(){
- $this->server->api->console->register("ach", "", [$this, "viewAchievements"]);
- $this->server->api->console->alias("getplayerachievements", "ach");
- $this->server->api->console->cmdWhitelist("ach");
- }
-}
diff --git a/src/API/BanAPI.php b/src/API/BanAPI.php
deleted file mode 100644
index d67da604..00000000
--- a/src/API/BanAPI.php
+++ /dev/null
@@ -1,408 +0,0 @@
-server = ServerAPI::request();
- }
-
- public function init(){
- $this->whitelist = new Config(DATA_PATH . "white-list.txt", CONFIG_LIST);//Open whitelist list file
- $this->bannedIPs = new Config(DATA_PATH . "banned-ips.txt", CONFIG_LIST);//Open Banned IPs list file
- $this->banned = new Config(DATA_PATH . "banned.txt", CONFIG_LIST);//Open Banned Usernames list file
- $this->ops = new Config(DATA_PATH . "ops.txt", CONFIG_LIST);//Open list of OPs
- $this->server->api->console->register("banip", " [IP|player]", [$this, "commandHandler"]);
- $this->server->api->console->register("ban", " [username]", [$this, "commandHandler"]);
- $this->server->api->console->register("kick", " [reason ...]", [$this, "commandHandler"]);
- $this->server->api->console->register("whitelist", " [username]", [$this, "commandHandler"]);
- $this->server->api->console->register("op", "", [$this, "commandHandler"]);
- $this->server->api->console->register("deop", "", [$this, "commandHandler"]);
- $this->server->api->console->register("sudo", "", [$this, "commandHandler"]);
- $this->server->api->console->alias("ban-ip", "banip add");
- $this->server->api->console->alias("banlist", "ban list");
- $this->server->api->console->alias("pardon", "ban remove");
- $this->server->api->console->alias("pardon-ip", "banip remove");
- $this->server->addHandler("console.command", [$this, "permissionsCheck"], 1);//Event handler when commands are issued. Used to check permissions of commands that go through the server.
- $this->server->addHandler("player.block.break", [$this, "permissionsCheck"], 1);//Event handler for blocks
- $this->server->addHandler("player.block.place", [$this, "permissionsCheck"], 1);//Event handler for blocks
- $this->server->addHandler("player.flying", [$this, "permissionsCheck"], 1);//Flying Event
- }
-
- /**
- * Whitelists a CMD so everyone can issue it - Even non OPs.
- * @deprecated use ConsoleAPI::cmdWhitelist
- * @see ConsoleAPI::cmdWhitelist
- * @param string $cmd Command to Whitelist
- */
- public function cmdWhitelist($cmd){
- $this->server->api->console->cmdWhitelist($cmd);
- }
-
- /**
- * @param mixed $data
- * @param string $event
- *
- * @return boolean
- */
- public function permissionsCheck($data, $event){
- switch($event){
- case "player.flying"://OPs can fly around the server.
- if($this->isOp($data->iusername)){
- return true;
- }
- break;
- case "player.block.break":
- /**
- * @var Player $player
- */
- $player = $data["player"];
- if(!$this->isOp($player->iusername) && $player->level->getName() === $this->server->api->level->getDefault()){
- $t = new Vector2($data["target"]->x, $data["target"]->z);
- $s = new Vector2($this->server->spawn->x, $this->server->spawn->z);
- if($t->distance($s) <= $this->server->api->getProperty("spawn-protection") and $this->server->api->dhandle($event . ".spawn", $data) !== true){
- return false;
- }
- }
- return;
- case "player.block.place"://Spawn protection detection. Allows OPs to place/break blocks in the spawn area.
- $player = $data["player"];
- if(!$this->isOp($player->iusername) && $player->level->getName() === $this->server->api->level->getDefault()){
- $t = new Vector2($data["block"]->x, $data["block"]->z);
- $s = new Vector2($this->server->spawn->x, $this->server->spawn->z);
- if($t->distance($s) <= $this->server->api->getProperty("spawn-protection") and $this->server->api->dhandle($event . ".spawn", $data) !== true){
- return false;
- }
- }
- return;
- case "console.command"://Checks if a command is allowed with the current user permissions.
- if(isset($this->cmdWhitelist[$data["cmd"]])){
- return;
- }
-
- if($data["issuer"] instanceof Player){
- if($this->server->api->handle("console.check", $data) === true or $this->isOp($data["issuer"]->iusername)){
- return;
- }
- }elseif($data["issuer"] === "console" or $data["issuer"] === "rcon"){
- return;
- }
- return false;
- }
- }
-
- /**
- * @param string $username
- *
- * @return boolean
- */
- public function isOp($username){//Is a player op?
- $username = strtolower($username);
- if($this->server->api->dhandle("op.check", $username) === true){
- return true;
- }elseif($this->ops->exists($username)){
- return true;
- }
- return false;
- }
-
- /**
- * @param string $username
- */
- public function ban($username){
- $this->commandHandler("ban", ["add", $username], "console", "");
- }
-
- /**
- * @param string $cmd
- * @param array $params
- * @param string $issuer
- * @param string $alias
- *
- * @return string
- */
- public function commandHandler($cmd, $params, $issuer, $alias){
- $output = "";
- switch($cmd){
- case "sudo":
- $target = strtolower(array_shift($params));
- $player = $this->server->api->player->get($target);
- if(!isset($params[0])){
- $output .= "Usage: /sudo \n";
- break;
- }
- if(!($player instanceof Player)){
- $output .= "Player not connected.\n";
- break;
- }
- $this->server->api->console->run(implode(" ", $params), $player);
- $output .= "Command ran as " . $player->username . ".\n";
- break;
- case "op":
- if(!isset($params[0])){
- $output .= "Usage: /op \n";
- break;
- }
- $user = strtolower($params[0]);
- $player = $this->server->api->player->get($user);
- if(!($player instanceof Player)){
- $this->ops->set($user);
- $this->ops->save($user);
- $output .= $user . " is now op\n";
- break;
- }
- $this->ops->set($player->iusername);
- $this->ops->save();
- $output .= $player->iusername . " is now op\n";
- $this->server->api->chat->sendTo(false, "You are now op.", $player->iusername);
- break;
- case "deop":
- if(!isset($params[0])){
- $output .= "Usage: /deop \n";
- break;
- }
- $user = strtolower($params[0]);
- $player = $this->server->api->player->get($user);
- if(!($player instanceof Player)){
- $this->ops->remove($user);
- $this->ops->save();
- $output .= $user . " is no longer op\n";
- break;
- }
- $this->ops->remove($player->iusername);
- $this->ops->save();
- $output .= $player->iusername . " is no longer op\n";
- $this->server->api->chat->sendTo(false, "You are no longer op.", $player->iusername);
- break;
- case "kick":
- if(!isset($params[0])){
- $output .= "Usage: /kick [reason ...]\n";
- }else{
- $name = strtolower(array_shift($params));
- $player = $this->server->api->player->get($name);
- if($player === false){
- $output .= "Player \"" . $name . "\" does not exist\n";
- }else{
- $reason = implode(" ", $params);
- $reason = $reason == "" ? "No reason" : $reason;
-
- $this->server->schedule(60, [$player, "close"], "You have been kicked: " . $reason); //Forces a kick
- $player->blocked = true;
- if($issuer instanceof Player){
- $this->server->api->chat->broadcast($player->username . " has been kicked by " . $issuer->username . ": $reason");
- }else{
- $this->server->api->chat->broadcast($player->username . " has been kicked: $reason");
- }
- }
- }
- break;
- case "whitelist":
- $p = strtolower(array_shift($params));
- switch($p){
- case "remove":
- $user = strtolower($params[0]);
- $this->whitelist->remove($user);
- $this->whitelist->save();
- $output .= "Player \"$user\" removed from white-list\n";
- break;
- case "add":
- $user = strtolower($params[0]);
- $this->whitelist->set($user);
- $this->whitelist->save();
- $output .= "Player \"$user\" added to white-list\n";
- break;
- case "reload":
- $this->whitelist = new Config(DATA_PATH . "white-list.txt", CONFIG_LIST);
- break;
- case "list":
- $output .= "White-list: " . implode(", ", $this->whitelist->getAll(true)) . "\n";
- break;
- case "on":
- case "true":
- case "1":
- $output .= "White-list turned on\n";
- $this->server->api->setProperty("white-list", true);
- break;
- case "off":
- case "false":
- case "0":
- $output .= "White-list turned off\n";
- $this->server->api->setProperty("white-list", false);
- break;
- default:
- $output .= "Usage: /whitelist [username]\n";
- break;
- }
- break;
- case "banip":
- $p = strtolower(array_shift($params));
- switch($p){
- case "pardon":
- case "remove":
- $ip = strtolower($params[0]);
- $this->bannedIPs->remove($ip);
- $this->bannedIPs->save();
- $output .= "IP \"$ip\" removed from ban list\n";
- break;
- case "add":
- case "ban":
- $ip = strtolower($params[0]);
- $player = $this->server->api->player->get($ip);
- if($player instanceof Player){
- $ip = $player->ip;
- $player->close("banned");
- }
- $this->bannedIPs->set($ip);
- $this->bannedIPs->save();
- $output .= "IP \"$ip\" added to ban list\n";
- break;
- case "reload":
- $this->bannedIPs = new Config(DATA_PATH . "banned-ips.txt", CONFIG_LIST);
- break;
- case "list":
- $output .= "IP ban list: " . implode(", ", $this->bannedIPs->getAll(true)) . "\n";
- break;
- default:
- $output .= "Usage: /banip [IP|player]\n";
- break;
- }
- break;
- case "ban":
- $p = strtolower(array_shift($params));
- switch($p){
- case "pardon":
- case "remove":
- $user = strtolower($params[0]);
- $this->banned->remove($user);
- $this->banned->save();
- $output .= "Player \"$user\" removed from ban list\n";
- break;
- case "add":
- case "ban":
- $user = strtolower($params[0]);
- $this->banned->set($user);
- $this->banned->save();
- $player = $this->server->api->player->get($user);
- if($player !== false){
- $player->close("You have been banned");
- }
- if($issuer instanceof Player){
- $this->server->api->chat->broadcast($user . " has been banned by " . $issuer->username . "\n");
- }else{
- $this->server->api->chat->broadcast($user . " has been banned\n");
- }
- $this->kick($user, "Banned");
- $output .= "Player \"$user\" added to ban list\n";
- break;
- case "reload":
- $this->banned = new Config(DATA_PATH . "banned.txt", CONFIG_LIST);
- break;
- case "list":
- $output .= "Ban list: " . implode(", ", $this->banned->getAll(true)) . "\n";
- break;
- default:
- $output .= "Usage: /ban [username]\n";
- break;
- }
- break;
- }
- return $output;
- }
-
- /**
- * @param string $username
- * @param string $reason
- */
- public function kick($username, $reason = "No Reason"){
- $this->commandHandler("kick", [$username, $reason], "console", "");
- }
-
- /**
- * @param string $username
- */
- public function pardon($username){
- $this->commandHandler("ban", ["pardon", $username], "console", "");
- }
-
- /**
- * @param string $ip
- */
- public function banIP($ip){
- $this->commandHandler("banip", ["add", $ip], "console", "");
- }
-
- /**
- * @param string $ip
- */
- public function pardonIP($ip){
- $this->commandHandler("banip", ["pardon", $ip], "console", "");
- }
-
- public function reload(){
- $this->commandHandler("ban", ["reload"], "console", "");
- $this->commandHandler("banip", ["reload"], "console", "");
- $this->commandHandler("whitelist", ["reload"], "console", "");
- }
-
- /**
- * @param string $ip
- *
- * @return boolean
- */
- public function isIPBanned($ip){
- if($this->server->api->dhandle("api.ban.ip.check", $ip) === false){
- return true;
- }elseif($this->bannedIPs->exists($ip, true)){
- return true;
- }else{
- return false;
- }
- }
-
- /**
- * @param string $username
- *
- * @return boolean
- */
- public function isBanned($username){
- $username = strtolower($username);
- if($this->server->api->dhandle("api.ban.check", $username) === false){
- return true;
- }elseif($this->banned->exists($username, true)){
- return true;
- }else{
- return false;
- }
- }
-
- /**
- * @param string $username
- *
- * @return boolean
- */
- public function inWhitelist($username){
- $username = strtolower($username);
- if($this->isOp($username)){
- return true;
- }elseif($this->server->api->dhandle("api.ban.whitelist.check", $username) === false){
- return true;
- }elseif($this->whitelist->exists($username, true)){
- return true;
- }
- return false;
- }
-}
diff --git a/src/API/BlockAPI.php b/src/API/BlockAPI.php
deleted file mode 100755
index f71346c1..00000000
--- a/src/API/BlockAPI.php
+++ /dev/null
@@ -1,702 +0,0 @@
-server = ServerAPI::request();
- }
- /**
- * @param integer $id
- * @param number $meta
- * @param boolean $v
- * @return GenericBlock
- */
- public static function get($id, $meta = 0, $v = false){
- if(isset(Block::$class[$id])){
- $classname = Block::$class[$id];
- $b = new $classname($meta);
- }else{
- $b = new GenericBlock((int) $id, $meta);
- }
- if($v instanceof Position){
- $b->position($v);
- }
- return $b;
- }
-
- public function init(){
- $this->server->schedule(1, [$this, "blockUpdateTick"], [], true);
- $this->server->api->console->register("setblock", " ", [$this, "commandHandler"]);
- $this->server->api->console->register("give", " - [amount]", [$this, "commandHandler"]);
- $this->server->api->console->register("id", "Check id of item", [$this, "commandHandler"]);
- $this->server->api->console->cmdWhitelist("id");
- }
-
- public function commandHandler($cmd, $args, $issuer, $alias){
- $output = "";
- switch($cmd){
- case "id":
- if(!($issuer instanceof Player)){
- $output .= "Run this command in-game!";
- break;
- }
- $itemheld = $issuer->getSlot($issuer->slot);
- $output = self::getItem($itemheld->getID(), $itemheld->getMetadata())."";
- break;
- case "setblock":
- if(!($issuer instanceof Player)){
- if(count($args) < 5){
- $output .= "Usage: /setblock ";
- break;
- }else{
- if(!is_numeric($args[0]) or !is_numeric($args[1]) or !is_numeric($args[2])){
- $output .= "You need to use a numeric coords!";
- break;
- }
- $level = $this->server->api->level->get($args[3]);
- if($level === false){
- $output .= "Unknown level";
- break;
- }
- $block = self::fromString($args[4])->getBlock();
- }
- }else{
- if(count($args) < 4){
- $output .= "Usage: /setblock ";
- break;
- }
-
- $level = $issuer->entity->level;
- $block = self::fromString($args[3])->getBlock();
- }
-
- $coords = [];
- for($i = 0; $i < 3; $i++){
- if($args[$i] === '~'){
- if($i === 0) $coord = $issuer->entity->x;
- elseif($i === 1) $coord = $issuer->entity->y;
- else $coord = $issuer->entity->z;
- $coords[$i] = round($coord, 0);
- }
- elseif(is_numeric($args[$i])){
- if($args[$i] > 0 and $args[$i] < 255){
- $coords[$i] = $args[$i];
- }
- }
- }
- if(!isset($coords[2])){
- $output .= "Usage: /setblock ";
- break;
- }
-
- $pos = new Position($coords[0], $coords[1], $coords[2], $level);
- if(!($block instanceof Block)){
- $output .= "Usage: /setblock ";
- break;
- }else{
- $level->setBlock($pos, $block, true, false, true);
- $output .= "Placed $block in ".implode(", ", $coords).", w:".$level->getName();
- }
- break;
- case "give":
- $player = $this->server->api->player->get($args[0] ?? "");
-
- if($player instanceof Player){
- $item = self::fromString($args[1] ?? "");
- if(($player->gamemode & 0x01) === 0x01){
- $output .= "Player is in creative mode.";
- break;
- }
- if($item->getID() === 0){
- $output .= "You cannot give an air block to a player.";
- break;
- }
-
- if(!isset($args[2])){
- $item->count = $item->getMaxStackSize();
- }else{
- $item->count = (int) $args[2];
- }
-
- $player->addItem($item->getID(), $item->getMetadata(), $item->count);
- $output .= "Giving ".$item->count." of ".$item->getName()." (".$item->getID().":".$item->getMetadata().") to ".$player->username;
- break;
- }else{
- $item = self::fromString($args[0] ?? "");
- if(!($issuer instanceof Player)){
- return "You cant give an item to a non-player.";
- }
- if(($issuer->gamemode & 0x01) === 0x01){
- $output .= "You are in creative mode.";
- break;
- }
- if($item->getID() === 0){
- $output .= "You cannot give an air block to a player.";
- break;
- }
-
- if(!isset($args[1])){
- $item->count = $item->getMaxStackSize();
- }else{
- $item->count = (int) $args[1];
- }
-
- $issuer->addItem($item->getID(), $item->getMetadata(), $item->count);
- $output .= "Giving ".$item->count." of ".$item->getName()." (".$item->getID().":".$item->getMetadata().") to ".$issuer->username;
- break;
- }
- break;
- }
- return $output;
- }
-
- public static function fromString($str, $multiple = false){
- if($multiple === true){
- $blocks = [];
- foreach(explode(",", $str) as $b){
- $blocks[] = BlockAPI::fromString($b, false);
- }
- return $blocks;
- }else{
- $b = explode(":", str_replace(" ", "_", trim($str)));
- if(!isset($b[1])){
- $meta = 0;
- }else{
- $meta = ((int) $b[1]) & 0xFFFF;
- }
-
- if(defined(strtoupper($b[0]))){
- $explodedString = explode(":", constant(strtoupper($b[0])));
- if(count($explodedString) === 2){
- $meta = (int) $explodedString[1];
- }
- $item = BlockAPI::getItem(constant(strtoupper($b[0])), $meta);
- if($item->getID() === AIR and strtoupper($b[0]) !== "AIR"){
- $item = BlockAPI::getItem(((int) $b[0]) & 0xFFFF, $meta);
- }
- }else{
- $item = BlockAPI::getItem(((int) $b[0]) & 0xFFFF, $meta);
- }
- return $item;
- }
- }
-
- public static function getItem($id, $meta = 0, $count = 1){
- $id = (int) $id;
- if(isset(Item::$class[$id])){
- $classname = Item::$class[$id];
- $i = new $classname($meta, $count);
- }else{
- $i = new Item($id, $meta, $count);
- }
- return $i;
- }
-
- public function playerBlockBreak(Player $player, Vector3 $vector){
- $target = $player->level->getBlock($vector);
- $item = $player->getSlot($player->slot);
-
- if($this->server->api->dhandle("player.block.touch", ["type" => "break", "player" => $player, "target" => $target, "item" => $item]) === false){
- if($this->server->api->dhandle("player.block.break.bypass", ["player" => $player, "target" => $target, "item" => $item]) !== true){
- return $this->cancelAction($target, $player, false);
- }
- }
-
- if((!$target->isBreakable($item, $player) and $this->server->api->dhandle("player.block.break.invalid", ["player" => $player, "target" => $target, "item" => $item]) !== true) or ($player->gamemode & 0x02) === 0x02 or (($player->lastBreak - $player->getLag() / 1000) + $target->getBreakTime($item, $player) - 0.2) >= microtime(true)){
- if($this->server->api->dhandle("player.block.break.bypass", ["player" => $player, "target" => $target, "item" => $item]) !== true){
- return $this->cancelAction($target, $player, false);
- }
- }
- $player->lastBreak = microtime(true);
-
- if($this->server->api->dhandle("player.block.break", ["player" => $player, "target" => $target, "item" => $item]) !== false){
- $drops = $target->getDrops($item, $player);
- if($target->onBreak($item, $player) === false){
- return $this->cancelAction($target, $player, false);
- }
- if(($player->gamemode & 0x01) === 0 and $item->useOn($target) and $item->getMetadata() >= $item->getMaxDurability()){
- $player->setSlot($player->slot, new Item(AIR, 0, 0), false);
- }
- }else{
- return $this->cancelAction($target, $player, false);
- }
-
-
- if(is_array($drops) && ($player->gamemode & 0x01) === 0x00 and count($drops) > 0){
- foreach($drops as $drop){
- $this->server->api->entity->drop(new Position($target->x + 0.5, $target->y, $target->z + 0.5, $target->level), BlockAPI::getItem($drop[0] & 0xFFFF, $drop[1] & 0xFFFF, $drop[2]));
- }
- }
- return false;
- }
-
- private function cancelAction(Block $block, Player $player, $send = true){
- $pk = new UpdateBlockPacket;
- $pk->x = $block->x;
- $pk->y = $block->y;
- $pk->z = $block->z;
- $pk->block = $block->getID();
- $pk->meta = $block->getMetadata();
- $player->dataPacket($pk);
- if($send === true){
- $player->sendInventorySlot($player->slot);
- }
- return false;
- }
-
- public function playerBlockAction(Player $player, Vector3 $vector, $face, $fx, $fy, $fz){
- if($face < 0 or $face > 5){
- return false;
- }
-
- $target = $player->level->getBlock($vector);
- $block = $target->getSide($face);
- $item = $player->getSlot($player->slot);
-
- if($target->getID() === AIR and $this->server->api->dhandle("player.block.place.invalid", ["player" => $player, "block" => $block, "target" => $target, "item" => $item]) !== true){ //If no block exists or not allowed in CREATIVE
- if($this->server->api->dhandle("player.block.place.bypass", ["player" => $player, "block" => $block, "target" => $target, "item" => $item]) !== true){
- $this->cancelAction($target, $player);
- return $this->cancelAction($block, $player);
- }
- }
-
- if($this->server->api->dhandle("player.block.touch", ["type" => "place", "player" => $player, "block" => $block, "target" => $target, "item" => $item]) === false){
- if($this->server->api->dhandle("player.block.place.bypass", ["player" => $player, "block" => $block, "target" => $target, "item" => $item]) !== true){
- return $this->cancelAction($block, $player);
- }
- }
- $this->blockUpdate($target, BLOCK_UPDATE_TOUCH);
-
- if($target->isActivable === true){
- if($this->server->api->dhandle("player.block.activate", ["player" => $player, "block" => $block, "target" => $target, "item" => $item]) !== false and $target->onActivate($item, $player) === true){
- return false;
- }
- }
-
- if(($player->gamemode & 0x02) === 0x02){ //Adventure mode!!
- if($this->server->api->dhandle("player.block.place.bypass", ["player" => $player, "block" => $block, "target" => $target, "item" => $item]) !== true){
- return $this->cancelAction($block, $player, false);
- }
- }
-
- if($block->y > 127 or $block->y < 0){
- return false;
- }
- if($item->isActivable === true and $item->onActivate($player->level, $player, $block, $target, $face, $fx, $fy, $fz) === true){
- if($item->count <= 0){
- $player->setSlot($player->slot, BlockAPI::getItem(AIR, 0, 0), false);
- }
- return false;
- }
-
- if($item->isPlaceable()){
- $hand = $item->getBlock();
- $hand->position($block);
- }elseif($block->getID() === FIRE){
- $player->level->setBlock($block, new AirBlock(), true, false, true);
- return false;
- }else{
- return $this->cancelAction($block, $player, false);
- }
-
- if(!($block->isReplaceable === true or ($hand->getID() === SLAB and $block->getID() === SLAB))){
- return $this->cancelAction($block, $player, false);
- }
-
- if($target->isReplaceable === true){
- $block = $target;
- $hand->position($block);
- //$face = -1;
- }
-
- if($hand->isSolid === true and $player->entity->inBlock($block)){
- return $this->cancelAction($block, $player, false); //Entity in block
- }
-
- if($this->server->api->dhandle("player.block.place", ["player" => $player, "block" => $block, "target" => $target, "item" => $item]) === false){
- return $this->cancelAction($block, $player);
- }elseif($hand->place($item, $player, $block, $target, $face, $fx, $fy, $fz) === false){
- return $this->cancelAction($block, $player, false);
- }
- if($hand->getID() === SIGN_POST or $hand->getID() === WALL_SIGN){
- $t = $this->server->api->tile->addSign($player->level, $block->x, $block->y, $block->z);
- $t->data["creator"] = $player->username;
- }
-
- if(($player->gamemode & 0x01) === 0x00){
- --$item->count;
- if($item->count <= 0){
- $player->setSlot($player->slot, BlockAPI::getItem(AIR, 0, 0), false);
- }
- }
-
- return false;
- }
-
- public function blockUpdate(Position $pos, $type = BLOCK_UPDATE_NORMAL){
- if(!($pos instanceof Block)){
- $block = $pos->level->getBlock($pos);
- }else{
- $pos = new Position($pos->x, $pos->y, $pos->z, $pos->level);
- $block = $pos->level->getBlock($pos);
- }
- if($block === false){
- return false;
- }
-
- $level = $block->onUpdate($type);
- if($level === BLOCK_UPDATE_NORMAL){
- $this->blockUpdateAround($block, $level);
- $this->server->api->entity->updateRadius($pos, 1);
- }elseif($level === BLOCK_UPDATE_RANDOM){
- //$this->nextRandomUpdate($pos); old version, change back if any issues will start to happen with this one(please note that old version makes a lot of lag)
- $this->scheduleBlockUpdate($pos, (mt_rand(25, 75) + Utils::getRandomUpdateTicks() * 0.05) / 0.05, BLOCK_UPDATE_RANDOM);
- }
- return $level;
- }
- public function blockUpdateAround(Position $pos, $type = BLOCK_UPDATE_NORMAL, $delay = false){
- if($delay !== false){
- $this->scheduleBlockUpdate($pos->getSide(0), $delay, $type);
- $this->scheduleBlockUpdate($pos->getSide(1), $delay, $type);
- $this->scheduleBlockUpdate($pos->getSide(2), $delay, $type);
- $this->scheduleBlockUpdate($pos->getSide(3), $delay, $type);
- $this->scheduleBlockUpdate($pos->getSide(4), $delay, $type);
- $this->scheduleBlockUpdate($pos->getSide(5), $delay, $type);
- }else{
- $this->blockUpdate($pos->getSide(0), $type);
- $this->blockUpdate($pos->getSide(1), $type);
- $this->blockUpdate($pos->getSide(2), $type);
- $this->blockUpdate($pos->getSide(3), $type);
- $this->blockUpdate($pos->getSide(4), $type);
- $this->blockUpdate($pos->getSide(5), $type);
- }
- }
-
- public function scheduleBlockUpdate(Position $pos, $delay, $type = BLOCK_UPDATE_SCHEDULED){
- $type = (int) $type;
- if($delay < 0){
- return false;
- }
-
- $index = $pos->x . "." . $pos->y . "." . $pos->z . "." . $pos->level->getName() . "." . $type;
- $delay = microtime(true) + $delay * 0.05;
- if(!isset($this->scheduledUpdates[$index])){
- $this->scheduledUpdates[$index] = $pos;
- $this->server->query("INSERT INTO blockUpdates (x, y, z, level, type, delay) VALUES (" . $pos->x . ", " . $pos->y . ", " . $pos->z . ", '" . $pos->level->getName() . "', " . $type . ", " . $delay . ");");
- return true;
- }
- return false;
- }
-
- public function nextRandomUpdate(Position $pos){
- if(!isset($this->scheduledUpdates[$pos->x . "." . $pos->y . "." . $pos->z . "." . $pos->level->getName() . "." . BLOCK_UPDATE_RANDOM])){
- $time = microtime(true);
- $offset = 0;
- while(true){
- $t = $offset + Utils::getRandomUpdateTicks() * 0.05;
- $update = $this->server->query("SELECT COUNT(*) FROM blockUpdates WHERE level = '" . $pos->level->getName() . "' AND type = " . BLOCK_UPDATE_RANDOM . " AND delay >= " . ($time + $t - 1) . " AND delay <= " . ($time + $t + 1) . ";");
- if($update instanceof SQLite3Result){
- $update = $update->fetchArray(SQLITE3_NUM);
- if($update[0] < 3){
- break;
- }
- }else{
- break;
- }
- $offset += mt_rand(25, 75);
- }
- $this->scheduleBlockUpdate($pos, $t / 0.05, BLOCK_UPDATE_RANDOM);
- }
- }
-
- public function blockUpdateTick(){
- $time = microtime(true);
- if(count($this->scheduledUpdates) > 0){
- $update = $this->server->query("SELECT x,y,z,level,type FROM blockUpdates WHERE delay <= " . $time . ";");
- if($update instanceof SQLite3Result){
- $upp = [];
- while(($up = $update->fetchArray(SQLITE3_ASSOC)) !== false){
- $index = $up["x"] . "." . $up["y"] . "." . $up["z"] . "." . $up["level"] . "." . $up["type"];
- if(isset($this->scheduledUpdates[$index])){
- $upp[] = [(int) $up["type"], $this->scheduledUpdates[$index]];
- unset($this->scheduledUpdates[$index]);
- }
- }
- $this->server->query("DELETE FROM blockUpdates WHERE delay <= " . $time . ";");
- foreach($upp as $b){
- $this->blockUpdate($b[1], $b[0]);
- }
- }
- }
- }
-}
diff --git a/src/API/ChatAPI.php b/src/API/ChatAPI.php
deleted file mode 100644
index 9f2bfac3..00000000
--- a/src/API/ChatAPI.php
+++ /dev/null
@@ -1,142 +0,0 @@
-server = ServerAPI::request();
- }
-
- public function init(){
- $this->server->api->console->register("tell", " ", [$this, "commandHandler"]);
- $this->server->api->console->register("me", "", [$this, "commandHandler"]);
- $this->server->api->console->register("say", "", [$this, "commandHandler"]);
- $this->server->api->console->cmdWhitelist("tell");
- $this->server->api->console->cmdWhitelist("me");
- $this->server->api->console->alias("msg", "tell");
- }
-
- /**
- * @param string $cmd
- * @param array $params
- * @param string $issuer
- * @param string $alias
- *
- * @return string
- */
- public function commandHandler($cmd, $params, $issuer, $alias){
- $output = "";
- switch($cmd){
- case "say":
- $s = implode(" ", $params);
- if(trim($s) == ""){
- $output .= "Usage: /say \n";
- break;
- }
- $sender = ($issuer instanceof Player) ? "Server" : ucfirst($issuer);
- $this->server->api->chat->broadcast("[$sender] " . $s);
- break;
- case "me":
- $s = implode(" ", $params);
- if(trim($s) == ""){
- $output .= "Usage: /me \n";
- break;
- }
- if(!($issuer instanceof Player)){
- if($issuer === "rcon"){
- $sender = "Rcon";
- }else{
- $sender = ucfirst($issuer);
- }
- }else{
- $sender = $issuer->username;
- }
- $this->broadcast("* $sender " . implode(" ", $params));
- break;
- case "tell":
- if(!isset($params[0]) or !isset($params[1])){
- $output .= "Usage: /$cmd \n";
- break;
- }
- if(!($issuer instanceof Player)){
- $sender = ucfirst($issuer);
- }else{
- $sender = $issuer->username;
- }
- $n = array_shift($params);
- $target = $this->server->api->player->get($n);
- if($target instanceof Player){
- $target = $target->username;
- }else{
- $target = strtolower($n);
- if($target === "server" or $target === "console" or $target === "rcon"){
- $target = "Console";
- }else{
- return "The player is offline.";
- }
- }
- if(strtolower($target) === strtolower($issuer)){
- return "You can't send message to yourself.";
- }
- $mes = implode(" ", $params);
- $output .= "You're whispering to " . $target . ": " . $mes . "\n";
- if($target !== "Console" and $target !== "Rcon"){
- $this->sendTo(false, $sender . " whispers to you: " . $mes, $target);
- }
- if($target === "Console" or $sender === "Console"){
- console("[INFO] " . $sender . " whispers to " . $target . ": " . $mes);
- }
- break;
- }
- return $output;
- }
-
- /**
- * @param string $message
- */
- public function broadcast($message){
- $this->send(false, $message);
- $this->server->send2Discord($message);
- }
-
- /**
- * @param mixed $owner Can be either Player object or string username. Boolean false for broadcast.
- * @param string $text
- * @param $whitelist
- * @param $blacklist
- */
- public function send($owner, $text, $whitelist = false, $blacklist = false){
- $message = [
- "player" => $owner,
- "message" => $text,
- ];
- if($owner !== false){
- if($owner instanceof Player){
- if($whitelist === false){
- console("[INFO] <" . $owner->username . "> " . $text);
- }
- }else{
- if($whitelist === false){
- console("[INFO] <" . $owner . "> " . $text);
- }
- }
- }else{
- if($whitelist === false){
- console("[INFO] $text");
- }
- $message["player"] = "";
- }
- $container = new Container($message, $whitelist, $blacklist);
- $this->server->handle("server.chat", $container);
- }
-
- /**
- * @param string $owner
- * @param string $text
- * @param mixed $player Can be either Player object or string username. Boolean false for broadcast.
- */
- public function sendTo($owner, $text, $player){
- $this->send($owner, $text, [$player]);
- }
-}
diff --git a/src/API/ConsoleAPI.php b/src/API/ConsoleAPI.php
deleted file mode 100644
index ec2cbf36..00000000
--- a/src/API/ConsoleAPI.php
+++ /dev/null
@@ -1,340 +0,0 @@
-help = [];
- $this->cmds = [];
- $this->alias = [];
- $this->server = ServerAPI::request();
- $this->last = microtime(true);
- }
-
- public function init(){
- $this->server->schedule(2, [$this, "handle"], [], true);
- if(!defined("NO_THREADS")){
- $this->loop = new ConsoleLoop();
- }
- $this->register("help", "[page|command name]", [$this, "defaultCommands"]);
- $this->register("status", "", [$this, "defaultCommands"]);
- $this->register("difficulty", "<0|1|2|3>", [$this, "defaultCommands"]);
- $this->register("stop", "", [$this, "defaultCommands"]);
- $this->register("defaultgamemode", "", [$this, "defaultCommands"]);
- $this->cmdWhitelist("help");
- $this->cmdWhitelist("status");
- }
-
- /**
- * Whitelists a CMD so everyone can issue it - Even non OPs.
- * @param string $cmd Command to Whitelist
- */
- public function cmdWhitelist($cmd){
- $this->server->api->ban->cmdWhitelist[strtolower(trim($cmd))] = true;
- }
-
- public function register($cmd, $help, $callback){
- if(!is_callable($callback)){
- return false;
- }
- $cmd = strtolower(trim($cmd));
- $this->cmds[$cmd] = $callback;
- $this->help[$cmd] = $help;
- ksort($this->help, SORT_NATURAL | SORT_FLAG_CASE);
- }
-
- function __destruct(){
- $this->server->deleteEvent($this->event);
- if(!defined("NO_THREADS")){
- $this->loop->stop();
- $this->loop->notify();
- //@fclose($this->loop->fp);
- usleep(50000);
- //$this->loop->join();
- }
- }
-
- public function alias($alias, $cmd){
- $this->alias[strtolower(trim($alias))] = trim($cmd);
- return true;
- }
-
- public function handle($time){
- if(defined("NO_THREADS")){
- return;
- }
- $line = $this->loop->line;
- if($line !== false){
- $line = preg_replace("#\\x1b\\x5b([^\\x1b]*\\x7e|[\\x40-\\x50])#", "", trim($line));
- $this->loop->line = false;
- $output = $this->run($line, "console");
- if($output != ""){
- $mes = explode("\n", trim($output));
- foreach($mes as $m){
- console("[CMD] " . $m);
- }
- }
- }else{
- $this->loop->notify();
- }
- }
-
- public function run($line = "", $issuer = "console", $alias = false){
- if($line != ""){
- $output = "";
- $end = strpos($line, " ");
- if($end === false){
- $end = strlen($line);
- }
- $cmd = strtolower(substr($line, 0, $end));
- $params = (string) substr($line, $end + 1);
- if(isset($this->alias[$cmd])){
- return $this->run($this->alias[$cmd] . ($params !== "" ? " " . $params : ""), $issuer, $cmd);
- }
-
- if(preg_match_all('#@([@a-z]{1,})#', $params, $matches, PREG_OFFSET_CAPTURE) > 0){
- $offsetshift = 0;
- foreach($matches[1] as $selector){
- if($selector[0][0] === "@"){ //Escape!
- $params = substr_replace($params, $selector[0], $selector[1] + $offsetshift - 1, strlen($selector[0]) + 1);
- --$offsetshift;
- continue;
- }
- switch(strtolower($selector[0])){
- case "u":
- case "player":
- case "username":
- $p = ($issuer instanceof Player) ? $issuer->username : $issuer;
- $params = substr_replace($params, $p, $selector[1] + $offsetshift - 1, strlen($selector[0]) + 1);
- $offsetshift -= strlen($selector[0]) - strlen($p) + 1;
- break;
- case "w":
- case "world":
- $p = ($issuer instanceof Player) ? $issuer->level->getName() : $this->server->api->level->getDefault()->getName();
- $params = substr_replace($params, $p, $selector[1] + $offsetshift - 1, strlen($selector[0]) + 1);
- $offsetshift -= strlen($selector[0]) - strlen($p) + 1;
- break;
- case "a":
- case "all":
- if($issuer instanceof Player){
- if($this->server->api->ban->isOp($issuer->username)){
- $output = "";
- foreach($this->server->api->player->getAll() as $p){
- $output .= $this->run($cmd . " " . substr_replace($params, $p->username, $selector[1] + $offsetshift - 1, strlen($selector[0]) + 1), $issuer, $alias);
- }
- }else{
- $issuer->sendChat("You don't have permissions to use this command.\n");
- }
- }else{
- $output = "";
- foreach($this->server->api->player->getAll() as $p){
- $output .= $this->run($cmd . " " . substr_replace($params, $p->username, $selector[1] + $offsetshift - 1, strlen($selector[0]) + 1), $issuer, $alias);
- }
- }
- return $output;
- case "r":
- case "random":
- $l = [];
- foreach($this->server->api->player->getAll() as $p){
- if($p !== $issuer){
- $l[] = $p;
- }
- }
- if(count($l) === 0){
- return;
- }
-
- $p = $l[mt_rand(0, count($l) - 1)]->username;
- $params = substr_replace($params, $p, $selector[1] + $offsetshift - 1, strlen($selector[0]) + 1);
- $offsetshift -= strlen($selector[0]) - strlen($p) + 1;
- break;
- }
- }
- }
- $params = explode(" ", $params);
- if(count($params) === 1 and $params[0] === ""){
- $params = [];
- }
-
- if(($d1 = $this->server->api->dhandle("console.command." . $cmd, ["cmd" => $cmd, "parameters" => $params, "issuer" => $issuer, "alias" => $alias])) === false
- or ($d2 = $this->server->api->dhandle("console.command", ["cmd" => $cmd, "parameters" => $params, "issuer" => $issuer, "alias" => $alias])) === false){
- if(in_array(strtolower($cmd), array_keys($this->cmds))){
- $output = "You don't have permissions to use this command.\n";
- }else{
- $output = "Command doesn't exist! Use /help\n";
- }
- }elseif($d1 !== true and (!isset($d2) or $d2 !== true)){
- if(isset($this->cmds[$cmd]) and is_callable($this->cmds[$cmd])){
- $output = @call_user_func($this->cmds[$cmd], $cmd, $params, $issuer, $alias);
- }elseif($this->server->api->dhandle("console.command.unknown", ["cmd" => $cmd, "params" => $params, "issuer" => $issuer, "alias" => $alias]) !== false){
- $output = $this->defaultCommands($cmd, $params, $issuer, $alias);
- }
- }
-
- if($output != "" and ($issuer instanceof Player)){
- $issuer->sendChat(trim($output));
- }
- return $output;
- }
- }
-
- public function defaultCommands($cmd, $params, $issuer, $alias){
- $output = "";
- switch($cmd){
- case "defaultgamemode":
- $gms = [
- "0" => SURVIVAL,
- "survival" => SURVIVAL,
- "s" => SURVIVAL,
- "1" => CREATIVE,
- "creative" => CREATIVE,
- "c" => CREATIVE,
- "2" => ADVENTURE,
- "adventure" => ADVENTURE,
- "a" => ADVENTURE,
- "3" => VIEW,
- "view" => VIEW,
- "viewer" => VIEW,
- "spectator" => VIEW,
- "v" => VIEW,
- ];
- if(!isset($params[0]) or !isset($gms[strtolower($params[0])])){
- $output .= "Usage: /$cmd \n";
- break;
- }
- $this->server->api->setProperty("gamemode", $gms[strtolower($params[0])]);
- $output .= "Default Gamemode is now " . strtoupper($this->server->getGamemode()) . ".\n";
- break;
- case "status":
- if(!($issuer instanceof Player) and $issuer === "console"){
- $this->server->debugInfo(true);
- }
- $info = $this->server->debugInfo();
- $output .= "TPS: " . $info["tps"] . ", Memory usage: " . $info["memory_usage"] . " (Peak " . $info["memory_peak_usage"] . ")\n";
- break;
- case "stop":
- $this->loop->stop = true;
- $output .= "Stopping the server\n";
- $this->server->close();
- break;
- case "difficulty":
- $s = trim(array_shift($params));
- if($s === "" or (((int) $s) > 3 and ((int) $s) < 0)){
- $output .= "Usage: /difficulty <0|1|2|3>\n";
- break;
- }
- $this->server->api->setProperty("difficulty", (int) $s);
- $output .= "Difficulty changed to " . $this->server->difficulty . "\n";
- break;
- case "?":
- if($issuer !== "console" and $issuer !== "rcon"){
- break;
- }
- case "help":
- if(isset($params[0]) and !is_numeric($params[0])){
- $c = trim(strtolower($params[0]));
- if(isset($this->help[$c]) or isset($this->alias[$c])){
- $c = isset($this->help[$c]) ? $c : $this->alias[$c];
- if($this->server->api->dhandle("console.command." . $c, ["cmd" => $c, "parameters" => [], "issuer" => $issuer, "alias" => false]) === false or $this->server->api->dhandle("console.command", ["cmd" => $c, "parameters" => [], "issuer" => $issuer, "alias" => false]) === false){
- break;
- }
- $output .= "Usage: /$c " . $this->help[$c] . "\n";
- break;
- }
- }
- $cmds = [];
- foreach($this->help as $c => $h){
- if($this->server->api->dhandle("console.command." . $c, ["cmd" => $c, "parameters" => [], "issuer" => $issuer, "alias" => false]) === false or $this->server->api->dhandle("console.command", ["cmd" => $c, "parameters" => [], "issuer" => $issuer, "alias" => false]) === false){
- continue;
- }
- $cmds[$c] = $h;
- }
-
- $max = ceil(count($cmds) / 5);
- $page = (int) (isset($params[0]) ? min($max, max(1, intval($params[0]))) : 1);
- $output .= FORMAT_RED . "-" . FORMAT_RESET . " Showing help page $page of $max (/help ) " . FORMAT_RED . "-" . FORMAT_RESET . "\n";
- $current = 1;
- foreach($cmds as $c => $h){
- $curpage = (int) ceil($current / 5);
- if($curpage === $page){
- $output .= "/$c " . $h . "\n";
- }elseif($curpage > $page){
- break;
- }
- ++$current;
- }
- break;
- default:
- $output .= "Command doesn't exist! Use /help\n";
- break;
- }
- return $output;
- }
-
- public static function debug($msg){
- console("[DEBUG] ".$msg, true, true, 2);
- }
- public static function notice($msg){
- console("[NOTICE] ".$msg);
- }
- public static function info($msg){
- console("[INFO] ".$msg);
- }
- public static function warn($msg){
- console("[WARNING] ".$msg);
- }
- public static function error($msg){
- console("[ERROR] ".$msg);
- }
-}
-
-class ConsoleLoop extends Thread{
-
- public $line;
- public $stop;
- public $base;
- public $ev;
- public $fp;
- public function __construct(){
- $this->line = false;
- $this->stop = false;
- $this->start();
- }
-
- public function stop(){
- $this->stop = true;
- }
-
- public function run(){
- if(!extension_loaded("readline")){
- $this->fp = fopen("php://stdin", "r");
- }
-
- while(!$this->stop){
- $this->line = $this->readLine();
- $this->synchronized(function($t) {
- $this->wait();
- $this->line = false;
- }, $this);
- }
-
- if(!extension_loaded("readline")){
- @fclose($this->fp);
- }
-
- exit(0);
- }
-
- private function readLine(){
- if($this->fp){
- $line = trim(fgets($this->fp));
- }else{
- $line = trim(readline(""));
- if($line != ""){
- readline_add_history($line);
- }
- }
- return $line;
- }
-}
diff --git a/src/API/EntityAPI.php b/src/API/EntityAPI.php
deleted file mode 100644
index 6aa80e5b..00000000
--- a/src/API/EntityAPI.php
+++ /dev/null
@@ -1,303 +0,0 @@
-entities = [];
- $this->server = ServerAPI::request();
-
- $this->serverSpawnAnimals = $this->server->api->getProperty("spawn-animals");
- $this->serverSpawnMobs = $this->server->api->getProperty("spawn-mobs");
- }
-
- public function init(){
- $this->server->api->console->register("summon", "", [$this, "commandHandler"]);
- $this->server->api->console->register("spawnmob", "", [$this, "commandHandler"]);
- $this->server->api->console->register("despawn", "", [$this, "CommandHandler"]);
- $this->server->api->console->register("entcnt", "", [$this, "CommandHandler"]);
- }
-
-
- public function commandHandler($cmd, $args, $issuer, $alias){
- //todo "MOB_".strtoupper($args[0]);
- $mob = [
- "chicken" => 10,
- "cow" => 11,
- "pig" => 12,
- "sheep" => 13,
- "wolf" => 14,
- "villager" => 15,
- "mooshroom" => 16,
-
- "zombie" => 32,
- "creeper" => 33,
- "skeleton" => 34,
- "spider" => 35,
- "pigman" => 36,
- "slime" => 37,
- "enderman" => 38,
- "silverfish" => 39,
- ];
- $output = "";
- switch($cmd){
- case "entcnt":
- return "Total amount of entities: ". count($this->entities);
- case "summon":
- case "spawnmob":
- if(!($issuer instanceof Player)){
- return "Please run this command in-game.";
- }
- if((count($args) < 1) or (count($args) > 3)){
- return "Usage: /$cmd [amount] [baby]";
- }
-
- if(is_int($args[0])) $type = $args[0];
- elseif(isset($mob[strtolower($args[0])])) $type = $mob[strtolower($args[0])];
- else return "Unknown mob.";
- if($type < 10 || $type > 39){
- return "Unknown mob.";
- }
- $mobName = ucfirst(array_flip($mob)[$type]);
-
- if(((isset($args[1]) && strtolower($args[1]) === "baby") || (isset($args[2]) && strtolower($args[2]) === "baby")) && !Utils::in_range($type, 10, 13)){
- return "$mobName cannot be a baby!";
- }
-
- $x = round($issuer->entity->x, 2, PHP_ROUND_HALF_UP);
- $y = round($issuer->entity->y, 2, PHP_ROUND_HALF_UP);
- $z = round($issuer->entity->z, 2, PHP_ROUND_HALF_UP);
- $level = $issuer->entity->level;
- $pos = new Position($x, $y, $z, $level);
-
- if(count($args) === 1){//summon
- $this->summon($pos, ENTITY_MOB, $type);
- return "$mobName spawned in $x, $y, $z.";
- }
- elseif(is_numeric($args[1])){//summon [amount]
- $amount = (int) $args[1];
- if($amount > 100){
- return "Cannot spawn > 100 mobs";
- }
- $isBaby = false;
- if(isset($args[2]) and strtolower($args[2]) === 'baby'){//summon [amount] [baby]
- $isBaby = true;
- }
-
- for($cnt = $amount; $cnt > 0; --$cnt){
- $this->summon($pos, ENTITY_MOB, $type, ["IsBaby" => $isBaby]);
- }
-
- return "$amount ".($isBaby === 1 ? "Baby" : "")." $mobName(s) spawned in $x, $y, $z.";
- }
- elseif(strtolower($args[1]) == "baby"){//summon [baby]
- $this->summon($pos, ENTITY_MOB, $type, ["IsBaby" => 1]);
- return "Baby $mobName spawned in $x, $y, $z.";
- }
- break;
- case "despawn":
- $cnt = 0;
- if(!isset($args[0])){
- return "/despawn ";
- }
-
- $despawnclass = 0;
- $despawntype = 0;
- switch($args[0]){
- case "all":
- foreach($this->entities as $entity){
- if($entity instanceof Entity && !$entity->isPlayer()){
- $entity->close();
- ++$cnt;
- }
- }
- break;
- case "minecarts":
- $despawntype = OBJECT_MINECART;
- break;
- case "mobs":
- $despawnclass = ENTITY_MOB;
- break;
- case "objects":
- $despawnclass = ENTITY_OBJECT;
- break;
- case "items":
- $despawnclass = ENTITY_ITEM;
- break;
- case "fallings":
- $despawnclass = ENTITY_FALLING;
- break;
- }
- if($despawnclass){
- foreach($this->entities as $entity){
- if($entity instanceof Entity && !$entity->isPlayer() && $entity->class === $despawnclass){
- $entity->close();
- ++$cnt;
- }
- }
- }
- if($despawntype){
- foreach($this->entities as $entity){
- if($entity instanceof Entity && !$entity->isPlayer() && $entity->type === $despawntype){
- $entity->close();
- ++$cnt;
- }
- }
- }
- return "$cnt entities have been despawned!";
- }
- return $output;
- }
-
- public function summon(Position $pos, $class, $type, array $data = []){
- $entity = $this->add($pos->level, $class, $type, [
- "x" => $pos->x,
- "y" => $pos->y,
- "z" => $pos->z
- ] + $data);
- $this->spawnToAll($entity, $pos->level);
- }
-
- public function add(Level $level, $class, $type = 0, $data = []){
- $eid = $this->eCnt++;
- $efl = EntityRegistry::$entityList->getEntityFromTypeAndClass($type, $class);
- if($efl instanceof PropertyEntity){
- $class = $efl->getEntityName();
- $this->entities[$eid] = new $class($level, $eid, $efl->getEntityClass(), $efl->getEntityType(), $data);
- }else{
- $this->entities[$eid] = new Entity($level, $eid, $class, $type, $data);
- }
- $level->entityList[$eid] = &$this->entities[$eid];
- $this->server->handle("entity.add", $this->entities[$eid]);
- return $this->entities[$eid];
- }
-
- public function spawnToAll(Entity $e){
- foreach($this->server->api->player->getAll($e->level) as $player){
- if($player->eid !== false and $player->eid !== $e->eid and $e->class !== ENTITY_PLAYER and $e instanceof Entity){
- $e->spawn($player);
- }
- }
- }
-
- public function get($eid){
- return $this->entities[$eid] ?? false;
- }
-
- public function remove($eid){
- if(isset($this->entities[$eid])){
- $this->entities[$eid]->closed = true;
- if($this->entities[$eid]->isPlayer()){
- $pk = new RemovePlayerPacket;
- $pk->eid = $eid;
- $pk->clientID = 0;
- $this->server->api->player->broadcastPacket($this->server->api->player->getAll(), $pk);
- }else{
- $pk = new RemoveEntityPacket;
- $pk->eid = $eid;
- $this->server->api->player->broadcastPacket($this->entities[$eid]->level->players, $pk);
- }
- $this->server->api->dhandle("entity.remove", $this->entities[$eid]);
- unset($this->entities[$eid]->level->entityList[$eid]);
- unset($this->entities[$eid]);
- $this->server->query("DELETE FROM entities WHERE EID = " . $eid . ";");
- }
- }
-
- public function updateRadius(Position $center, $radius = 15, $class = false){
- $this->server->query("UPDATE entities SET hasUpdate = 1 WHERE level = '" . $center->level->getName() . "' " . ($class !== false ? "AND class = $class " : "") . "AND abs(x - {$center->x}) <= $radius AND abs(y - {$center->y}) <= $radius AND abs(z - {$center->z}) <= $radius;");
- }
-
- public function getRadius(Position $center, $radius = 15, $class = false){
- $entities = [];
- $l = $this->server->query("SELECT EID FROM entities WHERE level = '" . $center->level->getName() . "' " . ($class !== false ? "AND class = $class " : "") . "AND abs(x - {$center->x}) <= $radius AND abs(y - {$center->y}) <= $radius AND abs(z - {$center->z}) <= $radius;");
- if($l !== false and $l !== true){
- while(($e = $l->fetchArray(SQLITE3_ASSOC)) !== false){
- $e = $this->get($e["EID"]);
- if($e instanceof Entity){
- $entities[$e->eid] = $e;
- }
- }
- }
- return $entities;
- }
-
- public function heal($eid, $heal, $cause){
- $this->harm($eid, -$heal, $cause);
- }
-
- public function harm($eid, $attack, $cause, $force = false){
- $e = $this->get($eid);
- if($e === false or $e->dead === true){
- return false;
- }
- $e->setHealth($e->getHealth() - $attack, $cause, $force);
- }
-
- public function dropRawPos(Position $pos, $item, $speedX, $speedY, $speedZ){
- if($item->getID() === AIR or $item->count <= 0){
- return;
- }
- $data = [
- "x" => $pos->x,
- "y" => $pos->y,
- "z" => $pos->z,
- "level" => $pos->level,
- "speedX" => $speedX,
- "speedY" => $speedY,
- "speedZ" => $speedZ,
- "item" => $item,
- ];
- if($this->server->api->handle("item.drop", $data) !== false){
- for($count = $item->count; $count > 0;){
- $item->count = min($item->getMaxStackSize(), $count);
- $count -= $item->count;
- $e = $this->add($pos->level, ENTITY_ITEM, $item->getID(), $data);
- $this->spawnToAll($e);
- $this->server->api->handle("entity.motion", $e);
- }
- }
- }
-
- public function drop(Position $pos, Item $item){
- if($item->getID() === AIR or $item->count <= 0){
- return;
- }
- $data = [
- "x" => $pos->x + mt_rand(-10, 10) / 50,
- "y" => $pos->y + 0.19,
- "z" => $pos->z + mt_rand(-10, 10) / 50,
- "level" => $pos->level,
- "speedX" => lcg_value() * 0.2 - 0.1,
- "speedY" => 0.2,
- "speedZ" => lcg_value() * 0.2 - 0.1,
- "item" => $item,
- ];
- if($this->server->api->handle("item.drop", $data) !== false){
- for($count = $item->count; $count > 0;){
- $item->count = min($item->getMaxStackSize(), $count);
- $count -= $item->count;
- $e = $this->add($pos->level, ENTITY_ITEM, $item->getID(), $data);
- $this->spawnToAll($e);
- $this->server->api->handle("entity.motion", $e);
- }
- }
- }
-
- public function spawnAll(Player $player){
- foreach($this->getAll($player->level) as $e){
- if($e->class !== ENTITY_PLAYER){
- $e->spawn($player);
- }
- }
- }
-
- public function getAll($level = null){
- if($level instanceof Level){
- return $level->entityList;
- }
- return $this->entities;
- }
-}
diff --git a/src/API/LevelAPI.php b/src/API/LevelAPI.php
deleted file mode 100644
index 8ef92340..00000000
--- a/src/API/LevelAPI.php
+++ /dev/null
@@ -1,266 +0,0 @@
-server = ServerAPI::request();
- $this->levels = [];
- }
-
- public function init(){
- $this->server->api->console->register("seed", "[world]", [$this, "commandHandler"]);
- $this->server->api->console->register("save-all", "", [$this, "commandHandler"]);
- $this->server->api->console->register("save-on", "", [$this, "commandHandler"]);
- $this->server->api->console->register("save-off", "", [$this, "commandHandler"]);
- $this->server->api->console->register("setwspawn", "Set the spawn position for your current world. ", [$this, "commandHandler"]);
- $this->server->api->console->register("place", "", [$this, "commandHandler"]);
- $this->default = $this->server->api->getProperty("level-name");
- if($this->loadLevel($this->default) === false){
- $this->generateLevel($this->default, $this->server->seed);
- $this->loadLevel($this->default);
- }
- $this->server->spawn = $this->getDefault()->getSafeSpawn();
- }
-
- public function loadLevel($name){
- if($this->get($name) !== false){
- return true;
- }elseif($this->levelExists($name) === false){
- console("[NOTICE] Level \"" . $name . "\" not found");
- return false;
- }
- $path = DATA_PATH . "worlds/" . $name . "/";
- console("[INFO] Preparing level \"" . $name . "\"");
- $level = new PMFLevel($path . "level.pmf");
- if(!$level->isLoaded){
- console("[ERROR] Could not load level \"" . $name . "\"");
- return false;
- }
- $entities = new Config($path . "entities.yml", CONFIG_YAML);
- if(file_exists($path . "tileEntities.yml")){
- @rename($path . "tileEntities.yml", $path . "tiles.yml");
- }
- $tiles = new Config($path . "tiles.yml", CONFIG_YAML);
- $blockUpdates = new Config($path . "bupdates.yml", CONFIG_YAML);
- $this->levels[$name] = new Level($level, $entities, $tiles, $blockUpdates, $name);
- foreach($entities->getAll() as $entity){
- if(!isset($entity["id"])){
- break;
- }
-
- $entity["x"] = $entity["Pos"][0];
- $entity["y"] = $entity["Pos"][1];
- $entity["z"] = $entity["Pos"][2];
- $entity["yaw"] = $entity["Rotation"][0];
- $entity["pitch"] = $entity["Rotation"][1];
-
- if($entity["id"] === 64){ //Item Drop
- $e = $this->server->api->entity->add($this->levels[$name], ENTITY_ITEM, $entity["Item"]["id"], [
- "meta" => $entity["Item"]["Damage"],
- "stack" => $entity["Item"]["Count"],
- "x" => $entity["Pos"][0],
- "y" => $entity["Pos"][1],
- "z" => $entity["Pos"][2],
- "yaw" => $entity["Rotation"][0],
- "pitch" => $entity["Rotation"][1],
- ]);
- }elseif($entity["id"] === FALLING_SAND){
- $e = $this->server->api->entity->add($this->levels[$name], ENTITY_FALLING, $entity["id"], $entity);
- //$e->setPosition(new Vector3($entity["Pos"][0], $entity["Pos"][1], $entity["Pos"][2]), $entity["Rotation"][0], $entity["Rotation"][1]);
- $e->setHealth($entity["Health"]);
- }elseif(Utils::getEntityTypeByID($entity["id"]) === ENTITY_OBJECT){ //Object
- $e = $this->server->api->entity->add($this->levels[$name], ENTITY_OBJECT, $entity["id"], $entity);
- //$e->setPosition(new Vector3($entity["Pos"][0], $entity["Pos"][1], $entity["Pos"][2]), $entity["Rotation"][0], $entity["Rotation"][1]);
- $e->setHealth(1);
- }else{
- $e = $this->server->api->entity->add($this->levels[$name], ENTITY_MOB, $entity["id"], $entity);
- //$e->setPosition(new Vector3($entity["Pos"][0], $entity["Pos"][1], $entity["Pos"][2]), $entity["Rotation"][0], $entity["Rotation"][1]);
- $e->setHealth($entity["Health"]);
- }
- }
-
- foreach($tiles->getAll() as $tile){
- if(!isset($tile["id"])){
- break;
- }
- $t = $this->server->api->tile->add($this->levels[$name], $tile["id"], $tile["x"], $tile["y"], $tile["z"], $tile);
- }
-
- $timeu = microtime(true);
- foreach($blockUpdates->getAll() as $bupdate){
- $this->server->api->block->scheduleBlockUpdate(new Position((int) $bupdate["x"], (int) $bupdate["y"], (int) $bupdate["z"], $this->levels[$name]), (float) $bupdate["delay"], (int) $bupdate["type"]);
- }
- return true;
- }
-
- public function get($name){
- if(isset($this->levels[$name])){
- return $this->levels[$name];
- }
- return false;
- }
-
- public function levelExists($name){
- if($name === ""){
- return false;
- }
- $path = DATA_PATH . "worlds/" . $name . "/";
- if($this->get($name) === false and !file_exists($path . "level.pmf")){
- $level = new LevelImport($path);
- if($level->import() === false){
- return false;
- }
- }
- return true;
- }
-
- public static function createGenerator($type, $options = []){
- return match($type){
- "FLAT" => new SuperflatGenerator(),
- "EXPERIMENTAL" => new ExperimentalGenerator($options),
- "HELL", "NETHER" => new HellGenerator($options),
- "END" => new EndGenerator($options),
- default => new NormalGenerator($options)
- };
- }
-
- public function generateLevel($name, $seed = false, $generator = false){
- if($this->levelExists($name)){
- return false;
- }
- $options = [];
- if($this->server->api->getProperty("generator-settings") !== false and trim($this->server->api->getProperty("generator-settings")) != ""){
- $options["preset"] = $this->server->api->getProperty("generator-settings");
- }
-
- if($generator !== false and class_exists($generator)){
- $generator = new $generator($options);
- }else{
- $type = strtoupper($this->server->api->getProperty("level-type"));
- $generator = $this->createGenerator($type, $options);
- }
- $gen = new WorldGenerator($generator, $name, $seed === false ? Utils::readInt(Utils::getRandomBytes(4, false)) : (int) $seed);
- $gen->generate();
- $gen->close();
- return true;
- }
-
- public function getDefault(){
- return $this->levels[$this->default];
- }
-
- public function commandHandler($cmd, $params, $issuer, $alias){
- $output = "";
- switch($cmd){
- case "place":
- if(!isset($params[0]) or $params[0] == "") return "/$cmd ";
- $class = $params[0];
- (new $class())->build($issuer->entity->level, $issuer->entity->x, $issuer->entity->y, $issuer->entity->z);
- break;
- case "setwspawn":
- if(!($issuer instanceof Player)){
- return ("Please run this command in-game. ");
- }
- $issuer->entity->level->setSpawn(new Vector3($issuer->entity->x, $issuer->entity->y, $issuer->entity->z));
- return ("Spawn set!");
- break;
- case "save-all":
- $output .= "Saving...\n";
- $save = $this->server->saveEnabled;
- $this->server->saveEnabled = true;
- $this->saveAll();
- $this->server->saveEnabled = $save;
- $output .= "Saved the world";
- break;
- case "save-on":
- $this->server->saveEnabled = true;
- break;
- case "save-off":
- $this->server->saveEnabled = false;
- break;
- case "seed":
- if(!isset($params[0]) and ($issuer instanceof Player)){
- $output .= "Seed: " . $issuer->level->getSeed() . "\n";
- }elseif(isset($params[0])){
- if(($lv = $this->server->api->level->get(trim(implode(" ", $params)))) !== false){
- $output .= "Seed: " . $lv->getSeed() . "\n";
- }
- }else{
- $output .= "Seed: " . $this->server->api->level->getDefault()->getSeed() . "\n";
- }
- }
- return $output;
- }
-
- public function saveAll(){
- foreach($this->levels as $level){
- $level->save();
- }
- }
-
- public function handle($data, $event){
- switch($event){
- }
- }
-
- public function __destruct(){
- $this->saveAll();
- foreach($this->levels as $level){
- $this->unloadLevel($level, true);
- }
- }
-
- public function unloadLevel(Level $level, $force = false){
- $name = $level->getName();
- if($name === $this->default and $force !== true){
- return false;
- }
- console("[INFO] Unloading level \"" . $name . "\"");
- $level->nextSave = PHP_INT_MAX;
- $level->save();
- foreach($this->server->api->player->getAll($level) as $player){
- $player->teleport($this->server->spawn);
- }
- foreach($this->server->api->entity->getAll($level) as $entity){
- if($entity->class !== ENTITY_PLAYER){
- $entity->close();
- }
- }
- foreach($this->server->api->tile->getAll($level) as $tile){
- $tile->close();
- }
- $level->close();
- unset($this->levels[$name]);
- return true;
- }
-
- public function getSpawn(){
- return $this->server->spawn;
- }
-
- public function loadMap(){
- if($this->mapName !== false and trim($this->mapName) !== ""){
- if(!file_exists($this->mapDir . "level.pmf")){
- $level = new LevelImport($this->mapDir);
- $level->import();
- }
- $this->level = new PMFLevel($this->mapDir . "level.pmf");
- console("[INFO] Preparing level \"" . $this->level->getData("name") . "\"");
- $this->time = (int) $this->level->getData("time");
- $this->seed = (int) $this->level->getData("seed");
- $this->spawn = $this->level->getSpawn();
- }
- }
-
- public function getAll(){
- return $this->levels;
- }
-
-}
diff --git a/src/API/PlayerAPI.php b/src/API/PlayerAPI.php
deleted file mode 100644
index e15da5af..00000000
--- a/src/API/PlayerAPI.php
+++ /dev/null
@@ -1,501 +0,0 @@
-server = ServerAPI::request();
- }
-
- public function init(){
- $this->server->schedule(20 * 15, [$this, "handle"], 1, true, "server.regeneration");
- $this->server->addHandler("player.death", [$this, "handle"], 1);
- $this->registerCmd("list");
- $this->registerCmd("kill", "");
- $this->registerCmd("gamemode", " [player]", [$this, "commandHandler"]);
- $this->registerCmd("tp", "[target player] OR /tp [target player] ");
- $this->registerCmd("spawnpoint", "[player] [x] [y] [z]");
- $this->registerCmd("spawn");
- $this->registerCmd("ping");
- $this->registerCmd("loc");
-
- $this->server->api->console->alias("lag", "ping");
- $this->server->api->console->alias("gm", "gamemode");
- $this->server->api->console->alias("who", "list");
- $this->server->api->console->alias("suicide", "kill");
- $this->server->api->console->alias("tppos", "tp");
- $this->server->api->console->alias("xyz", "loc");
- $this->server->api->console->alias("coords", "loc");
-
- $this->server->api->console->cmdWhitelist("list");
- $this->server->api->console->cmdWhitelist("ping");
- $this->server->api->console->cmdWhitelist("spawn");
- $this->server->api->console->cmdWhitelist("loc");
- $this->server->preparedSQL->selectPlayersToHeal = $this->server->database->prepare("SELECT EID FROM entities WHERE class = " . ENTITY_PLAYER . " AND health < 20;");
- }
-
- public function registerCmd($cmd, $help = ""){
- $this->server->api->console->register($cmd, $help, [$this, "commandHandler"]);
- }
-
- public function handle($data, $event){
- switch($event){
- case "server.regeneration":
- if($this->server->difficulty === 0){
- $result = $this->server->preparedSQL->selectPlayersToHeal->execute();
- if($result !== false){
- while(($player = $result->fetchArray()) !== false){
- if(($player = $this->server->api->entity->get($player["EID"])) !== false){
- if($player->getHealth() <= 0){
- continue;
- }
- $player->setHealth(min(20, $player->getHealth() + $data), "regeneration");
- }
- }
- return true;
- }
- }
- break;
- case "player.death":
- if(is_numeric($data["cause"])){
- $e = $this->server->api->entity->get($data["cause"]);
- if($e instanceof Entity){
- switch($e->class){
- case ENTITY_PLAYER:
- $message = " was killed by " . $e->name;
- break;
- default:
- $message = " was killed by {$e->getName()}";
- break;
- }
- }
- }else{
- switch($data["cause"]){
- case "cactus":
- $message = " was pricked to death";
- break;
- case "lava":
- $message = " tried to swim in lava";
- break;
- case "fire":
- $message = " went up in flames";
- break;
- case "burning":
- $message = " burned to death";
- break;
- case "suffocation":
- $message = " suffocated in a wall";
- break;
- case "water":
- $message = " drowned";
- break;
- case "void":
- $message = " fell out of the world";
- break;
- case "fall":
- $message = " hit the ground too hard";
- break;
- case "explosion":
- $message = " blew up";
- break;
- default:
- $message = " died";
- break;
- }
- }
- $this->server->api->chat->broadcast($data["player"]->username . $message);
- return true;
- break;
- }
- }
-
- public function commandHandler($cmd, $args, $issuer, $alias){
- $output = "";
- switch($cmd){
- case "spawnpoint":
- if(!($issuer instanceof Player)){
- return "Please run this command in-game.";
- }
-
- if(count($args) === 1 or count($args) === 4){
- $target = $this->server->api->player->get(array_shift($args));
- }else{
- $target = $issuer;
- }
-
- if(!($target instanceof Player)){
- return "That player cannot be found.";
- }
-
- if(count($args) === 3){
- $spawn = new Position(floatval(array_shift($args)), floatval(array_shift($args)), floatval(array_shift($args)), $issuer->level);
- }else{
- $spawn = new Position($issuer->entity->x, $issuer->entity->y, $issuer->entity->z, $issuer->entity->level);
- }
-
- $target->setSpawn($spawn);
- return "Spawnpoint set correctly!\n";
- case "spawn":
- if(!($issuer instanceof Player)){
- return "Please run this command in-game.";
- }
- $issuer->teleport($this->server->spawn);
- return "You were teleported to the spawn.";
- case "ping":
- if(!($issuer instanceof Player)){
- return "Please run this command in-game.";
- }
- return "ping " . round($issuer->getLag(), 2) . "ms, packet loss " . round($issuer->getPacketLoss() * 100, 2) . "%, " . round($issuer->getBandwidth() / 1024, 2) . " KB/s\n";
- case "gamemode":
- $player = false;
- $setgm = false;
- $gms = [
- "0" => SURVIVAL,
- "survival" => SURVIVAL,
- "s" => SURVIVAL,
- "1" => CREATIVE,
- "creative" => CREATIVE,
- "c" => CREATIVE,
- "2" => ADVENTURE,
- "adventure" => ADVENTURE,
- "a" => ADVENTURE,
- "3" => VIEW,
- "view" => VIEW,
- "viewer" => VIEW,
- "spectator" => VIEW,
- "v" => VIEW,
- ];
- if($issuer instanceof Player){
- $player = $issuer;
- }
- if(count($args) == 1){
- $setgm = $args[0];
- }elseif(isset($args[1])){
- if($this->server->api->player->get($args[1]) instanceof Player){
- $player = $this->server->api->player->get($args[1]);
- $setgm = $args[0];
- }elseif($this->server->api->player->get($args[0]) instanceof Player){
- $player = $this->server->api->player->get($args[0]);
- $setgm = $args[1];
- }else{
- return "Usage: /$cmd [player] or /$cmd [player] \n";
- }
- }
- if(!($player instanceof Player) or !isset($gms[strtolower($setgm)])){
- return "Usage: /$cmd [player] or /$cmd [player] \n";
- }
- if($player->setGamemode($gms[strtolower($setgm)])){
- return "Gamemode of " . $player->username . " changed to " . $player->getGamemode() . "\n";
- }
- break;
- case "tp":
- if(count($args) <= 2 or substr($args[0], 0, 2) === "w:" or substr($args[1], 0, 2) === "w:"){
- if((!isset($args[1]) or substr($args[0], 0, 2) === "w:") and isset($args[0]) and ($issuer instanceof Player)){
- $name = $issuer->username;
- $target = implode(" ", $args);
- }elseif(isset($args[1]) and isset($args[0])){
- $name = array_shift($args);
- $target = implode(" ", $args);
- }else{
- return "Usage: /$cmd [target player] \n";
- }
- if($this->teleport($name, $target) !== false){
- return "\"$name\" teleported to \"$target\"\n";
- }else{
- return "Couldn't teleport.\n";
- }
- }else{
- if(!isset($args[3]) and isset($args[2]) and isset($args[1]) and isset($args[0]) and ($issuer instanceof Player)){
- $name = $issuer->username;
- $x = $args[0];
- $y = $args[1];
- $z = $args[2];
- }elseif(isset($args[3]) and isset($args[2]) and isset($args[1]) and isset($args[0])){
- $name = $args[0];
- $x = $args[1];
- $y = $args[2];
- $z = $args[3];
- }else{
- return "Usage: /$cmd [player] \n";
- }
- if($this->tppos($name, $x, $y, $z)){
- return "\"$name\" teleported to ($x, $y, $z)\n";
- }else{
- return "Couldn't teleport.\n";
- }
- }
- case "kill":
- case "suicide":
- if(!isset($args[0]) and ($issuer instanceof Player)){
- $player = $issuer;
- }else{
- $player = $this->get($args[0]);
- }
- if($player instanceof Player){
- $player->entity->harm(PHP_INT_MAX, "console", true);
- return "Ouch. That looks like it hurt.\n";
- }else{
- return "Usage: /$cmd [player]\n";
- }
- break;
- case "list":
- $output .= "There are " . count($this->server->clients) . "/" . $this->server->maxClients . " players online:\n";
- if(count($this->server->clients) == 0){
- break;
- }
- foreach($this->server->clients as $c){
- $output .= $c->username . ", ";
- }
- return substr($output, 0, -2) . "\n";
- break;
- case "loc":
- if(!($issuer instanceof Player)) return "Please run this command in-game.";
- $x = round($issuer->entity->x, 1, PHP_ROUND_HALF_UP);
- $y = round($issuer->entity->y, 1, PHP_ROUND_HALF_UP);
- $z = round($issuer->entity->z, 1, PHP_ROUND_HALF_UP);
- $level = $issuer->entity->level->getName();
- $compass = [0 => "X+", 1 => "Z+", 2 => "X-", 3 => "Z-", null => "null"];
- $direction = $compass[$issuer->entity->getDirection()];
- return "Your coordinates: X: $x, Y: $y, Z: $z, world: $level.\nDirection: $direction";
- }
- return $output;
- }
-
- public function get($name, $alike = true, $multiple = false){
- $name = trim(strtolower($name));
- if($name === ""){
- return false;
- }
- $query = $this->server->query("SELECT ip,port,name FROM players WHERE name " . ($alike === true ? "LIKE '" . $name . "%'" : "= '" . $name . "'") . ";");
- $players = [];
- if($query !== false and $query !== true){
- while(($d = $query->fetchArray(SQLITE3_ASSOC)) !== false){
- $CID = PocketMinecraftServer::clientID($d["ip"], $d["port"]);
- if(isset($this->server->clients[$CID])){
- $players[$CID] = $this->server->clients[$CID];
- if($multiple === false and $d["name"] === $name){
- return $players[$CID];
- }
- }
- }
- }
-
- if($multiple === false){
- if(count($players) > 0){
- return array_shift($players);
- }else{
- return false;
- }
- }else{
- return $players;
- }
- }
-
- public function teleport(&$name, &$target){
- if(substr($target, 0, 2) === "w:"){
- $lv = $this->server->api->level->get(substr($target, 2));
- if($lv instanceof Level){
- $origin = $this->get($name);
- if($origin instanceof Player){
- $name = $origin->username;
- return $origin->teleport($lv->getSafeSpawn());
- }
- }else{
- return false;
- }
- }
- $player = $this->get($target);
- if(($player instanceof Player) and ($player->entity instanceof Entity)){
- $target = $player->username;
- $origin = $this->get($name);
- if($origin instanceof Player){
- $name = $origin->username;
- return $origin->teleport($player->entity);
- }
- }
- return false;
- }
-
- public function tppos(&$name, &$x, &$y, &$z){
- $player = $this->get($name);
- if(($player instanceof Player) and ($player->entity instanceof Entity)){
- $name = $player->username;
- $x = $x[0] === "~" ? $player->entity->x + floatval(substr($x, 1)) : floatval($x);
- $y = $y[0] === "~" ? $player->entity->y + floatval(substr($y, 1)) : floatval($y);
- $z = $z[0] === "~" ? $player->entity->z + floatval(substr($z, 1)) : floatval($z);
- $player->teleport(new Vector3($x, $y, $z));
- return true;
- }
- return false;
- }
-
- public function broadcastPacket(array $players, RakNetDataPacket $packet){
- foreach($players as $p){
- $p->dataPacket(clone $packet);
- }
- }
-
- public function online(){
- $o = [];
- foreach($this->server->clients as $p){
- if($p->auth === true){
- $o[] = $p->username;
- }
- }
- return $o;
- }
-
- public function add($CID){
- if(isset($this->server->clients[$CID])){
- $player = $this->server->clients[$CID];
- $player->data = $this->getOffline($player->username);
- $player->gamemode = $player->data->get("gamemode");
- if(($player->level = $this->server->api->level->get($player->data->get("position")["level"])) === false){
- $player->level = $this->server->api->level->getDefault();
- $player->data->set("position", [
- "level" => $player->level->getName(),
- "x" => $player->level->getSpawn()->x,
- "y" => $player->level->getSpawn()->y,
- "z" => $player->level->getSpawn()->z,
- ]);
- }
- $this->server->query("INSERT OR REPLACE INTO players (CID, ip, port, name) VALUES (" . $player->CID . ", '" . $player->ip . "', " . $player->port . ", '" . strtolower($player->username) . "');");
- }
- }
-
- public function getOffline($name, $create = true){
- $iname = strtolower($name);
- $default = [
- "caseusername" => $name,
- "position" => [
- "level" => $this->server->spawn->level->getName(),
- "x" => $this->server->spawn->x,
- "y" => $this->server->spawn->y,
- "z" => $this->server->spawn->z,
- ],
- "spawn" => [
- "level" => $this->server->spawn->level->getName(),
- "x" => $this->server->spawn->x,
- "y" => $this->server->spawn->y,
- "z" => $this->server->spawn->z,
- ],
- "inventory" => array_fill(0, PLAYER_SURVIVAL_SLOTS, [AIR, 0, 0]),
- "hotbar" => [0, -1, -1, -1, -1, -1, -1, -1, -1],
- "armor" => array_fill(0, 4, [AIR, 0]),
- "gamemode" => $this->server->gamemode,
- "health" => 20,
- "lastIP" => "",
- "lastID" => 0,
- "achievements" => [],
- ];
-
- if(!file_exists(DATA_PATH . "players/" . $iname . ".yml")){
- if($this->server->extraprops->get("save-player-data") && $create){
- console("[NOTICE] Player data not found for \"" . $iname . "\", creating new profile");
- $data = new Config(DATA_PATH . "players/" . $iname . ".yml", CONFIG_YAML, $default);
- $data->save();
- }else{
- return false;
- }
- }
-
- $data = new Config(DATA_PATH . "players/" . $iname . ".yml", CONFIG_YAML, $default);
-
- if(($data->get("gamemode") & 0x01) === 1){
- $data->set("health", 20);
- }
- $this->server->handle("player.offline.get", $data);
- return $data;
- }
-
- public function spawnAllPlayers(Player $player){
- foreach($this->getAll() as $p){
- if($p !== $player and ($p->entity instanceof Entity)){
- $p->entity->spawn($player);
- if($p->level !== $player->level){
- $pk = new MoveEntityPacket_PosRot;
- $pk->eid = $p->entity->eid;
- $pk->x = -256;
- $pk->y = 128;
- $pk->z = -256;
- $pk->yaw = 0;
- $pk->pitch = 0;
- $player->dataPacket($pk);
- }
- }
- }
- }
-
- public function getAll($level = null){
- if($level instanceof Level){
- $clients = [];
- $l = $this->server->query("SELECT EID FROM entities WHERE level = '" . $level->getName() . "' AND class = '" . ENTITY_PLAYER . "';");
- if($l !== false and $l !== true){
- while(($e = $l->fetchArray(SQLITE3_ASSOC)) !== false){
- $e = $this->getByEID($e["EID"]);
- if($e instanceof Player){
- $clients[$e->CID] = $e;
- }
- }
- } return $clients;
-
- }
- return $this->server->clients;
- }
-
- public function getByEID($eid){
- $eid = (int) $eid;
- $CID = $this->server->query("SELECT ip,port FROM players WHERE EID = '" . $eid . "';", true);
- $CID = is_array($CID) ? PocketMinecraftServer::clientID($CID["ip"], $CID["port"]) : false;
- if(isset($this->server->clients[$CID])){
- return $this->server->clients[$CID];
- }
- return false;
- }
-
- public function spawnToAllPlayers(Player $player){
- foreach($this->getAll() as $p){
- if($p !== $player and ($p->entity instanceof Entity) and ($player->entity instanceof Entity)){
- $player->entity->spawn($p);
- if($p->level !== $player->level){
- $pk = new MoveEntityPacket_PosRot;
- $pk->eid = $player->entity->eid;
- $pk->x = -256;
- $pk->y = 128;
- $pk->z = -256;
- $pk->yaw = 0;
- $pk->pitch = 0;
- $p->dataPacket($pk);
- }
- }
- }
- }
-
- public function remove($CID){
- if(isset($this->server->clients[$CID])){
- $player = $this->server->clients[$CID];
- $player->close();
- if($player->username != "" and ($player->data instanceof Config)){
- $this->saveOffline($player->data);
- }
- $this->server->query("DELETE FROM players WHERE name = '" . $player->username . "';");
- $this->server->api->entity->remove($player->eid);
- unset($this->server->clients[$CID]);
- if($player->entity instanceof Entity){
- unset($player->entity->player);
- //unset($player->entity);
- }
-
- $player = null;
- unset($player);
- }
- }
-
- public function saveOffline(Config $data){
- if($this->server->extraprops->get("save-player-data")){
- $this->server->handle("player.offline.save", $data);
- $data->save();
- }
- }
-}
diff --git a/src/API/PluginAPI.php b/src/API/PluginAPI.php
deleted file mode 100644
index 04d65d53..00000000
--- a/src/API/PluginAPI.php
+++ /dev/null
@@ -1,313 +0,0 @@
-server = ServerAPI::request();
- $this->randomNonce = Utils::getRandomBytes(16, false);
- $this->server->api->console->register("plugins", "", [$this, "commandHandler"]);
- $this->server->api->console->register("version", "", [$this, "commandHandler"]);
- $this->server->api->console->cmdWhitelist("version");
- if($this->server->extraprops->get("query-plugins")){ //allow players to also view plugins ingame, since query makes names public
- $this->server->api->console->cmdWhitelist("plugins");
- }
- $this->server->api->console->alias("pl", "plugins");
- $this->server->api->console->alias("ver", "version");
- $this->server->api->console->alias("about", "version");
- }
-
- public function commandHandler($cmd, $params, $issuer, $alias){
- $output = "";
- switch($cmd){
- case "plugins":
- $output = "Plugins (" . count($this->plugins) . "): ";
- foreach($this->getList() as $plugin){
- $output .= $plugin["name"] . " v" . $plugin["version"] . ", ";
- }
- $output = $output === "Plugins (0): " ? "No plugins installed." : substr($output, 0, -2);
- break;
- case "version":
- $output = "This server is running NostalgiaCore version: " . MAJOR_VERSION .", PHP version: ". PHP_VERSION . "\n(Implementing API version #" . CURRENT_API_VERSION . " for Minecraft: PE " . CURRENT_MINECRAFT_VERSION . ")";
- if(GIT_COMMIT !== str_repeat("00", 20)){
- $output .= " (git " . GIT_COMMIT . ")";
- }
- break;
- }
- return $output;
- }
-
- public function getList(){
- $list = [];
- foreach($this->plugins as $p){
- $list[] = $p[1];
- }
- return $list;
- }
-
- public function __destruct(){
- foreach($this->plugins as $p){
- if(method_exists($p[0], "__destruct")){$p[0]->__destruct();};
- }
- unset($this->plugins);
- }
-
- public function getAll(){
- return $this->plugins;
- }
-
- public function createConfig(Plugin $plugin, $default = []){
- $p = $this->get($plugin);
- if($p === false){
- return false;
- }
- $path = $this->configPath($plugin);
- $cnf = new Config($path . "config.yml", CONFIG_YAML, $default);
- $cnf->save();
- return $path;
- }
-
- public function get($identifier){
- if($identifier instanceof Plugin){
- foreach($this->plugins as $p){
- if($p[0] === $identifier){
- return $p;
- }
- }
- return false;
- }
- if(isset($this->plugins[$identifier])){
- return $this->plugins[$identifier];
- }
- return false;
- }
-
- public function configPath(Plugin $plugin){
- $p = $this->get($plugin);
- $identifier = $this->getIdentifier($p[1]["name"], $p[1]["author"]);
- if($p === false){
- return false;
- }
- $path = $this->pluginsPath() . $p[1]["name"] . DIRECTORY_SEPARATOR;
- $this->plugins[$identifier][1]["path"] = $path;
- if(!file_exists($path)){
- mkdir($path, 0777);
- }
- return $path;
- }
-
- public function pluginsPath(){
- $path = join(DIRECTORY_SEPARATOR, [DATA_PATH . "plugins", ""]);
- if(!file_exists($path)){
- mkdir($path, 0777);
- }
-
- return $path;
- }
-
- public function readYAML($file){
- return yaml_parse(preg_replace("#^([ ]*)([a-zA-Z_]{1}[^\:]*)\:#m", "$1\"$2\":", file_get_contents($file)));
- }
-
- public function writeYAML($file, $data){
- return file_put_contents($file, yaml_emit($data, YAML_UTF8_ENCODING));
- }
-
- public function init(){
- $this->server->event("server.start", [$this, "initAll"]);
- $this->loadAll();
- }
-
- private function loadAll(){
- $pharCnt = 0;
- $dir = dir($this->pluginsPath());
- while(false !== ($file = $dir->read())){
- if($file[0] !== "."){
- $ext = strtolower(substr($file, -3));
- $ext2 = strtolower(substr($file, -4));
- if($ext === "php" or $ext === "pmf"){
- $this->load($dir->path . $file);
- }
- if($ext2 === "phar"){
- ++$pharCnt;
- $pluginInfo = []; //TODO: A PluginInfo class?
- $filePath = $this->pluginsPath().$file;
- $p = new Phar($this->pluginsPath().$file, 0);
- foreach (new RecursiveIteratorIterator($p) as $file) {
- $name = $file->getFileName();
- $content = file_get_contents($file->getPathName());
- if($name === "plugin.cfg"){
- $pluginInfo = PharUtils::readMainConfig($content);
- break;
- }
- }
- console("[INFO] Loading PHAR plugin \"".FORMAT_GREEN.$pluginInfo["name"].FORMAT_RESET."\" ".FORMAT_AQUA.$pluginInfo["version"].FORMAT_RESET." by ".FORMAT_AQUA.$pluginInfo["author"].FORMAT_RESET);
-
- $aver = CURRENT_API_VERSION;
- if(!in_array((string) CURRENT_API_VERSION, $pluginInfo["api"])){
- if(is_array($pluginInfo)) $s = implode(",",$pluginInfo["api"]);
- else $s = $pluginInfo["api"];
- console("[WARNING] API is not the same as Core, might cause bugs({$s} != {$aver})");
- }
-
- $phr = "phar://$filePath/";
- include($phr."/src/".$pluginInfo["classLoader"]);
- $class = $pluginInfo["CLClass"];
- $loader = new $class();
- $loader->loadAll($phr);
-
- $pluginName = PharUtils::getNameSpaceClass($pluginInfo["mainFile"]);
- include($phr."/src/".$pluginInfo["mainFile"]);
- $plugin = new $pluginName($this->server->api, false);
- if(!($plugin instanceof Plugin)){
- console("[ERROR] Plugin \"" . $pluginInfo["name"] . "\" doesn't use the Plugin Interface");
- $plugin->__destruct();
- unset($plugin);
- continue;
- }
- $identifier = $this->getIdentifier($pluginInfo["name"], $pluginInfo["author"]);
- $this->plugins[$identifier] = [$plugin, $pluginInfo];
- }
- }
- }
- if($pharCnt > 0){
- console("[WARNING] PHAR Plugin format is experemental and might cause bugs.");
- }
- }
-
- public function load($file){
- if(is_link($file) or is_dir($file) or !file_exists($file)){
- console("[ERROR] " . basename($file) . " is not a file");
- return false;
- }
- if(strtolower(substr($file, -3)) === "pmf"){
- $pmf = new PMFPlugin($file);
- $info = $pmf->getPluginInfo();
- }else{
- $content = file_get_contents($file);
- $info = strstr($content, "*/", true);
- $content = str_repeat(PHP_EOL, substr_count($info, "\n")) . substr(strstr($content, "*/"), 2);
- if(preg_match_all('#([a-zA-Z0-9\-_]*)=([^\r\n]*)#u', $info, $matches) == 0){ //false or 0 matches
- console("[ERROR] Failed parsing of " . basename($file));
- return false;
- }
- $info = [];
- foreach($matches[1] as $k => $i){
- $v = $matches[2][$k];
- switch(strtolower($v)){
- case "on":
- case "true":
- case "yes":
- $v = true;
- break;
- case "off":
- case "false":
- case "no":
- $v = false;
- break;
- }
- $info[$i] = $v;
- }
- $info["code"] = $content;
- $info["class"] = trim(strtolower($info["class"]));
- }
- if(!isset($info["name"]) or !isset($info["version"]) or !isset($info["class"]) or !isset($info["author"])){
- console("[ERROR] Failed parsing of " . basename($file));
- return false;
- }
- console("[INFO] Loading plugin \"" . FORMAT_GREEN . $info["name"] . FORMAT_RESET . "\" " . FORMAT_AQUA . $info["version"] . FORMAT_RESET . " by " . FORMAT_AQUA . $info["author"] . FORMAT_RESET);
- if($info["class"] !== "none" and class_exists($info["class"])){
- console("[ERROR] Failed loading plugin: class already exists");
- return false;
- }
- if(((!isset($pmf) and (include $file) === false) or (isset($pmf) and eval($info["code"]) === false)) and $info["class"] !== "none" and !class_exists($info["class"])){
- console("[ERROR] Failed loading {$info['name']}: evaluation error");
- return false;
- }
-
- $className = $info["class"];
- $apiversion = array_map("floatval", explode(",", (string) $info["apiversion"]));
- if(!in_array((string) CURRENT_API_VERSION, $apiversion)){
- console("[WARNING] Plugin \"" . $info["name"] . "\" may not be compatible with the API (" . $info["apiversion"] . " != " . CURRENT_API_VERSION . ")! It can crash or corrupt the server!");
- }
-
- $identifier = $this->getIdentifier($info["name"], $info["author"]);
-
- if($info["class"] !== "none"){
- $object = new $className($this->server->api, false);
- if(!($object instanceof Plugin)){
- console("[ERROR] Plugin \"" . $info["name"] . "\" doesn't use the Plugin Interface");
- if(method_exists($object, "__destruct")){
- $object->__destruct();
- }
- $object = null;
- unset($object);
- }else{
- $this->plugins[$identifier] = [$object, $info];
- }
- }else{
- $this->plugins[$identifier] = [new DummyPlugin($this->server->api, false), $info];
- }
- return true;
- }
-
- public function getIdentifier($name, $author){
- return sha1(trim(strtolower($name)), true) ^ sha1(trim(strtolower($author)), true) ^ sha1($this->randomNonce, true);
- }
-
- public function initAll(){
- console("[INFO] Starting plugins...");
- $names = [];
- $versions = [];
- foreach($this->plugins as $p){
- $names[] = $p[1]["name"];
- $versions[] = $p[1]["version"];
- }
-
- foreach($this->plugins as $p){
- if($p[0] instanceof OtherPluginRequirement){
- foreach($p[0]->getRequiredPlugins() as $required){
- if(in_array($required->pluginName, $names)){
- if(!in_array($required->version, $versions) && $required->version !== false){
- console("[WARNING] Plugin \"" . $required->pluginName . "\" needed by \"" . $p[1]["name"] . "\" is incorrect version.");
- }
- }else{
- console("[ERROR] Plugin \"" . $required->pluginName . "\" needed by \"" . $p[1]["name"] . "\" is not found.");
- ServerAPI::request()->close();
-
- }
- }
- }
- $p[0]->init(); //ARGHHH!!! Plugin loading randomly fails!!
- }
- }
-
- private function fillDefaults($default, &$yaml){
- foreach($default as $k => $v){
- if(is_array($v)){
- if(!isset($yaml[$k]) or !is_array($yaml[$k])){
- $yaml[$k] = [];
- }
- $this->fillDefaults($v, $yaml[$k]);
- }elseif(!isset($yaml[$k])){
- $yaml[$k] = $v;
- }
- }
- }
-}
-
-class RequiredPluginEntry{ //Use this as object of requirements array
-
- public $pluginName;
- public $version;
-
- public function __construct($name, $version = false){
- $this->pluginName = $name;
- $this->version = $version;
- }
-}
-
-
\ No newline at end of file
diff --git a/src/API/QueryAPI.php b/src/API/QueryAPI.php
deleted file mode 100644
index 46357c6f..00000000
--- a/src/API/QueryAPI.php
+++ /dev/null
@@ -1,42 +0,0 @@
-server = ServerAPI::request();
- QueryAPI::$NOT_FOUND_VALUE = new NFV();
- $this->updateQueryData("splitnum", chr(128));
- $this->updateQueryData("hostname", $this->server->name);
- $this->updateQueryData("gametype", ($this->server->gamemode & 0x01) === 0 ? "SMP" : "CMP");
- $this->updateQueryData("game_id", "MINECRAFTPE");
- $this->updateQueryData("version", CURRENT_MINECRAFT_VERSION);
- $this->updateQueryData("server_engine", "NostalgiaCore " . MAJOR_VERSION);
- $this->addToQuery("plugins");
- $this->addToQuery("map");
- $this->addToQuery("numplayers");
- $this->updateQueryData("maxplayers", $this->server->maxClients);
- $this->updateQueryData("whitelist", $this->server->api->getProperty("white-list") === true ? "on" : "off");
- $this->updateQueryData("hostport", $this->server->api->getProperty("server-port"));
- $this->addToQuery("tps");
- }
-
- public function updateQueryData($name, $value){
- $this->queryData[$name] = $value;
- }
-
- public function addToQuery($name){
- $this->updateQueryData($name, QueryAPI::$NOT_FOUND_VALUE);
- }
-
- public function getQueryData(){
- return $this->queryData;
- }
-}
-
-class NFV{
-
-}
\ No newline at end of file
diff --git a/src/API/ServerAPI.php b/src/API/ServerAPI.php
deleted file mode 100644
index 33fe79be..00000000
--- a/src/API/ServerAPI.php
+++ /dev/null
@@ -1,414 +0,0 @@
-run();
- }
-
- public function run(){
- $this->load();
- return $this->init();
- }
-
- public function load(){
- if(!file_exists(DATA_PATH . "worlds/")){
- mkdir(DATA_PATH . "worlds/", 0777);
- }
-
- if(!file_exists(DATA_PATH . "players/")){
- mkdir(DATA_PATH . "players/", 0777);
- }
-
- if(!file_exists(DATA_PATH . "plugins/")){
- mkdir(DATA_PATH . "plugins/", 0777);
- }
-
- //Init all the events
- foreach(get_declared_classes() as $class){
- if(is_subclass_of($class, "BaseEvent") and property_exists($class, "handlers") and property_exists($class, "handlerPriority")){
- $class::unregisterAll();
- }
- }
-
- $version = new VersionString();
- console("[INFO] Starting Minecraft PE server version " . FORMAT_AQUA . CURRENT_MINECRAFT_VERSION);
-
- console("[INFO] Loading properties...");
- $this->config = new Config(DATA_PATH . "server.properties", CONFIG_PROPERTIES, [
- "server-name" => "Minecraft: PE Server",
- "description" => "Server made using NostalgiaCore",
- "motd" => "Welcome @player to this server!",
- "server-ip" => "",
- "server-port" => 19132,
- "server-type" => "normal",
- "memory-limit" => "128M",
- "white-list" => false,
- "announce-player-achievements" => true,
- "spawn-protection" => 16,
- "view-distance" => 10,
- "max-players" => 20,
- "allow-flight" => false,
- "spawn-animals" => true,
- "spawn-mobs" => true,
- "mobs-amount" => 50,
- "gamemode" => SURVIVAL,
- "hardcore" => false,
- "pvp" => true,
- "difficulty" => 1,
- "generator-settings" => "",
- "level-name" => "world",
- "level-seed" => "",
- "level-type" => "DEFAULT",
- "enable-query" => true,
- "enable-rcon" => false,
- "rcon.password" => substr(base64_encode(Utils::getRandomBytes(20, false)), 3, 10),
- "auto-save" => true,
- "chunk-send-delay-ticks" => PocketMinecraftServer::$chukSendDelay,
- "chunk-loading-radius" => PocketMinecraftServer::$chunkLoadingRadius,
- ]);
- Biome::init();
- $this->parseProperties();
- MobSpawner::$MOB_LIMIT = $this->getProperty("mobs-amount", 50);
- LevelAPI::$defaultLevelType = $this->getProperty("level-type");
- //Load advanced properties
- define("DEBUG", $this->getProperty("debug", 1));
- define("ADVANCED_CACHE", $this->getProperty("enable-advanced-cache", false));
- //define("MAX_CHUNK_RATE", 20 / $this->getProperty("max-chunks-per-second", 8)); //Default rate ~512 kB/s
- if(ADVANCED_CACHE == true){
- console("[INFO] Advanced cache enabled");
- }
- MobSpawner::$spawnAnimals = $this->getProperty("spawn-animals");
- MobSpawner::$spawnMobs = $this->getProperty("spawn-mobs");
- PocketMinecraftServer::$chukSendDelay = $this->getProperty("chunk-send-delay-ticks");
- PocketMinecraftServer::$chunkLoadingRadius = $this->getProperty("chunk-loading-radius");
-
- if(PocketMinecraftServer::$chunkLoadingRadius < 4){
- ConsoleAPI::warn("Players may not be able to join if chunk loading radius is less than 4!");
- }
-
- if($this->getProperty("upnp-forwarding") == true){
- console("[INFO] [UPnP] Trying to port forward...");
- UPnP_PortForward($this->getProperty("server-port"));
- }
-
- $this->server = new PocketMinecraftServer($this->getProperty("server-name"), $this->getProperty("gamemode"), ($seed = $this->getProperty("level-seed")) != "" ? (int) $seed : false, $this->getProperty("server-port"), ($ip = $this->getProperty("server-ip")) != "" ? $ip : "0.0.0.0");
- $this->server->api = $this;
- self::$serverRequest = $this->server;
- $this->server->send2Discord("[INFO] Starting Minecraft PE server version " . CURRENT_MINECRAFT_VERSION);
- console("[INFO] This server is running NostalgiaCore version " . ($version->isDev() ? FORMAT_YELLOW : "") . MAJOR_VERSION . FORMAT_RESET . " \"" . CODENAME . "\" (MCPE: " . CURRENT_MINECRAFT_VERSION . ") (API " . CURRENT_API_VERSION . ") (PHP " . PHP_VERSION . ")", true, true, 0);
- console("[INFO] NostalgiaCore is distributed under the LGPL License", true, true, 0);
-
- $this->loadProperties();
- $this->loadAPI("console", "ConsoleAPI");
- $this->loadAPI("level", "LevelAPI");
- $this->loadAPI("block", "BlockAPI");
- $this->loadAPI("chat", "ChatAPI");
- $this->loadAPI("ban", "BanAPI");
- $this->loadAPI("entity", "EntityAPI");
- $this->loadAPI("tile", "TileAPI");
- $this->loadAPI("player", "PlayerAPI");
- $this->loadAPI("time", "TimeAPI");
- $this->loadAPI("queryAPI", "QueryAPI");
- $this->loadAPI("achievement", "AchievementAPI");
- foreach($this->apiList as $ob){
- if(is_callable([$ob, "init"])){
- $ob->init(); //Fails sometimes!!!
- }
- }
- $this->loadAPI("plugin", "PluginAPI"); //fix :(
- $this->plugin->init();
-
- }
-
- private function parseProperties(){
- foreach($this->config->getAll() as $n => $v){
- switch($n){
- case "gamemode":
- case "max-players":
- case "server-port":
- case "debug":
- case "difficulty":
- $v = (int) $v;
- break;
- case "server-id":
- if($v !== false){
- $v = preg_match("/[^0-9\-]/", $v) > 0 ? Utils::readInt(substr(md5($v, true), 0, 4)) : $v;
- }
- break;
- }
- $this->config->set($n, $v);
- }
- if($this->getProperty("hardcore") == 1 and $this->getProperty("difficulty") < 3){
- $this->setProperty("difficulty", 3);
- }
- }
-
- public function getProperty($name, $default = false){
- if(($v = arg($name)) !== false){ //Allow for command-line arguments
- switch(strtolower(trim($v))){
- case "on":
- case "true":
- case "yes":
- $v = true;
- break;
- case "off":
- case "false":
- case "no":
- $v = false;
- break;
- }
- switch($name){
- case "gamemode":
- case "max-players":
- case "server-port":
- case "debug":
- case "difficulty":
- case "time-per-second":
- $v = (int) $v;
- break;
- case "server-id":
- if($v !== false){
- $v = preg_match("/[^0-9\-]/", $v) > 0 ? Utils::readInt(substr(md5($v, true), 0, 4)) : $v;
- }
- break;
- }
- return $v;
- }
- return ($this->config->exists($name) ? $this->config->get($name) : $default);
- }
-
- public function setProperty($name, $value, $save = true){
- $this->config->set($name, $value);
- if($save == true){
- $this->writeProperties();
- }
- $this->loadProperties();
- }
-
- private function writeProperties(){
- $this->config->save();
- }
-
- private function loadProperties(){
- if(($memory = str_replace("B", "", strtoupper($this->getProperty("memory-limit")))) !== false){
- $value = ["M" => 1, "G" => 1024];
- $real = ((int) substr($memory, 0, -1)) * $value[substr($memory, -1)];
- if($real < 128){
- console("[WARNING] NostalgiaCore may not work right with less than 128MB of RAM", true, true, 0);
- }
- @ini_set("memory_limit", $memory);
- }else{
- $this->setProperty("memory-limit", "128M");
- }
-
- if($this->server instanceof PocketMinecraftServer){
- $this->server->setType($this->getProperty("server-type"));
- $this->server->maxClients = $this->getProperty("max-players");
- $this->server->description = $this->getProperty("description");
- $this->server->motd = $this->getProperty("motd");
- $this->server->gamemode = $this->getProperty("gamemode");
- $this->server->difficulty = $this->getProperty("difficulty");
- $this->server->whitelist = $this->getProperty("white-list");
- }
- }
-
- public function loadAPI($name, $class, $dir = false){
- if(isset($this->$name)){
- return false;
- }elseif(!class_exists($class)){
- $internal = false;
- if($dir === false){
- $internal = true;
- $dir = FILE_PATH . "src/API/";
- }
- $file = $dir . $class . ".php";
- if(!file_exists($file)){
- console("[ERROR] API " . $name . " [" . $class . "] in " . $dir . " doesn't exist", true, true, 0);
- return false;
- }
- require_once($file);
- }else{
- $internal = true;
- }
- $this->$name = new $class();
- $this->apiList[] = $this->$name;
- console("[" . ($internal === true ? "INTERNAL" : "DEBUG") . "] API \x1b[36m" . $name . "\x1b[0m [\x1b[30;1m" . $class . "\x1b[0m] loaded", true, true, ($internal === true ? 3 : 2));
- }
-
- public function init(){
- if(!(self::$serverRequest instanceof PocketMinecraftServer)){
- self::$serverRequest = $this->server;
- }
-
- if($this->getProperty("auto-save") === true){
- $this->server->schedule(18000, [$this, "autoSave"], [], true);
- }
- if(!defined("NO_THREADS") and $this->getProperty("enable-rcon") === true){
- $this->rcon = new RCON($this->getProperty("rcon.password", ""), $this->getProperty("rcon.port", $this->getProperty("server-port")), ($ip = $this->getProperty("server-ip")) != "" ? $ip : "0.0.0.0", $this->getProperty("rcon.threads", 1), $this->getProperty("rcon.clients-per-thread", 50));
- }
-
- if($this->getProperty("enable-query") === true){
- $this->query = new QueryHandler();
- }
- CraftingRecipes::init();
- $this->server->init();
- unregister_tick_function([$this->server, "tick"]);
- $this->console->__destruct();
- if($this->rcon instanceof RCON){
- $this->rcon->stop();
- }
- $this->__destruct();
- if($this->getProperty("upnp-forwarding") === true){
- console("[INFO] [UPnP] Removing port forward...");
- UPnP_RemovePortForward($this->getProperty("server-port"));
- }
- return $this->restart;
- }
-
- public function __destruct(){
- foreach($this->apiList as $i => $ob){
- if(method_exists($ob, "__destruct")){
- $ob->__destruct();
- unset($this->apiList[$i]);
- }
- }
- }
-
- /*-------------------------------------------------------------*/
-
- public function async(callable $callable, $params = [], $remove = false){
- $cnt = $this->asyncCnt++;
- $this->asyncCalls[$cnt] = new Async($callable, $params);
- return $remove === true ? $this->getAsync($cnt) : $cnt;
- }
-
- public function getAsync($id){
- if(!isset($this->asyncCalls[$id])){
- return false;
- }
- $ob = $this->asyncCalls[$id];
- unset($this->asyncCalls[$id]);
- return $ob;
- }
-
- public function autoSave(){
- console("[DEBUG] Saving....", true, true, 2);
- $this->server->api->level->saveAll();
- }
-
- public function asyncOperation($t, $d, $c = null){
- return $this->server->asyncOperation($t, $d, $c);
- }
-
- public function addHandler($e, $c, $p = 5){
- return $this->server->addHandler($e, $c, $p);
- }
-
- public function dhandle($e, $d){
- return $this->server->handle($e, $d);
- }
-
- public function handle($e, &$d){
- return $this->server->handle($e, $d);
- }
-
- public function schedule($t, $c, $d, $r = false, $e = "server.schedule"){
- return $this->server->schedule($t, $c, $d, $r, $e);
- }
-
- public function event($e, $d){
- return $this->server->event($e, $d);
- }
-
- public function trigger($e, $d){
- return $this->server->trigger($e, $d);
- }
-
- public function deleteEvent($id){
- return $this->server->deleteEvent($id);
- }
-
- public function getProperties(){
- return $this->config->getAll();
- }
-
- public function getList(){
- return $this->apiList;
- }
-
-}
diff --git a/src/API/TileAPI.php b/src/API/TileAPI.php
deleted file mode 100644
index 000b70a5..00000000
--- a/src/API/TileAPI.php
+++ /dev/null
@@ -1,99 +0,0 @@
-tiles = [];
- $this->server = ServerAPI::request();
- }
-
- public function get(Position $pos){
- $tile = $this->server->query("SELECT * FROM tiles WHERE level = '" . $pos->level->getName() . "' AND x = {$pos->x} AND y = {$pos->y} AND z = {$pos->z};", true);
- if($tile !== false and $tile !== true and ($tile = $this->getByID($tile["ID"])) !== false){
- return $tile;
- }
- return false;
- }
-
- public function getByID($id){
- if($id instanceof Tile){
- return $id;
- }elseif(isset($this->tiles[$id])){
- return $this->tiles[$id];
- }
- return false;
- }
-
- public function init(){
-
- }
-
- public function addSign(Level $level, $x, $y, $z, $lines = ["", "", "", ""]){
- return $this->add($level, TILE_SIGN, $x, $y, $z, $data = [
- "id" => "Sign",
- "x" => $x,
- "y" => $y,
- "z" => $z,
- "Text1" => $lines[0],
- "Text2" => $lines[1],
- "Text3" => $lines[2],
- "Text4" => $lines[3],
- ]);
- }
-
- public function add(Level $level, $class, $x, $y, $z, $data = []){
- $id = $this->tCnt++;
- $this->tiles[$id] = new Tile($level, $id, $class, $x, $y, $z, $data);
- $this->spawnToAll($this->tiles[$id]);
- return $this->tiles[$id];
- }
-
- public function spawnToAll(Tile $t){
- foreach($this->server->api->player->getAll($t->level) as $player){
- if($player->eid !== false){
- $t->spawn($player);
- }
- }
- }
-
- public function spawnAll(Player $player){
- foreach($this->getAll($player->level) as $t){
- $t->spawn($player);
- }
- }
-
- public function getAll($level = null){
- if($level instanceof Level){
- $tiles = [];
- $l = $this->server->query("SELECT ID FROM tiles WHERE level = '" . $level->getName() . "';");
- if($l !== false and $l !== true){
- while(($t = $l->fetchArray(SQLITE3_ASSOC)) !== false){
- $t = $this->getByID($t["ID"]);
- if($t instanceof Tile){
- $tiles[$t->id] = $t;
- }
- }
- }
- return $tiles;
- }
- return $this->tiles;
- }
-
- public function remove($id){
- if(isset($this->tiles[$id])){
- $t = $this->tiles[$id];
- $this->tiles[$id] = null;
- unset($this->tiles[$id]);
- $t->closed = true;
- $t->close();
- $this->server->query("DELETE FROM tiles WHERE ID = " . $id . ";");
- $this->server->api->dhandle("tile.remove", $t);
- $t = null;
- unset($t);
- }
- }
-}
\ No newline at end of file
diff --git a/src/API/TimeAPI.php b/src/API/TimeAPI.php
deleted file mode 100644
index 51924611..00000000
--- a/src/API/TimeAPI.php
+++ /dev/null
@@ -1,180 +0,0 @@
- 0,
- "sunset" => 9500,
- "night" => 10900,
- "sunrise" => 17800,
- ];
- private $server;
-
- function __construct(){
- $this->server = ServerAPI::request();
- }
-
- public function init(){
- $this->server->api->console->register("time", " [time]", [$this, "commandHandler"]);
- }
-
- public function commandHandler($cmd, $args, $issuer, $alias){
- $output = "";
- switch($cmd){
- case "time":
- $level = false;
- if($issuer instanceof Player){
- $level = $issuer->level;
- }else{
- $level = $this->server->api->level->getDefault();
- }
- $p = strtolower(array_shift($args));
- switch($p){
- case "check":
- if(substr($args[0] ?? "", 0, 2) === "w:"){
- $levelName = preg_replace("/w:/", "", $args[0]);
- $level = $this->server->api->level->get($levelName);
- if($level instanceof Level){
- $world = " in world \"$levelName\"";
- }else{
- $output .= "World \"$levelName\" doesn't exist or loaded!";
- break;
- }
- }else $world = " in world \"" . $level->getName() . "\"";
- $output .= "Time" . $world . ": " . $this->getDate($level) . ", " . $this->getPhase($level) . " (" . $this->get(true, $level) . " ticks)\n";
- break;
- case "add":
- if(substr($args[1] ?? "", 0, 2) === "w:"){
- $levelName = preg_replace("/w:/", "", $args[1]);
- $level = $this->server->api->level->get($levelName);
- if($level instanceof Level){
- $world = " to the time of world \"$levelName\"";
- }else{
- $output .= "World \"$levelName\" doesn't exist or loaded!";
- break;
- }
- }else $world = " to the time of world \"" . $level->getName() . "\"";
-
- $addTime = array_shift($args);
- if(!is_numeric($addTime)){
- $output .= "Time must be an integer!";
- break;
- }
- $addTime = (int) $addTime;
- $this->add($addTime, $level);
- $output .= "Added $addTime ticks" . $world . "\n";
- break;
- case "set":
- if(isset($args[1]) and substr($args[1], 0, 2) === "w:"){
- $levelName = preg_replace("/w:/", "", $args[1]);
- $level = $this->server->api->level->get($levelName);
- if($level instanceof Level){
- $world = " in world \"$levelName\"";
- }else{
- $output .= "World \"$levelName\" doesn't exist or loaded!";
- break;
- }
- }else $world = " in world \"" . $level->getName() . "\"";
-
- $setTime = array_shift($args);
- if(is_numeric($setTime)){
- $setTime = (int) $setTime;
- }elseif($setTime == 'sunrise' or $setTime == 'day' or $setTime == 'sunset' or $setTime == 'night')
- ;
- else{
- $output .= "Wrong time!";
- break;
- }
- $this->set($setTime, $level);
- $output .= "Set the time to " . $setTime . $world . "\n";
- break;
- case "sunrise":
- case "day":
- case "sunset":
- case "night":
- if(count($args) > 1 && substr($args[1], 0, 2) === "w:"){
- $levelName = preg_replace("/w:/", "", $args[1]);
- $level = $this->server->api->level->get($levelName);
- if($level instanceof Level){
- $world = " in world \"$levelName\"";
- }else{
- $output .= "World \"$levelName\" doesn't exist or loaded!";
- break;
- }
- }else $world = " in world \"" . $level->getName() . "\"";
-
- $this->set($p, $level);
- $output .= "Set the time to " . $p . $world . "\n";
- break;
- default:
- $output .= "Usage: /time [time] [w:world]\n";
- break;
- }
- break;
- }
- return $output;
- }
-
- public function getDate($time = false){
- $time = !is_integer($time) ? $this->get(false, $time) : $time;
- return str_pad(strval((floor($time / 800) + 6) % 24), 2, "0", STR_PAD_LEFT) . ":" . str_pad(strval(floor(($time % 800) / 13.33)), 2, "0", STR_PAD_LEFT);
- }
-
- public function get($raw = false, $level = false){
- if(!($level instanceof Level)){
- $level = $this->server->api->level->getDefault();
- }
- return $raw === true ? $level->getTime() : abs($level->getTime()) % 19200;
- }
-
- public function getPhase($time = false){
- $time = !is_integer($time) ? $this->get(false, $time) : $time;
- if($time < TimeAPI::$phases["sunset"]){
- $time = "day";
- }elseif($time < TimeAPI::$phases["night"]){
- $time = "sunset";
- }elseif($time < TimeAPI::$phases["sunrise"]){
- $time = "night";
- }else{
- $time = "sunrise";
- }
- return $time;
- }
-
- public function add($time, $level = false){
- if(!($level instanceof Level)){
- $level = $this->server->api->level->getDefault();
- }
- $level->setTime($level->getTime() + (int) $time);
- }
-
- public function set($time, $level = false){
- if(!($level instanceof Level)){
- $level = $this->server->api->level->getDefault();
- }
- if(is_string($time) and isset(TimeAPI::$phases[$time])){
- $level->setTime(TimeAPI::$phases[$time]);
- }else{
- $level->setTime((int) $time);
- }
- return $level->getTime();
- }
-
- public function night(){
- return $this->set("night");
- }
-
- public function day(){
- return $this->set("day");
- }
-
- public function sunrise(){
- return $this->set("sunrise");
- }
-
- public function sunset(){
- return $this->set("sunset");
- }
-
-
-}
diff --git a/src/BaseEvent.php b/src/BaseEvent.php
deleted file mode 100644
index 0244e7ce..00000000
--- a/src/BaseEvent.php
+++ /dev/null
@@ -1,116 +0,0 @@
- EventPriority::LOWEST){
- return false;
- }
- $identifier = Utils::getCallableIdentifier($handler);
- if(isset(static::$handlers[$identifier])){ //Already registered
- return false;
- }else{
- static::$handlers[$identifier] = $handler;
- if(!isset(static::$handlerPriority[(int) $priority])){
- static::$handlerPriority[(int) $priority] = [];
- krsort(static::$handlerPriority);
- }
- static::$handlerPriority[(int) $priority][$identifier] = $handler;
- return true;
- }
- }
-
- public static function unregister(callable $handler, $priority = EventPriority::NORMAL){
- $identifier = Utils::getCallableIdentifier($handler);
- if(isset(static::$handlers[$identifier])){
- if(isset(static::$handlerPriority[(int) $priority][$identifier])){
- unset(static::$handlerPriority[(int) $priority][$identifier]);
- }else{
- for($priority = EventPriority::MONITOR; $priority <= EventPriority::LOWEST; ++$priority){
- unset(static::$handlerPriority[$priority][$identifier]);
- if(count(static::$handlerPriority[$priority]) === 0){
- unset(static::$handlerPriority[$priority]);
- }
- }
- }
- unset(static::$handlers[$identifier]);
- return true;
- }else{
- return false;
- }
- }
-
- final public function getEventName(){
- return $this->eventName !== null ? get_class($this) : $this->eventName;
- }
-
- final public function getPrioritySlot(){
- return (int) $this->prioritySlot;
- }
-
- final public function setPrioritySlot($slot){
- $this->prioritySlot = (int) $slot;
- }
-
- public function isAllowed(){
- return ($this->status & 0x7FFFFFFF) === BaseEvent::ALLOW;
- }
-
- public function setAllowed($forceAllow = false){
- $this->status = BaseEvent::ALLOW | ($forceAllow === true ? BaseEvent::FORCE : 0);
- }
-
- public function isCancelled(){
- return ($this->status & 0x7FFFFFFF) === BaseEvent::DENY;
- }
-
- public function setCancelled($forceCancel = false){
- if($this instanceof CancellableEvent){
- $this->status = BaseEvent::DENY | ($forceCancel === true ? BaseEvent::FORCE : 0);
- }
- return false;
- }
-
- public function isNormal(){
- return $this->status === BaseEvent::NORMAL;
- }
-
- public function setNormal(){
- $this->status = BaseEvent::NORMAL;
- }
-
- public function isForced(){
- return ($this->status & BaseEvent::FORCE) > 0;
- }
-}
diff --git a/src/Deprecation.php b/src/Deprecation.php
deleted file mode 100644
index 7d8e66cd..00000000
--- a/src/Deprecation.php
+++ /dev/null
@@ -1,15 +0,0 @@
- "ServerAPI::schedule()",
- "server.time" => "time.change",
- "world.block.change" => "block.change",
- "block.drop" => "item.drop",
- "api.op.check" => "op.check",
- "api.player.offline.get" => "player.offline.get",
- "api.player.offline.save" => "player.offline.save",
- ];
-}
\ No newline at end of file
diff --git a/src/Player.php b/src/Player.php
deleted file mode 100755
index 88d7bd58..00000000
--- a/src/Player.php
+++ /dev/null
@@ -1,2391 +0,0 @@
-bigCnt = 0;
- $this->MTU = $MTU;
- $this->server = ServerAPI::request();
- $this->lastBreak = microtime(true);
- $this->clientID = $clientID;
- $this->CID = PocketMinecraftServer::clientID($ip, $port);
- $this->ip = $ip;
- $this->port = $port;
- $this->spawnPosition = $this->server->spawn;
- $this->timeout = microtime(true) + 20;
- $this->inventory = [];
- $this->armor = [];
- $this->gamemode = $this->server->gamemode;
- $this->level = $this->server->api->level->getDefault();
- $this->slot = 0;
- $this->hotbar = [0, -1, -1, -1, -1, -1, -1, -1, -1];
- $this->packetStats = [0, 0];
- $this->buffer = new RakNetPacket(RakNetInfo::DATA_PACKET_0);
- $this->buffer->data = [];
- $this->blockSendQueue = new RakNetPacket(RakNetInfo::DATA_PACKET_0);
- $this->blockSendQueue->data = [];
- $this->server->schedule(1, [$this, "handlePacketQueues"], [], true);
- $this->server->schedule(20 * 60, [$this, "clearQueue"], [], true);
- $this->evid[] = $this->server->event("server.close", [$this, "close"]);
- console("[DEBUG] New Session started with " . $ip . ":" . $port . ". MTU " . $this->MTU . ", Client ID " . $this->clientID, true, true, 2);
- }
-
- public function __get($name){
- if(isset($this->{$name})){
- return ($this->{$name});
- }
- return null;
- }
-
- public function getSpawn(){
- return $this->spawnPosition;
- }
-
- /**
- * @param Vector3 $pos
- *
- * @return boolean
- */
- public function sleepOn(Vector3 $pos){
- foreach($this->server->api->player->getAll($this->level) as $p){
- if($p->isSleeping instanceof Vector3){
- if($pos->distance($p->isSleeping) <= 0.1){
- return false;
- }
- }
- }
- $this->isSleeping = $pos;
- $this->teleport(new Position($pos->x + 0.5, $pos->y + 1, $pos->z + 0.5, $this->level), false, false, false, false);
- if($this->entity instanceof Entity){
- $this->entity->updateMetadata();
- }
- $this->setSpawn($pos);
-
- return true;
- }
-
- /**
- * @param Vector3 $pos
- * @param float|boolean $yaw
- * @param float|boolean $pitch
- * @param float|boolean $terrain
- * @param float|boolean $force
- *
- * @return boolean
- */
- public function teleport(Vector3 $pos, $yaw = false, $pitch = false, $terrain = true, $force = true){
- if($this->entity instanceof Entity and $this->level instanceof Level){
- $this->entity->check = false;
- if($yaw === false){
- $yaw = $this->entity->yaw;
- }
- if($pitch === false){
- $pitch = $this->entity->pitch;
- }
- if($this->server->api->dhandle("player.teleport", ["player" => $this, "target" => $pos]) === false){
- $this->entity->check = true;
- return false;
- }
-
- if($pos instanceof Position and $pos->level instanceof Level and $pos->level !== $this->level){
- if($this->server->api->dhandle("player.teleport.level", ["player" => $this, "origin" => $this->level, "target" => $pos->level]) === false){
- $this->entity->check = true;
- return false;
- }
-
- foreach($this->level->entityList as $e){
- if($e !== $this->entity){
- if($e->isPlayer()){
- $pk = new MoveEntityPacket;
- $pk->entities = [[$this->entity->eid, -256, 128, -256, 0, 0]];
- $e->player->dataPacket($pk);
- $pk->entities[0] = $e->eid;
- $this->dataPacket($pk);
- }else{
- $pk = new RemoveEntityPacket;
- $pk->eid = $e->eid;
- $this->dataPacket($pk);
- }
- }
- }
- $this->level->freeAllChunks($this);
- $this->level = $pos->level;
- $this->chunksLoaded = [];
- $this->server->api->entity->spawnToAll($this->entity);
- $this->server->api->entity->spawnAll($this);
-
- $pk = new SetTimePacket;
- $pk->time = $this->level->getTime();
- $this->dataPacket($pk);
- $terrain = true;
- foreach($this->level->players as $player){
- if($player !== $this and $player->entity instanceof Entity){
- $pk = new MovePlayerPacket();
- $pk->entities = [[$player->entity->eid, $player->entity->x, $player->entity->y, $player->entity->z, $player->entity->yaw, $player->entity->pitch]];
- $this->dataPacket($pk);
-
- $pk = new PlayerEquipmentPacket;
- $pk->eid = $this->eid;
- $pk->item = $this->getSlot($this->slot)->getID();
- $pk->meta = $this->getSlot($this->slot)->getMetadata();
- $pk->slot = 0;
- $player->dataPacket($pk);
- $this->sendArmor($player);
-
- $pk = new PlayerEquipmentPacket;
- $pk->eid = $player->eid;
- $pk->item = $player->getSlot($player->slot)->getID();
- $pk->meta = $player->getSlot($player->slot)->getMetadata();
- $pk->slot = 0;
- $this->dataPacket($pk);
- $player->sendArmor($this);
- }
- }
- }
-
- $this->lastCorrect = $pos;
- $this->entity->fallY = false;
- $this->entity->fallStart = false;
- //if($terrain === true){
-
- //$this->getNextChunk($this->level);
- //}*/
- $this->entity->check = true;
- if($force === true){
- $this->forceMovement = $pos;
- }
- }
- if($this->spawned){
- $this->entity->setPosition($pos, $yaw, $pitch);
- $this->entity->resetSpeed();
- $this->entity->updateLast();
- $this->entity->calculateVelocity();
- }
-
- $this->orderChunks(true);
- $this->getNextChunk($this->level);
- $pk = new MovePlayerPacket;
- $pk->eid = 0;
- $pk->x = $pos->x;
- $pk->y = $pos->y + 1.62;
- $pk->z = $pos->z;
- $pk->bodyYaw = $yaw;
- $pk->pitch = $pitch;
- $pk->yaw = $yaw;
- $pk->teleport = true;
- $this->dataPacket($pk);
- }
- public function addToBlockSendQueue(RakNetDataPacket $packet){
- if($this->connected === false) return false;
-
- $packet->encode();
- $len = strlen($packet->buffer) + 1;
- $MTU = $this->MTU - 24;
-
-
- if(($this->blockSendQueueLength + $len) >= $MTU){
- $this->sendBlockUpdateQueue();
- }
-
- $packet->messageIndex = $this->counter[3]++;
- $packet->reliability = 2;
- @$this->blockSendQueue->data[] = $packet;
- $this->blockSendQueueLength += 6 + $len;
- }
- /**
- * @param integer $id
- * @param array $data
- *
- * @return array|bool
- */
- public function dataPacket(RakNetDataPacket $packet){
- if($this->connected === false){
- return false;
- }
-
- if(EventHandler::callEvent(new DataPacketSendEvent($this, $packet)) === BaseEvent::DENY){
- return;
- }
-
- $packet->encode();
- $len = strlen($packet->buffer) + 1;
- $MTU = $this->MTU - 24;
- if($len > $MTU){
- return $this->directBigRawPacket($packet);
- }
-
- if(($this->bufferLen + $len) >= $MTU){
- $this->sendBuffer();
- }
-
- $packet->messageIndex = $this->counter[3]++;
- $packet->reliability = 2;
- @$this->buffer->data[] = $packet;
- $this->bufferLen += 6 + $len;
- return [];
- }
-
- private function directBigRawPacket(RakNetDataPacket $packet){
- if($this->connected === false){
- return false;
- }
-
- $sendtime = microtime(true);
-
- $size = $this->MTU - 34;
- $buffer = str_split($packet->buffer, $size);
- $bigCnt = $this->bigCnt;
- $this->bigCnt = ($this->bigCnt + 1) % 0x10000;
- $cnts = [];
- $bufCount = count($buffer);
- foreach($buffer as $i => $buf){
- $cnts[] = $count = $this->counter[0]++;
-
- $pk = new UnknownPacket;
- $pk->packetID = $packet->pid();
- $pk->reliability = 2;
- $pk->hasSplit = true;
- $pk->splitCount = $bufCount;
- $pk->splitID = $bigCnt;
- $pk->splitIndex = $i;
- $pk->buffer = $buf;
- $pk->messageIndex = $this->counter[3]++;
-
- $rk = new RakNetPacket(RakNetInfo::DATA_PACKET_0);
- $rk->data[] = $pk;
- $rk->seqNumber = $count;
- $rk->sendtime = $sendtime;
- $this->recoveryQueue[$count] = $rk;
- $this->send($rk);
- }
- return $cnts;
- }
-
- public function send(RakNetPacket $packet){
- if($this->connected === true){
- $packet->ip = $this->ip;
- $packet->port = $this->port;
- $this->bandwidthRaw += $this->server->send($packet);
- }
- }
-
-
- public function sendBlockUpdateQueue(){
- if($this->blockSendQueueLength > 0 and $this->blockSendQueue instanceof RakNetPacket){
- $this->blockSendQueue->seqNumber = $this->counter[0]++;
- $this->send($this->blockSendQueue);
- }
- $this->blockSendQueueLength = 0;
- $this->blockSendQueue = new RakNetPacket(RakNetInfo::DATA_PACKET_0);
- $this->blockSendQueue->data = [];
- }
- public function sendBuffer(){
- if($this->bufferLen > 0 and $this->buffer instanceof RakNetPacket){
- $this->buffer->seqNumber = $this->counter[0]++;
- $this->send($this->buffer);
- }
- $this->bufferLen = 0;
- $this->buffer = new RakNetPacket(RakNetInfo::DATA_PACKET_0);
- $this->buffer->data = [];
- $this->nextBuffer = microtime(true) + 0.05;
- }
-
- /**
- * @param integer $slot
- *
- * @return Item
- */
- public function getSlot($slot){
- if(isset($this->inventory[(int) $slot])){
- return $this->inventory[(int) $slot];
- }else{
- return BlockAPI::getItem(AIR, 0, 0);
- }
- }
-
- /**
- * @param integer $slot
- * @param Item $item
- * @param boolean $send
- *
- * @return boolean
- */
- public function setSlot($slot, Item $item, $send = true){
- $this->inventory[(int) $slot] = $item;
- if($send === true){
- $this->sendInventorySlot((int) $slot);
- }
- return true;
- }
-
- /**
- * @param Player|string|boolean|void $player
- */
- public function sendArmor($player = false){
- $data = [
- "player" => $this,
- "eid" => $this->eid,
- "slots" => []
- ];
- for($i = 0; $i < 4; ++$i){
- if(isset($this->armor[$i]) and ($this->armor[$i] instanceof Item) and $this->armor[$i]->getID() > AIR){
- $data["slots"][$i] = $this->armor[$i]->getID() !== AIR ? $this->armor[$i]->getID() - 256 : 0;
- }else{
- $this->armor[$i] = BlockAPI::getItem(AIR, 0, 0);
- $data["slots"][$i] = 255;
- }
- }
- if($player instanceof Player){
- if($player === $this){
- $pk = new ContainerSetContentPacket;
- $pk->windowid = 0x78; //Armor window id
- $pk->slots = $this->armor;
- $this->dataPacket($pk);
- }else{
- $pk = new PlayerArmorEquipmentPacket;
- $pk->eid = $this->eid;
- $pk->slots = $data["slots"];
- $player->dataPacket($pk);
- }
- }else{
- $this->server->api->dhandle("player.armor", $data);
- }
- }
- public function stopUsingChunk($X, $Z){
- $ind = "$X:$Z";
- if(isset($this->chunksLoaded[$ind])) unset($this->chunksLoaded[$ind]);
- if(isset($this->chunksOrder[$ind])) unset($this->chunksOrder[$ind]);
-
- $this->dataPacket(new UnloadChunkPacket($X, $Z));
- }
- public function orderChunks($force = false){
- if(!($this->entity instanceof Entity) or $this->connected === false){
- return false;
- }
- $X = ((int)$this->entity->x) >> 4;
- $Z = ((int)$this->entity->z) >> 4;
-
- if($force === false && $X == $this->prevChunkX && $Z == $this->prevChunkZ){
- return; //doesnt need reorder
- }
- $this->prevChunkX = $X;
- $this->prevChunkZ = $Z;
- $this->chunksOrder = [];
-
- $startX = $this->level->generatorType === 1 ? $X - PocketMinecraftServer::$chunkLoadingRadius : 0;
- $stopX = $this->level->generatorType === 1 ? $X + PocketMinecraftServer::$chunkLoadingRadius : 15;
- $startZ = $this->level->generatorType === 1 ? $Z - PocketMinecraftServer::$chunkLoadingRadius : 0;
- $stopZ = $this->level->generatorType === 1 ? $Z + PocketMinecraftServer::$chunkLoadingRadius : 15;
- for($x = $startX; $x <= $stopX; ++$x){
- for($z = $startZ; $z <= $stopZ; ++$z){
- $d = $x . ":" . $z;
- if(!isset($this->chunksLoaded[$d])){
- $this->chunksOrder[$d] = abs($x - $X) + abs($z - $Z);
- }
- }
- }
- asort($this->chunksOrder);
-
- $this->reload = true;
-
- }
-
- public function loadAllChunks(){
- for($x = 0; $x < 16; $x++){
- for($z = 0; $z < 16; $z++){
- $this->useChunk($x, $z);
- }
- }
- }
-
- public function useChunk($X, $Z){
- $Yndex = 0;
- for($iY = 0; $iY < 8; ++$iY){
- if(isset($this->chunksOrder["$X:$Z"])){
- unset($this->chunksOrder["$X:$Z"]);
- $this->chunksLoaded["$X:$Z"] = true;
- $Yndex |= 1 << $iY;
- }
- }
-
- /*$tiles = $this->server->query("SELECT ID FROM tiles WHERE spawnable = 1 AND level = '" . $this->level->getName() . "' AND x >= " . (($X << 4) - 1) . " AND x < " . (($X << 4) + 17) . " AND z >= " . (($Z << 4) - 1) . " AND z < " . (($Z << 4) + 17) . ";");
- $this->lastChunk = false;
- if($tiles !== false and $tiles !== true){
- while(($tile = $tiles->fetchArray(SQLITE3_ASSOC)) !== false){
- $tile = $this->server->api->tile->getByID($tile["ID"]);
- if($tile instanceof Tile){
- $tile->spawn($this);
- }
- }
- }*/
- //$this->stopUsingChunk($X, $Z); //just in case
- $pk = new FullChunkDataPacket;
- $pk->chunkX = $X;
- $pk->chunkZ = $Z;
- $pk->data = $this->level->getOrderedFullChunk($X, $Z);
- $cnt = $this->dataPacket($pk);
- if($cnt === false){
- return false;
- }
- }
- public $chunkTicker = 0;
- public function entityTick(){
- //ConsoleAPI::debug("{$this->username}, cl: ".count($this->chunksLoaded).", oc: ".count($this->chunksOrder));
- if(count($this->chunksOrder) <= 0 && $this->level->generatorType != 0){
- $this->orderChunks();
- }
-
- if($this->isSleeping) ++$this->sleepingTime;
- if($this->chunkTicker++ > PocketMinecraftServer::$chukSendDelay){
- $this->getNextChunk($this->level);
- $this->chunkTicker = 0;
- }
- }
-
- public function getNextChunk($world){
- if($this->connected === false or $world != $this->level){
- return false;
- }
-
- foreach($this->chunkCount as $count => $t){
- if(isset($this->recoveryQueue[$count]) or isset($this->resendQueue[$count])){
- return;
- }else{
- unset($this->chunkCount[$count]);
- }
- }
-
- $c = key($this->chunksOrder);
- $d = $c != null ? $this->chunksOrder[$c] : null;
- if($c === null or $d === null){
- return false;
- }
-
- unset($this->chunksOrder[$c]);
- $this->chunksLoaded[$c] = true;
- $id = explode(":", $c);
- $X = $id[0];
- $Z = $id[1];
- $x = $X << 4;
- $z = $Z << 4;
- $this->level->useChunk($X, $Z, $this);
- $this->chunksLoaded["$X:$Z"] = true;
-
- $pk = new FullChunkDataPacket;
- $pk->chunkX = $X;
- $pk->chunkZ = $Z;
- $pk->data = $this->level->getOrderedFullChunk($X, $Z);
- $cnt = $this->dataPacket($pk);
- $this->chunkCount = [];
- foreach($cnt as $i => $count){
- $this->chunkCount[$count] = true;
- }
-
- $this->lastChunk = [$x, $z];
- }
-
- /**
- * @param Vector3 $pos
- */
- public function setSpawn(Vector3 $pos){
- if(!($pos instanceof Position)){
- $level = $this->level;
- }else{
- $level = $pos->level;
- }
- $this->spawnPosition = new Position($pos->x, $pos->y, $pos->z, $level);
- $pk = new SetSpawnPositionPacket;
- $pk->x = (int) $this->spawnPosition->x;
- $pk->y = (int) $this->spawnPosition->y;
- $pk->z = (int) $this->spawnPosition->z;
- $this->dataPacket($pk);
- }
-
- public function sendInventorySlot($s){
- $this->sendInventory();
- return;
- $s = (int) $s;
- if(!isset($this->inventory[$s])){
- $pk = new ContainerSetSlotPacket;
- $pk->windowid = 0;
- $pk->slot = (int) $s;
- $pk->item = BlockAPI::getItem(AIR, 0, 0);
- $this->dataPacket($pk);
- }
-
- $slot = $this->inventory[$s];
- $pk = new ContainerSetSlotPacket;
- $pk->windowid = 0;
- $pk->slot = (int) $s;
- $pk->item = $slot;
- $this->dataPacket($pk);
- return true;
- }
-
- public function sendInventory(){
- if(($this->gamemode & 0x01) === CREATIVE){
- return;
- }
- $hotbar = [];
- foreach($this->hotbar as $slot){
- $hotbar[] = $slot <= -1 ? -1 : $slot + 9;
- }
-
- $pk = new ContainerSetContentPacket;
- $pk->windowid = 0;
- $pk->slots = $this->inventory;
- $pk->hotbar = $hotbar;
- $this->dataPacket($pk);
- }
-
- /**
- * @param $type
- * @param $damage
- * @param $count
- *
- * @return boolean
- */
- public function hasSpace($type, $damage, $count){
- $inv = $this->inventory;
- while($count > 0){
- $add = 0;
- foreach($inv as $s => $item){
- if($item->getID() === AIR){
- $add = min($item->getMaxStackSize(), $count);
- $inv[$s] = BlockAPI::getItem($type, $damage, $add);
- break;
- }elseif($item->getID() === $type and $item->getMetadata() === $damage){
- $add = min($item->getMaxStackSize() - $item->count, $count);
- if($add <= 0){
- continue;
- }
- $inv[$s] = BlockAPI::getItem($type, $damage, $item->count + $add);
- break;
- }
- }
- if($add <= 0){
- return false;
- }
- $count -= $add;
- }
- return true;
- }
-
- /**
- * @param integer $slot
- *
- * @return Item
- */
- public function getArmor($slot){
- if(isset($this->armor[(int) $slot])){
- return $this->armor[(int) $slot];
- }else{
- return BlockAPI::getItem(AIR, 0, 0);
- }
- }
-
- public function setArmor($slot, Item $armor, $send = true){
- $this->armor[(int) $slot] = $armor;
- if($send === true){
- $this->sendArmor($this);
- }
- return true;
- }
-
- /**
- * @param mixed $data
- * @param string $event
- */
- public function eventHandler($data, $event){
- switch($event){
- case "entity.link":
- $pk = new SetEntityLinkPacket();
- if($data["rider"] === $this->eid){
- $pk->rider = 0;
- }else{
- $pk->rider = $data["rider"];
- }
- $pk->riding = $data["riding"];
- $pk->type = 0; //TODO;
- $this->dataPacket($pk);
- break;
- case "tile.update":
- if($data->level === $this->level){
- if($data->class === TILE_FURNACE){
- foreach($this->windows as $id => $w){
- if($w === $data){
- $pk = new ContainerSetDataPacket;
- $pk->windowid = $id;
- $pk->property = 0; //Smelting
- $pk->value = floor($data->data["CookTime"]);
- $this->dataPacket($pk);
-
- $pk = new ContainerSetDataPacket;
- $pk->windowid = $id;
- $pk->property = 1; //Fire icon
- $pk->value = $data->data["BurnTicks"];
- $this->dataPacket($pk);
- }
- }
- }
- }
- break;
- case "tile.container.slot":
- if($data["tile"]->level === $this->level){
- foreach($this->windows as $id => $w){
- if($w === $data["tile"]){
- $pk = new ContainerSetSlotPacket;
- $pk->windowid = $id;
- $pk->slot = $data["slot"] + (isset($data["offset"]) ? $data["offset"] : 0);
- $pk->item = $data["slotdata"];
- $this->dataPacket($pk);
- }
- }
- }
- break;
- case "player.armor":
- if($data["player"]->level === $this->level){
- if($data["eid"] === $this->eid){
- $this->sendArmor($this);
- break;
- }
- $pk = new PlayerArmorEquipmentPacket;
- $pk->eid = $data["eid"];
- $pk->slots = $data["slots"];
- $this->dataPacket($pk);
- }
- break;
- case "player.pickup":
- if($data["eid"] === $this->eid){
- $data["eid"] = 0;
- $pk = new TakeItemEntityPacket;
- $pk->eid = 0;
- $pk->target = $data["entity"]->eid;
- $this->dataPacket($pk);
- if(($this->gamemode & 0x01) === 0x00){
- $this->addItem($data["entity"]->type, $data["entity"]->meta, $data["entity"]->stack, false);
- }
- switch($data["entity"]->type){
- case WOOD:
- AchievementAPI::grantAchievement($this, "mineWood");
- break;
- case DIAMOND:
- AchievementAPI::grantAchievement($this, "diamond");
- break;
- case LEATHER:
- AchievementAPI::grantAchievement($this, "leather");
- break;
- }
- }elseif($data["entity"]->level === $this->level){
- $pk = new TakeItemEntityPacket;
- $pk->eid = $data["eid"];
- $pk->target = $data["entity"]->eid;
- $this->dataPacket($pk);
- }
- break;
- case "player.equipment.change":
- if($data["eid"] === $this->eid or $data["player"]->level !== $this->level){
- break;
- }
- $data["slot"] = 0;
-
- $pk = new PlayerEquipmentPacket;
- $pk->eid = $data["eid"];
- $pk->item = $data["item"]->getID();
- $pk->meta = $data["item"]->getMetadata();
- $pk->slot = $data["slot"];
- $this->dataPacket($pk);
-
- break;
- case "entity.motion":
- if($data->eid === $this->eid or $data->level !== $this->level){
- break;
- }
- if(($data->speedX === 0 && $data->speedY === 0 && $data->speedZ === 0) || ($data->speedX === $data->lastSpeedX && $data->speedY === $data->lastSpeedY && $data->lastSpeedZ === $data->speedZ)){ //causer of packet flood is eliminated.
- break;
- }
- $pk = new SetEntityMotionPacket; //TODO one packet for all entities if possible
- $pk->entities = [[$data->eid, $data->speedX, $data->speedY, $data->speedZ]];
- $this->dataPacket($pk);
- break;
- case "entity.animate":
-
- $pk = new AnimatePacket;
- $pk->eid = $data["eid"];
- $pk->action = $data["action"]; //1 swing arm,
- $this->dataPacket($pk);
- break;
- case "entity.metadata":
- if($data->eid === $this->eid){
- $eid = 0;
- }else{
- $eid = $data->eid;
- }
- if($data->level === $this->level){
- $pk = new SetEntityDataPacket;
- $pk->eid = $eid;
- $pk->metadata = $data->getMetadata();
- $this->dataPacket($pk);
- }
- break;
- case "entity.event":
- if($data["entity"]->eid === $this->eid){
- $eid = 0;
- }else{
- $eid = $data["entity"]->eid;
- }
- if($data["entity"]->level === $this->level){
- $pk = new EntityEventPacket;
- $pk->eid = $eid;
- $pk->event = $data["event"];
- $this->dataPacket($pk);
- }
- break;
- case "server.chat":
- if(($data instanceof Container) === true){
- if(!$data->check($this->username) and !$data->check($this->iusername)){
- return;
- }else{
- $message = $data->get();
- $this->sendChat(preg_replace('/\x1b\[[0-9;]*m/', "", $message["message"]), $message["player"]); //Remove ANSI codes from chat
- }
- }else{
- $message = (string) $data;
- $this->sendChat(preg_replace('/\x1b\[[0-9;]*m/', "", (string) $data)); //Remove ANSI codes from chat
- }
- break;
- }
- }
-
- /**
- * @param $type
- * @param $damage
- * @param integer $count
- * @param boolean $send
- *
- * @return boolean
- */
- public function addItem($type, $damage, $count, $send = true){
- while($count > 0){
- $add = 0;
- foreach($this->inventory as $s => $item){
- if($item->getID() === AIR){
- $add = min($item->getMaxStackSize(), $count);
- $this->inventory[$s] = BlockAPI::getItem($type, $damage, $add);
- if($send === true){
- $this->sendInventorySlot($s);
- }
- break;
- }elseif($item->getID() === $type and $item->getMetadata() === $damage){
- $add = min($item->getMaxStackSize() - $item->count, $count);
- if($add <= 0){
- continue;
- }
- $item->count += $add;
- if($send === true){
- $this->sendInventorySlot($s);
- }
- break;
- }
- }
- if($add <= 0){
- return false;
- }
- $count -= $add;
- }
- return true;
- }
-
- /**
- * @param string $message
- * @param string $author
- */
- public function sendChat($message, $author = ""){
- $mes = explode("\n", $message);
- foreach($mes as $m){
- if(preg_match_all('#@([@A-Za-z_]{1,})#', $m, $matches, PREG_OFFSET_CAPTURE) > 0){
- $offsetshift = 0;
- foreach($matches[1] as $selector){
- if($selector[0][0] === "@"){ //Escape!
- $m = substr_replace($m, $selector[0], $selector[1] + $offsetshift - 1, strlen($selector[0]) + 1);
- --$offsetshift;
- continue;
- }
- switch(strtolower($selector[0])){
- case "player":
- case "username":
- $m = substr_replace($m, $this->username, $selector[1] + $offsetshift - 1, strlen($selector[0]) + 1);
- $offsetshift += strlen($selector[0]) - strlen($this->username) + 1;
- break;
- }
- }
- }
-
- if($m !== ""){
- $pk = new MessagePacket;
- $pk->source = ($author instanceof Player) ? $author->username : $author;
- $pk->message = TextFormat::clean($m); //Colors not implemented :(
- $this->dataPacket($pk);
- }
- }
- }
- public function makeInvisibleForOnePlayer(Player $player){
- $pk = new RemoveEntityPacket;
- $pk->eid = $this->entity->eid;
- $player->dataPacket($pk);
- }
- public function makeInvisibleForAllPlayers(){
- $pk = new RemoveEntityPacket;
- $pk->eid = $this->entity->eid;
- $this->server->api->player->broadcastPacket($this->server->api->player->getAll($this->level), $pk);
- }
- public function getGamemode(){
- switch($this->gamemode){
- case SURVIVAL:
- return "survival";
- case CREATIVE:
- return "creative";
- case ADVENTURE:
- return "adventure";
- case VIEW:
- return "view";
- }
- }
-
- public function setGamemode($gm){
- if($gm < 0 or $gm > 3 or $this->gamemode === $gm){
- return false;
- }
-
- if($this->server->api->dhandle("player.gamemode.change", ["player" => $this, "gamemode" => $gm]) === false){
- return false;
- }
-
- $inv =& $this->inventory;
- if($gm === VIEW){
- $this->armor = [];
- $this->sendArmor();
- }
- if(($this->gamemode & 0x01) === ($gm & 0x01)){
- if(($gm & 0x01) === 0x01 and ($gm & 0x02) === 0x02){
- $inv = [];
- foreach(BlockAPI::$creative as $item){
- $inv[] = BlockAPI::getItem(0, 0, 1);
- }
- }elseif(($gm & 0x01) === 0x01){
- $inv = [];
- foreach(BlockAPI::$creative as $item){
- $inv[] = BlockAPI::getItem($item[0], $item[1], 1);
- }
- }
- $this->gamemode = $gm;
- $this->sendChat("Your gamemode has been changed to " . $this->getGamemode() . ".\n");
- }else{
- foreach($this->inventory as $slot => $item){
- $inv[$slot] = BlockAPI::getItem(AIR, 0, 0);
- }
- $this->blocked = true;
- $this->gamemode = $gm;
- $this->sendChat("Your gamemode has been changed to " . $this->getGamemode() . ", you've to do a forced reconnect.\n");
- $this->server->schedule(30, [$this, "close"], "gamemode change", false, true); //Forces a kick
- }
-
- if($this->gamemode === SPECTATOR){
- $this->makeInvisibleForAllPlayers();
- }
- if($this->gamemode === CREATIVE){
- $this->server->api->player->spawnToAllPlayers($this);
- }
-
- $this->inventory = $inv;
- $this->sendSettings();
- $this->sendInventory();
- return true;
- }
-
- public function sendSettings($nametags = true){
- /*
- bit mask | flag name
- 0x00000001 world_inmutable
- 0x00000010 -
- 0x00000100 -
- 0x00001000 - (autojump)
- 0x00010000 -
- 0x00100000 - (nametags_visible)
- 0x01000000 ?
- 0x10000000 ?
- */
- $flags = 0;
- if(($this->gamemode & 0x02) === 0x02){
- $flags |= 0x01; //Do not allow placing/breaking blocks, adventure mode
- }
-
- if($nametags !== false){
- $flags |= 0x20; //Show Nametags
- }
- $pk = new AdventureSettingsPacket;
- $pk->flags = $flags;
- $this->dataPacket($pk);
- }
-
- public function measureLag(){
- if($this->connected === false){
- return false;
- }
- if($this->packetStats[1] > 2){
- $this->packetLoss = $this->packetStats[1] / max(1, $this->packetStats[0] + $this->packetStats[1]);
- }else{
- $this->packetLoss = 0;
- }
- $this->packetStats = [0, 0];
- array_shift($this->bandwidthStats);
- $this->bandwidthStats[] = $this->bandwidthRaw / max(0.00001, microtime(true) - $this->lastMeasure);
- $this->bandwidthRaw = 0;
- $this->lagStat = array_sum($this->lag) / max(1, count($this->lag));
- $this->lag = [];
- $this->sendBuffer();
- $this->lastMeasure = microtime(true);
- }
-
- public function getLag(){
- return $this->lagStat * 1000;
- }
-
- public function getPacketLoss(){
- return $this->packetLoss;
- }
-
- public function getBandwidth(){
- return array_sum($this->bandwidthStats) / max(1, count($this->bandwidthStats));
- }
-
- public function clearQueue(){
- if($this->connected === false){
- return false;
- }
- ksort($this->received);
- if(($cnt = count($this->received)) > PLAYER_MAX_QUEUE){
- foreach($this->received as $c => $t){
- unset($this->received[$c]);
- --$cnt;
- if($cnt <= PLAYER_MAX_QUEUE){
- break;
- }
- }
- }
- }
-
- public function handlePacketQueues(){
- if($this->connected === false){
- return false;
- }
- $time = microtime(true);
- if($time > $this->timeout){
- $this->close("timeout");
- return false;
- }
-
- if(($ackCnt = count($this->ackQueue)) > 0){
- rsort($this->ackQueue);
- $safeCount = (int) (($this->MTU - 1) / 4);
- $packetCnt = (int) ($ackCnt / $safeCount + 1);
- for($p = 0; $p < $packetCnt; ++$p){
- $pk = new RakNetPacket(RakNetInfo::ACK);
- $pk->packets = [];
- for($c = 0; $c < $safeCount; ++$c){
- if(($k = array_pop($this->ackQueue)) === null){
- break;
- }
- $pk->packets[] = $k;
- }
- $this->send($pk);
- }
- $this->ackQueue = [];
- }
-
- if(($receiveCnt = count($this->receiveQueue)) > 0){
- ksort($this->receiveQueue);
- foreach($this->receiveQueue as $count => $packets){
- unset($this->receiveQueue[$count]);
- foreach($packets as $p){
- if($p instanceof RakNetDataPacket and $p->hasSplit === false){
- if(isset($p->messageIndex) and $p->messageIndex !== false){
- if($p->messageIndex > $this->receiveCount){
- $this->receiveCount = $p->messageIndex;
- }elseif($p->messageIndex !== 0){
- if(isset($this->received[$p->messageIndex])){
- continue;
- }
- }
- $this->received[$p->messageIndex] = true;
- }
- $p->decode();
- $this->handleDataPacket($p);
- }
- }
- }
- }
-
- if($this->nextBuffer <= $time and $this->bufferLen > 0){
- $this->sendBuffer();
- }
-
- $limit = $time - 5; //max lag
- foreach($this->recoveryQueue as $count => $data){
- if($data->sendtime > $limit){
- break;
- }
- unset($this->recoveryQueue[$count]);
- $this->resendQueue[$count] = $data;
- }
-
- if(($resendCnt = count($this->resendQueue)) > 0){
- foreach($this->resendQueue as $count => $data){
- unset($this->resendQueue[$count]);
- $this->packetStats[1]++;
- $this->lag[] = microtime(true) - $data->sendtime;
- $data->sendtime = microtime(true);
- $cnt = $this->send($data);
- if(isset($this->chunkCount[$count])){
- unset($this->chunkCount[$count]);
- if(!is_null($cnt) and !is_null($cnt[0]))
- $this->chunkCount[$cnt[0]] = true;
- }
- }
- }
- }
-
- /**
- * @param string $reason Reason for closing connection
- * @param boolean $msg Set to false to silently disconnect player. No broadcast.
- */
- public function close($reason = "", $msg = true){
- if($this->connected === true){
- foreach($this->evid as $ev){
- $this->server->deleteEvent($ev);
- }
- if($this->username != ""){
- $this->server->api->handle("player.quit", $this);
- $this->save();
- }
- $reason = $reason == "" ? "server stop" : $reason;
- $this->sendChat("You have been kicked. Reason: " . $reason . "\n");
- $this->sendBuffer();
- $this->directDataPacket(new DisconnectPacket);
- $this->connected = false;
- $this->level->freeAllChunks($this);
- $this->loggedIn = false;
- $this->buffer = null;
- unset($this->buffer);
- $this->recoveryQueue = [];
- $this->receiveQueue = [];
- $this->resendQueue = [];
- $this->ackQueue = [];
- $this->server->api->player->remove($this->CID);
- if($msg === true and $this->username != "" and $this->spawned !== false){
- $this->server->api->chat->broadcast($this->username . " left the game: " . $reason);
- }
- $this->spawned = false;
- console("[INFO] " . FORMAT_AQUA . $this->username . FORMAT_RESET . "[/" . $this->ip . ":" . $this->port . "] logged out due to " . $reason);
- $this->windows = [];
- $this->armor = [];
- $this->inventory = [];
- $this->chunksLoaded = [];
- $this->chunksOrder = [];
- $this->chunkCount = [];
- $this->cratingItems = [];
- $this->received = [];
- }
- }
-
- public function save(){
- if($this->entity instanceof Entity){
- $this->data->set("achievements", $this->achievements);
- $this->data->set("position", [
- "level" => $this->entity->level->getName(),
- "x" => (float) $this->entity->x,
- "y" => (float) $this->entity->y,
- "z" => (float) $this->entity->z,
- "yaw" => (float) $this->entity->yaw,
- "pitch" => (float) $this->entity->pitch
- ]);
- $this->data->set("spawn", [
- "level" => $this->spawnPosition->level->getName(),
- "x" => $this->spawnPosition->x,
- "y" => $this->spawnPosition->y,
- "z" => $this->spawnPosition->z
- ]);
- $inv = [];
- foreach($this->inventory as $slot => $item){
- if($item instanceof Item){
- if($slot < (($this->gamemode & 0x01) === 0 ? PLAYER_SURVIVAL_SLOTS : PLAYER_CREATIVE_SLOTS)){
- $inv[$slot] = [$item->getID(), $item->getMetadata(), $item->count];
- }
- }
- }
- $this->data->set("inventory", $inv);
- $this->data->set("hotbar", $this->hotbar);
-
- $armor = [];
- foreach($this->armor as $slot => $item){
- if($item instanceof Item){
- $armor[$slot] = [$item->getID(), $item->getMetadata()];
- }
- }
- $this->data->set("armor", $armor);
- if($this->entity instanceof Entity){
- $this->data->set("health", $this->entity->getHealth());
- }
- $this->data->set("gamemode", $this->gamemode);
- }
- }
-
- public function directDataPacket(RakNetDataPacket $packet, $reliability = 0, $recover = true){
- if($this->connected === false){
- return false;
- }
-
- if(EventHandler::callEvent(new DataPacketSendEvent($this, $packet)) === BaseEvent::DENY){
- return [];
- }
-
- $packet->encode();
- $pk = new RakNetPacket(RakNetInfo::DATA_PACKET_0);
- $pk->data[] = $packet;
- $pk->seqNumber = $this->counter[0]++;
- $pk->sendtime = microtime(true);
- if($recover !== false){
- $this->recoveryQueue[$pk->seqNumber] = $pk;
- }
-
- $this->send($pk);
- return [$pk->seqNumber];
- }
-
- public function handleDataPacket(RakNetDataPacket $packet){
- if($this->connected === false){
- return;
- }
-
- if(EventHandler::callEvent(new DataPacketReceiveEvent($this, $packet)) === BaseEvent::DENY){
- return;
- }
- switch($packet->pid()){
- case 0x01:
- break;
- case ProtocolInfo::PONG_PACKET:
- break;
- case ProtocolInfo::PING_PACKET:
- $pk = new PongPacket;
- $pk->ptime = $packet->time;
- $pk->time = abs(microtime(true) * 1000);
- $this->directDataPacket($pk);
- break;
- case ProtocolInfo::DISCONNECT_PACKET:
- $this->close("client disconnect");
- break;
- case ProtocolInfo::CLIENT_CONNECT_PACKET:
- if($this->loggedIn === true){
- break;
- }
- $pk = new ServerHandshakePacket;
- $pk->port = $this->port;
- $pk->session = $packet->session;
- $pk->session2 = Utils::readLong("\x00\x00\x00\x00\x04\x44\x0b\xa9");
- $this->dataPacket($pk);
- break;
- case ProtocolInfo::CLIENT_HANDSHAKE_PACKET:
- if($this->loggedIn === true){
- break;
- }
- break;
- case ProtocolInfo::LOGIN_PACKET:
- if($this->loggedIn === true){
- break;
- }
- $this->username = $packet->username;
- $this->iusername = strtolower($this->username);
- $this->loginData = ["clientId" => $packet->clientId, "loginData" => $packet->loginData];
- if(count($this->server->clients) > $this->server->maxClients and !$this->server->api->ban->isOp($this->iusername)){
- $this->close("server is full!", false);
- return;
- }
- if($packet->protocol1 !== 17 && $packet->protocol1 !== ProtocolInfo::CURRENT_PROTOCOL){
- if($packet->protocol1 < ProtocolInfo::CURRENT_PROTOCOL){
- $pk = new LoginStatusPacket;
- $pk->status = 1;
- $this->directDataPacket($pk);
- }else{
- $pk = new LoginStatusPacket;
- $pk->status = 2;
- $this->directDataPacket($pk);
- }
- $this->close("Incorrect protocol #" . $packet->protocol1, false);
- return;
- }
- if(preg_match('#[^a-zA-Z0-9_]#', $this->username) > 0 or $this->username === "" or $this->iusername === "rcon" or $this->iusername === "console" or $this->iusername === "server"){
- $this->close("Bad username", false);
- return;
- }
- if($this->server->api->handle("player.connect", $this) === false){
- $this->close("Unknown reason", false);
- return;
- }
-
- if($this->server->whitelist === true and !$this->server->api->ban->inWhitelist($this->iusername)){
- $this->close("Server is white-listed", false);
- return;
- }elseif($this->server->api->ban->isBanned($this->iusername) or $this->server->api->ban->isIPBanned($this->ip)){
- $this->close("You are banned!", false);
- return;
- }
- $this->loggedIn = true;
-
- if(!isset($this->CID) or $this->CID == null){
- console("[DEBUG] Player " . $this->username . " does not have a CID", true, true, 2);
- $this->CID = Utils::readLong(Utils::getRandomBytes(8, false));
- }
- $u = $this->server->api->player->get($this->iusername, false);
- if($u !== false){
- $u = $this->server->clients[$this->CID];
- $u->close("this player already in game");
- }
-
- $this->server->api->player->add($this->CID);
- if($this->server->api->handle("player.join", $this) === false){
- $this->close("join cancelled", false);
- return;
- }
-
- if(!($this->data instanceof Config)){
- $this->close("no config created", false);
- return;
- }
-
- $this->auth = true;
- if(!$this->data->exists("inventory") or ($this->gamemode & 0x01) === 0x01){
- if(($this->gamemode & 0x01) === 0x01){
- $inv = [];
- if(($this->gamemode & 0x02) === 0x02){
- foreach(BlockAPI::$creative as $item){
- $inv[] = [0, 0, 1];
- }
- }else{
- foreach(BlockAPI::$creative as $item){
- $inv[] = [$item[0], $item[1], 1];
- }
- }
- }
- $this->data->set("inventory", $inv);
- }
- $this->achievements = $this->data->get("achievements");
- $this->data->set("caseusername", $this->username);
- $this->inventory = [];
- foreach($this->data->get("inventory") as $slot => $item){
- if(!is_array($item) or count($item) < 3){
- $item = [AIR, 0, 0];
- }
- $this->inventory[$slot] = BlockAPI::getItem($item[0], $item[1], $item[2]);
- }
-
- $this->armor = [];
- foreach($this->data->get("armor") as $slot => $item){
- $this->armor[$slot] = BlockAPI::getItem($item[0], $item[1], $item[0] === 0 ? 0 : 1);
- }
-
- $this->data->set("lastIP", $this->ip);
- $this->data->set("lastID", $this->clientID);
-
- $this->server->api->player->saveOffline($this->data);
-
-
- $pk = new LoginStatusPacket;
- $pk->status = 0;
- $this->dataPacket($pk);
- $spawnPos = $this->getSpawn();
-
-
-
- if(($this->gamemode & 0x01) === 0x01){
- $this->slot = 0;
- $this->hotbar = [];
- }elseif($this->data->exists("hotbar")){
- $this->hotbar = $this->data->get("hotbar");
- $this->slot = $this->hotbar[0];
- }else{
- $this->slot = -1;//0
- $this->hotbar = [-1, -1, -1, -1, -1, -1, -1, -1, -1];
- }
- $this->entity = $this->server->api->entity->add($this->level, ENTITY_PLAYER, 0, ["player" => $this]);
- $this->eid = $this->entity->eid;
- $this->server->query("UPDATE players SET EID = " . $this->eid . " WHERE CID = " . $this->CID . ";");
- $this->entity->x = $this->data->get("position")["x"];
- $this->entity->y = $this->data->get("position")["y"];
- $this->entity->z = $this->data->get("position")["z"];
- $pk = new StartGamePacket;
- $pk->seed = $this->level->getSeed();
- $pk->spawnX = (int) $this->spawnPosition->x;
- $pk->spawnY = (int) $this->spawnPosition->y;
- $pk->spawnZ = (int) $this->spawnPosition->z;
- $pk->x = $this->entity->x;
- $pk->y = $this->entity->y;
- $pk->z = $this->entity->z;
- $pk->generator = $this->level->generatorType; //1 - inf, 0 - old, 2 - flat
- $pk->gamemode = $this->gamemode & 0x01;
- $pk->eid = 0;
- $this->dataPacket($pk);
- $this->lastCorrect = new Vector3($this->entity->x, $this->entity->y, $this->entity->z);
- if(($level = $this->server->api->level->get($this->data->get("spawn")["level"])) !== false){
- $this->spawnPosition = new Position($this->data->get("spawn")["x"], $this->data->get("spawn")["y"], $this->data->get("spawn")["z"], $level);
-
- $pk = new SetSpawnPositionPacket;
- $pk->x = (int) $this->spawnPosition->x;
- $pk->y = (int) $this->spawnPosition->y;
- $pk->z = (int) $this->spawnPosition->z;
- $this->dataPacket($pk);
- }
-
- //$this->entity->check = false; whaT?
- $this->entity->setName($this->username);
- $this->entity->data["CID"] = $this->CID;
- $this->evid[] = $this->server->event("server.chat", [$this, "eventHandler"]);
- $this->evid[] = $this->server->event("entity.motion", [$this, "eventHandler"]);
- $this->evid[] = $this->server->event("entity.animate", [$this, "eventHandler"]);
- $this->evid[] = $this->server->event("entity.event", [$this, "eventHandler"]);
- $this->evid[] = $this->server->event("entity.metadata", [$this, "eventHandler"]);
- $this->evid[] = $this->server->event("entity.link", [$this, "eventHandler"]);
- $this->evid[] = $this->server->event("player.equipment.change", [$this, "eventHandler"]);
- $this->evid[] = $this->server->event("player.armor", [$this, "eventHandler"]);
- $this->evid[] = $this->server->event("player.pickup", [$this, "eventHandler"]);
- $this->evid[] = $this->server->event("tile.container.slot", [$this, "eventHandler"]);
- $this->evid[] = $this->server->event("tile.update", [$this, "eventHandler"]);
- $this->lastMeasure = microtime(true);
- $this->server->schedule(50, [$this, "measureLag"], [], true);
-
- $pk = new SetTimePacket;
- $pk->time = (int) $this->level->getTime();
- $pk->started = !$this->level->isTimeStopped();
- $this->dataPacket($pk);
-
-
- console("[INFO] " . FORMAT_AQUA . $this->username . FORMAT_RESET . "[/" . $this->ip . ":" . $this->port . "] logged in with entity id " . $this->eid . " at (" . $this->entity->level->getName() . ", " . round($this->entity->x, 2) . ", " . round($this->entity->y, 2) . ", " . round($this->entity->z, 2) . ")");
- $this->entity->setHealth($this->data->get("health"), "spawn", true);
-
- $this->server->api->entity->spawnAll($this);
- $this->server->api->entity->spawnToAll($this->entity);
-
- $array = explode("@n", (string)$this->server->motd);
- foreach($array as $msg){
- $this->sendChat($msg."\n");
- }
- $this->sendSettings();
- $this->sendInventory();
-
- $this->blocked = false;
- break;
- case ProtocolInfo::ROTATE_HEAD_PACKET:
- if($this->spawned === false){
- break;
- }
- if(($this->entity instanceof Entity)){
- if($this->blocked === true or $this->server->api->handle("player.move", $this->entity) === false){
- if($this->lastCorrect instanceof Vector3){
- $this->teleport($this->lastCorrect, $this->entity->yaw, $this->entity->pitch, false);
- }
- }else{
- $this->entity->setPosition($this->entity, $packet->yaw, $this->entity->pitch);
- }
- }
- break;
- case ProtocolInfo::MOVE_PLAYER_PACKET:
- if($this->spawned === false){
- $this->spawned = true;
- $this->server->handle("player.spawn", $this);
- $this->server->api->chat->broadcast($this->username." joined the game");
- //console("Current position: {$this->entity}");
- $this->server->api->player->spawnAllPlayers($this);
- $this->server->api->player->spawnToAllPlayers($this);
- $this->teleport($this->entity);
- return;
- }
- if($this->isSleeping) break;
- if(($this->entity instanceof Entity) and $packet->messageIndex > $this->lastMovement){
- $this->lastMovement = $packet->messageIndex;
- $newPos = new Vector3($packet->x, $packet->y, $packet->z);
- if($this->forceMovement instanceof Vector3){
- if($this->forceMovement->distance($newPos) <= 0.7){
- $this->forceMovement = false;
- }else{
- //console("force");
- $this->teleport($this->forceMovement, $this->entity->yaw, $this->entity->pitch, false);
- }
- }
- $speed = $this->entity->getSpeedMeasure();
- if($this->blocked === true or ($this->server->api->getProperty("allow-flight") !== true and (($speed > 9 and ($this->gamemode & 0x01) === 0x00) or $speed > 20 or $this->entity->distance($newPos) > 7)) or $this->server->api->handle("player.move", $this->entity) === false){
- if($this->lastCorrect instanceof Vector3){
- //console("last");
- $this->teleport($this->lastCorrect, $this->entity->yaw, $this->entity->pitch, false);
- }
- }else{
- //console("New Pos: $newPos");
- $this->entity->setPosition($newPos, $packet->yaw, $packet->pitch);
- }
- $this->entity->updateAABB();
- }
- break;
- case 0xa7:
- //TODO 0xa7
- break;
- case ProtocolInfo::PLAYER_EQUIPMENT_PACKET:
- if($this->spawned === false){
- break;
- }
- $packet->eid = $this->eid;
-
- $data = [];
- $data["eid"] = $packet->eid;
- $data["player"] = $this;
-
- if($packet->slot === 0x28 or $packet->slot === 0){ //0 for 0.8.0 compatibility
- $data["slot"] = -1;
- $data["item"] = BlockAPI::getItem(AIR, 0, 0);
- if($this->server->handle("player.equipment.change", $data) !== false){
- $this->slot = -1;
- }
- break;
- }else{
- $packet->slot -= 9;
- }
-
-
- if(($this->gamemode & 0x01) === SURVIVAL){
- $data["item"] = $this->getSlot($packet->slot);
- if(!($data["item"] instanceof Item)){
- break;
- }
- }elseif(($this->gamemode & 0x01) === CREATIVE){
- $packet->slot = false;
- foreach(BlockAPI::$creative as $i => $d){
- if($d[0] === $packet->item and $d[1] === $packet->meta){
- $packet->slot = $i;
- }
- }
- if($packet->slot !== false){
- $data["item"] = $this->getSlot($packet->slot);
- }else{
- break;
- }
- }else{
- break;//?????
- }
-
- $data["slot"] = $packet->slot;
-
- if($this->server->handle("player.equipment.change", $data) !== false){
- $this->slot = $packet->slot;
- if(($this->gamemode & 0x01) === SURVIVAL){
- if(!in_array($this->slot, $this->hotbar)){
- array_pop($this->hotbar);
- array_unshift($this->hotbar, $this->slot);
- }
- }
- }else{
- //$this->sendInventorySlot($packet->slot);
- $this->sendInventory();
- }
- if($this->entity->inAction === true){
- $this->entity->inAction = false;
- $this->entity->updateMetadata();
- }
- break;
- case ProtocolInfo::REQUEST_CHUNK_PACKET:
- console("request x:".$packet->chunkX.", z: ".$packet->chunkZ." chunk");
- //$this->useChunk($packet->chunkX, $packet->chunkZ);
- //$this->lastChunk = [$packet->chunkX, $packet->chunkZ];
- break;
- case ProtocolInfo::UPDATE_BLOCK_PACKET:
- $this->level->resendBlocksToPlayers[$this->CID]["{$packet->x}.{$packet->y}.{$packet->z}"] = true;
- break;
- case ProtocolInfo::USE_ITEM_PACKET:
- if(!($this->entity instanceof Entity)){
- break;
- }
-
- $blockVector = new Vector3($packet->x, $packet->y, $packet->z);
-
- if(($this->spawned === false or $this->blocked === true) and $packet->face >= 0 and $packet->face <= 5){
- $target = $this->level->getBlock($blockVector);
- $block = $target->getSide($packet->face);
-
- $pk = new UpdateBlockPacket;
- $pk->x = $target->x;
- $pk->y = $target->y;
- $pk->z = $target->z;
- $pk->block = $target->getID();
- $pk->meta = $target->getMetadata();
- $this->dataPacket($pk);
-
- $pk = new UpdateBlockPacket;
- $pk->x = $block->x;
- $pk->y = $block->y;
- $pk->z = $block->z;
- $pk->block = $block->getID();
- $pk->meta = $block->getMetadata();
- $this->dataPacket($pk);
- break;
- }
- $this->craftingItems = [];
- $this->toCraft = [];
- $packet->eid = $this->eid;
- $data = [];
- $data["eid"] = $packet->eid;
- $data["player"] = $this;
- $data["face"] = $packet->face;
- $data["x"] = $packet->x;
- $data["y"] = $packet->y;
- $data["z"] = $packet->z;
- $data["item"] = $packet->item;
- $data["meta"] = $packet->meta;
- $data["fx"] = $packet->fx;
- $data["fy"] = $packet->fy;
- $data["fz"] = $packet->fz;
- $data["posX"] = $packet->posX;
- $data["posY"] = $packet->posY;
- $data["posZ"] = $packet->posZ;
- if($packet->face >= 0 and $packet->face <= 5){ //Use Block, place
- if($this->entity->inAction === true){
- $this->entity->inAction = false;
- $this->entity->updateMetadata();
- }
-
- if($this->blocked === true or ($this->entity->position instanceof Vector3 and $blockVector->distance($this->entity->position) > 10)){
-
- }elseif($this->getSlot($this->slot)->getID() !== $packet->item or ($this->getSlot($this->slot)->isTool() === false and $this->getSlot($this->slot)->getMetadata() !== $packet->meta)){
- $this->sendInventorySlot($this->slot);
- }else{
- $this->server->api->block->playerBlockAction($this, $blockVector, $packet->face, $packet->fx, $packet->fy, $packet->fz);
- break;
- }
- $target = $this->level->getBlock($blockVector);
- $block = $target->getSide($packet->face);
-
- $pk = new UpdateBlockPacket;
- $pk->x = $target->x;
- $pk->y = $target->y;
- $pk->z = $target->z;
- $pk->block = $target->getID();
- $pk->meta = $target->getMetadata();
- $this->dataPacket($pk);
-
- $pk = new UpdateBlockPacket;
- $pk->x = $block->x;
- $pk->y = $block->y;
- $pk->z = $block->z;
- $pk->block = $block->getID();
- $pk->meta = $block->getMetadata();
- $this->dataPacket($pk);
- break;
- }elseif($packet->face === 0xff and $this->server->handle("player.action", $data) !== false){
- $this->entity->inAction = true;
- $this->startAction = microtime(true);
- $this->entity->updateMetadata();
- }
- break;
- case ProtocolInfo::PLAYER_ACTION_PACKET:
- if($this->spawned === false or $this->blocked === true){
- break;
- }
- $packet->eid = $this->eid;
- $this->craftingItems = [];
- $this->toCraft = [];
-
- switch($packet->action){
- case 5: //Shot arrow
- if($this->entity->inAction === true){
- if($this->getSlot($this->slot)->getID() === BOW){ // and player had arrow){
- if($this->startAction !== false){
- $time = microtime(true) - $this->startAction;
- $d = [
- "x" => $this->entity->x,
- "y" => $this->entity->y + 1.6,
- "z" => $this->entity->z,
- "yaw" => $this->entity->yaw,
- "pitch" => $this->entity->pitch
- ];
- $e = $this->server->api->entity->add($this->level, ENTITY_OBJECT, OBJECT_ARROW, $d);
- $e->speedX = -sin(($e->yaw / 180) * M_PI) * cos(($e->pitch / 180) * M_PI);
- $e->speedZ = cos(($e->yaw / 180) * M_PI) * cos(($e->pitch / 180) * M_PI);
- $e->speedY = -sin(($e->pitch / 180) * M_PI);
- $e->shoot($e->speedX, $e->speedY, $e->speedZ, 1.5, 1.0);
- //$this->server->api->entity->spawnToAll($e);
- $e->spawn($this);
- //$this->getSlot($this->slot)->useOn("shooting", true);
- $this->removeItem(ARROW, 0, 1);
- }
- }
- }
- $this->startAction = false;
- $this->entity->inAction = false;
- $this->entity->updateMetadata();
- break;
- case 6: //get out of the bed
- $this->stopSleep();
- }
- break;
- case ProtocolInfo::REMOVE_BLOCK_PACKET:
- $blockVector = new Vector3($packet->x, $packet->y, $packet->z);
- if($this->spawned === false or $this->blocked === true or $this->entity->distance($blockVector) > 8){
- $target = $this->level->getBlock($blockVector);
-
- $pk = new UpdateBlockPacket;
- $pk->x = $target->x;
- $pk->y = $target->y;
- $pk->z = $target->z;
- $pk->block = $target->getID();
- $pk->meta = $target->getMetadata();
- $this->dataPacket($pk);
- break;
- }
- $this->craftingItems = [];
- $this->toCraft = [];
- $this->server->api->block->playerBlockBreak($this, $blockVector);
- break;
- case ProtocolInfo::PLAYER_ARMOR_EQUIPMENT_PACKET:
- if($this->spawned === false or $this->blocked === true){
- break;
- }
- $this->craftingItems = [];
- $this->toCraft = [];
-
- $packet->eid = $this->eid;
- for($i = 0; $i < 4; ++$i){
- $s = $packet->slots[$i];
- if($s === 0 or $s === 255){
- $s = BlockAPI::getItem(AIR, 0, 0);
- }else{
- $s = BlockAPI::getItem($s + 256, 0, 1);
- }
- $slot = $this->armor[$i];
- if($slot->getID() !== AIR and $s->getID() === AIR){
- $this->addItem($slot->getID(), $slot->getMetadata(), 1, false);
- $this->armor[$i] = BlockAPI::getItem(AIR, 0, 0);
- $packet->slots[$i] = 255;
- }elseif($s->getID() !== AIR and $slot->getID() === AIR and ($sl = $this->hasItem($s->getID())) !== false){
- $this->armor[$i] = $this->getSlot($sl);
- $this->setSlot($sl, BlockAPI::getItem(AIR, 0, 0), false);
- }elseif($s->getID() !== AIR and $slot->getID() !== AIR and ($slot->getID() !== $s->getID() or $slot->getMetadata() !== $s->getMetadata()) and ($sl = $this->hasItem($s->getID())) !== false){
- $item = $this->armor[$i];
- $this->armor[$i] = $this->getSlot($sl);
- $this->setSlot($sl, $item, false);
- }else{
- $packet->slots[$i] = 255;
- }
-
- }
- $this->sendArmor();
- if($this->entity->inAction === true){
- $this->entity->inAction = false;
- $this->entity->updateMetadata();
- }
- break;
- case ProtocolInfo::INTERACT_PACKET:
- if($this->spawned === false){
- break;
- }
- $packet->eid = $this->eid;
- $data = [];
- $data["target"] = $packet->target;
- $data["eid"] = $packet->eid;
- $data["action"] = $packet->action;
- $this->craftingItems = [];
- $this->toCraft = [];
- $target = $this->server->api->entity->get($packet->target);
- if($target instanceof Entity and $this->entity instanceof Entity and $this->gamemode !== VIEW and $this->blocked === false and ($target instanceof Entity) and $this->entity->distance($target) <= 8){
- $data["targetentity"] = $packet->target;
- $data["entity"] = $this->entity;
- $data["player"] = $this;
- if($this->server->handle("player.interact", $data) !== false){
- $target->interactWith($this->entity, $packet->action);
- }
- }
-
- break;
- case ProtocolInfo::ANIMATE_PACKET:
- if($this->spawned === false){
- break;
- }
- $packet->eid = $this->eid;
- $this->server->api->dhandle("entity.animate", ["eid" => $packet->eid, "entity" => $this->entity, "action" => $packet->action]);
- break;
- case ProtocolInfo::RESPAWN_PACKET:
- if($this->spawned === false){
- break;
- }
- if(@$this->entity->dead === false){
- break;
- }
- $this->craftingItems = [];
- $this->toCraft = [];
- $this->teleport($this->spawnPosition);
- if($this->entity instanceof Entity){
- $this->entity->fire = 0;
- $this->entity->air = 300;
- $this->entity->setHealth(20, "respawn", true);
- $this->entity->updateMetadata();
- }else{
- break;
- }
- $this->sendInventory();
- $this->blocked = false;
- $this->server->handle("player.respawn", $this);
- break;
- case ProtocolInfo::SET_HEALTH_PACKET: //Not used
- break;
- case ProtocolInfo::ENTITY_EVENT_PACKET:
- if($this->spawned === false or $this->blocked === true){
- break;
- }
- $this->craftingItems = [];
- $this->toCraft = [];
- $packet->eid = $this->eid;
- if($this->entity->inAction === true){
- $this->entity->inAction = false;
- $this->entity->updateMetadata();
- }
- switch($packet->event){
- case 9: //Eating
- $items = [ //TODO rewrite
- APPLE => 4,
- MUSHROOM_STEW => 10,
- BEETROOT_SOUP => 10,
- BREAD => 5,
- RAW_PORKCHOP => 3,
- COOKED_PORKCHOP => 8,
- BEEF => 3,
- STEAK => 8,
- COOKED_CHICKEN => 6,
- RAW_CHICKEN => 2,
- MELON_SLICE => 2,
- GOLDEN_APPLE => 10,
- PUMPKIN_PIE => 8,
- CARROT => 4,
- POTATO => 1,
- BAKED_POTATO => 6,
- BEETROOT => 1
- ];
- $slot = $this->getSlot($this->slot);
- if($this->entity->getHealth() < 20 and isset($items[$slot->getID()])){
- $pk = new EntityEventPacket;
- $pk->eid = 0;
- $pk->event = 9;
- $this->dataPacket($pk);
-
- $this->entity->heal($items[$slot->getID()], "eating");
- --$slot->count;
- if($slot->count <= 0){
- $this->setSlot($this->slot, BlockAPI::getItem(AIR, 0, 0), false);
- }
- if($slot->getID() === MUSHROOM_STEW or $slot->getID() === BEETROOT_SOUP){
- $this->addItem(BOWL, 0, 1, false);
- }
- }
- break;
- }
- break;
- case ProtocolInfo::DROP_ITEM_PACKET:
- if($this->spawned === false or $this->blocked === true){
- break;
- }
- $packet->eid = $this->eid;
- $packet->item = $this->getSlot($this->slot);
- $this->craftingItems = [];
- $this->toCraft = [];
- $data["eid"] = $packet->eid;
- $data["unknown"] = $packet->unknown;
- $data["item"] = $packet->item;
- $data["player"] = $this;
- if($this->blocked === false and $this->server->handle("player.drop", $data) !== false){
- $f1 = 0.3;
- $sX = -sin(($this->entity->yaw / 180) * M_PI) * cos(($this->entity->pitch / 180) * M_PI) * $f1;
- $sZ = cos(($this->entity->yaw / 180) * M_PI) * cos(($this->entity->pitch / 180) * M_PI) * $f1;
- $sY = -sin(($this->entity->pitch / 180) * M_PI) * $f1 + 0.1;
- $f1 = 0.02;
- $f3 = $this->entity->random->nextFloat() * M_PI * 2.0;
- $f1 *= $this->entity->random->nextFloat();
- $sX += cos($f3) * $f1;
- $sY += ($this->entity->random->nextFloat() - $this->entity->random->nextFloat()) * 0.1;
- $sZ += sin($f3) * $f1;
-
- $this->server->api->entity->dropRawPos(new Position($this->entity->x, $this->entity->y - 0.3 + $this->entity->height - 0.12, $this->entity->z, $this->level), $packet->item, $sX, $sY, $sZ);
- $this->setSlot($this->slot, BlockAPI::getItem(AIR, 0, 0), false);
- }
- if($this->entity->inAction === true){
- $this->entity->inAction = false;
- $this->entity->updateMetadata();
- }
- break;
- case ProtocolInfo::MESSAGE_PACKET:
- if($this->spawned === false){
- break;
- }
- $this->craftingItems = [];
- $this->toCraft = [];
- if(trim($packet->message) != "" and strlen($packet->message) <= 255){
- $message = $packet->message;
- if($message[0] === "/"){ //Command
- if($this instanceof Player){
- console("[DEBUG] " . FORMAT_AQUA . $this->username . FORMAT_RESET . " issued server command: " . $message);
- }else{
- console("[DEBUG] " . FORMAT_YELLOW . "*" . $this . FORMAT_RESET . " issued server command: " . $message);
- }
- $this->server->api->console->run(substr($message, 1), $this);
- }else{
- $data = ["player" => $this, "message" => $message];
- if(Utils::hasEmoji($data["message"])){
- $this->sendChat("Your message contains illegal characters");
- break;
- }
- if($this->server->api->handle("player.chat", $data) !== false){
- $this->server->send2Discord("<" . $this->username . "> " . $message);
- if(isset($data["message"])){
- $this->server->api->chat->send($this, $data["message"]);
- }else{
- $this->server->api->chat->send($this, $message);
- }
- }
- }
- }
- break;
- case ProtocolInfo::CONTAINER_CLOSE_PACKET:
- if($this->spawned === false){
- break;
- }
- $this->craftingItems = [];
- $this->toCraft = [];
- if(isset($this->windows[$packet->windowid])){
- if(is_array($this->windows[$packet->windowid])){
- foreach($this->windows[$packet->windowid] as $ob){
- $pk = new TileEventPacket;
- $pk->x = $ob->x;
- $pk->y = $ob->y;
- $pk->z = $ob->z;
- $pk->case1 = 1;
- $pk->case2 = 0;
- $this->server->api->player->broadcastPacket($this->level->players, $pk);
- }
- }elseif($this->windows[$packet->windowid]->class === TILE_CHEST){
- $pk = new TileEventPacket;
- $pk->x = $this->windows[$packet->windowid]->x;
- $pk->y = $this->windows[$packet->windowid]->y;
- $pk->z = $this->windows[$packet->windowid]->z;
- $pk->case1 = 1;
- $pk->case2 = 0;
- $this->server->api->player->broadcastPacket($this->level->players, $pk);
- }
- }
- unset($this->windows[$packet->windowid]);
-
- $pk = new ContainerClosePacket;
- $pk->windowid = $packet->windowid;
- $this->dataPacket($pk);
- break;
- case ProtocolInfo::CONTAINER_SET_SLOT_PACKET:
- if($this->spawned === false or $this->blocked === true){
- break;
- }
-
- if($this->lastCraft <= (microtime(true) - 1)){
- if(isset($this->toCraft[-1])){
- $this->toCraft = [-1 => $this->toCraft[-1]];
- }else{
- $this->toCraft = [];
- }
- $this->craftingItems = [];
- }
-
- if($packet->windowid === 0){
- $craft = false;
- $slot = $this->getSlot($packet->slot);
- if($slot->count >= $packet->item->count and (($slot->getID() === $packet->item->getID() and $slot->getMetadata() === $packet->item->getMetadata()) or ($packet->item->getID() === AIR and $packet->item->count === 0)) and !isset($this->craftingItems[$packet->slot])){ //Crafting recipe
- $use = BlockAPI::getItem($slot->getID(), $slot->getMetadata(), $slot->count - $packet->item->count);
- $this->craftingItems[$packet->slot] = $use;
- $craft = true;
- }elseif($slot->count <= $packet->item->count and ($slot->getID() === AIR or ($slot->getID() === $packet->item->getID() and $slot->getMetadata() === $packet->item->getMetadata()))){ //Crafting final
- $craftItem = BlockAPI::getItem($packet->item->getID(), $packet->item->getMetadata(), $packet->item->count - $slot->count);
- if(count($this->toCraft) === 0){
- $this->toCraft[-1] = 0;
- }
- $this->toCraft[$packet->slot] = $craftItem;
- $craft = true;
- }elseif(((count($this->toCraft) === 1 and isset($this->toCraft[-1])) or count($this->toCraft) === 0) and $slot->count > 0 and $slot->getID() > AIR and ($slot->getID() !== $packet->item->getID() or $slot->getMetadata() !== $packet->item->getMetadata())){ //Crafting final
- $craftItem = BlockAPI::getItem($packet->item->getID(), $packet->item->getMetadata(), $packet->item->count);
- if(count($this->toCraft) === 0){
- $this->toCraft[-1] = 0;
- }
- $use = BlockAPI::getItem($slot->getID(), $slot->getMetadata(), $slot->count);
- $this->craftingItems[$packet->slot] = $use;
- $this->toCraft[$packet->slot] = $craftItem;
- $craft = true;
- }
-
- if($craft === true){
- $this->lastCraft = microtime(true);
- }
-
- if($craft === true and count($this->craftingItems) > 0 and count($this->toCraft) > 0 and ($recipe = $this->craftItems($this->toCraft, $this->craftingItems, $this->toCraft[-1])) !== true){
- if($recipe === false){
- $this->sendInventory();
- $this->toCraft = [];
- }else{
- $this->toCraft = [-1 => $this->toCraft[-1]];
- }
- $this->craftingItems = [];
- }
- }else{
- $this->toCraft = [];
- $this->craftingItems = [];
- }
- if(!isset($this->windows[$packet->windowid])){
- break;
- }
-
- if(is_array($this->windows[$packet->windowid])){
- $tiles = $this->windows[$packet->windowid];
- if($packet->slot >= 0 and $packet->slot < CHEST_SLOTS){
- $tile = $tiles[0];
- $slotn = $packet->slot;
- $offset = 0;
- }elseif($packet->slot >= CHEST_SLOTS and $packet->slot <= (CHEST_SLOTS << 1)){
- $tile = $tiles[1];
- $slotn = $packet->slot - CHEST_SLOTS;
- $offset = CHEST_SLOTS;
- }else{
- break;
- }
-
- $item = BlockAPI::getItem($packet->item->getID(), $packet->item->getMetadata(), $packet->item->count);
-
- $slot = $tile->getSlot($slotn);
- if($this->server->api->dhandle("player.container.slot", [
- "tile" => $tile,
- "slot" => $packet->slot,
- "offset" => $offset,
- "slotdata" => $slot,
- "itemdata" => $item,
- "player" => $this
- ]) === false){
- $pk = new ContainerSetSlotPacket;
- $pk->windowid = $packet->windowid;
- $pk->slot = $packet->slot;
- $pk->item = $slot;
- $this->dataPacket($pk);
- break;
- }
- if($item->getID() !== AIR and $slot->getID() == $item->getID()){
- if($slot->count < $item->count){
- if($this->removeItem($item->getID(), $item->getMetadata(), $item->count - $slot->count, false) === false){
- break;
- }
- }elseif($slot->count > $item->count){
- $this->addItem($item->getID(), $item->getMetadata(), $slot->count - $item->count, false);
- }
- }else{
- if($this->removeItem($item->getID(), $item->getMetadata(), $item->count, false) === false){
- break;
- }
- $this->addItem($slot->getID(), $slot->getMetadata(), $slot->count, false);
- }
- $tile->setSlot($slotn, $item, true, $offset);
- }else{
- $tile = $this->windows[$packet->windowid];
- if(($tile->class !== TILE_CHEST and $tile->class !== TILE_FURNACE) or $packet->slot < 0 or ($tile->class === TILE_CHEST and $packet->slot >= CHEST_SLOTS) or ($tile->class === TILE_FURNACE and $packet->slot >= FURNACE_SLOTS)){
- break;
- }
- $item = BlockAPI::getItem($packet->item->getID(), $packet->item->getMetadata(), $packet->item->count);
-
- $slot = $tile->getSlot($packet->slot);
- if($this->server->api->dhandle("player.container.slot", [
- "tile" => $tile,
- "slot" => $packet->slot,
- "slotdata" => $slot,
- "itemdata" => $item,
- "player" => $this,
- ]) === false){
- $pk = new ContainerSetSlotPacket;
- $pk->windowid = $packet->windowid;
- $pk->slot = $packet->slot;
- $pk->item = $slot;
- $this->dataPacket($pk);
- break;
- }
-
- if($tile->class === TILE_FURNACE and $packet->slot == 2){
- switch($slot->getID()){
- case IRON_INGOT:
- AchievementAPI::grantAchievement($this, "acquireIron");
- break;
- }
- }
-
- if($item->getID() !== AIR and $slot->getID() == $item->getID()){
- if($slot->count < $item->count){
- if($this->removeItem($item->getID(), $item->getMetadata(), $item->count - $slot->count, false) === false){
- break;
- }
- }elseif($slot->count > $item->count){
- $this->addItem($item->getID(), $item->getMetadata(), $slot->count - $item->count, false);
- }
- }else{
- if($this->removeItem($item->getID(), $item->getMetadata(), $item->count, false) === false){
- break;
- }
- $this->addItem($slot->getID(), $slot->getMetadata(), $slot->count, false);
- }
- $tile->setSlot($packet->slot, $item);
- }
- break;
- case ProtocolInfo::SEND_INVENTORY_PACKET: //TODO, Mojang, enable this ´^_^`
- if($this->spawned === false){
- break;
- }
- break;
- case ProtocolInfo::ENTITY_DATA_PACKET:
- if($this->spawned === false or $this->blocked === true){
- break;
- }
- $this->craftingItems = [];
- $this->toCraft = [];
- $t = $this->server->api->tile->get(new Position($packet->x, $packet->y, $packet->z, $this->level));
- if(($t instanceof Tile) and $t->class === TILE_SIGN){
- if($t->data["creator"] !== $this->username){
- $t->spawn($this);
- }else{
- $nbt = new NBT();
- $nbt->load($packet->namedtag);
- $d = array_shift($nbt->tree);
- if($d["id"] !== TILE_SIGN){
- $t->spawn($this);
- }else{
- $t->setText($d["Text1"], $d["Text2"], $d["Text3"], $d["Text4"]);
- }
- }
- }
- break;
- case ProtocolInfo::PLAYER_INPUT_PACKET:
- break; //TODO player input-
- default:
- console("[DEBUG] Unhandled 0x" . dechex($packet->pid()) . " data packet for " . $this->username . " (" . $this->clientID . "): " . print_r($packet, true), true, true, 2);
- break;
- }
- }
-
- /**
- * Get an Item which is currently held by player
- * @return Item
- */
-
- public function getHeldItem(){
- return $this->getSlot($this->slot);
- }
-
- public function stopSleep(){
- $this->isSleeping = false;
- $this->sleepingTime = 0;
- if($this->entity instanceof Entity){
- $this->entity->updateMetadata();
- }
- }
-
- public function hasItem($type, $damage = false){
- foreach($this->inventory as $s => $item){
- if($item->getID() === $type and ($item->getMetadata() === $damage or $damage === false) and $item->count > 0){
- return $s;
- }
- }
- return false;
- }
-
- public function removeItem($type, $damage, $count, $send = true){
- while($count > 0){
- $remove = 0;
- foreach($this->inventory as $s => $item){
- if($item->getID() === $type and $item->getMetadata() === $damage){
- $remove = min($count, $item->count);
- if($remove < $item->count){
- $item->count -= $remove;
- }else{
- $this->inventory[$s] = BlockAPI::getItem(AIR, 0, 0);
- }
- if($send === true){
- $this->sendInventorySlot($s);
- }
- break;
- }
- }
- if($remove <= 0){
- return false;
- }
- $count -= $remove;
- }
- return true;
- }
-
- /**
- * @param array $craft
- * @param array $recipe
- * @param $type
- *
- * @return array|bool
- */
- public function craftItems(array $craft, array $recipe, $type){
- $craftItem = [0, true, 0];
- unset($craft[-1]);
-
- foreach($craft as $slot => $item){
- if($item instanceof Item){
- $craftItem[0] = $item->getID();
- if($item->getMetadata() !== $craftItem[1] and $craftItem[1] !== true){
- $craftItem[1] = false;
- }else{
- $craftItem[1] = $item->getMetadata();
- }
- $craftItem[2] += $item->count;
- }
-
- }
-
- $recipeItems = [];
- foreach($recipe as $slot => $item){
- if(!isset($recipeItems[$item->getID()])){
- $recipeItems[$item->getID()] = [$item->getID(), $item->getMetadata(), $item->count];
- }else{
- if($item->getMetadata() !== $recipeItems[$item->getID()][1]){
- $recipeItems[$item->getID()][1] = false;
- }
- $recipeItems[$item->getID()][2] += $item->count;
- }
- }
-
- $res = CraftingRecipes::canCraft($craftItem, $recipeItems, $type);
-
- if(!is_array($res) and $type === 1){
- $res2 = CraftingRecipes::canCraft($craftItem, $recipeItems, 0);
- if(is_array($res2)){
- $res = $res2;
- }
- }
-
- if(is_array($res)){
- if($this->server->api->dhandle("player.craft", ["player" => $this, "recipe" => $recipe, "craft" => $craft, "type" => $type]) === false){
- return false;
- }
- foreach($recipe as $slot => $item){
- $s = $this->getSlot($slot);
- $s->count -= $item->count;
- if($s->count <= 0){
- $this->setSlot($slot, BlockAPI::getItem(AIR, 0, 0), false);
- }
- }
- foreach($craft as $slot => $item){
- $s = $this->getSlot($slot);
- if($s->count <= 0 or $s->getID() === AIR){
- $this->setSlot($slot, BlockAPI::getItem($item->getID(), $item->getMetadata(), $item->count), false);
- }else{
- $this->setSlot($slot, BlockAPI::getItem($item->getID(), $item->getMetadata(), $s->count + $item->count), false);
- }
- switch($item->getID()){
- case WORKBENCH:
- AchievementAPI::grantAchievement($this, "buildWorkBench");
- break;
- case WOODEN_PICKAXE:
- AchievementAPI::grantAchievement($this, "buildPickaxe");
- break;
- case FURNACE:
- AchievementAPI::grantAchievement($this, "buildFurnace");
- break;
- case WOODEN_HOE:
- AchievementAPI::grantAchievement($this, "buildHoe");
- break;
- case BREAD:
- AchievementAPI::grantAchievement($this, "makeBread");
- break;
- case CAKE:
- AchievementAPI::grantAchievement($this, "bakeCake");
- $this->addItem(BUCKET, 0, 3);
- break;
- case STONE_PICKAXE:
- case GOLDEN_PICKAXE:
- case IRON_PICKAXE:
- case DIAMOND_PICKAXE:
- AchievementAPI::grantAchievement($this, "buildBetterPickaxe");
- break;
- case WOODEN_SWORD:
- AchievementAPI::grantAchievement($this, "buildSword");
- break;
- case DIAMOND:
- AchievementAPI::grantAchievement($this, "diamond");
- break;
-
- }
- }
- }
- return $res;
- }
-
- public function handlePacket(RakNetPacket $packet){
- if($this->connected === true){
- $this->timeout = microtime(true) + 20;
- switch($packet->pid()){
- case RakNetInfo::NACK:
- foreach($packet->packets as $count){
- if(isset($this->recoveryQueue[$count])){
- $this->resendQueue[$count] =& $this->recoveryQueue[$count];
- $this->lag[] = microtime(true) - $this->recoveryQueue[$count]->sendtime;
- unset($this->recoveryQueue[$count]);
- }
- ++$this->packetStats[1];
- }
- break;
-
- case RakNetInfo::ACK:
- foreach($packet->packets as $count){
- if(isset($this->recoveryQueue[$count])){
- $this->lag[] = microtime(true) - $this->recoveryQueue[$count]->sendtime;
- unset($this->recoveryQueue[$count]);
- unset($this->resendQueue[$count]);
- }
- ++$this->packetStats[0];
- }
- break;
-
- case RakNetInfo::DATA_PACKET_0:
- case RakNetInfo::DATA_PACKET_1:
- case RakNetInfo::DATA_PACKET_2:
- case RakNetInfo::DATA_PACKET_3:
- case RakNetInfo::DATA_PACKET_4:
- case RakNetInfo::DATA_PACKET_5:
- case RakNetInfo::DATA_PACKET_6:
- case RakNetInfo::DATA_PACKET_7:
- case RakNetInfo::DATA_PACKET_8:
- case RakNetInfo::DATA_PACKET_9:
- case RakNetInfo::DATA_PACKET_A:
- case RakNetInfo::DATA_PACKET_B:
- case RakNetInfo::DATA_PACKET_C:
- case RakNetInfo::DATA_PACKET_D:
- case RakNetInfo::DATA_PACKET_E:
- case RakNetInfo::DATA_PACKET_F:
- $this->ackQueue[] = $packet->seqNumber;
- $this->receiveQueue[$packet->seqNumber] = [];
- foreach($packet->data as $pk){
- $this->receiveQueue[$packet->seqNumber][] = $pk;
- }
- break;
- }
- }
- }
-
- public function damageArmorPart($slot, $part){
- $part->useOn($this->entity, true); //PocketMine is forced to do it =<. Even if PocketMine doesnt want, he have to damage your armor.
- if($part->getMetadata() >= $part->getMaxDurability()){
- $this->setArmor($slot, BlockAPI::getItem(AIR, 0, 0), false);
- return;
- }
- $this->setArmor($slot, $part, false);
- }
-
- /**
- * @return string
- */
- function __toString(){
- if($this->username != ""){
- return $this->username;
- }
- return $this->clientID;
- }
-
-}
-
-class PlayerNull extends Player{
-
- public function __construct(){
-
- }
-}
diff --git a/src/PocketMinecraftServer.php b/src/PocketMinecraftServer.php
deleted file mode 100644
index 3d7f1f89..00000000
--- a/src/PocketMinecraftServer.php
+++ /dev/null
@@ -1,756 +0,0 @@
-port = (int) $port;
- $this->doTick = true;
- $this->gamemode = (int) $gamemode;
- $this->name = $name;
- $this->motd = "Welcome to " . $name;
- $this->serverID = false;
- $this->seed = $seed;
- $this->serverip = $serverip;
- $this->load();
- }
-
- private function load(){
- global $dolog;
-
- $this->version = new VersionString();
- /*if(defined("DEBUG") and DEBUG >= 0){
- @cli_set_process_title("NostalgiaCore ".MAJOR_VERSION);
- }*/
-
- console("[INFO] Starting Minecraft PE server on " . ($this->serverip === "0.0.0.0" ? "*" : $this->serverip) . ":" . $this->port);
- EntityRegistry::registerEntities();
- Structures::initialize();
- Feature::init();
- StaticBlock::init();
- define("BOOTUP_RANDOM", Utils::getRandomBytes(16));
- $this->serverID = $this->serverID === false ? Utils::readLong(substr(Utils::getUniqueID(true, $this->serverip . $this->port), 8)) : $this->serverID;
- $this->seed = $this->seed === false ? Utils::readInt(Utils::getRandomBytes(4, false)) : $this->seed;
- $this->startDatabase();
- $this->api = false;
- $this->tCnt = 1;
- $this->events = [];
- $this->eventsID = [];
- $this->handlers = [];
- $this->invisible = false;
- $this->levelData = false;
- $this->difficulty = 1;
- $this->tiles = [];
- $this->entities = [];
- $this->custom = [];
- $this->evCnt = 1;
- $this->handCnt = 1;
- $this->eidCnt = 1;
- $this->maxClients = 20;
- $this->schedule = [];
- $this->scheduleCnt = 1;
- $this->description = "";
- $this->whitelist = false;
- $this->memoryStats = [];
- $this->clients = [];
- $this->spawn = false;
- $this->saveEnabled = true;
- $this->tickMeasure = array_fill(0, 40, 0);
- $this->setType("normal");
- $this->interface = new MinecraftInterface("255.255.255.255", $this->port, $this->serverip);
- $this->stop = false;
- $this->ticks = 0;
- if(!defined("NO_THREADS")){
- $this->asyncThread = new AsyncMultipleQueue();
- }
-
- console("[INFO] Loading extra.properties...");
- $this->extraprops = new Config(DATA_PATH . "extra.properties", CONFIG_PROPERTIES, [
- "version" => "5",
- "experemental-mob-features" => true,
- "enable-mob-ai" => false,
- "enable-nether-reactor" => true,
- "enable-explosions" => true,
- "enable-rail-connection" => true,
- "save-player-data" => true,
- "save-console-data" => true,
- "query-plugins" => false,
- "discord-msg" => false,
- "discord-ru-smiles" => false,
- "discord-webhook-url" => "none",
- "discord-bot-name" => "NostalgiaCore Logger",
- "despawn-mobs" => true,
- "mob-despawn-ticks" => 18000,
- ]);
-
- Living::$despawnMobs = $this->extraprops->get("despawn-mobs");
- Living::$despawnTimer = $this->extraprops->get("mob-despawn-ticks");
- Entity::$allowedAI = $this->extraprops->get("enable-mob-ai");
- Entity::$updateOnTick = $this->extraprops->get("experemental-mob-features");
- if(Entity::$updateOnTick){
- console("[WARNING] Experemental mob features are enabled. Unpredictable behavior.");
- }
- Explosion::$enableExplosions = $this->extraprops->get("enable-explosions");
- RailBlock::$shouldconnectrails = $this->extraprops->get("enable-rail-connection"); //Rail connection in config
- NetherReactorBlock::$enableReactor = $this->extraprops->get("enable-nether-reactor");
- if($this->extraprops->get("discord-msg") == true){
- if($this->extraprops->get("discord-webhook-url") !== "none"){
- console("[INFO] Discord Logger is enabled.");
- }else{
- console("[WARNING] Discord Logger is enabled in extra.properties,");
- console("[WARNING] but you didn't put the webhook url, so it won't work.");
- }
- }elseif($this->extraprops->get("version") == null){
- console("[WARNING] Your extra.properties file is corrupted!");
- console("[WARNING] To fix it - just remove it! Server will generate it again automatically.");
- }
- $dolog = $this->extraprops->get("save-console-data");
- }
-
- public function onShutdown(){
- console("[INFO] Saving...");
- $save = $this->saveEnabled;
- $this->saveEnabled = true;
- $this->api->level->saveAll();
- $this->saveEnabled = $save;
- //$this->send2Discord('[INFO] Server stopped!');
- }
-
- public function startDatabase(){
- $this->preparedSQL = new stdClass();
- $this->preparedSQL->entity = new stdClass();
- $this->database = new SQLite3(":memory:");
- $this->query("PRAGMA journal_mode = OFF;");
- $this->query("PRAGMA encoding = \"UTF-8\";");
- $this->query("PRAGMA secure_delete = OFF;");
- $this->query("CREATE TABLE players (CID INTEGER PRIMARY KEY, EID NUMERIC, ip TEXT, port NUMERIC, name TEXT UNIQUE COLLATE NOCASE);");
- $this->query("CREATE TABLE entities (EID INTEGER PRIMARY KEY, level TEXT, type NUMERIC, class NUMERIC, hasUpdate NUMERIC, name TEXT, x NUMERIC, y NUMERIC, z NUMERIC, yaw NUMERIC, pitch NUMERIC, health NUMERIC);");
- $this->query("CREATE TABLE tiles (ID INTEGER PRIMARY KEY, level TEXT, class TEXT, x NUMERIC, y NUMERIC, z NUMERIC, spawnable NUMERIC);");
- $this->query("CREATE TABLE actions (ID INTEGER PRIMARY KEY, interval NUMERIC, last NUMERIC, code TEXT, repeat NUMERIC);");
- $this->query("CREATE TABLE handlers (ID INTEGER PRIMARY KEY, name TEXT, priority NUMERIC);");
- $this->query("CREATE TABLE blockUpdates (level TEXT, x INTEGER, y INTEGER, z INTEGER, type INTEGER, delay NUMERIC);");
- $this->query("CREATE TABLE recipes (id INTEGER PRIMARY KEY, type NUMERIC, recipe TEXT);");
- $this->query("PRAGMA synchronous = OFF;");
- $this->preparedSQL->selectHandlers = $this->database->prepare("SELECT DISTINCT ID FROM handlers WHERE name = :name ORDER BY priority DESC;");
- $this->preparedSQL->selectActions = $this->database->prepare("SELECT ID,code,repeat FROM actions WHERE last <= (:time - interval);");
- $this->preparedSQL->updateAction = $this->database->prepare("UPDATE actions SET last = :time WHERE ID = :id;");
- $this->preparedSQL->entity->setPosition = $this->database->prepare("UPDATE entities SET x = :x, y = :y, z = :z, pitch = :pitch, yaw = :yaw WHERE EID = :eid ;");
- $this->preparedSQL->entity->setLevel = $this->database->prepare("UPDATE entities SET level = :level WHERE EID = :eid ;");
- }
-
- public function query($sql, $fetch = false){
- $result = $this->database->query($sql) or console("[ERROR] [SQL Error] " . $this->database->lastErrorMsg() . ". Query: " . $sql, true, true, 0);
- if($fetch === true and ($result instanceof SQLite3Result)){
- $result = $result->fetchArray(SQLITE3_ASSOC);
- }
- return $result;
- }
-
- public function setType($type = "normal"){
- switch(trim(strtolower($type))){
- case "normal":
- case "demo":
- $this->serverType = "MCCPP;Demo;";
- break;
- case "minecon":
- $this->serverType = "MCCPP;MINECON;";
- break;
- }
- }
-
- public function titleTick(){
- $time = microtime(true);
- if(defined("DEBUG") and DEBUG >= 0){
- echo "\x1b]0;NostalgiaCore " . MAJOR_VERSION . " | Online " . count($this->clients) . "/" . $this->maxClients . " | RAM " . round((memory_get_usage() / 1024) / 1024, 2) . "MB | U " . round(($this->interface->bandwidth[1] / max(1, $time - $this->interface->bandwidth[2])) / 1024, 2) . " D " . round(($this->interface->bandwidth[0] / max(1, $time - $this->interface->bandwidth[2])) / 1024, 2) . " kB/s | TPS " . $this->getTPS() . "\x07";
- }
-
- $this->interface->bandwidth = [0, 0, $time];
- }
-
- /**
- * @return float
- */
- public function getTPS(){
- $v = array_values($this->tickMeasure);
- $divval = ($v[39] - $v[0]);
- if($divval === 0){
- return 0;
- }
- $tps = 40 / $divval;
- return round($tps, 4);
- }
-
- public function checkTicks(){
- if($this->getTPS() < 12){
- console("[WARNING] Can't keep up! Is the server overloaded?");
- }
- }
-
- /**
- * @param string $reason
- */
- public function close($reason = "server stop"){
- usleep(2);
- $this->onShutdown();
- if($this->stop !== true){
- if(is_int($reason)){
- $reason = "signal stop";
- }
- if(($this->api instanceof ServerAPI) === true){
- if(($this->api->chat instanceof ChatAPI) === true){
- $this->api->chat->send(false, "Stopping server...");
- new StopMessageThread($this, "[INFO] Stopping server..."); //broadcast didnt want to send message to discord for some reason
- }
- }
- $this->stop = true;
- $this->trigger("server.close", $reason);
- $this->interface->close();
-
- if(!defined("NO_THREADS")){
- @$this->asyncThread->stop = true;
- }
- }
- }
-
- public function send2Discord($msg){
- if($this->extraprops->get("discord-msg") == true and $this->extraprops->get("discord-webhook-url") !== "none"){
- $url = $this->extraprops->get("discord-webhook-url");
- $name = $this->extraprops->get("discord-bot-name");
- $this->asyncOperation(ASYNC_CURL_POST, [
- "url" => $url,
- "data" => [
- "username" => $name,
- "content" => $this->extraprops->get("discord-ru-smiles") ? str_replace("@", " ", str_replace("Û", "<:imp_cool:1151085500396998719>", str_replace("Ü", "<:imp_badphp5:1151085478410457120>", str_replace("Ú", "<:imp_gudjava:1151085431962742784>", str_replace("¨", "<:imp_wut:1151085524241621012>", $msg))))) : str_replace("@", "", $msg)
- ],
- ], null);
- }
- }
-
- public function asyncOperation($type, array $data, callable $callable = null){
- if(defined("NO_THREADS")){
- return false;
- }
- $d = "";
- $type = (int) $type;
- switch($type){
- case ASYNC_CURL_GET:
- if(isset($data["headers"])){
- $jsstr = json_encode($data["headers"]);
- }
- $d .= Utils::writeShort(strlen($data["url"])) . $data["url"] . (isset($data["timeout"]) ? Utils::writeShort($data["timeout"]) : Utils::writeShort(10)) . (isset($data["headers"]) ? Utils::writeShort(strlen($jsstr)) . $jsstr : Utils::writeShort(1) . " ");
- break;
- case ASYNC_CURL_POST:
- $d .= Utils::writeShort(strlen($data["url"])) . $data["url"] . (isset($data["timeout"]) ? Utils::writeShort($data["timeout"]) : Utils::writeShort(10));
- $d .= Utils::writeShort(count($data["data"]));
- foreach($data["data"] as $key => $value){
- $d .= Utils::writeShort(strlen($key)) . $key . Utils::writeInt(strlen($value)) . $value;
- }
- break;
- default:
- return false;
- }
- $ID = $this->asyncID++;
- $this->async[$ID] = $callable;
- $this->asyncThread->input .= Utils::writeInt($ID) . Utils::writeShort($type) . $d;
- return $ID;
- }
-
- public function trigger($event, $data = ""){
- if(isset($this->events[$event])){
- foreach($this->events[$event] as $evid => $ev){
- if(!is_callable($ev)){
- $this->deleteEvent($evid);
- continue;
- }
- if(is_array($ev)){
- $method = $ev[1];
- $ev[0]->$method($data, $event);
- }else{
- $ev($data, $event);
- }
- }
- }elseif(isset(Deprecation::$events[$event])){
- $sub = "";
- if(Deprecation::$events[$event] !== false){
- $sub = " Substitute \"" . Deprecation::$events[$event] . "\" found.";
- }
- console("[ERROR] Event \"$event\" has been deprecated.$sub [Trigger]");
- }
- }
-
- public function deleteEvent($id){
- $id = (int) $id;
- if(isset($this->eventsID[$id])){
- $ev = $this->eventsID[$id];
- $this->eventsID[$id] = null;
- unset($this->eventsID[$id]);
- $this->events[$ev][$id] = null;
- unset($this->events[$ev][$id]);
- if(count($this->events[$ev]) === 0){
- unset($this->events[$ev]);
- }
- }
- }
-
- public function asyncOperationChecker(){
- if(defined("NO_THREADS")){
- return false;
- }
- if(isset($this->asyncThread->output[5])){
- $offset = 0;
- $ID = Utils::readInt(substr($this->asyncThread->output, $offset, 4));
- $offset += 4;
- $type = Utils::readShort(substr($this->asyncThread->output, $offset, 2));
- $offset += 2;
- $data = [];
- switch($type){
- case ASYNC_CURL_GET:
- case ASYNC_CURL_POST:
- $len = Utils::readInt(substr($this->asyncThread->output, $offset, 4));
- $offset += 4;
- $data["result"] = substr($this->asyncThread->output, $offset, $len);
- $this->dhandle("async.curl.get", ["response" => $data["result"]]);
- $offset += $len;
- break;
- }
-
- $this->asyncThread->output = substr($this->asyncThread->output, $offset);
- if(isset($this->async[$ID]) and $this->async[$ID] !== null and is_callable($this->async[$ID])){
- if(is_array($this->async[$ID])){
- $method = $this->async[$ID][1];
- $result = $this->async[$ID][0]->$method($data, $type, $ID);
- }else{
- $result = $this->async[$ID]($data, $type, $ID);
- }
- }
- unset($this->async[$ID]);
- }
- }
-
- /**
- * @param string $event
- * @param callable $callable
- * @param integer $priority
- *
- * @return boolean
- */
- public function addHandler($event, callable $callable, $priority = 5){
- if(!is_callable($callable)){
- return false;
- }elseif(isset(Deprecation::$events[$event])){
- $sub = "";
- if(Deprecation::$events[$event] !== false){
- $sub = " Substitute \"" . Deprecation::$events[$event] . "\" found.";
- }
- console("[ERROR] Event \"$event\" has been deprecated.$sub [Adding handle to " . (is_array($callable) ? get_class($callable[0]) . "::" . $callable[1] : $callable) . "]");
- }
- $priority = (int) $priority;
- $hnid = $this->handCnt++;
- $this->handlers[$hnid] = $callable;
- $this->query("INSERT INTO handlers (ID, name, priority) VALUES (" . $hnid . ", '" . str_replace("'", "\\'", $event) . "', " . $priority . ");");
- //console("[INTERNAL] New handler " . (is_array($callable) ? get_class($callable[0]) . "::" . $callable[1] : $callable) . " to special event " . $event . " (ID " . $hnid . ")", true, true, 3);
- return $hnid;
- }
-
- public function dhandle($e, $d){
- return $this->handle($e, $d);
- }
-
- public function handle($event, &$data){
- $this->preparedSQL->selectHandlers->reset();
- $this->preparedSQL->selectHandlers->clear();
- $this->preparedSQL->selectHandlers->bindValue(":name", $event, SQLITE3_TEXT);
- $handlers = $this->preparedSQL->selectHandlers->execute();
- $result = null;
- if($handlers instanceof SQLite3Result){
- $call = [];
- while(($hn = $handlers->fetchArray(SQLITE3_ASSOC)) !== false){
- $call[(int) $hn["ID"]] = true;
- }
- $handlers->finalize();
- foreach($call as $hnid => $boolean){
- if($result !== false and $result !== true){
- $called[$hnid] = true;
- $handler = $this->handlers[$hnid];
- if(is_array($handler)){
- $method = $handler[1];
- $result = $handler[0]->$method($data, $event);
- }else{
- $result = $handler($data, $event);
- }
- }else{
- break;
- }
- }
- }elseif(isset(Deprecation::$events[$event])){
- $sub = "";
- if(Deprecation::$events[$event] !== false){
- $sub = " Substitute \"" . Deprecation::$events[$event] . "\" found.";
- }
- console("[ERROR] Event \"$event\" has been deprecated.$sub [Handler]");
- }
-
- if($result !== false){
- $this->trigger($event, $data);
- }
- return $result;
- }
-
- public function eventHandler($data, $event){
- switch($event){
-
- }
- }
-
- public function init(){
- register_tick_function([$this, "tick"]);
- declare(ticks=5000); //Minimum TPS for main thread locks
-
- $this->loadEvents();
- register_shutdown_function([$this, "dumpError"]);
- register_shutdown_function([$this, "close"]);
- if(function_exists("pcntl_signal")){
- pcntl_signal(SIGTERM, [$this, "close"]);
- pcntl_signal(SIGINT, [$this, "close"]);
- pcntl_signal(SIGHUP, [$this, "close"]);
- }
- console("[INFO] Default game type: " . strtoupper($this->getGamemode()));
- $this->trigger("server.start", microtime(true));
- console('[INFO] Done (' . round(microtime(true) - START_TIME, 3) . 's)! For help, type "help" or "?"');
- $this->process();
- }
-
- public function loadEvents(){
- if(ENABLE_ANSI === true){
- $this->schedule(30, [$this, "titleTick"], [], true);
- }
- $this->schedule(20 * 15, [$this, "checkTicks"], [], true);
- $this->schedule(20 * 60, [$this, "checkMemory"], [], true);
- $this->schedule(20 * 45, "Cache::cleanup", [], true);
- $this->schedule(20, [$this, "asyncOperationChecker"], [], true);
- }
-
- public function schedule($ticks, callable $callback, $data = [], $repeat = false, $eventName = "server.schedule"){
- if(!is_callable($callback)){
- return false;
- }
- $chcnt = $this->scheduleCnt++;
- $this->schedule[$chcnt] = [$callback, $data, $eventName];
- $this->query("INSERT INTO actions (ID, interval, last, repeat) VALUES(" . $chcnt . ", " . ($ticks / 20) . ", " . microtime(true) . ", " . (((bool) $repeat) === true ? 1 : 0) . ");");
- return $chcnt;
- }
-
- /**
- * @return string
- */
- public function getGamemode(){
- switch($this->gamemode){
- case SURVIVAL:
- return "survival";
- case CREATIVE:
- return "creative";
- case ADVENTURE:
- return "adventure";
- case VIEW:
- return "view";
- }
- }
-
- public function process()
- {
- $lastLoop = 0;
- while($this->stop === false){
- $packet = $this->interface->readPacket();
- if($packet instanceof Packet){
- $this->packetHandler($packet);
- $lastLoop = 0;
- } elseif($this->tick() > 0){
- $lastLoop = 0;
- } else{
- ++ $lastLoop;
- if($lastLoop < 16){
- usleep(1);
- } elseif($lastLoop < 128){
- usleep(100);
- } elseif($lastLoop < 256){
- usleep(512);
- } else{
- usleep(10000);
- }
- }
- $this->tick();
- }
- }
-
- public function packetHandler(Packet $packet){
- $data =& $packet;
- $CID = PocketMinecraftServer::clientID($packet->ip, $packet->port);
- if(isset($this->clients[$CID])){
- $this->clients[$CID]->handlePacket($packet);
- }else{
- if($this->handle("server.noauthpacket." . $packet->pid(), $packet) === false){
- return;
- }
- switch($packet->pid()){
- case RakNetInfo::UNCONNECTED_PING:
- case RakNetInfo::UNCONNECTED_PING_OPEN_CONNECTIONS:
- if($this->invisible === true){
- $pk = new RakNetPacket(RakNetInfo::UNCONNECTED_PONG);
- $pk->pingID = $packet->pingID;
- $pk->serverID = $this->serverID;
- $pk->serverType = $this->serverType;
- $pk->ip = $packet->ip;
- $pk->port = $packet->port;
- $this->send($pk);
- break;
- }
- if(!isset($this->custom["times_" . $CID])){
- $this->custom["times_" . $CID] = 0;
- }
- $ln = 15;
- if($this->description == "" or substr($this->description, -1) != " "){
- $this->description .= " ";
- }
- $txt = substr($this->description, $this->custom["times_" . $CID], $ln);
- $txt .= substr($this->description, 0, $ln - strlen($txt));
- $pk = new RakNetPacket(RakNetInfo::UNCONNECTED_PONG);
- $pk->pingID = $packet->pingID;
- $pk->serverID = $this->serverID;
- $pk->serverType = $this->serverType . $this->name . " [" . count($this->clients) . "/" . $this->maxClients . "] " . $txt;
- $pk->ip = $packet->ip;
- $pk->port = $packet->port;
- $this->send($pk);
- $this->custom["times_" . $CID] = ($this->custom["times_" . $CID] + 1) % strlen($this->description);
- break;
- case RakNetInfo::OPEN_CONNECTION_REQUEST_1:
- if($packet->structure !== RakNetInfo::STRUCTURE){
- console("[DEBUG] Incorrect structure #" . $packet->structure . " from " . $packet->ip . ":" . $packet->port, true, true, 2);
- $pk = new RakNetPacket(RakNetInfo::INCOMPATIBLE_PROTOCOL_VERSION);
- $pk->serverID = $this->serverID;
- $pk->ip = $packet->ip;
- $pk->port = $packet->port;
- $this->send($pk);
- }else{
- $pk = new RakNetPacket(RakNetInfo::OPEN_CONNECTION_REPLY_1);
- $pk->serverID = $this->serverID;
- $pk->mtuSize = strlen($packet->buffer);
- $pk->ip = $packet->ip;
- $pk->port = $packet->port;
- $this->send($pk);
- }
- break;
- case RakNetInfo::OPEN_CONNECTION_REQUEST_2:
- if($this->invisible === true){
- break;
- }
-
- $this->clients[$CID] = new Player($packet->clientID, $packet->ip, $packet->port, $packet->mtuSize); //New Session!
- $pk = new RakNetPacket(RakNetInfo::OPEN_CONNECTION_REPLY_2);
- $pk->serverID = $this->serverID;
- $pk->port = $this->port;
- $pk->mtuSize = $packet->mtuSize;
- $pk->ip = $packet->ip;
- $pk->port = $packet->port;
- $this->send($pk);
- break;
- }
- }
- }
-
- public static function clientID($ip, $port){
- return crc32($ip . $port) ^ crc32($port . $ip . BOOTUP_RANDOM);
- //return $ip . ":" . $port;
- }
-
- public function send(Packet $packet){
- return $this->interface->writePacket($packet);
- }
-
- public function tick(){
- $time = microtime(true);
- if($this->lastTick <= ($time - 0.05)){
- $this->tickMeasure[] = $this->lastTick = $time;
- unset($this->tickMeasure[key($this->tickMeasure)]);
- ++$this->ticks;
- foreach($this->api->level->levels as $l){
- $l->onTick($this);
- }
- return $this->tickerFunction($time);
- }
- return 0;
- }
-
- public function tickerFunction($time){
- //actions that repeat every x time will go here
- $this->preparedSQL->selectActions->reset();
- $this->preparedSQL->selectActions->bindValue(":time", $time, SQLITE3_FLOAT);
- $actions = $this->preparedSQL->selectActions->execute();
-
- $actionCount = 0;
- if($actions instanceof SQLite3Result){
- while(($action = $actions->fetchArray(SQLITE3_ASSOC)) !== false){
- $cid = $action["ID"];
- $this->preparedSQL->updateAction->reset();
- $this->preparedSQL->updateAction->bindValue(":time", $time, SQLITE3_FLOAT);
- $this->preparedSQL->updateAction->bindValue(":id", $cid, SQLITE3_INTEGER);
- $this->preparedSQL->updateAction->execute();
- if(!isset($this->schedule[$cid]) || !isset($this->schedule[$cid][0]) || !@is_callable($this->schedule[$cid][0])){
- $return = false;
- }else{
- ++$actionCount;
- $return = call_user_func($this->schedule[$cid][0], $this->schedule[$cid][1], $this->schedule[$cid][2]);
- }
-
- if($action["repeat"] == 0 or $return === false){
- $this->query("DELETE FROM actions WHERE ID = " . $action["ID"] . ";");
- $this->schedule[$cid] = null;
- unset($this->schedule[$cid]);
- }
- }
- $actions->finalize();
- }
- return $actionCount;
- }
-
- public function dumpError(){
- if($this->stop === true){
- return;
- }
- ini_set("memory_limit", "-1"); //Fix error dump not dumped on memory problems
- console("[SEVERE] An unrecovereable has ocurred and the server has crashed. Creating an error dump");
- $dump = "```\r\n# NostalgiaCore Error Dump " . date("D M j H:i:s T Y") . "\r\n";
- $er = error_get_last();
- $errorConversion = [
- 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",
- ];
- $er["type"] = isset($errorConversion[$er["type"]]) ? $errorConversion[$er["type"]] : $er["type"];
- $dump .= "Error: " . var_export($er, true) . "\r\n\r\n";
- if(stripos($er["file"], "plugin") !== false){
- $dump .= "THIS ERROR WAS CAUSED BY A PLUGIN. REPORT IT TO THE PLUGIN DEVELOPER.\r\n";
- }
-
- $dump .= "Code: \r\n";
- $file = @file($er["file"], FILE_IGNORE_NEW_LINES);
- for($l = max(0, $er["line"] - 10); $l < $er["line"] + 10; ++$l){
- $dump .= "[" . ($l + 1) . "] " . @$file[$l] . "\r\n";
- }
- $dump .= "\r\n\r\n";
- $dump .= "Backtrace: \r\n";
- foreach(getTrace() as $line){
- $dump .= "$line\r\n";
- }
- $dump .= "\r\n\r\n";
- $dump .= "NostalgiaCore version: " . MAJOR_VERSION . " [Protocol " . ProtocolInfo::CURRENT_PROTOCOL . "; API " . CURRENT_API_VERSION . "]\r\n";
- $dump .= "Git commit: " . GIT_COMMIT . "\r\n";
- $dump .= "Source SHA1 sum: " . SOURCE_SHA1SUM . "\r\n";
- $dump .= "uname -a: " . php_uname("a") . "\r\n";
- $dump .= "PHP Version: " . phpversion() . "\r\n";
- $dump .= "Zend version: " . zend_version() . "\r\n";
- $dump .= "OS : " . PHP_OS . ", " . Utils::getOS() . "\r\n";
- $dump .= "Debug Info: " . var_export($this->debugInfo(false), true) . "\r\n\r\n\r\n";
- global $arguments;
- $dump .= "Parameters: " . var_export($arguments, true) . "\r\n\r\n\r\n";
- $p = $this->api->getProperties();
- if($p["rcon.password"] != ""){
- $p["rcon.password"] = "******";
- }
- $dump .= "server.properties: " . var_export($p, true) . "\r\n\r\n\r\n";
- if($this->api->plugin instanceof PluginAPI){
- $plist = $this->api->plugin->getList();
- $dump .= "Loaded plugins:\r\n";
- foreach($plist as $p){
- $dump .= $p["name"] . " " . $p["version"] . " by " . $p["author"] . "\r\n";
- }
- $dump .= "\r\n\r\n";
- }
-
- $extensions = [];
- foreach(get_loaded_extensions() as $ext){
- $extensions[$ext] = phpversion($ext);
- }
-
- $dump .= "Loaded Modules: " . var_export($extensions, true) . "\r\n";
- $this->checkMemory();
- $dump .= "Memory Usage Tracking: \r\n" . chunk_split(base64_encode(gzdeflate(implode(";", $this->memoryStats), 9))) . "\r\n";
- ob_start();
- phpinfo();
- $dump .= "\r\nphpinfo(): \r\n" . chunk_split(base64_encode(gzdeflate(ob_get_contents(), 9))) . "\r\n";
- ob_end_clean();
- $dump .= "\r\n```";
- $name = "Error_Dump_" . date("D_M_j-H.i.s-T_Y");
- logg($dump, $name, true, 0, true);
- console("[SEVERE] Please submit the \"{$name}.log\" file to the Bug Reporting page. Give as much info as you can.", true, true, 0);
- }
-
- public function debugInfo($console = false){
- $info = [];
- $info["tps"] = $this->getTPS();
- $info["memory_usage"] = round((memory_get_usage() / 1024) / 1024, 2) . "MB";
- $info["memory_peak_usage"] = round((memory_get_peak_usage() / 1024) / 1024, 2) . "MB";
- $info["entities"] = $this->query("SELECT count(EID) as count FROM entities;", true);
- $info["entities"] = $info["entities"]["count"];
- $info["players"] = $this->query("SELECT count(CID) as count FROM players;", true);
- $info["players"] = $info["players"]["count"];
- $info["events"] = count($this->eventsID);
- $info["handlers"] = $this->query("SELECT count(ID) as count FROM handlers;", true);
- $info["handlers"] = $info["handlers"]["count"];
- $info["actions"] = $this->query("SELECT count(ID) as count FROM actions;", true);
- $info["actions"] = $info["actions"]["count"];
- $info["garbage"] = gc_collect_cycles();
- $this->handle("server.debug", $info);
- if($console === true){
- console("[DEBUG] TPS: " . $info["tps"] . ", Memory usage: " . $info["memory_usage"] . " (Peak " . $info["memory_peak_usage"] . "), Entities: " . $info["entities"] . ", Events: " . $info["events"] . ", Handlers: " . $info["handlers"] . ", Actions: " . $info["actions"] . ", Garbage: " . $info["garbage"], true, true, 2);
- }
- return $info;
- }
-
- public function checkMemory(){
- $info = $this->debugInfo();
- $data = $info["memory_usage"] . "," . $info["players"] . "," . $info["entities"];
- $i = count($this->memoryStats) - 1;
- if($i < 0 or $this->memoryStats[$i] !== $data){
- $this->memoryStats[] = $data;
- }
- }
-
- public function event($event, callable $func){
- if(!is_callable($func)){
- return false;
- }elseif(isset(Deprecation::$events[$event])){
- $sub = "";
- if(Deprecation::$events[$event] !== false){
- $sub = " Substitute \"" . Deprecation::$events[$event] . "\" found.";
- }
- console("[ERROR] Event \"$event\" has been deprecated.$sub [Attach to " . (is_array($func) ? get_class($func[0]) . "::" . $func[1] : $func) . "]");
- }
- $evid = $this->evCnt++;
- if(!isset($this->events[$event])){
- $this->events[$event] = [];
- }
- $this->events[$event][$evid] = $func;
- $this->eventsID[$evid] = $event;
- console("[INTERNAL] Attached " . (is_array($func) ? get_class($func[0]) . "::" . $func[1] : $func) . " to event " . $event . " (ID " . $evid . ")", true, true, 3);
- return $evid;
- }
-}
\ No newline at end of file
diff --git a/src/astarnavigator/IElement.php b/src/astarnavigator/IElement.php
deleted file mode 100644
index 4357c6ab..00000000
--- a/src/astarnavigator/IElement.php
+++ /dev/null
@@ -1,7 +0,0 @@
-x = $x;
- $this->y = $y;
- }
-
- public function equals(PathTile $t){
- return $t->x === $this->x && $t->y === $this->y;
- }
-
- public function addOffset($offset){
- $this->x += $offset[0];
- $this->y += $offset[1];
- return $this;
- }
-
- public function __toString(){
- return $this->x.":".$this->y;
- }
-
-}
-
diff --git a/src/astarnavigator/PathTileXYZ.php b/src/astarnavigator/PathTileXYZ.php
deleted file mode 100644
index 90ec4c98..00000000
--- a/src/astarnavigator/PathTileXYZ.php
+++ /dev/null
@@ -1,39 +0,0 @@
-x = floor($x);
- $this->y = floor($y);
- $this->z = floor($z);
- $this->level = $level;
- }
-
- public function equals(PathTile $t){
- return $t->x === $this->x && $t->y === $this->y && $t->z === $this->z;
- }
-
- public function asVector(){
- return new Vector3($this->x, $this->y, $this->z);
- }
-
- public function asArray(){
- return ["x" => $this->x, "y" => $this->y, "z" => $this->z];
- }
-
- public function addOffset($offset){
- return new PathTileXYZ($this->x + $offset[0], $this->y + $offset[1], $this->z + $offset[2], $this->level);
- }
-
- public function __toString(){
- return $this->x.":".$this->y.":".$this->z;
- }
-}
-
diff --git a/src/astarnavigator/TileNavigator.php b/src/astarnavigator/TileNavigator.php
deleted file mode 100644
index 67077bc7..00000000
--- a/src/astarnavigator/TileNavigator.php
+++ /dev/null
@@ -1,82 +0,0 @@
-blockedProvider = $blockedProvider;
- $this->neighborProvider = $neighborProvider;
- $this->distanceAlgorithm = $distanceAlgorithm;
- }
-
- public function reconstructPath($path, $current){
- $totalPath = [$current];
- while (isset($path[(string)$current]))
- {
- $current = $path[(string)$current];
- $totalPath[] = $current;
- }
- //foreach(array_unique($path) as $k => $p) console($k.":".$p);
- //foreach($totalPath as $k => $p) console($k.":".$p);
- array_pop($totalPath);
- return array_reverse($totalPath);
- }
-
- public function navigate(PathTile $from, PathTile $to, $maxDist)
- {
- $open = new SplPriorityQueue();
- $open->insert($from, 0);
- $path = [];
- $gScore = [];
- $gScore[(string) $from] = 0;
- $has = [(string)$from, true];
- if($this->blockedProvider->isBlocked($to)){
- return null;
- }
- $visited = [];
- $maxDist*=$maxDist; //no square root
- while(!$open->isEmpty())
- {
- $current = $open->top();
- $open->next();
- if ($current == $to){
-
- return $this->reconstructPath($path, $current);
- }
- foreach($this->neighborProvider->getNeighbors($current) as $neighbor)
- {
- if(!Utils::in_range(Utils::distance_noroot($neighbor->asArray(), $from->asArray()), -$maxDist, $maxDist)){
- continue;
- }
- if(isset($visited[(string)$neighbor])){
- continue;
- }
-
- $visited[(string)$neighbor] = $neighbor;
- $distbetweenCost = $this->distanceAlgorithm->calculate($current, $neighbor);
- $tentativeG = $gScore[(string) $current] + $distbetweenCost;
- if (!isset($has[(string)$neighbor]))
- {
- $open->insert($neighbor, -$tentativeG);
- $has[(string)$neighbor] = true;
- }
- else if ($tentativeG >= $gScore[(string) $neighbor])
- {
- continue;
- }
- if(!isset($gScore[(string) $neighbor]) || $distbetweenCost < $gScore[(string) $neighbor]){
- $path[(string) $neighbor] = $current;
- }
-
- $gScore[(string) $neighbor] = $tentativeG;
- }
- }
-
- return null;
- }
-
-
-}
-
diff --git a/src/astarnavigator/algorithms/IDistanceAlgorithm.php b/src/astarnavigator/algorithms/IDistanceAlgorithm.php
deleted file mode 100644
index 391c629a..00000000
--- a/src/astarnavigator/algorithms/IDistanceAlgorithm.php
+++ /dev/null
@@ -1,7 +0,0 @@
-asArray(), $to->asArray());
- }
- return 666;
- }
-
-}
-
diff --git a/src/astarnavigator/algorithms/Pythagoras3D.php b/src/astarnavigator/algorithms/Pythagoras3D.php
deleted file mode 100644
index 7651a3ac..00000000
--- a/src/astarnavigator/algorithms/Pythagoras3D.php
+++ /dev/null
@@ -1,16 +0,0 @@
-asArray(), $to->asArray());
- }
- return INF;
- }
-
-}
-
diff --git a/src/astarnavigator/providers/IBlockedProvider.php b/src/astarnavigator/providers/IBlockedProvider.php
deleted file mode 100644
index 40adf01b..00000000
--- a/src/astarnavigator/providers/IBlockedProvider.php
+++ /dev/null
@@ -1,12 +0,0 @@
-level->getBlockWithoutVector($tile->x, $tile->y, $tile->z);
- return $b instanceof Block && $b->isSolid;
- }
- return false;
- }
-
-}
-
diff --git a/src/astarnavigator/providers/MCDiagonalProvider.php b/src/astarnavigator/providers/MCDiagonalProvider.php
deleted file mode 100644
index 811c6838..00000000
--- a/src/astarnavigator/providers/MCDiagonalProvider.php
+++ /dev/null
@@ -1,34 +0,0 @@
-addOffset($offset);
- if(!$tile->level->getBlockWithoutVector($pnt->x, $pnt->y, $pnt->z, false)->isSolid){
- if(!$tile->level->getBlockWithoutVector($pnt->x, $pnt->y - 1, $pnt->z, false)->isSolid){
- --$pnt->y;
- }
- $pnts[] = $pnt;
- }else{
- if(!$tile->level->getBlockWithoutVector($pnt->x, $pnt->y + 1, $pnt->z, false)->isSolid){
- ++$pnt->y;
- $pnts[] = $pnt;
- }
- }
- }
- return $pnts;
- }
- return [];
- }
-
-
-}
-
diff --git a/src/build/compile.sh b/src/build/compile.sh
deleted file mode 100755
index 885898db..00000000
--- a/src/build/compile.sh
+++ /dev/null
@@ -1,389 +0,0 @@
-#!/bin/bash
-COMPILER_VERSION="0.16"
-
-PHP_VERSION="5.5.9"
-ZEND_VM="GOTO"
-
-LIBEDIT_VERSION="0.3"
-ZLIB_VERSION="1.2.8"
-PTHREADS_VERSION="0.1.0"
-PHPYAML_VERSION="1.1.1"
-YAML_VERSION="0.1.4"
-CURL_VERSION="curl-7_35_0"
-
-echo "[PocketMine] PHP installer and compiler for Linux & Mac"
-DIR="$(pwd)"
-date > "$DIR/install.log" 2>&1
-uname -a >> "$DIR/install.log" 2>&1
-echo "[INFO] Checking dependecies"
-type make >> "$DIR/install.log" 2>&1 || { echo >&2 "[ERROR] Please install \"make\""; read -p "Press [Enter] to continue..."; exit 1; }
-type autoconf >> "$DIR/install.log" 2>&1 || { echo >&2 "[ERROR] Please install \"autoconf\""; read -p "Press [Enter] to continue..."; exit 1; }
-type automake >> "$DIR/install.log" 2>&1 || { echo >&2 "[ERROR] Please install \"automake\""; read -p "Press [Enter] to continue..."; exit 1; }
-type libtool >> "$DIR/install.log" 2>&1 || { echo >&2 "[ERROR] Please install \"libtool\""; read -p "Press [Enter] to continue..."; exit 1; }
-type m4 >> "$DIR/install.log" 2>&1 || { echo >&2 "[ERROR] Please install \"m4\""; read -p "Press [Enter] to continue..."; exit 1; }
-type wget >> "$DIR/install.log" 2>&1 || type curl >> "$DIR/install.log" 2>&1 || { echo >&2 "[ERROR] Please install \"wget\" or \"curl\""; read -p "Press [Enter] to continue..."; exit 1; }
-type getconf >> "$DIR/install.log" 2>&1 || { echo >&2 "[ERROR] Please install \"getconf\""; read -p "Press [Enter] to continue..."; exit 1; }
-
-#Needed to use aliases
-shopt -s expand_aliases
-type wget >> "$DIR/install.log" 2>&1
-if [ $? -eq 0 ]; then
- alias download_file="wget --no-check-certificate -q -O -"
-else
- type curl >> "$DIR/install.log" 2>&1
- if [ $? -eq 0 ]; then
- alias download_file="curl --insecure --silent --location"
- else
- echo "error, curl or wget not found"
- fi
-fi
-
-export CC="gcc"
-COMPILE_FOR_ANDROID=no
-RANLIB=ranlib
-HAVE_MYSQLI="--with-mysqli=mysqlnd"
-if [ "$1" == "rpi" ]; then
- [ -z "$march" ] && march=armv6zk;
- [ -z "$mtune" ] && mtune=arm1176jzf-s;
- [ -z "$CFLAGS" ] && CFLAGS="-mfloat-abi=hard -mfpu=vfp";
- echo "[INFO] Compiling for Raspberry Pi ARMv6zk hard float"
-elif [ "$1" == "mac" ]; then
- [ -z "$march" ] && march=prescott;
- [ -z "$mtune" ] && mtune=generic;
- [ -z "$CFLAGS" ] && CFLAGS="-fomit-frame-pointer";
- echo "[INFO] Compiling for Intel MacOS"
-elif [ "$1" == "ios" ]; then
- [ -z "$march" ] && march=armv6;
- [ -z "$mtune" ] && mtune=cortex-a8;
- echo "[INFO] Compiling for iOS ARMv6"
-elif [ "$1" == "crosscompile" ]; then
- HAVE_MYSQLI="--without-mysqli"
- if [ "$2" == "android" ] || [ "$2" == "android-armv6" ]; then
- COMPILE_FOR_ANDROID=yes
- [ -z "$march" ] && march=armv6;
- [ -z "$mtune" ] && mtune=arm1136jf-s;
- TOOLCHAIN_PREFIX="arm-unknown-linux-uclibcgnueabi"
- export CC="$TOOLCHAIN_PREFIX-gcc"
- CONFIGURE_FLAGS="--host=$TOOLCHAIN_PREFIX --enable-static-link --disable-ipv6"
- CFLAGS="-uclibc --static $CFLAGS";
- LDFLAGS="--static"
- echo "[INFO] Cross-compiling for Android ARMv6"
- elif [ "$2" == "android-armv7" ]; then
- COMPILE_FOR_ANDROID=yes
- [ -z "$march" ] && march=armv7-a;
- [ -z "$mtune" ] && mtune=cortex-a8;
- TOOLCHAIN_PREFIX="arm-unknown-linux-uclibcgnueabi"
- export CC="$TOOLCHAIN_PREFIX-gcc"
- CONFIGURE_FLAGS="--host=$TOOLCHAIN_PREFIX --enable-static-link --disable-ipv6"
- CFLAGS="-uclibc --static $CFLAGS";
- LDFLAGS="--static"
- echo "[INFO] Cross-compiling for Android ARMv7"
- elif [ "$2" == "rpi" ]; then
- TOOLCHAIN_PREFIX="arm-linux-gnueabihf"
- [ -z "$march" ] && march=armv6zk;
- [ -z "$mtune" ] && mtune=arm1176jzf-s;
- [ -z "$CFLAGS" ] && CFLAGS="-mfloat-abi=hard -mfpu=vfp";
- export CC="$TOOLCHAIN_PREFIX-gcc"
- CONFIGURE_FLAGS="--host=$TOOLCHAIN_PREFIX"
- [ -z "$CFLAGS" ] && CFLAGS="-uclibc";
- echo "[INFO] Cross-compiling for Raspberry Pi ARMv6zk hard float"
- elif [ "$2" == "mac" ]; then
- [ -z "$march" ] && march=prescott;
- [ -z "$mtune" ] && mtune=generic;
- [ -z "$CFLAGS" ] && CFLAGS="-fomit-frame-pointer";
- TOOLCHAIN_PREFIX="i686-apple-darwin10"
- export CC="$TOOLCHAIN_PREFIX-gcc"
- CONFIGURE_FLAGS="--host=$TOOLCHAIN_PREFIX"
- #zlib doesn't use the correct ranlib
- RANLIB=$TOOLCHAIN_PREFIX-ranlib
- echo "[INFO] Cross-compiling for Intel MacOS"
- elif [ "$2" == "ios" ] || [ "$2" == "ios-armv6" ]; then
- [ -z "$march" ] && march=armv6;
- [ -z "$mtune" ] && mtune=generic-armv6;
- CONFIGURE_FLAGS="--target=arm-apple-darwin10"
- elif [ "$2" == "ios-armv7" ]; then
- [ -z "$march" ] && march=armv7-a;
- [ -z "$mtune" ] && mtune=generic-armv7-a;
- CONFIGURE_FLAGS="--target=arm-apple-darwin10"
- else
- echo "Please supply a proper platform [android android-armv6 android-armv7 rpi mac ios ios-armv6 ios-armv7] to cross-compile"
- exit 1
- fi
-elif [ -z "$CFLAGS" ]; then
- if [ `getconf LONG_BIT` = "64" ]; then
- echo "[INFO] Compiling for current machine using 64-bit"
- CFLAGS="-m64 $CFLAGS"
- else
- echo "[INFO] Compiling for current machine using 32-bit"
- CFLAGS="-m32 $CFLAGS"
- fi
-fi
-
-cat > test.c <<'CTEST'
-#include
-main(){
- printf("Hello world\n");
-}
-CTEST
-
-
-type $CC >> "$DIR/install.log" 2>&1 || { echo >&2 "[ERROR] Please install \"$CC\""; read -p "Press [Enter] to continue..."; exit 1; }
-
-[ -z "$THREADS" ] && THREADS=1;
-[ -z "$march" ] && march=native;
-[ -z "$mtune" ] && mtune=native;
-[ -z "$CFLAGS" ] && CFLAGS="";
-[ -z "$LDFLAGS" ] && LDFLAGS="";
-[ -z "$CONFIGURE_FLAGS" ] && CONFIGURE_FLAGS="";
-
-
-if [ "$mtune" != "none" ]; then
- $CC -march=$march -mtune=$mtune $CFLAGS -o test test.c >> "$DIR/install.log" 2>&1
- if [ $? -eq 0 ]; then
- CFLAGS="-march=$march -mtune=$mtune -fno-gcse $CFLAGS"
- fi
-else
- $CC -march=$march $CFLAGS -o test test.c >> "$DIR/install.log" 2>&1
- if [ $? -eq 0 ]; then
- CFLAGS="-march=$march -fno-gcse $CFLAGS"
- fi
-fi
-
-rm test >> "$DIR/install.log" 2>&1
-rm test.c >> "$DIR/install.log" 2>&1
-
-export CFLAGS="-O2 $CFLAGS"
-export LDFLAGS="$LDFLAGS"
-
-rm -r -f install_data/ >> "$DIR/install.log" 2>&1
-rm -r -f bin/ >> "$DIR/install.log" 2>&1
-mkdir -m 0777 install_data >> "$DIR/install.log" 2>&1
-mkdir -m 0777 bin >> "$DIR/install.log" 2>&1
-cd install_data
-set -e
-
-#PHP 5
-echo -n "[PHP] downloading $PHP_VERSION..."
-download_file "http://php.net/get/php-$PHP_VERSION.tar.gz/from/this/mirror" | tar -zx >> "$DIR/install.log" 2>&1
-mv php-$PHP_VERSION php
-echo " done!"
-
-if [ 1 ] || [ "$1" == "crosscompile" ] || [ "$1" == "rpi" ]; then
- HAVE_LIBEDIT="--without-libedit"
-else
- #libedit
- echo -n "[libedit] downloading $LIBEDIT_VERSION..."
- download_file "http://download.sourceforge.net/project/libedit/libedit/libedit-$LIBEDIT_VERSION/libedit-$LIBEDIT_VERSION.tar.gz" | tar -zx >> "$DIR/install.log" 2>&1
- echo -n " checking..."
- cd libedit
- ./configure --prefix="$DIR/install_data/php/ext/libedit" --enable-static >> "$DIR/install.log" 2>&1
- echo -n " compiling..."
- if make -j $THREADS >> "$DIR/install.log" 2>&1; then
- echo -n " installing..."
- make install >> "$DIR/install.log" 2>&1
- HAVE_LIBEDIT="--with-libedit=\"$DIR/install_data/php/ext/libedit\""
- else
- echo -n " disabling..."
- HAVE_LIBEDIT="--without-libedit"
- fi
- echo -n " cleaning..."
- cd ..
- rm -r -f ./libedit
- echo " done!"
-fi
-
-#zlib
-echo -n "[zlib] downloading $ZLIB_VERSION..."
-download_file "http://zlib.net/zlib-$ZLIB_VERSION.tar.gz" | tar -zx >> "$DIR/install.log" 2>&1
-mv zlib-$ZLIB_VERSION zlib
-echo -n " checking..."
-cd zlib
-RANLIB=$RANLIB ./configure --prefix="$DIR/install_data/php/ext/zlib" \
---static >> "$DIR/install.log" 2>&1
-echo -n " compiling..."
-make -j $THREADS >> "$DIR/install.log" 2>&1
-echo -n " installing..."
-make install >> "$DIR/install.log" 2>&1
-echo -n " cleaning..."
-cd ..
-rm -r -f ./zlib
-echo " done!"
-
-if [ "$(uname -s)" == "Darwin" ] && [ "$1" != "crosscompile" ] && [ "$2" != "curl" ]; then
- HAVE_CURL="shared,/usr"
-else
- #curl
- echo -n "[cURL] downloading $CURL_VERSION..."
- download_file "https://github.com/bagder/curl/archive/$CURL_VERSION.tar.gz" | tar -zx >> "$DIR/install.log" 2>&1
- mv curl-$CURL_VERSION curl
- echo -n " checking..."
- cd curl
- if [ ! -f ./configure ]; then
- ./buildconf --force >> "$DIR/install.log" 2>&1
- fi
- ./configure --disable-dependency-tracking \
- --enable-ipv6 \
- --enable-optimize \
- --enable-http \
- --enable-ftp \
- --disable-dict \
- --enable-file \
- --disable-gopher \
- --disable-imap \
- --disable-pop3 \
- --disable-rtsp \
- --disable-smtp \
- --disable-telnet \
- --disable-tftp \
- --disable-ldap \
- --disable-ldaps \
- --without-libidn \
- --enable-threaded-resolver \
- --prefix="$DIR/install_data/php/ext/curl" \
- --disable-shared \
- --enable-static \
- $CONFIGURE_FLAGS >> "$DIR/install.log" 2>&1
- echo -n " compiling..."
- make -j $THREADS >> "$DIR/install.log" 2>&1
- echo -n " installing..."
- make install >> "$DIR/install.log" 2>&1
- echo -n " cleaning..."
- cd ..
- rm -r -f ./curl
- echo " done!"
- HAVE_CURL="$DIR/install_data/php/ext/curl"
-fi
-
-#pthreads
-echo -n "[PHP pthreads] downloading $PTHREADS_VERSION..."
-download_file "http://pecl.php.net/get/pthreads-$PTHREADS_VERSION.tgz" | tar -zx >> "$DIR/install.log" 2>&1
-mv pthreads-$PTHREADS_VERSION "$DIR/install_data/php/ext/pthreads"
-echo " done!"
-
-#PHP YAML
-echo -n "[PHP YAML] downloading $PHPYAML_VERSION..."
-download_file "http://pecl.php.net/get/yaml-$PHPYAML_VERSION.tgz" | tar -zx >> "$DIR/install.log" 2>&1
-mv yaml-$PHPYAML_VERSION "$DIR/install_data/php/ext/yaml"
-echo " done!"
-
-#YAML
-echo -n "[YAML] downloading $YAML_VERSION..."
-download_file "http://pyyaml.org/download/libyaml/yaml-$YAML_VERSION.tar.gz" | tar -zx >> "$DIR/install.log" 2>&1
-mv yaml-$YAML_VERSION yaml
-echo -n " checking..."
-cd yaml
-RANLIB=$RANLIB ./configure \
---prefix="$DIR/install_data/php/ext/yaml" \
---enable-static \
---disable-shared \
-$CONFIGURE_FLAGS >> "$DIR/install.log" 2>&1
-echo -n " compiling..."
-make -j $THREADS >> "$DIR/install.log" 2>&1
-echo -n " installing..."
-make install >> "$DIR/install.log" 2>&1
-echo -n " cleaning..."
-cd ..
-rm -r -f ./yaml
-echo " done!"
-
-echo -n "[PHP]"
-set +e
-if which free >/dev/null; then
- MAX_MEMORY=$(free -m | awk '/^Mem:/{print $2}')
-else
- MAX_MEMORY=$(top -l 1 | grep PhysMem: | awk '{print $10}' | tr -d 'a-zA-Z')
-fi
-if [ $MAX_MEMORY -gt 512 ] && [ "$1" != "crosscompile" ]; then
- echo -n " enabling optimizations..."
- OPTIMIZATION="--enable-inline-optimization "
-else
- OPTIMIZATION="--disable-inline-optimization "
-fi
-set -e
-echo -n " checking..."
-cd php
-rm -rf ./aclocal.m4 >> "$DIR/install.log" 2>&1
-rm -rf ./autom4te.cache/ >> "$DIR/install.log" 2>&1
-rm -f ./configure >> "$DIR/install.log" 2>&1
-./buildconf --force >> "$DIR/install.log" 2>&1
-if [ "$1" == "crosscompile" ]; then
- sed -i 's/pthreads_working=no/pthreads_working=yes/' ./configure
- export LIBS="-lpthread -ldl"
- CONFIGURE_FLAGS="$CONFIGURE_FLAGS --enable-opcache=no"
-
-fi
-./configure $OPTIMIZATION--prefix="$DIR/bin/php5" \
---exec-prefix="$DIR/bin/php5" \
---with-curl="$HAVE_CURL" \
---with-zlib="$DIR/install_data/php/ext/zlib" \
---with-zlib-dir="$DIR/install_data/php/ext/zlib" \
---with-yaml="$DIR/install_data/php/ext/yaml" \
-$HAVE_LIBEDIT \
---disable-libxml \
---disable-xml \
---disable-dom \
---disable-simplexml \
---disable-xmlreader \
---disable-xmlwriter \
---disable-cgi \
---disable-session \
---disable-debug \
---disable-phar \
---disable-pdo \
---without-pear \
---without-iconv \
---without-pdo-sqlite \
---enable-ctype \
---enable-sockets \
---enable-shared=no \
---enable-static=yes \
---enable-shmop \
---enable-pcntl \
---enable-pthreads \
---enable-maintainer-zts \
---enable-zend-signals \
-$HAVE_MYSQLI \
---enable-embedded-mysqli \
---enable-bcmath \
---enable-cli \
---enable-zip \
---with-zend-vm=$ZEND_VM \
-$CONFIGURE_FLAGS >> "$DIR/install.log" 2>&1
-echo -n " compiling..."
-if [ $COMPILE_FOR_ANDROID == "yes" ]; then
- sed -i 's/-export-dynamic/-all-static/g' Makefile
-fi
-make -j $THREADS >> "$DIR/install.log" 2>&1
-echo -n " installing..."
-make install >> "$DIR/install.log" 2>&1
-echo " generating php.ini..."
-
-TIMEZONE=$(date +%Z)
-touch "$DIR/bin/php5/lib/php.ini"
-if [ "$1" != "crosscompile" ]; then
- OPCACHE_PATH=$(find "$DIR/bin/php5" -name opcache.so)
- echo "zend_extension=\"$OPCACHE_PATH\"" >> "$DIR/bin/php5/lib/php.ini"
- echo "opcache.enable=1" >> "$DIR/bin/php5/lib/php.ini"
- echo "opcache.enable_cli=1" >> "$DIR/bin/php5/lib/php.ini"
- echo "opcache.save_comments=0" >> "$DIR/bin/php5/lib/php.ini"
- echo "opcache.fast_shutdown=1" >> "$DIR/bin/php5/lib/php.ini"
- echo "opcache.max_accelerated_files=4096" >> "$DIR/bin/php5/lib/php.ini"
- echo "opcache.interned_strings_buffer=8" >> "$DIR/bin/php5/lib/php.ini"
- echo "opcache.memory_consumption=128" >> "$DIR/bin/php5/lib/php.ini"
- echo "opcache.optimization_level=0xffffffff" >> "$DIR/bin/php5/lib/php.ini"
-fi
-if [ "$HAVE_CURL" == "shared,/usr" ]; then
- echo "extension=curl.so" >> "$DIR/bin/php5/lib/php.ini"
-fi
-echo "date.timezone=$TIMEZONE" >> "$DIR/bin/php5/lib/php.ini"
-echo "short_open_tag=0" >> "$DIR/bin/php5/lib/php.ini"
-echo "asp_tags=0" >> "$DIR/bin/php5/lib/php.ini"
-
-echo " done!"
-cd "$DIR"
-echo -n "[INFO] Cleaning up..."
-rm -r -f install_data/ >> "$DIR/install.log" 2>&1
-date >> "$DIR/install.log" 2>&1
-echo " done!"
-echo "[PocketMine] You should start the server now using \"./start.sh.\""
-echo "[PocketMine] If it doesn't work, please send the \"install.log\" file to the Bug Tracker."
diff --git a/src/build/installer.sh b/src/build/installer.sh
deleted file mode 100644
index 8c043ccb..00000000
--- a/src/build/installer.sh
+++ /dev/null
@@ -1,61 +0,0 @@
-#!/bin/bash
-echo "==================================="
-echo "NostalgiaCore Installer"
-echo "==================================="
-echo "["$(date +%k:%M)"] Downloading NostalgiaCore..."
-apt install git
-git clone https://github.com/kotyaralih/NostalgiaCore
-echo "["$(date +%k:%M)"] Extracting..."
-cd NostalgiaCore
-mv * ../
-cd ../
-rm -r NostalgiaCore
-rm bin.7z
-echo "["$(date +%k:%M)"] Downloading PHP..."
-arch=$(uname -m)
-if [[ $arch == x86_64* ]]; then
- echo "X64 Architecture"
- wget https://owouwu.ru/NC_bin.tar.gz > /dev/null
- tar -xvf NC_bin.tar.gz
- rm NC_bin.tar.gz
-elif [[ $arch == i*86 ]]; then
- echo "X32 Architecture"
- wget https://owouwu.ru/NC_bin.tar.gz > /dev/null
- tar -xvf NC_bin.tar.gz
- rm NC_bin.tar.gz
-elif [[ $arch == arm* ]] || [[ $arch = aarch* ]]; then
- echo "ARM Architecture"
- wget https://owouwu.ru/NCArm_bin.tar.gz > /dev/null
- tar -xvf NCArm_bin.tar.gz
- rm NCArm_bin.tar.gz
-fi
-if [ $(./bin/php5/bin/php -r 'echo "yes";' 2>/dev/null) == "yes" ]; then
- OPCACHE_PATH="$(find $(pwd) -name opcache.so)"
- XDEBUG_PATH="$(find $(pwd) -name xdebug.so)"
- echo "" > "./bin/php5/bin/php.ini"
- #UOPZ_PATH="$(find $(pwd) -name uopz.so)"
- #echo "zend_extension=\"$UOPZ_PATH\"" >> "./bin/php5/bin/php.ini"
- echo "zend_extension=\"$OPCACHE_PATH\"" >> "./bin/php5/bin/php.ini"
- echo "zend_extension=\"$XDEBUG_PATH\"" >> "./bin/php5/bin/php.ini"
- echo "opcache.enable=1" >> "./bin/php5/bin/php.ini"
- echo "opcache.enable_cli=1" >> "./bin/php5/bin/php.ini"
- echo "opcache.save_comments=0" >> "./bin/php5/bin/php.ini"
- echo "opcache.fast_shutdown=1" >> "./bin/php5/bin/php.ini"
- echo "opcache.max_accelerated_files=4096" >> "./bin/php5/bin/php.ini"
- echo "opcache.interned_strings_buffer=8" >> "./bin/php5/bin/php.ini"
- echo "opcache.memory_consumption=128" >> "./bin/php5/bin/php.ini"
- echo "opcache.optimization_level=0xffffffff" >> "./bin/php5/bin/php.ini"
- echo "date.timezone=$TIMEZONE" >> "./bin/php5/bin/php.ini"
- echo "short_open_tag=0" >> "./bin/php5/bin/php.ini"
- echo "asp_tags=0" >> "./bin/php5/bin/php.ini"
- echo "phar.readonly=0" >> "./bin/php5/bin/php.ini"
- echo "phar.require_hash=1" >> "./bin/php5/bin/php.ini"
- echo "done"
- alldone=yes
-else
- echo "Invalid PHP build detected"
-fi
-echo "Done, starting..."
-echo "Wait >15 seconds..."
-chmod +x start.sh
-bash start.sh
diff --git a/src/build/jenkins.sh b/src/build/jenkins.sh
deleted file mode 100644
index e52d67c8..00000000
--- a/src/build/jenkins.sh
+++ /dev/null
@@ -1,182 +0,0 @@
-#!/bin/bash -x
-export PATH=/opt/arm-2013.05/bin:/opt/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin:/opt/arm-unknown-linux-uclibcgnueabi/bin:$PATH
-export THREADS=2
-
-#Needed to use aliases
-shopt -s expand_aliases
-type wget > /dev/null 2>&1
-if [ $? -eq 0 ]; then
- alias download_file="wget --no-check-certificate -q -O -"
-else
- type curl >> /dev/null 2>&1
- if [ $? -eq 0 ]; then
- alias download_file="curl --insecure --silent --location"
- else
- echo "error, curl or wget not found"
- fi
-fi
-
-rm -rf $WORKSPACE/compile.sh
-download_file "https://github.com/PocketMine/PocketMine-MP/raw/master/src/build/compile.sh" > $WORKSPACE/compile.sh
-chmod +x $WORKSPACE/compile.sh
-SCRIPT="$WORKSPACE/compile.sh"
-ARCHIVE=$WORKSPACE/archive
-COMPILEDIR=$WORKSPACE/compile
-rm -rf $ARCHIVE $COMPILEDIR
-mkdir -p $ARCHIVE
-mkdir -p $COMPILEDIR
-
-if [ "$COMPILE_LINUX_32BIT" = "true" ];
-then
- mkdir -p {$COMPILEDIR,$ARCHIVE}/linux/32bit
- cd $COMPILEDIR/linux/32bit
-
- CFLAGS=-m32 march=i686 mtune=generic $SCRIPT
-
- cp -r $COMPILEDIR/linux/32bit/{install.log,bin/*,install_data/*} $ARCHIVE/linux/32bit/
- if [ ! -f $COMPILEDIR/linux/32bit/bin/php5/bin/php ]; then
- exit 1
- fi
-fi
-
-if [ "$COMPILE_LINUX_64BIT" = "true" ];
-then
- mkdir -p {$COMPILEDIR,$ARCHIVE}/linux/64bit
- cd $COMPILEDIR/linux/64bit
-
- $SCRIPT
-
- cp -r $COMPILEDIR/linux/64bit/{install.log,bin/*,install_data/*} $ARCHIVE/linux/64bit/
- if [ ! -f $COMPILEDIR/linux/64bit/bin/php5/bin/php ]; then
- exit 1
- fi
-fi
-
-if [ "$COMPILE_MAC" = "true" ];
-then
- mkdir -p {$COMPILEDIR,$ARCHIVE}/mac
- cd $COMPILEDIR/mac
-
- curl -L http://ftpmirror.gnu.org/libtool/libtool-2.4.2.tar.gz | tar -xz > /dev/null
- cd libtool-2.4.2
- ./configure --prefix="$COMPILEDIR/mac/libtool" > /dev/null
- make > /dev/null
- make install
- cd ../
- rm -rf libtool-2.4.2
- export LIBTOOL="$COMPILEDIR/mac/libtool/bin/libtool"
- export LIBTOOLIZE="$COMPILEDIR/mac/libtool/bin/libtoolize"
- $SCRIPT mac curl
-
- cp -r $COMPILEDIR/mac/{install.log,bin/*,install_data/*} $ARCHIVE/mac/
- if [ ! -f $COMPILEDIR/mac/bin/php5/bin/php ]; then
- exit 1
- fi
-fi
-
-if [ "$COMPILE_RPI" = "true" ];
-then
- mkdir -p {$COMPILEDIR,$ARCHIVE}/rpi
- cd $COMPILEDIR/rpi
-
- $SCRIPT rpi
-
- cp -r $COMPILEDIR/rpi/{install.log,bin/*,install_data/*} $ARCHIVE/rpi/
- if [ ! -f $COMPILEDIR/rpi/bin/php5/bin/php ]; then
- exit 1
- fi
-fi
-
-if [ "$CROSSCOMPILE_ANDROID_ARMV6" = "true" ];
-then
- mkdir -p {$COMPILEDIR,$ARCHIVE}/crosscompile/android-armv6
- cd $COMPILEDIR/crosscompile/android-armv6
-
- $SCRIPT crosscompile android-armv6
-
- cp -r $COMPILEDIR/crosscompile/android-armv6/{install.log,bin/*,install_data/*} $ARCHIVE/crosscompile/android-armv6/
- if [ ! -f $COMPILEDIR/crosscompile/android-armv6/bin/php5/bin/php ]; then
- exit 1
- fi
-fi
-
-if [ "$CROSSCOMPILE_ANDROID_ARMV7" = "true" ];
-then
- mkdir -p {$COMPILEDIR,$ARCHIVE}/crosscompile/android-armv7
- cd $COMPILEDIR/crosscompile/android-armv7
-
- $SCRIPT crosscompile android-armv7
-
- cp -r $COMPILEDIR/crosscompile/android-armv7/{install.log,bin/*,install_data/*} $ARCHIVE/crosscompile/android-armv7/
- if [ ! -f $COMPILEDIR/crosscompile/android-armv7/bin/php5/bin/php ]; then
- exit 1
- fi
-fi
-
-if [ "$CROSSCOMPILE_IOS_ARMV6" = "true" ];
-then
- mkdir -p {$COMPILEDIR,$ARCHIVE}/crosscompile/ios-armv6
- cd $COMPILEDIR/crosscompile/ios-armv6
- curl -L http://ftpmirror.gnu.org/libtool/libtool-2.4.2.tar.gz | tar -xz > /dev/null
- cd libtool-2.4.2
- ./configure --prefix="$COMPILEDIR/crosscompile/ios-armv6/libtool" > /dev/null
- make > /dev/null
- make install
- cd ../
- rm -rf libtool-2.4.2
- export LIBTOOL="$COMPILEDIR/crosscompile/ios-armv6/libtool/bin/libtool"
- export LIBTOOLIZE="$COMPILEDIR/crosscompile/ios-armv6/libtool/bin/libtoolize"
- PATH="/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:$PATH" $SCRIPT crosscompile ios-armv6
-
- cp -r $COMPILEDIR/crosscompile/ios-armv6/{install.log,bin/*,install_data/*} $ARCHIVE/crosscompile/ios-armv6/
- if [ ! -f $COMPILEDIR/crosscompile/ios-armv6/bin/php5/bin/php ]; then
- exit 1
- fi
-fi
-
-if [ "$CROSSCOMPILE_IOS_ARMV7" = "true" ];
-then
- mkdir -p {$COMPILEDIR,$ARCHIVE}/crosscompile/ios-armv7
- cd $COMPILEDIR/crosscompile/ios-armv7
- curl -L http://ftpmirror.gnu.org/libtool/libtool-2.4.2.tar.gz | tar -xz > /dev/null
- cd libtool-2.4.2
- ./configure --prefix="$COMPILEDIR/crosscompile/ios-armv7/libtool" > /dev/null
- make > /dev/null
- make install
- cd ../
- rm -rf libtool-2.4.2
- export LIBTOOL="$COMPILEDIR/crosscompile/ios-armv7/libtool/bin/libtool"
- export LIBTOOLIZE="$COMPILEDIR/crosscompile/ios-armv7/libtool/bin/libtoolize"
- PATH="/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:$PATH" $SCRIPT crosscompile ios-armv7
-
- cp -r $COMPILEDIR/crosscompile/ios-armv7/{install.log,bin/*,install_data/*} $ARCHIVE/crosscompile/ios-armv7/
- if [ ! -f $COMPILEDIR/crosscompile/ios-armv7/bin/php5/bin/php ]; then
- exit 1
- fi
-fi
-
-if [ "$CROSSCOMPILE_RPI" = "true" ];
-then
- mkdir -p {$COMPILEDIR,$ARCHIVE}/crosscompile/rpi
- cd $COMPILEDIR/crosscompile/rpi
-
- $SCRIPT crosscompile rpi
-
- cp -r $COMPILEDIR/crosscompile/rpi/{install.log,bin/*,install_data/*} $ARCHIVE/crosscompile/rpi/
- if [ ! -f $COMPILEDIR/crosscompile/rpi/bin/php5/bin/php ]; then
- exit 1
- fi
-fi
-
-if [ "$CROSSCOMPILE_MAC" = "true" ];
-then
- mkdir -p {$COMPILEDIR,$ARCHIVE}/crosscompile/mac
- cd $COMPILEDIR/crosscompile/mac
-
- $SCRIPT crosscompile mac curl
-
- cp -r $COMPILEDIR/crosscompile/mac/{install.log,bin/*,install_data/*} $ARCHIVE/crosscompile/mac/
- if [ ! -f $COMPILEDIR/crosscompile/mac/bin/php5/bin/php ]; then
- exit 1
- fi
-fi
diff --git a/src/config.php b/src/config.php
deleted file mode 100644
index cc63e55a..00000000
--- a/src/config.php
+++ /dev/null
@@ -1,61 +0,0 @@
-0.0, 0.5
-define("BIOME_MUSHROOM_ISLAND", 14);
-define("BIOME_MUSHROOM_ISLAND_SHORE", 15);
-define("BIOME_BEACH", 16);
-define("BIOME_DESERT_HILLS", 17);
-define("BIOME_FOREST_HILLS", 18);
-define("BIOME_TAIGA_HILLS", 19);
-define("BIOME_EXTREME_HILLS_EDGE", 20);
-define("BIOME_JUNGLE", 21);
-define("BIOME_JUNGLE_HILLS", 22);
-define("BIOME_JUNGLE_EDGE", 23);
-define("BIOME_DEEP_OCEAN", 24);
-define("BIOME_STONE_BEACH", 25);
-define("BIOME_COLD_BEACH", 26);
-define("BIOME_BIRCH_FOREST", 27);
-define("BIOME_BIRCH_FOREST_HILLS", 28);
-define("BIOME_ROOFED_FOREST", 29);
-define("BIOME_COLD_TAIGA", 30);
-define("BIOME_COLD_TAIGA_HILLS", 31);
-define("BIOME_MEGA_TAIGA", 32);
-define("BIOME_MEGA_TAIGA_HILLS", 33);
-define("BIOME_EXTREME_HILLS_PLUS", 34);
-define("BIOME_SAVANNA", 35);
-define("BIOME_SAVANNA_PLATEAU", 36);
-define("BIOME_MESA", 37);
-define("BIOME_MESA_PLATEAU_F", 38);
-define("BIOME_MESA_PLATEAU", 39);
-//define("BIOME_SUNFLOWER_PLAINS", 129); metioning not found
-
-//define("BIOME_ICE_PLAINS_SPIKES", 140); metioning not found
-
-define("BIOME_REDWOOD_TAIGA_MUTATED", 160); //mentioned, but cannot check id
-
-define("BIOME_MAX_BIOMES", 256);
diff --git a/src/constants/BlockEntityIDs.php b/src/constants/BlockEntityIDs.php
deleted file mode 100644
index 2d039b85..00000000
--- a/src/constants/BlockEntityIDs.php
+++ /dev/null
@@ -1,13 +0,0 @@
- 0){
- console("[ERROR] Use PHP >= 8.0.0", true, true, 0);
- ++$errors;
-}
-
-define("USE_NATIVE_RANDOM", version_compare("8.2.0", PHP_VERSION) <= 0);
-
-if(php_sapi_name() !== "cli"){
- console("[ERROR] You must run NostalgiaCore 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);
- ++$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(!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("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("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($errors > 0){
- console("[ERROR] Please use the installer provided on the homepage, or recompile PHP again.", true, true, 0);
- exit(1); //Exit with error
-}
-
-$sha1sum = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
-/***REM_START***/
-require_once(FILE_PATH . "/src/math/Vector3.php");
-require_once(FILE_PATH . "/src/math/AxisAlignedBB.php");
-require_once(FILE_PATH . "/src/world/Position.php");
-require_once(FILE_PATH . "/src/pmf/PMF.php");
-
-require_once(FILE_PATH . "/src/astarnavigator/IElement.php");
-require_once(FILE_PATH . "/src/astarnavigator/PHPUtils.php");
-require_once(FILE_PATH . "/src/astarnavigator/PathTile.php");
-
-require_once(FILE_PATH . "/src/astarnavigator/algorithms/IDistanceAlgorithm.php");
-require_once(FILE_PATH . "/src/astarnavigator/algorithms/Pythagoras3D.php");
-require_once(FILE_PATH . "/src/astarnavigator/algorithms/ManhattanHeuristic3D.php");
-
-require_once(FILE_PATH . "/src/astarnavigator/providers/INeighborProvider.php");
-require_once(FILE_PATH . "/src/astarnavigator/providers/MCDiagonalProvider.php");
-
-require_once(FILE_PATH . "/src/astarnavigator/providers/IBlockedProvider.php");
-require_once(FILE_PATH . "/src/astarnavigator/providers/MCBlockedProvider.php");
-
-require_once(FILE_PATH . "/src/astarnavigator/ITileNavigator.php");
-require_once(FILE_PATH . "/src/astarnavigator/TileNavigator.php");
-
-require_once(FILE_PATH . "/src/nbt/tag/NamedTag.php");
-
-require_once(FILE_PATH . "/src/entity/ai/tasks/TaskBase.php");
-require_once(FILE_PATH. "/src/entity/ai/tasks/TaskTempt.php");
-
-require_once(FILE_PATH . "/src/entity/Rideable.php");
-require_once(FILE_PATH . "/src/entity/Attachable.php");
-require_once(FILE_PATH . "/src/entity/Damageable.php");
-require_once(FILE_PATH . "/src/entity/Breedable.php");
-require_once(FILE_PATH . "/src/entity/Damageable.php");
-require_once(FILE_PATH . "/src/entity/Pathfindable.php");
-require_once(FILE_PATH . "/src/entity/Entity.php");
-require_once(FILE_PATH . "/src/entity/Living.php");
-require_once(FILE_PATH . "/src/entity/Creature.php");
-require_once(FILE_PATH . "/src/entity/Ageable.php");
-require_once(FILE_PATH . "/src/entity/Animal.php");
-
-require_once(FILE_PATH . "/src/world/MobSpawner.php");
-
-require_once(FILE_PATH . "/src/material/Item.php");
-require_once(FILE_PATH . "/src/material/item/base/ItemTool.php");
-require_once(FILE_PATH . "/src/material/item/base/ItemHoe.php");
-require_once(FILE_PATH . "/src/material/item/base/ItemPickaxe.php");
-require_once(FILE_PATH . "/src/material/item/base/ItemAxe.php");
-require_once(FILE_PATH . "/src/material/item/base/ItemShovel.php");
-require_once(FILE_PATH . "/src/material/item/base/ItemSword.php");
-require_once(FILE_PATH . "/src/material/item/armor/ArmorItem.php");
-
-require_once(FILE_PATH . "/src/structure/Structure.php");
-require_once(FILE_PATH . "/src/world/generator/Populator.php");
-require_once(FILE_PATH . "/src/world/generator/LevelGenerator.php");
-
-require_once(FILE_PATH . "/src/world/generator/structure/StructureBase.php");
-require_once(FILE_PATH . "/src/world/generator/structure/StructureGenerator.php");
-require_once(FILE_PATH . "/src/plugin/Plugin.php");
-require_once(FILE_PATH . "/src/plugin/OtherPluginRequirement.php");
-require_once(FILE_PATH . "/src/plugin/DummyPlugin.php");
-require_once(FILE_PATH . "/src/plugin/phar/IClassLoader.php");
-require_once(FILE_PATH . "/src/plugin/phar/PharUtils.php");
-
-require_once(FILE_PATH . "/src/world/generator/LevelGenerator.php");
-require_once(FILE_PATH . "/src/world/generator/NewLevelGenerator.php");
-
-require_once(FILE_PATH . "/src/world/generator/biome/BiomeDecorator.php");
-
-require_once(FILE_PATH . "/src/world/generator/biome/Biome.php");
-require_once(FILE_PATH . "/src/world/generator/biome/BiomeSelector.php");
-require_once(FILE_PATH . "/src/world/generator/biome/NormalGeneratorBiomeSelector.php");
-require_once(FILE_PATH . "/src/world/generator/biome/biomes/BiomeWithGrass.php");
-require_once(FILE_PATH . "/src/world/generator/biome/biomes/BiomeWithSand.php");
-require_once(FILE_PATH . "/src/world/generator/biome/biomes/BiomeWithSnow.php");
-require_once(FILE_PATH . "/src/world/generator/biome/biomes/BiomeExtremeHills.php");
-
-
-require_once(FILE_PATH . "/src/world/generator/populator/TreePopulator.php");
-
-
-
-
-require_all(FILE_PATH . "src/");
-
-
-
-$inc = get_included_files();
-$inc[] = array_shift($inc);
-$srcdir = realpath(FILE_PATH . "src/");
-foreach($inc as $s){
- if(strpos(realpath(dirname($s)), $srcdir) === false and strtolower(basename($s)) !== "pocketmine-mp.php"){
- continue;
- }
- $sha1sum ^= sha1_file($s, true);
-}
-/***REM_END***/
-ini_set("opcache.mmap_base", bin2hex(Utils::getRandomBytes(8, false))); //Fix OPCache address errors
-define("SOURCE_SHA1SUM", bin2hex($sha1sum));
-
-/***REM_START***/
-if(!file_exists(DATA_PATH . "server.properties") and arg("no-wizard", false) != true){
- $installer = new Installer();
-}
-/***REM_END***/
diff --git a/src/entity/Ageable.php b/src/entity/Ageable.php
deleted file mode 100644
index 89c3c4df..00000000
--- a/src/entity/Ageable.php
+++ /dev/null
@@ -1,14 +0,0 @@
-setAge(isset($data["Age"]) ? $data["Age"] : 0);
- if(isset($this->data["IsBaby"]) && $this->data["IsBaby"] && $this->getAge() >= 0){
- $this->setAge(-24000);
- }
-
- $this->ai->addTask(new TaskTempt());
- $this->ai->addTask(new TaskPanic());
- }
-
- public function harm($dmg, $cause = "generic", $force = false){
- $ret = parent::harm($dmg, $cause, $force);
- $this->inPanic |= ($ret && is_numeric($cause));
- $this->inLove = false;
- return $ret;
- }
-
- public function isBaby(){
- return $this->getAge() < 0;
- }
-
- public function breed(){
- $c = $this->spawnChild();
- if($this->server->dhandle("entity.animal.breed", ["parent" => $this, "child" => $c]) !== false){
- $c->parent = &$this;
- $this->server->api->entity->spawnToAll($c);
- }
- }
-
- public function update(){
- parent::update();
- $age = $this->getAge() + 1; //100 - fast. debug, 1 - normal
- if($age >= 0 && $this->isBaby()){
- $this->setAge($age);
- $this->updateMetadata();
- }else{
- $this->setAge($age);
- }
- }
-
- public function getAge(){
- return $this->age;
- }
-
- public function setAge($i){
- $this->age = $i;
- }
-
- public function spawnChild()
- {
- return $this->server->api->entity->add($this->level, $this->class, $this->type, [
- "x" => $this->x + lcg_value() * mt_rand(-1, 1),
- "y" => $this->y,
- "z" => $this->z + lcg_value() * mt_rand(-1, 1),
- "IsBaby" => true,
- "Age" => -24000,
- ]);
- }
-
- public function getMetadata(){
- $d = parent::getMetadata();
- $d[14]["value"] = $this->isBaby();
- return $d;
- }
-
- public function createSaveData(){
- $data = parent::createSaveData();
- $data["IsBaby"] = $this->isBaby();
- $data["Age"] = $this->getAge();
- return $data;
- }
-
- public function isInLove(){
- return $this->inLove > 0;
- }
-
- public function interactWith(Entity $e, $action){
- if($e->isPlayer() && $action === InteractPacket::ACTION_HOLD){
- $slot = $e->player->getHeldItem();
- if($this->isFood($slot->getID())){
- $e->player->removeItem($slot->getID(), $slot->getMetadata(), 1);
- $this->inLove = 600; //600 ticks, original mehod from mcpe
- return true;
- }
- }
- parent::interactWith($e, $action);
- }
-
- public function counterUpdate(){
- parent::counterUpdate();
- if($this->isInLove()){
- --$this->inLove;
- }
- }
-
- public function getDrops(){
- if($this->isBaby()){
- return [];
- }
- return parent::getDrops();
- }
-}
diff --git a/src/entity/Attachable.php b/src/entity/Attachable.php
deleted file mode 100644
index b3600271..00000000
--- a/src/entity/Attachable.php
+++ /dev/null
@@ -1,5 +0,0 @@
-inPanic = false; //force for now
- parent::__construct($level, $eid, $class, $type, $data);
- $this->setHealth(isset($this->data["Health"]) ? $this->data["Health"] : 1, "generic");
- // $this->setName((isset($mobs[$this->type]) ? $mobs[$this->type]:$this->type));
- $this->ai->addTask(new TaskLookAround());
- $this->ai->addTask(new TaskRandomWalk());
- $this->ai->addTask(new TaskLookAtPlayer());
- $this->ai->addTask(new TaskSwimming());
- }
-
- public function createSaveData(){
- $data = parent::createSaveData();
- $data["State"] = @$this->getState();
- return $data;
- }
-
- public function getSpeedModifer(){
- return $this->speedModifer * ($this->inPanic ? 1.5 : 1.0);
- }
- public function getArmorValue(){
- return 2;
- }
- public function spawn($player){
- if(!($player instanceof Player)){
- $player = $this->server->api->player->get($player);
- }
- if($player->eid === $this->eid or $this->closed !== false or ($player->level !== $this->level and $this->class !== ENTITY_PLAYER)){
- return false;
- }
- $pk = new AddMobPacket;
- $pk->eid = $this->eid;
- $pk->type = $this->type;
- $pk->x = $this->x;
- $pk->y = $this->y;
- $pk->z = $this->z;
- $pk->yaw = $this->yaw;
- $pk->pitch = $this->pitch;
- $pk->metadata = $this->getMetadata();
- $player->dataPacket($pk);
-
- $pk = new SetEntityMotionPacket;
- $pk->entities = [[$this->eid, $this->speedX, $this->speedY, $this->speedZ]];
- $player->dataPacket($pk);
- }
-
-}
diff --git a/src/entity/Damageable.php b/src/entity/Damageable.php
deleted file mode 100644
index b2736566..00000000
--- a/src/entity/Damageable.php
+++ /dev/null
@@ -1,5 +0,0 @@
-random = new Random();
- $this->last = [&$this->lastX, &$this->lastY, &$this->lastZ, &$this->lastYaw, &$this->lastPitch, &$this->lastTime]; //pointers to variables
- $this->canBeAttacked = false;
- $this->hasKnockback = false;
- $this->level = $level;
- $this->speedModifer = 0.7;
- $this->fallY = false;
- $this->fallStart = false;
- $this->server = ServerAPI::request();
- $this->eid = (int) $eid;
- $this->type = (int) $type;
- $this->class = (int) $class;
- $this->player = false;
- $this->attach = false;
- $this->data = $data;
- $this->status = 0;
- $this->health = 20;
- $this->hasGravity = false;
- $this->dmgcounter = array(0, 0, 0);
- $this->air = 200;
- $this->fire = 0;
- $this->crouched = false;
- $this->invincible = false;
- $this->lastUpdate = $this->spawntime = microtime(true);
- $this->dead = false;
- $this->closed = false;
- $this->isStatic = false;
- $this->name = "";
- $this->state = $this->data["State"] = isset($this->data["State"]) ? $this->data["State"] : 0;
- $this->tickCounter = 0;
- $this->server->query("INSERT OR REPLACE INTO entities (EID, level, type, class, health, hasUpdate) VALUES (" . $this->eid . ", '" . $this->level->getName() . "', " . $this->type . ", " . $this->class . ", " . $this->health . ", 0);");
- $this->x = isset($this->data["x"]) ? (float) $this->data["x"] : 0;
- $this->y = isset($this->data["y"]) ? (float) $this->data["y"] : 0;
- $this->z = isset($this->data["z"]) ? (float) $this->data["z"] : 0;
- $this->speedX = isset($this->data["speedX"]) ? (float) $this->data["speedX"] : 0;
- $this->speedY = isset($this->data["speedY"]) ? (float) $this->data["speedY"] : 0;
- $this->speedZ = isset($this->data["speedZ"]) ? (float) $this->data["speedZ"] : 0;
- $this->speed = 0;
- $this->yaw = isset($this->data["yaw"]) ? (float) $this->data["yaw"] : 0;
- $this->headYaw = isset($this->data["headYaw"]) ? $this->data["headYaw"] : $this->yaw;
- $this->pitch = isset($this->data["pitch"]) ? (float) $this->data["pitch"] : 0;
- $this->position = array(
- "level" => $this->level,
- "x" => &$this->x,
- "y" => &$this->y,
- "z" => &$this->z,
- "yaw" => &$this->yaw,
- "pitch" => &$this->pitch
- );
- $this->moveTime = 0;
- $this->lookTime = 0;
- $this->onGround = false;
- $this->gravity = 0.08;
- switch($this->class) {
- case ENTITY_PLAYER:
- $this->player = $this->data["player"];
- $this->setHealth($this->health, "generic");
- $this->speedModifer = 1;
- $this->width = 0.6;
- $this->height = 1.8;
- $this->hasKnockback = true;
- $this->hasGravity = true;
- $this->canBeAttacked = true;
- break;
- case ENTITY_ITEM:
- if(isset($data["item"]) and ($data["item"] instanceof Item)){
- $this->meta = $this->data["item"]->getMetadata();
- $this->stack = $this->data["item"]->count;
- } else{
- $this->meta = (int) $this->data["meta"];
- $this->stack = (int) $this->data["stack"];
- }
- $this->gravity = 0.06;
- $this->hasGravity = true;
- $this->setHealth(5, "generic");
- $this->setSize(0.25, 0.25);
- break;
- case ENTITY_FALLING:
- $this->setHealth(PHP_INT_MAX, "generic");
- $this->height = 0.98;
- $this->width = 0.98;
- $this->gravity = 0.04;
- $this->hasGravity = true;
- break;
- case ENTITY_OBJECT:
- $this->x = isset($this->data["TileX"]) ? $this->data["TileX"] : $this->x;
- $this->y = isset($this->data["TileY"]) ? $this->data["TileY"] : $this->y;
- $this->z = isset($this->data["TileZ"]) ? $this->data["TileZ"] : $this->z;
- $this->setHealth(1, "generic");
- // $this->setName((isset($objects[$this->type]) ? $objects[$this->type]:$this->type));
- $this->width = 1;
- $this->height = 1;
- if($this->type === OBJECT_SNOWBALL){
- $this->server->schedule(1210, array(
- $this,
- "update"
- )); // Despawn
- // $this->update();
- }
- break;
- }
- $this->radius = $this->width / 2;
- $this->boundingBox = new AxisAlignedBB($this->x - $this->radius, $this->y, $this->z - $this->radius, $this->x + $this->radius, $this->y + $this->height, $this->z + $this->radius);
- //$this->update();
- $this->updateLast();
- $this->updatePosition();
- if($this->isInVoid()){
- $this->outOfWorld();
- }
- }
-
- public function isType(){
- return in_array($this->type, func_get_args());
- }
-
- public function attackEntity($entity){
-
- }
-
- public function addVelocity($vX, $vY = 0, $vZ = 0)
- {
- if($vX instanceof Vector3){
- return $this->addVelocity($vX->x, $vX->y, $vX->z);
- }
- $this->speedX += $vX;
- $this->speedY += $vY;
- $this->speedZ += $vZ;
- }
- public function isMovingHorizontally()
- {
- return ($this->speedX >= self::MIN_POSSIBLE_SPEED || $this->speedX <= -self::MIN_POSSIBLE_SPEED) || ($this->speedZ >= self::MIN_POSSIBLE_SPEED || $this->speedZ <= -self::MIN_POSSIBLE_SPEED);
- }
- public function isMoving()
- {
- return $this->isMovingHorizontally() || ($this->speedY > self::MIN_POSSIBLE_SPEED || $this->speedY < -self::MIN_POSSIBLE_SPEED);
- }
-
- public function setVelocity($vX, $vY = 0, $vZ = 0)
- {
- if($vX instanceof Vector3){
- return $this->setVelocity($vX->x, $vX->y, $vX->z);
- }
- $this->speedX = $vX;
- $this->speedY = $vY;
- $this->speedZ = $vZ;
- }
-
- /**
- *
- * @param mixed $e
- * Entity instance or EID
- * @return string|false if failed
- */
- public static function getNameOf($e)
- {
- if($e instanceof Entity){
- return $e->getName();
- } elseif(($e = ServerAPI::request()->api->entity->get($e)) != false){
- return $e->getName();
- }
- return false;
- }
-
- /**
- *
- * @param mixed $e
- * Entity instance or EID
- * @return number|false if failed
- */
- public static function getHeightOf($e)
- {
- if($e instanceof Entity){
- return $e->getHeight();
- } elseif(($e = ServerAPI::request()->api->entity->get($e)) != false){
- return $e->getHeight();
- }
- return false;
- }
-
- /**
- *
- * @param mixed $e
- * Entity instance or EID
- * @return number|false if failed
- */
- public static function getWidthOf($e)
- {
- if($e instanceof Entity){
- return $e->getWidth();
- } elseif(($e = ServerAPI::request()->api->entity->get($e)) != false){
- return $e->getWidth();
- }
- return false;
- }
-
- /**
- * Get an entity height
- *
- * @return number
- */
- public function getHeight($a)
- {
- return $this->height;
- }
-
- /**
- * Get an entity width
- *
- * @return number
- */
- public function getWidth()
- {
- return $this->width;
- }
-
- public function lookOn(Vector3 $target)
- {
- $horizontal = sqrt(pow(($target->x - $this->x), 2) + pow(($target->z - $this->z), 2));
- $vertical = $target->y - ($this->y + - 0.5); /* 0.5 = $entity->getEyeHeight() */
- $pitch = - asin($horizontal) / M_PI * 180; // negative is up, positive is down
-
- $xDist = $target->x - $this->x;
- $zDist = $target->z - $this->z;
-
- $yaw = atan2($zDist, $xDist) / M_PI * 180 - 90;
- if($yaw < 0){
- $yaw += 360.0;
- }
- $this->yaw = $yaw;
- $this->pitch = $pitch;
- $this->server->query("UPDATE entities SET pitch = " . $this->pitch . ", yaw = " . $this->yaw . " WHERE EID = " . $this->eid . ";");
- }
-
- public function getDrops()
- {
- if($this->class === ENTITY_PLAYER and $this->player instanceof Player and ($this->player->gamemode & 0x01) === 0){
- $inv = [];
- for($i = 0; $i < PLAYER_SURVIVAL_SLOTS; ++ $i){
- $slot = $this->player->getSlot($i);
- $this->player->setSlot($i, BlockAPI::getItem(AIR, 0, 0));
- if($slot->getID() !== AIR and $slot->count > 0){
- $inv[] = array(
- $slot->getID(),
- $slot->getMetadata(),
- $slot->count
- );
- }
- }
- for($re = 0; $re < 4; $re ++){
- $slot = $this->player->getArmor($re);
- $this->player->setArmor($re, BlockAPI::getItem(AIR, 0, 0));
- if($slot->getID() !== AIR and $slot->count > 0){
- $inv[] = array(
- $slot->getID(),
- $slot->getMetadata(),
- $slot->count
- );
- }
- }
- return $inv;
- }
- return [];
- }
-
- private function spawnDrops()
- {
- foreach($this->getDrops() as $drop){
- $this->server->api->entity->drop($this, BlockAPI::getItem($drop[0] & 0xFFFF, $drop[1] & 0xFFFF, $drop[2] & 0xFF), true);
- }
- }
-
- public function environmentUpdate()
- {
- $hasUpdate = Entity::$updateOnTick ? $this->class === ENTITY_MOB : false; // force true for mobs
- $time = microtime(true);
- if($this->class === ENTITY_PLAYER and ($this->player instanceof Player) and $this->player->spawned === true and $this->player->blocked !== true && ! $this->dead){
- $myBB = $this->boundingBox->grow(1, 0.5, 1);
- foreach($this->server->api->entity->getRadius($this, 2, ENTITY_ITEM) as $item){ //TODO vanilla method of searching/radius
- if(!$item->closed && $item->spawntime > 0 && $item->delayBeforePickup == 0){
- if($item->boundingBox->intersectsWith($myBB)){
- if((($this->player->gamemode & 0x01) === 1 || $this->player->hasSpace($item->type, $item->meta, $item->stack) === true) && $this->server->api->dhandle("player.pickup", array(
- "eid" => $this->player->eid,
- "player" => $this->player,
- "entity" => $item,
- "block" => $item->type,
- "meta" => $item->meta,
- "target" => $item->eid
- )) !== false){
- $item->close();
- }
- }
- }
- }
- } elseif($this->class === ENTITY_ITEM){
- if(($time - $this->spawntime) >= 300){
- $this->close(); // Despawn timer
- return false;
- }
- } elseif($this->class === ENTITY_OBJECT and $this->type === OBJECT_SNOWBALL){
- if(($time - $this->spawntime) >= 60){
- $this->close();
- return false;
- }
- }
-
- if($this->class !== ENTITY_PLAYER and ($this->y >= 128 or $this->y <= 0)){
- $this->close();
- return false;
- }
-
- if($this->dead === true){
- $this->fire = 0;
- $this->air = 200;
- return false;
- }
- if($this->isInVoid()){
- $this->outOfWorld();
- $hasUpdate = true;
- }
-
- if($this->fire > 0){
- if(($this->fire % 20) === 0){
- $this->harm(1, "burning");
- }
- $this->fire -= 10;
- if($this->fire <= 0){
- $this->fire = 0;
- $this->updateMetadata();
- } else{
- $hasUpdate = true;
- }
- if(($this->player instanceof Player) and ($this->player->gamemode & 0x01) === CREATIVE){
- $this->fire = 0;
- }
- }
-
- $startX = floor($this->boundingBox->minX);
- $startY = floor($this->boundingBox->minY);
- $startZ = floor($this->boundingBox->minZ);
- $endX = ceil($this->boundingBox->maxX);
- $endY = ceil($this->boundingBox->maxY);
- $endZ = ceil($this->boundingBox->maxZ);
- if(!($this instanceof Painting) && !($this->isPlayer() && $this->player->isSleeping !== false)){
- for($i = 0; $i < 8; ++$i){
- $x = ((($i >> 0) % 2) - 0.5) * $this->width * 0.8;
- $y= ((($i >> 1) % 2) - 0.5) * 0.1;
- $z = ((($i >> 2) % 2) - 0.5) * $this->width * 0.8;
-
- $blockX = floor($this->x + $x);
- $blockY = floor($this->y + $this->getEyeHeight() + $y);
- $blockZ = floor($this->z + $z);
-
- if(StaticBlock::getIsSolid($this->level->level->getBlockID($blockX, $blockY, $blockZ))){
- $this->harm(1, "suffocation"); // Suffocation
- $hasUpdate = true;
- break;
- }
- }
- }
-
-
- $waterDone = false;
- for ($y = $startY; $y <= $endY; ++$y){
- for ($x = $startX; $x <= $endX; ++$x){
- for ($z = $startZ; $z <= $endZ; ++$z){
- $pos = new Vector3($x, $y, $z);
- $b = $this->level->getBlock($pos);
- switch ($b->getID()) {
- case WATER:
- case STILL_WATER: // Drowing
- if ($this->fire > 0 and $this->inBlock($pos)) {
- $this->fire = 0;
- $this->updateMetadata();
- }
- if (($this->air <= 0 && ! $waterDone) || $this->type === MOB_ENDERMAN) { //TODO check is correct
- $this->harm(2, "water");
- $hasUpdate = true;
- $waterDone = true;
- } elseif ($x == ($endX - 1) and $y == $endY and $z == ($endZ - 1 - (($b->getMetadata() % 8) / 9)) and ($this->class === ENTITY_MOB or $this->class === ENTITY_PLAYER) and !$waterDone) {
- $this->air -= 1;
- $waterDone = true;
- $this->updateMetadata();
- $hasUpdate = true;
- }
- break;
- case LAVA: // Lava damage
- case STILL_LAVA:
- if ($this->inBlock($pos)) {
- $this->harm(5, "lava");
- $this->fire = 300;
- $this->updateMetadata();
- $hasUpdate = true;
- }
- break;
- case FIRE: // Fire block damage
- if ($this->inBlock($pos)) {
- $this->harm(1, "fire");
- $this->fire = 300;
- $this->updateMetadata();
- $hasUpdate = true;
- }
- break;
- case CACTUS: // Cactus damage
- if ($this->touchingBlock($pos)) {
- $this->harm(1, "cactus");
- $hasUpdate = true;
- }
- break;
- }
- }
- }
- }
- return $hasUpdate;
- }
-
- public function updateEntityMovement(){}
-
- public function isInVoid(){
- return $this->y < -1.6;
- }
-
-
- public function update(){
- if($this->closed === true){
- return false;
- }
-
- $now = microtime(true);
- if($this->check === false){
- $this->lastUpdate = $now;
- return;
- }
-
- if(!$this->isPlayer() && !isset($this->level->usedChunks[((int)$this->x >> 4).".".((int)$this->z >> 4)])){
- $this->close();
- return false;
- }
-
- $tdiff = $now - $this->lastUpdate;
- if($this->tickCounter === 0){
- $this->tickCounter = 1;
- $hasUpdate = $this->environmentUpdate();
- } else{
- $hasUpdate = true;
- $this->tickCounter = 0;
- }
-
- if($this->closed === true){
- return false;
- }
- ++$this->counter;
- if($this->isStatic === false){
- $startX = floor($this->x - 0.5 - $this->width - 1);
- // prefix for flying when player on fence
- $y = floor($this->y - 1);
- $yC = ceil($this->y - 1);
- $startZ = floor($this->z - 0.5 - $this->width - 1);
- $endX = ceil($this->x - 0.5 + $this->width + 1);
- $endZ = ceil($this->z - 0.5 + $this->width + 1);
- $support = false;
- $isFlying = true;
-
- if($this->isPlayer()){
- for($z = $startZ; $z <= $endZ; ++ $z){
- for($x = $startX; $x <= $endX; ++ $x){
- $v = new Vector3($x, $y, $z);
- $v1 = new Vector3($x, $yC, $z);
- if($this->isSupport($v, $this->width)){
- $b = $this->level->getBlock($v);
- if($b->isSolid === true){
- $support = true;
- $isFlying = false;
- break;
- } elseif(($b instanceof LiquidBlock) or $b->getID() === COBWEB or $b->getID() === LADDER or $b->getID() === FENCE or $b->getID() === STONE_WALL or $b->getID() === IRON_BARS){
- $isFlying = false;
- }
- } elseif($this->isSupport($v1, $this->width)){
- $b = $this->level->getBlock($v1);
- if($b->isSolid === true){
- $support = true;
- $isFlying = false;
- break;
- } elseif(($b instanceof LiquidBlock) or $b->getID() === COBWEB or $b->getID() === LADDER or $b->getID() === FENCE or $b->getID() === STONE_WALL or $b->getID() === IRON_BARS){
- $isFlying = false;
- }
- }
- }
- if($support === true){
- break;
- }
- }
- }
- if(!$this->isPlayer()){
- $this->updateEntityMovement();
- $update = false;
- if($this->speedX > -self::MIN_POSSIBLE_SPEED && $this->speedX < self::MIN_POSSIBLE_SPEED){
- $this->speedX = 0;
- }
- if($this->speedZ > -self::MIN_POSSIBLE_SPEED && $this->speedZ < self::MIN_POSSIBLE_SPEED){
- $this->speedZ = 0;
- }
- if($this->speedY > -self::MIN_POSSIBLE_SPEED && $this->speedY < self::MIN_POSSIBLE_SPEED){
- $this->speedY = 0;
- }
-
- $horizontalMultiplyFactor = 0.91;
- if($this->onGround){
- $horizontalMultiplyFactor = 0.54;
- $b = $this->level->level->getBlockID(floor($this->x), floor($this->boundingBox->minX) - 1, floor($this->z));
- if($b > 0){
- $horizontalMultiplyFactor = StaticBlock::getSlipperiness($b) * 0.91;
- }
- }
- if($this->inWater){
- $this->speedX *= 0.8;
- $this->speedY *= 0.8;
- $this->speedZ *= 0.8;
- }else{
- $this->speedX *= $horizontalMultiplyFactor;
- $this->speedY *= 0.98;
- $this->speedZ *= $horizontalMultiplyFactor;
- }
-
- $savedSpeedY = $this->speedY;
- if($this->class === ENTITY_MOB || $this->class === ENTITY_ITEM || ($this->class === ENTITY_OBJECT && $this->type === OBJECT_PRIMEDTNT) || $this->class === ENTITY_FALLING){
- $water = false;
- $aABB = $this->boundingBox->addCoord($this->speedX, $this->speedY, $this->speedZ);
- $x0 = floor($aABB->minX);
- $x1 = ceil($aABB->maxX);
- $y0 = floor($aABB->minY);
- $y1 = ceil($aABB->maxY);
- $z0 = floor($aABB->minZ);
- $z1 = ceil($aABB->maxZ);
- //$x1 = $x1 > 256 ? 256 : $x1;
- //$y1 = $y1 > 128 ? 128 : $y1;
- //$z1 = $z1 > 256 ? 256 : $z1;
- for($x = $x0; $x < $x1; ++$x){
- for($y = $y0; $y < $y1; ++$y){
- for($z = $z0; $z < $z1; ++$z){
- $pos = new Vector3($x, $y, $z);
- $b = $this->level->getBlock($pos);
- if($b->y == ($y1 - 1) && ($b->getID() === WATER || $b->getID() === STILL_WATER)){
- $water = true;
- }
- if($b != false && $b->isSolid){
- $this->speedY = $b->boundingBox->calculateYOffset($this->boundingBox, $this->speedY);
- $this->speedX = $b->boundingBox->calculateXOffset($this->boundingBox, $this->speedX);
- $this->speedZ = $b->boundingBox->calculateZOffset($this->boundingBox, $this->speedZ);
- }
- }
- }
- }
-
- $this->inWater = $water;
- }
-
- $support = $savedSpeedY != $this->speedY && $savedSpeedY < 0;
-
- if($this->speedX != 0){
- $this->x += $this->speedX;
- $update = true;
- }
- if($this->speedZ != 0){
- $this->z += $this->speedZ;
- $update = true;
- }
- if($this->speedY != 0){
- $ny = $this->y + $this->speedY;
- if($this->class === ENTITY_FALLING){
- if($support){
- $this->level->fastSetBlockUpdate($this->x, $this->y, $this->z, $this->data["Tile"], 0);
- $this->close();
- return;
- }
- $id = $this->level->level->getBlockID($this->x, $this->y, $this->z);
- if($id > 0 && !StaticBlock::getIsSolid($id) && !StaticBlock::getIsLiquid($id)){
- $this->server->api->entity->drop($this, BlockAPI::getItem($this->data["Tile"], 0, 1));
- $this->close();
- return;
- }
-
- }
- $this->y = $ny;
-
- $update = true;
- }
- $this->onGround = $support;
-
- if($this->hasGravity){
- $this->speedY -= $this->inWater ? 0.02 : $this->gravity; // TODO: fix packet spam
- $update = true;
- } elseif($this->lastX != $this->x || $this->lastZ != $this->z || $this->lastY != $this->z){
- $this->server->api->handle("entity.move", $this);
- $update = true;
- }elseif ($this->lastYaw != $this->yaw || $this->lastPitch != $this->pitch || $this->lastHeadYaw != $this->headYaw) {
- $update = true;
- }
-
- if($update === true){
- $hasUpdate = true;
- if(($this->server->ticks % 4 === 0 && $this->class === ENTITY_ITEM) || $this->class != ENTITY_ITEM){ //update item speed every 4 ticks
- $this->server->api->handle("entity.motion", $this);
- $this->lastSpeedZ = $this->speedZ;
- $this->lastSpeedY = $this->speedY;
- $this->lastSpeedX = $this->speedX;
- }
- }
- } elseif($this->player instanceof Player){
- if($isFlying === true and ($this->player->gamemode & 0x01) === 0x00){
- if($this->fallY === false or $this->fallStart === false){
- $this->fallY = $y;
- $this->fallStart = microtime(true);
- } elseif($y > $this->fallY){
- $this->fallY = $y;
- }
- } elseif($this->fallY !== false){ // Fall damage!
- if($y < $this->fallY){
- $blockToFallOn = $this->level->getBlock(new Vector3($x, $y, $z));
- if($blockToFallOn->getID() === FARMLAND){
- $this->level->setBlock($blockToFallOn, new DirtBlock(), true, false, true);
- }
-
- $d = $this->level->getBlock(new Vector3($x, $y + 1, $z));
- $d2 = $this->level->getBlock(new Vector3($x, $y + 2, $z));
- $dmg = ($this->fallY - $y) - 3;
- if($dmg > 0 and ! ($d instanceof LiquidBlock) and $d->getID() !== LADDER and $d->getID() !== COBWEB and ! ($d2 instanceof LiquidBlock) and $d2->getID() !== LADDER and $d2->getID() !== COBWEB){
- $this->harm($dmg, "fall");
- }
- }
- $this->fallY = false;
- $this->fallStart = false;
- }
- $this->calculateVelocity();
- if($this->speed <= 9 or ($this->speed <= 20 and ($this->player->gamemode & 0x01) === 0x01)){
- $this->player->lastCorrect = new Vector3($this->last[0], $this->last[1], $this->last[2]);
- }
-
- $hasUpdate = true;
- }
- }
-
- $this->counterUpdate();
-
- if($this->lastHeadYaw != $this->headYaw){
- $this->sendHeadYaw();
- }
- if($this->class === ENTITY_PLAYER || $update){
- $this->updateMovement();
- }
-
- if($this->isPlayer()){
- $this->player->entityTick();
- }
-
- $this->needsUpdate = $hasUpdate;
- $this->lastUpdate = $now;
- }
-
- public function counterUpdate(){
- if($this->knockbackTime > 0){
- --$this->knockbackTime;
- }
- if($this->moveTime > 0){
- -- $this->moveTime;
- }
- if($this->lookTime > 0){
- -- $this->lookTime;
- }
- if($this->idleTime > 0){
- -- $this->idleTime;
- }
- if($this->delayBeforePickup > 0){
- --$this->delayBeforePickup;
- }
- }
-
- public function updateMovement()
- {
- if($this->closed === true){
- return false;
- }
- $now = microtime(true);
- if($this->isStatic === false and ($this->lastX != $this->x or $this->lastY != $this->y or $this->lastZ != $this->z or $this->lastYaw != $this->yaw or $this->lastPitch != $this->pitch or $this->lastHeadYaw != $this->headYaw)){
- if($this->class === ENTITY_PLAYER or ($this->last[5] + 8) < $now){
- if($this->server->api->handle("entity.move", $this) === false){
- if($this->class === ENTITY_PLAYER){
- $this->player->teleport(new Vector3($this->last[0], $this->last[1], $this->last[2]), $this->last[3], $this->last[4]);
- } else{
- //TODO fix $this->setPosition($this->last[0], $this->last[1], $this->last[2], $this->last[3], $this->last[4]);
- }
- } else{
- $this->updateLast();
- $players = $this->server->api->player->getAll($this->level);
- if($this->player instanceof Player){
- //console("gujnbguib");
- unset($players[$this->player->CID]);
- $pk = new MovePlayerPacket();
- $pk->eid = $this->eid;
- $pk->x = $this->x;
- $pk->y = $this->y;
- $pk->z = $this->z;
- $pk->yaw = $this->yaw;
- $pk->pitch = $this->pitch;
- $pk->bodyYaw = $this->yaw;
- $this->server->api->player->broadcastPacket($players, $pk);
- } else{
-
- $pk = new MoveEntityPacket;
- $pk->entities = [[$this->eid, $this->x, $this->y, $this->z, $this->yaw, $this->pitch]];
- $this->server->api->player->broadcastPacket($players, $pk);
- }
- }
- } else{
- $this->updatePosition();
- $this->updateLast();
- }
-
-
- }
-
- $this->lastUpdate = $now;
- }
-
- /**
- * Handle fall out of world
- */
- public function outOfWorld(){
- if($this->isPlayer()){
- $this->health = 0;
- $this->makeDead("void");
- }else{
- $this->close();
- }
- }
-
- public function getEyeHeight(){
- return $this->isPlayer() ? 1.62 : $this->width;
- }
-
- public function interactWith(Entity $e, $action)
- {
- if($this->class === ENTITY_PLAYER and ($this->server->api->getProperty("pvp") == false or $this->server->difficulty <= 0 or ($e->player->gamemode & 0x01) === 0x01)){
- return false;
- }
-
- if($action === InteractPacket::ACTION_ATTACK && $e->isPlayer()){
- $slot = $e->player->getHeldItem();
- $damage = $slot->getDamageAgainstOf($e);
- $this->harm($damage, $e->eid);
- if($slot->isTool() === true and ($e->player->gamemode & 0x01) === 0){
- if($slot->useOn($e) and $slot->getMetadata() >= $slot->getMaxDurability()){
- $e->player->removeItem($slot->getID(), $slot->getMetadata(), 1, true);
- }
- }
- return true;
- }
- return false;
- }
-
- public function getDirection()
- {
- $rotation = ((int)($this->yaw - 90)) % 360;
- if($rotation < 0){
- $rotation += 360.0;
- }
- if((0 <= $rotation and $rotation < 45) or (315 <= $rotation and $rotation < 360)){
- return 2; //x-
- } elseif(45 <= $rotation and $rotation < 135){
- return 3; //z-
- } elseif(135 <= $rotation and $rotation < 225){
- return 0; //x+
- } elseif(225 <= $rotation and $rotation < 315){
- return 1; //z+
- } else{
- return null;
- }
- }
-
- /**
- * METADATA VALUES(EXPEREMENTAL)
- * *****************
- * Types: Get input type of
- * 0 -> Byte
- * 1 -> Short
- * 2 -> Integer
- * 3 -> Float
- * 4 -> Length of , Short
- * 5 -> [Short, Byte, Short]
- * 6 -> [Integer, Integer, Integer]
- * *****************
- * 0 => ["type" => 0, "value" => $flags] --> DATA_FLAGS
- * 1 => ["type" => 1, "value" => $this->air] --> Entity Air
- * 14 => ["type" => 0, "value" => 1] --> IsBaby, value: 0 => false, 1 => true
- * 16 => ["type" => 0, "value" => 0] --> Fuse(TNT), Saddled(Pig), Creeper(29 ticks before explosion)
- * 17 => ["type" => 6, "value" => [0, 0, 0]] --> Bed Position >
- *
- *
- * DATA FLAGS IDS
- * 0 - fire
- * 1 - crouching
- * 4 - inAction(ex.: using a bow)
- */
- public function getMetadata()
- {
- $flags = 0;
- $flags ^= $this->fire > 0 ? 0b1 : 0;
- $flags ^= ($this->crouched ? 0b1 : 0) << 1;
- $flags ^= ($this->inAction ? 0b1 : 0) << 4;
- $d = [
- 0 => [
- "type" => 0,
- "value" => $flags
- ],
- 1 => [
- "type" => 1,
- "value" => $this->air
- ],
- 14 => [
- "type" => 0,
- "value" => 0
- ],
- 16 => [
- "type" => 0,
- "value" => 0
- ],
- 17 => [
- "type" => 6,
- "value" => [
- 0,
- 0,
- 0
- ]
- ]
- ];
- $d[16]["value"] = $this->data["State"];
- if($this->class === ENTITY_PLAYER){
- if($this->player->isSleeping !== false){
- $d[16]["value"] = 2;
- $d[17]["value"] = [
- $this->player->isSleeping->x,
- $this->player->isSleeping->y,
- $this->player->isSleeping->z
- ];
- }
- }
- return $d;
- }
-
- public function updateMetadata()
- {
- $this->server->api->dhandle("entity.metadata", $this);
- }
-
- public function spawn($player)
- {
- if(! ($player instanceof Player)){
- $player = $this->server->api->player->get($player);
- }
- if($player->eid === $this->eid or $this->closed !== false or ($player->level !== $this->level and $this->class !== ENTITY_PLAYER)){
- return false;
- }
- switch($this->class) {
- case ENTITY_PLAYER:
- if($this->player->connected !== true or $this->player->spawned === false){
- return false;
- }
- if($this->player->gamemode === SPECTATOR){
- break;
- }
- $pk = new AddPlayerPacket();
- $pk->clientID = 0; // $this->player->clientID;
- $pk->username = $this->player->username;
- $pk->eid = $this->eid;
- $pk->x = $this->x;
- $pk->y = $this->y;
- $pk->z = $this->z;
- $pk->yaw = 0;
- $pk->pitch = 0;
- $pk->itemID = 0;
- $pk->itemAuxValue = 0;
- $pk->metadata = $this->getMetadata();
- $player->dataPacket($pk);
-
- $pk = new SetEntityMotionPacket();
- $pk->entities = [[$this->eid, $this->speedX, $this->speedY, $this->speedZ]];
- $player->dataPacket($pk);
-
- $pk = new PlayerEquipmentPacket();
- $pk->eid = $this->eid;
- $pk->item = $this->player->getSlot($this->player->slot)->getID();
- $pk->meta = $this->player->getSlot($this->player->slot)->getMetadata();
- $pk->slot = 0;
- $player->dataPacket($pk);
- $this->player->sendArmor($player);
- break;
- case ENTITY_ITEM:
- $pk = new AddItemEntityPacket();
- $pk->eid = $this->eid;
- $pk->x = $this->x;
- $pk->y = $this->y;
- $pk->z = $this->z;
- $pk->yaw = $this->yaw;
- $pk->pitch = $this->pitch;
- $pk->roll = 0;
- $pk->item = BlockAPI::getItem($this->type, $this->meta, $this->stack);
- $pk->metadata = $this->getMetadata();
- $player->dataPacket($pk);
-
- $pk = new SetEntityMotionPacket();
- $pk->entities = [[$this->eid, $this->speedX, $this->speedY, $this->speedZ]];
- $player->dataPacket($pk);
- break;
- case ENTITY_FALLING:
- $pk = new AddEntityPacket(); //TODO fix
- $pk->eid = $this->eid;
- $pk->type = $this->type;
- $pk->x = $this->x;
- $pk->y = $this->y;
- $pk->z = $this->z;
- $pk->did = -($this->data["Tile"] | $this->data["Metadata"] << 0x10);
- $player->dataPacket($pk);
-
- $pk = new SetEntityMotionPacket();
- $pk->entities = [[$this->eid, $this->speedX, $this->speedY, $this->speedZ]];
- $player->dataPacket($pk);
- break;
- }
- }
-
- public function close()
- {
- if($this->closed === false){
- $this->closed = true;
- if($this?->linkedEntity?->linkedEntity?->eid === $this->eid){
- $this->linkedEntity->linkedEntity = false;
- }
- $this->linkedEntity = false;
- $this->server->api->entity->remove($this->eid);
- }
- }
-
- public function __destruct()
- {
- $this->close();
- }
-
- public function getEID()
- {
- return $this->eid;
- }
-
- public function getName()
- {
- return $this->name;
- }
-
- public function setName($name)
- {
- $this->name = $name;
- // $this->server->query("UPDATE entities SET name = '".str_replace("'", "", $this->name)."' WHERE EID = ".$this->eid.";"); is this neccessary for database?
- }
-
- public function look($pos2)
- {
- $pos = $this->getPosition();
- $angle = Utils::angle3D($pos2, $pos);
- $this->yaw = $angle["yaw"];
- $this->pitch = $angle["pitch"];
- $this->server->query("UPDATE entities SET pitch = " . $this->pitch . ", yaw = " . $this->yaw . " WHERE EID = " . $this->eid . ";");
- }
-
- public function move(Vector3 $pos, $yaw = 0, $pitch = 0)
- {
- $this->x += $pos->x;
- $this->y += $pos->y;
- $this->z += $pos->z;
- $this->yaw += $yaw;
- $this->yaw %= 360;
- $this->pitch += $pitch;
- $this->pitch %= 90;
- $this->server->query("UPDATE entities SET x = " . $this->x . ", y = " . $this->y . ", z = " . $this->z . ", pitch = " . $this->pitch . ", yaw = " . $this->yaw . " WHERE EID = " . $this->eid . ";");
- $this->updateAABB();
- }
-
- public function updateAABB()
- {
- $this->boundingBox->setBounds($this->x - $this->radius, $this->y, $this->z - $this->radius, $this->x + $this->radius, $this->y + $this->height, $this->z + $this->radius);
- }
-
- public function updatePosition()
- {
- $this->server->query("UPDATE entities SET level = '" . $this->level->getName() . "', x = " . $this->x . ", y = " . $this->y . ", z = " . $this->z . ", pitch = " . $this->pitch . ", yaw = " . $this->yaw . " WHERE EID = " . $this->eid . ";");
- $this->sendMoveUpdate();
- // $this->sendMotion();
- $this->updateAABB();
- }
-
- public function sendHeadYaw(){
- $pk = new RotateHeadPacket;
- $pk->entities = [[$this->eid, $this->headYaw]];
- $this->server->api->player->broadcastPacket($this->level->players, $pk);
- }
-
- public function setPosition(Vector3 $pos, $yaw = false, $pitch = false)
- {
- if($pos instanceof Position and $pos->level instanceof Level and $this->level !== $pos->level){
- $this->level = $pos->level;
- $this->server->preparedSQL->entity->setLevel->reset();
- $this->server->preparedSQL->entity->setLevel->clear();
- $this->server->preparedSQL->entity->setLevel->bindValue(":level", $this->level->getName(), SQLITE3_TEXT);
- $this->server->preparedSQL->entity->setLevel->bindValue(":eid", $this->eid, SQLITE3_INTEGER);
- $this->server->preparedSQL->entity->setLevel->execute();
- }
- $this->x = $pos->x;
- $this->y = $pos->y;
- $this->z = $pos->z;
- if($yaw !== false){
- $this->yaw = $yaw;
- }
- if($pitch !== false){
- $this->pitch = $pitch;
- }
- $this->server->preparedSQL->entity->setPosition->reset();
- $this->server->preparedSQL->entity->setPosition->clear();
- $this->server->preparedSQL->entity->setPosition->bindValue(":x", $this->x, SQLITE3_TEXT);
- $this->server->preparedSQL->entity->setPosition->bindValue(":y", $this->y, SQLITE3_TEXT);
- $this->server->preparedSQL->entity->setPosition->bindValue(":z", $this->z, SQLITE3_TEXT);
- $this->server->preparedSQL->entity->setPosition->bindValue(":pitch", $this->pitch, SQLITE3_TEXT);
- $this->server->preparedSQL->entity->setPosition->bindValue(":yaw", $this->yaw, SQLITE3_TEXT);
- $this->server->preparedSQL->entity->setPosition->bindValue(":eid", $this->eid, SQLITE3_INTEGER);
- $this->server->preparedSQL->entity->setPosition->execute();
- }
-
- public function inBlock(Vector3 $block, $radius = 0.8)
- {
- $me = new Vector3($this->x - 0.5, $this->y, $this->z - 0.5);
- if(($block->y == (ceil($this->y)) or $block->y == (ceil($this->y) + 1)) and $block->maxPlainDistance($me) < $radius){
- return true;
- }
- return false;
- }
-
- public function touchingBlock(Vector3 $block, $radius = 0.9)
- {
- $me = new Vector3($this->x - 0.5, $this->y, $this->z - 0.5);
- if(($block->y == (((int) $this->y) - 1) or $block->y == ((int) $this->y) or $block->y == (((int) $this->y) + 1)) and $block->maxPlainDistance($me) < $radius){
- return true;
- }
- return false;
- }
-
- public function isSupport(Vector3 $pos, $radius = 1)
- {
- $me = new Vector2($this->x - 0.5, $this->z - 0.5);
- $diff = $this->y - $pos->y;
- if($me->distance(new Vector2($pos->x, $pos->z)) < $radius and $diff > - 0.7 and $diff < 1.6){
- return true;
- }
- return false;
- }
-
- public function resetSpeed()
- {
- $this->speedMeasure = array(
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0
- );
- }
-
- public function getSpeed()
- {
- return $this->speed;
- }
-
- public function getSpeedMeasure()
- {
- return array_sum($this->speedMeasure) / count($this->speedMeasure);
- }
-
- public function calculateVelocity()
- {
- $diffTime = max(0.05, abs(microtime(true) - $this->last[5]));
- $origin = new Vector2($this->last[0], $this->last[2]);
- $final = new Vector2($this->x, $this->z);
- $speedX = ($this->last[0] - $this->x) / $diffTime;
- $speedY = ($this->last[1] - $this->y) / $diffTime;
- $speedZ = ($this->last[2] - $this->z) / $diffTime;
- if($this->speedX != $speedX or $this->speedY != $speedY or $this->speedZ != $speedZ){
- $this->speedX = $speedX;
- $this->speedY = $speedY;
- $this->speedZ = $speedZ;
- $this->server->api->handle("entity.motion", $this);
- }
- $this->speed = $origin->distance($final) / $diffTime;
- unset($this->speedMeasure[key($this->speedMeasure)]);
- $this->speedMeasure[] = $this->speed;
- }
- /**
- * @return array
- */
- public function createSaveData(){
- $data = [
- "id" => $this->type,
- "Health" => $this->health,
- "Pos" => [
- 0 => $this->x,
- 1 => $this->y,
- 2 => $this->z,
- ],
- "Rotation" => [
- 0 => $this->yaw,
- 1 => $this->pitch,
- ],
-
- ];
- if($this->class === ENTITY_OBJECT){
- $data["TileX"] = $this->x;
- $data["TileY"] = $this->y;
- $data["TileZ"] = $this->z;
- }
- if($this->class === ENTITY_FALLING){
- $data["Tile"] = $this->data["Tile"];
- $data["Metadata"] = $this->data["Metadata"];
- }
- if($this->class === ENTITY_ITEM){
- $data["Item"] = [
- "id" => $this->type,
- "Damage" => $this->meta,
- "Count" => $this->stack,
- ];
- }
- return $data;
- }
-
- public function updateLast()
- {
- $this->last[0] = $this->x;
- $this->last[1] = $this->y;
- $this->last[2] = $this->z;
- $this->last[3] = $this->yaw;
- $this->last[4] = $this->pitch;
- $this->last[5] = microtime(true);
- $this->lastHeadYaw = $this->headYaw;
- }
-
- public function getPosition($round = false)
- {
- return ! isset($this->position) ? false : ($round === true ? array_map("floor", $this->position) : $this->position);
- }
-
- public function harm($dmg, $cause = "generic", $force = false)
- {
- if (! $this->canBeAttacked) {
- return false;
- }
- $dmg = $this->applyArmor($dmg, $cause); //TODO HURTCAM
- $ret = $this->setHealth(max(- 128, $this->getHealth() - ((int) $dmg)), $cause, $force);
-
- if ($ret != false && $this->hasKnockback && is_numeric($cause) && ($entity = $this->server->api->entity->get($cause)) != false) {
- $d = $entity->x - $this->x;
-
- for ($d1 = $entity->z - $this->z; $d * $d + $d1 * $d1 < 0.0001; $d1 = (lcg_value() - lcg_value()) * 0.01) {
- $d = (lcg_value() - lcg_value()) * 0.01;
- }
- if($this->isPlayer()){
- //force reset speed
- $this->speedX = $this->speedY = $this->speedZ = 0;
- }
- // attackedAtYaw = (float)((Math.atan2($d1, $d) * 180D) / 3.1415927410125732D) >
- $this->knockBack($d, $d1);
- if($this->isPlayer()){
- $pk = new SetEntityMotionPacket();
- $pk->entities = [[0, $this->speedX, $this->speedY, $this->speedZ]];
- $this->player->directDataPacket($pk, 0);
- }
- $this->knockbackTime = 10;
- $this->sendMotion();
-
- }
-
- return $ret;
- }
-
- public function setState($v)
- {
- $this->state = $v;
- $this->data["State"] = $v;
- $this->updateMetadata();
- }
-
- public function getState()
- {
- return $this->state;
- }
-
- public function heal($health, $cause = "generic")
- {
- return $this->setHealth(min(20, $this->getHealth() + ((int) $health)), $cause);
- }
-
- public function sendMotion()
- {
- $pk = new SetEntityMotionPacket();
- $pk->entities = [[$this->eid, $this->speedX, $this->speedY, $this->speedZ]];
- $this->server->api->player->broadcastPacket($this->level->players, $pk);
- }
-
- public function linkEntity(Entity $e, $type)
- {
- //if($e->isPlayer()){
- $this->server->api->dhandle("entity.link", ["rider" => $e->eid, "riding" => $this->eid, "type" => 0]);
- //}
- }
-
- public function isPlayer()
- {
- return isset($this->player) && $this->player instanceof Player;
- }
-
- public function sendMoveUpdate()
- {
- if($this->class === ENTITY_PLAYER){
- $this->player->teleport(new Vector3($this->x, $this->y, $this->z));
- return;
- }
- $pk = new MoveEntityPacket();
- $pk->entities = [[$this->eid, $this->x, $this->y, $this->z, $this->yaw, $this->pitch]];
- $this->server->api->player->broadcastPacket($this->level->players, $pk);
- }
-
- public function moveEntityWithOffset($oX, $oY, $oZ)
- {
- $oX = $oX === 0 ? $this->speedX : ($this->getSpeedModifer() * $oX * $this->getSpeed());
- $oY = $oY <= 0 ? $this->speedY : (0.42);
- $oZ = $oZ === 0 ? $this->speedZ : ($this->getSpeedModifer() * $oZ * $this->getSpeed());
- $this->setVelocity($oX, $oY, $oZ);
- }
-
- public function getSpeedModifer()
- {
- return $this->speedModifer;
- }
- public function getArmorValue(){
- $pnts = 0;
- if($this->isPlayer()){
- foreach($this->player->armor as $slot => $part){
- if($part instanceof ArmorItem){
- $pnts += $part->getDamageReduceAmount();
- $this->player->damageArmorPart($slot, $part);
- }
- }
- $this->player->sendArmor($this->player);
- }
- return $pnts;
- }
- public function applyArmor($damage, $cause){
- if(is_numeric($cause) || $cause === "explosion"){
- $var3 = 25 - $this->getArmorValue();
- $var4 = $damage * $var3 + $this->carryoverDamage;
- $damage = $var4 / 25;
- $this->carryoverDamage = $var4 % 25;
- }
- return $damage;
- }
-
- public function setHealth($health, $cause = "generic", $force = false)
- {
- $health = (int) $health;
- $harm = false;
- if($health < $this->health){
- $harm = true;
- $dmg = $this->health - $health;
- if(($this->class !== ENTITY_PLAYER or (($this->player instanceof Player) and (($this->player->gamemode & 0x01) === 0x00 or $force === true))) and ($this->dmgcounter[0] < microtime(true) or $this->dmgcounter[1] < $dmg) and ! $this->dead){
- $this->dmgcounter[0] = microtime(true) + 0.5;
- $this->dmgcounter[1] = $dmg;
- } else{
- return false; // Entity inmunity
- }
- } elseif($health === $this->health and ! $this->dead){
- return false;
- }
- if($this->server->api->dhandle("entity.health.change", array(
- "entity" => $this,
- "eid" => $this->eid,
- "health" => $health,
- "cause" => $cause
- )) !== false or $force === true){
- $this->health = min(127, max(- 127, $health));
- $this->server->query("UPDATE entities SET health = " . $this->health . " WHERE EID = " . $this->eid . ";");
- if($harm === true){
- $pk = new EntityEventPacket;
- $pk->eid = $this->eid;
- $pk->event = EntityEventPacket::ENTITY_DAMAGE;
- $this->server->api->player->broadcastPacket($this->level->players, $pk);
- }
- if($this->player instanceof Player){
- $pk = new SetHealthPacket();
- $pk->health = $this->health;
- $this->player->dataPacket($pk);
- }
- if($this->health <= 0 and $this->dead === false){
- $this->makeDead($cause);
- } elseif($this->health > 0){
- $this->dead = false;
- }
- return true;
- }
- return false;
- }
-
- public function setSize($w, $h)
- {
- $this->width = $w;
- $this->height = $h;
- $this->radius = $w / 2;
- }
-
- public function makeDead($cause){
- if($this->server->api->dhandle("entity.death", ["entity" => $this, "cause" => $cause]) === false) return false;
- $this->spawnDrops();
- $this->air = 200;
- $this->fire = 0;
- $this->crouched = false;
- $this->fallY = false;
- $this->fallStart = false;
- $this->updateMetadata();
- $this->dead = true;
- if($this->player instanceof Player){
- $pk = new MoveEntityPacket_PosRot();
- $pk->eid = $this->eid;
- $pk->x = - 256;
- $pk->y = 128;
- $pk->z = - 256;
- $pk->yaw = 0;
- $pk->pitch = 0;
- $this->server->api->player->broadcastPacket($this->level->players, $pk);
- }else{
- $pk = new EntityEventPacket;
- $pk->eid = $this->eid;
- $pk->event = EntityEventPacket::ENTITY_DEAD;
- $this->server->api->player->broadcastPacket($this->level->players, $pk);
- }
- if($this->player instanceof Player){
- $this->player->blocked = true;
- $this->server->api->dhandle("player.death", [
- "player" => $this->player,
- "cause" => $cause
- ]);
- if($this->server->api->getProperty("hardcore") == 1){ //poor player =<
- $this->server->api->ban->ban($this->player->username);
- }
- } else{
- $this->server->api->schedule(40, [$this, "close"], []);
- }
- }
-
- public function getAttackDamage(){
- return 0;
- }
-
- public function setSpeed($s)
- {
- $this->speed = $s;
- }
-
- public function knockBack($d, $d1)
- {
- $f = sqrt($d * $d + $d1 * $d1);
- $f1 = 0.4;
- $this->speedX /= 2;
- $this->speedY /= 2;
- $this->speedZ /= 2;
- $this->speedX -= ($d / $f) * $f1;
- $this->speedY += 0.4;
- $this->speedZ -= ($d1 / $f) * $f1;
- if($this->speedY > 0.40000000596046448){
- $this->speedY = 0.40000000596046448;
- }
- }
-
- public function getHealth()
- {
- return $this->health;
- }
-
- public function __toString()
- {
- return "Entity(x={$this->x},y={$this->y},z={$this->z},level=" . $this->level->getName() . ",class={$this->class},type={$this->type})";
- }
-
- /**
- * Debug
- */
- public function printSpeed($add = ""){
- ConsoleAPI::debug("$add {$this->speedX}:{$this->speedY}:{$this->speedZ}");
- }
-
- /*
- * Deprecated methods.
- * Those methods were left only for compability with older plugins
- */
- /**
- *
- * @deprecated Use {@link getHeightOf} or {@link getWidthOf} instead
- * @throws Exception
- */
- public static function getSizeOf($e)
- {
- throw new Exception("Use getHeightOf or getWidthOf method instead of this.");
- }
-
-
- /**
- *
- * @deprecated Use {@link getHeight} or {@link getWidth} instead
- * @throws Exception
- */
- public function getSize()
- {
- throw new Exception("Use getHeight or getWidth method instead of this.");
- }
-}
diff --git a/src/entity/Hanging.php b/src/entity/Hanging.php
deleted file mode 100644
index 554abb69..00000000
--- a/src/entity/Hanging.php
+++ /dev/null
@@ -1,5 +0,0 @@
-target = false;
- $this->ai = new EntityAI($this);
- $this->pathFinder = new TileNavigator(new MCBlockedProvider(), new MCDiagonalProvider(), new ManhattanHeuristic3D());
- $this->pathFollower = new PathFollower($this);
- parent::__construct($level, $eid, $class, $type, $data);
- $this->canBeAttacked = true;
- $this->hasGravity = true;
- $this->hasKnockback = true;
- if(self::$despawnMobs) $this->server->schedule(self::$despawnTimer, [$this, "close"]); //900*20
- }
-
- public function hasPath(){
- return $this->path != null;
- }
-
- public function close(){
- parent::close();
- unset($this->pathFollower->entity);
- unset($this->ai->entity);
- unset($this->ai->mobController->entity);
- unset($this->ai);
- unset($this->parent);
- }
- public function updateEntityMovement(){
- if(!$this->dead && Entity::$allowedAI && $this->idleTime <= 0) {
- $this->ai->updateTasks();
- }
- $this->ai->mobController->rotateTick();
- //$this->ai->mobController->movementTick();
-
- /*if(self::$entityPushing){
- $this->collideHandler();
- }*/
- if($this->onGround){
- //if(!$this->hasPath() && $this->pathFinder instanceof ITileNavigator){
- // $this->path = $this->pathFinder->navigate(new PathTileXYZ($this->x, $this->y, $this->z, $this->level), new PathTileXYZ($this->x + mt_rand(-10, 10), $this->y + mt_rand(-1, 1), $this->z + mt_rand(-10, 10), $this->level), 10);
- //}
- //$this->pathFollower->followPath();
- }
- }
-
- public function sendMoveUpdate(){
- if($this->counter % 3 != 0){
- return;
- }
- parent::sendMoveUpdate();
- }
-}
diff --git a/src/entity/Monster.php b/src/entity/Monster.php
deleted file mode 100644
index 969de944..00000000
--- a/src/entity/Monster.php
+++ /dev/null
@@ -1,15 +0,0 @@
-ai->addTask(new TaskAttackPlayer());
- }
-
- public function getAttackDamage(){
- return 2;
- }
-
- public function attackEntity($entity){
- $entity->harm($this->getAttackDamage(), $this->eid);
- }
-}
diff --git a/src/entity/Neutral.php b/src/entity/Neutral.php
deleted file mode 100644
index faaaf4a9..00000000
--- a/src/entity/Neutral.php
+++ /dev/null
@@ -1,7 +0,0 @@
-entity = $entity;
- $this->tasks = [];
- $this->mobController = new MobController($entity);
- }
-
- /**
- * Add a task for entity
- * @param TaskBase $task
- */
- public function addTask(TaskBase $task){
- $this->tasks[$task->__toString()] = $task;
- }
- public function removeTask($name){
- if(isset($this->tasks[$name])){
- unset($this->tasks[$name]);
- return true;
- }
- return false;
- }
-
- /**
- *
- * @param mixed $id classname
- * @return TaskBase | false
- */
- public function getTask($id){
- return isset($this->tasks[$id]) ? $this->tasks[$id] : false;
- }
-
- public function isStarted($id){
- $task = @$this->getTask($id);
- return $task instanceof TaskBase && $task->isStarted;
- }
-
- public function updateTasks(){
- if(!isset($this->entity) or !($this->entity instanceof Entity)){
- return;
- }
- foreach($this->tasks as $t){
- if(!$t->isStarted && $t->canBeExecuted($this)){
- $t->isStarted = true;
- $t->onStart($this);
- }
- if($t->isStarted){
- $t->onUpdate($this);
- if($t->selfCounter <= 0){
- $t->isStarted = false;
- $t->onEnd($this);
- }
- }
- }
- }
-
- public function __destruct(){
- unset($this->entity);
- }
-
-}
-
diff --git a/src/entity/ai/MobController.php b/src/entity/ai/MobController.php
deleted file mode 100644
index 32a8db86..00000000
--- a/src/entity/ai/MobController.php
+++ /dev/null
@@ -1,96 +0,0 @@
-entity = $e;
- }
-
- public function moveNonInstant($x, $y, $z){
- if($x == 0 && $y == 0 && $z == 0){
- return false;
- }
-
- $ox = ($x > 0 ? 1 : ($x < 0 ? -1 : 0));
- $oy = ($y > 0 ? 1 : ($y < 0 ? -1 : 0));
- $oz = ($z > 0 ? 1 : ($z < 0 ? -1 : 0));
- $xf = $this->entity->x + ($this->entity->getSpeedModifer() * $ox * $this->entity->getSpeed());
- $zf = $this->entity->z + ($this->entity->getSpeedModifer() * $oz * $this->entity->getSpeed());
- if($this->entity->onGround){
- $bs = [ //TODO simplify(somehow)
- $this->entity->level->getBlockWithoutVector(ceil($xf), floor($this->entity->y), ceil($zf)),
- $this->entity->level->getBlockWithoutVector(ceil($xf), floor($this->entity->y), $zf - ($oz < 0 ? 1 : 0)),
- $this->entity->level->getBlockWithoutVector($xf - ($ox < 0 ? 1 : 0), floor($this->entity->y), $zf - ($oz < 0 ? 1 : 0)),
- $this->entity->level->getBlockWithoutVector($xf - ($ox < 0 ? 1 : 0), floor($this->entity->y), ceil($zf)),
- ];
- foreach($bs as $b){
- if($b->isSolid){
- if(!$b->getSide(1)->isSolid){
- $oy = 1;
- break;
- }
- }
- }
- }
- $this->faceEntity($this->entity->add($ox, $oy, $oz));
- if($this->entity->knockbackTime <= 0){
- $this->entity->moveEntityWithOffset($ox, $oy, $oz);
- }
- return true;
- }
- public function rotateTick(){ //TODO handle more rotation
- $w180 = Utils::wrapAngleTo180($this->finalHeadYaw - $this->entity->headYaw);
- $w180min = min(abs($w180), 20)*Utils::getSign($w180);
- $this->entity->headYaw = Utils::wrapAngleTo360($this->entity->headYaw + $w180min);
- }
- public function moveTo($x, $y, $z){
- return $this->moveNonInstant($x - floor($this->entity->x), $y - floor($this->entity->y), $z - floor($this->entity->z));
- }
-
- public function faceEntity(Vector3 $v){
- $d = $v->subtract($this->entity)->normalize();
- $dx = $d->x;
- $dz = $d->z;
-
- $tan = $dz == 0 ? ($dx < 0 ? 180 : 0) : (90 - rad2deg(atan($dx / $dz)));
- $thetaOffset = $dz < 0 ? 90 : 270;
- $calcYaw = ($thetaOffset + $tan);
- $this->finalHeadYaw = $this->entity->yaw = $calcYaw;
- }
-
- public function lookOffset($x, $y, $z, $pitch = true){
- $tan = $z == 0 ? ($x < 0 ? 180 : 0) : (90 - rad2deg(atan($x / $z))); /*arctan(infinity) = pi/2 = (90deg) - 90 = 0*/
- $thetaOffset = $z < 0 ? 90 : 270;
- $calcYaw = $tan + $thetaOffset;
-
- $this->entity->yaw = $this->finalHeadYaw = $calcYaw;
-
- if($pitch){
- $diff = sqrt($x * $x + $z * $z);
- $calcPitch = $diff == 0 ? ($y < 0 ? -90 : 90) : rad2deg(atan($y / $diff));
- $this->entity->pitch = $this->entity->type === MOB_CHICKEN ? -$calcPitch : $calcPitch;
- }
-
- $this->entity->server->query("UPDATE entities SET pitch = ".$this->entity->pitch.", yaw = ".$this->entity->yaw." WHERE EID = ".$this->entity->eid.";");
- return true;
- }
-
- public function lookOn($x, $y = 0, $z = 0, $pitch = true){
- if($x instanceof Vector3){
- return $this->lookOn($x->x, $x->y + $x->getEyeHeight(), $x->z, $pitch);
- }
- return $this->lookOffset($x - $this->entity->x, ($this->entity->y + $this->entity->height) - $y, $z - $this->entity->z, $pitch);
- }
-
- public function __destruct(){
- unset($this->entity);
- }
-}
-
diff --git a/src/entity/ai/path/PathFollower.php b/src/entity/ai/path/PathFollower.php
deleted file mode 100644
index 2a1a1097..00000000
--- a/src/entity/ai/path/PathFollower.php
+++ /dev/null
@@ -1,27 +0,0 @@
-entity = $entity;
- }
-
- public function followPath(){
- if(!isset($entity) or $this->entity->path == null){
- return;
- }
- if((is_array($this->entity->path) && count($this->entity->path) <= 0 || $this->entity->currentIndex >= count($this->entity->path))){
- $this->entity->path = null;
- $this->entity->currentIndex = 0;
- $this->entity->currentNode = false;
- }elseif(($this->entity->currentNode == false || $this->entity->ai->mobController->moveTo($this->entity->currentNode->x, $this->entity->currentNode->y, $this->entity->currentNode->z) === false)){
- $this->entity->currentNode = $this->entity->path[$this->entity->currentIndex++];
- }
- }
-
-}
-
diff --git a/src/entity/ai/tasks/TaskAttackPlayer.php b/src/entity/ai/tasks/TaskAttackPlayer.php
deleted file mode 100644
index 1fc5e4f7..00000000
--- a/src/entity/ai/tasks/TaskAttackPlayer.php
+++ /dev/null
@@ -1,63 +0,0 @@
-selfCounter = 1;
- }
-
- public function onUpdate(EntityAI $ai){
- if(!($this->target instanceof Entity)
- || ($ai->entity instanceof Spider && $ai->entity->level->isDay())
- || ($this->target instanceof Entity && !$this->target->isPlayer())
- || (Utils::distance_noroot($this->target, $ai->entity) > 256)
- || $this->target->level->getName() != $ai->entity->level->getName()){
- $this->reset();
- if($ai->entity instanceof Enderman){
- $ai->entity->setAngry(false);
- }
- return;
- }
-
- $ai->mobController->moveTo($this->target->x, floor($ai->entity->y), $this->target->z);
- $ai->mobController->lookOn($this->target);
- $mult = $ai->entity instanceof Spider ? 1 : 2;
- $radius = ($ai->entity->width * $mult)*($ai->entity->width * $mult);
- if(Utils::distance_noroot($this->target, $ai->entity) <= $radius && $this->attackTime <= 0){
- if($ai->entity instanceof Slime && $ai->entity->getSlimeSize() == 1){
- $this->attackTime = 20;
- }
- else{
- $ai->entity->attackEntity($this->target);
- $this->attackTime = 20;
- }
- }
- --$this->attackTime;
- }
- public function onEnd(EntityAI $ai){
- parent::onEnd($ai);
- if($ai->entity instanceof Enderman){
- $ai->entity->setAngry(false);
- }
- }
-
- public function canBeExecuted(EntityAI $ai){
- $target = $this->findTarget($ai->entity, 16);
- if(($ai->entity instanceof Spider && !$ai->entity->level->isDay())
- || $target instanceof Entity
- && $target->class === ENTITY_PLAYER
- && $target->isPlayer()){
- $this->target = $target; //TODO get rid of it
- $ai->entity->target = $target;
- if($ai->entity instanceof Enderman){ //TODO find a better way
- $ai->entity->setAngry(true);
- }
- return true;
- }
- return false;
- }
-}
-
diff --git a/src/entity/ai/tasks/TaskBase.php b/src/entity/ai/tasks/TaskBase.php
deleted file mode 100644
index a1f00294..00000000
--- a/src/entity/ai/tasks/TaskBase.php
+++ /dev/null
@@ -1,47 +0,0 @@
-isStarted = false;
- $this->selfCounter = 0;
- }
-
- final function __toString(){
- return get_class($this);
- }
-}
-
diff --git a/src/entity/ai/tasks/TaskLookAround.php b/src/entity/ai/tasks/TaskLookAround.php
deleted file mode 100644
index af13cff6..00000000
--- a/src/entity/ai/tasks/TaskLookAround.php
+++ /dev/null
@@ -1,32 +0,0 @@
-selfCounter = 1;
- $this->rotation = mt_rand(-120, 120);
- }
-
- public function onEnd(EntityAI $ai)
- {
- $ai->entity->idleTime = mt_rand(20, 40);
- }
-
- public function canBeExecuted(EntityAI $ai)
- {
- return !$ai->entity->inPanic && !$ai->entity->isMoving() && lcg_value() < 0.02 && !$ai->isStarted("TaskLookAtPlayer") && !$ai->isStarted("TaskTempt") && !$ai->entity->hasPath(); /*Vanilla value*/
- }
-
- public function onUpdate(EntityAI $ai)
- {
- if($this->rotation === 0){
- $this->selfCounter = 0;
- }
- $v = min(Utils::getSign($this->rotation) * 10, $this->rotation);
- $ai->entity->headYaw += $v;
- $this->rotation -= $v;
-
- }
-}
diff --git a/src/entity/ai/tasks/TaskLookAtPlayer.php b/src/entity/ai/tasks/TaskLookAtPlayer.php
deleted file mode 100644
index cf9c624c..00000000
--- a/src/entity/ai/tasks/TaskLookAtPlayer.php
+++ /dev/null
@@ -1,66 +0,0 @@
-entity->inPanic && lcg_value() < 0.02 && !$ai->entity->isMovingHorizontally() && !$ai->isStarted("TaskLookAround") && !$ai->isStarted("TaskTempt") && !$ai->entity->hasPath();
- }
-
- protected function findTarget($e, $r){
- $svd = null;
- $svdDist = -1;
- foreach($e->level->players as $p){
- $p = $p->entity;
- if(Utils::distance_noroot($e, $p) > $r*$r){
- continue;
- }
- if($svdDist === -1){
- $svdDist = Utils::distance_noroot($e, $p);
- $svd = $p;
- continue;
- }
- if($svd != null && $svdDist === 0){
- $svd = $p;
- }
- if(($cd = Utils::distance_noroot($e, $p)) < $svdDist){
- $svdDist = $cd;
- $svd = $p;
- }
- }
-
- if($svd == null){
- return null;
- }
-
- return $svd;
- }
-
- public function onStart(EntityAI $ai){
- $this->target = $this->findTarget($ai->entity, 6); //TODO max distance for different mobs
- if(!($this->target instanceof Entity) || !$this->target->isPlayer()){
- $this->reset();
- $this->onEnd($ai);
- return;
- }
- $this->yaw = $ai->entity->yaw;
- $this->pitch = $ai->entity->pitch;
- $this->selfCounter = mt_rand(20, 60);
- }
-
- public function onUpdate(EntityAI $ai){
- if(!($this->target instanceof Entity) || Utils::distance($ai->entity, $this->target) > 6 || $this->target->level->getName() != $ai->entity->level->getName()){ //TODO max distance for different mobs
- $this->reset();
- $this->onEnd($ai);
- return;
- }
- $ai->mobController->lookOn($this->target);
- $this->selfCounter--;
- }
-
- public function onEnd(EntityAI $ai){
- unset($this->target);
- $ai->entity->pitch = 0;
- }
-}
-
diff --git a/src/entity/ai/tasks/TaskPanic.php b/src/entity/ai/tasks/TaskPanic.php
deleted file mode 100644
index c3f52233..00000000
--- a/src/entity/ai/tasks/TaskPanic.php
+++ /dev/null
@@ -1,41 +0,0 @@
-selfCounter = 60;
- $this->regenerateRandXZ();
- }
-
- public function onEnd(EntityAI $ai)
- {
- $ai->entity->inPanic = false;
- $this->reset();
- }
-
- public function regenerateRandXZ(){
- $this->randX = (mt_rand(0, 1) ? -1 : 1) * 2;
- $this->randZ = (mt_rand(0, 1) ? -1 : 1) * 2;
- }
-
- public function reset(){
- $this->randX = $this->randZ = 2;
- }
-
- public function onUpdate(EntityAI $ai)
- {
- --$this->selfCounter;
- if($this->selfCounter % 20 === 0) $this->regenerateRandXZ();
- $ai->mobController->moveNonInstant($this->randX, 0, $this->randZ);
- }
-
- public function canBeExecuted(EntityAI $ai)
- {
- return $ai->entity instanceof Animal && $ai->entity->inPanic && $ai->entity->knockbackTime <= 0;
- }
-
-
-}
-
diff --git a/src/entity/ai/tasks/TaskRandomWalk.php b/src/entity/ai/tasks/TaskRandomWalk.php
deleted file mode 100644
index 429dbf6a..00000000
--- a/src/entity/ai/tasks/TaskRandomWalk.php
+++ /dev/null
@@ -1,41 +0,0 @@
-x = mt_rand(-16, 16);
- $this->z = mt_rand(-16, 16);
- if($this->x === 0 && $this->z === 0){
- $this->reset();
- return false;
- }
- $this->selfCounter = floor(5 * Utils::distance($ai->entity, $ai->entity->add($this->x, 0, $this->z)));
- }
-
- public function onEnd(EntityAI $ai)
- {
- $this->x = $this->z = 0;
- }
-
- public function onUpdate(EntityAI $ai)
- {
- if(($ai->entity instanceof Creeper && $ai->entity->isIgnited()) || $ai->isStarted("TaskTempt")) {
- $this->reset();
- return false; //TODO Better way: block movement
- }
- --$this->selfCounter;
- $ai->mobController->moveNonInstant($this->x, 0, $this->z);
- }
-
- public function canBeExecuted(EntityAI $ai)
- {
- if(($ai->entity instanceof Creeper && $ai->entity->isIgnited()) || $ai->entity->hasPath() || $ai->isStarted("TaskTempt")) {
- return false;
- }
- return !$ai->entity->inPanic && !$ai->isStarted("TaskLookAround") && !$ai->isStarted("TaskLookAtPlayer") && mt_rand(0, 120) == 0;
- }
-
-
-}
diff --git a/src/entity/ai/tasks/TaskSwimming.php b/src/entity/ai/tasks/TaskSwimming.php
deleted file mode 100644
index 5cc72be9..00000000
--- a/src/entity/ai/tasks/TaskSwimming.php
+++ /dev/null
@@ -1,34 +0,0 @@
-selfCounter = 1;
- }
-
- public function onEnd(EntityAI $ai)
- {
-
- }
-
- public function onUpdate(EntityAI $ai)
- {
- if(!$ai->entity->inWater){
- $this->reset();
- }
-
- if(lcg_value() < 0.8){ #1.5.2 method
- $ai->entity->speedY = 0.42;
- }
-
-
- }
-
- public function canBeExecuted(EntityAI $ai)
- {
- return $ai->entity->inWater;
- }
-
-}
-
diff --git a/src/entity/ai/tasks/TaskTempt.php b/src/entity/ai/tasks/TaskTempt.php
deleted file mode 100644
index 1e2bfc21..00000000
--- a/src/entity/ai/tasks/TaskTempt.php
+++ /dev/null
@@ -1,74 +0,0 @@
-selfCounter = 1;
- }
-
- public function onEnd(EntityAI $ai)
- {
- unset($this->target);
- unset($ai->entity->target);
- $ai->entity->pitch = 0;
- }
-
- public function onUpdate(EntityAI $ai)
- {
- if(!($this->target instanceof Entity) || ($this->target instanceof Entity && !$this->target->isPlayer()) || (Utils::distance_noroot($this->target, $ai->entity) > 100) || !$ai->entity->isFood($this->target->player->getHeldItem()->getID()) || $this->target->level->getName() != $ai->entity->level->getName()){
- $this->reset();
- return;
- }
-
- $ai->mobController->moveTo($this->target->x, floor($ai->entity->y), $this->target->z);
- $ai->mobController->lookOn($this->target);
- }
-
- public function canBeExecuted(EntityAI $ai)
- {
- if(!($ai->entity instanceof Breedable) || $ai->entity->inPanic){ //TODO Work with path
- return false;
- }
- $target = $this->findTarget($ai->entity, 10);
- if($target instanceof Entity && $target->class === ENTITY_PLAYER && $target->isPlayer() && $ai->entity->isFood($target->player->getHeldItem()->getID())){
- $this->target = $target;
- $ai->entity->target = $target;
- return true;
- }
-
- return false;
- }
-
- protected function findTarget($e, $r){
- $svd = null;
- $svdDist = -1;
- foreach($e->level->players as $p){
- $p = $p->entity;
- if(Utils::distance_noroot($e, $p) > $r*$r){
- continue;
- }
- if($svdDist === -1){
- $svdDist = Utils::distance_noroot($e, $p);
- $svd = $p;
- continue;
- }
- if($svd != null && $svdDist === 0){
- $svd = $p;
- }
- if(($cd = Utils::distance_noroot($e, $p)) < $svdDist){
- $svdDist = $cd;
- $svd = $p;
- }
- }
-
- if($svd == null){
- return null;
- }
-
- return $svd;
- }
-}
-
diff --git a/src/entity/animal/Chicken.php b/src/entity/animal/Chicken.php
deleted file mode 100644
index 0294bef7..00000000
--- a/src/entity/animal/Chicken.php
+++ /dev/null
@@ -1,41 +0,0 @@
-timeUntilEgg = mt_rand(0,6000) + 6000;
- $this->setSize($this->isBaby() ? 0.2 : 0.4, $this->isBaby() ? 0.35 : 0.7);
- parent::__construct($level, $eid, $class, $type, $data);
- $this->setHealth(isset($this->data["Health"]) ? $this->data["Health"] : 4, "generic");
- $this->setName('Chicken');
- $this->setSpeed(0.25);
- $this->update();
- }
- public function isFood($id){
- return $id === PUMPKIN_SEEDS || $id === MELON_SEEDS || $id === BEETROOT_SEEDS || $id === WHEAT_SEEDS;
- }
-
- public function update(){
- parent::update();
- if($this->timeUntilEgg-- <= 0 && !$this->isBaby()){
- $this->dropAnEgg();
- $this->timeUntilEgg = mt_rand(0,6000) + 6000;
- }
- }
-
- public function dropAnEgg(){
- if($this->closed){
- return;
- }
- ServerAPI::request()->api->entity->drop(new Position($this->x + 0.5, $this->y, $this->z + 0.5, $this->level), BlockAPI::getItem(EGG, 0, 1));
- }
-
- public function getDrops(){
- return $this->isBaby() ? parent::getDrops() : [
- [FEATHER, 0, mt_rand(0,2)],
- [$this->fire > 0 ? COOKED_CHICKEN : RAW_CHICKEN, 0, 1]
- ];
- }
-
-}
diff --git a/src/entity/animal/Cow.php b/src/entity/animal/Cow.php
deleted file mode 100644
index cc98e5d7..00000000
--- a/src/entity/animal/Cow.php
+++ /dev/null
@@ -1,37 +0,0 @@
-setSize($this->isBaby() ? 0.45 : 0.9 , $this->isBaby() ? 0.7 : 1.4);
- parent::__construct($level, $eid, $class, $type, $data);
- $this->setHealth(isset($this->data["Health"]) ? $this->data["Health"] : 10, "generic");
- $this->setName("Cow");
- $this->setSpeed(0.2);
- $this->update();
- }
-
- public function isFood($id){
- return $id === WHEAT;
- }
-
- public function interactWith(Entity $e, $action){
- if($e->isPlayer() && $action === InteractPacket::ACTION_HOLD){
- $slot = $e->player->getHeldItem();
- if($slot->getID() === BUCKET && $slot->getMetadata() === 0){
- $e->player->removeItem($slot->getID(), $slot->getMetadata(), 1, true); //remove only 1 bucket
- $e->player->addItem(BUCKET, 1, 1, true);
- return true;
- }
- }
- parent::interactWith($e, $action);
- }
-
- public function getDrops(){
- return $this->isBaby() ? parent::getDrops() : [
- [LEATHER, 0, mt_rand(0,2)],
- [($this->fire > 0 ? STEAK : BEEF), 0, mt_rand(0, 3)]
- ];
- }
-
-}
\ No newline at end of file
diff --git a/src/entity/animal/Mooshroom.php b/src/entity/animal/Mooshroom.php
deleted file mode 100644
index 017ee1b4..00000000
--- a/src/entity/animal/Mooshroom.php
+++ /dev/null
@@ -1,25 +0,0 @@
-setName("Mooshroom");
- $this->update();
- }
-
- public function interactWith(Entity $e, $action){
- if($e->isPlayer() && $action === InteractPacket::ACTION_HOLD){
- $slot = $e->player->getHeldItem();
- if($slot->getID() === SHEARS){
- //drop
- $this->close();
- $this->server->api->entity->summon($this, ENTITY_MOB, MOB_COW, $this->data);
- return true;
- }
- }
- parent::interactWith($e, $action);
- }
-}
\ No newline at end of file
diff --git a/src/entity/animal/Pig.php b/src/entity/animal/Pig.php
deleted file mode 100644
index 37a4ad40..00000000
--- a/src/entity/animal/Pig.php
+++ /dev/null
@@ -1,72 +0,0 @@
-setSize($this->isBaby() ? 0.45 : 0.9, $this->isBaby() ? 0.45 : 0.9);
- parent::__construct($level, $eid, $class, $type, $data);
- $this->setHealth(isset($this->data["Health"]) ? $this->data["Health"]:10, "generic");
- $this->server = ServerAPI::request();
- $this->setName("Pig");
- $this->setSpeed(0.25);
- $this->update();
- }
- /**
- * @return boolean
- */
- public function isSaddled(){
- return (boolean) $this->getState();
- }
-
- /**
- * @param boolean $value
- */
- public function setSaddled($value = null){
- $this->setState($value === null ? !$this->getState() : $value);
- }
-
- public function canRide($e){
- return $this->isSaddled() && !($this->linkedEntity instanceof Entity);
- }
-
- public function interactWith(Entity $e, $action)
- {
- if($e->isPlayer() && $action === InteractPacket::ACTION_HOLD){
- $slot = $e->player->getHeldItem();
- if($this->canRide($e)){
- $this->linkedEntity = $e;
- $e->isRiding = true;
- $this->linkEntity($e, SetEntityLinkPacket::TYPE_RIDE);
- return true;
- }
- if($e->isRiding && $this->linkedEntity->eid = $e->eid){
- $this->linkEntity($e, SetEntityLinkPacket::TYPE_REMOVE);
- $e->isRiding = false;
- $this->linkedEntity = 0;
- return true;
- }
- if($slot->getID() === SADDLE){
- if(!$this->isSaddled()){
- $e->player->removeItem($slot->getID(), 0, 1);
- $this->setSaddled(1);
- }
- return true; //avoid further interactions
- }
-
- }
- return parent::interactWith($e, $action);
- }
-
- public function isFood($id){
- return $id === POTATO || $id === CARROT || $id === BEETROOT;
- }
-
- public function getDrops(){
- return $this->isBaby() ? parent::getDrops() : ($this->isSaddled() ? [
- [($this->fire > 0 ? COOKED_PORKCHOP : RAW_PORKCHOP), 0, mt_rand(0,2)],
- [SADDLE, 0, 1]
- ] : [
- [($this->fire > 0 ? COOKED_PORKCHOP : RAW_PORKCHOP), 0, mt_rand(0,2)]
- ]);
- }
-}
diff --git a/src/entity/animal/Sheep.php b/src/entity/animal/Sheep.php
deleted file mode 100644
index 5159c3b7..00000000
--- a/src/entity/animal/Sheep.php
+++ /dev/null
@@ -1,128 +0,0 @@
-setSize($this->isBaby() ? 0.45 : 0.9, $this->isBaby() ? 0.675 : 1.3);
- parent::__construct($level, $eid, $class, $type, $data);
- $this->setHealth(isset($this->data["Health"]) ? $this->data["Health"] : 8, "generic");
- $this->setName("Sheep");
- $this->data["Sheared"] = isset($this->data["Sheared"]) ? $this->data["Sheared"] : 0;
- $this->data["Color"] = isset($this->data["Color"]) ? $this->data["Color"] : $this->sheepColor();
- $this->setSpeed(0.25);
- $this->update();
- if($this->isSheared() and Entity::$updateOnTick){ //if ai enabled
- $this->server->schedule(mt_rand(60, 400), [$this, "eatGrass"], null, true); //unknown time
- }elseif($this->isBaby() and Entity::$updateOnTick){
- $this->server->schedule(mt_rand(400, 1000), [$this, "eatGrass"], null, true); //unknown time
- }
- }
-
- public function createSaveData(){
- $data = parent::createSaveData();
- $data["Color"] = @$this->data["Color"];
- $data["Sheared"] = @$this->data["Sheared"];
- return $data;
- }
-
- public function eatGrass(){
- $downBlock = $this->level->getBlock(new Vector3($this->x, $this->y-1, $this->z));
- if($downBlock->getID() !== GRASS){
- //console("eww i don't wanna eat this $downBlock");
- return false;
- }
- $pk = new EntityEventPacket;
- $pk->eid = $this->eid;
- $pk->event = EntityEventPacket::ENTITY_ANIM_10;
- $this->server->api->player->broadcastPacket($this->level->players, $pk);
- $this->server->schedule(38, [$this, "setSheared"], false);
- $this->level->setBlock(new Position($this->x, $this->y-1, $this->z, $this->level), new DirtBlock());
- }
-
- public function setSheared($v = null){
- $this->data["Sheared"] = $v === null ? !$this->isSheared() : $v;
- $this->updateMetadata();
- }
-
- public function isSheared(){
- return $this->data["Sheared"];
- }
-
- public function getColor(){
- return $this->data["Color"]; //color === 16 -> color = 0, color === 17 -> color = 1 ...
- }
-
- public function switchColorMeta($meta){
- return abs($meta - 15);
- }
-
- public function setColor($meta){
- $this->data["Color"] = $meta;
- }
- public function getDrops(){
- return ($this->isBaby() || $this->isSheared()) ? parent::getDrops() : [
- [WOOL, $this->getColor(), 1]
- ];
- }
-
- public function isFood($id){
- return $id === WHEAT;
- }
-
- public function interactWith(Entity $e, $action){
- if($e->isPlayer() && $action === InteractPacket::ACTION_HOLD){
- $slot = $e->player->getHeldItem();
- if($slot->getID() === SHEARS){
- if(!$this->isSheared()){
- if($e->player->gamemode != 1) $slot->useOn($this);
- $this->setSheared(1);
- $this->server->api->entity->drop($this, BlockAPI::getItem(WOOL, $this->getColor(), mt_rand(1, 3)));
- //$this->server->schedule(20, [$this, "eatGrass"]);
- if($slot->getMetadata() >= $slot->getMaxDurability()){
- $e->player->removeItem($slot->getID(), $slot->getMetadata(), $slot->count, true);
- }else{
- $e->player->setSlot($e->player->slot, $slot);
- }
- }
- return true;
- }elseif($slot->getID() === DYE){
- $this->setColor($this->switchColorMeta($slot->getMetadata()));
-
- if(($e->player->gamemode & 0x01) === SURVIVAL){
- $e->player->removeItem($slot->getID(), $slot->getMetadata(), 1, true);
- }
- }
- }
- return parent::interactWith($e, $action);
- }
-
- public function getMetadata(){
- $d = parent::getMetadata();
- if(!isset($this->data["Sheared"])){
- $this->data["Sheared"] = 0;
- }
- $d[16]["value"] = ($this->data["Sheared"] << 4) | ($this->getColor() & 0x0F);
- return $d;
- }
-
- public function sheepColor(){ //a method from 0.8.1
- $c = mt_rand(0,100);
- if($c <= 4){
- return 0xF; //white
- }
- if($c <= 9){
- return 0x7;
- }
- if($c <= 14){
- return 0x8;
- }
- if($c <= 17){
- return 0xC;
- }
- if(mt_rand(0, 500)){
- return 0x0;
- }
- return 0x0;
- }
-}
\ No newline at end of file
diff --git a/src/entity/animal/Wolf.php b/src/entity/animal/Wolf.php
deleted file mode 100644
index 77aaa3d8..00000000
--- a/src/entity/animal/Wolf.php
+++ /dev/null
@@ -1,50 +0,0 @@
-setSize(0.6, 0.8);
- parent::__construct($level, $eid, $class, $type, $data);
- $this->setSpeed(0.3);
- $this->setName("Wolf");
- $this->setHealth(isset($this->data["Health"]) ? $this->data["Health"] : 10, "generic");
- }
-
- public function getMetadata(){
- $ret = parent::getMetadata();
- $ret[self::WOLF_FLAGS] = ["type" => 0, "value" =>
- (($this->angry) << self::WF_ANGRY) ^
- (($this->interested) << self::WF_INTERESTED) ^
- (($this->sitting) << self::WF_SITTING)
- ];//TODO toggles
- return $ret;
- }
-
- public function isTamed()
- {
- return false;
- }
-
- public function getOwner()
- {
- return null;
- }
- public function isFood($id) //TODO
- {
- return false;
- }
-
-
-}
-
diff --git a/src/entity/monster/Creeper.php b/src/entity/monster/Creeper.php
deleted file mode 100644
index 9510cd2f..00000000
--- a/src/entity/monster/Creeper.php
+++ /dev/null
@@ -1,89 +0,0 @@
-setSize(0.6, 1.7);
- parent::__construct($level, $eid, $class, $type, $data);
- $this->setHealth(isset($this->data["Health"]) ? $this->data["Health"] : 20, "generic");
- $this->setName("Creeper");
- $this->ignited = 0;
- $this->setSpeed(0.25);
- $this->update();
- $this->timeUntilExplode = $this->isIgnited() ? self::EXPL_TIME : 0;
- }
-
- public function getAttackDamage(){
- return 0; //TODO special attack
- }
-
- public function setIgnited($v = null){
- $this->setState($v === null ? !$this->getState() : $v);
- }
-
- /**
- * @return boolean
- */
- public function isIgnited(){
- return $this->getState() > 0;
- }
-
- public function interactWith(Entity $e, $action){
- if($e->isPlayer() && $action === InteractPacket::ACTION_HOLD){
- $slot = $e->player->getHeldItem();
- if($slot->getID() === FLINT_AND_STEEL && !$this->isIgnited()){
- if($slot->useOn($this) && $slot->getMetadata() >= $slot->getMaxDurability()){
- $e->player->removeItem($slot->getID(), $slot->getMetadata(), $slot->count, true);
- }else{
- $e->player->setSlot($e->player->slot, $slot);
- }
- $this->ignite();
- return true;
- }
- }
- return parent::interactWith($e, $action);
- }
-
- public function ignite(){
- $this->setIgnited(1);
- $this->timeUntilExplode = self::EXPL_TIME;
- }
-
- public function attackEntity($entity){
- if(Utils::distance_noroot($entity, $this) <= 49 && !$this->isIgnited()){
- $this->ignite();
- }
-
- }
- public function update(){
- if($this->isIgnited() && $this->target instanceof Entity && Utils::distance_noroot($this->target, $this) > 49){
- $this->setIgnited(-1); //broken in vanilla too
- $this->timeUntilExplode = 0;
- }
- if($this->timeUntilExplode === 1){
- $this->explode();
- }
- if($this->timeUntilExplode >= 0){
- --$this->timeUntilExplode;
- }
- parent::update();
- }
-
- public function explode()
- {
- if($this->closed || $this->dead){
- return false;
- }
- $this->setIgnited(0);
- $explosion = new Explosion($this, 3);
- $this->close();
- $explosion->explode();
- }
-
- public function getDrops(){
- return [
- [GUNPOWDER, 0, mt_rand(0,2)]
- ];
- }
-}
diff --git a/src/entity/monster/Enderman.php b/src/entity/monster/Enderman.php
deleted file mode 100644
index 8484094c..00000000
--- a/src/entity/monster/Enderman.php
+++ /dev/null
@@ -1,65 +0,0 @@
-setSize(0.6, 2.9);
- parent::__construct($level, $eid, $class, $type, $data);
- $this->setName("Enderman");
- $this->setSpeed(0.3);
- $this->setHealth(isset($this->data["Health"]) ? $this->data["Health"] : 40, "generic");
- }
-
- public function getMetadata(){
- $ret = parent::getMetadata();
- $ret[self::DATA_ANGRY] = ["type" => 0, "value" => (int)$this->isAngry];
- $ret[self::DATA_BLOCKID] = ["type" => 1, "value" => 0];
- $ret[self::DATA_BLOCKMETA] = ["type" => 1, "value" => 0]; //TODO carry blocks
- return $ret;
- }
-
- public function setAngry($t){
- if($this->isAngry != $t){
- $this->isAngry = $t;
- $this->updateMetadata();
- }
- }
-
- public function isAngry(){
- return $this->isAngry;
- }
-
- public function harm($dmg, $cause = "generic", $force = false){
- parent::harm($dmg, $cause, $force);
- if($cause === "water"){
- $this->randomTeleport();
- }
- if(is_numeric($cause) && $this->level->entityList[$cause]->isPlayer()){
- $this->setAngry(true); //TODO better way to find is it angry or not
- }
- }
-
- public function randomTeleport(){
- $x = $this->x + ($this->random->nextFloat() - 0.5) * 64;
- $z = $this->z + ($this->random->nextFloat() - 0.5) * 64;
- for($y = 0; $y < 128; ++$y){
- $b = $this->level->getBlockWithoutVector($x, $y, $z);
- if($b instanceof Block && !$b->isTransparent){ //TODO hitbox check
- $this->x = $x;
- $this->y = $y+0.5;
- $this->z = $z;
- }
- }
- }
-
-}
-
diff --git a/src/entity/monster/PigZombie.php b/src/entity/monster/PigZombie.php
deleted file mode 100644
index 7ef42cb9..00000000
--- a/src/entity/monster/PigZombie.php
+++ /dev/null
@@ -1,29 +0,0 @@
-setSize(0.3, 1.95);
- parent::__construct($level, $eid, $class, $type, $data);
- $this->setHealth(isset($this->data["Health"]) ? $this->data["Health"] : 20, "generic");
- $this->setName("Pigman");
- $this->setSpeed(0.25);
- $this->update();
- }
- public function getAttackDamage(){
- return 5;
- }
- public function getDrops(){
- return [
- [COOKED_PORKCHOP, 0, mt_rand(0,2)],
- [GOLD_INGOT, 0, mt_rand(0,1)]
- ];
- }
-
- public function harm($dmg, $cause = "generic", $force = false)
- {
- if($cause === "fire" || $cause === "lava" || $cause === "burning"){
- return false;
- }
- return parent::harm($dmg, $cause, $force);
- }
-}
\ No newline at end of file
diff --git a/src/entity/monster/SilverFish.php b/src/entity/monster/SilverFish.php
deleted file mode 100644
index 43f4b10a..00000000
--- a/src/entity/monster/SilverFish.php
+++ /dev/null
@@ -1,14 +0,0 @@
-setSize(0.3, 0.7);
- parent::__construct($level, $eid, $class, $type, $data);
- $this->setSpeed(0.3);
- $this->setHealth(isset($this->data["Health"]) ? $this->data["Health"] : 8, "generic");
- $this->setName("Silverfish");
- }
-}
-
diff --git a/src/entity/monster/Skeleton.php b/src/entity/monster/Skeleton.php
deleted file mode 100644
index 46a3f17b..00000000
--- a/src/entity/monster/Skeleton.php
+++ /dev/null
@@ -1,49 +0,0 @@
-setSize(0.6, 1.99);
- parent::__construct($level, $eid, $class, $type, $data);
- $this->setHealth(isset($this->data["Health"]) ? $this->data["Health"] : 15, "generic");
- $this->setName("Skeleton");
- $this->ai->removeTask("TaskAttackPlayer");
- $this->setSpeed(0.25);
- $this->update();
- }
-
- public function getAttackDamage(){
- return 0; //TODO special attack
- }
-
- public function updateBurning(){
- if($this->fire > 0 or !$this->level->isDay()){
- return false;
- }
-
- for($y = $this->y; $y < 129; $y++){
- $block = $this->level->getBlockWithoutVector($this->x, $y, $this->z);
- if($block->isSolid){
- return false;
- }
- }
- if($block->getID() === AIR){
- $this->fire = 160; //Value from 0.8.1
- $this->updateMetadata();
- return true;
- }else{
- return false;
- }
- }
-
- public function update(){
- $this->updateBurning();
- parent::update();
- }
-
- public function getDrops(){
- return [
- [ARROW, 0, mt_rand(0,2)],
- [BONE, 0, mt_rand(0,2)]
- ];
- }
-}
\ No newline at end of file
diff --git a/src/entity/monster/Slime.php b/src/entity/monster/Slime.php
deleted file mode 100644
index c2e1a89c..00000000
--- a/src/entity/monster/Slime.php
+++ /dev/null
@@ -1,58 +0,0 @@
-setName("Slime");
- /* Health formula
- * SlimeSize = Slime::getSlimeSize(this);
- * return SlimeSize * SlimeSize;
- */
- $this->setSlimeSize($data["Size"] ?? (1 << mt_rand(0, 2)));
- }
-
- public function getSlimeSize(){
- return $this->size;
- }
-
- public function makeDead($cause){
- $cnt = 2 + mt_rand(0, 2);
- $s = $this->size;
- if($s > 1){
- for($i = 0; $i < $cnt; ++$i){
- $xOff = (($cnt % 2) - 0.5) * $s / 4;
- $zOff = (($cnt / 2) - 0.5) * $s / 4;
- $e = $this->server->api->entity->add($this->level, $this->class, $this->type, [
- "x" => $this->x + $xOff,
- "y"=> $this->y + 1,
- "z" => $this->z + $zOff,
- "Size" => (int) ($s / 2)
- ]);
- $this->server->api->entity->spawnToAll($e);
- }
- }
- parent::makeDead($cause);
- }
-
- public function setSlimeSize($i){
- $this->size = $i;
- $this->setSize(0.6 * $i, 0.6 * $i);
- $this->setHealth($i * $i);
- }
-
- public function createSaveData(){
- $sd = parent::createSaveData();
- $sd["Size"] = $this->size;
- return $sd;
- }
-
- public function getMetadata(){
- $ret = parent::getMetadata();
- $ret[16]["value"] = $this->size;
- return $ret;
- }
-}
-
diff --git a/src/entity/monster/Spider.php b/src/entity/monster/Spider.php
deleted file mode 100644
index 117a77d4..00000000
--- a/src/entity/monster/Spider.php
+++ /dev/null
@@ -1,18 +0,0 @@
-setSize(1.4, 0.9);
- parent::__construct($level, $eid, $class, $type, $data);
- $this->setHealth(isset($this->data["Health"]) ? $this->data["Health"] : 16, "generic");
- $this->setName("Spider");
- $this->setSpeed(0.3);
- $this->update();
- }
-
- public function getDrops(){
- return [
- [STRING, 0, mt_rand(0,2)]
- ];
- }
-}
\ No newline at end of file
diff --git a/src/entity/monster/Zombie.php b/src/entity/monster/Zombie.php
deleted file mode 100644
index cea5b509..00000000
--- a/src/entity/monster/Zombie.php
+++ /dev/null
@@ -1,53 +0,0 @@
-setSize(0.6, 1.85);
- parent::__construct($level, $eid, $class, $type, $data);
- $this->setHealth(isset($this->data["Health"]) ? $this->data["Health"] : 20, "generic");
- $this->setName("Zombie");
- $this->setSpeed(0.23);
- $this->update();
- }
-
- public function getArmorValue(){
- return 2;
- }
-
- public function updateBurning(){
- if($this->fire > 0 or !$this->level->isDay()){
- return false;
- }
-
- for($y = $this->y; $y < 129; $y++){
- $block = $this->level->getBlockWithoutVector($this->x, $y, $this->z);
- if($block->isSolid){
- return false;
- }
- }
- if($block->getID() === AIR){
- $this->fire = 160; //Value from 0.8.1
- $this->updateMetadata();
- return true;
- }else{
- return false;
- }
- }
-
- public function getAttackDamage(){
- return 4; //TODO vanillafy(zombies might be able to hold items)
- }
-
- public function update(){
- $this->updateBurning();
- parent::update();
- }
-
- public function getDrops(){
- return [
- [CARROT, 0, Utils::chance(0.83) ? 1 : 0],
- [POTATO, 0, Utils::chance(0.83) ? 1 : 0],
- [FEATHER, 0, mt_rand(0,2)]
- ];
- }
-}
\ No newline at end of file
diff --git a/src/entity/neutral/Villager.php b/src/entity/neutral/Villager.php
deleted file mode 100644
index 90153868..00000000
--- a/src/entity/neutral/Villager.php
+++ /dev/null
@@ -1,14 +0,0 @@
-setSize(0.6, 1.8);
- parent::__construct($level, $eid, $class, $type, $data);
- $this->setSpeed(0.3);
- $this->setHealth(isset($this->data["Health"]) ? $this->data["Health"] : 10, "generic");
- $this->setName("Villager");
- }
-}
-
diff --git a/src/entity/object/FallingSand.php b/src/entity/object/FallingSand.php
deleted file mode 100644
index e69de29b..00000000
diff --git a/src/entity/object/ItemEntity.php b/src/entity/object/ItemEntity.php
deleted file mode 100644
index e69de29b..00000000
diff --git a/src/entity/object/Minecart.php b/src/entity/object/Minecart.php
deleted file mode 100644
index 3bf1519f..00000000
--- a/src/entity/object/Minecart.php
+++ /dev/null
@@ -1,66 +0,0 @@
-canBeAttacked = true;
- $this->x = isset($this->data["TileX"]) ? $this->data["TileX"]:$this->x;
- $this->y = isset($this->data["TileY"]) ? $this->data["TileY"]:$this->y;
- $this->z = isset($this->data["TileZ"]) ? $this->data["TileZ"]:$this->z;
- $this->setHealth(3, "generic");
- //$this->setName((isset($objects[$this->type]) ? $objects[$this->type]:$this->type));
- $this->width = 0.98;
- $this->height = 0.7;
- $this->update();
- }
-
- public function getDrops(){
- return [
- [MINECART, 0, 1]
- ];
- }
-
- public function spawn($player){
- $pk = new AddEntityPacket;
- $pk->eid = $this->eid;
- $pk->type = $this->type;
- $pk->x = $this->x;
- $pk->y = $this->y;
- $pk->z = $this->z;
- $pk->yaw = $this->yaw;
- $pk->pitch = $this->pitch;
- $player->dataPacket($pk);
-
- $pk = new SetEntityMotionPacket;
- $pk->entities = [[$this->eid, $this->speedX, $this->speedY, $this->speedZ]];
- $player->dataPacket($pk);
- }
-
- public function interactWith(Entity $e, $action){
- if($action === InteractPacket::ACTION_HOLD && $e->isPlayer() && $this->canRide($e)){
- $this->linkedEntity = $e;
- $e->isRiding = true;
- $this->linkEntity($e, SetEntityLinkPacket::TYPE_RIDE);
- return true;
- }
- if($e->isPlayer() && $action === InteractPacket::ACTION_HOLD){
- $this->linkEntity($e, SetEntityLinkPacket::TYPE_REMOVE);
- $this->linkedEntity = 0;
- $e->isRiding = false;
- return true;
- }
- parent::interactWith($e, $action);
- }
-
- public function canRide($e)
- {
- return !($this->linkedEntity instanceof Entity) && !$e->isRiding;
- }
-
-}
diff --git a/src/entity/object/Painting.php b/src/entity/object/Painting.php
deleted file mode 100644
index 3f75d63a..00000000
--- a/src/entity/object/Painting.php
+++ /dev/null
@@ -1,40 +0,0 @@
-x = isset($this->data["TileX"]) ? $this->data["TileX"]:$this->x;
- $this->y = isset($this->data["TileY"]) ? $this->data["TileY"]:$this->y;
- $this->z = isset($this->data["TileZ"]) ? $this->data["TileZ"]:$this->z;
- $this->setHealth(1, "generic");
- $this->canBeAttacked = true;
- $this->width = 1;
- $this->isStatic = true;
- }
-
- public function getDrops(){
- return [
- [PAINTING, 0, 1]
- ];
- }
-
- public function createSaveData(){
- $data = parent::createSaveData();
-
- $data["Motive"] = $this->data["Motive"];
-
- return $data;
- }
-
- public function spawn($player){
- $pk = new AddPaintingPacket;
- $pk->eid = $this->eid;
- $pk->x = (int) $this->x;
- $pk->y = (int) $this->y;
- $pk->z = (int) $this->z;
- $pk->direction = $this->getDirection();
- $pk->title = $this->data["Motive"];
- $player->dataPacket($pk);
- }
-}
diff --git a/src/entity/object/PrimedTNT.php b/src/entity/object/PrimedTNT.php
deleted file mode 100644
index 097706bc..00000000
--- a/src/entity/object/PrimedTNT.php
+++ /dev/null
@@ -1,49 +0,0 @@
-data["fuse"])){
- $this->data["fuse"] = 0;
- }
- $this->setHealth(10000000, "generic");
- $this->server->schedule(5, [$this, "updateFuse"], [], true);
- $this->update();
- }
-
- public function getMetadata(){
- $d = parent::getMetadata();
- $d[16]["value"] = (int) max(0, $this->data["fuse"] - (microtime(true) - $this->spawntime) * 20);
- return $d;
- }
-
- public function updateFuse(){
- if($this->closed === true){
- return false;
- }
- if($this->type === OBJECT_PRIMEDTNT){
- $this->updateMetadata();
- if(((microtime(true) - $this->spawntime) * 20) >= $this->data["fuse"]){
- $this->close();
- $explosion = new Explosion($this, $this->data["power"]);
- $explosion->explode();
- }
- }
- }
-
- public function spawn($player){
- $pk = new AddEntityPacket;
- $pk->eid = $this->eid;
- $pk->type = $this->type;
- $pk->x = $this->x;
- $pk->y = $this->y;
- $pk->z = $this->z;
- $pk->did = 0;
- $player->dataPacket($pk);
- $pk = new SetEntityMotionPacket;
- $pk->entities = [[$this->eid, $this->speedX, $this->speedY, $this->speedZ]];
- $player->dataPacket($pk);
- }
-}
diff --git a/src/entity/object/TripodCamera.php b/src/entity/object/TripodCamera.php
deleted file mode 100644
index ec4baed9..00000000
--- a/src/entity/object/TripodCamera.php
+++ /dev/null
@@ -1,18 +0,0 @@
-setHealth(PHP_INT_MAX, "generic");
- }
-
- public function interactWith(Entity $e, $action){
- if($e->isPlayer() and $action === InteractPacket::ACTION_HOLD){
- //todo
- $this->server->schedule(40, [$this, "close"]);
- }
- parent::interactWith($e, $action);
- }
-}
\ No newline at end of file
diff --git a/src/entity/object/projectile/Arrow.php b/src/entity/object/projectile/Arrow.php
deleted file mode 100644
index 744e9732..00000000
--- a/src/entity/object/projectile/Arrow.php
+++ /dev/null
@@ -1,61 +0,0 @@
-server->schedule(1210, array($this, "update")); //Despawn
- }
-
- public function handleUpdate(){
- $pk = new MoveEntityPacket_PosRot;
- $pk->eid = $this->eid;
- $pk->x = $this->x;
- $pk->y = $this->y;
- $pk->z = $this->z;
- $pk->yaw = $this->yaw;
- $pk->pitch = $this->pitch;
- $this->server->api->player->broadcastPacket($this->level->players, $pk);
- }
-
- public function shoot($d, $d1, $d2, $f, $f1){ //original name from 0.8.1 IDA decompilation, var names are taken from b1.7.3
- $f2 = sqrt($d * $d + $d1 * $d1 + $d2 * $d2);
- $d /= $f2;
- $d1 /= $f2;
- $d2 /= $f2;
- $d += $this->random->nextGaussian() * 0.0075 * $f1; //0.0074999998323619366 replaced with 0.0075
- $d1 += $this->random->nextGaussian() * 0.0075 * $f1;
- $d2 += $this->random->nextGaussian() * 0.0075 * $f1;
- $d *= $f;
- $d1 *= $f;
- $d2 *= $f;
- $this->speedX = $d;
- $this->speedY = $d1;
- $this->speedZ = $d2;
- $f3 = sqrt($d * $d + $d2 * $d2);
- $this->yaw = (atan2($d, $d2) * 180) / M_PI;
- $this->pitch = (atan2($d1, $f3) * 180) / M_PI;
- $this->update();
- //TODO i guess? $ticksInGround = 0;
- }
-
- public function spawn($player){
- //if($this->type === OBJECT_ARROW){
- $pk = new AddEntityPacket;
- $pk->eid = $this->eid;
- $pk->type = $this->type;
- $pk->x = $this->x;
- $pk->y = $this->y;
- $pk->z = $this->z;
- $pk->did = 1;
- $pk->speedX = $this->speedX;
- $pk->speedY = $this->speedY;
- $pk->speedZ = $this->speedZ;
- $player->dataPacket($pk);
-
- $pk = new SetEntityMotionPacket;
- $pk->entities = [[$this->eid, $this->speedX, $this->speedY, $this->speedZ]];
- $player->dataPacket($pk);
- //}
- }
-}
diff --git a/src/entity/object/projectile/Egg.php b/src/entity/object/projectile/Egg.php
deleted file mode 100644
index e69de29b..00000000
diff --git a/src/entity/object/projectile/Snowball.php b/src/entity/object/projectile/Snowball.php
deleted file mode 100644
index fc01ede0..00000000
--- a/src/entity/object/projectile/Snowball.php
+++ /dev/null
@@ -1,61 +0,0 @@
-server->schedule(1210, array($this, "update")); //Despawn
- }
-
- public function handleUpdate(){
- $pk = new MoveEntityPacket_PosRot;
- $pk->eid = $this->eid;
- $pk->x = $this->x;
- $pk->y = $this->y;
- $pk->z = $this->z;
- $pk->yaw = $this->yaw;
- $pk->pitch = $this->pitch;
- $this->server->api->player->broadcastPacket($this->level->players, $pk);
- }
-
- public function shoot($d, $d1, $d2, $f, $f1){ //original name from 0.8.1 IDA decompilation, var names are taken from b1.7.3
- $f2 = sqrt($d * $d + $d1 * $d1 + $d2 * $d2);
- $d /= $f2;
- $d1 /= $f2;
- $d2 /= $f2;
- $d += $this->random->nextGaussian() * 0.0075 * $f1; //0.0074999998323619366 replaced with 0.0075
- $d1 += $this->random->nextGaussian() * 0.0075 * $f1;
- $d2 += $this->random->nextGaussian() * 0.0075 * $f1;
- $d *= $f;
- $d1 *= $f;
- $d2 *= $f;
- $this->speedX = $d;
- $this->speedY = $d1;
- $this->speedZ = $d2;
- $f3 = sqrt($d * $d + $d2 * $d2);
- $this->yaw = (atan2($d, $d2) * 180) / M_PI;
- $this->pitch = (atan2($d1, $f3) * 180) / M_PI;
- $this->update();
- //TODO i guess? $ticksInGround = 0;
- }
-
- public function spawn($player){
- //if($this->type === OBJECT_ARROW){
- $pk = new AddEntityPacket;
- $pk->eid = $this->eid;
- $pk->type = $this->type;
- $pk->x = $this->x;
- $pk->y = $this->y;
- $pk->z = $this->z;
- $pk->did = 1;
- $pk->speedX = $this->speedX;
- $pk->speedY = $this->speedY;
- $pk->speedZ = $this->speedZ;
- $player->dataPacket($pk);
-
- $pk = new SetEntityMotionPacket;
- $pk->entities = [[$this->eid, $this->speedX, $this->speedY, $this->speedZ]];
- $player->dataPacket($pk);
- //}
- }
-}
\ No newline at end of file
diff --git a/src/entity/registry/EntityList.php b/src/entity/registry/EntityList.php
deleted file mode 100644
index 615c5820..00000000
--- a/src/entity/registry/EntityList.php
+++ /dev/null
@@ -1,14 +0,0 @@
-entities;
- }
- public function addEntity(PropertyEntity $property){
- $this->entities[$property->getEntityType()] = $property;
- }
- public function getEntityFromTypeAndClass($type, $class){
- return isset($this->entities[$type]) && $this->entities[$type]->getEntityClass() === $class ? $this->entities[$type] : 0;
- }
- private $entities = [];
-}
diff --git a/src/entity/registry/EntityRegistry.php b/src/entity/registry/EntityRegistry.php
deleted file mode 100644
index fc719089..00000000
--- a/src/entity/registry/EntityRegistry.php
+++ /dev/null
@@ -1,45 +0,0 @@
-isAbstract()){
- //self::$entityList[$className::TYPE] = $className;
- self::$entityList->addEntity(new PropertyEntity($className::CLASS_TYPE, $className::TYPE, $className));
- //self::$shortNames[$className] = $class->getShortName(); what is this even supposed to do?
- //console("[INFO] Registered a ".$className);
- return true;
- }
-
- return false;
- }
-}
\ No newline at end of file
diff --git a/src/entity/registry/PropertyEntity.php b/src/entity/registry/PropertyEntity.php
deleted file mode 100644
index d2cf972b..00000000
--- a/src/entity/registry/PropertyEntity.php
+++ /dev/null
@@ -1,21 +0,0 @@
-class = $class;
- $this->type = $type;
- $this->name = $name;
- }
-
- public function getEntityClass(){
- return $this->class;
- }
- public function getEntityType(){
- return $this->type;
- }
- public function getEntityName(){
- return $this->name;
- }
-}
\ No newline at end of file
diff --git a/src/event/CancellableEvent.php b/src/event/CancellableEvent.php
deleted file mode 100644
index 2c3ea9b1..00000000
--- a/src/event/CancellableEvent.php
+++ /dev/null
@@ -1,9 +0,0 @@
- $handlerList){
- if(count($handlerList) > 0){
- $event->setPrioritySlot($priority);
- foreach($handlerList as $handler){
- call_user_func($handler, $event);
- }
- if($event->isForced()){
- if($event instanceof CancellableEvent and $event->isCancelled()){
- return BaseEvent::DENY;
- }else{
- return BaseEvent::ALLOW;
- }
- }
- }
- }
-
- if($event instanceof CancellableEvent and $event->isCancelled()){
- return BaseEvent::DENY;
- }elseif($event->isAllowed()){
- return BaseEvent::ALLOW;
- }else{
- return BaseEvent::NORMAL;
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/src/event/EventPriority.php b/src/event/EventPriority.php
deleted file mode 100644
index f42e8d73..00000000
--- a/src/event/EventPriority.php
+++ /dev/null
@@ -1,52 +0,0 @@
-packet = $packet;
- $this->player = $player;
- }
-
- public function getPacket(){
- return $this->packet;
- }
-
- public function getPlayer(){
- return $this->player;
- }
-}
\ No newline at end of file
diff --git a/src/event/server/DataPacketSendEvent.php b/src/event/server/DataPacketSendEvent.php
deleted file mode 100644
index 5e55a29b..00000000
--- a/src/event/server/DataPacketSendEvent.php
+++ /dev/null
@@ -1,41 +0,0 @@
-packet = $packet;
- $this->player = $player;
- }
-
- public function getPacket(){
- return $this->packet;
- }
-
- public function getPlayer(){
- return $this->player;
- }
-}
\ No newline at end of file
diff --git a/src/event/server/PacketReceiveEvent.php b/src/event/server/PacketReceiveEvent.php
deleted file mode 100644
index cb26cbf0..00000000
--- a/src/event/server/PacketReceiveEvent.php
+++ /dev/null
@@ -1,36 +0,0 @@
-packet = $packet;
- }
-
- public function getPacket(){
- return $this->packet;
- }
-}
\ No newline at end of file
diff --git a/src/event/server/PacketSendEvent.php b/src/event/server/PacketSendEvent.php
deleted file mode 100644
index becb15e4..00000000
--- a/src/event/server/PacketSendEvent.php
+++ /dev/null
@@ -1,36 +0,0 @@
-packet = $packet;
- }
-
- public function getPacket(){
- return $this->packet;
- }
-}
\ No newline at end of file
diff --git a/src/functions.php b/src/functions.php
deleted file mode 100644
index c9ffb592..00000000
--- a/src/functions.php
+++ /dev/null
@@ -1,280 +0,0 @@
- $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::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");
- }
-}
-
-/**
- * @deprecated Use $expr ?? $null
- */
-function nullsafe(&$a, $null){
- return $a ?? $null;
-}
-
-
-
-function require_all($path, &$count = 0){
- $dir = dir($path . "/");
- $dirs = [];
- while(false !== ($file = $dir->read())){
- if($file !== "." and $file !== ".."){
- if(!is_dir($path . $file) and strtolower(substr($file, -3)) === "php"){
- require_once($path . $file);
- ++$count;
- }elseif(is_dir($path . $file)){
- $dirs[] = $path . $file . "/";
- }
- }
- }
- foreach($dirs as $dir){
- require_all($dir, $count);
- }
-
-}
-
-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 arg($name, $default = false){
- global $arguments, $argv;
- if(!isset($arguments)){
- $arguments = arguments($argv);
- }
-
- if(isset($arguments["commands"][$name])){
- return $arguments["commands"][$name];
- }else{
- return $default;
- }
-}
-
-function arguments($args){
- if(!is_array($args)){
- $args = [];
- }
- array_shift($args);
- $args = join(' ', $args);
-
- preg_match_all('/ (--[\w\-]+ (?:[= ] [^-\s]+ )? ) | (-\w+) | (\w+) /x', $args, $match);
- $args = array_shift($match);
-
- $ret = [
- 'input' => [],
- 'commands' => [],
- 'flags' => []
- ];
-
- foreach($args as $arg){
-
- // Is it a command? (prefixed with --)
- if(substr($arg, 0, 2) === '--'){
-
- $value = preg_split('/[= ]/', $arg, 2);
- $com = substr(array_shift($value), 2);
- $value = join($value);
-
- $ret['commands'][$com] = !empty($value) ? $value : true;
- continue;
-
- }
-
- // Is it a flag? (prefixed with -)
- if(substr($arg, 0, 1) === '-'){
- $ret['flags'][] = substr($arg, 1);
- continue;
- }
-
- $ret['input'][] = $arg;
- continue;
-
- }
-
- return $ret;
-}
-
-function console($message, $EOL = true, $log = true, $level = 1){
- if(!defined("DEBUG") or DEBUG >= $level){
- $message .= $EOL === true ? PHP_EOL : "";
- $time = (ENABLE_ANSI === true ? FORMAT_AQUA . date("H:i:s") . FORMAT_RESET : date("H:i:s")) . " ";
- $replaced = TextFormat::clean(preg_replace('/\x1b\[[0-9;]*m/', "", $time . $message));
- if($log === true and (!defined("LOG") or LOG === true)){
- logg(date("Y-m-d") . " " . $replaced, "console", false, $level);
- }
- if(ENABLE_ANSI === true){
- $add = "";
- if(preg_match("/\[([a-zA-Z0-9]*)\]/", $message, $matches) > 0){
- switch($matches[1]){
- case "ERROR":
- case "SEVERE":
- $add .= FORMAT_RED;
- break;
- case "INTERNAL":
- case "DEBUG":
- $add .= FORMAT_WHITE;
- break;
- case "WARNING":
- $add .= FORMAT_YELLOW;
- break;
- case "NOTICE":
- $add .= FORMAT_AQUA;
- break;
- default:
- $add .= FORMAT_GRAY;
- break;
- }
- }
- $message = TextFormat::toANSI($time . $add . $message . FORMAT_RESET);
- }else{
- $message = $replaced;
- }
- echo $message;
- }
-}
-
-function getTrace($start = 1){
- $e = new Exception();
- $trace = $e->getTrace();
- $messages = [];
- $j = 0;
- for($i = (int) $start; isset($trace[$i]); ++$i, ++$j){
- $params = "";
- 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)) . ", ";
- }
- $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 = [
- 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 logg($message, $name, $EOL = true, $level = 2, $close = false){
- global $fpointers, $dolog;
- if((!defined("DEBUG") or DEBUG >= $level) and (!defined("LOG") or LOG === true)){
- $message .= $EOL === true ? PHP_EOL : "";
- if(!isset($fpointers)){
- $fpointers = [];
- }
- if(!isset($fpointers[$name]) or $fpointers[$name] === false){
- $fpointers[$name] = @fopen(DATA_PATH . "/" . $name . ".log", "ab");
- }
- if($dolog){
- @fwrite($fpointers[$name], $message);
- }
- if($close === true){
- fclose($fpointers[$name]);
- unset($fpointers[$name]);
- }
- }
-}
diff --git a/src/installer/Installer.php b/src/installer/Installer.php
deleted file mode 100644
index c228cda6..00000000
--- a/src/installer/Installer.php
+++ /dev/null
@@ -1,261 +0,0 @@
- $native){
- echo " $native => $short\n";
- }
- do{
- echo "[?] Language (en): ";
- $lang = strtolower($this->getInput("en"));
- if(!isset(InstallerLang::$languages[$lang])){
- echo "[!] Couldn't find the language\n";
- $lang = false;
- }
- }while($lang == false);
- $this->lang = new InstallerLang($lang);
- echo "[*] ".$this->lang->language_has_been_selected."\n";
- echo "[?] ".$this->lang->skip_installer." (y/N): ";
- if(strtolower($this->getInput()) === "y"){
- return;
- }
- echo "\n";
- $this->welcome();
- $this->generateBaseConfig();
- $this->generateUserFiles();
-
- $this->networkFunctions();
-
- $this->endWizard();
- }
-
- private function welcome(){
- echo $this->lang->welcome_to_pocketmine."\n";
- echo <<lang->accept_license." (y/N): ";
- if(strtolower($this->getInput("n")) != "y"){
- echo "[!] ".$this->lang->you_have_to_accept_the_license."\n";
- sleep(5);
- exit(0);
- }
- echo "[*] ".$this->lang->setting_up_server_now."\n";
- echo "[*] ".$this->lang->default_values_info."\n";
- echo "[*] ".$this->lang->server_properties."\n";
-
- }
-
- private function generateBaseConfig(){
- $config = new Config(DATA_PATH . "server.properties", CONFIG_PROPERTIES);
- echo "[?] ".$this->lang->name_your_server." (".self::DEFAULT_NAME."): ";
- $config->set("server-name", $this->getInput(self::DEFAULT_NAME));
- echo "[*] ".$this->lang->port_warning."\n";
- do{
- echo "[?] ".$this->lang->server_port." (".self::DEFAULT_PORT."): ";
- $port = (int) $this->getInput(self::DEFAULT_PORT);
- if($port <= 0 or $port > 65535){
- echo "[!] ".$this->lang->invalid_port."\n";
- }
- }while($port <= 0 or $port > 65535);
- $config->set("server-port", $port);
- echo "[*] ".$this->lang->ram_warning."\n";
- echo "[?] ".$this->lang->server_ram." (".self::DEFAULT_MEMORY."): ";
- $config->set("memory-limit", ((int) $this->getInput(self::DEFAULT_MEMORY))."M");
- echo "[*] ".$this->lang->gamemode_info."\n";
- do{
- echo "[?] ".$this->lang->default_gamemode.": (".self::DEFAULT_GAMEMODE."): ";
- $gamemode = (int) $this->getInput(self::DEFAULT_GAMEMODE);
- }while($gamemode < 0 or $gamemode > 3);
- $config->set("gamemode", $gamemode);
- echo "[?] ".$this->lang->max_players." (".self::DEFAULT_PLAYERS."): ";
- $config->set("max-players", (int) $this->getInput(self::DEFAULT_PLAYERS));
- echo "[*] ".$this->lang->spawn_protection_info."\n";
- echo "[?] ".$this->lang->spawn_protection." (Y/n): ";
- if(strtolower($this->getInput("y")) == "n"){
- $config->set("spawn-protection", -1);
- }else{
- $config->set("spawn-protection", 16);
- }
- $config->save();
- }
-
- private function generateUserFiles(){
- echo "[*] ".$this->lang->op_info."\n";
- echo "[?] ".$this->lang->op_who.": ";
- $op = strtolower($this->getInput(""));
- if($op === ""){
- echo "[!] ".$this->lang->op_warning."\n";
- }else{
- $ops = new Config(DATA_PATH."ops.txt", CONFIG_LIST);
- $ops->set($op, true);
- $ops->save();
- }
- echo "[*] ".$this->lang->whitelist_info."\n";
- echo "[?] ".$this->lang->whitelist_enable." (y/N): ";
- $config = new Config(DATA_PATH . "server.properties", CONFIG_PROPERTIES);
- if(strtolower($this->getInput("n")) === "y"){
- echo "[!] ".$this->lang->whitelist_warning."\n";
- $config->set("white-list", true);
- }else{
- $config->set("white-list", false);
- }
- $config->save();
- }
-
- private function networkFunctions(){
- $config = new Config(DATA_PATH . "server.properties", CONFIG_PROPERTIES);
- echo "[!] ".$this->lang->query_warning1."\n";
- echo "[!] ".$this->lang->query_warning2."\n";
- echo "[?] ".$this->lang->query_disable." (y/N): ";
- if(strtolower($this->getInput("n")) === "y"){
- $config->set("enable-query", false);
- }else{
- $config->set("enable-query", true);
- }
-
- echo "[*] ".$this->lang->rcon_info."\n";
- echo "[?] ".$this->lang->rcon_enable." (y/N): ";
- if(strtolower($this->getInput("n")) === "y"){
- $config->set("enable-rcon", true);
- $password = substr(base64_encode(Utils::getRandomBytes(20, false)), 3, 10);
- $config->set("rcon.password", $password);
- echo "[*] ".$this->lang->rcon_password.": ".$password."\n";
- }else{
- $config->set("enable-rcon", false);
- }
-
- $config->save();
-
-
- echo "[*] ".$this->lang->ip_get."\n";
-
- $externalIP = Utils::getIP();
- $internalIP = gethostbyname(trim(`hostname`));
-
- echo "[!] ".$this->lang->get("ip_warning", array("{{EXTERNAL_IP}}", "{{INTERNAL_IP}}"), array($externalIP, $internalIP))."\n";
- echo "[!] ".$this->lang->ip_confirm;
- $this->getInput();
- }
-
- private function endWizard(){
- echo "[*] ".$this->lang->you_have_finished."\n";
- echo "[*] ".$this->lang->pocketmine_plugins."\n";
- echo "[*] ".$this->lang->pocketmine_will_start."\n\n\n";
- sleep(4);
- }
-
- private function getInput($default = ""){
- $input = trim(fgets(STDIN));
- return $input === "" ? $default:$input;
- }
-
-
- }
-
- class InstallerLang{
- public static $languages = array(
- "ru" => "Pyccĸий",
- "en" => "English",
- "es" => "Español",
- "zh" => "中文",
- "ja" => "日本語",
- "de" => "Deutsch",
- //"vi" => "Tiếng Việt",
- "ko" => "한국어",
- "fr" => "Français",
- "it" => "Italiano",
- //"lv" => "Latviešu",
- "nl" => "Nederlands",
- //"pt" => "Português",
- "sv" => "Svenska",
- "fi" => "Suomi",
- "tr" => "Türkçe",
- //"et" => "Eesti",
- );
- private $texts = array();
- private $lang;
- private $langfile;
- public function __construct($lang = ""){
- if(file_exists(FILE_PATH."src/lang/Installer/".$lang.".ini")){
- $this->lang = $lang;
- $this->langfile = FILE_PATH."src/lang/Installer/".$lang.".ini";
- }else{
- $l = glob(FILE_PATH."src/lang/Installer/".$lang."_*.ini");
- if(count($l) > 0){
- $files = array();
- foreach($l as $file){
- $files[$file] = filesize($file);
- }
- arsort($files);
- reset($files);
- $l = key($files);
- $l = substr($l, strrpos($l, "/") + 1, -4);
- $this->lang = isset(self::$languages[$l]) ? $l:$lang;
- $this->langfile = FILE_PATH."src/lang/Installer/".$l.".ini";
- }else{
- $this->lang = "en";
- $this->langfile = FILE_PATH."src/lang/Installer/en.ini";
- }
- }
-
- $this->loadLang(FILE_PATH."src/lang/Installer/en.ini", "en");
- if($this->lang !== "en"){
- $this->loadLang($this->langfile, $this->lang);
- }
-
- }
-
- public function getLang(){
- return ($this->lang);
- }
-
- public function loadLang($langfile, $lang = "en"){
- $this->texts[$lang] = array();
- $texts = explode("\n", str_replace(array("\r", "\/\/"), array("", "//"), file_get_contents($langfile)));
- foreach($texts as $line){
- $line = trim($line);
- if($line === ""){
- continue;
- }
- $line = explode("=", $line);
- $this->texts[$lang][array_shift($line)] = str_replace(array("\\n", "\\N",), "\n", implode("=", $line));
- }
- }
-
- public function get($name, $search = array(), $replace = array()){
- if(!isset($this->texts[$this->lang][$name])){
- if($this->lang !== "en" and isset($this->texts["en"][$name])){
- return $this->texts["en"][$name];
- }else{
- return $name;
- }
- }elseif(count($search) > 0){
- return str_replace($search, $replace, $this->texts[$this->lang][$name]);
- }else{
- return $this->texts[$this->lang][$name];
- }
- }
-
- public function __get($name){
- return $this->get($name);
- }
-
- }
-/***REM_END***/
diff --git a/src/inventory/Window.php b/src/inventory/Window.php
deleted file mode 100644
index 91d39845..00000000
--- a/src/inventory/Window.php
+++ /dev/null
@@ -1,15 +0,0 @@
-server = ServerAPI::request();
- }
-}
\ No newline at end of file
diff --git a/src/lang/Installer/af_ZA.ini b/src/lang/Installer/af_ZA.ini
deleted file mode 100644
index 6fb66a5e..00000000
--- a/src/lang/Installer/af_ZA.ini
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
diff --git a/src/lang/Installer/ar_SA.ini b/src/lang/Installer/ar_SA.ini
deleted file mode 100644
index 3ca15b97..00000000
--- a/src/lang/Installer/ar_SA.ini
+++ /dev/null
@@ -1,21 +0,0 @@
-language_has_been_selected=وقد تم اختيار اللغة الإنجليزية بشكل صحيح.
-skip_installer=هل تريد تخطي معالج الإعداد؟
-
-welcome_to_pocketmine=مرحبا بكم في NostalgiaCore! \ nBefore بدء إعداد ملقم جديد لديك لقبول الترخيص. \ مرخص nNostalgiaCore تحت رخصة LGPL، \ n التي يمكنك أن تقرأ فتح ملف الترخيص على هذا folder.Do كنت ترغب في تخطي المعالج انشاء؟
-accept_license=هل تقبل رخصة؟
-you_have_to_accept_the_license=عليك أن تقبل رخصة LGPL إلى الاستمرار في استخدام NostalgiaCore
-
-setting_up_server_now=أنت ذاهب لإعداد الخادم الخاص بك الآن.
-default_values_info=إذا كنت لا تريد تغيير القيمة الافتراضية، فقط اضغط على Enter.
-server_properties=يمكنك تحريرها في وقت لاحق على الملف server.properties.
-
-name_your_server=إعطاء اسم على الخادم الخاص بك
-port_warning=لا تقم بتغيير قيمة المنفذ الافتراضي إذا كان هذا هو الخادم الخاص بك أولا.
-server_port=منفذ خادم
-invalid_port=منفذ خادم غير صالحة
-ram_warning=ذاكرة الوصول العشوائي هو الحد الأقصى لمقدار الذاكرة سوف تستخدم NostalgiaCore. ينصح قيمة 128-256 ميغا بايت
-server_ram=RAM الخادم في ميغا بايت
-gamemode_info=الاختيار بين العمل الإبداعي (1) أو البقاء على قيد الحياة (0)
-
-
-
diff --git a/src/lang/Installer/cs_CZ.ini b/src/lang/Installer/cs_CZ.ini
deleted file mode 100644
index 6fb66a5e..00000000
--- a/src/lang/Installer/cs_CZ.ini
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
diff --git a/src/lang/Installer/de_DE.ini b/src/lang/Installer/de_DE.ini
deleted file mode 100644
index efe0bfbc..00000000
--- a/src/lang/Installer/de_DE.ini
+++ /dev/null
@@ -1,45 +0,0 @@
-language_has_been_selected=Englisch haben Sie richtig ausgewählt.
-skip_installer=Möchten Sie den Setup-Assistenten überspringen?
-
-welcome_to_pocketmine=Willkommen auf NostalgiaCore!\nBevor Sie die Einrichtung Ihres neuen Server starten, müssen Sie die Lizenz akzeptieren. \nNostalgiaCore ist unter der LGPL-Lizenz, \ndamit Sie die LIZENZ in diesem Ordner lesen oder öffnen können.
-accept_license=Akzeptieren Sie die Lizenz?
-you_have_to_accept_the_license=Sie müssen die LGPL Lizenz akzeptieren, um weiterhin NostalgiaCore zu nutzen
-
-setting_up_server_now=Sie werden jetzt Ihren Server einrichten.
-default_values_info=Wenn Sie nicht den Standardwert ändern möchten, drücken Sie einfach Enter.
-server_properties=Sie können sie später in der server.properties Datei bearbeiten.
-
-name_your_server=Geben Sie einen Namen für Ihren Server ein
-port_warning=Ändern Sie den Standard-Port-Wert nicht, wenn dies Ihr erster Server ist.
-server_port=Server-Port
-invalid_port=Ungültiger Server-Port
-ram_warning=Der RAM ist die maximale Speichermenge die NostalgiaCore verwenden kann. Ein Wert zwischen 128 bis 256 MB wird empfohlen
-server_ram=Server RAM in MB
-gamemode_info=Wählen Sie zwischen Kreativ (1) oder Überleben (0)
-default_gamemode=Standard Spielmodus
-max_players=Max. Online-Spieler
-spawn_protection_info=Der Spawn-Schutz verbietet Platzierung/Zerstörung der Blöcke in der Einstiegszone, was aber nicht für OPs gilt
-spawn_protection=Aktiviere Spawn-Schutz?
-
-op_info=Ein OP ist der Admin Spieler des Servers. OPs können mehr Befehle ausführen als normale Spieler
-op_who=OP Spieler Name (z.B. dein Spiel-Name)
-op_warning=Sie werden in der Lage sein einen OP Benutzer später mit /op hinzuzufügen
-whitelist_info=Nur die Spieler auf der white-list können zu ihrem Spiel verbinden.
-whitelist_enable=Möchten Sie die white-list aktivieren?
-whitelist_warning=Sie müssen die Spieler zur white-list hinzufügen
-
-query_warning1=Query ist ein Protokoll das von verschiedenen Tools verwendet wird, um Informationen von Ihrem Server und eingeloggten Spieler zu nehmen.
-query_warning2=Wenn Sie es deaktivieren, werden Sie nicht in der Lage sein, Server-Listen zu verwenden.
-query_disable=Wollen Sie Query deaktivieren?
-rcon_info=RCON ist ein Protokoll für eine Remote-Verbindung mit der Server-Konsole, mit der Benutzung eines Passworts.
-rcon_enable=Wollen Sie RCON aktivieren?
-rcon_password=RCON Passwort (Sie können es später ändern)
-usage_info=Die anonymen Nutzungsdaten ermöglichen es uns, globale Statistiken für NostalgiaCore und seine Plugins zu berechnen. Sie können sie auf stats.pocketmine.net ansehen
-usage_disable=Wollen Sie die anonyme Nutzung deaktivieren?
-ip_get=Bekomme deine externe IP und interne IP
-ip_warning=Ihre externe IP ist {{EXTERNAL_IP}}. Evtl. musst Du einen port-forward auf deine interne IP {{INTERNAL_IP}} machen
-ip_confirm=Achten Sie darauf, wenn Sie den Port forwarden müssen und Sie es überspringen, dass keine externen Spieler beitreten können. [Drücke Enter]
-
-you_have_finished=Sie haben den Setup-Assistenten korrekt beendet
-pocketmine_will_start=NostalgiaCore wird nun gestartet. Tippe /help um die Liste der verfügbaren Befehle anzuzeigen.
-pocketmine_plugins=Überprüfen Sie das Plugin Repository um neue Features, Minispiele, oder einen erweiterten Schutz für Ihren Server hinzuzufügen
diff --git a/src/lang/Installer/el_GR.ini b/src/lang/Installer/el_GR.ini
deleted file mode 100644
index 6fb66a5e..00000000
--- a/src/lang/Installer/el_GR.ini
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
diff --git a/src/lang/Installer/en.ini b/src/lang/Installer/en.ini
deleted file mode 100644
index 51120ae3..00000000
--- a/src/lang/Installer/en.ini
+++ /dev/null
@@ -1,45 +0,0 @@
-language_has_been_selected=English has been correctly selected.
-skip_installer=Do you want to skip the set-up wizard?
-
-welcome_to_pocketmine=Welcome to NostalgiaCore!\nBefore starting setting up your new server you have to accept the license.\nNostalgiaCore is licensed under the LGPL License,\nthat you can read opening the LICENSE file on this folder.
-accept_license=Do you accept the License?
-you_have_to_accept_the_license=You have to accept the LGPL license to continue using NostalgiaCore
-
-setting_up_server_now=You are going to set up your server now.
-default_values_info=If you don't want to change the default value, just press Enter.
-server_properties=You can edit them later on the server.properties file.
-
-name_your_server=Give a name to your server
-port_warning=Do not change the default port value if this is your first server.
-server_port=Server port
-invalid_port=Invalid server port
-ram_warning=The RAM is the maximum amount of memory NostalgiaCore will use. A value of 128-256 MB is recommended
-server_ram=Server RAM in MB
-gamemode_info=Choose between Creative (1) or Survival (0)
-default_gamemode=Default Game mode
-max_players=Max. online players
-spawn_protection_info=The spawn protection disallows placing/breaking blocks in the spawn zone except for OPs
-spawn_protection=Enable spawn protection?
-
-op_info=An OP is the player admin of the server. OPs can run more commands than normal players
-op_who=OP player name (example, your game name)
-op_warning=You will be able to add an OP user later using /op
-whitelist_info=The white-list only allows players in it to join.
-whitelist_enable=Do you want to enable the white-list?
-whitelist_warning=You will have to add the players to the white-list
-
-query_warning1=Query is a protocol used by diferent tools to get information of your server and players logged in.
-query_warning2=If you disable it, you won't be able to use server lists.
-query_disable=Do you want to disable Query?
-rcon_info=RCON is a protocol to remote connect with the server console using a password.
-rcon_enable=Do you want to enable RCON?
-rcon_password=RCON password (you can change it later)
-usage_info=The anonymous usage data allows us to calculate global statistics for NostalgiaCore and its plugins. You can view them on stats.pocketmine.net
-usage_disable=Do you want to disable the anonymous usage?
-ip_get=Getting your external IP and internal IP
-ip_warning=Your external IP is {{EXTERNAL_IP}}. You may have to port-forward to your internal IP {{INTERNAL_IP}}
-ip_confirm=Be sure to check it, if you have to forward and you skip that, no external players will be able to join. [Press Enter]
-
-you_have_finished=You have finished the set-up wizard correctly
-pocketmine_will_start=NostalgiaCore will now start. Type /help to view the list of available commands.
-pocketmine_plugins=Check the Plugin Repository to add new features, minigames, or advanced protection to your server
\ No newline at end of file
diff --git a/src/lang/Installer/en_AU.ini b/src/lang/Installer/en_AU.ini
deleted file mode 100644
index 7d3e1cba..00000000
--- a/src/lang/Installer/en_AU.ini
+++ /dev/null
@@ -1,45 +0,0 @@
-language_has_been_selected=English has been correctly selected.
-skip_installer=Do you want to skip the set-up wizard?
-
-welcome_to_pocketmine=Welcome to NostalgiaCore!\nBefore starting setting up your new server you have to accept the license.\nNostalgiaCore is licensed under the LGPL License,\nthat you can read opening the LICENSE file on this folder.
-accept_license=Do you accept the License?
-you_have_to_accept_the_license=You have to accept the LGPL license to continue using NostalgiaCore
-
-setting_up_server_now=You are going to set up your server now.
-default_values_info=If you don't want to change the default value, just press Enter.
-server_properties=You can edit them later on the server.properties file.
-
-name_your_server=Give a name to your server
-port_warning=Do not change the default port value if this is your first server.
-server_port=Server port
-invalid_port=Invalid server port
-ram_warning=The RAM is the maximum amount of memory NostalgiaCore will use. A value of 128-256 MB is recommended
-server_ram=Server RAM in MB
-gamemode_info=Choose between Creative (1) or Survival (0)
-default_gamemode=Default Game mode
-max_players=Max. online players
-spawn_protection_info=The spawn protection disallows placing/breaking blocks in the spawn zone except for OPs
-spawn_protection=Enable spawn protection?
-
-op_info=An OP is the player admin of the server. OPs can run more commands than normal players
-op_who=OP player name (example, your game name)
-op_warning=You will be able to add an OP user later using /op
-whitelist_info=The white-list only allows players in it to join.
-whitelist_enable=Do you want to enable the white-list?
-whitelist_warning=You will have to add the players to the white-list
-
-query_warning1=Query is a protocol used by diferent tools to get information of your server and players logged in.
-query_warning2=If you disable it, you won't be able to use server lists.
-query_disable=Do you want to disable Query?
-rcon_info=RCON is a protocol to remote connect with the server console using a password.
-rcon_enable=Do you want to enable RCON?
-rcon_password=RCON password (you can change it later)
-usage_info=The anonymous usage data allows us to calculate global statistics for NostalgiaCore and its plugins. You can view them on stats.pocketmine.net
-usage_disable=Do you want to disable the anonymous usage?
-ip_get=Getting your external IP and internal IP
-ip_warning=Your external IP is {{EXTERNAL_IP}}. You may have to port-forward to your internal IP {{INTERNAL_IP}}
-ip_confirm=Be sure to check it, if you have to forward and you skip that, no external players will be able to join. [Press Enter]
-
-you_have_finished=You have finished the set-up wizard correctly
-pocketmine_will_start=NostalgiaCore will now start. Type /help to view the list of available commands.
-pocketmine_plugins=Check the Plugin Repository to add new features, minigames, or advanced protection to your server
diff --git a/src/lang/Installer/en_CA.ini b/src/lang/Installer/en_CA.ini
deleted file mode 100644
index 7d3e1cba..00000000
--- a/src/lang/Installer/en_CA.ini
+++ /dev/null
@@ -1,45 +0,0 @@
-language_has_been_selected=English has been correctly selected.
-skip_installer=Do you want to skip the set-up wizard?
-
-welcome_to_pocketmine=Welcome to NostalgiaCore!\nBefore starting setting up your new server you have to accept the license.\nNostalgiaCore is licensed under the LGPL License,\nthat you can read opening the LICENSE file on this folder.
-accept_license=Do you accept the License?
-you_have_to_accept_the_license=You have to accept the LGPL license to continue using NostalgiaCore
-
-setting_up_server_now=You are going to set up your server now.
-default_values_info=If you don't want to change the default value, just press Enter.
-server_properties=You can edit them later on the server.properties file.
-
-name_your_server=Give a name to your server
-port_warning=Do not change the default port value if this is your first server.
-server_port=Server port
-invalid_port=Invalid server port
-ram_warning=The RAM is the maximum amount of memory NostalgiaCore will use. A value of 128-256 MB is recommended
-server_ram=Server RAM in MB
-gamemode_info=Choose between Creative (1) or Survival (0)
-default_gamemode=Default Game mode
-max_players=Max. online players
-spawn_protection_info=The spawn protection disallows placing/breaking blocks in the spawn zone except for OPs
-spawn_protection=Enable spawn protection?
-
-op_info=An OP is the player admin of the server. OPs can run more commands than normal players
-op_who=OP player name (example, your game name)
-op_warning=You will be able to add an OP user later using /op
-whitelist_info=The white-list only allows players in it to join.
-whitelist_enable=Do you want to enable the white-list?
-whitelist_warning=You will have to add the players to the white-list
-
-query_warning1=Query is a protocol used by diferent tools to get information of your server and players logged in.
-query_warning2=If you disable it, you won't be able to use server lists.
-query_disable=Do you want to disable Query?
-rcon_info=RCON is a protocol to remote connect with the server console using a password.
-rcon_enable=Do you want to enable RCON?
-rcon_password=RCON password (you can change it later)
-usage_info=The anonymous usage data allows us to calculate global statistics for NostalgiaCore and its plugins. You can view them on stats.pocketmine.net
-usage_disable=Do you want to disable the anonymous usage?
-ip_get=Getting your external IP and internal IP
-ip_warning=Your external IP is {{EXTERNAL_IP}}. You may have to port-forward to your internal IP {{INTERNAL_IP}}
-ip_confirm=Be sure to check it, if you have to forward and you skip that, no external players will be able to join. [Press Enter]
-
-you_have_finished=You have finished the set-up wizard correctly
-pocketmine_will_start=NostalgiaCore will now start. Type /help to view the list of available commands.
-pocketmine_plugins=Check the Plugin Repository to add new features, minigames, or advanced protection to your server
diff --git a/src/lang/Installer/en_GB.ini b/src/lang/Installer/en_GB.ini
deleted file mode 100644
index 7d3e1cba..00000000
--- a/src/lang/Installer/en_GB.ini
+++ /dev/null
@@ -1,45 +0,0 @@
-language_has_been_selected=English has been correctly selected.
-skip_installer=Do you want to skip the set-up wizard?
-
-welcome_to_pocketmine=Welcome to NostalgiaCore!\nBefore starting setting up your new server you have to accept the license.\nNostalgiaCore is licensed under the LGPL License,\nthat you can read opening the LICENSE file on this folder.
-accept_license=Do you accept the License?
-you_have_to_accept_the_license=You have to accept the LGPL license to continue using NostalgiaCore
-
-setting_up_server_now=You are going to set up your server now.
-default_values_info=If you don't want to change the default value, just press Enter.
-server_properties=You can edit them later on the server.properties file.
-
-name_your_server=Give a name to your server
-port_warning=Do not change the default port value if this is your first server.
-server_port=Server port
-invalid_port=Invalid server port
-ram_warning=The RAM is the maximum amount of memory NostalgiaCore will use. A value of 128-256 MB is recommended
-server_ram=Server RAM in MB
-gamemode_info=Choose between Creative (1) or Survival (0)
-default_gamemode=Default Game mode
-max_players=Max. online players
-spawn_protection_info=The spawn protection disallows placing/breaking blocks in the spawn zone except for OPs
-spawn_protection=Enable spawn protection?
-
-op_info=An OP is the player admin of the server. OPs can run more commands than normal players
-op_who=OP player name (example, your game name)
-op_warning=You will be able to add an OP user later using /op
-whitelist_info=The white-list only allows players in it to join.
-whitelist_enable=Do you want to enable the white-list?
-whitelist_warning=You will have to add the players to the white-list
-
-query_warning1=Query is a protocol used by diferent tools to get information of your server and players logged in.
-query_warning2=If you disable it, you won't be able to use server lists.
-query_disable=Do you want to disable Query?
-rcon_info=RCON is a protocol to remote connect with the server console using a password.
-rcon_enable=Do you want to enable RCON?
-rcon_password=RCON password (you can change it later)
-usage_info=The anonymous usage data allows us to calculate global statistics for NostalgiaCore and its plugins. You can view them on stats.pocketmine.net
-usage_disable=Do you want to disable the anonymous usage?
-ip_get=Getting your external IP and internal IP
-ip_warning=Your external IP is {{EXTERNAL_IP}}. You may have to port-forward to your internal IP {{INTERNAL_IP}}
-ip_confirm=Be sure to check it, if you have to forward and you skip that, no external players will be able to join. [Press Enter]
-
-you_have_finished=You have finished the set-up wizard correctly
-pocketmine_will_start=NostalgiaCore will now start. Type /help to view the list of available commands.
-pocketmine_plugins=Check the Plugin Repository to add new features, minigames, or advanced protection to your server
diff --git a/src/lang/Installer/en_PT.ini b/src/lang/Installer/en_PT.ini
deleted file mode 100644
index 6fb66a5e..00000000
--- a/src/lang/Installer/en_PT.ini
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
diff --git a/src/lang/Installer/en_US.ini b/src/lang/Installer/en_US.ini
deleted file mode 100644
index 7d3e1cba..00000000
--- a/src/lang/Installer/en_US.ini
+++ /dev/null
@@ -1,45 +0,0 @@
-language_has_been_selected=English has been correctly selected.
-skip_installer=Do you want to skip the set-up wizard?
-
-welcome_to_pocketmine=Welcome to NostalgiaCore!\nBefore starting setting up your new server you have to accept the license.\nNostalgiaCore is licensed under the LGPL License,\nthat you can read opening the LICENSE file on this folder.
-accept_license=Do you accept the License?
-you_have_to_accept_the_license=You have to accept the LGPL license to continue using NostalgiaCore
-
-setting_up_server_now=You are going to set up your server now.
-default_values_info=If you don't want to change the default value, just press Enter.
-server_properties=You can edit them later on the server.properties file.
-
-name_your_server=Give a name to your server
-port_warning=Do not change the default port value if this is your first server.
-server_port=Server port
-invalid_port=Invalid server port
-ram_warning=The RAM is the maximum amount of memory NostalgiaCore will use. A value of 128-256 MB is recommended
-server_ram=Server RAM in MB
-gamemode_info=Choose between Creative (1) or Survival (0)
-default_gamemode=Default Game mode
-max_players=Max. online players
-spawn_protection_info=The spawn protection disallows placing/breaking blocks in the spawn zone except for OPs
-spawn_protection=Enable spawn protection?
-
-op_info=An OP is the player admin of the server. OPs can run more commands than normal players
-op_who=OP player name (example, your game name)
-op_warning=You will be able to add an OP user later using /op
-whitelist_info=The white-list only allows players in it to join.
-whitelist_enable=Do you want to enable the white-list?
-whitelist_warning=You will have to add the players to the white-list
-
-query_warning1=Query is a protocol used by diferent tools to get information of your server and players logged in.
-query_warning2=If you disable it, you won't be able to use server lists.
-query_disable=Do you want to disable Query?
-rcon_info=RCON is a protocol to remote connect with the server console using a password.
-rcon_enable=Do you want to enable RCON?
-rcon_password=RCON password (you can change it later)
-usage_info=The anonymous usage data allows us to calculate global statistics for NostalgiaCore and its plugins. You can view them on stats.pocketmine.net
-usage_disable=Do you want to disable the anonymous usage?
-ip_get=Getting your external IP and internal IP
-ip_warning=Your external IP is {{EXTERNAL_IP}}. You may have to port-forward to your internal IP {{INTERNAL_IP}}
-ip_confirm=Be sure to check it, if you have to forward and you skip that, no external players will be able to join. [Press Enter]
-
-you_have_finished=You have finished the set-up wizard correctly
-pocketmine_will_start=NostalgiaCore will now start. Type /help to view the list of available commands.
-pocketmine_plugins=Check the Plugin Repository to add new features, minigames, or advanced protection to your server
diff --git a/src/lang/Installer/es_AR.ini b/src/lang/Installer/es_AR.ini
deleted file mode 100644
index 58d040ed..00000000
--- a/src/lang/Installer/es_AR.ini
+++ /dev/null
@@ -1,45 +0,0 @@
-language_has_been_selected=Español sido seleccionado correctamente.
-skip_installer=Quieres saltarte el asistente de configuración?
-
-welcome_to_pocketmine=Bienvenido a NostalgiaCore!\nAntes de comenzar a configurar tu nuevo servidor, tienes que aceptar la licencia.\nNostalgiaCore está licenciado con la licencia LGPL,\nque puedes leer abriendo el archivo LICENSE en esta carpeta.
-accept_license=¿Aceptas la Licencia?
-you_have_to_accept_the_license=Tienes que aceptar la licencia LGPL antes de continuar usando NostalgiaCore
-
-setting_up_server_now=La configuración del servidor va a comenzar.
-default_values_info=Si no quieres cambiar el valor por defecto, pulsa Enter.
-server_properties=Puedes editar todo despues en el fichero server.properties.
-
-name_your_server=Nombre del servidor
-port_warning=No cambies el puerto por defecto si este es tu primer servidor.
-server_port=Puerto del servidor
-invalid_port=Puerto inválido
-ram_warning=La RAM esla máxima memoria que NostalgiaCore usará. Es recomendado usar un valor de 128-256 MB
-server_ram=RAM del servidor en MB
-gamemode_info=Elige entre Creativo (1) o Supervivencia (0)
-default_gamemode=Modo de juego por defecto
-max_players=Límite de jugadores
-spawn_protection_info=La protección del inicio bloquea poner/romper bloques en la zona de inicio, excepto los OPs
-spawn_protection=¿Activar protección de inicio?
-
-op_info=Un OP es el jugador administrador del servidor. Los OPs pueden usar más comandos que los jugadores normales
-op_who=Jugador OP (por ejemplo, tu nombre de jugador)
-op_warning=Podrás añadir mas OPs después usando /op
-whitelist_info=La lista blanca permite entrar únicamente a los jugadores en ella.
-whitelist_enable=¿Quieres activar la lista blanca?
-whitelist_warning=Tendrás que añadir los jugadores a la lista blanca
-
-query_warning1=Query es un protocolo usado por diferentes herramientas para conseguir informacion de tu servidor y los jugadores conectados.
-query_warning2=Si lo desactivas, no podrás usar listas de servidores.
-query_disable=¿Quieres desactivar Query?
-rcon_info=RCON es un protocolo que permite conectarte a la consola del servidor usando una contraseña.
-rcon_enable=¿Queres activar RCON?
-rcon_password=Contraseña RCON (puedes cambiarla después)
-usage_info=Los datos de uso anónimos nos permiten calcular estadísticas globales para NostalgiaCore y sus plugins. Puedes verlas en stats.pocketmine.net
-usage_disable=¿Quieres desactivar las datos de uso anónimos?
-ip_get=Obteniendo tu IP externa e IP interna
-ip_warning=Tu IP externa es {{EXTERNAL_IP}}. Quizás debas redireccionar el puerto a tu IP interna {{INTERNAL_IP}}
-ip_confirm=Asegúrate de comprobarlo, ya que si debes hacerlo y lo saltas, ningún jugador externo podra entrar. [Pulsa Enter]
-
-you_have_finished=Has completado el asistente de configuración correctamente
-pocketmine_will_start=NostalgiaCore se iniciará ahora. Escribe /help para ver la lista de los comandos disponibles.
-pocketmine_plugins=Ves al Repositorio de Plugins para añadir nuevas funcionalidades, minijuegos o protección avanzada a tu servidor
diff --git a/src/lang/Installer/es_ES.ini b/src/lang/Installer/es_ES.ini
deleted file mode 100644
index 58d040ed..00000000
--- a/src/lang/Installer/es_ES.ini
+++ /dev/null
@@ -1,45 +0,0 @@
-language_has_been_selected=Español sido seleccionado correctamente.
-skip_installer=Quieres saltarte el asistente de configuración?
-
-welcome_to_pocketmine=Bienvenido a NostalgiaCore!\nAntes de comenzar a configurar tu nuevo servidor, tienes que aceptar la licencia.\nNostalgiaCore está licenciado con la licencia LGPL,\nque puedes leer abriendo el archivo LICENSE en esta carpeta.
-accept_license=¿Aceptas la Licencia?
-you_have_to_accept_the_license=Tienes que aceptar la licencia LGPL antes de continuar usando NostalgiaCore
-
-setting_up_server_now=La configuración del servidor va a comenzar.
-default_values_info=Si no quieres cambiar el valor por defecto, pulsa Enter.
-server_properties=Puedes editar todo despues en el fichero server.properties.
-
-name_your_server=Nombre del servidor
-port_warning=No cambies el puerto por defecto si este es tu primer servidor.
-server_port=Puerto del servidor
-invalid_port=Puerto inválido
-ram_warning=La RAM esla máxima memoria que NostalgiaCore usará. Es recomendado usar un valor de 128-256 MB
-server_ram=RAM del servidor en MB
-gamemode_info=Elige entre Creativo (1) o Supervivencia (0)
-default_gamemode=Modo de juego por defecto
-max_players=Límite de jugadores
-spawn_protection_info=La protección del inicio bloquea poner/romper bloques en la zona de inicio, excepto los OPs
-spawn_protection=¿Activar protección de inicio?
-
-op_info=Un OP es el jugador administrador del servidor. Los OPs pueden usar más comandos que los jugadores normales
-op_who=Jugador OP (por ejemplo, tu nombre de jugador)
-op_warning=Podrás añadir mas OPs después usando /op
-whitelist_info=La lista blanca permite entrar únicamente a los jugadores en ella.
-whitelist_enable=¿Quieres activar la lista blanca?
-whitelist_warning=Tendrás que añadir los jugadores a la lista blanca
-
-query_warning1=Query es un protocolo usado por diferentes herramientas para conseguir informacion de tu servidor y los jugadores conectados.
-query_warning2=Si lo desactivas, no podrás usar listas de servidores.
-query_disable=¿Quieres desactivar Query?
-rcon_info=RCON es un protocolo que permite conectarte a la consola del servidor usando una contraseña.
-rcon_enable=¿Queres activar RCON?
-rcon_password=Contraseña RCON (puedes cambiarla después)
-usage_info=Los datos de uso anónimos nos permiten calcular estadísticas globales para NostalgiaCore y sus plugins. Puedes verlas en stats.pocketmine.net
-usage_disable=¿Quieres desactivar las datos de uso anónimos?
-ip_get=Obteniendo tu IP externa e IP interna
-ip_warning=Tu IP externa es {{EXTERNAL_IP}}. Quizás debas redireccionar el puerto a tu IP interna {{INTERNAL_IP}}
-ip_confirm=Asegúrate de comprobarlo, ya que si debes hacerlo y lo saltas, ningún jugador externo podra entrar. [Pulsa Enter]
-
-you_have_finished=Has completado el asistente de configuración correctamente
-pocketmine_will_start=NostalgiaCore se iniciará ahora. Escribe /help para ver la lista de los comandos disponibles.
-pocketmine_plugins=Ves al Repositorio de Plugins para añadir nuevas funcionalidades, minijuegos o protección avanzada a tu servidor
diff --git a/src/lang/Installer/es_MX.ini b/src/lang/Installer/es_MX.ini
deleted file mode 100644
index beeafd42..00000000
--- a/src/lang/Installer/es_MX.ini
+++ /dev/null
@@ -1,45 +0,0 @@
-language_has_been_selected=Español seleccionado.
-skip_installer=Deseas omitir el asistente de configuración?
-
-welcome_to_pocketmine=¡Bienvenido a NostalgiaCore!\nAntes de empezar a configurar tu nuevo servidor necesitas aceptar la licensia.\nLa licensia de NostalgiaCore esta bajo la licensia LGPL,\n que puedes leer abriendo el archivo "License" en esta carpeta.
-accept_license=Aceptas la licensia?
-you_have_to_accept_the_license=Debes aceptar la licensia de LPGL para continuar utilizando NostalgiaCore
-
-setting_up_server_now=Empezemos con la configuración.
-default_values_info=Si no quieres cambiar los valores predeterminados pulsa Enter.
-server_properties=Puedes editarlos despues editando el archivo "server.properties".
-
-name_your_server=Escribe el nombre de tu servidor
-port_warning=No cambies el puerto predeterminado si este es tu primer servidor.
-server_port=Puerto del servidor
-invalid_port=Puerto invalido
-ram_warning=La RAM es la máxima memoria que NostalgiaCore usará. Se recomienda utilizar un mínimo de 128 MB
-server_ram=RAM del servidor en MB
-gamemode_info=Escoge entre Creativo (1) o Survival (0)
-default_gamemode=Modo de juego predeterminado
-max_players=Límite de jugadores
-spawn_protection_info=La protección del inicio impide poner/romper bloques en la zona de aparición, a excepción de los OPs
-spawn_protection=Activar la protección del spawn?
-
-op_info=Un OP es el administrador del servidor. Los OPs pueden ejecutar más comandos que los usuarios normales
-op_who=OP nombre del jugador (Por ejemplo: Tu nombre de Minecraft)
-op_warning=Podrás añadir más usuarios a la lista de OPs después, utilizando el comando /op
-whitelist_info=La lista blanca (white-list) permite hacer una lista de invitados, solo los usuarios en la lista podrán entrar a tu servidor.
-whitelist_enable=¿Deseas activar la lista blanca?
-whitelist_warning=Tendrás que añadir usuarios a la lista blanca
-
-query_warning1=Query es un protocolo usado por diferentes herramientas para conseguir informacion de tu servidor y los jugadores conectados.
-query_warning2=Si lo desactivas, no podrás registrar tu servidor en una lista de servidores.
-query_disable=¿Quieres desactivar Query?
-rcon_info=RCON es un protocolo que te permite conectarte a la consola de tu servidor usando una contraseña.
-rcon_enable=¿Queres activar RCON?
-rcon_password=Contraseña para RCON (puedes cambiarla después)
-usage_info=Los datos de uso anónimos nos permiten calcular estadísticas globales para NostalgiaCore y sus plugins. Puedes verlas en stats.pocketmine.net
-usage_disable=¿Quieres desactivar las datos de uso anónimos?
-ip_get=Obteniendo tu IP externa e IP interna
-ip_warning=Tu IP externa es {{EXTERNAL_IP}}. Quizás debas redireccionar el puerto a tu IP interna: {{INTERNAL_IP}}
-ip_confirm=Asegúrate de que este bien, ya que si debes hacerlo y lo saltas, ningún jugador podrá entrar si esta fuera de tu red WIFI. [Pulsa Enter]
-
-you_have_finished=Has completado el asistente de configuración correctamente
-pocketmine_will_start=NostalgiaCore se iniciará ahora. Escribe /help para ver la lista de los comandos disponibles.
-pocketmine_plugins=Ve al Repositorio de Plugins para añadir nuevas funciones, minijuegos o protección avanzada a tu servidor
diff --git a/src/lang/Installer/et_EE.ini b/src/lang/Installer/et_EE.ini
deleted file mode 100644
index 6fb66a5e..00000000
--- a/src/lang/Installer/et_EE.ini
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
diff --git a/src/lang/Installer/fi_FI.ini b/src/lang/Installer/fi_FI.ini
deleted file mode 100644
index bdfa7ab6..00000000
--- a/src/lang/Installer/fi_FI.ini
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-default_gamemode=Normaali Peli Tila
-
-
-
diff --git a/src/lang/Installer/fr_FR.ini b/src/lang/Installer/fr_FR.ini
deleted file mode 100644
index 6112ea65..00000000
--- a/src/lang/Installer/fr_FR.ini
+++ /dev/null
@@ -1,45 +0,0 @@
-language_has_been_selected=Français a été correctement sélectionné.
-skip_installer=Voulez-vous passer l'assistant d'installation?
-
-welcome_to_pocketmine=Bienvenue sur NostalgiaCore!\nAvant de commencer à paramétrer votre nouveau serveur, vous devez accepter la license d'utilisation.\nNostalgiaCore est sous licence LGPL,\nvous pouvez la lire en ouvrant le fichier LICENSE dans ce dossier.
-accept_license=Acceptez-vous la Licence?
-you_have_to_accept_the_license=Vous devez accepter la licence LGPL pour continuer à utiliser NostalgiaCore
-
-setting_up_server_now=Vous êtes maintenant prêt à paramétrer votre serveur.
-default_values_info=Si vous ne voulez pas changer la valeur par défaut, pressez juste Enter.
-server_properties=Vous pouvez éditer cela plus tard dans le fichier server.properties.
-
-name_your_server=Donnez un nom à votre serveur
-port_warning=Ne changez pas la valeur par défaut du port si c'est votre premier serveur.
-server_port=Port du serveur
-invalid_port=Port du serveur invalide
-ram_warning=La RAM est au maximum de sa capacité par rapport à la mémoire utilisée par NostalgiaCore. Une valeur de 128-256 MB est recommandée
-server_ram=RAM du serveur en MB
-gamemode_info=Choisir entre Créatif (1) ou Survie (1)
-default_gamemode=Mode de jeu par défaut
-max_players=Joueurs max. en ligne
-spawn_protection_info=La protection de spawn désactive le placement/cassement de blocs dans la zone de spawn excepté pour les OPs
-spawn_protection=Activer la protection de spawn?
-
-op_info=Un OP est un administrateur du serveur. Les OPs peuvent exécuter plus de commandes que les joueurs normaux
-op_who=Nom de joueur OP (exemple, votre nom de jeu)
-op_warning=Vous serez en mesure d'ajouter un OP plus tard en utilisant /op
-whitelist_info=La white-list autorise seulement les joueurs présents sur celle-ci.
-whitelist_enable=Voulez-vous activer la white-list?
-whitelist_warning=Vous devrez ajouter les joueurs à la white-list
-
-query_warning1=Query est un protocole utilisé par différents outils pour avoir des informations sur votre serveur et les joueurs connectés.
-query_warning2=Si vous le désactivez, vous ne pourrez pas utiliser les listes du serveur.
-query_disable=Voulez-vous désactiver Query?
-rcon_info=RCON est un protocole pour se connecter à distance à la console du serveur par un mot de passe.
-rcon_enable=Voulez-vous activer RCON?
-rcon_password=Mot de passe RCON (vous pouvez le changer plus tard)
-usage_info=Les données d'utilisation anonyme vous permettent de calculer les statistiques globales de NostalgiaCore et ses plugins. Vous pouvez les voir sur stats.pocketmine.net
-usage_disable=Voulez-vous désactiver l'utilisation anonyme?
-ip_get=Obtention de votre IP externe et IP interne
-ip_warning=Votre IP externe est {{EXTERNAL_IP}}. Vous pourriez avoir à transmettre au port votre IP interne {{INTERNAL_IP}}
-ip_confirm=Vérifiez-le bien, si vous avancez et sautez cette étape, les joueurs extérieurs ne pourront pas rejoindre votre serveur. [Tapez Enter]
-
-you_have_finished=Vous avez correctement terminé l'assistant d'installation
-pocketmine_will_start=NostalgiaCore démarre. Tapez /help pour voir la liste des commandes disponibles.
-pocketmine_plugins=Vérification du répertoire de plugin pour ajouter des nouvelles caractéristiques, mini-jeux, ou une protection avancée de votre serveur
diff --git a/src/lang/Installer/ga_IE.ini b/src/lang/Installer/ga_IE.ini
deleted file mode 100644
index 6fb66a5e..00000000
--- a/src/lang/Installer/ga_IE.ini
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
diff --git a/src/lang/Installer/he_IL.ini b/src/lang/Installer/he_IL.ini
deleted file mode 100644
index 6fb66a5e..00000000
--- a/src/lang/Installer/he_IL.ini
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
diff --git a/src/lang/Installer/id_ID.ini b/src/lang/Installer/id_ID.ini
deleted file mode 100644
index 6fb66a5e..00000000
--- a/src/lang/Installer/id_ID.ini
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
diff --git a/src/lang/Installer/it_IT.ini b/src/lang/Installer/it_IT.ini
deleted file mode 100644
index f29e4e2b..00000000
--- a/src/lang/Installer/it_IT.ini
+++ /dev/null
@@ -1,45 +0,0 @@
-language_has_been_selected=Italiano selezionato correttamente.
-skip_installer=Vuoi evitare il programma di installazione?
-
-welcome_to_pocketmine=Benvenuto in NostalgiaCore!\nPrima di iniziare a impostare il tuo nuovo server devi accettare la licenza.\nNostalgiaCore è distribuito sotto licenza LGPL,\nche potrai leggere aprendo il file LICNESE in questa cartella.
-accept_license=Accetti i termini della licenza?
-you_have_to_accept_the_license=Devi accettare i termini della licenza LGPL per continuare ad usare NostalgiaCore
-
-setting_up_server_now=Stai per iniziare ad impostare il tuo server.
-default_values_info=Se non vuoi cambiare i valori proposti, premi Invio.
-server_properties=Potrai modificarli in seguito nel file server.properties.
-
-name_your_server=Dai un nome al tuo server
-port_warning=Non cambiare la porta predefinita se questo è il tuo primo server.
-server_port=Porta del server
-invalid_port=Porta del server non valida
-ram_warning=La RAM è la massima quantità di memoria che NostalgiaCore potrà usare. Un valore di 128-256 MB è raccomandata
-server_ram=RAM del server in MB
-gamemode_info=Scegli tra Creative (1) o Survival (0)
-default_gamemode=Modalità di gioco predefinita
-max_players=Players massimi
-spawn_protection_info=La protezione dello spawn non permette di piazzare/rompere blocchi nella zona di spawn, ad eccezione degli Operatori
-spawn_protection=Abilitare la protezione dello spawn?
-
-op_info=Un Operatore (OP) è un player amministratore del server. Gli operatori possono usare più comandi dei players normali
-op_who=Nome del player OP (ad esempio, il tuo nome in gioco)
-op_warning=Sarà possibile aggiungere un player OP più tardi con /op
-whitelist_info=La white-list permette solo ad i players in lista di entrare.
-whitelist_enable=Vuoi abilitare la white-list?
-whitelist_warning=Dovrai aggiungere i players in white-list
-
-query_warning1=Query è un protocollo usato da differenti programmi per ottenere informazioni dal tuo server e dai player che ci entrano.
-query_warning2=Se lo disabiliti, non sarai in grado di usare le liste server.
-query_disable=Vuoi disabilitare Query?
-rcon_info=RCON è un protocollo per connessioni remote con la console del server grazie all'utilizzo di una password.
-rcon_enable=Vuoi abilitare RCON?
-rcon_password=Password RCON (potrai cambiarla più tardi)
-usage_info=L'invio anonimo dei dati di utilizzo ci aiuta a calcolare statistiche generali per NostalgiaCore ed i suoi plugins. Puoi vederle su stats.pocketmine.net
-usage_disable=Vuoi disabilitare l'invio anonimo dei dati di utilizzo?
-ip_get=Ottengo il tuo indirizzo IP interno ed esterno
-ip_warning=Il tuo indirizzo IP è {{EXTERNAL_IP}}. Potresti dover redirigere le porte al tuo IP interno: {{INTERNAL_IP}}
-ip_confirm=Sii sicuro di farlo, se devi redirigere le porte e non lo fai, nessun player esterno sarà in grado di entrare. [Premi Invio]
-
-you_have_finished=Hai completato l'installazione con successo
-pocketmine_will_start=Ora NostalgiaCore si avvierà. Digita /help per visualizzare la lista dei comandi disponibili.
-pocketmine_plugins=Controlla il Repository dei Plugins per aggiungere nuove funzionalità, minigiochi, o protezioni avanzate al tuo server
diff --git a/src/lang/Installer/ja_JP.ini b/src/lang/Installer/ja_JP.ini
deleted file mode 100644
index 40a92ef1..00000000
--- a/src/lang/Installer/ja_JP.ini
+++ /dev/null
@@ -1,45 +0,0 @@
-language_has_been_selected=日本語に設定されました
-skip_installer=セットアップウィザードをスキップしますか?
-
-welcome_to_pocketmine=NostalgiaCoreをインストールして頂きありがとうございます!サーバのセットアップを開始するにはライセンスに同意する必要があります。NostalgiaCoreはLGPLライセンスに基づいて認可されており、これについてはこのフォルダ内のLICENSEファイルから確認することができます。
-accept_license=ライセンスに同意しますか?
-you_have_to_accept_the_license=NostalgiaCoreを使用するにはLGPLライセンスに同意する必要があります
-
-setting_up_server_now=サーバのセットアップを開始します
-default_values_info=設定を変更しない場合は、Enterキーを押してください。
-server_properties=それらの設定は後からでもserver.propertiesファイルから変更できます
-
-name_your_server=あなたのサーバに名前を付けてください
-port_warning=これが初めてのサーバの場合は、ポート番号をデフォルトから変更しないでください
-server_port=サーバポート
-invalid_port=不適切なサーバポートです
-ram_warning=RAMはNostalgiaCoreが使用し得るメモリの最大値を示しています。128-256MBの範囲内で指定することを推奨します。
-server_ram=RAMの単位はMBです
-gamemode_info=クリエイティブモード(1)、またはサバイバルモード(0)を選択してください
-default_gamemode=デフォルトのゲームモード
-max_players=最大プレイヤー数
-spawn_protection_info=スポーンプロテクションは、OPでないプレイヤーによるスポーン地点付近でのブロックの設置/破壊を制限します
-spawn_protection=スポーンプロテクションを有効にしますか?
-
-op_info=OPとはそのサーバの管理権限を指します。OPを持ったプレイヤーは他のプレイヤーよりも多くのコマンドを使用できます。
-op_who=OPプレイヤー名(例: あなたのゲーム内での名前)
-op_warning=後から/op <プレイヤー名>コマンドを実行してOPプレイヤーを追加することもできます
-whitelist_info=ホワイトリストはこのサーバに入ることのできるプレイヤーを制限します。
-whitelist_enable=ホワイトリストを有効にしますか?
-whitelist_warning=プレイヤーをホワイトリストに追加してください
-
-query_warning1=クエリは他のツールによりあなたのサーバやプレイヤーの情報を取得するためのプロトコルです。
-query_warning2=それを無効にした場合、サーバリストを使用できなくなる可能性があります。
-query_disable=クエリを無効にしますか?
-rcon_info=RCONはパスワードを用いてサーバコンソールからリモート接続するためのプロトコルです。
-rcon_enable=RCONを有効にしますか?
-rcon_password=RCONパスワード(後から変更できます)
-usage_info=世界中で使われているNostalgiaCoreやそのプラグインの統計を算出するために匿名の使用データが送信されます。統計はこちらから確認できます。stats.pocketmine.net
-usage_disable=匿名の使用データの送信を拒否しますか?
-ip_get=グローバルIPとプライベートIPの取得
-ip_warning=あなたのグローバルIPは{{EXTERNAL_IP}}です。プライベートIP{{INTERNAL_IP}}をポート解放してください。
-ip_confirm=必ずポート解放ができているか確認してください。ポートが解放できていなかった場合、他のプレイヤーがサーバに入れなくなる恐れがあります。[Enterキーを押してください]
-
-you_have_finished=セットアップは正しく終了しました
-pocketmine_will_start=PocketMine_MPを起動します。/helpと入力すれば使用可能なコマンド一覧を表示できます。
-pocketmine_plugins=拡張機能や管理システム、ミニゲームなどを追加できるプラグインリポジトリも確認してみてください
diff --git a/src/lang/Installer/ko_KR.ini b/src/lang/Installer/ko_KR.ini
deleted file mode 100644
index ba1d8de7..00000000
--- a/src/lang/Installer/ko_KR.ini
+++ /dev/null
@@ -1,45 +0,0 @@
-language_has_been_selected=한국어가 언어로 선택되었습니다.
-skip_installer=설치 마법사를 건너뛰겠습니까?
-
-welcome_to_pocketmine=NostalgiaCore에 오신 것을 환영합니다!\n서버 설치를 시작하기 전, 약관에 동의해야 합니다. \nNostalgiaCore는 GNU 약소 일반 공중 사용 허가서(LGPL) 하에 배포되고 있습니다. \n이 폴더에서 약관을 읽을 수 있습니다.
-accept_license=약관에 동의하십니까?
-you_have_to_accept_the_license=GNU 약소 일반 공중 사용 허가서(LGPL)에 동의하셔야 NostalgiaCore를 사용할 수 있습니다.
-
-setting_up_server_now=서버 설정을 시작합니다.
-default_values_info=기본값을 수정하고 싶지 않으면, 엔터를 누르십시기 바랍니다.
-server_properties=이 설정들은 server.properties 파일에서 세부적으로 변경이 가능합니다.
-
-name_your_server=당신의 서버 이름을 입력하시기 바랍니다.
-port_warning=만약 당신이 서버를 처음 설정한다면 포트 값을 변경하지 마세요.
-server_port=서버 포트
-invalid_port=서버 포트가 잘못 입력되었습니다.
-ram_warning=RAM 값은 NostalgiaCore에 할당할 메모리의 크기입니다. 128~256MB를 권장합니다.
-server_ram=서버 RAM (MB)
-gamemode_info=크리에이티브 (1) 또는 서바이벌 (0) 게임모드 중 하나를 고르세요.
-default_gamemode=기본 게임 모드
-max_players=최대 동시 접속 인원 수
-spawn_protection_info=스폰 보호는 OP를 제외한 유저들이 스폰 지역 근처에서 블럭을 놓거나 부수는것을 방지합니다.
-spawn_protection=스폰 지역 보호를 사용하겠습니까?
-
-op_info=OP는 서버 관리자를 뜻합니다. OP는 일반 플레이어보다 훨씬 많은 명령어들을 사용할 수 있습니다
-op_who=OP 권한을 줄 플레이어 이름(예: 당신의 닉네임)
-op_warning=또는 이후에 /op <플레이어 이름> 을 입력해 그 유저에게 OP 권한을 줄 수도 있습니다
-whitelist_info=화이트리스트를 사용하면 허용된 플레이어들만 서버에 접속할 수 있습니다.
-whitelist_enable=화이트리스트를 사용하겠습니까?
-whitelist_warning=당신은 접속을 허용할 플레이어들의 이름을 적어야 합니다
-
-query_warning1=쿼리 (Query)는 당신의 서버와 현재 접속한 플레이어들의 정보를 알 수 있게 해주는 여러가지 기능이 담긴 프로토콜입니다.
-query_warning2=쿼리를 사용하지 않으면, 당신은 서버 리스트를 사용할 수 없게 됩니다.
-query_disable=쿼리를 사용하지 않겠습니까?
-rcon_info=RCON은 비밀 번호를 사용하여 서버 명령창에 원격으로 접소갈 수 있는 프로토콜입니다.
-rcon_enable=RCON 을 사용하시겠습니까?
-rcon_password=RCON 비밀번호 설정 (나중에 server.properties 에서 변경이 가능합니다.)
-usage_info=익명 사용 통계 전송을 허용하면 NostalgiaCore가 세계의 서버 상황과 플러그인들을 통계화하는 데 사용할 수 있습니다. 당신은 stats.pocketmine.net에서 이를 확인할 수 있습니다
-usage_disable=익명 사용 통계 전송을 사용하지 않으시겠습니까?
-ip_get=내/외부 IP 주소 얻기
-ip_warning=당신의 외부 IP는 {{EXTERNAL_IP}}입니다. 당신의 내부 IP {{INTERNAL_IP}}로 포트포워딩이 필요할 수 있습니다
-ip_confirm=신중하게 확인하세요. 만약 포트 포워딩이 필요하지만 하지 않을 경우 외부에서 플레이어들이 접속할 수 없게 됩니다. [계속 하시려면 엔터를 누르세요]
-
-you_have_finished=NostalgiaCore의 설치가 모두 완료되었습니다.
-pocketmine_will_start=NostalgiaCore 서버를 구동합니다. /help로 사용 가능한 모든 명령어의 목록을 보시기 바랍니다.
-pocketmine_plugins=플러그인 저장소에서 새로운 기능을 추가하세요. 새로운 기능, 미니게임을 추가하거나 고급 기능으로 당신의 서버를 보호할 수 있습니다
diff --git a/src/lang/Installer/lv_LV.ini b/src/lang/Installer/lv_LV.ini
deleted file mode 100644
index 6fb66a5e..00000000
--- a/src/lang/Installer/lv_LV.ini
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
diff --git a/src/lang/Installer/ms_MY.ini b/src/lang/Installer/ms_MY.ini
deleted file mode 100644
index 6fb66a5e..00000000
--- a/src/lang/Installer/ms_MY.ini
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
diff --git a/src/lang/Installer/mt_MT.ini b/src/lang/Installer/mt_MT.ini
deleted file mode 100644
index 6fb66a5e..00000000
--- a/src/lang/Installer/mt_MT.ini
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
diff --git a/src/lang/Installer/nl_NL.ini b/src/lang/Installer/nl_NL.ini
deleted file mode 100644
index 4d5395dd..00000000
--- a/src/lang/Installer/nl_NL.ini
+++ /dev/null
@@ -1,45 +0,0 @@
-language_has_been_selected=Nederlands is nu geselecteerd.
-skip_installer=Wil je de set-up help overslaan?
-
-welcome_to_pocketmine=Welkom op de NostalgiaCore!\nVoordat je je nieuwe server klaarmaakt, moet je onze gebruikersovereenkomst accepteren.\nNostalgiaCore is gelicenseerd onder LGPL License,\nwat je kunt lezen door de LICENSE file in deze map te openen.
-accept_license=Accepteer je de gebruikersvoorwaarden?
-you_have_to_accept_the_license=Je moet de LGPL gebruikersvoorwaarden accepteren voordat je verder gaat met het gebruiken van de services van NostalgiaCore
-
-setting_up_server_now=Je gaat nu een server klaarmaken voor gebruik.
-default_values_info=Druk op Enter als je de gebruikelijke waarde niet wilt veranderen.
-server_properties=Je kunt ze later veranderen in het server.properties bestand.
-
-name_your_server=Geef een naam aan je server
-port_warning=Verander de gebruikelijke poort niet als dit je eerste server is.
-server_port=Server poort
-invalid_port=Ongeldige server poort
-ram_warning=De RAM is het maximale aantal memory wat NostalgiaCore zal gebruiken. Een aantal tussen de 128 en de 256 MB is aanbevolen
-server_ram=Server RAM in MB
-gamemode_info=Kies tussen Creative (1) of Survival (0)
-default_gamemode=Gebruikelijke spelmodus
-max_players=Maximale online spelers
-spawn_protection_info=De spawnbeveiliging verbiedt het plaatsen/slopen van blokken in het spawn gebied behalve voor OP's
-spawn_protection=Wil je spawnbeveiliging aanzetten?
-
-op_info=Een OP is de beheerder van de server. OP's kunnen meer commando's gebruiken dan normale spelers
-op_who=OP speler naam (voorbeeld: je username)
-op_warning=Je kunt later meerdere OP's toevoegen met het commando /op
-whitelist_info=De whitelist laat alleen de spelers die in de lijst staan op de server.
-whitelist_enable=Wil je de whitelist aanzetten?
-whitelist_warning=Je moet wel spelers aan de whitelist toevoegen.
-
-query_warning1=Query is een protocol dat gebruikt wordt door verschillende programma's om informatie te verkrijgen van je server en welke spelers ingelogd zijn.
-query_warning2=Als je het uitzet, zul je geen mogelijkheid hebben om server lijsten te gebruiken.
-query_disable=Wil je Query uitschakelen?
-rcon_info=RCON is een protocol om je server op afstand te beheren via de server console door middel van een wachtwoord.
-rcon_enable=Wil je RCON aanzetten?
-rcon_password=RCON wachtwoord (deze kun je later veranderen)
-usage_info=De anonieme gebruikersdata laat ons toe om de globale statistieken voor PocketMine-ML te zien en zijn plugins. Je kunt de statistieken zien op stats.pocketmine.net
-usage_disable=Wil je anonieme data uitschakelen?
-ip_get=Je externe IP en interne IP verkrijgen
-ip_warning=Je externe IP is {{EXTERNAL_IP}}. Het is mogelijk dat je moet port-forwarden naar je interne IP:{{INTERNAL_IP}}
-ip_confirm=Wees niet bang om het te controleren, als je moet port-forwarden en je slaat dit over, kunnen externe spelers niet op de server.
-
-you_have_finished=Je hebt de set-up help volledig beëindigd.
-pocketmine_will_start=NostalgiaCore zal nu opstarten. Type /help om de lijst van beschikbare commando's te weergeven.
-pocketmine_plugins=Check de Plugin Opslag om nieuwe features, minigames of geavanceerde spawnbeveiliging toe te voegen aan je server
diff --git a/src/lang/Installer/no_NO.ini b/src/lang/Installer/no_NO.ini
deleted file mode 100644
index 4b9c0c5d..00000000
--- a/src/lang/Installer/no_NO.ini
+++ /dev/null
@@ -1,20 +0,0 @@
-language_has_been_selected=Norsk har blitt valgt.
-skip_installer=Vil du hoppe over utpakking trollmannen?
-
-welcome_to_pocketmine=Velkommen til NostalgiaCore!\nFør vi starter med å sette opp din nye server må du akseptere vår lisens.\nNostalgiaCore er lisensiert under LGPL lisensen,\nat du kan lese LISENS filen i denne mappen.
-accept_license=Aksepterer du lisensen?
-you_have_to_accept_the_license=Du må akseptere LGPL lisensen for å fortsette med å bruke NostalgiaCore
-
-setting_up_server_now=Nå skal du sette opp din server.
-default_values_info=Hvis du ikke vil gjøre forskjell med den ordinære verdien, så trenger du bare å trykke Enter.
-server_properties=Du kan redigere dem senere i server.properties filen.
-
-name_your_server=Gi et navn til din server
-port_warning=Ikke bytt på den vanlige port verdien vis dette er din første server.
-server_port=Server port
-invalid_port=Ugyldig server port
-ram_warning=RAMMEN er den maksimale beløpet NostalgiaCore vil bruke. A verdien av 128-256 MB er anbefalt
-server_ram=Server RAMMEN i MB
-
-
-
diff --git a/src/lang/Installer/pl_PL.ini b/src/lang/Installer/pl_PL.ini
deleted file mode 100644
index 6fb66a5e..00000000
--- a/src/lang/Installer/pl_PL.ini
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
diff --git a/src/lang/Installer/pt_PT.ini b/src/lang/Installer/pt_PT.ini
deleted file mode 100644
index 6fb66a5e..00000000
--- a/src/lang/Installer/pt_PT.ini
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
diff --git a/src/lang/Installer/ru_RU.ini b/src/lang/Installer/ru_RU.ini
deleted file mode 100644
index 968dc793..00000000
--- a/src/lang/Installer/ru_RU.ini
+++ /dev/null
@@ -1,45 +0,0 @@
-language_has_been_selected=Был выбран русский язык.
-skip_installer=Вы хотите пропустить мастер настройки?
-
-welcome_to_pocketmine=Добро пожаловать в NostalgiaCore!\nПеред началом установки нового сервера, вы должны согласиться с лицензией. \nNostalgiaCore лицензировано на условиях LGPL лицензии, \nс которой вы можете ознакомиться, открыв файл LICENSE в этой папке.
-accept_license=Принимаете ли вы лицензию?
-you_have_to_accept_the_license=Вы должны принять LGPL лицензию, чтобы продолжить использование NostalgiaCore
-
-setting_up_server_now=Теперь вы можете настроить сервер.
-default_values_info=Если вы не хотите изменять стандартное значение, просто нажмите Enter.
-server_properties=Вы можете редактировать их позже в файле server.properties.
-
-name_your_server=Дайте имя вашему серверу
-port_warning=Не изменяйте значение порта по умолчанию, если это ваш первый сервер.
-server_port=Порт сервера
-invalid_port=Неверный порт сервера
-ram_warning=RAM - максимальный объем памяти, котооый будет использовать NostalgiaCore, рекомендуемое значение 128-256 МБ
-server_ram=Оперативная память сервера в МБ
-gamemode_info=Выберите между Креативом-(1), или Выживанием (0)
-default_gamemode=Режим игры по умолчанию
-max_players=Максимум онлайн игроков
-spawn_protection_info=Защита спавна запрещает размещение/разрушение блоков на спавне, за исключением операторов
-spawn_protection=Включить защиту спавна?
-
-op_info=Оператор - Администратор сервера, который может использовать больше команд, чем обычный игрок
-op_who=Имя оператора (К примеру ваш ник в игре)
-op_warning=Вы можете добавить оператора позже используя команду /op
-whitelist_info=White-list позволяет присоединиться только игрокам в этом списке.
-whitelist_enable=Вы хотите включить white-list?
-whitelist_warning=Вам придётся добавить игроков в white-list
-
-query_warning1=Query - это протокол, используемый разными инструментами, чтобы получить информацию о вашем сервере и о зашедших игроках.
-query_warning2=Если вы отключите его, вы не сможете использовать списки серверов.
-query_disable=Вы хотите отключить Query?
-rcon_info=RCON - это протокол для удаленного управления сервером через консоль, с использованием пароля.
-rcon_enable=Вы хотите включить RCON?
-rcon_password=RCON пароль (вы сможете изменить его позже)
-usage_info=Сбор анонимных данных о использовании поможет нам проанализировать глобальную статистику для NostalgiaCore и плагинов. Статистика доступна по адресу stats.pocketmine.net
-usage_disable=Вы хотите отключить сбор анонимных данных о использовании?
-ip_get=Получение вашего внешнего и внутреннего IP адреса
-ip_warning=Ваш внешний IP адрес: {{EXTERNAL_IP}}. Возможно вам необходимо открыть порты к вашему внутреннему IP адресу: {{INTERNAL_IP}}
-ip_confirm=Убедитесь в том, что вы открыли порты, в противном случае игроки вне вашей локальной сети не смогут подключится. [Нажмите Enter]
-
-you_have_finished=Вы закончили работу с мастером установки
-pocketmine_will_start=NostalgiaCore сейчас запустится. Введите /help для просмотра доступных вам команд.
-pocketmine_plugins=Посетите репозиторий плагинов для получения новых функций, мини-игр, или повышения защиты вашего сервера.
diff --git a/src/lang/Installer/sv_SE.ini b/src/lang/Installer/sv_SE.ini
deleted file mode 100644
index 2b6ac001..00000000
--- a/src/lang/Installer/sv_SE.ini
+++ /dev/null
@@ -1,45 +0,0 @@
-language_has_been_selected=Svenska har bilvit valt.
-skip_installer=Vill du hoppa över Installations programmet?
-
-welcome_to_pocketmine=Välkommen till NostalgiaCore! Före du börja ställa in din server måste du godkänna licensen. NostalgiaCore är licenserat under LGPL Licensen som du kan läsa genom att öppna LICENSE filen i den här mappen.
-accept_license=Accepterar du Licensen?
-you_have_to_accept_the_license=Du måste godkänna LGPL licensen för att fortsätta använda NostalgiaCore
-
-setting_up_server_now=Du håller på att börja ställa in din server nu.
-default_values_info=Om du inte vill ändra standard värdet, tryck bara ENTER.
-server_properties=Du kan redigera dem senare i server.properies filen.
-
-name_your_server=Ge ett namn till din server
-port_warning=ändra INTE standard porten om detta är din första server.
-server_port=Server port
-invalid_port=Ogiltig Server port
-ram_warning=RAM är max mängden minne NostalgiaCore kommer använda. Ett väre av 128-256 MB är rekommenderat
-server_ram=Server RAM i MB
-gamemode_info=Välj mellan Kreativt läge (1) eller Överlevnad (0)
-default_gamemode=Standard spelläge
-max_players=Max spelare online
-spawn_protection_info=Spawn skydd stoppar spelare från att bygga / krossa block i Spawn-zonen förutom för OPs
-spawn_protection=Aktivera Spawn-skydd?
-
-op_info=En OP är en spelar Administratör på servern. OPs kan köra fler kommandon än vanliga spelare
-op_who=OP spelar namn (Ditt IGN här)
-op_warning=Du kommer kunna lägga till fler OPs senare me /op
-whitelist_info=whitelisten är en lista på spelare som får komma in på servern.
-whitelist_enable=Vill du aktivera whitelisten?
-whitelist_warning=Du måste i så fall lägga till spelare på whitelisten
-
-query_warning1=Query är ett protokoll som används av olika verktyg för att samla in information om din server och spelare loggade in.
-query_warning2=Om du stänger av den så kommer du inte kunna använda serverlistor.
-query_disable=Vill du stänga av Query?
-rcon_info=RCON är ett protocol för att trådlöst ansluta till server konsolen med ett lösenord.
-rcon_enable=Vill du aktivera RCON?
-rcon_password=RCON lösenord (kan bytas senare)
-usage_info=Anonym data användning tillåter oss att räkna ut global statistik för NostalgiaCore och dess plugin. Du kan se dessa på stats.pocketmine.net
-usage_disable=Vill du stänga av anonym data använding?
-ip_get=Hämtar din externa IP och interna IP
-ip_warning=Din externa Ip är {{EXTERNAL_IP}}} Du kan behöva göra en "port-foward" till din Interna IP {{INTERNAL_IP}}
-ip_confirm=Var säker på att du kollar den. Om du måste göra en "port-foward" men skippar det så kommer inga externa spelare att kunna logga in på din server. [Tryck på ENTER]
-
-you_have_finished=Du är nu klar. Allt har genomförts korrekt
-pocketmine_will_start=Din Server kommer nu att starta. skriv /help eller /? för en list på tillgängliga kommandon.
-pocketmine_plugins=Kolla in Plugin Hemsidan för att lägga till nya saker till din server, minispel, eller avancerat skydd
diff --git a/src/lang/Installer/th_TH.ini b/src/lang/Installer/th_TH.ini
deleted file mode 100644
index 6fb66a5e..00000000
--- a/src/lang/Installer/th_TH.ini
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
diff --git a/src/lang/Installer/tlh_AA.ini b/src/lang/Installer/tlh_AA.ini
deleted file mode 100644
index 6fb66a5e..00000000
--- a/src/lang/Installer/tlh_AA.ini
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
diff --git a/src/lang/Installer/tr_TR.ini b/src/lang/Installer/tr_TR.ini
deleted file mode 100644
index a1f659cb..00000000
--- a/src/lang/Installer/tr_TR.ini
+++ /dev/null
@@ -1,12 +0,0 @@
-language_has_been_selected=İngilizce seçildi.
-skip_installer=Kurulum yazılımını atlamak istiyormusunuz?
-
-accept_license=Lisansı kabul ediyormusunuz?
-you_have_to_accept_the_license=NostalgiaCore'yi kullanabilmeniz için LGPL lisansını kabul etmeniz gereklidir
-
-setting_up_server_now=Sunucunuz şimdi kurulacak, Devam edilsin mi?
-
-invalid_port=Yanlış sunucu port'u
-
-
-
diff --git a/src/lang/Installer/uk_UA.ini b/src/lang/Installer/uk_UA.ini
deleted file mode 100644
index 6fb66a5e..00000000
--- a/src/lang/Installer/uk_UA.ini
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
diff --git a/src/lang/Installer/vi_VN.ini b/src/lang/Installer/vi_VN.ini
deleted file mode 100644
index ea15a21d..00000000
--- a/src/lang/Installer/vi_VN.ini
+++ /dev/null
@@ -1,31 +0,0 @@
-language_has_been_selected=Tiếng Anh đã được chọn.
-skip_installer=Bạn có muốn bỏ qua hướng dẫn set-up?
-
-welcome_to_pocketmine=Chào mừng tới NostalgiaCore!\nTrước khi bắt đầu, bạn phải chấp nhận hợp đồng. \nNostalgiaCore được hợp đồng bởi LGPL License,\nbạn có thể đọc file LICENSE trong thư mục này.
-accept_license=Bạn có chấp nhận hợp đồng ?
-you_have_to_accept_the_license=Bạn phải chấp nhận LGPL license để sử dụng NostalgiaCore
-
-setting_up_server_now=Bạn sẽ bắt đầu set up server của bạn ngay.
-default_values_info=Nếu bạn không muốn đổi giá trị mặc định, nhấn Enter.
-server_properties=Bạn có thể chỉnh sửa lại vào file server.properties .
-
-name_your_server=Đặt tên server
-port_warning=Không được đổi giá trị port mặc định nếu đây là server đầu tiên của bạn.
-server_port=Server port
-invalid_port=Server port không đúng
-ram_warning=RAM là tất cả bộ nhớ mà NostalgiaCore sẽ sử dụng. 128/256 MB là cần thiết
-server_ram=Server RAM theo MB
-gamemode_info=Chọn Creative (1) hoặc Survival (0)
-default_gamemode=Chế độ mặc định
-max_players=Giới hạn lượng người chơi
-spawn_protection_info=Spawn protection không cho phép đặt/đập trong khu vực hồi sinh trừ OPs
-spawn_protection=Mở Spawn protection?
-
-op_info=OP là chủ/quản lí server. OPs có nhiều quyền hạn hơn người thường
-op_who=Tên OP (ví dụ, tên bạn)
-op_warning=Bạn có thể thêm OP bằng lệnh /op
-whitelist_info=White-list chỉ cho người có phép của quản lí tham gia.
-whitelist_enable=Bạn có muốn bật white-list?
-whitelist_warning=Bạn sẽ phải thêm người chơi vào white-list
-
-
diff --git a/src/lang/Installer/zh_CN.ini b/src/lang/Installer/zh_CN.ini
deleted file mode 100644
index 7a5d535a..00000000
--- a/src/lang/Installer/zh_CN.ini
+++ /dev/null
@@ -1,46 +0,0 @@
-language_has_been_selected=您现在选择了简体中文.
-skip_installer=您想跳过安装向导吗?
-
-welcome_to_pocketmine=欢迎来到NostalgiaCore!\n在开始使用您的新服务器之前您需要接受以下协议\nNostalgiaCore使用了LGPL协议,\n你可以在这个文件夹中找到LICENCE文件.
-accept_license=您接受协议内容吗?
-you_have_to_accept_the_license=您接受了LGPL协议来继续使用NostalgiaCore
-
-setting_up_server_now=你现在要开始设置您的服务器了
-default_values_info=如果您希望留住默认设置请直接按下回车键.
-server_properties=您以后可以在server.properties中修改设置.
-
-name_your_server=命名您的服务器:
-port_warning=尽量不要改变端口如果这是您第一次设置服务器.
-server_port=服务器端口:
-invalid_port=不正确的服务器端口.
-ram_warning=RAM是NostalgiaCore可用的最大内存. 推荐范围: 128-256 MB
-server_ram=分配给服务器的内存(MB):
-gamemode_info=选择模式: (1)生存模式 或 (2)创造模式
-default_gamemode=默认游戏模式
-max_players=最大在线人数
-spawn_protection_info=出生点保护可以在出生点范围内保护所有方块不被摆放/破坏.
-spawn_protection=启用出生点保护?
-
-op_info=OP是一个服务器的管理员, 可以执行比普通玩家更多的命令.
-op_who=OP的用户名是什么?
-op_warning=你可以执行\"/op <用户名>\"来添加OP.
-whitelist_info=白名单可以只允许在其列表内的玩家加入.
-whitelist_enable=您想启用白名单吗?
-whitelist_warning=你可以用"/whitelist add <用户名>"把别人加入白名单.
-
-query_warning1=请求是一个用于不同的程序的协议用来获取您服务器数据和登录的玩家.
-query_warning2=如果您禁止了它, 您将不能使用服务器列表.
-query_disable=您希望禁用Query请求吗?
-rcon_info=RCON是一个用来远程连接到服务器控制台的协议(需要密码).
-rcon_enable=您希望启用RCON吗?
-rcon_password=RCON密码 (您也以后更改它) :
-usage_info=匿名数据让我们可以获得全球的NostalgiaCore和它的插件的统计信息. 您可以在 stats.pocketmine.net 查看统计信息.
-
-usage_disable=您希望禁用匿名数据吗?
-ip_get=获得你的外部IP和内部IP
-ip_warning=您的外部IP是 {{EXTERNAL_IP}} . 您可能需要端口转发到您的内网IP {{INTERNAL_IP}} .
-ip_confirm=请确认您检查了它, 如果您直接进入下一步并跳过这一步, 没有外部的玩家可以加入. [按\"回车\"键]
-
-you_have_finished=您已经成功完成了服务器设置向导.
-pocketmine_will_start=NostalgiaCore现在开始运行. 输入 \"/help\" 来看所有可用的命令.
-pocketmine_plugins=请查看插件源来添加新的功能, 迷你游戏或者对服务器的高级保护.
diff --git a/src/lang/Installer/zu_ZA.ini b/src/lang/Installer/zu_ZA.ini
deleted file mode 100644
index a47ed8d9..00000000
--- a/src/lang/Installer/zu_ZA.ini
+++ /dev/null
@@ -1,45 +0,0 @@
-language_has_been_selected={crwdns106:0}{crwdne106:0}
-skip_installer={crwdns107:0}{crwdne107:0}
-
-welcome_to_pocketmine={crwdns108:0}{crwdne108:0}
-accept_license={crwdns109:0}{crwdne109:0}
-you_have_to_accept_the_license={crwdns110:0}{crwdne110:0}
-
-setting_up_server_now={crwdns111:0}{crwdne111:0}
-default_values_info={crwdns112:0}{crwdne112:0}
-server_properties={crwdns113:0}{crwdne113:0}
-
-name_your_server={crwdns114:0}{crwdne114:0}
-port_warning={crwdns115:0}{crwdne115:0}
-server_port={crwdns116:0}{crwdne116:0}
-invalid_port={crwdns117:0}{crwdne117:0}
-ram_warning={crwdns118:0}{crwdne118:0}
-server_ram={crwdns119:0}{crwdne119:0}
-gamemode_info={crwdns120:0}{crwdne120:0}
-default_gamemode={crwdns121:0}{crwdne121:0}
-max_players={crwdns122:0}{crwdne122:0}
-spawn_protection_info={crwdns123:0}{crwdne123:0}
-spawn_protection={crwdns124:0}{crwdne124:0}
-
-op_info={crwdns125:0}{crwdne125:0}
-op_who={crwdns126:0}{crwdne126:0}
-op_warning={crwdns127:0}{crwdne127:0}
-whitelist_info={crwdns128:0}{crwdne128:0}
-whitelist_enable={crwdns129:0}{crwdne129:0}
-whitelist_warning={crwdns130:0}{crwdne130:0}
-
-query_warning1={crwdns131:0}{crwdne131:0}
-query_warning2={crwdns132:0}{crwdne132:0}
-query_disable={crwdns133:0}{crwdne133:0}
-rcon_info={crwdns134:0}{crwdne134:0}
-rcon_enable={crwdns135:0}{crwdne135:0}
-rcon_password={crwdns136:0}{crwdne136:0}
-usage_info={crwdns137:0}{crwdne137:0}
-usage_disable={crwdns138:0}{crwdne138:0}
-ip_get={crwdns139:0}{crwdne139:0}
-ip_warning={crwdns140:0}{{EXTERNAL_IP}}{crwdnd140:0}{{INTERNAL_IP}}{crwdne140:0}
-ip_confirm={crwdns141:0}{crwdne141:0}
-
-you_have_finished={crwdns142:0}{crwdne142:0}
-pocketmine_will_start={crwdns143:0}{crwdne143:0}
-pocketmine_plugins={crwdns144:0}{crwdne144:0}
diff --git a/src/material/Block.php b/src/material/Block.php
deleted file mode 100755
index 4ea821be..00000000
--- a/src/material/Block.php
+++ /dev/null
@@ -1,264 +0,0 @@
- "AirBlock",
- STONE => "StoneBlock",
- GRASS => "GrassBlock",
- DIRT => "DirtBlock",
- COBBLESTONE => "CobblestoneBlock",
- PLANKS => "PlanksBlock",
- SAPLING => "SaplingBlock",
- BEDROCK => "BedrockBlock",
- WATER => "WaterBlock",
- STILL_WATER => "StillWaterBlock",
- LAVA => "LavaBlock",
- STILL_LAVA => "StillLavaBlock",
- SAND => "SandBlock",
- GRAVEL => "GravelBlock",
- GOLD_ORE => "GoldOreBlock",
- IRON_ORE => "IronOreBlock",
- COAL_ORE => "CoalOreBlock",
- WOOD => "WoodBlock",
- LEAVES => "LeavesBlock",
- SPONGE => "SpongeBlock",
- GLASS => "GlassBlock",
- LAPIS_ORE => "LapisOreBlock",
- LAPIS_BLOCK => "LapisBlock",
- SANDSTONE => "SandstoneBlock",
- BED_BLOCK => "BedBlock",
- POWERED_RAIL => "PoweredRailBlock",
- COBWEB => "CobwebBlock",
- TALL_GRASS => "TallGrassBlock",
- DEAD_BUSH => "DeadBushBlock",
- WOOL => "WoolBlock",
- DANDELION => "DandelionBlock",
- CYAN_FLOWER => "CyanFlowerBlock",
- BROWN_MUSHROOM => "BrownMushroomBlock",
- RED_MUSHROOM => "RedMushRoomBlock",
- GOLD_BLOCK => "GoldBlock",
- IRON_BLOCK => "IronBlock",
- DOUBLE_SLAB => "DoubleSlabBlock",
- SLAB => "SlabBlock",
- BRICKS_BLOCK => "BricksBlock",
- TNT => "TNTBlock",
- BOOKSHELF => "BookshelfBlock",
- MOSS_STONE => "MossStoneBlock",
- OBSIDIAN => "ObsidianBlock",
- TORCH => "TorchBlock",
- FIRE => "FireBlock",
-
- WOOD_STAIRS => "WoodStairsBlock",
- CHEST => "ChestBlock",
-
- DIAMOND_ORE => "DiamondOreBlock",
- DIAMOND_BLOCK => "DiamondBlock",
- WORKBENCH => "WorkbenchBlock",
- WHEAT_BLOCK => "WheatBlock",
- FARMLAND => "FarmlandBlock",
- FURNACE => "FurnaceBlock",
- BURNING_FURNACE => "BurningFurnaceBlock",
- SIGN_POST => "SignPostBlock",
- WOOD_DOOR_BLOCK => "WoodDoorBlock",
- LADDER => "LadderBlock",
- RAIL => "RailBlock",
- COBBLESTONE_STAIRS => "CobblestoneStairsBlock",
- WALL_SIGN => "WallSignBlock",
-
- IRON_DOOR_BLOCK => "IronDoorBlock",
- REDSTONE_ORE => "RedstoneOreBlock",
- GLOWING_REDSTONE_ORE => "GlowingRedstoneOreBlock",
-
- SNOW_LAYER => "SnowLayerBlock",
- ICE => "IceBlock",
- SNOW_BLOCK => "SnowBlock",
- CACTUS => "CactusBlock",
- CLAY_BLOCK => "ClayBlock",
- SUGARCANE_BLOCK => "SugarcaneBlock",
-
- FENCE => "FenceBlock",
- PUMPKIN => "PumpkinBlock",
- NETHERRACK => "NetherrackBlock",
- SOUL_SAND => "SoulSandBlock",
- GLOWSTONE_BLOCK => "GlowstoneBlock",
-
- LIT_PUMPKIN => "LitPumpkinBlock",
- INVISIBLE_BEDROCK => "InvisibleBedrockBlock",
-
- CAKE_BLOCK => "CakeBlock",
-
- TRAPDOOR => "TrapdoorBlock",
-
- STONE_BRICKS => "StoneBricksBlock",
-
- IRON_BARS => "IronBarsBlock",
- GLASS_PANE => "GlassPaneBlock",
- MELON_BLOCK => "MelonBlock",
- PUMPKIN_STEM => "PumpkinStemBlock",
- MELON_STEM => "MelonStemBlock",
-
- FENCE_GATE => "FenceGateBlock",
- BRICK_STAIRS => "BrickStairsBlock",
- STONE_BRICK_STAIRS => "StoneBrickStairsBlock",
-
- NETHER_BRICKS => "NetherBricksBlock",
-
- NETHER_BRICKS_STAIRS => "NetherBricksStairsBlock",
-
- SANDSTONE_STAIRS => "SandstoneStairsBlock",
-
- SPRUCE_WOOD_STAIRS => "SpruceWoodStairsBlock",
- BIRCH_WOOD_STAIRS => "BirchWoodStairsBlock",
- JUNGLE_WOOD_STAIRS => "JungleWoodStairsBlock",
- STONE_WALL => "StoneWallBlock",
-
- CARROT_BLOCK => "CarrotBlock",
- POTATO_BLOCK => "PotatoBlock",
-
- QUARTZ_BLOCK => "QuartzBlock",
- QUARTZ_STAIRS => "QuartzStairsBlock",
- DOUBLE_WOOD_SLAB => "DoubleWoodSlabBlock",
- WOOD_SLAB => "WoodSlabBlock",
-
- HAY_BALE => "HayBaleBlock",
- CARPET => "CarpetBlock",
-
- COAL_BLOCK => "CoalBlock",
-
- BEETROOT_BLOCK => "BeetrootBlock",
- STONECUTTER => "StonecutterBlock",
- GLOWING_OBSIDIAN => "GlowingObsidianBlock",
- NETHER_REACTOR => "NetherReactorBlock",
- INFO_UPDATE => "InfoUpdateBlock",
- INFO_UPDATE2 => "InfoUpdate2Block",
- RESERVED6 => "Reserved6Block",
-
- ACACIA_WOOD_STAIRS => "AcaciaWoodStairsBlock",
- DARK_OAK_WOOD_STAIRS => "DarkOakWoodStairsBlock",
- EMERALD_ORE => "EmeraldOreBlock",
- EMERALD_BLOCK => "EmeraldBlock",
- END_STONE => "EndStoneBlock",
- HARDENED_CLAY => "HardenedClayBlock",
- LOG2 => "Log2Block",
- LEAVES2 => "Leaves2Block",
- END_PORTAL_FRAME => "EndPortalFrameBlock",
- COCOA => "CocoaBlock",
- RED_MUSHROOM_BLOCK => "RedMushroomSolidBlock",
- BROWN_MUSHROOM_BLOCK => "BrownMushroomSolidBlock",
- MONSTER_SPAWNER => "MonsterSpawnerBlock",
- VINES => "VinesBlock",
- MYCELIUM => "MyceliumBlock",
- PODZOL => "PodzolBlock",
- STAINED_CLAY => "StainedClayBlock",
- LILY_PAD => "LilypadBlock",
- DOUBLE_PLANT => "DoubleTallGrass",
- );
- protected $id;
- protected $meta;
- protected $name;
- protected $breakTime;
- public $boundingBox;
- protected $hardness;
- public $isActivable = false;
- public $breakable = true;
- public $isFlowable = false;
- public $isSolid = true;
- public $isTransparent = false;
- public $isReplaceable = false;
- public $isPlaceable = true;
- public $level = false;
- public $hasPhysics = false;
- public $isLiquid = false;
- public $isFullBlock = true;
- public $x = 0;
- public $y = 0;
- public $z = 0;
- public $slipperiness;
-
- public function __construct($id, $meta = 0, $name = "Unknown"){
- $this->id = (int) $id;
- $this->meta = (int) $meta;
- $this->name = $name;
- $this->breakTime = 0.20;
- $this->hardness = 10;
- $this->slipperiness = 0.6;
- $this->boundingBox = new AxisAlignedBB($this->x, $this->y, $this->z, $this->x + 1, $this->y + 1, $this->z + 1);
- }
-
- final public function getHardness(){
- return ($this->hardness);
- }
-
- final public function getName(){
- return $this->name;
- }
-
- final public function getID(){
- return $this->id;
- }
-
- public function setMetadata($i){
- $this->meta = $i;
- }
-
- final public function getMetadata(){
- return $this->meta & 0x0F;
- }
-
- final public function position(Position $v){
- $this->level = $v->level;
- $this->x = (int) $v->x;
- $this->y = (int) $v->y;
- $this->z = (int) $v->z;
- $this->boundingBox->setBounds($this->x, $this->y, $this->z, $this->x + 1, $this->y + 1, $this->z + 1);
- }
-
- public function getDrops(Item $item, Player $player){
- if(!isset(Block::$class[$this->id])){ //Unknown blocks
- return array();
- }else{
- return array(
- array($this->id, $this->meta, 1),
- );
- }
- }
-
- public function getBreakTime(Item $item, Player $player){
- if(($player->gamemode & 0x01) === 0x01){
- return 0.15;
- }
- return $this->breakTime;
- }
-
- public function getSide($side, $step = 1){
- $v = parent::getSide($side, $step);
- if($this->level instanceof Level){
- return $this->level->getBlock($v);
- }
- return $v;
- }
-
- final public function __toString(){
- return "Block ". $this->name ." (".$this->id.":".$this->meta.")";
- }
-
- abstract function isBreakable(Item $item, Player $player);
-
- abstract function onBreak(Item $item, Player $player);
-
- abstract function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz);
-
- abstract function onActivate(Item $item, Player $player);
-
- abstract function onUpdate($type);
-}
-
-/***REM_START***/
-require_once("block/GenericBlock.php");
-require_once("block/SolidBlock.php");
-require_once("block/TransparentBlock.php");
-require_once("block/FallableBlock.php");
-require_once("block/LiquidBlock.php");
-require_once("block/StairBlock.php");
-require_once("block/DoorBlock.php");
-/***REM_END***/
diff --git a/src/material/Item.php b/src/material/Item.php
deleted file mode 100755
index e5cc0a1a..00000000
--- a/src/material/Item.php
+++ /dev/null
@@ -1,315 +0,0 @@
- "LeatherCapItem",
- LEATHER_TUNIC => "LeatherTunicItem",
- LEATHER_PANTS => "LeatherPantsItem",
- LEATHER_BOOTS => "LeatherBootsItem",
- CHAIN_HELMET => "ChainHelmetItem",
- CHAIN_CHESTPLATE => "ChainChestplateItem",
- CHAIN_LEGGINGS => "ChainLeggingsItem",
- CHAIN_BOOTS => "ChainBootsItem",
- IRON_HELMET => "IronHelmetItem",
- IRON_CHESTPLATE => "IronChestplateItem",
- IRON_LEGGINGS => "IronLeggingsItem",
- IRON_BOOTS => "IronBootsItem",
- DIAMOND_HELMET => "DiamondHelmetItem",
- DIAMOND_CHESTPLATE => "DiamondChestplateItem",
- DIAMOND_LEGGINGS => "DiamondLeggingsItem",
- DIAMOND_BOOTS => "DiamondBootsItem",
- GOLDEN_HELMET => "GoldenHelmetItem",
- GOLDEN_CHESTPLATE => "GoldenChestplateItem",
- GOLDEN_LEGGINGS => "GoldenLeggingsItem",
- GOLDEN_BOOTS => "GoldenBootsItem",
-
- //food
- APPLE => "AppleItem",
- MUSHROOM_STEW => "MushroomStewItem",
- BREAD => "BreadItem",
- RAW_PORKCHOP => "RawPorkchopItem",
- COOKED_PORKCHOP => "CookedPorkchopItem",
- CAKE => "CakeItem",
- MELON => "MelonItem",
- BEEF => "BeefItem",
- STEAK => "SteakItem",
- RAW_CHICKEN => "RawChickenItem",
- COOKED_CHICKEN => "CookedChickenItem",
- CARROT => "CarrotItem",
- POTATO => "PotatoItem",
- BAKED_POTATO => "BakedPotatoItem",
- PUMPKIN_PIE => "PumpkinPieItem",
- BEETROOT => "BeetrootItem",
- BEETROOT_SOUP => "BeetrootSoupItem",
-
- //generic
- ARROW => "ArrowItem",
- COAL => "CoalItem",
- DIAMOND => "DiamondItem",
- IRON_INGOT => "IronIngotItem",
- GOLD_INGOT => "GoldIngotItem",
- STICK => "StickItem",
- BOWL => "BowlItem",
- 'STRING' => "StringItem",
- FEATHER => "FeatherItem",
- GUNPOWDER => "GunpowderItem",
- WHEAT_SEEDS => "WheatSeedsItem",
- WHEAT => "WheatItem",
- FLINT => "FlintItem",
- PAINTING => "PaintingItem",
- SIGN => "SignItem",
- WOODEN_DOOR => "WoodenDoorItem",
- BUCKET => "BucketItem",
- MINECART => "MinecartItem",
- SADDLE => "SaddleItem",
- IRON_DOOR => "IronDoorItem",
- REDSTONE => "RedstoneItem",
- SNOWBALL => "SnowballItem",
- LEATHER => "LeatherItem",
- BRICK => "BrickItem",
- CLAY => "ClayItem",
- SUGARCANE => "SugarCaneItem",
- PAPER => "PaperItem",
- BOOK => "BookItem",
- SLIMEBALL => "SlimeballItem",
- EGG => "EggItem",
- GLOWSTONE_DUST => "GlowstoneDustItem",
- DYE => "DyeItem",
- BONE => "BoneItem",
- SUGAR => "SugarItem",
- BED => "BedItem",
- PUMPKIN_SEEDS => "PumpkinSeedsItem",
- MELON_SEEDS => "MelonSeedsItem",
- SPAWN_EGG => "SpawnEggItem",
- NETHER_BRICK => "NetherBrickItem",
- QUARTZ => "QuartzItem",
- CAMERA => "CameraItem",
- BEETROOT_SEEDS => "BeetrootSeedsItem",
- EMERALD => "EmeraldItem",
-
- //tool
- IRON_SHOVEL => "IronShovelItem",
- IRON_PICKAXE => "IronPickaxeItem",
- IRON_AXE => "IronAxeItem",
- FLINT_STEEL => "FlintSteelItem",
- BOW => "BowItem",
- IRON_SWORD => "IronSwordItem",
- WOODEN_SWORD => "WoodenSwordItem",
- WOODEN_SHOVEL => "WoodenShovelItem",
- WOODEN_PICKAXE => "WoodenPickaxeItem",
- WOODEN_AXE => "WoodenAxeItem",
- STONE_SWORD => "StoneSwordItem",
- STONE_SHOVEL => "StoneShovelItem",
- STONE_PICKAXE => "StonePickaxeItem",
- STONE_AXE => "StoneAxeItem",
- DIAMOND_SWORD => "DiamondSwordItem",
- DIAMOND_SHOVEL => "DiamondShovelItem",
- DIAMOND_PICKAXE => "DiamondPickaxeItem",
- DIAMOND_AXE => "DiamondAxeItem",
- GOLDEN_SWORD => "GoldenSwordItem",
- GOLDEN_SHOVEL => "GoldenShovelItem",
- GOLDEN_PICKAXE => "GoldenPickaxeItem",
- GOLDEN_AXE => "GoldenAxeItem",
- WOODEN_HOE => "WoodenHoeItem",
- STONE_HOE => "StoneHoeItem",
- IRON_HOE => "IronHoeItem",
- DIAMOND_HOE => "DiamondHoeItem",
- GOLDEN_HOE => "GoldenHoeItem",
- COMPASS => "CompassItem",
- CLOCK => "ClockItem",
- SHEARS => "ShearsItem",
-
- );
- protected $block;
- protected $id;
- protected $meta;
- public $count;
- protected $maxStackSize = 64;
- protected $durability = 0;
- protected $name;
- public $isActivable = false;
-
- public function __construct($id, $meta = 0, $count = 1, $name = "Unknown"){
- $this->id = (int) $id;
- $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])){
- $this->block = BlockAPI::get($this->id, $this->meta);
- $this->name = $this->block->getName();
- }
- if($this->isTool() || $this->isArmor() || $this->getID() === SADDLE){
- $this->maxStackSize = 1;
- }
- }
-
- public function isPickaxe(){
- return false;
- }
-
- public function getName(){
- return $this->name;
- }
-
- public function isPlaceable(){
- return (($this->block instanceof Block) and $this->block->isPlaceable === true);
- }
-
- public function getBlock(){
- if($this->block instanceof Block){
- return $this->block;
- }else{
- return BlockAPI::get(AIR);
- }
- }
-
- public function getID(){
- return $this->id;
- }
-
- public function getMetadata(){
- return $this->meta;
- }
-
- public function isArmor(){
- return false;
- }
-
- public function getMaxStackSize(){
- return $this->maxStackSize;
- }
-
- public function getFuelTime(){
- if(!isset(FuelData::$duration[$this->id])){
- return false;
- }
- if($this->id !== BUCKET or $this->meta === 10){
- return FuelData::$duration[$this->id];
- }
- return false;
- }
-
- public function getSmeltItem(){
- if(!isset(SmeltingData::$product[$this->id])){
- return false;
- }
-
- if(isset(SmeltingData::$product[$this->id][0]) and !is_array(SmeltingData::$product[$this->id][0])){
- return BlockAPI::getItem(SmeltingData::$product[$this->id][0], SmeltingData::$product[$this->id][1]);
- }
-
- if(!isset(SmeltingData::$product[$this->id][$this->meta])){
- return false;
- }
-
- return BlockAPI::getItem(SmeltingData::$product[$this->id][$this->meta][0], SmeltingData::$product[$this->id][$this->meta][1]);
-
- }
-
- public function useOn($object, $force = false){
- if($force){
- if(($object instanceof Entity) and !$this->isSword()){
- $this->meta += 2;
- }else{
- $this->meta++;
- }
- return true;
- }
- return false;
- }
-
- public function isTool(){
- return false;
- }
-
- public function getMaxDurability(){
- if(!$this->isTool() and $this->id !== BOW){
- return false;
- }
-
- $levels = [
- 2 => 40, //GOLD
- 1 => 59, //WOODEN
- 3 => 131, //STONE
- 4 => 250, //IRON
- 5 => 1561, //DIAMOND(called EMERALD in disassembled code)
- FLINT_STEEL => 65, //lets assume it is correct
- SHEARS => 239, //x2
- BOW => 2 //x3
- ];
-
- if(($type = $this->getLevel()) === false){
- $type = $this->id;
- }
- return $levels[$type];
- }
-
- public function getLevel(){
- return false;
- }
-
- //TODO remove?
- public function getPickaxeLevel(){ //Returns false or level of the pickaxe
- switch($this->id){
- case WOODEN_PICKAXE:
- return 1;
- case GOLDEN_PICKAXE:
- return 2;
- case STONE_PICKAXE:
- return 3;
- case IRON_PICKAXE:
- return 4;
- case DIAMOND_PICKAXE:
- return 5;
- default:
- return false;
- }
- }
-
- public function isAxe(){
- return false;
- }
-
- public function isSword(){
- return false;
- }
-
- public function isShovel(){
- return false;
- }
-
- public function isHoe(){
- return false;
- }
-
- public function isShears(){
- return ($this->id === SHEARS);
- }
-
- public function __toString(){
- return "Item ". $this->name ." (".$this->id.":".$this->meta.")";
- }
-
- public function getDamageAgainstOf($e){
- return Item::DEF_DAMAGE;
- }
-
- public function getDestroySpeed(Block $block, Player $player){
- return 1;
- }
-
- public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
- return false;
- }
-
-}
diff --git a/src/material/Material.php b/src/material/Material.php
deleted file mode 100644
index 674ce90b..00000000
--- a/src/material/Material.php
+++ /dev/null
@@ -1,9 +0,0 @@
-getID()] = $b->isSolid;
- self::$isTransparent[$b->getID()] = $b->isTransparent;
- self::$isFlowable[$b->getID()] = $b->isFlowable;
- self::$isReplaceable[$b->getID()] = $b->isReplaceable;
- self::$isPlaceable[$b->getID()] = $b->isPlaceable;
- self::$hasPhysics[$b->getID()] = $b->hasPhysics;
- self::$isLiquid[$b->getID()] = $b->isLiquid;
- self::$isFullBlock[$b->getID()] = $b->isFullBlock;
- self::$slipperiness[$b->getID()] = $b->slipperiness;
- self::$boundingBoxes[$b->getID()] = $b->boundingBox;
- self::$hardness[$b->getID()] = $b->getHardness();
- }
- }
-
- public static function getBlock($id){
- return Block::$class[$id] ?? Block::$class[0];
- }
-
- public static function getHardness($id){
- return self::$hardness[$id] ?? StaticBlock::DEFAULT_HARDNESS;
- }
-
- public static function getBoundingBoxForBlockCoords($id, $x, $y, $z){
- /**@var AxisAlignedBB $bb*/
- $bb = self::$boundingBoxes[$id] ?? false;
- if($bb === false){
- return clone self::$NULL_BOUNDS;
- }
- $bb = clone $bb;
- return $bb->setBounds($x + $bb->minX, $y + $bb->minY, $z + $bb->minZ, $x + $bb->maxX, $y + $bb->maxY, $z + $bb->maxZ);
- }
-
-
- public static function getSlipperiness($id){
- return self::$slipperiness[$id] ?? StaticBlock::DEFAULT_SLIPPERINESS;
- }
-
- public static function getIsSolid($id){
- return self::$isSolid[$id] ?? false;
- }
-
- public static function getIsTransparent($id){
- return self::$isTransparent[$id] ?? false;
- }
-
- public static function getIsFlowable($id){
- return self::$isFlowable[$id] ?? false;
- }
-
- public static function getIsReplaceable($id){
- return self::$isReplaceable[$id] ?? false;
- }
-
- public static function getIsPlaceable($id){
- return self::$isPlaceable[$id] ?? false;
- }
-
- public static function getHasPhysics($id){
- return self::$hasPhysics[$id] ?? false;
- }
-
- public static function getIsLiquid($id){
- return self::$isLiquid[$id] ?? false;
- }
-
- public static function getIsFullBlock($id){
- return self::$isFullBlock[$id] ?? false;
- }
-}
diff --git a/src/material/block/DoorBlock.php b/src/material/block/DoorBlock.php
deleted file mode 100644
index 1218b3b3..00000000
--- a/src/material/block/DoorBlock.php
+++ /dev/null
@@ -1,137 +0,0 @@
-isSolid = false;
- }
-
- /**
- * @param int $type
- *
- * @return bool|int
- */
- public function onUpdate($type){
- if($type === BLOCK_UPDATE_NORMAL){
- if($this->getSide(0)->getID() === AIR){ //Replace with common break method
- $this->level->setBlock($this, new AirBlock(), false);
- if($this->getID() == 64) ServerAPI::request()->api->entity->drop(new Position($this->x+0.5, $this->y, $this->z+0.5, $this->level), BlockAPI::getItem(324, 0, 1));
- elseif($this->getID() == 71) ServerAPI::request()->api->entity->drop(new Position($this->x+0.5, $this->y, $this->z+0.5, $this->level), BlockAPI::getItem(330, 0, 1));
- if($this->getSide(1) instanceof DoorBlock){
- $this->level->setBlock($this->getSide(1), new AirBlock(), false);
- }
- return BLOCK_UPDATE_NORMAL;
- }
- }
- return false;
- }
-
-
- /**
- * @param Item $item
- * @param Player $player
- * @param Block $block
- * @param Block $target
- * @param integer $face
- * @param integer $fx
- * @param integer $fy
- * @param integer $fz
- *
- * @return boolean
- */
- public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
- if($face === 1){
- $blockUp = $this->getSide(1);
- $blockDown = $this->getSide(0);
- if($blockUp->isReplaceable === false or $blockDown->isTransparent === true){
- return false;
- }
- $direction = $player->entity->getDirection();
- $face = array(
- 0 => 3,
- 1 => 4,
- 2 => 2,
- 3 => 5,
- );
- $next = $this->getSide($face[(($direction + 2) % 4)]);
- $next2 = $this->getSide($face[$direction]);
- $metaUp = 0x08;
- if($next->getID() === $this->id or ($next2->isTransparent === false and $next->isTransparent === true)){ //Door hinge
- $metaUp |= 0x01;
- }
- $this->level->setBlock($blockUp, BlockAPI::get($this->id, $metaUp), true, false, true); //Top
-
- $this->meta = $direction & 0x03;
- $this->level->setBlock($block, $this, true, false, true); //Bottom
- return true;
- }
- return false;
- }
-
- /**
- * @param Item $item
- * @param Player $player
- *
- * @return boolean
- */
- public function onBreak(Item $item, Player $player){
- if(($this->meta & 0x08) === 0x08){
- $down = $this->getSide(0);
- if($down->getID() === $this->id){
- $this->level->setBlock($down, new AirBlock(), true, false, true);
- }
- }else{
- $up = $this->getSide(1);
- if($up->getID() === $this->id){
- $this->level->setBlock($up, new AirBlock(), true, false, true);
- }
- }
- $this->level->setBlock($this, new AirBlock(), true, false, true);
- return true;
- }
-
- /**
- * @param Item $item
- * @param Player $player
- *
- * @return boolean
- */
- public function onActivate(Item $item, Player $player){
- if(($this->meta & 0x08) === 0x08){ //Top
- $down = $this->getSide(0);
- if($down->getID() === $this->id){
- $meta = $down->getMetadata() ^ 0x04;
- $this->level->setBlock($down, BlockAPI::get($this->id, $meta), true, false, true);
- $players = ServerAPI::request()->api->player->getAll($this->level);
- unset($players[$player->CID]);
- $pk = new LevelEventPacket;
- $pk->x = $this->x;
- $pk->y = $this->y;
- $pk->z = $this->z;
- $pk->evid = 1003;
- $pk->data = 0;
- ServerAPI::request()->api->player->broadcastPacket($players, $pk);
- return true;
- }
- return false;
- }else{
- $this->meta ^= 0x04;
- $this->level->setBlock($this, $this, true, false, true);
- $players = ServerAPI::request()->api->player->getAll($this->level);
- unset($players[$player->CID]);
- $pk = new LevelEventPacket;
- $pk->x = $this->x;
- $pk->y = $this->y;
- $pk->z = $this->z;
- $pk->evid = 1003;
- $pk->data = 0;
- ServerAPI::request()->api->player->broadcastPacket($players, $pk);
- }
- return true;
- }
-}
\ No newline at end of file
diff --git a/src/material/block/FallableBlock.php b/src/material/block/FallableBlock.php
deleted file mode 100644
index 856050fa..00000000
--- a/src/material/block/FallableBlock.php
+++ /dev/null
@@ -1,31 +0,0 @@
-hasPhysics = true;
- }
-
- /**
- * @param Item $item
- * @param Player $player
- * @param Block $block
- * @param Block $target
- * @param int $face
- * @param int $fx
- * @param int $fy
- * @param int $fz
- *
- * @return mixed
- */
- public function place(Item $item, 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);
- return $ret;
- }
-}
\ No newline at end of file
diff --git a/src/material/block/FlowableBlock.php b/src/material/block/FlowableBlock.php
deleted file mode 100644
index 3c7aba58..00000000
--- a/src/material/block/FlowableBlock.php
+++ /dev/null
@@ -1,15 +0,0 @@
-isFlowable = true;
- $this->isFullBlock = false;
- $this->isSolid = false;
- }
-}
\ No newline at end of file
diff --git a/src/material/block/GenericBlock.php b/src/material/block/GenericBlock.php
deleted file mode 100644
index ba5ffaa2..00000000
--- a/src/material/block/GenericBlock.php
+++ /dev/null
@@ -1,86 +0,0 @@
-level->setBlock($this, $this, true, false, true);
- }
-
- /**
- * @param Item $item
- * @param Player $player
- *
- * @return boolean
- */
- public function isBreakable(Item $item, Player $player){
- return ($this->breakable);
- }
-
- /**
- * @param Item $item
- * @param Player $player
- *
- * @return mixed
- */
- public function onBreak(Item $item, Player $player){
- return $this->level->setBlock($this, new AirBlock(), true, false, true);
- }
-
- /**
- * @param integer $type
- *
- * @return boolean
- */
- public function onUpdate($type){
- if($this->hasPhysics === true and $type === BLOCK_UPDATE_NORMAL){
- $down = $this->getSide(0);
- if($down->getID() === AIR or ($down instanceof LiquidBlock)){
- $data = array(
- "x" => $this->x + 0.5,
- "y" => $this->y + 0.5,
- "z" => $this->z + 0.5,
- "Tile" => $this->id,
- "Metadata" => $this->getMetadata()
- );
- $server = ServerAPI::request();
- $this->level->setBlock($this, new AirBlock(), false, false, true);
- $e = $server->api->entity->add($this->level, ENTITY_FALLING, FALLING_SAND, $data);
- $server->api->entity->spawnToAll($e);
- $server->api->block->blockUpdateAround(clone $this, BLOCK_UPDATE_NORMAL, 1);
- }
- return false;
- }
- return false;
- }
-
- /**
- * @param Item $item
- * @param Player $player
- *
- * @return boolean
- */
- public function onActivate(Item $item, Player $player){
- return $this->isActivable;
- }
-}
\ No newline at end of file
diff --git a/src/material/block/LightingBlock.php b/src/material/block/LightingBlock.php
deleted file mode 100644
index 694574ab..00000000
--- a/src/material/block/LightingBlock.php
+++ /dev/null
@@ -1,9 +0,0 @@
-isLiquid = true;
- $this->breakable = false;
- $this->isReplaceable = true;
- $this->isSolid = false;
- $this->isFullBlock = true;
- }
-}
\ No newline at end of file
diff --git a/src/material/block/SolidBlock.php b/src/material/block/SolidBlock.php
deleted file mode 100644
index 72c45d2a..00000000
--- a/src/material/block/SolidBlock.php
+++ /dev/null
@@ -1,14 +0,0 @@
-isSolid = true;
- $this->isFullBlock = true;
- }
-}
\ No newline at end of file
diff --git a/src/material/block/StairBlock.php b/src/material/block/StairBlock.php
deleted file mode 100644
index 327a90ba..00000000
--- a/src/material/block/StairBlock.php
+++ /dev/null
@@ -1,61 +0,0 @@
-meta & 0x04) === 0x04){
- $this->isFullBlock = true;
- }else{
- $this->isFullBlock = false;
- }
- $this->hardness = 30;
- }
-
- /**
- * @param Item $item
- * @param Player $player
- * @param Block $block
- * @param Block $target
- * @param int $face
- * @param int $fx
- * @param int $fy
- * @param int $fz
- *
- * @return bool|mixed
- */
- public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
- $faces = array(
- 0 => 0,
- 1 => 2,
- 2 => 1,
- 3 => 3,
- );
- $this->meta = $faces[$player->entity->getDirection()] & 0x03;
- if(($fy > 0.5 and $face !== 1) or $face === 0){
- $this->meta |= 0x04; //Upside-down stairs
- }
- $this->level->setBlock($block, $this, true, false, true);
- return true;
- }
-
- /**
- * @param Item $item
- * @param Player $player
- *
- * @return array
- */
- public function getDrops(Item $item, Player $player){
- if($item->getPickaxeLevel() >= 1){
- return array(
- array($this->id, 0, 1),
- );
- }else{
- return array();
- }
- }
-}
\ No newline at end of file
diff --git a/src/material/block/TransparentBlock.php b/src/material/block/TransparentBlock.php
deleted file mode 100644
index 07181e2b..00000000
--- a/src/material/block/TransparentBlock.php
+++ /dev/null
@@ -1,20 +0,0 @@
-isActivable = false;
- $this->breakable = true;
- $this->isFlowable = false;
- $this->isTransparent = true;
- $this->isReplaceable = false;
- $this->isPlaceable = true;
- $this->isSolid = true;
- $this->boundingBox->setBounds($this->x, $this->y, $this->z, $this->x + 1, $this->y + 1.2, $this->z + 1);
- }
-}
\ No newline at end of file
diff --git a/src/material/block/attachable/LadderBlock.php b/src/material/block/attachable/LadderBlock.php
deleted file mode 100644
index a4386336..00000000
--- a/src/material/block/attachable/LadderBlock.php
+++ /dev/null
@@ -1,46 +0,0 @@
-isSolid = false;
- $this->isFullBlock = false;
- $this->hardness = 2;
- }
-
- public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
- if($face === 0 || $face === 1){
- return false; //fix of placing invalid ids without array
- }
- if($target->isTransparent === false){
- $this->meta = $face;
- $this->level->setBlock($block, $this, true, false, true);
- return true;
- }
- return false;
- }
-
- public function onUpdate($type){
- if($type === BLOCK_UPDATE_NORMAL){
- $side = $this->getMetadata();
- $faces = array( //magical tranformation
- 3 => 2,
- 2 => 3,
- 5 => 4,
- 4 => 5,
- );
- if($this->getSide($faces[$side]) instanceof AirBlock){ //Replace with common break method
- ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem($this->id, 0, 1));
- $this->level->setBlock($this, new AirBlock(), true, false, true);
- return BLOCK_UPDATE_NORMAL;
- }
- }
- return false;
- }
-
- public function getDrops(Item $item, Player $player){
- return array(
- array($this->id, 0, 1),
- );
- }
-}
diff --git a/src/material/block/attachable/SignPostBlock.php b/src/material/block/attachable/SignPostBlock.php
deleted file mode 100644
index 3dc7b5d6..00000000
--- a/src/material/block/attachable/SignPostBlock.php
+++ /dev/null
@@ -1,55 +0,0 @@
- 2,
- 3 => 3,
- 4 => 4,
- 5 => 5,
- );
-
- public function __construct($meta = 0){
- parent::__construct(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){
- if($target->isSolid && $face !== 0){
- if(!isset($this->faces[$face])){
- $this->meta = floor((($player->entity->yaw + 180) * 16 / 360) + 0.5) & 0x0F;
- $this->level->setBlock($block, BlockAPI::get(SIGN_POST, $this->meta), true, false, true);
- return true;
- }else{
- $this->meta = $this->faces[$face];
- $this->level->setBlock($block, BlockAPI::get(WALL_SIGN, $this->meta, true, false, true));
- return true;
- }
- }
- return false;
- }
-
- public function onUpdate($type){
- if($type === BLOCK_UPDATE_NORMAL){
- if($this->getSide(0)->getID() === AIR){ //Replace with common break method
- ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem(SIGN, 0, 1));
- $this->level->setBlock($this, new AirBlock(), true, true, true);
- return BLOCK_UPDATE_NORMAL;
- }
- }
- return false;
- }
-
- public function onBreak(Item $item, Player $player){
- $this->level->setBlock($this, new AirBlock(), true, true, true);
- return true;
- }
-
- public function getDrops(Item $item, Player $player){
- return array(
- array(SIGN, 0, 1),
- );
- }
-}
\ No newline at end of file
diff --git a/src/material/block/attachable/TorchBlock.php b/src/material/block/attachable/TorchBlock.php
deleted file mode 100644
index 7bae649b..00000000
--- a/src/material/block/attachable/TorchBlock.php
+++ /dev/null
@@ -1,57 +0,0 @@
-hardness = 0;
- }
- public function getMaxLightValue(){
- return 15;
- }
- public function onUpdate($type){
- if($type === BLOCK_UPDATE_NORMAL){
- $side = $this->getMetadata();
- $faces = array(
- 1 => 4,
- 2 => 5,
- 3 => 2,
- 4 => 3,
- 5 => 0,
- 6 => 0,
- 0 => 0,
- );
-
- if($this->getSide($faces[$side])->isTransparent === true and !($side === 0 and $this->getSide(0)->getID() === FENCE)){ //Replace with common break method
- ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem($this->id, 0, 1));
- $this->level->setBlock($this, new AirBlock(), true, false, true);
- return BLOCK_UPDATE_NORMAL;
- }
- }
- return false;
- }
-
- public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
- if($target->isTransparent === false and $face !== 0){
- $faces = array(
- 1 => 5,
- 2 => 4,
- 3 => 3,
- 4 => 2,
- 5 => 1,
- );
- $this->meta = $faces[$face];
- $this->level->setBlock($block, $this, true, false, true);
- return true;
- }elseif($this->getSide(0)->isTransparent === false or $this->getSide(0)->getID() === FENCE or $this->getSide(0)->getID() === STONE_WALL){
- $this->meta = 0;
- $this->level->setBlock($block, $this, true, false, true);
- return true;
- }
- return false;
- }
- public function getDrops(Item $item, Player $player){
- return array(
- array($this->id, 0, 1),
- );
- }
-}
\ No newline at end of file
diff --git a/src/material/block/attachable/TrapdoorBlock.php b/src/material/block/attachable/TrapdoorBlock.php
deleted file mode 100644
index 8124bb08..00000000
--- a/src/material/block/attachable/TrapdoorBlock.php
+++ /dev/null
@@ -1,63 +0,0 @@
-isActivable = true;
- if(($this->meta & 0x04) === 0x04){
- $this->isFullBlock = false;
- }else{
- $this->isFullBlock = true;
- }
- $this->hardness = 15;
- }
-
- public function canAttachTo(Block $target){
- $id = $target->getID();
- return $id === SLAB || $id === GLOWSTONE || $id === SLAB || $id === WOOD_SLAB || (!$target->isTransparent || $target instanceof StairBlock);
- }
-
- public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
- if(($this->canAttachTo($target)) and $face !== 0 and $face !== 1){
- $faces = array(
- 2 => 0,
- 3 => 1,
- 4 => 2,
- 5 => 3,
- );
- $this->meta = $faces[$face] & 0x03;
- $this->level->setBlock($block, $this, true, false, true);
- return true;
- }
- }
- public function getDrops(Item $item, Player $player){
- return array(
- array($this->id, 0, 1),
- );
- }
- public function onUpdate($type){
- if($type === BLOCK_UPDATE_NORMAL){
- $faces = array( //meta => side
- 0 => 3,
- 4 => 3, //activated
- 1 => 2,
- 5 => 2, //activated
- 2 => 5,
- 6 => 5, //activated
- 3 => 4,
- 7 => 4, //activated
- );
- $side = $faces[$this->meta];
- if($this->getSide($side) instanceof AirBlock){ //Replace with common break method
- ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem($this->id, 0, 1));
- $this->level->setBlock($this, new AirBlock(), true, false, true);
- return BLOCK_UPDATE_NORMAL;
- }
- }
- }
- public function onActivate(Item $item, Player $player){
- $this->meta ^= 0x04;
- $this->level->setBlock($this, $this, true, false, true);
- return true;
- }
-}
\ No newline at end of file
diff --git a/src/material/block/attachable/WallSignBlock.php b/src/material/block/attachable/WallSignBlock.php
deleted file mode 100644
index b41f26a1..00000000
--- a/src/material/block/attachable/WallSignBlock.php
+++ /dev/null
@@ -1,15 +0,0 @@
-hardness = 0;
- }
-
- public function place(Item $item, 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);
- return $ret;
- }
-
- public function getMaxLightValue(){
- return 15;
- }
-
- public function getSourceCount(){
- $count = 0;
- for($side = 2; $side <= 5; ++$side){
- if($this->getSide($side) instanceof LavaBlock ){
- $b = $this->getSide($side);
- $level = $b->meta & 0x06;
- if($level == 0x00){
- $count++;
- }
- }
- }
- return $count;
- }
-
- public function checkWater(){
- for($side = 0; $side <= 5; ++$side){
- $b = $this->getSide($side);
- if($b instanceof WaterBlock){
- $level = $this->meta & 0x06;
- if($level == 0x00){
- $this->level->setBlock($b, new ObsidianBlock(), false, false, true);
- }else{
- $this->level->setBlock($b, new CobblestoneBlock(), false, false, true);
- }
- }
- }
- }
-
- public function getFrom(){
- for($side = 0; $side <= 5; ++$side){
- $b = $this->getSide($side);
- if($b instanceof LavaBlock){
- $tlevel = $b->meta & 0x06;
- $level = $this->meta & 0x06;
- if( ($tlevel + 2) == $level || ($side == 0x01 && $level == 0x01 ) || ($tlevel == 6 && $level == 6 )){
- return $b;
- }
- }
- }
- return null;
- }
-
- public function onUpdate($type){
- //return false;
- $newId = $this->id;
- $level = $this->meta & 0x06;
- if($type !== BLOCK_UPDATE_NORMAL){
- return false;
- }
-
- if($this->checkWater()){
- return;
- }
-
- $falling = $this->meta >> 3;
- $down = $this->getSide(0);
-
- $from = $this->getFrom();
- if($from !== null || $level == 0x00){
- if($down instanceof AirBlock || $down instanceof LavaBlock){
- $this->level->setBlock($down, new LavaBlock(0x01), false, false, true);
- ServerAPI::request()->api->block->scheduleBlockUpdate($down, 40, BLOCK_UPDATE_NORMAL);
- }elseif($level !== 0x06){
- for($side = 2; $side <= 5; ++$side){
- $b = $this->getSide($side);
- if($b instanceof LavaBlock){
-
- }elseif($b->isFlowable === true){
- $this->level->setBlock($b, new LavaBlock( min($level + 2,6) ), false, false, true);
- ServerAPI::request()->api->block->scheduleBlockUpdate($b, 40, BLOCK_UPDATE_NORMAL);
- }
- }
- }
- }else{
- //Extend Remove for Left Lavas
- for($side = 2; $side <= 5; ++$side){
- $sb = $this->getSide($side);
- if($sb instanceof LavaBlock){
- $tlevel = $sb->meta & 0x06;
- if($tlevel != 0x00){
- for ($s = 0; $s <= 5; $s++) {
- $ssb = $sb->getSide($s);
- ServerAPI::request()->api->block->scheduleBlockUpdate($ssb, 40, BLOCK_UPDATE_NORMAL);
- }
- $this->level->setBlock($sb, new AirBlock(), false, false, true);
- }
- }
- $b = $this->getSide(0)->getSide($side);
- if($b instanceof LavaBlock){
- $tlevel = $b->meta & 0x06;
- if($tlevel != 0x00){
- for ($s = 0; $s <= 5; $s++) {
- $ssb = $sb->getSide($s);
- ServerAPI::request()->api->block->scheduleBlockUpdate($ssb, 40, BLOCK_UPDATE_NORMAL);
- }
- $this->level->setBlock($b, new AirBlock(), false, false, true);
- }
- }
- //ServerAPI::request()->api->block->scheduleBlockUpdate(new Position($b, 0, 0, $this->level), 10, BLOCK_UPDATE_NORMAL);
- }
-
- $this->level->setBlock($this, new AirBlock(), false, false, true);
- }
- return false;
- }
-
-}
diff --git a/src/material/block/liquid/StillLavaBlock.php b/src/material/block/liquid/StillLavaBlock.php
deleted file mode 100644
index ea82e135..00000000
--- a/src/material/block/liquid/StillLavaBlock.php
+++ /dev/null
@@ -1,9 +0,0 @@
-hardness = 500;
- }
-
-}
\ No newline at end of file
diff --git a/src/material/block/liquid/StillWaterBlock.php b/src/material/block/liquid/StillWaterBlock.php
deleted file mode 100644
index 67ae7ab1..00000000
--- a/src/material/block/liquid/StillWaterBlock.php
+++ /dev/null
@@ -1,14 +0,0 @@
-hardness = 500;
- }
-
-}
\ No newline at end of file
diff --git a/src/material/block/liquid/WaterBlock.php b/src/material/block/liquid/WaterBlock.php
deleted file mode 100644
index aaf8083c..00000000
--- a/src/material/block/liquid/WaterBlock.php
+++ /dev/null
@@ -1,121 +0,0 @@
-hardness = 500;
- }
-
- public function place(Item $item, 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, 5, BLOCK_UPDATE_NORMAL);
- return $ret;
- }
-
- public function getSourceCount(){
- $count = 0;
- for($side = 2; $side <= 5; ++$side){
- if( $this->getSide($side) instanceof WaterBlock ){
- $b = $this->getSide($side);
- $level = $b->meta & 0x07;
- if($level == 0x00){
- $count++;
- }
- }
- }
- return $count;
- }
-
- public function checkLava(){
- for($side = 0; $side <= 5; ++$side){
- if($side == 1){
- continue;
- }
- $b = $this->getSide($side);
- if($b instanceof LavaBlock){
- $level = $b->meta & 0x07;
- if($level == 0x00){
- $this->level->setBlock($b, new ObsidianBlock(), false, false, true);
- }else{
- $this->level->setBlock($b, new CobblestoneBlock(), false, false, true);
- }
- return true;
- }
- }
- return false;
- }
-
- public function getFrom(){
- for($side = 0; $side <= 5; ++$side){
- $b = $this->getSide($side);
- if($b instanceof WaterBlock){
- $tlevel = $b->meta & 0x07;
- $level = $this->meta & 0x07;
- if( ($tlevel + 1) == $level || ($side == 0x01 && $level == 0x01 )){
- return $b;
- }
- }
- }
- return null;
- }
-
- public function onUpdate($type){
- //return false;
- $newId = $this->id;
- $level = $this->meta & 0x07;
-
- if($type !== BLOCK_UPDATE_NORMAL){
- return false;
- }
-
- $this->checkLava();
-
- $falling = $this->meta >> 3;
- $down = $this->getSide(0);
-
- $from = $this->getFrom();
- //Has Source or Its Source
- if($from !== null || $level == 0x00){
- if($down instanceof AirBlock || $down instanceof WaterBlock){
- $this->level->setBlock($down, new WaterBlock(1), false, false, true); //TODO fix somehow
- ServerAPI::request()->api->block->scheduleBlockUpdate($down, 5, BLOCK_UPDATE_NORMAL);
- }elseif($level !== 0x07){{
- for($side = 2; $side <= 5; ++$side){
- $b = $this->getSide($side);
- if($b instanceof WaterBlock){
- if($this->getSourceCount() >= 2 && $level != 0x00){ //Infinite water source
- $this->level->setBlock($this, new WaterBlock(0), false, false, true);
- }
- }elseif($b->isFlowable === true){
- $this->level->setBlock($b, new WaterBlock($level + 1), false, false, true);
- ServerAPI::request()->api->block->scheduleBlockUpdate($b, 5, BLOCK_UPDATE_NORMAL);
- }
- }
- }
- }
- }else{
- //Extend Remove for Left Waters
- for($side = 2; $side <= 5; ++$side){
- $sb = $this->getSide($side);
- if($sb instanceof WaterBlock){
- $tlevel = $sb->meta & 0x07;
- if($tlevel != 0x00){
- ServerAPI::request()->api->block->blockUpdateAround($sb, BLOCK_UPDATE_NORMAL, 5);
- $this->level->setBlock($sb, new AirBlock(), false, false, true);
- }
- }
- $b = $this->getSide(0)->getSide($side);
- if($b instanceof WaterBlock){
- $tlevel = $b->meta & 0x07;
- if($tlevel != 0x00){
- ServerAPI::request()->api->block->blockUpdateAround($b, BLOCK_UPDATE_NORMAL, 5);
- $this->level->setBlock($b, new AirBlock(), false, false, true);
- }
- }
- }
- ServerAPI::request()->api->block->blockUpdateAround($this, BLOCK_UPDATE_NORMAL, 5);
- $this->level->setBlock($this, new AirBlock(), false, false, true);
- }
- return false;
- }
-}
\ No newline at end of file
diff --git a/src/material/block/misc/AirBlock.php b/src/material/block/misc/AirBlock.php
deleted file mode 100644
index d8533473..00000000
--- a/src/material/block/misc/AirBlock.php
+++ /dev/null
@@ -1,19 +0,0 @@
-isActivable = false;
- $this->breakable = false;
- $this->isFlowable = true;
- $this->isTransparent = true;
- $this->isReplaceable = true;
- $this->isPlaceable = false;
- $this->hasPhysics = false;
- $this->isSolid = false;
- $this->isFullBlock = true;
- $this->hardness = 0;
-
- }
-
-}
\ No newline at end of file
diff --git a/src/material/block/misc/BedBlock.php b/src/material/block/misc/BedBlock.php
deleted file mode 100644
index 1a12b74a..00000000
--- a/src/material/block/misc/BedBlock.php
+++ /dev/null
@@ -1,122 +0,0 @@
- 3,
- 1 => 4,
- 2 => 2,
- 3 => 5,
- ];
-
- public function __construct($type = 0){
- parent::__construct(BED_BLOCK, $type, "Bed Block");
- $this->isActivable = true;
- $this->isFullBlock = false;
- $this->hardness = 1;
- }
-
- public function onActivate(Item $item, Player $player){
- if(ServerAPI::request()->api->time->getPhase($player->level) !== "night"){
- $pk = new ChatPacket;
- $pk->message = "You can only sleep at night";
- $player->dataPacket($pk);
- return true;
- }
-
- $blockNorth = $this->getSide(2); //Gets the blocks around them
- $blockSouth = $this->getSide(3);
- $blockEast = $this->getSide(5);
- $blockWest = $this->getSide(4);
- if(($this->meta & 0x08) === 0x08){ //This is the Top part of bed
- $b = $this;
- }else{ //Bottom Part of Bed
- if($blockNorth->getID() === $this->id and ($blockNorth->meta & 0x08) === 0x08){
- $b = $blockNorth;
- }elseif($blockSouth->getID() === $this->id and ($blockSouth->meta & 0x08) === 0x08){
- $b = $blockSouth;
- }elseif($blockEast->getID() === $this->id and ($blockEast->meta & 0x08) === 0x08){
- $b = $blockEast;
- }elseif($blockWest->getID() === $this->id and ($blockWest->meta & 0x08) === 0x08){
- $b = $blockWest;
- }else{
- $pk = new ChatPacket;
- $pk->message = "This bed is incomplete";
- $player->dataPacket($pk);
- return true;
- }
- }
-
- if($player->sleepOn($b) === false){
- $pk = new ChatPacket;
- $pk->message = "This bed is occupied";
- $player->dataPacket($pk);
- }
- return true;
- }
-
- public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
- $down = $this->getSide(0);
- if($down->isTransparent === false){
-
- $d = $player->entity->getDirection();
- $next = $this->getSide(self::$faces[(($d + 3) % 4)]);
- $downNext = $next->getSide(0);
- if($next->isReplaceable === true and $downNext->isTransparent === false){
- $meta = (($d + 3) % 4) & 0x03;
- $this->level->setBlock($block, BlockAPI::get($this->id, $meta), true, false, true);
- $this->level->setBlock($next, BlockAPI::get($this->id, $meta | 0x08), true, false, true);
- return true;
- }
- }
- return false;
- }
-
- public function onBreak(Item $item, Player $player){
- $blockNorth = $this->getSide(2); //Gets the blocks around them
- $blockSouth = $this->getSide(3);
- $blockEast = $this->getSide(5);
- $blockWest = $this->getSide(4);
-
- if(($this->meta & 0x08) === 0x08){ //This is the Top part of bed
- switch($this->meta & 0x7){
- case 0:
- if($blockNorth->id === $this->id) $this->level->setBlock($blockNorth, new AirBlock(), true, false, true);
- break;
- case 1:
- if($blockEast->id === $this->id) $this->level->setBlock($blockEast, new AirBlock(), true, false, true);
- break;
- case 2:
- if($blockSouth->id === $this->id) $this->level->setBlock($blockSouth, new AirBlock(), true, false, true);
- break;
- case 3:
- if($blockWest->id === $this->id) $this->level->setBlock($blockWest, new AirBlock(), true, false, true);
- break;
- }
- }else{ //Bottom Part of Bed
- switch($this->meta & 0x7){
- case 0:
- if($blockSouth->id === $this->id) $this->level->setBlock($blockSouth, new AirBlock(), true, false, true);
- break;
- case 1:
- if($blockWest->id === $this->id) $this->level->setBlock($blockWest, new AirBlock(), true, false, true);
- break;
- case 2:
- if($blockNorth->id === $this->id) $this->level->setBlock($blockNorth, new AirBlock(), true, false, true);
- break;
- case 3:
- if($blockEast->id === $this->id) $this->level->setBlock($blockEast, new AirBlock(), true, false, true);
- break;
- }
- }
- $this->level->setBlock($this, new AirBlock(), true, false, true);
- return true;
- }
-
- public function getDrops(Item $item, Player $player){
- return array(
- array(BED, 0, 1),
- );
- }
-
-}
\ No newline at end of file
diff --git a/src/material/block/misc/FireBlock.php b/src/material/block/misc/FireBlock.php
deleted file mode 100644
index af229c91..00000000
--- a/src/material/block/misc/FireBlock.php
+++ /dev/null
@@ -1,37 +0,0 @@
-isReplaceable = true;
- $this->breakable = false;
- $this->isFullBlock = true;
- $this->hardness = 0;
- }
-
- public function getDrops(Item $item, Player $player){
- return array();
- }
- public function getMaxLightValue(){
- return 15;
- }
- public function onUpdate($type){
- if($type === BLOCK_UPDATE_NORMAL){
- for($s = 0; $s <= 5; ++$s){
- $side = $this->getSide($s);
- if($side->getID() !== AIR and !($side instanceof LiquidBlock)){
- return false;
- }
- }
- $this->level->setBlock($this, new AirBlock(), true, false, true);
- return BLOCK_UPDATE_NORMAL;
- }elseif($type === BLOCK_UPDATE_RANDOM){
- if($this->getSide(0)->getID() !== NETHERRACK){
- $this->level->setBlock($this, new AirBlock(), true, false, true);
- return BLOCK_UPDATE_NORMAL;
- }
- }
- return false;
- }
-
-}
\ No newline at end of file
diff --git a/src/material/block/misc/MobSpawnerBlock.php b/src/material/block/misc/MobSpawnerBlock.php
deleted file mode 100644
index 1844eac6..00000000
--- a/src/material/block/misc/MobSpawnerBlock.php
+++ /dev/null
@@ -1,30 +0,0 @@
-isActivable = true;
- }
-
- public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
- $api = ServerAPI::request();
- $tile = $api->api->tile->add($this->level, TILE_MOB_SPAWNER, $this->x, $this->y, $this->z, [
- "id" => TILE_MOB_SPAWNER,
- "x" => $this->x,
- "y" => $this->y,
- "z" => $this->z,
- "EntityId" => MOB_SPIDER, //TODO vanilla values
- "Delay" => 5,
- "MinSpawnDelay" => 20,
- "MaxSpawnDelay" => 80,
- "SpawnCount" => 4,
- "MaxNearbyEntities" => 0,
- "RequiredPlayerRange" => 0,
- "SpawnRange" => 4
- ]);
- parent::place($item, $player, $block, $target, $face, $fx, $fy, $fz);
- }
-}
-
diff --git a/src/material/block/misc/NetherReactorBlock.php b/src/material/block/misc/NetherReactorBlock.php
deleted file mode 100644
index 7c20e94c..00000000
--- a/src/material/block/misc/NetherReactorBlock.php
+++ /dev/null
@@ -1,242 +0,0 @@
-isActivable = true;
- }
-
- public function onActivate(Item $item, Player $player){
- //if(($item->getID() === IRON_SWORD || $item->getID() === WOODEN_SWORD || $item->getID() === STONE_SWORD || $item->getID() === DIAMOND_SWORD || $item->getID() === GOLD_SWORD) /*&& $player->gamemode === 0*/){
- if($this->getMetadata() === 0 && $this->isCorrect($this->getX(),$this->getY(),$this->getZ()) && $this->getY() < 101 && NetherReactorBlock::$enableReactor){
- NetherReactorStructure::buildReactor($this->level, $this->getX(),$this->getY(),$this->getZ());
- $this->meta = 1;
- $this->level->setBlock($this,$this);
- $server = ServerAPI::request();
- $server->schedule(40, array($this, "glow"), 1);
- $server->schedule(60, array($this, "glow"), 2);
- $server->schedule(80, array($this, "glow"), 3);
- $server->schedule(140, array($this, "glow"), 4);
- $server->schedule(200, array($this, "spawnItems"), [0,15,2,true]); //200
- $server->schedule(260, array($this, "spawnItems"), [0,15,"checkPigmen",true]);
- $server->schedule(300, array($this, "spawnItems"), [0,15,"checkPigmen",true]);
- $server->schedule(340, array($this, "spawnItems"), [11,20,"checkPigmen",false]);
- $server->schedule(400, array($this, "spawnItems"), [0,10,"checkPigmen",false]);
- $server->schedule(500, array($this, "spawnItems"), [17,32, "checkPigmen",false]); //500
- $server->schedule(580, array($this, "spawnItems"), [17,32, "checkPigmen",false]);
- $server->schedule(620, array($this, "spawnItems"), [1,32, "checkPigmen",false]);
- $server->schedule(660, array($this, "spawnItems"), [1,32,"checkPigmen",false]);
- $server->schedule(700, array($this, "spawnItems"), [1,32,"checkPigmen",false]);
- $server->schedule(860, array($this, "glow"), 5);
- $server->schedule(880, array($this, "glow"), 6);
- $server->schedule(900, array($this, "glow"), 7);
- $server->schedule(920, array($this, "destroy"));
- return true;
- }
- //}
-
- }
-
- public function destroy(){
- $this->level->setBlock(new Vector3($this->x, $this->y, $this->z),new NetherReactorBlock(2));
- $this->decay($this->x-8, $this->y-3, $this->z-8, 0, 17, 16, 2, 34, 1, 0, 17, 1);
- $this->decay($this->x-8, $this->y-3, $this->z-8, 1, 16, 1, 2, 34, 1, 0, 17, 16);
- $this->decay($this->x-8, $this->y-3, $this->z-8, 3, 14, 10, 8, 34, 1, 3, 14, 1);
- $this->decay($this->x-8, $this->y-3, $this->z-8, 4, 13, 1, 8, 34, 1, 3, 14, 10);
- $this->decay($this->x-8, $this->y-3, $this->z-8, 5, 12, 6, 14, 34, 1, 5, 12, 1);
- $this->decay($this->x-8, $this->y-3, $this->z-8, 6, 11, 1, 14, 34, 1, 5, 12, 16);
- }
-
- public function getDrops(Item $item, Player $player){
- if($item->getPickaxeLevel() >= 1){
- return array(
- [DIAMOND, 0, 3],
- [IRON_INGOT, 0, 6],
- );
- }
- }
-
- private function decay($x, $y, $z, $aOne, $aTwo, $aThree, $bOne, $bTwo, $bThree, $cOne, $cTwo, $cThree) {
- for($a = $aOne; $a < $aTwo; $a += $aThree) { //wth those cycles are? TODO simplify if possible(makes server lag)
- for($b = $bOne; $b < $bTwo; $b += $bThree) {
- for($c = $cOne; $c < $cTwo; $c += $cThree) {
- if ($this->level->getBlock(new Vector3($x+$a, $y+$b, $z+$c))->getID() === 87 && lcg_value() > 0.75){
- $this->level->setBlock(new Vector3($x+$a, $y+$b, $z+$c), new AirBlock());
- }
- }
- }
- }
- }
-
- private function pigmenCheck($x,$y,$z) {
- $pigCount = 0;
- $server = ServerAPI::request();
- $allEntities = $server->api->entity->entities;
- foreach($allEntities as $entity) {
- if($entity->type === MOB_PIGMAN && $entity->x < $x + 8 && $entity->x > $x - 8 && $entity->z < $z + 8 && $entity->z > $z - 8 && $entity->y > $y - 2 && $entity->y < $y + 3){
- $pigCount += 1;
- }
- }
- return $pigCount < 3 ? $pigCount < 2 ? 2 : 1 : 0;
- }
-
- public function spawnItems($data) {
- $x = $this->x;
- $y = $this->y;
- $z = $this->z;
- $minAmount = $data[0];
- $maxAmount = $data[1];
- $pigmen = $data[2] === "checkPigmen" ? $this->pigmenCheck($x, $y, $z) : $data[2];
- $forceAmount = $data[3];
- $server = ServerAPI::request();
- if(!$forceAmount){
- $spawnNumber = $minAmount + floor(lcg_value()*($maxAmount-$minAmount+1));
- }
- else{
- $spawnNumber = $maxAmount;
- }
- for($i = 0; $i < $spawnNumber; $i++) {
- $randomRange = floor(lcg_value()*5+3);
- $shiftX = cos(floor(lcg_value()*360)*(pi()/180));
- $shiftZ = sin(floor(lcg_value()*360)*(pi()/180));
- if(Utils::chance(5)) $randomID = $this->rarePossibleLoot[array_rand($this->rarePossibleLoot)];
- else $randomID = $this->possibleLoot[array_rand($this->possibleLoot)];
- $server->api->entity->drop(new Position($x+($shiftX*$randomRange)+0.5, $y, $z+($shiftZ*$randomRange)+0.5, $this->level), BlockAPI::getItem($randomID, 0, 1));
- }
- for($i = 0; $i < $pigmen; $i++) {
- $randomRange = floor(lcg_value()*5+3);
- $shiftX = cos(floor(lcg_value()*360)*(pi()/180));
- $shiftZ = sin(floor(lcg_value()*360)*(pi()/180));
- $data = array(
- "x" => $x+($shiftX*$randomRange)+0.5,
- "y" => $y,
- "z" => $z+($shiftZ*$randomRange)+0.5,
- );
- $e = $server->api->entity->add($this->level, ENTITY_MOB, MOB_PIGMAN, $data);
- $server->api->entity->spawnToAll($e);
- }
- }
-
- public function glow($part){
- $x = $this->x;
- $y = $this->y;
- $z = $this->z;
- switch($part){
- case 1:
- $this->level->setBlock(new Vector3($x, $y-1, $z),new GlowingObsidianBlock);
- $this->level->setBlock(new Vector3($x+1, $y-1, $z),new GlowingObsidianBlock);
- $this->level->setBlock(new Vector3($x-1, $y-1, $z),new GlowingObsidianBlock);
- $this->level->setBlock(new Vector3($x, $y-1, $z+1),new GlowingObsidianBlock);
- $this->level->setBlock(new Vector3($x, $y-1, $z-1),new GlowingObsidianBlock);
- break;
- case 2:
- $this->level->setBlock(new Vector3($x+1, $y, $z+1),new GlowingObsidianBlock);
- $this->level->setBlock(new Vector3($x+1, $y, $z-1),new GlowingObsidianBlock);
- $this->level->setBlock(new Vector3($x-1, $y, $z+1),new GlowingObsidianBlock);
- $this->level->setBlock(new Vector3($x-1, $y, $z-1),new GlowingObsidianBlock);
- break;
- case 3:
- $this->level->setBlock(new Vector3($x, $y+1, $z),new GlowingObsidianBlock);
- $this->level->setBlock(new Vector3($x+1, $y+1, $z),new GlowingObsidianBlock);
- $this->level->setBlock(new Vector3($x-1, $y+1, $z),new GlowingObsidianBlock);
- $this->level->setBlock(new Vector3($x, $y+1, $z+1),new GlowingObsidianBlock);
- $this->level->setBlock(new Vector3($x, $y+1, $z-1),new GlowingObsidianBlock);
- break;
- case 4:
- $this->level->setBlock(new Vector3($x+1, $y-1, $z+1),new GlowingObsidianBlock);
- $this->level->setBlock(new Vector3($x+1, $y-1, $z-1),new GlowingObsidianBlock);
- $this->level->setBlock(new Vector3($x-1, $y-1, $z+1),new GlowingObsidianBlock);
- $this->level->setBlock(new Vector3($x-1, $y-1, $z-1),new GlowingObsidianBlock);
- break;
- case 5:
- $this->level->setBlock(new Vector3($x, $y+1, $z),new ObsidianBlock);
- $this->level->setBlock(new Vector3($x+1, $y+1, $z),new ObsidianBlock);
- $this->level->setBlock(new Vector3($x-1, $y+1, $z),new ObsidianBlock);
- $this->level->setBlock(new Vector3($x, $y+1, $z+1),new ObsidianBlock);
- $this->level->setBlock(new Vector3($x, $y+1, $z-1),new ObsidianBlock);
- $this->level->setBlock(new Vector3($x+1, $y+1, $z+1),new ObsidianBlock);
- $this->level->setBlock(new Vector3($x+1, $y+1, $z-1),new ObsidianBlock);
- $this->level->setBlock(new Vector3($x-1, $y+1, $z+1),new ObsidianBlock);
- $this->level->setBlock(new Vector3($x-1, $y+1, $z-1),new ObsidianBlock);
- break;
- case 6:
- $this->level->setBlock(new Vector3($x, $y, $z), new NetherReactorBlock(2));
- $this->level->setBlock(new Vector3($x+1, $y, $z),new ObsidianBlock);
- $this->level->setBlock(new Vector3($x-1, $y, $z),new ObsidianBlock);
- $this->level->setBlock(new Vector3($x, $y, $z+1),new ObsidianBlock);
- $this->level->setBlock(new Vector3($x, $y, $z-1),new ObsidianBlock);
- $this->level->setBlock(new Vector3($x+1, $y, $z+1),new ObsidianBlock);
- $this->level->setBlock(new Vector3($x+1, $y, $z-1),new ObsidianBlock);
- $this->level->setBlock(new Vector3($x-1, $y, $z+1),new ObsidianBlock);
- $this->level->setBlock(new Vector3($x-1, $y, $z-1),new ObsidianBlock);
- break;
- case 7:
- $this->level->setBlock(new Vector3($x, $y-1, $z),new ObsidianBlock);
- $this->level->setBlock(new Vector3($x+1, $y-1, $z),new ObsidianBlock);
- $this->level->setBlock(new Vector3($x-1, $y-1, $z),new ObsidianBlock);
- $this->level->setBlock(new Vector3($x, $y-1, $z+1),new ObsidianBlock);
- $this->level->setBlock(new Vector3($x, $y-1, $z-1),new ObsidianBlock);
- $this->level->setBlock(new Vector3($x+1, $y-1, $z+1),new ObsidianBlock);
- $this->level->setBlock(new Vector3($x+1, $y-1, $z-1),new ObsidianBlock);
- $this->level->setBlock(new Vector3($x-1, $y-1, $z+1),new ObsidianBlock);
- $this->level->setBlock(new Vector3($x-1, $y-1, $z-1),new ObsidianBlock);
- break;
- }
- }
-
- private function isCorrect($x, $y, $z){
- $offsetX = -1;
- $offsetZ = -1;
- foreach($this->core as $yOffset => $layer){
- foreach($layer as $line){
- foreach(str_split($line) as $char){
- $b = $this->level->getBlock(new Vector3($x + $offsetX, $y + $yOffset, $z + $offsetZ))->getID();
- switch($char){
- case "G":
- if($b === GOLD_BLOCK){ //TODO make it use structure class
- break;
- }
- return false;
- case "C":
- if($b === COBBLESTONE){
- break;
- }
- return false;
- case "R":
- if($b === NETHER_REACTOR and $this->level->getBlock(new Vector3($x + $offsetX, $y + $yOffset, $z + $offsetZ))->getMetadata() === 0){
- break;
- }
- return false;
- case " ":
- if($b === 0){
- break;
- }
- return false;
- default:
- break;
- }
- ++$offsetX;
- }
- ++$offsetZ;
- $offsetX = -1;
- }
- $offsetZ = -1;
- }
- return true;
- }
-
- private $possibleLoot = [
- GLOWSTONE_DUST, QUARTZ, CACTUS, SUGARCANE, BROWN_MUSHROOM, RED_MUSHROOM, PUMPKIN_SEEDS, MELON_SEEDS
- ];
-
- private $rarePossibleLoot = [
- BOW, BED, BOWL, ARROW, WOODEN_DOOR, FEATHER, PAINTING, BONE, DANDELION
- ];
-
- private $core = [
- -1 => ["GCG", "CCC", "GCG"],
- 0 => ["C C", " R ", "C C",],
- 1 =>[" C ", "CCC", " C "]
- ];
-}
diff --git a/src/material/block/misc/TNTBlock.php b/src/material/block/misc/TNTBlock.php
deleted file mode 100644
index b70acdab..00000000
--- a/src/material/block/misc/TNTBlock.php
+++ /dev/null
@@ -1,29 +0,0 @@
-hardness = 0;
- $this->isActivable = true;
- }
-
- public function onActivate(Item $item, Player $player){
- if($item->getID() === FLINT_STEEL){
- if(($player->gamemode & 0x01) === 0){
- $item->useOn($this);
- }
- $data = array(
- "x" => $this->x + 0.5,
- "y" => $this->y + 0.5,
- "z" => $this->z + 0.5,
- "power" => 3,
- "fuse" => 20 * 4, //4 seconds
- );
- $this->level->setBlock($this, new AirBlock(), false, false, true);
- $e = ServerAPI::request()->api->entity->add($this->level, ENTITY_OBJECT, OBJECT_PRIMEDTNT, $data);
- ServerAPI::request()->api->entity->spawnToAll($e);
- return true;
- }
- return false;
- }
-}
\ No newline at end of file
diff --git a/src/material/block/nonfull/CakeBlock.php b/src/material/block/nonfull/CakeBlock.php
deleted file mode 100644
index 485e943b..00000000
--- a/src/material/block/nonfull/CakeBlock.php
+++ /dev/null
@@ -1,49 +0,0 @@
-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){
- $down = $this->getSide(0);
- if($down->getID() !== AIR){
- $this->level->setBlock($block, $this, true, false, true);
- return true;
- }
- return false;
- }
-
- public function onUpdate($type){
- if($type === BLOCK_UPDATE_NORMAL){
- if($this->getSide(0)->getID() === AIR){ //Replace with common break method
- $this->level->setBlock($this, new AirBlock(), true, false, true);
- return BLOCK_UPDATE_NORMAL;
- }
- }
- return false;
- }
-
- public function getDrops(Item $item, Player $player){
- return array();
- }
-
- public function onActivate(Item $item, Player $player){
- if($player->entity->getHealth() < 20){
- ++$this->meta;
- $player->entity->heal(3, "cake");
- if($this->meta >= 0x06){
- $this->level->setBlock($this, new AirBlock(), true, false, true);
- }else{
- $this->level->setBlock($this, $this, true, false, true);
- }
- return true;
- }
- return false;
- }
-
-}
\ No newline at end of file
diff --git a/src/material/block/nonfull/CarpetBlock.php b/src/material/block/nonfull/CarpetBlock.php
deleted file mode 100644
index 068717c3..00000000
--- a/src/material/block/nonfull/CarpetBlock.php
+++ /dev/null
@@ -1,49 +0,0 @@
- "White Carpet",
- 1 => "Orange Carpet",
- 2 => "Magenta Carpet",
- 3 => "Light Blue Carpet",
- 4 => "Yellow Carpet",
- 5 => "Lime Carpet",
- 6 => "Pink Carpet",
- 7 => "Gray Carpet",
- 8 => "Light Gray Carpet",
- 9 => "Cyan Carpet",
- 10 => "Purple Carpet",
- 11 => "Blue Carpet",
- 12 => "Brown Carpet",
- 13 => "Green Carpet",
- 14 => "Red Carpet",
- 15 => "Black Carpet",];
-
- public function __construct($meta = 0){
- parent::__construct(CARPET, $meta, self::$names[$meta]);
- $this->hardness = 0;
- $this->isFullBlock = false;
- $this->isSolid = true;
- }
-
- public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
- $down = $this->getSide(0);
- if($down->getID() !== AIR){
- $this->level->setBlock($block, $this, true, false, true);
- return true;
- }
- return false;
- }
-
- public function onUpdate($type){
- if($type === BLOCK_UPDATE_NORMAL){
- if($this->getSide(0)->getID() === AIR){ //Replace with common break method
- ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem($this->id, $this->meta, 1));
- $this->level->setBlock($this, new AirBlock(), true, false, true);
- return BLOCK_UPDATE_NORMAL;
- }
- }
- return false;
- }
-
-}
\ No newline at end of file
diff --git a/src/material/block/nonfull/ChestBlock.php b/src/material/block/nonfull/ChestBlock.php
deleted file mode 100644
index 9da2f542..00000000
--- a/src/material/block/nonfull/ChestBlock.php
+++ /dev/null
@@ -1,108 +0,0 @@
-isActivable = true;
- $this->isFullBlock = false;
- $this->hardness = 15;
- }
- public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
- $server = ServerAPI::request();
- $faces = array(
- 0 => 4,
- 1 => 2,
- 2 => 5,
- 3 => 3,
- );
-
- $chest = false;
- $this->meta = $faces[$player->entity->getDirection()];
-
- for($side = 2; $side <= 5; ++$side){
- if(($this->meta === 4 or $this->meta === 5) and ($side === 4 or $side === 5)){
- continue;
- }elseif(($this->meta === 3 or $this->meta === 2) and ($side === 2 or $side === 3)){
- continue;
- }
- $c = $this->getSide($side);
- if(($c instanceof ChestBlock) and $c->getMetadata() === $this->meta){
- if((($tile = $server->api->tile->get($c)) instanceof Tile) and !$tile->isPaired()){
- $chest = $tile;
- break;
- }
- }
- }
-
- $this->level->setBlock($block, $this, true, false, true);
- $tile = $server->api->tile->add($this->level, TILE_CHEST, $this->x, $this->y, $this->z, array(
- "Items" => array(),
- "id" => TILE_CHEST,
- "x" => $this->x,
- "y" => $this->y,
- "z" => $this->z
- ));
-
- if($chest instanceof Tile){
- $chest->pairWith($tile);
- $tile->pairWith($chest);
- }
- return true;
- }
-
- public function onBreak(Item $item, Player $player){
- $t = ServerAPI::request()->api->tile->get($this);
- if($t !== false){
- $t->unpair();
- }
- $this->level->setBlock($this, new AirBlock(), true, true, true);
- return true;
- }
-
- public function onActivate(Item $item, Player $player){
- $top = $this->getSide(1);
- if($top->isTransparent !== true){
- return true;
- }
-
- $server = ServerAPI::request();
- $t = $server->api->tile->get($this);
- $chest = false;
- if($t !== false){
- $chest = $t;
- }else{
- $chest = $server->api->tile->add($this->level, TILE_CHEST, $this->x, $this->y, $this->z, array(
- "Items" => array(),
- "id" => TILE_CHEST,
- "x" => $this->x,
- "y" => $this->y,
- "z" => $this->z
- ));
- }
-
-
-
- if(($player->gamemode & 0x01) === 0x01){
- return true;
- }
-
- $chest->openInventory($player);
- return true;
- }
-
- public function getDrops(Item $item, Player $player){
- $drops = array(
- array($this->id, 0, 1),
- );
- $t = ServerAPI::request()->api->tile->get($this);
- if($t !== false and $t->class === TILE_CHEST){
- for($s = 0; $s < CHEST_SLOTS; ++$s){
- $slot = $t->getSlot($s);
- if($slot->getID() > AIR and $slot->count > 0){
- $drops[] = array($slot->getID(), $slot->getMetadata(), $slot->count);
- }
- }
- }
- return $drops;
- }
-}
\ No newline at end of file
diff --git a/src/material/block/nonfull/CobwebBlock.php b/src/material/block/nonfull/CobwebBlock.php
deleted file mode 100644
index 3e0a432d..00000000
--- a/src/material/block/nonfull/CobwebBlock.php
+++ /dev/null
@@ -1,22 +0,0 @@
-isSolid = true;
- $this->isFullBlock = false;
- $this->hardness = 25;
- }
- public function getDrops(Item $item, Player $player){
- if ($item->isSword()){
- return array(
- array(287, 0, 1),
- );
- }
- elseif ($item->isShears()){
- return array(
- array(COBWEB, 0, 1),
- );
- }
- }
-}
\ No newline at end of file
diff --git a/src/material/block/nonfull/EndPortalFrame.php b/src/material/block/nonfull/EndPortalFrame.php
deleted file mode 100644
index fe58e999..00000000
--- a/src/material/block/nonfull/EndPortalFrame.php
+++ /dev/null
@@ -1,10 +0,0 @@
-isFullBlock = false;
- $this->hardness = 3600000;
- //direction is isset in this version?
- }
-}
\ No newline at end of file
diff --git a/src/material/block/nonfull/FarmlandBlock.php b/src/material/block/nonfull/FarmlandBlock.php
deleted file mode 100644
index fed4b3d0..00000000
--- a/src/material/block/nonfull/FarmlandBlock.php
+++ /dev/null
@@ -1,62 +0,0 @@
-hardness = 3;
- }
-
- public function getDrops(Item $item, Player $player){
- return [
- [DIRT, 0, 1]
- ];
- }
-
- public function hasCrops(){
- //TODO vanilla 0.8.1 detection method
- $b = $this->getSide(1);
- return $b->isTransparent && $b->id != 0;
- }
-
- public function onUpdate($type){
- if($type === BLOCK_UPDATE_NORMAL){
- if(!$this->getSide(1)->isTransparent){
- $this->level->setBlock($this, BlockAPI::get(DIRT, 0), true, false, true);
- return $type;
- }
- }
- if($type === BLOCK_UPDATE_RANDOM){
- if($this->meta === 0 && mt_rand(0,5) == 0){
- $water = $this->checkWater();
- if($water){
- $this->level->setBlock($this, BlockAPI::get(FARMLAND, 1), true, false, true);
- }elseif(!$this->hasCrops()){
- $this->level->setBlock($this, BlockAPI::get(DIRT, 0), true, false, true);
- }
- }
- if(!$this->getSide(1)->isFlowable){
- $this->level->setBlock($this, BlockAPI::get(DIRT, 0), true, false, true);
- }
- return $type;
- }
- return false;
- }
-
- public function getBlockID($x, $y, $z){
- return $this->level->level->getBlockID($x, $y, $z); //PMFLevel method
- }
-
- public function checkWater(){
- for($x = $this->x - 4; $x <= $this->x + 4; $x++){
- for($y = $this->y; $y <= $this->y + 1; $y++){
- for($z = $this->z - 4; $z <= $this->z + 4; $z++){
- $id = $this->getBlockID($x, $y, $z);
- if($id === 8 || $id === 9){
- return true;
- }
- }
- }
- }
- return false;
- }
-}
diff --git a/src/material/block/nonfull/FenceBlock.php b/src/material/block/nonfull/FenceBlock.php
deleted file mode 100644
index 50e1d6cc..00000000
--- a/src/material/block/nonfull/FenceBlock.php
+++ /dev/null
@@ -1,9 +0,0 @@
-isFullBlock = false;
- $this->hardness = 15;
- }
-}
\ No newline at end of file
diff --git a/src/material/block/nonfull/FenceGateBlock.php b/src/material/block/nonfull/FenceGateBlock.php
deleted file mode 100644
index b62533cc..00000000
--- a/src/material/block/nonfull/FenceGateBlock.php
+++ /dev/null
@@ -1,44 +0,0 @@
-isActivable = true;
- if(($this->meta & 0x04) === 0x04){
- $this->isFullBlock = true;
- }else{
- $this->isFullBlock = false;
- }
- $this->hardness = 15;
- }
- public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
- $faces = array(
- 0 => 3,
- 1 => 0,
- 2 => 1,
- 3 => 2,
- );
- $this->meta = $faces[$player->entity->getDirection()] & 0x03;
- $this->level->setBlock($block, $this, true, false, true);
- return true;
- }
- public function getDrops(Item $item, Player $player){
- return array(
- array($this->id, 0, 1),
- );
- }
- public function onActivate(Item $item, Player $player){
- $this->meta ^= 0x04;
- $this->level->setBlock($this, $this, true, false, true);
- $players = ServerAPI::request()->api->player->getAll($this->level);
- unset($players[$player->CID]);
- $pk = new LevelEventPacket;
- $pk->x = $this->x;
- $pk->y = $this->y;
- $pk->z = $this->z;
- $pk->evid = 1003;
- $pk->data = 0;
- ServerAPI::request()->api->player->broadcastPacket($players, $pk);
- return true;
- }
-}
diff --git a/src/material/block/nonfull/GlassPaneBlock.php b/src/material/block/nonfull/GlassPaneBlock.php
deleted file mode 100644
index b926d196..00000000
--- a/src/material/block/nonfull/GlassPaneBlock.php
+++ /dev/null
@@ -1,14 +0,0 @@
-isFullBlock = false;
- $this->isSolid = false;
- }
- public function getDrops(Item $item, Player $player){
- return array(
- array(GLASS_PANE, 0, 0),
- );
- }
-}
\ No newline at end of file
diff --git a/src/material/block/nonfull/IronBarsBlock.php b/src/material/block/nonfull/IronBarsBlock.php
deleted file mode 100644
index 9e44f47e..00000000
--- a/src/material/block/nonfull/IronBarsBlock.php
+++ /dev/null
@@ -1,10 +0,0 @@
-isFullBlock = false;
- $this->isSolid = false;
- }
-
-}
\ No newline at end of file
diff --git a/src/material/block/nonfull/IronDoorBlock.php b/src/material/block/nonfull/IronDoorBlock.php
deleted file mode 100644
index ab8bb315..00000000
--- a/src/material/block/nonfull/IronDoorBlock.php
+++ /dev/null
@@ -1,39 +0,0 @@
-isActivable = true;
- $this->hardness = 25;
- }
-
- public function getBreakTime(Item $item, Player $player){
- if(($player->gamemode & 0x01) === 0x01){
- return 0.20;
- }
- switch($item->getPickaxeLevel()){
- case 5:
- return 0.95;
- case 4:
- return 1.25;
- case 3:
- return 1.9;
- case 2:
- return 0.65;
- case 1:
- return 3.75;
- default:
- return 25;
- }
- }
-
- public function getDrops(Item $item, Player $player){
- if($item->getPickaxeLevel() >= 1){
- return array(
- array(IRON_DOOR, 0, 1),
- );
- }else{
- return array();
- }
- }
-}
diff --git a/src/material/block/nonfull/PoweredRailBlock.php b/src/material/block/nonfull/PoweredRailBlock.php
deleted file mode 100644
index c9e7a74b..00000000
--- a/src/material/block/nonfull/PoweredRailBlock.php
+++ /dev/null
@@ -1,11 +0,0 @@
-hardness = 0.7;
- $this->isFullBlock = false;
- $this->isSolid = false;
- }
-
-}
\ No newline at end of file
diff --git a/src/material/block/nonfull/RailBaseBlock.php b/src/material/block/nonfull/RailBaseBlock.php
deleted file mode 100644
index beb2c9c0..00000000
--- a/src/material/block/nonfull/RailBaseBlock.php
+++ /dev/null
@@ -1,56 +0,0 @@
-level->getBlockID($x, $y, $z);
- return $id === POWERED_RAIL || $id === RAIL;
- }
- public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
- $down = $this->getSide(0);
- if($down->getID() !== AIR and $down instanceof SolidBlock){
-
- $this->level->setBlock($block, $this, true, false, true);
- $logic = new RailLogic($this);
- $logic->place(false, true);
- return true;
- }
- return false;
- }
-
- public function updateState(){}
-
- public function onUpdate($type){
- if($type === BLOCK_UPDATE_NORMAL){
-
- $meta = $this->getMetadata();
- if($this->id === POWERED_RAIL){
- $meta &= 7;
- }
- $x = $this->x;
- $y = $this->y;
- $z = $this->z;
- if(
- ($this->level->level->getBlockID($x, $y - 1, $z) == 0) ||
- (($meta == 2) && $this->level->level->getBlockID($x + 1, $y, $z) == 0) ||
- (($meta == 3) && $this->level->level->getBlockID($x - 1, $y, $z) == 0) ||
- (($meta == 4) && $this->level->level->getBlockID($x, $y, $z - 1) == 0) ||
- (($meta == 5) && $this->level->level->getBlockID($x, $y, $z + 1) == 0)
- ){
- $this->level->setBlock($this, new AirBlock(), true, false, true);
- ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem($this->id, $this->meta, 1));
- }else{
- $this->updateState();
- }
-
-
- //if($this->getSide(0)->getID() === AIR){//Replace with common break method
- // ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem($this->id, $this->meta, 1));
- // $this->level->setBlock($this, new AirBlock(), true, false, true);
- //}
-
- }
-
- }
-}
diff --git a/src/material/block/nonfull/RailBlock.php b/src/material/block/nonfull/RailBlock.php
deleted file mode 100644
index 67bdc276..00000000
--- a/src/material/block/nonfull/RailBlock.php
+++ /dev/null
@@ -1,21 +0,0 @@
-hardness = 0.7;
- $this->isFullBlock = false;
- $this->isSolid = false;
- }
-
- public function updateState(){
- //$logic = (new RailLogic($this));
- //if($logic->countPotentialConnections() == 3){
- // $logic->place(false, false);
- //}
- }
-
-}
\ No newline at end of file
diff --git a/src/material/block/nonfull/SlabBlock.php b/src/material/block/nonfull/SlabBlock.php
deleted file mode 100644
index bd4d6d45..00000000
--- a/src/material/block/nonfull/SlabBlock.php
+++ /dev/null
@@ -1,96 +0,0 @@
- "Stone",
- 1 => "Sandstone",
- 2 => "Wooden",
- 3 => "Cobblestone",
- 4 => "Brick",
- 5 => "Stone Brick",
- 6 => "Quartz",
- 7 => "", //hum?
- );
- $this->name = (($this->meta & 0x08) === 0x08 ? "Upper ":"") . $names[$this->meta & 0x07] . " Slab";
- if(($this->meta & 0x08) === 0x08){
- $this->isFullBlock = true;
- }else{
- $this->isFullBlock = false;
- }
- $this->hardness = 30;
- }
-
- public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
- $this->meta &= 0x07;
- if($face === 0){
- if($target->getID() === SLAB and ($target->getMetadata() & 0x08) === 0x08 and ($target->getMetadata() & 0x07) === ($this->meta & 0x07)){
- $this->level->setBlock($target, BlockAPI::get(DOUBLE_SLAB, $this->meta), true, false, true);
- return true;
- }elseif($block->getID() === SLAB and ($block->getMetadata() & 0x07) === ($this->meta & 0x07)){
- $this->level->setBlock($block, BlockAPI::get(DOUBLE_SLAB, $this->meta), true, false, true);
- return true;
- }else{
- $this->meta |= 0x08;
- }
- }elseif($face === 1){
- if($target->getID() === SLAB and ($target->getMetadata() & 0x08) === 0 and ($target->getMetadata() & 0x07) === ($this->meta & 0x07)){
- $this->level->setBlock($target, BlockAPI::get(DOUBLE_SLAB, $this->meta), true, false, true);
- return true;
- }elseif($block->getID() === SLAB and ($block->getMetadata() & 0x07) === ($this->meta & 0x07)){
- $this->level->setBlock($block, BlockAPI::get(DOUBLE_SLAB, $this->meta), true, false, true);
- return true;
- }
- }elseif(!$player->entity->inBlock($block)){
- if($block->getID() === SLAB){
- if(($block->getMetadata() & 0x07) === ($this->meta & 0x07)){
- $this->level->setBlock($block, BlockAPI::get(DOUBLE_SLAB, $this->meta), true, false, true);
- return true;
- }
- return false;
- }else{
- if($fy > 0.5){
- $this->meta |= 0x08;
- }
- }
- }else{
- return false;
- }
- if($block->getID() === SLAB and ($target->getMetadata() & 0x07) !== ($this->meta & 0x07)){
- return false;
- }
- $this->level->setBlock($block, $this, true, false, true);
- return true;
- }
-
- public function getBreakTime(Item $item, Player $player){
- if(($player->gamemode & 0x01) === 0x01){
- return 0.20;
- }
- switch($item->getPickaxeLevel()){
- case 5:
- return 0.4;
- case 4:
- return 0.5;
- case 3:
- return 0.75;
- case 2:
- return 0.25;
- case 1:
- return 1.5;
- default:
- return 10;
- }
- }
-
- public function getDrops(Item $item, Player $player){
- if($item->getPickaxeLevel() >= 1){
- return array(
- array($this->id, $this->meta & 0x07, 1),
- );
- }else{
- return array();
- }
- }
-}
\ No newline at end of file
diff --git a/src/material/block/nonfull/SnowLayerBlock.php b/src/material/block/nonfull/SnowLayerBlock.php
deleted file mode 100644
index 2af04991..00000000
--- a/src/material/block/nonfull/SnowLayerBlock.php
+++ /dev/null
@@ -1,38 +0,0 @@
-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){
- $down = $this->getSide(0);
- if($down instanceof SolidBlock){
- $this->level->setBlock($block, $this, true, false, true);
- return true;
- }
- return false;
- }
-
- public function onUpdate($type){
- if($type === BLOCK_UPDATE_NORMAL){
- if($this->getSide(0)->getID() === AIR){ //Replace with common break method
- $this->level->setBlock($this, new AirBlock(), true, false, true);
- return BLOCK_UPDATE_NORMAL;
- }
- }
- return false;
- }
-
- public function getDrops(Item $item, Player $player){
- if($item->isShovel() !== false){
- return array(
- array(SNOWBALL, 0, 1),
- );
- }
- }
-}
\ No newline at end of file
diff --git a/src/material/block/nonfull/StoneWallBlock.php b/src/material/block/nonfull/StoneWallBlock.php
deleted file mode 100644
index 1856ecaa..00000000
--- a/src/material/block/nonfull/StoneWallBlock.php
+++ /dev/null
@@ -1,17 +0,0 @@
-isFullBlock = false;
- $this->isSolid = false;
- $this->hardness = 30;
- }
-
- public function getDrops(Item $item, Player $player){
- if($item->isPickaxe()){
- return [[COBBLESTONE_WALL, $this->getMetadata(), 1]];
- }
- return [];
- }
-}
\ No newline at end of file
diff --git a/src/material/block/nonfull/WoodDoorBlock.php b/src/material/block/nonfull/WoodDoorBlock.php
deleted file mode 100644
index 2d411264..00000000
--- a/src/material/block/nonfull/WoodDoorBlock.php
+++ /dev/null
@@ -1,15 +0,0 @@
-isActivable = true;
- $this->hardness = 15;
- }
-
- public function getDrops(Item $item, Player $player){
- return array(
- array(WOODEN_DOOR, 0, 1),
- );
- }
-}
diff --git a/src/material/block/nonfull/WoodSlabBlock.php b/src/material/block/nonfull/WoodSlabBlock.php
deleted file mode 100644
index 3bd9f6dc..00000000
--- a/src/material/block/nonfull/WoodSlabBlock.php
+++ /dev/null
@@ -1,90 +0,0 @@
- "Oak",
- 1 => "Spruce",
- 2 => "Birch",
- 3 => "Jungle",
- 4 => "Acacia",
- 5 => "Dark Oak"
- );
- $this->name = (($this->meta & 0x08) === 0x08 ? "Upper ":"") . $names[$this->meta & 0x07] . " Wooden Slab";
- if(($this->meta & 0x08) === 0x08){
- $this->isFullBlock = true;
- }else{
- $this->isFullBlock = false;
- }
- $this->hardness = 15;
- }
-
- public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
- $this->meta &= 0x07;
- if($face === 0){
- if($target->getID() === WOOD_SLAB and ($target->getMetadata() & 0x08) === 0x08 and ($target->getMetadata() & 0x07) === ($this->meta & 0x07)){
- $this->level->setBlock($target, BlockAPI::get(DOUBLE_WOOD_SLAB, $this->meta), true, false, true);
- return true;
- }elseif($block->getID() === WOOD_SLAB and ($block->getMetadata() & 0x07) === ($this->meta & 0x07)){
- $this->level->setBlock($block, BlockAPI::get(DOUBLE_WOOD_SLAB, $this->meta), true, false, true);
- return true;
- }else{
- $this->meta |= 0x08;
- }
- }elseif($face === 1){
- if($target->getID() === WOOD_SLAB and ($target->getMetadata() & 0x08) === 0 and ($target->getMetadata() & 0x07) === ($this->meta & 0x07)){
- $this->level->setBlock($target, BlockAPI::get(DOUBLE_WOOD_SLAB, $this->meta), true, false, true);
- return true;
- }elseif($block->getID() === WOOD_SLAB and ($block->getMetadata() & 0x07) === ($this->meta & 0x07)){
- $this->level->setBlock($block, BlockAPI::get(DOUBLE_WOOD_SLAB, $this->meta), true, false, true);
- return true;
- }
- }elseif(!$player->entity->inBlock($block)){
- if($block->getID() === WOOD_SLAB){
- if(($block->getMetadata() & 0x07) === ($this->meta & 0x07)){
- $this->level->setBlock($block, BlockAPI::get(DOUBLE_WOOD_SLAB, $this->meta), true, false, true);
- return true;
- }
- return false;
- }else{
- if($fy > 0.5){
- $this->meta |= 0x08;
- }
- }
- }else{
- return false;
- }
- if($block->getID() === WOOD_SLAB and ($target->getMetadata() & 0x07) !== ($this->meta & 0x07)){
- return false;
- }
- $this->level->setBlock($block, $this, true, false, true);
- return true;
- }
-
- public function getBreakTime(Item $item, Player $player){
- if(($player->gamemode & 0x01) === 0x01){
- return 0.20;
- }
- switch($item->isAxe()){
- case 5:
- return 0.4;
- case 4:
- return 0.5;
- case 3:
- return 0.75;
- case 2:
- return 0.25;
- case 1:
- return 1.5;
- default:
- return 3;
- }
- }
-
- public function getDrops(Item $item, Player $player){
- return array(
- array($this->id, $this->meta & 0x07, 1),
- );
- }
-}
\ No newline at end of file
diff --git a/src/material/block/nonfull/stairs/AcaciaWoodStairsBlock.php b/src/material/block/nonfull/stairs/AcaciaWoodStairsBlock.php
deleted file mode 100644
index 97ab5d1e..00000000
--- a/src/material/block/nonfull/stairs/AcaciaWoodStairsBlock.php
+++ /dev/null
@@ -1,33 +0,0 @@
-gamemode & 0x01) === 0x01){
- return 0.20;
- }
- switch($item->isAxe()){
- case 5:
- return 0.4;
- case 4:
- return 0.5;
- case 3:
- return 0.75;
- case 2:
- return 0.25;
- case 1:
- return 1.5;
- default:
- return 3;
- }
- }
-
- public function getDrops(Item $item, Player $player){
- return array(
- array($this->id, 0, 1),
- );
- }
-}
\ No newline at end of file
diff --git a/src/material/block/nonfull/stairs/BirchWoodStairsBlock.php b/src/material/block/nonfull/stairs/BirchWoodStairsBlock.php
deleted file mode 100644
index c15f361d..00000000
--- a/src/material/block/nonfull/stairs/BirchWoodStairsBlock.php
+++ /dev/null
@@ -1,33 +0,0 @@
-gamemode & 0x01) === 0x01){
- return 0.20;
- }
- switch($item->isAxe()){
- case 5:
- return 0.4;
- case 4:
- return 0.5;
- case 3:
- return 0.75;
- case 2:
- return 0.25;
- case 1:
- return 1.5;
- default:
- return 3;
- }
- }
-
- public function getDrops(Item $item, Player $player){
- return array(
- array($this->id, 0, 1),
- );
- }
-}
\ No newline at end of file
diff --git a/src/material/block/nonfull/stairs/BrickStairsBlock.php b/src/material/block/nonfull/stairs/BrickStairsBlock.php
deleted file mode 100644
index f295924e..00000000
--- a/src/material/block/nonfull/stairs/BrickStairsBlock.php
+++ /dev/null
@@ -1,8 +0,0 @@
-gamemode & 0x01) === 0x01){
- return 0.20;
- }
- switch($item->isAxe()){
- case 5:
- return 0.4;
- case 4:
- return 0.5;
- case 3:
- return 0.75;
- case 2:
- return 0.25;
- case 1:
- return 1.5;
- default:
- return 3;
- }
- }
-
- public function getDrops(Item $item, Player $player){
- return array(
- array($this->id, 0, 1),
- );
- }
-}
\ No newline at end of file
diff --git a/src/material/block/nonfull/stairs/JungleWoodStairsBlock.php b/src/material/block/nonfull/stairs/JungleWoodStairsBlock.php
deleted file mode 100644
index fd52b4ae..00000000
--- a/src/material/block/nonfull/stairs/JungleWoodStairsBlock.php
+++ /dev/null
@@ -1,33 +0,0 @@
-gamemode & 0x01) === 0x01){
- return 0.20;
- }
- switch($item->isAxe()){
- case 5:
- return 0.4;
- case 4:
- return 0.5;
- case 3:
- return 0.75;
- case 2:
- return 0.25;
- case 1:
- return 1.5;
- default:
- return 3;
- }
- }
-
- public function getDrops(Item $item, Player $player){
- return array(
- array($this->id, 0, 1),
- );
- }
-}
\ No newline at end of file
diff --git a/src/material/block/nonfull/stairs/NetherBricksStairsBlock.php b/src/material/block/nonfull/stairs/NetherBricksStairsBlock.php
deleted file mode 100644
index f7702777..00000000
--- a/src/material/block/nonfull/stairs/NetherBricksStairsBlock.php
+++ /dev/null
@@ -1,8 +0,0 @@
-gamemode & 0x01) === 0x01){
- return 0.20;
- }
- switch($item->isAxe()){
- case 5:
- return 0.4;
- case 4:
- return 0.5;
- case 3:
- return 0.75;
- case 2:
- return 0.25;
- case 1:
- return 1.5;
- default:
- return 3;
- }
- }
-
- public function getDrops(Item $item, Player $player){
- return array(
- array($this->id, 0, 1),
- );
- }
-}
\ No newline at end of file
diff --git a/src/material/block/nonfull/stairs/StoneBrickStairsBlock.php b/src/material/block/nonfull/stairs/StoneBrickStairsBlock.php
deleted file mode 100644
index fcf556cd..00000000
--- a/src/material/block/nonfull/stairs/StoneBrickStairsBlock.php
+++ /dev/null
@@ -1,8 +0,0 @@
-gamemode & 0x01) === 0x01){
- return 0.20;
- }
- switch($item->isAxe()){
- case 5:
- return 0.4;
- case 4:
- return 0.5;
- case 3:
- return 0.75;
- case 2:
- return 0.25;
- case 1:
- return 1.5;
- default:
- return 3;
- }
- }
-
- public function getDrops(Item $item, Player $player){
- return array(
- array($this->id, 0, 1),
- );
- }
-}
\ No newline at end of file
diff --git a/src/material/block/ore/CoalOreBlock.php b/src/material/block/ore/CoalOreBlock.php
deleted file mode 100644
index ebd90cea..00000000
--- a/src/material/block/ore/CoalOreBlock.php
+++ /dev/null
@@ -1,39 +0,0 @@
-hardness = 15;
- }
-
- public function getBreakTime(Item $item, Player $player){
- if(($player->gamemode & 0x01) === 0x01){
- return 0.20;
- }
- switch($item->getPickaxeLevel()){
- case 5:
- return 0.6;
- case 4:
- return 0.75;
- case 3:
- return 1.15;
- case 2:
- return 0.4;
- case 1:
- return 2.25;
- default:
- return 15;
- }
- }
-
- public function getDrops(Item $item, Player $player){
- if($item->getPickaxeLevel() >= 1){
- return array(
- array(COAL, 0, 1),
- );
- }else{
- return array();
- }
- }
-
-}
\ No newline at end of file
diff --git a/src/material/block/ore/DiamondOreBlock.php b/src/material/block/ore/DiamondOreBlock.php
deleted file mode 100644
index 03cb0605..00000000
--- a/src/material/block/ore/DiamondOreBlock.php
+++ /dev/null
@@ -1,32 +0,0 @@
-hardness = 15;
- }
-
- public function getBreakTime(Item $item, Player $player){
- if(($player->gamemode & 0x01) === 0x01){
- return 0.20;
- }
- switch($item->getPickaxeLevel()){
- case 5:
- return 0.6;
- case 4:
- return 0.75;
- default:
- return 15;
- }
- }
-
- public function getDrops(Item $item, Player $player){
- if($item->getPickaxeLevel() >= 4){
- return array(
- array(DIAMOND, 0, 1),
- );
- }else{
- return array();
- }
- }
-}
\ No newline at end of file
diff --git a/src/material/block/ore/EmeraldOreBlock.php b/src/material/block/ore/EmeraldOreBlock.php
deleted file mode 100644
index 0a0e8dde..00000000
--- a/src/material/block/ore/EmeraldOreBlock.php
+++ /dev/null
@@ -1,32 +0,0 @@
-hardness = 15;
- }
-
- public function getBreakTime(Item $item, Player $player){
- if(($player->gamemode & 0x01) === 0x01){
- return 0.20;
- }
- switch($item->getPickaxeLevel()){
- case 5:
- return 0.6;
- case 4:
- return 0.75;
- default:
- return 15;
- }
- }
-
- public function getDrops(Item $item, Player $player){
- if($item->getPickaxeLevel() >= 4){
- return array(
- array(EMERALD, 0, 1),
- );
- }else{
- return array();
- }
- }
-}
\ No newline at end of file
diff --git a/src/material/block/ore/GlowingRedstoneOreBlock.php b/src/material/block/ore/GlowingRedstoneOreBlock.php
deleted file mode 100644
index b360c6be..00000000
--- a/src/material/block/ore/GlowingRedstoneOreBlock.php
+++ /dev/null
@@ -1,46 +0,0 @@
-hardness = 15;
- }
-
- public function onUpdate($type){
- if($type === BLOCK_UPDATE_SCHEDULED or $type === BLOCK_UPDATE_RANDOM){
- $this->level->setBlock($this, BlockAPI::get(REDSTONE_ORE, $this->meta), false, false, true);
- return BLOCK_UPDATE_WEAK;
- }else{
- $this->level->scheduleBlockUpdate(new Position($this, 0, 0, $this->level), Utils::getRandomUpdateTicks(), BLOCK_UPDATE_RANDOM);
- }
- return false;
- }
- public function getMaxLightValue(){
- return 9;
- }
-
- public function getBreakTime(Item $item, Player $player){
- if(($player->gamemode & 0x01) === 0x01){
- return 0.20;
- }
- switch($item->getPickaxeLevel()){
- case 5:
- return 0.6;
- case 4:
- return 0.75;
- default:
- return 15;
- }
- }
-
- public function getDrops(Item $item, Player $player){
- if($item->getPickaxeLevel() >= 4){
- return array(
- array(REDSTONE_DUST, 0, mt_rand(4, 5)),
- );
- }else{
- return array();
- }
- }
-
-}
\ No newline at end of file
diff --git a/src/material/block/ore/GoldOreBlock.php b/src/material/block/ore/GoldOreBlock.php
deleted file mode 100644
index f82b8698..00000000
--- a/src/material/block/ore/GoldOreBlock.php
+++ /dev/null
@@ -1,32 +0,0 @@
-hardness = 15;
- }
-
- public function getBreakTime(Item $item, Player $player){
- if(($player->gamemode & 0x01) === 0x01){
- return 0.20;
- }
- switch($item->getPickaxeLevel()){
- case 5:
- return 0.6;
- case 4:
- return 0.75;
- default:
- return 15;
- }
- }
-
- public function getDrops(Item $item, Player $player){
- if($item->getPickaxeLevel() >= 4){
- return array(
- array(GOLD_ORE, 0, 1),
- );
- }else{
- return array();
- }
- }
-}
\ No newline at end of file
diff --git a/src/material/block/ore/IronOreBlock.php b/src/material/block/ore/IronOreBlock.php
deleted file mode 100644
index 7d173153..00000000
--- a/src/material/block/ore/IronOreBlock.php
+++ /dev/null
@@ -1,34 +0,0 @@
-hardness = 15;
- }
-
- public function getBreakTime(Item $item, Player $player){
- if(($player->gamemode & 0x01) === 0x01){
- return 0.20;
- }
- switch($item->getPickaxeLevel()){
- case 5:
- return 0.6;
- case 4:
- return 0.75;
- case 3:
- return 1.15;
- default:
- return 15;
- }
- }
-
- public function getDrops(Item $item, Player $player){
- if($item->getPickaxeLevel() >= 3){
- return array(
- array(IRON_ORE, 0, 1),
- );
- }else{
- return array();
- }
- }
-}
\ No newline at end of file
diff --git a/src/material/block/ore/LapisOreBlock.php b/src/material/block/ore/LapisOreBlock.php
deleted file mode 100644
index 58782f0c..00000000
--- a/src/material/block/ore/LapisOreBlock.php
+++ /dev/null
@@ -1,35 +0,0 @@
-hardness = 15;
- }
-
- public function getBreakTime(Item $item, Player $player){
- if(($player->gamemode & 0x01) === 0x01){
- return 0.20;
- }
- switch($item->getPickaxeLevel()){
- case 5:
- return 0.6;
- case 4:
- return 0.75;
- case 3:
- return 1.15;
- default:
- return 15;
- }
- }
-
- public function getDrops(Item $item, Player $player){
- if($item->getPickaxeLevel() >= 3){
- return array(
- array(DYE, 4, mt_rand(4, 8)),
- );
- }else{
- return array();
- }
- }
-
-}
\ No newline at end of file
diff --git a/src/material/block/ore/RedstoneOreBlock.php b/src/material/block/ore/RedstoneOreBlock.php
deleted file mode 100644
index 499a580e..00000000
--- a/src/material/block/ore/RedstoneOreBlock.php
+++ /dev/null
@@ -1,27 +0,0 @@
-hardness = 15;
- }
-
- public function onUpdate($type){
- if($type === BLOCK_UPDATE_NORMAL or $type === BLOCK_UPDATE_TOUCH){
- $this->level->setBlock($this, BlockAPI::get(GLOWING_REDSTONE_ORE, $this->meta), false, false, true);
- $this->level->scheduleBlockUpdate(new Position($this, 0, 0, $this->level), Utils::getRandomUpdateTicks(), BLOCK_UPDATE_RANDOM);
- return BLOCK_UPDATE_WEAK;
- }
- return false;
- }
-
- public function getDrops(Item $item, Player $player){
- if($item->getPickaxeLevel() >= 4){
- return array(
- array(REDSTONE_DUST, 0, mt_rand(4, 5)),
- );
- }else{
- return array();
- }
- }
-}
\ No newline at end of file
diff --git a/src/material/block/plant/BeetrootBlock.php b/src/material/block/plant/BeetrootBlock.php
deleted file mode 100644
index 8fdfd55e..00000000
--- a/src/material/block/plant/BeetrootBlock.php
+++ /dev/null
@@ -1,68 +0,0 @@
-isActivable = true;
- $this->hardness = 0;
- }
-
- public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
- $down = $this->getSide(0);
- if($down->getID() === FARMLAND){
- $this->level->setBlock($block, $this, true, false, true);
- $this->level->scheduleBlockUpdate(new Position($this, 0, 0, $this->level), Utils::getRandomUpdateTicks(), BLOCK_UPDATE_RANDOM);
- return true;
- }
- return false;
- }
-
- public function onActivate(Item $item, Player $player){
- if($item->getID() === DYE and $item->getMetadata() === 0x0F){ //Bonemeal
- $this->meta += mt_rand(0, 3) + 2;
- if ($this->meta > 7) {
- $this->meta = 7;
- }
- $this->level->setBlock($this, $this, true, false, true);
- if(($player->gamemode & 0x01) === 0){
- $player->removeItem(DYE,0x0F,1);
- }
- return true;
- }
- return false;
- }
-
- public function onUpdate($type){
- if($type === BLOCK_UPDATE_NORMAL){
- if($this->getSide(0)->getID() != 60){
- ServerAPI::request()->api->entity->drop(new Position($this->x + 0.5, $this->y, $this->z + 0.5, $this->level), BlockAPI::getItem(BEETROOT_SEEDS, 0, 1));
- $this->level->setBlock($this, new AirBlock(), false, false, true);
- return BLOCK_UPDATE_NORMAL;
- }
- }elseif($type === BLOCK_UPDATE_RANDOM){
- if(mt_rand(0, 2) == 1){
- if($this->meta < 0x07){
- ++$this->meta;
- $this->level->setBlock($this, $this, true, false, true);
- return BLOCK_UPDATE_RANDOM;
- }
- }else{
- return BLOCK_UPDATE_RANDOM;
- }
- }
- return false;
- }
-
- public function getDrops(Item $item, Player $player){
- $drops = [];
- if($this->meta >= 0x07){
- $drops[] = [BEETROOT, 0, 1];
- }
- for($i = 0; $i < 3; ++$i){
- if(mt_rand(0, 15) <= $this->meta){ //a way from 1.4.7
- $drops[] = [BEETROOT_SEEDS, 0, 1];
- }
- }
- return $drops;
- }
-}
\ No newline at end of file
diff --git a/src/material/block/plant/BrownMushroomBlock.php b/src/material/block/plant/BrownMushroomBlock.php
deleted file mode 100644
index 85cb771c..00000000
--- a/src/material/block/plant/BrownMushroomBlock.php
+++ /dev/null
@@ -1,28 +0,0 @@
-hardness = 0;
- }
-
- public function onUpdate($type){
- if($type === BLOCK_UPDATE_NORMAL){
- if($this->getSide(0)->isTransparent === true){ //Replace with common break method
- ServerAPI::request()->api->entity->drop(new Position($this->x+0.5, $this->y, $this->z+0.5, $this->level), BlockAPI::getItem($this->id));
- $this->level->setBlock($this, new AirBlock(), false, false, true);
- return BLOCK_UPDATE_NORMAL;
- }
- }
- return false;
- }
-
- public function place(Item $item, 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);
- return true;
- }
- return false;
- }
-}
\ No newline at end of file
diff --git a/src/material/block/plant/CactusBlock.php b/src/material/block/plant/CactusBlock.php
deleted file mode 100644
index 310b46e4..00000000
--- a/src/material/block/plant/CactusBlock.php
+++ /dev/null
@@ -1,66 +0,0 @@
-isFullBlock = false;
- $this->hardness = 2;
- }
-
- public function onUpdate($type){
- if($type === BLOCK_UPDATE_NORMAL){
- $down = $this->getSide(0);
- $block0 = $this->getSide(2);
- $block1 = $this->getSide(3);
- $block2 = $this->getSide(4);
- $block3 = $this->getSide(5);
- if($block0->isFlowable === false or $block1->isFlowable === false or $block2->isFlowable === false or $block3->isFlowable === false or ($down->getID() !== SAND and $down->getID() !== CACTUS)){ //Replace with common break method
- $this->level->setBlock($this, new AirBlock(), false);
- ServerAPI::request()->api->entity->drop(new Position($this->x + 0.5, $this->y, $this->z + 0.5, $this->level), BlockAPI::getItem($this->id));
- return BLOCK_UPDATE_NORMAL;
- }
- }elseif($type === BLOCK_UPDATE_RANDOM){
- if($this->getSide(0)->getID() !== CACTUS){
- if($this->meta == 0x0F){
- for($y = 1; $y < 3; ++$y){
- $b = $this->level->getBlock(new Vector3($this->x, $this->y + $y, $this->z));
- if($b->getID() === AIR){
- $this->level->setBlock($b, new CactusBlock(), true, false, true);
- break;
- }
- }
- $this->meta = 0;
- $this->level->setBlock($this, $this, false);
- }else{
- ++$this->meta;
- $this->level->setBlock($this, $this, false);
- }
- return BLOCK_UPDATE_RANDOM;
- }
- }
- return false;
- }
-
- public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
- $down = $this->getSide(0);
- if($down->getID() === SAND or $down->getID() === CACTUS){
- $block0 = $this->getSide(2);
- $block1 = $this->getSide(3);
- $block2 = $this->getSide(4);
- $block3 = $this->getSide(5);
- if($block0->isFlowable === true and $block1->isFlowable === true and $block2->isFlowable === true and $block3->isFlowable === true){
- $this->level->setBlock($this, $this, true, false, true);
- $this->level->scheduleBlockUpdate(new Position($this, 0, 0, $this->level), Utils::getRandomUpdateTicks(), BLOCK_UPDATE_RANDOM);
- ServerAPI::request()->api->block->scheduleBlockUpdate(clone $this, 10, BLOCK_UPDATE_NORMAL);
- return true;
- }
- }
- return false;
- }
-
- public function getDrops(Item $item, Player $player){
- return array(
- array($this->id, 0, 1),
- );
- }
-}
\ No newline at end of file
diff --git a/src/material/block/plant/CarrotBlock.php b/src/material/block/plant/CarrotBlock.php
deleted file mode 100644
index b2864855..00000000
--- a/src/material/block/plant/CarrotBlock.php
+++ /dev/null
@@ -1,66 +0,0 @@
-isActivable = true;
- $this->hardness = 0;
- }
-
- public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
- $down = $this->getSide(0);
- if($down->getID() === FARMLAND){
- $this->level->setBlock($block, $this, true, false, true);
- $this->level->scheduleBlockUpdate(new Position($this, 0, 0, $this->level), Utils::getRandomUpdateTicks(), BLOCK_UPDATE_RANDOM);
- return true;
- }
- return false;
- }
-
- public function onActivate(Item $item, Player $player){
- if($item->getID() === DYE and $item->getMetadata() === 0x0F){ //Bonemeal
- $this->meta += mt_rand(0, 3) + 2;
- if ($this->meta > 7) {
- $this->meta = 7;
- }
- $this->level->setBlock($this, $this, true, false, true);
- if(($player->gamemode & 0x01) === 0){
- $player->removeItem(DYE,0x0F,1);
- }
- return true;
- }
- return false;
- }
-
- public function onUpdate($type){
- if($type === BLOCK_UPDATE_NORMAL){
- if($this->getSide(0)->getID() != 60){
- ServerAPI::request()->api->entity->drop(new Position($this->x + 0.5, $this->y, $this->z + 0.5, $this->level), BlockAPI::getItem(CARROT, 0, 1));
- $this->level->setBlock($this, new AirBlock(), false, false, true);
- return BLOCK_UPDATE_NORMAL;
- }
- }elseif($type === BLOCK_UPDATE_RANDOM){
- if(mt_rand(0, 2) == 1){
- if($this->meta < 0x07){
- ++$this->meta;
- $this->level->setBlock($this, $this, true, false, true);
- return BLOCK_UPDATE_RANDOM;
- }
- }else{
- return BLOCK_UPDATE_RANDOM;
- }
- }
- return false;
- }
-
- public function getDrops(Item $item, Player $player){
- $drops = [];
- if($this->meta >= 0x07){
- $drops[] = [CARROT, 0, mt_rand(1, 4)];
- }
- else{
- $drops[] = [CARROT, 0, 1];
- }
- return $drops;
- }
-}
\ No newline at end of file
diff --git a/src/material/block/plant/CocoaBlock.php b/src/material/block/plant/CocoaBlock.php
deleted file mode 100644
index 229f60ca..00000000
--- a/src/material/block/plant/CocoaBlock.php
+++ /dev/null
@@ -1,65 +0,0 @@
- 0x00,
- 3 => 0x02,
- 4 => 0x03,
- 5 => 0x01
- ];
- public function __construct($meta = 0){
- parent::__construct(COCOA, $meta, "tile.cocoa.name<");
- $this->isActivable = true;
- $this->hardness = 0;
- }
-
- public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
- if($face === 0 || $face === 1){
- return false; //fix of placing invalid ids without array
- }
- if($target->isTransparent === false){
- $this->level->setBlock($this, BlockAPI::get($this->id, self::$faces[$face]), true, false, true);
- return true;
- }
- return false;
- }
-
- public function onActivate(Item $item, Player $player){
- if($this->getGrowthStage() < 0x02 && $item->getID() === DYE and $item->getMetadata() === 0x0F){ //Bonemeal
- $this->meta += 0b0100; //TODO limit
- $this->level->setBlock($this, $this, true, false, true);
- if(($player->gamemode & 0x01) === 0){
- $player->removeItem(DYE, 0x0F, 1);
- }
- return true;
- }
- return false;
- }
-
- public function onUpdate($type){
- if($type === BLOCK_UPDATE_RANDOM){
- if(mt_rand(0, 2) == 1){
- if($this->getGrowthStage() < 0x02){
- $this->meta += 0b0100;
- $this->level->setBlock($this, $this, true, false, true);
- return BLOCK_UPDATE_RANDOM;
- }
- }else{
- return BLOCK_UPDATE_RANDOM;
- }
- }
- return false;
- }
- public function getGrowthStage(){
- return $this->meta >> 2;
- }
- public function getDrops(Item $item, Player $player){
- $drops = [];
- if($this->getGrowthStage() >= 0x02){ //hum?
- $drops[] = [DYE, 3, mt_rand(1, 4)];
- }else{
- $drops[] = [DYE, 3, 1];
- }
- return $drops;
- }
-}
diff --git a/src/material/block/plant/CyanFlowerBlock.php b/src/material/block/plant/CyanFlowerBlock.php
deleted file mode 100644
index c4c276ef..00000000
--- a/src/material/block/plant/CyanFlowerBlock.php
+++ /dev/null
@@ -1,39 +0,0 @@
- "Poppy",
- 1 => "Blue Orchid",
- 2 => "Allium",
- 3 => "Azure Bluet",
- 4 => "Red Tulip",
- 5 => "Orange Tulip",
- 6 => "White Tulip",
- 7 => "Pink Tulip",
- 8 => "Oxeye Daisy",
- ];
- public function __construct($meta = 0){
- parent::__construct(CYAN_FLOWER, $meta, self::$names[$meta] ?? "Poppy");
- $this->hardness = 0;
- }
-
- public function place(Item $item, 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);
- return true;
- }
- return false;
- }
-
- public function onUpdate($type){
- if($type === BLOCK_UPDATE_NORMAL){
- if($this->getSide(0)->isTransparent === true){ //Replace with common break method
- ServerAPI::request()->api->entity->drop(new Position($this->x + 0.5, $this->y, $this->z + 0.5, $this->level), BlockAPI::getItem($this->id));
- $this->level->setBlock($this, new AirBlock(), false, false, true);
- return BLOCK_UPDATE_NORMAL;
- }
- }
- return false;
- }
-}
\ No newline at end of file
diff --git a/src/material/block/plant/DandelionBlock.php b/src/material/block/plant/DandelionBlock.php
deleted file mode 100644
index 5d352a67..00000000
--- a/src/material/block/plant/DandelionBlock.php
+++ /dev/null
@@ -1,28 +0,0 @@
-hardness = 0;
- }
-
- public function place(Item $item, 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);
- return true;
- }
- return false;
- }
-
- public function onUpdate($type){
- if($type === BLOCK_UPDATE_NORMAL){
- if($this->getSide(0)->isTransparent === true){ //Replace with common break method
- ServerAPI::request()->api->entity->drop(new Position($this->x+0.5, $this->y, $this->z+0.5, $this->level), BlockAPI::getItem($this->id));
- $this->level->setBlock($this, new AirBlock(), false, false, true);
- return BLOCK_UPDATE_NORMAL;
- }
- }
- return false;
- }
-}
\ No newline at end of file
diff --git a/src/material/block/plant/DeadBushBlock.php b/src/material/block/plant/DeadBushBlock.php
deleted file mode 100644
index fac37637..00000000
--- a/src/material/block/plant/DeadBushBlock.php
+++ /dev/null
@@ -1,36 +0,0 @@
-isReplaceable = true;
- $this->hardness = 0;
- }
-
- public function onUpdate($type){
- if($type === BLOCK_UPDATE_NORMAL){
- if($this->getSide(0)->isTransparent === true){ //Replace with common break method
- $this->level->setBlock($this, new AirBlock(), false, false, true);
- return BLOCK_UPDATE_NORMAL;
- }
- }
- return false;
- }
-
- public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
- $down = $this->getSide(0);
- if($down->getID() == 12){
- $this->level->setBlock($block, $this, true, false, true);
- return true;
- }
- return false;
- }
-
- public function getDrops(Item $item, Player $player){
- if($item->isShears()){
- return array(
- array(DEAD_BUSH, 0, 1),
- );
- }
- }
-}
\ No newline at end of file
diff --git a/src/material/block/plant/DoubleTallGrass.php b/src/material/block/plant/DoubleTallGrass.php
deleted file mode 100644
index ea9f1b8a..00000000
--- a/src/material/block/plant/DoubleTallGrass.php
+++ /dev/null
@@ -1,44 +0,0 @@
- "Sunflower",
- 1 => "Lilac",
- 2 => "Tall Grass",
- 3 => "Tall Fern",
- 4 => "Rose Bush",
- 5 => "Peony",
- ];
- public function __construct($meta = 1){
- parent::__construct(DOUBLE_PLANT, $meta, "Tall Grass");
- $this->name = self::$NAMES[$this->meta] ?? "Tall Grass";
- $this->hardness = 0;
- }
-
- public function onUpdate($type){
- if($type === BLOCK_UPDATE_NORMAL){ //TODO destroy if 2nd block occupied
- //if($this->meta & 0x8 == 0 && $this->getSide(0)->isTransparent === true){ //Replace with common break method
- ///$this->level->setBlock($this, new AirBlock(), false, false, true);
- //return BLOCK_UPDATE_NORMAL;
- //} //TODO fix
- }
- return false;
- }
-
- public function getDrops(Item $item, Player $player){ //TODO vanilla?
- return [];
- }
-
- public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
- $down = $this->getSide(0);
- if($down->getID() == 2 or $down->getID() == 3){ //TODO destroy the block above(tested only in creative)
- $this->level->setBlock($block, $this, true, false, true);
- $this->level->setBlock($block->add(0, 1, 0), new DoubleTallGrass($this->meta ^ 0x8), true, false, true);
- return true;
- }
- return false;
- }
-
-}
-
diff --git a/src/material/block/plant/LilypadBlock.php b/src/material/block/plant/LilypadBlock.php
deleted file mode 100644
index 403bce34..00000000
--- a/src/material/block/plant/LilypadBlock.php
+++ /dev/null
@@ -1,13 +0,0 @@
-isSolid = false;
- $this->isFullBlock = false;
- }
-
- public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){//TODO: directions & only on water placement, im too lazy to make it cuz it's 0:17
- $this->level->setBlock($block, $this, true, false, true);
- }
-}
\ No newline at end of file
diff --git a/src/material/block/plant/MelonStemBlock.php b/src/material/block/plant/MelonStemBlock.php
deleted file mode 100644
index f877bf27..00000000
--- a/src/material/block/plant/MelonStemBlock.php
+++ /dev/null
@@ -1,79 +0,0 @@
-isActivable = true;
- $this->hardness = 0;
- }
- public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
- $down = $this->getSide(0);
- if($down->getID() === FARMLAND){
- $this->level->setBlock($block, $this, true, false, true);
- $this->level->scheduleBlockUpdate(new Position($this, 0, 0, $this->level), Utils::getRandomUpdateTicks(), BLOCK_UPDATE_RANDOM);
- return true;
- }
- return false;
- }
-
- public function onUpdate($type){
- if($type === BLOCK_UPDATE_NORMAL){
- if($this->getSide(0)->getID() != 60){
- ServerAPI::request()->api->entity->drop(new Position($this->x+0.5, $this->y, $this->z+0.5, $this->level), BlockAPI::getItem(MELON_SEEDS, 0, mt_rand(0, 2)));
- $this->level->setBlock($this, new AirBlock(), false, false, true);
- return BLOCK_UPDATE_NORMAL;
- }
- }elseif($type === BLOCK_UPDATE_RANDOM){
- if(mt_rand(0, 2) == 1){
- if($this->meta < 0x07){
- ++$this->meta;
- $this->level->setBlock($this, $this, true, false, true);
- return BLOCK_UPDATE_RANDOM;
- }else{
- for($side = 2; $side <= 5; ++$side){
- $b = $this->getSide($side);
- if($b->getID() === MELON_BLOCK){
- return BLOCK_UPDATE_RANDOM;
- }
- }
- $side = $this->getSide(mt_rand(2,5));
- $d = $side->getSide(0);
- if($side->getID() === AIR and ($d->getID() === FARMLAND or $d->getID() === GRASS or $d->getID() === DIRT)){
- $this->level->setBlock($side, new MelonBlock(), true, false, true);
- }
- }
- }
- return BLOCK_UPDATE_RANDOM;
- }
- return false;
- }
-
- public function onActivate(Item $item, Player $player){
- if($item->getID() === DYE and $item->getMetadata() === 0x0F){ //Bonemeal
- $this->meta += mt_rand(0, 3) + 2;
- if ($this->meta > 7) {
- $this->meta = 7;
- }
- $this->level->setBlock($this, $this, true, false, true);
- if(($player->gamemode & 0x01) === 0){
- $player->removeItem(DYE,0x0F,1);
- }
- return true;
- }
- return false;
- }
-
- public function getDrops(Item $item, Player $player){
- $drops = [];
- if($this->meta >= 0x07){
- $drops[] = [MELON_SEEDS, 0, mt_rand(1, 2)];
- }
- elseif($this->meta >= 0x01 and $this->meta <= 0x07){
- $drops[] = [MELON_SEEDS, 0, 1];
- }
- else{
- $drops[] = [MELON_SEEDS, 0, 0];
- }
- return $drops;
- }
-}
\ No newline at end of file
diff --git a/src/material/block/plant/PotatoBlock.php b/src/material/block/plant/PotatoBlock.php
deleted file mode 100644
index ec1bd3e6..00000000
--- a/src/material/block/plant/PotatoBlock.php
+++ /dev/null
@@ -1,65 +0,0 @@
-isActivable = true;
- $this->hardness = 0;
- }
-
- public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
- $down = $this->getSide(0);
- if($down->getID() === FARMLAND){
- $this->level->setBlock($block, $this, true, false, true);
- $this->level->scheduleBlockUpdate(new Position($this, 0, 0, $this->level), Utils::getRandomUpdateTicks(), BLOCK_UPDATE_RANDOM);
- return true;
- }
- return false;
- }
-
- public function onActivate(Item $item, Player $player){
- if($item->getID() === DYE and $item->getMetadata() === 0x0F){ //Bonemeal
- $this->meta += mt_rand(0, 3) + 2;
- if ($this->meta > 7) {
- $this->meta = 7;
- }
- $this->level->setBlock($this, $this, true, false, true);
- if(($player->gamemode & 0x01) === 0){
- $player->removeItem(DYE,0x0F,1);
- }
- return true;
- }
- return false;
- }
-
- public function onUpdate($type){
- if($type === BLOCK_UPDATE_NORMAL){
- if($this->getSide(0)->getID() != 60){
- ServerAPI::request()->api->entity->drop(new Position($this->x + 0.5, $this->y, $this->z + 0.5, $this->level), BlockAPI::getItem(POTATO, 0, 1));
- $this->level->setBlock($this, new AirBlock(), false, false, true);
- return BLOCK_UPDATE_NORMAL;
- }
- }elseif($type === BLOCK_UPDATE_RANDOM){
- if(mt_rand(0, 2) == 1){
- if($this->meta < 0x07){
- ++$this->meta;
- $this->level->setBlock($this, $this, true, false, true);
- return BLOCK_UPDATE_RANDOM;
- }
- }else{
- return BLOCK_UPDATE_RANDOM;
- }
- }
- return false;
- }
-
- public function getDrops(Item $item, Player $player){
- $drops = [];
- if($this->meta >= 0x07){
- $drops[] = [POTATO, 0, mt_rand(1, 4)];
- }else{
- $drops[] = [POTATO, 0, 1];
- }
- return $drops;
- }
-}
\ No newline at end of file
diff --git a/src/material/block/plant/PumpkinStemBlock.php b/src/material/block/plant/PumpkinStemBlock.php
deleted file mode 100644
index 68444084..00000000
--- a/src/material/block/plant/PumpkinStemBlock.php
+++ /dev/null
@@ -1,79 +0,0 @@
-isActivable = true;
- $this->hardness = 0;
- }
- public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
- $down = $this->getSide(0);
- if($down->getID() === FARMLAND){
- $this->level->setBlock($block, $this, true, false, true);
- $this->level->scheduleBlockUpdate(new Position($this, 0, 0, $this->level), Utils::getRandomUpdateTicks(), BLOCK_UPDATE_RANDOM);
- return true;
- }
- return false;
- }
-
- public function onUpdate($type){
- if($type === BLOCK_UPDATE_NORMAL){
- if($this->getSide(0)->getID() != 60){
- ServerAPI::request()->api->entity->drop(new Position($this->x + 0.5, $this->y, $this->z + 0.5, $this->level), BlockAPI::getItem(PUMPKIN_SEEDS, 0, mt_rand(0, 2)));
- $this->level->setBlock($this, new AirBlock(), false, false, true);
- return BLOCK_UPDATE_NORMAL;
- }
- }elseif($type === BLOCK_UPDATE_RANDOM){
- if(mt_rand(0, 2) == 1){
- if($this->meta < 0x07){
- ++$this->meta;
- $this->level->setBlock($this, $this, true, false, true);
- return BLOCK_UPDATE_RANDOM;
- }else{
- for($side = 2; $side <= 5; ++$side){
- $b = $this->getSide($side);
- if($b->getID() === PUMPKIN){
- return BLOCK_UPDATE_RANDOM;
- }
- }
- $side = $this->getSide(mt_rand(2,5));
- $d = $side->getSide(0);
- if($side->getID() === AIR and ($d->getID() === FARMLAND or $d->getID() === GRASS or $d->getID() === DIRT)){
- $this->level->setBlock($side, new PumpkinBlock(), true, false, true);
- }
- }
- }
- return BLOCK_UPDATE_RANDOM;
- }
- return false;
- }
-
- public function onActivate(Item $item, Player $player){
- if($item->getID() === DYE and $item->getMetadata() === 0x0F){ //Bonemeal
- $this->meta += mt_rand(0, 3) + 2;
- if ($this->meta > 7) {
- $this->meta = 7;
- }
- $this->level->setBlock($this, $this, true, false, true);
- if(($player->gamemode & 0x01) === 0){
- $player->removeItem(DYE,0x0F,1);
- }
- return true;
- }
- return false;
- }
-
- public function getDrops(Item $item, Player $player){
- $drops = [];
- if($this->meta >= 0x07){
- $drops[] = [PUMPKIN_SEEDS, 0, mt_rand(1, 2)];
- }
- elseif($this->meta >= 0x01 and $this->meta <= 0x07){
- $drops[] = [PUMPKIN_SEEDS, 0, 1];
- }
- else{
- $drops[] = [PUMPKIN_SEEDS, 0, 0];
- }
- return $drops;
- }
-}
\ No newline at end of file
diff --git a/src/material/block/plant/RedMushroomBlock.php b/src/material/block/plant/RedMushroomBlock.php
deleted file mode 100644
index c9f43b7b..00000000
--- a/src/material/block/plant/RedMushroomBlock.php
+++ /dev/null
@@ -1,28 +0,0 @@
-hardness = 0;
- }
-
- public function onUpdate($type){
- if($type === BLOCK_UPDATE_NORMAL){
- if($this->getSide(0)->isTransparent === true){ //Replace with common break method
- ServerAPI::request()->api->entity->drop(new Position($this->x+0.5, $this->y, $this->z+0.5, $this->level), BlockAPI::getItem($this->id));
- $this->level->setBlock($this, new AirBlock(), false);
- return BLOCK_UPDATE_NORMAL;
- }
- }
- return false;
- }
-
- public function place(Item $item, 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);
- return true;
- }
- return false;
- }
-}
\ No newline at end of file
diff --git a/src/material/block/plant/SaplingBlock.php b/src/material/block/plant/SaplingBlock.php
deleted file mode 100644
index ed4319aa..00000000
--- a/src/material/block/plant/SaplingBlock.php
+++ /dev/null
@@ -1,75 +0,0 @@
-isActivable = true;
- $names = array(
- 0 => "Oak Sapling",
- 1 => "Spruce Sapling",
- 2 => "Birch Sapling",
- 3 => "Jungle Sapling",
- 4 => "Acacia Sapling",
- 5 => "Dark Oak Sapling",
- );
- $this->name = $names[$this->meta & 0x07];
- $this->hardness = 0;
- }
-
- public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
- $down = $this->getSide(0);
- if($down->getID() === GRASS or $down->getID() === DIRT or $down->getID() === FARMLAND){
- $this->level->setBlock($block, $this, true, false, true);
- $this->level->scheduleBlockUpdate(new Position($this, 0, 0, $this->level), Utils::getRandomUpdateTicks(), BLOCK_UPDATE_RANDOM);
- return true;
- }
- return false;
- }
-
- public function onActivate(Item $item, Player $player){
- if($item->getID() === DYE and $item->getMetadata() === 0x0F){ //Bonemeal
- TreeObject::growTree($this->level, $this, new Random(), $this->meta);
- if(($player->gamemode & 0x01) === 0){
- $player->removeItem(DYE, 0x0F, 1);
- }
- return true;
- }
- return false;
- }
- public function onUpdate($type){
- if($type === BLOCK_UPDATE_NORMAL){
- if($this->getSide(0)->isTransparent === true){ //Replace with common break method
- ServerAPI::request()->api->entity->drop(new Position($this->x + 0.5, $this->y, $this->z + 0.5, $this->level), BlockAPI::getItem($this->id, $this->getMetadata()));
- $this->level->setBlock($this, new AirBlock(), false, false, true);
- return BLOCK_UPDATE_NORMAL;
- }
- }elseif($type === BLOCK_UPDATE_RANDOM){ //Growth
- if(mt_rand(1, 7) === 1){
- if(($this->meta & 0x08) === 0x08){
- TreeObject::growTree($this->level, $this, new Random(), $this->meta & 0x07);
- }else{
- $this->meta |= 0x08;
- $this->level->setBlock($this, $this, true, false, true);
- return BLOCK_UPDATE_RANDOM;
- }
- }else{
- return BLOCK_UPDATE_RANDOM;
- }
- }
- return false;
- }
-
- public function getDrops(Item $item, Player $player){
- return array(
- array($this->id, $this->meta & 0x07, 1),
- );
- }
-}
\ No newline at end of file
diff --git a/src/material/block/plant/SugarcaneBlock.php b/src/material/block/plant/SugarcaneBlock.php
deleted file mode 100644
index a93ccf41..00000000
--- a/src/material/block/plant/SugarcaneBlock.php
+++ /dev/null
@@ -1,97 +0,0 @@
-isActivable = true;
- $this->hardness = 0;
- }
-
- public function getDrops(Item $item, Player $player){
- return array(
- array(SUGARCANE, 0, 1),
- );
- }
-
- public function onActivate(Item $item, Player $player){
- if($item->getID() === DYE and $item->getMetadata() === 0x0F){ //Bonemeal
- if($this->getSide(0)->getID() !== SUGARCANE_BLOCK){
- for($y = 1; $y < 3; ++$y){
- $b = $this->level->getBlock(new Vector3($this->x, $this->y + $y, $this->z));
- if($b->getID() === AIR){
- $this->level->setBlock($b, new SugarcaneBlock(), true, false, true);
- break;
- }
- }
- $this->meta = 0;
- $this->level->setBlock($this, $this, true, false, true);
- }
- if(($player->gamemode & 0x01) === 0){
- $player->removeItem(DYE,0x0F,1);
- }
- return true;
- }
- return false;
- }
-
- public function onUpdate($type){
-
- $down = $this->getSide(0);
- if($down->getID() === GRASS or $down->getID() === DIRT or $down->getID() === SAND){
- $block0 = $down->getSide(2);
- $block1 = $down->getSide(3);
- $block2 = $down->getSide(4);
- $block3 = $down->getSide(5);
- if(!($block0 instanceof WaterBlock) and !($block1 instanceof WaterBlock) and !($block2 instanceof WaterBlock) and !($block3 instanceof WaterBlock)){
- $this->level->setBlock($this, new AirBlock(), true, false, true);
- ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem(SUGARCANE));
- return true;
- }
- }
- if($type === BLOCK_UPDATE_NORMAL){
- $down = $this->getSide(0);
- if($down->isTransparent === true and $down->getID() !== SUGARCANE_BLOCK){ //Replace with common break method
- ServerAPI::request()->api->entity->drop(new Position($this->x+0.5, $this->y, $this->z+0.5, $this->level), BlockAPI::getItem(SUGARCANE));
- $this->level->setBlock($this, new AirBlock(), false, false, true);
- return BLOCK_UPDATE_NORMAL;
- }
- }elseif($type === BLOCK_UPDATE_RANDOM){
- if($this->getSide(0)->getID() !== SUGARCANE_BLOCK){
- if($this->meta === 0x0F){
- for($y = 1; $y < 3; ++$y){
- $b = $this->level->getBlock(new Vector3($this->x, $this->y + $y, $this->z));
- if($b->getID() === AIR){
- $this->level->setBlock($b, new SugarcaneBlock(), true, false, true);
- }
- }
- $this->meta = 0;
- $this->level->setBlock($this, $this, true, false, true);
- }else{
- ++$this->meta;
- $this->level->setBlock($this, $this, true, false, true);
- }
- return BLOCK_UPDATE_RANDOM;
- }
- }
- return false;
- }
-
- public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
- $down = $this->getSide(0);
- if($down->getID() === SUGARCANE_BLOCK){
- $this->level->setBlock($block, new SugarcaneBlock(), true, false, true);
- return true;
- }elseif($down->getID() === GRASS or $down->getID() === DIRT or $down->getID() === SAND){
- $block0 = $down->getSide(2);
- $block1 = $down->getSide(3);
- $block2 = $down->getSide(4);
- $block3 = $down->getSide(5);
- if(($block0 instanceof WaterBlock) or ($block1 instanceof WaterBlock) or ($block2 instanceof WaterBlock) or ($block3 instanceof WaterBlock)){
- $this->level->setBlock($block, new SugarcaneBlock(), true, false, true);
- $this->level->scheduleBlockUpdate(new Position($this, 0, 0, $this->level), Utils::getRandomUpdateTicks(), BLOCK_UPDATE_RANDOM);
- return true;
- }
- }
- return false;
- }
-}
diff --git a/src/material/block/plant/TallGrassBlock.php b/src/material/block/plant/TallGrassBlock.php
deleted file mode 100644
index 45a2f5e1..00000000
--- a/src/material/block/plant/TallGrassBlock.php
+++ /dev/null
@@ -1,43 +0,0 @@
-isReplaceable = true;
- $names = array(
- 0 => "Dead Shrub",
- 1 => "Grass",
- 2 => "Fern",
- );
- $this->name = $names[$this->meta & 0x02];
- $this->hardness = 0;
- }
-
- public function onUpdate($type){
- if($type === BLOCK_UPDATE_NORMAL){
- if($this->getSide(0)->isTransparent === true){ //Replace with common break method
- $this->level->setBlock($this, new AirBlock(), false, false, true);
- if(Utils::chance(15)) ServerAPI::request()->api->entity->drop(new Position($this->x + 0.5, $this->y, $this->z + 0.5, $this->level), BlockAPI::getItem(WHEAT_SEEDS));
- return BLOCK_UPDATE_NORMAL;
- }
- }
- return false;
- }
-
- public function getDrops(Item $item, Player $player){
- $drops = array();
- if($item->isShears()) $drops[] = array($this->id, $this->meta & 0x03, 1);
- elseif(Utils::chance(15)) $drops[] = array(WHEAT_SEEDS, 0, 1);
- return $drops;
- }
-
- public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
- $down = $this->getSide(0);
- if($down->getID() == 2 or $down->getID() == 3){
- $this->level->setBlock($block, $this, true, false, true);
- return true;
- }
- return false;
- }
-
-}
diff --git a/src/material/block/plant/VinesBlock.php b/src/material/block/plant/VinesBlock.php
deleted file mode 100644
index 748b8b88..00000000
--- a/src/material/block/plant/VinesBlock.php
+++ /dev/null
@@ -1,35 +0,0 @@
-isSolid = false;
- $this->isFullBlock = false;
- $this->hardness = 2;
- }
-
- public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){//TODO: make replacement
- if($face === 0 || $face === 1){
- return false; //fix of placing invalid ids without array
- }
- if($target->isTransparent === false){
- $faces = array(
- 2 => 0x01,
- 3 => 0x04,
- 4 => 0x08,
- 5 => 0x02,
- );
- $this->level->setBlock($this, BlockAPI::get($this->id, $faces[$face]), true, false, true);
- return true;
- }
- return false;
- }
-
- public function getDrops(Item $item, Player $player){
- $drops = array();
- if($item->isShears()){
- $drops[] = array($this->id, 0, 1);
- }
- return $drops;
- }
-}
diff --git a/src/material/block/plant/WheatBlock.php b/src/material/block/plant/WheatBlock.php
deleted file mode 100644
index b3ea789c..00000000
--- a/src/material/block/plant/WheatBlock.php
+++ /dev/null
@@ -1,69 +0,0 @@
-isActivable = true;
- $this->hardness = 0;
- }
-
- public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
- $down = $this->getSide(0);
- if($down->getID() === FARMLAND){
- $this->level->setBlock($block, $this, true, false, true);
- $this->level->scheduleBlockUpdate(new Position($this, 0, 0, $this->level), Utils::getRandomUpdateTicks(), BLOCK_UPDATE_RANDOM);
- return true;
- }
- return false;
- }
-
- public function onActivate(Item $item, Player $player){
- if($item->getID() === DYE and $item->getMetadata() === 0x0F){ //Bonemeal
- $this->meta += mt_rand(0, 3) + 2;
- if ($this->meta > 7) {
- $this->meta = 7;
- }
- $this->level->setBlock($this, $this, true, false, true);
- if(($player->gamemode & 0x01) === 0){
- $player->removeItem(DYE,0x0F,1);
- }
- return true;
- }
- return false;
- }
-
- public function onUpdate($type){
- if($type === BLOCK_UPDATE_NORMAL){
- if($this->getSide(0)->getID() != 60){
- ServerAPI::request()->api->entity->drop(new Position($this->x + 0.5, $this->y, $this->z + 0.5, $this->level), BlockAPI::getItem(WHEAT_SEEDS, 0, 1));
- $this->level->setBlock($this, new AirBlock(), false, false, true);
- return BLOCK_UPDATE_NORMAL;
- }
- }
- elseif($type === BLOCK_UPDATE_RANDOM){
- if(mt_rand(0, 2) == 1){
- if($this->meta < 0x07){
- ++$this->meta;
- $this->level->setBlock($this, $this, true, false, true);
- return BLOCK_UPDATE_RANDOM;
- }
- }else{
- return BLOCK_UPDATE_RANDOM;
- }
- }
- return false;
- }
-
- public function getDrops(Item $item, Player $player){
- $drops = [];
- if($this->meta >= 0x07){
- $drops[] = [WHEAT, 0, 1];
- }
- for($i = 0; $i < 3; ++$i){
- if(mt_rand(0, 15) <= $this->meta){ //a way from 1.4.7
- $drops[] = [WHEAT_SEEDS, 0, 1];
- }
- }
- return $drops;
- }
-}
\ No newline at end of file
diff --git a/src/material/block/solid/BedrockBlock.php b/src/material/block/solid/BedrockBlock.php
deleted file mode 100644
index 0324e418..00000000
--- a/src/material/block/solid/BedrockBlock.php
+++ /dev/null
@@ -1,17 +0,0 @@
-breakable = false;
- $this->hardness = 18000000;
- }
-
- public function isBreakable(Item $item, Player $player){
- if(($player->gamemode & 0x01) === 0x01){
- return true;
- }
- return false;
- }
-
-}
\ No newline at end of file
diff --git a/src/material/block/solid/BookshelfBlock.php b/src/material/block/solid/BookshelfBlock.php
deleted file mode 100644
index 4e6fe99c..00000000
--- a/src/material/block/solid/BookshelfBlock.php
+++ /dev/null
@@ -1,9 +0,0 @@
-hardness = 7.5;
- }
-
-}
\ No newline at end of file
diff --git a/src/material/block/solid/BricksBlock.php b/src/material/block/solid/BricksBlock.php
deleted file mode 100644
index f212b494..00000000
--- a/src/material/block/solid/BricksBlock.php
+++ /dev/null
@@ -1,38 +0,0 @@
-hardness = 30;
- }
-
- public function getBreakTime(Item $item, Player $player){
- if(($player->gamemode & 0x01) === 0x01){
- return 0.20;
- }
- switch($item->getPickaxeLevel()){
- case 5:
- return 0.4;
- case 4:
- return 0.5;
- case 3:
- return 0.75;
- case 2:
- return 0.25;
- case 1:
- return 1.5;
- default:
- return 10;
- }
- }
-
- public function getDrops(Item $item, Player $player){
- if($item->getPickaxeLevel() >= 1){
- return array(
- array(BRICKS_BLOCK, 0, 1),
- );
- }else{
- return array();
- }
- }
-}
\ No newline at end of file
diff --git a/src/material/block/solid/BrownMushroomSolidBlock.php b/src/material/block/solid/BrownMushroomSolidBlock.php
deleted file mode 100644
index f8a5f737..00000000
--- a/src/material/block/solid/BrownMushroomSolidBlock.php
+++ /dev/null
@@ -1,14 +0,0 @@
-isActivable = true;
- $this->hardness = 17.5;
- }
-
- public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
- $faces = array(
- 0 => 4,
- 1 => 2,
- 2 => 5,
- 3 => 3,
- );
- $this->meta = $faces[$player->entity->getDirection()];
- $this->level->setBlock($block, $this, true, false, true);
- return true;
- }
-
- public function getMaxLightValue(){
- return 13;
- }
-
- public function onBreak(Item $item, Player $player){
- $this->level->setBlock($this, new AirBlock(), true, true, true);
- return true;
- }
-
- public function onActivate(Item $item, Player $player){
- $server = ServerAPI::request();
- $t = $server->api->tile->get($this);
- $furnace = false;
- if($t !== false){
- $furnace = $t;
- }else{
- $furnace = $server->api->tile->add($this->level, TILE_FURNACE, $this->x, $this->y, $this->z, array(
- "Items" => array(),
- "id" => TILE_FURNACE,
- "x" => $this->x,
- "y" => $this->y,
- "z" => $this->z
- ));
- }
-
- if(($player->gamemode & 0x01) === 0x01){
- return true;
- }
-
- $furnace->openInventory($player);
- return true;
- }
-
- public function getBreakTime(Item $item, Player $player){
- if(($player->gamemode & 0x01) === 0x01){
- return 0.20;
- }
- switch($item->getPickaxeLevel()){
- case 5:
- return 0.7;
- case 4:
- return 0.9;
- case 3:
- return 1.35;
- case 2:
- return 0.45;
- case 1:
- return 2.65;
- default:
- return 17.5;
- }
- }
-
- public function getDrops(Item $item, Player $player){
- $drops = array();
- if($item->getPickaxeLevel() >= 1){
- $drops[] = array(FURNACE, 0, 1);
- }
- $t = ServerAPI::request()->api->tile->get($this);
- if($t !== false and $t->class === TILE_FURNACE){
- for($s = 0; $s < FURNACE_SLOTS; ++$s){
- $slot = $t->getSlot($s);
- if($slot->getID() > AIR and $slot->count > 0){
- $drops[] = array($slot->getID(), $slot->getMetadata(), $slot->count);
- }
- }
- }
- return $drops;
- }
-}
\ No newline at end of file
diff --git a/src/material/block/solid/ClayBlock.php b/src/material/block/solid/ClayBlock.php
deleted file mode 100644
index 0341e768..00000000
--- a/src/material/block/solid/ClayBlock.php
+++ /dev/null
@@ -1,14 +0,0 @@
-hardness = 3;
- }
-
- public function getDrops(Item $item, Player $player){
- return array(
- array(CLAY, 0, 4),
- );
- }
-}
\ No newline at end of file
diff --git a/src/material/block/solid/CoalBlock.php b/src/material/block/solid/CoalBlock.php
deleted file mode 100644
index 7b488670..00000000
--- a/src/material/block/solid/CoalBlock.php
+++ /dev/null
@@ -1,38 +0,0 @@
-hardness = 30;
- }
-
- public function getBreakTime(Item $item, Player $player){
- if(($player->gamemode & 0x01) === 0x01){
- return 0.20;
- }
- switch($item->getPickaxeLevel()){
- case 5:
- return 0.95;
- case 4:
- return 1.25;
- case 3:
- return 1.9;
- case 2:
- return 0.65;
- case 1:
- return 3.75;
- default:
- return 25;
- }
- }
-
- public function getDrops(Item $item, Player $player){
- if($item->getPickaxeLevel() >= 1){
- return array(
- array(COAL_BLOCK, 0, 1),
- );
- }else{
- return array();
- }
- }
-}
\ No newline at end of file
diff --git a/src/material/block/solid/CobblestoneBlock.php b/src/material/block/solid/CobblestoneBlock.php
deleted file mode 100644
index cab26772..00000000
--- a/src/material/block/solid/CobblestoneBlock.php
+++ /dev/null
@@ -1,38 +0,0 @@
-hardness = 30;
- }
-
- public function getBreakTime(Item $item, Player $player){
- if(($player->gamemode & 0x01) === 0x01){
- return 0.20;
- }
- switch($item->getPickaxeLevel()){
- case 5:
- return 0.4;
- case 4:
- return 0.5;
- case 3:
- return 0.75;
- case 2:
- return 0.25;
- case 1:
- return 1.5;
- default:
- return 10;
- }
- }
-
- public function getDrops(Item $item, Player $player){
- if($item->getPickaxeLevel() >= 1){
- return array(
- array(COBBLESTONE, 0, 1),
- );
- }else{
- return array();
- }
- }
-}
\ No newline at end of file
diff --git a/src/material/block/solid/DiamondBlock.php b/src/material/block/solid/DiamondBlock.php
deleted file mode 100644
index 5d698469..00000000
--- a/src/material/block/solid/DiamondBlock.php
+++ /dev/null
@@ -1,32 +0,0 @@
-hardness = 30;
- }
-
- public function getBreakTime(Item $item, Player $player){
- if(($player->gamemode & 0x01) === 0x01){
- return 0.20;
- }
- switch($item->getPickaxeLevel()){
- case 5:
- return 0.95;
- case 4:
- return 1.25;
- default:
- return 25;
- }
- }
-
- public function getDrops(Item $item, Player $player){
- if($item->getPickaxeLevel() >= 4){
- return array(
- array(DIAMOND_BLOCK, 0, 1),
- );
- }else{
- return array();
- }
- }
-}
\ No newline at end of file
diff --git a/src/material/block/solid/DirtBlock.php b/src/material/block/solid/DirtBlock.php
deleted file mode 100644
index c5c37072..00000000
--- a/src/material/block/solid/DirtBlock.php
+++ /dev/null
@@ -1,82 +0,0 @@
-isActivable = true;
- $names = array(
- 0 => "Dirt",
- 1 => "Grassless Dirt",
- );
- $this->name = $names[$this->meta & 0x01];
- $this->hardness = 2.5;
- }
-
- public function onActivate(Item $item, Player $player){
- if($item->isHoe()){
- if($this->getSide(1)->isTransparent === false) return false;
- if(($player->gamemode & 0x01) === 0){
- $item->useOn($this);
- if($item->getMetadata() >= $item->getMaxDurability()) $player->setSlot($player->slot, new Item(AIR, 0, 0), false);
- else $player->setSlot($player->slot, $item, true);
- }
- $this->level->setBlock($this, BlockAPI::get(FARMLAND, 0), true, false, true);
- return true;
- }
- return false;
- }
-
- public function onUpdate($type){
- if($type === BLOCK_UPDATE_RANDOM){
- if(mt_rand(0, 3) == 0){
- $up = $this->getSide(1);
- if(($up->isTransparent === false) or ($up->isLiquid) or ($up->getID() == 60)) return false;
- if($this->getGrassInRadius()){
- $this->level->setBlock($this, BlockAPI::get(GRASS, 0), true, false, true);
- }
- }
- }
- return BLOCK_UPDATE_RANDOM;
- }
-
- public function getBlockID($x, $y, $z){
- return $this->level->getBlock(new Vector3($x, $y, $z))->getID();
- }
-
- public function getGrassInRadius(){
- $x = $this->x;
- $y = $this->y;
- $z = $this->z;
-
- if($this->getBlockID($x+1, $y, $z+1) == 2) return true;
- if($this->getBlockID($x+1, $y, $z) == 2) return true;
- if($this->getBlockID($x+1, $y, $z-1) == 2) return true;
- if($this->getBlockID($x, $y, $z+1) == 2) return true;
- if($this->getBlockID($x, $y, $z-1) == 2) return true;
- if($this->getBlockID($x-1, $y, $z+1) == 2) return true;
- if($this->getBlockID($x-1, $y, $z) == 2) return true;
- if($this->getBlockID($x-1, $y, $z-1) == 2) return true;
-
- if($this->getBlockID($x+1, $y-1, $z+1) == 2) return true;
- if($this->getBlockID($x+1, $y-1, $z) == 2) return true;
- if($this->getBlockID($x+1, $y-1, $z-1) == 2) return true;
- if($this->getBlockID($x, $y-1, $z+1) == 2) return true;
- if($this->getBlockID($x, $y-1, $z) == 2) return true;
- if($this->getBlockID($x, $y-1, $z-1) == 2) return true;
- if($this->getBlockID($x-1, $y-1, $z+1) == 2) return true;
- if($this->getBlockID($x-1, $y-1, $z) == 2) return true;
- if($this->getBlockID($x-1, $y-1, $z-1) == 2) return true;
-
- if($this->getBlockID($x+1, $y+1, $z+1) == 2) return true;
- if($this->getBlockID($x+1, $y+1, $z) == 2) return true;
- if($this->getBlockID($x+1, $y+1, $z-1) == 2) return true;
- if($this->getBlockID($x, $y+1, $z+1) == 2) return true;
- if($this->getBlockID($x, $y+1, $z-1) == 2) return true;
- if($this->getBlockID($x-1, $y+1, $z+1) == 2) return true;
- if($this->getBlockID($x-1, $y+1, $z) == 2) return true;
- if($this->getBlockID($x-1, $y+1, $z-1) == 2) return true;
-
- return false;
- }
-
-}
\ No newline at end of file
diff --git a/src/material/block/solid/DoubleSlabBlock.php b/src/material/block/solid/DoubleSlabBlock.php
deleted file mode 100755
index 4000199f..00000000
--- a/src/material/block/solid/DoubleSlabBlock.php
+++ /dev/null
@@ -1,50 +0,0 @@
- "Stone",
- 1 => "Sandstone",
- 2 => "Wooden",
- 3 => "Cobblestone",
- 4 => "Brick",
- 5 => "Stone Brick",
- 6 => "Quartz",
- 7 => "Smooth Stone",
- );
- $this->name = "Double " . $names[$this->meta & 0x07] . " Slab";
- $this->hardness = 30;
- }
-
- public function getBreakTime(Item $item, Player $player){
- if(($player->gamemode & 0x01) === 0x01){
- return 0.20;
- }
- switch($item->getPickaxeLevel()){
- case 5:
- return 0.4;
- case 4:
- return 0.5;
- case 3:
- return 0.75;
- case 2:
- return 0.25;
- case 1:
- return 1.5;
- default:
- return 10;
- }
- }
-
- public function getDrops(Item $item, Player $player){
- if($item->getPickaxeLevel() >= 1){
- return array(
- array(SLAB, $this->meta & 0x07, 2),
- );
- }else{
- return array();
- }
- }
-
-}
diff --git a/src/material/block/solid/DoubleWoodSlabBlock.php b/src/material/block/solid/DoubleWoodSlabBlock.php
deleted file mode 100644
index 8c9af844..00000000
--- a/src/material/block/solid/DoubleWoodSlabBlock.php
+++ /dev/null
@@ -1,44 +0,0 @@
- "Oak",
- 1 => "Spruce",
- 2 => "Birch",
- 3 => "Jungle",
- 4 => "Acacia",
- 5 => "Dark Oak",
- );
- $this->name = "Double " . $names[$this->meta & 0x07] . " Wooden Slab";
- $this->hardness = 15;
- }
-
- public function getBreakTime(Item $item, Player $player){
- if(($player->gamemode & 0x01) === 0x01){
- return 0.20;
- }
- switch($item->isAxe()){
- case 5:
- return 0.4;
- case 4:
- return 0.5;
- case 3:
- return 0.75;
- case 2:
- return 0.25;
- case 1:
- return 1.5;
- default:
- return 3;
- }
- }
-
- public function getDrops(Item $item, Player $player){
- return array(
- array(WOOD_SLAB, $this->meta & 0x07, 2),
- );
- }
-
-}
\ No newline at end of file
diff --git a/src/material/block/solid/EmeraldBlock.php b/src/material/block/solid/EmeraldBlock.php
deleted file mode 100644
index 44a3beb9..00000000
--- a/src/material/block/solid/EmeraldBlock.php
+++ /dev/null
@@ -1,32 +0,0 @@
-hardness = 30;
- }
-
- public function getBreakTime(Item $item, Player $player){
- if(($player->gamemode & 0x01) === 0x01){
- return 0.20;
- }
- switch($item->getPickaxeLevel()){
- case 5:
- return 0.95;
- case 4:
- return 1.25;
- default:
- return 25;
- }
- }
-
- public function getDrops(Item $item, Player $player){
- if($item->getPickaxeLevel() >= 4){
- return array(
- array(EMERALD_BLOCK, 0, 1),
- );
- }else{
- return array();
- }
- }
-}
\ No newline at end of file
diff --git a/src/material/block/solid/EndStoneBlock.php b/src/material/block/solid/EndStoneBlock.php
deleted file mode 100644
index 1f45d43f..00000000
--- a/src/material/block/solid/EndStoneBlock.php
+++ /dev/null
@@ -1,38 +0,0 @@
-hardness = 45;
- }
-
- public function getBreakTime(Item $item, Player $player){
- if(($player->gamemode & 0x01) === 0x01){
- return 0.20;
- }
- switch($item->getPickaxeLevel()){ //from pm 1.4
- case 5:
- return 0.6;
- case 4:
- return 0.75;
- case 3:
- return 1.15;
- case 2:
- return 0.4;
- case 1:
- return 2.25;
- default:
- return 15;
- }
- }
-
- public function getDrops(Item $item, Player $player){
- if($item->getPickaxeLevel() >= 1){
- return array(
- array(END_STONE, 0, 1),
- );
- }else{
- return array();
- }
- }
-}
\ No newline at end of file
diff --git a/src/material/block/solid/FurnaceBlock.php b/src/material/block/solid/FurnaceBlock.php
deleted file mode 100644
index b4b6a535..00000000
--- a/src/material/block/solid/FurnaceBlock.php
+++ /dev/null
@@ -1,15 +0,0 @@
-id = FURNACE;
- $this->name = "Furnace";
- $this->isActivable = true;
- }
-}
\ No newline at end of file
diff --git a/src/material/block/solid/GlassBlock.php b/src/material/block/solid/GlassBlock.php
deleted file mode 100644
index 202a6aa0..00000000
--- a/src/material/block/solid/GlassBlock.php
+++ /dev/null
@@ -1,12 +0,0 @@
-hardness = 1.5;
- }
-
- public function getDrops(Item $item, Player $player){
- return array();
- }
-}
\ No newline at end of file
diff --git a/src/material/block/solid/GlowingObsidianBlock.php b/src/material/block/solid/GlowingObsidianBlock.php
deleted file mode 100644
index b3e67e27..00000000
--- a/src/material/block/solid/GlowingObsidianBlock.php
+++ /dev/null
@@ -1,12 +0,0 @@
-hardness = 1.5;
- }
-
- public function getMaxLightValue(){
- return 15;
- }
-
- public function getDrops(Item $item, Player $player){
- return array(
- array(GLOWSTONE_DUST, 0, mt_rand(2, 4)),
- );
- }
-}
\ No newline at end of file
diff --git a/src/material/block/solid/GoldBlock.php b/src/material/block/solid/GoldBlock.php
deleted file mode 100644
index a4f632dc..00000000
--- a/src/material/block/solid/GoldBlock.php
+++ /dev/null
@@ -1,32 +0,0 @@
-hardness = 30;
- }
-
- public function getBreakTime(Item $item, Player $player){
- if(($player->gamemode & 0x01) === 0x01){
- return 0.20;
- }
- switch($item->getPickaxeLevel()){
- case 5:
- return 0.6;
- case 4:
- return 0.75;
- default:
- return 15;
- }
- }
-
- public function getDrops(Item $item, Player $player){
- if($item->getPickaxeLevel() >= 4){
- return array(
- array(GOLD_BLOCK, 0, 1),
- );
- }else{
- return array();
- }
- }
-}
\ No newline at end of file
diff --git a/src/material/block/solid/GrassBlock.php b/src/material/block/solid/GrassBlock.php
deleted file mode 100644
index ad1db085..00000000
--- a/src/material/block/solid/GrassBlock.php
+++ /dev/null
@@ -1,56 +0,0 @@
-isActivable = true;
- $this->hardness = 3;
- }
-
- public function getDrops(Item $item, Player $player){
- return array(
- array(DIRT, 0, 1),
- );
- }
-
- public function onActivate(Item $item, Player $player){
- if($item->getID() === DYE and $item->getMetadata() === 0x0F){
- if(($player->gamemode & 0x01) === 0){
- $player->removeItem(DYE,0x0F,1);
- }
- TallGrassObject::growGrass($this->level, $this, new Random(), 8, 2);
- return true;
- }elseif($item->isHoe()){
- if($this->getSide(1)->isTransparent === false) return false;
- if(($player->gamemode & 0x01) === 0){
- $item->useOn($this);
- if($item->getMetadata() >= $item->getMaxDurability()) $player->setSlot($player->slot, new Item(AIR, 0, 0), false);
- else $player->setSlot($player->slot, $item, true);
- }
- $this->level->setBlock($this, new FarmlandBlock());
- //$this->seedsDrop();
- return true;
- }
- return false;
- }
-
- /*public function seedsDrop(){
- $chance = Utils::randomFloat() * 100;
- if($chance <= 1){
- ServerAPI::request()->api->entity->drop(new Position($this->x+0.5, $this->y+1, $this->z+0.5, $this->level), BlockAPI::getItem(458,0,1));
- return;
- }
- elseif($chance > 1 and $chance <= 16){
- ServerAPI::request()->api->entity->drop(new Position($this->x+0.5, $this->y+1, $this->z+0.5, $this->level), BlockAPI::getItem(295,0,1));
- return;
- }
- return;
- }*/
-
- public function onUpdate($type){
- if($type === BLOCK_UPDATE_RANDOM && !$this->getSide(1)->isTransparent && mt_rand(0, 2) == 1){
- $this->level->setBlock($this, BlockAPI::get(DIRT, 0), true, false, true);
- }
- return BLOCK_UPDATE_RANDOM;
- }
-}
diff --git a/src/material/block/solid/GravelBlock.php b/src/material/block/solid/GravelBlock.php
deleted file mode 100644
index 0f7c3706..00000000
--- a/src/material/block/solid/GravelBlock.php
+++ /dev/null
@@ -1,20 +0,0 @@
-hardness = 3;
- }
-
- public function getDrops(Item $item, Player $player){
- if(mt_rand(1,10) === 1){
- return array(
- array(FLINT, 0, 1),
- );
- }
- return array(
- array(GRAVEL, 0, 1),
- );
- }
-
-}
\ No newline at end of file
diff --git a/src/material/block/solid/HardenedClayBlock.php b/src/material/block/solid/HardenedClayBlock.php
deleted file mode 100644
index 94078b80..00000000
--- a/src/material/block/solid/HardenedClayBlock.php
+++ /dev/null
@@ -1,39 +0,0 @@
-hardness = 30;
- }
-
- public function getBreakTime(Item $item, Player $player){
- if(($player->gamemode & 0x01) === 0x01){
- return 0.20;
- }
- switch($item->getPickaxeLevel()){
- case 5:
- return 0.25;
- case 4:
- return 0.35;
- case 3:
- return 0.5;
- case 2:
- return 0.2;
- case 1:
- return 0.95;
- default:
- return 6.25;
- }
- }
-
- public function getDrops(Item $item, Player $player){
- if($item->getPickaxeLevel() >= 1){
- return array(
- array(HARDENED_CLAY, 0, 1),
- );
- }else{
- return array();
- }
- }
-
-}
\ No newline at end of file
diff --git a/src/material/block/solid/HayBaleBlock.php b/src/material/block/solid/HayBaleBlock.php
deleted file mode 100644
index 4a9bf8fc..00000000
--- a/src/material/block/solid/HayBaleBlock.php
+++ /dev/null
@@ -1,30 +0,0 @@
-hardness = 10;
- }
-
- public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
- $faces = array(
- 0 => 0,
- 1 => 0,
- 2 => 0b1000,
- 3 => 0b1000,
- 4 => 0b0100,
- 5 => 0b0100,
- );
-
- $this->meta = ($this->meta & 0x03) | $faces[$face];
- $this->level->setBlock($block, $this, true, false, true);
- return true;
- }
-
- public function getDrops(Item $item, Player $player){
- return array(
- array($this->id, 0, 1),
- );
- }
-
-}
\ No newline at end of file
diff --git a/src/material/block/solid/IceBlock.php b/src/material/block/solid/IceBlock.php
deleted file mode 100644
index e89807f3..00000000
--- a/src/material/block/solid/IceBlock.php
+++ /dev/null
@@ -1,77 +0,0 @@
-hardness = 2.5;
- $this->slipperiness = 0.98;
- }
- public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
- $ret = $this->level->setBlock($this, $this, true, false, true);
- $this->level->scheduleBlockUpdate(new Position($this, 0, 0, $this->level), Utils::getRandomUpdateTicks(), BLOCK_UPDATE_RANDOM);
- return $ret;
- }
- public function onBreak(Item $item, Player $player){
- if(($player->gamemode & 0x01) === 0){
- $this->level->setBlock($this, new WaterBlock(), true, false, true);
- ServerAPI::request()->api->block->scheduleBlockUpdate(clone $this, 10, BLOCK_UPDATE_NORMAL);
- }else{
- $this->level->setBlock($this, new AirBlock(), true, false, true);
- }
- return true;
- }
- /*
- Scan for blocks which can emit light
- args: offsetX: int, offsetY: int, offsetZ: int
- do not set offsets more than 15 : no lighting sources are giving so much light
- */
- private function scanForNearbyLightSources($offsetX, $offsetY, $offsetZ){
- for($x = -$offsetX; $x <= $offsetX; ++$x){ //i hope it is possible to optimize it
- for($z = -$offsetZ; $z <= $offsetZ; ++$z){
- for($y = -$offsetY; $y <= $offsetY; ++$y){
- $pX = $this->x+$x;
- $pY = $this->y+$y;
- $pZ = $this->z+$z;
- $block = $this->level->getBlock(new Vector3($pX, $pY, $pZ));
- if($block instanceof LightingBlock){ //idk is it possible to make it better
- return $block;
- }
- }
- }
- }
- }
- public function onUpdate($type){ /*Taken from https://github.com/PocketMine/PocketMine-MP/issues/3249*/
- if($type === BLOCK_UPDATE_RANDOM){
- $light = $this->scanForNearbyLightSources(3,3,3);
- if(LightUtils::getLightValueFromNearbySource($light,$this) > 12){
- $this->level->setBlock($this, new WaterBlock(), true);
- ServerAPI::request()->api->block->scheduleBlockUpdate(new Position($this, 0, 0, $this->level), 10, BLOCK_UPDATE_NORMAL); //additional request for update
- }
- return BLOCK_UPDATE_RANDOM;
- }
- return false;
- }
- public function getBreakTime(Item $item, Player $player){
- if(($player->gamemode & 0x01) === 0x01){
- return 0.20;
- }
- switch($item->getPickaxeLevel()){
- case 5:
- return 0.1;
- case 4:
- return 0.15;
- case 3:
- return 0.2;
- case 2:
- return 0.1;
- case 1:
- return 0.4;
- default:
- return 0.75;
- }
- }
-
- public function getDrops(Item $item, Player $player){
- return array();
- }
-}
\ No newline at end of file
diff --git a/src/material/block/solid/InfoUpdate2Block.php b/src/material/block/solid/InfoUpdate2Block.php
deleted file mode 100755
index 78eb44bb..00000000
--- a/src/material/block/solid/InfoUpdate2Block.php
+++ /dev/null
@@ -1,10 +0,0 @@
-breakable = true;
- $this->hardness = 0;
- }
-
-}
\ No newline at end of file
diff --git a/src/material/block/solid/InfoUpdateBlock.php b/src/material/block/solid/InfoUpdateBlock.php
deleted file mode 100755
index abda197f..00000000
--- a/src/material/block/solid/InfoUpdateBlock.php
+++ /dev/null
@@ -1,10 +0,0 @@
-breakable = true;
- $this->hardness = 0;
- }
-
-}
\ No newline at end of file
diff --git a/src/material/block/solid/InvisibleBedrockBlock.php b/src/material/block/solid/InvisibleBedrockBlock.php
deleted file mode 100755
index 3b067016..00000000
--- a/src/material/block/solid/InvisibleBedrockBlock.php
+++ /dev/null
@@ -1,17 +0,0 @@
-breakable = false;
- $this->hardness = 3600000;
- }
-
- public function isBreakable(Item $item, Player $player){
- if(($player->gamemode & 0x01) === 0x01){
- return true;
- }
- return false;
- }
-
-}
\ No newline at end of file
diff --git a/src/material/block/solid/IronBlock.php b/src/material/block/solid/IronBlock.php
deleted file mode 100644
index 2cc7d298..00000000
--- a/src/material/block/solid/IronBlock.php
+++ /dev/null
@@ -1,34 +0,0 @@
-hardness = 30;
- }
-
- public function getBreakTime(Item $item, Player $player){
- if(($player->gamemode & 0x01) === 0x01){
- return 0.20;
- }
- switch($item->getPickaxeLevel()){
- case 5:
- return 0.95;
- case 4:
- return 1.25;
- case 3:
- return 1.9;
- default:
- return 25;
- }
- }
-
- public function getDrops(Item $item, Player $player){
- if($item->getPickaxeLevel() >= 3){
- return array(
- array(IRON_BLOCK, 0, 1),
- );
- }else{
- return array();
- }
- }
-}
\ No newline at end of file
diff --git a/src/material/block/solid/LapisBlock.php b/src/material/block/solid/LapisBlock.php
deleted file mode 100644
index 3b4911cb..00000000
--- a/src/material/block/solid/LapisBlock.php
+++ /dev/null
@@ -1,35 +0,0 @@
-hardness = 15;
- }
-
- public function getBreakTime(Item $item, Player $player){
- if(($player->gamemode & 0x01) === 0x01){
- return 0.20;
- }
- switch($item->getPickaxeLevel()){
- case 5:
- return 0.6;
- case 4:
- return 0.75;
- case 3:
- return 1.15;
- default:
- return 15;
- }
- }
-
- public function getDrops(Item $item, Player $player){
- if($item->getPickaxeLevel() >= 3){
- return array(
- array(LAPIS_BLOCK, 0, 1),
- );
- }else{
- return array();
- }
- }
-
-}
\ No newline at end of file
diff --git a/src/material/block/solid/Leaves2Block.php b/src/material/block/solid/Leaves2Block.php
deleted file mode 100644
index 475feffe..00000000
--- a/src/material/block/solid/Leaves2Block.php
+++ /dev/null
@@ -1,87 +0,0 @@
- "Acacia Leaves",
- 1 => "Dark Oak Leaves"
- ];
-
- public function __construct($meta = 0){
- parent::__construct(LEAVES2, $meta, self::$names[$meta & 0x01]);
- $this->hardness = 1;
- }
-
- private function createIndex($x, $y, $z){
- return $index = $x.".".$y.".".$z;
- }
-
- private function findLog(Block $pos, array $visited, $distance){ //port from newest pocketmine
- $index = $this->createIndex($pos->x, $pos->y, $pos->z);
- if(isset($visited[$index])){
- return false;
- }
- $visited[$index] = true;
-
- $block = $this->level->getBlock($pos);
- if($block instanceof WoodBlock or $block instanceof Log2Block){ //type doesn't matter
- return true;
- }
-
- if($block->getId() === $this->getId() && $distance <= 4){
- foreach(range(2, 5) as $side){
- if($this->findLog($pos->getSide($side), $visited, $distance + 1)){ //recursion i guess?
- return true;
- }
- }
- }
- return false;
- }
-
- public function onUpdate($type){
- if($type === BLOCK_UPDATE_NORMAL){
- if(($this->meta & 0b00001100) === 0){
- $this->meta |= 0x08;
- $this->level->setBlock($this, $this, false, false, true);
- return BLOCK_UPDATE_RANDOM;
- }
- }elseif($type === BLOCK_UPDATE_RANDOM){
- if(($this->meta & 0b00001100) === 0x08){
- $this->meta &= 0x02;
- $visited = array();
- $check = 0;
- if($this->findLog($this, $visited, 0) !== true){
- $this->level->setBlock($this, new AirBlock(), false, false, true);
- if(mt_rand(1, 20) === 1){ //Saplings
- ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem(SAPLING, $this->meta + 2 & 0x05, 1));
- }
- if(($this->meta & 0x02) === 1 and mt_rand(1, 200) === 1){ //Apples
- ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem(APPLE, 0, 1));
- }
- return BLOCK_UPDATE_NORMAL;
- }
- }
- }
- return false;
- }
-
- public function place(Item $item, 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){
- $drops = array();
- if($item->isShears()){
- $drops[] = array(LEAVES2, $this->getMetadata(), 1);
- }else{
- if(mt_rand(1, 20) === 1){ //Saplings
- $drops[] = array(SAPLING, $this->meta + 2 & 0x05, 1);
- }
- if(($this->meta & 0x03) === 1 and mt_rand(1, 100) === 1){ //Apples
- $drops[] = array(APPLE, 0, 1);
- }
- }
- return $drops;
- }
-}
diff --git a/src/material/block/solid/LeavesBlock.php b/src/material/block/solid/LeavesBlock.php
deleted file mode 100644
index 6bbe485e..00000000
--- a/src/material/block/solid/LeavesBlock.php
+++ /dev/null
@@ -1,88 +0,0 @@
- "Oak Leaves",
- WoodBlock::SPRUCE => "Spruce Leaves",
- WoodBlock::BIRCH => "Birch Leaves",
- WoodBlock::JUNGLE => "Jungle Leaves",
- );
- $this->name = $names[$this->meta & 0x03];
- $this->hardness = 1;
- }
-
- private function createIndex($x, $y, $z){
- return $index = $x.".".$y.".".$z;
- }
-
- private function findLog(Block $pos, array $visited, $distance){ //port from newest pocketmine
- $index = $this->createIndex($pos->x, $pos->y, $pos->z);
- if(isset($visited[$index])){
- return false;
- }
- $visited[$index] = true;
-
- $block = $this->level->getBlock($pos);
- if($block instanceof WoodBlock){ //type doesn't matter
- return true;
- }
-
- if($block->getId() === $this->getId() && $distance <= 4){
- foreach(range(2, 5) as $side){
- if($this->findLog($pos->getSide($side), $visited, $distance + 1)){ //recursion i guess?
- return true;
- }
- }
- }
- return false;
- }
-
- public function onUpdate($type){
- if($type === BLOCK_UPDATE_NORMAL){
- if(($this->meta & 0b00001100) === 0){
- $this->meta |= 0x08;
- $this->level->setBlock($this, $this, false, false, true);
- return BLOCK_UPDATE_RANDOM;
- }
- }elseif($type === BLOCK_UPDATE_RANDOM){
- if(($this->meta & 0b00001100) === 0x08){
- $this->meta &= 0x03;
- $visited = array();
- $check = 0;
- if($this->findLog($this, $visited, 0) !== true){
- $this->level->setBlock($this, new AirBlock(), false, false, true);
- if(mt_rand(1, 20) === 1){ //Saplings
- ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem(SAPLING, $this->meta & 0x03, 1));
- }
- if(($this->meta & 0x03) === WoodBlock::OAK and mt_rand(1, 200) === 1){ //Apples
- ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem(APPLE, 0, 1));
- }
- return BLOCK_UPDATE_NORMAL;
- }
- }
- }
- return false;
- }
-
- public function place(Item $item, 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){
- $drops = array();
- if($item->isShears()){
- $drops[] = array(LEAVES, $this->meta & 0x03, 1);
- }else{
- if(mt_rand(1,20) === 1){ //Saplings
- $drops[] = array(SAPLING, $this->meta & 0x03, 1);
- }
- if(($this->meta & 0x03) === WoodBlock::OAK and mt_rand(1,100) === 1){ //Apples
- $drops[] = array(APPLE, 0, 1);
- }
- }
- return $drops;
- }
-}
\ No newline at end of file
diff --git a/src/material/block/solid/LitPumpkinBlock.php b/src/material/block/solid/LitPumpkinBlock.php
deleted file mode 100644
index 870e87bc..00000000
--- a/src/material/block/solid/LitPumpkinBlock.php
+++ /dev/null
@@ -1,24 +0,0 @@
-hardness = 5;
- }
-
- public function getMaxLightValue(){
- return 15;
- }
-
- public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
- $faces = array(
- 0 => 1,
- 1 => 2,
- 2 => 3,
- 3 => 0,
- );
- $this->meta = $faces[$player->entity->getDirection()];
- $this->level->setBlock($block, $this, true, false, true);
- return true;
- }
-}
\ No newline at end of file
diff --git a/src/material/block/solid/Log2Block.php b/src/material/block/solid/Log2Block.php
deleted file mode 100644
index bcc66c12..00000000
--- a/src/material/block/solid/Log2Block.php
+++ /dev/null
@@ -1,34 +0,0 @@
- "Acacia Log",
- 1 => "Dark Oak Log",
- );
- $this->name = $names[$this->meta & 0x02];
- $this->hardness = 10;
- }
-
- public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
- $faces = array(
- 0 => 0,
- 1 => 0,
- 2 => 0b1000,
- 3 => 0b1000,
- 4 => 0b0100,
- 5 => 0b0100,
- );
-
- $this->meta = ($this->meta & 0x03) | $faces[$face];
- $this->level->setBlock($block, $this, true, false, true);
- return true;
- }
-
- public function getDrops(Item $item, Player $player){
- return array(
- array($this->id, $this->meta & 0x02, 1),
- );
- }
-}
\ No newline at end of file
diff --git a/src/material/block/solid/MelonBlock.php b/src/material/block/solid/MelonBlock.php
deleted file mode 100644
index b9e34fc1..00000000
--- a/src/material/block/solid/MelonBlock.php
+++ /dev/null
@@ -1,13 +0,0 @@
-hardness = 5;
- }
- public function getDrops(Item $item, Player $player){
- return array(
- array(MELON_SLICE, 0, mt_rand(3, 7)),
- );
- }
-}
\ No newline at end of file
diff --git a/src/material/block/solid/MonsterSpawnerBlock.php b/src/material/block/solid/MonsterSpawnerBlock.php
deleted file mode 100644
index ce097b01..00000000
--- a/src/material/block/solid/MonsterSpawnerBlock.php
+++ /dev/null
@@ -1,21 +0,0 @@
-hardness = 5;
- }
- public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
- parent::place($item, $player, $block, $target, $face, $fx, $fy, $fz);
- ServerAPI::request()->api->tile->add($this->level, TILE_MOB_SPAWNER, $this->x, $this->y, $this->z, [
- "EntityId" => 0,
- "id" => TILE_MOB_SPAWNER,
- "x" => $this->x,
- "y" => $this->y,
- "z" => $this->z,
- ]);
- }
- public function getDrops(Item $item, Player $player){
- return [];
- }
-}
\ No newline at end of file
diff --git a/src/material/block/solid/MossStoneBlock.php b/src/material/block/solid/MossStoneBlock.php
deleted file mode 100644
index 068a8e7a..00000000
--- a/src/material/block/solid/MossStoneBlock.php
+++ /dev/null
@@ -1,38 +0,0 @@
-hardness = 30;
- }
-
- public function getBreakTime(Item $item, Player $player){
- if(($player->gamemode & 0x01) === 0x01){
- return 0.20;
- }
- switch($item->getPickaxeLevel()){
- case 5:
- return 0.4;
- case 4:
- return 0.5;
- case 3:
- return 0.75;
- case 2:
- return 0.25;
- case 1:
- return 1.5;
- default:
- return 10;
- }
- }
-
- public function getDrops(Item $item, Player $player){
- if($item->getPickaxeLevel() >= 1){
- return array(
- array(MOSS_STONE, 0, 1),
- );
- }else{
- return array();
- }
- }
-}
\ No newline at end of file
diff --git a/src/material/block/solid/MyceliumBlock.php b/src/material/block/solid/MyceliumBlock.php
deleted file mode 100644
index 4d4659a9..00000000
--- a/src/material/block/solid/MyceliumBlock.php
+++ /dev/null
@@ -1,35 +0,0 @@
-isActivable = true;
- $this->hardness = 3;
- }
-
- public function onUpdate($type){
- if($type === BLOCK_UPDATE_RANDOM && !$this->getSide(1)->isTransparent && mt_rand(0, 2) == 1){
- $this->level->setBlock($this, BlockAPI::get(DIRT, 0), true, false, true);
- }
- return BLOCK_UPDATE_RANDOM;
- }
-
- public function onActivate(Item $item, Player $player){ //uwu
- //$oldtime = microtime(true);
- //if(mt_rand(0, 1) === 0){
- //Structures::$SMALLFARM_VILLAGE->rotate(Structure::DEG_240, $this->level)->build($this->level, $this->x, $this->y, $this->z);
- //}else{
- //(new OakTreeStructure())->build($this->level, $this->x, $this->y, $this->z);
- //}
- //$time = microtime(true);
- //console("builded in ".($time - $oldtime));
-
- //(new WoodHutStructure())->build($this->level, $this->getX(), $this->getY(), $this->getZ());
- }
-
- public function getDrops(Item $item, Player $player){
- return array(
- array(DIRT, 0, 1),
- );
- }
-}
\ No newline at end of file
diff --git a/src/material/block/solid/NetherBricksBlock.php b/src/material/block/solid/NetherBricksBlock.php
deleted file mode 100644
index fa662f0e..00000000
--- a/src/material/block/solid/NetherBricksBlock.php
+++ /dev/null
@@ -1,38 +0,0 @@
-hardness = 30;
- }
-
- public function getBreakTime(Item $item, Player $player){
- if(($player->gamemode & 0x01) === 0x01){
- return 0.20;
- }
- switch($item->getPickaxeLevel()){
- case 5:
- return 0.4;
- case 4:
- return 0.5;
- case 3:
- return 0.75;
- case 2:
- return 0.25;
- case 1:
- return 1.5;
- default:
- return 10;
- }
- }
-
- public function getDrops(Item $item, Player $player){
- if($item->getPickaxeLevel() >= 1){
- return array(
- array(NETHER_BRICKS, 0, 1),
- );
- }else{
- return array();
- }
- }
-}
\ No newline at end of file
diff --git a/src/material/block/solid/NetherrackBlock.php b/src/material/block/solid/NetherrackBlock.php
deleted file mode 100644
index 9e2f0b9c..00000000
--- a/src/material/block/solid/NetherrackBlock.php
+++ /dev/null
@@ -1,38 +0,0 @@
-hardness = 2;
- }
-
- public function getBreakTime(Item $item, Player $player){
- if(($player->gamemode & 0x01) === 0x01){
- return 0.20;
- }
- switch($item->getPickaxeLevel()){
- case 5:
- return 0.1;
- case 4:
- return 0.1;
- case 3:
- return 0.15;
- case 2:
- return 0.05;
- case 1:
- return 0.3;
- default:
- return 2;
- }
- }
-
- public function getDrops(Item $item, Player $player){
- if($item->getPickaxeLevel() >= 1){
- return array(
- array(NETHERRACK, 0, 1),
- );
- }else{
- return array();
- }
- }
-}
\ No newline at end of file
diff --git a/src/material/block/solid/ObsidianBlock.php b/src/material/block/solid/ObsidianBlock.php
deleted file mode 100644
index 03b56770..00000000
--- a/src/material/block/solid/ObsidianBlock.php
+++ /dev/null
@@ -1,29 +0,0 @@
-hardness = 6000;
- }
-
- public function getBreakTime(Item $item, Player $player){
- if(($player->gamemode & 0x01) === 0x01){
- return 0.20;
- }
- if($item->getPickaxeLevel() >= 5){
- return 2.15;
- }else{
- return 250;
- }
- }
-
- public function getDrops(Item $item, Player $player){
- if($item->getPickaxeLevel() >= 5){
- return [
- [OBSIDIAN, 0, 1]
- ];
- }else{
- return [];
- }
- }
-}
diff --git a/src/material/block/solid/PlanksBlock.php b/src/material/block/solid/PlanksBlock.php
deleted file mode 100644
index 3bf0f9a0..00000000
--- a/src/material/block/solid/PlanksBlock.php
+++ /dev/null
@@ -1,18 +0,0 @@
- "Oak Wooden Planks",
- WoodBlock::SPRUCE => "Spruce Wooden Planks",
- WoodBlock::BIRCH => "Birch Wooden Planks",
- WoodBlock::JUNGLE => "Jungle Wooden Planks",
- 4 => "Acacia Wooden Planks",
- 5 => "Dark Oak Wooden Planks",
- );
- $this->name = $names[$this->meta & 0x05];
- $this->hardness = 15;
- }
-
-}
\ No newline at end of file
diff --git a/src/material/block/solid/PodzolBlock.php b/src/material/block/solid/PodzolBlock.php
deleted file mode 100644
index 98b809c0..00000000
--- a/src/material/block/solid/PodzolBlock.php
+++ /dev/null
@@ -1,62 +0,0 @@
-hardness = 2.5;
- }
-
- public function onUpdate($type){
- if($type === BLOCK_UPDATE_RANDOM){
- if(mt_rand(0, 3) == 0){
- $up = $this->getSide(1);
- if(($up->isTransparent === false) or ($up->isLiquid) or ($up->getID() == 60)) return false;
- if($this->getGrassInRadius()){
- $this->level->setBlock($this, BlockAPI::get(GRASS, 0), true, false, true);
- }
- }
- }
- return BLOCK_UPDATE_RANDOM;
- }
-
- public function getBlockID($x, $y, $z){
- return $this->level->getBlock(new Vector3($x, $y, $z))->getID();
- }
-
- public function getGrassInRadius(){
- $x = $this->x;
- $y = $this->y;
- $z = $this->z;
-
- if($this->getBlockID($x+1, $y, $z+1) == 2) return true;
- if($this->getBlockID($x+1, $y, $z) == 2) return true;
- if($this->getBlockID($x+1, $y, $z-1) == 2) return true;
- if($this->getBlockID($x, $y, $z+1) == 2) return true;
- if($this->getBlockID($x, $y, $z-1) == 2) return true;
- if($this->getBlockID($x-1, $y, $z+1) == 2) return true;
- if($this->getBlockID($x-1, $y, $z) == 2) return true;
- if($this->getBlockID($x-1, $y, $z-1) == 2) return true;
-
- if($this->getBlockID($x+1, $y-1, $z+1) == 2) return true;
- if($this->getBlockID($x+1, $y-1, $z) == 2) return true;
- if($this->getBlockID($x+1, $y-1, $z-1) == 2) return true;
- if($this->getBlockID($x, $y-1, $z+1) == 2) return true;
- if($this->getBlockID($x, $y-1, $z) == 2) return true;
- if($this->getBlockID($x, $y-1, $z-1) == 2) return true;
- if($this->getBlockID($x-1, $y-1, $z+1) == 2) return true;
- if($this->getBlockID($x-1, $y-1, $z) == 2) return true;
- if($this->getBlockID($x-1, $y-1, $z-1) == 2) return true;
-
- if($this->getBlockID($x+1, $y+1, $z+1) == 2) return true;
- if($this->getBlockID($x+1, $y+1, $z) == 2) return true;
- if($this->getBlockID($x+1, $y+1, $z-1) == 2) return true;
- if($this->getBlockID($x, $y+1, $z+1) == 2) return true;
- if($this->getBlockID($x, $y+1, $z-1) == 2) return true;
- if($this->getBlockID($x-1, $y+1, $z+1) == 2) return true;
- if($this->getBlockID($x-1, $y+1, $z) == 2) return true;
- if($this->getBlockID($x-1, $y+1, $z-1) == 2) return true;
-
- return false;
- }
-
-}
\ No newline at end of file
diff --git a/src/material/block/solid/PumpkinBlock.php b/src/material/block/solid/PumpkinBlock.php
deleted file mode 100644
index d837ac14..00000000
--- a/src/material/block/solid/PumpkinBlock.php
+++ /dev/null
@@ -1,20 +0,0 @@
-hardness = 5;
- }
- public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
- $faces = array(
- 0 => 1,
- 1 => 2,
- 2 => 3,
- 3 => 0,
- );
- $this->meta = $faces[$player->entity->getDirection()];
- $this->level->setBlock($block, $this, true, false, true);
- return true;
- }
-
-}
\ No newline at end of file
diff --git a/src/material/block/solid/QuartzBlock.php b/src/material/block/solid/QuartzBlock.php
deleted file mode 100644
index 120272b5..00000000
--- a/src/material/block/solid/QuartzBlock.php
+++ /dev/null
@@ -1,44 +0,0 @@
- "Quartz Block",
- 1 => "Chiseled Quartz Block",
- 2 => "Quartz Pillar",
- 3 => "Quartz Pillar", //why 2 pillars?
- );
- $this->name = $names[$this->meta & 0x03];
- }
-
- public function getBreakTime(Item $item, Player $player){
- if(($player->gamemode & 0x01) === 0x01){
- return 0.20;
- }
- switch($item->getPickaxeLevel()){
- case 5:
- return 0.15;
- case 4:
- return 0.2;
- case 3:
- return 0.3;
- case 2:
- return 0.1;
- case 1:
- return 0.6;
- default:
- return 4;
- }
- }
-
- public function getDrops(Item $item, Player $player){
- if($item->getPickaxeLevel() >= 1){
- return array(
- array(QUARTZ_BLOCK, $this->meta & 0x03, 1),
- );
- }else{
- return array();
- }
- }
-}
\ No newline at end of file
diff --git a/src/material/block/solid/RedMushroomSolidBlock.php b/src/material/block/solid/RedMushroomSolidBlock.php
deleted file mode 100644
index 075c9a6d..00000000
--- a/src/material/block/solid/RedMushroomSolidBlock.php
+++ /dev/null
@@ -1,14 +0,0 @@
-breakable = true;
- $this->hardness = 0;
- }
-
-}
\ No newline at end of file
diff --git a/src/material/block/solid/SandBlock.php b/src/material/block/solid/SandBlock.php
deleted file mode 100644
index c77b2798..00000000
--- a/src/material/block/solid/SandBlock.php
+++ /dev/null
@@ -1,14 +0,0 @@
- "Sand",
- 1 => "Red Sand"
- ];
- $this->name = $names[$this->meta & 0x01];
- $this->hardness = 2.5;
- }
-
-}
\ No newline at end of file
diff --git a/src/material/block/solid/SandstoneBlock.php b/src/material/block/solid/SandstoneBlock.php
deleted file mode 100644
index 766097da..00000000
--- a/src/material/block/solid/SandstoneBlock.php
+++ /dev/null
@@ -1,45 +0,0 @@
- "Sandstone",
- 1 => "Chiseled Sandstone",
- 2 => "Smooth Sandstone",
- );
- $this->name = $names[$this->meta & 0x03];
- $this->hardness = 4;
- }
-
- public function getBreakTime(Item $item, Player $player){
- if(($player->gamemode & 0x01) === 0x01){
- return 0.20;
- }
- switch($item->getPickaxeLevel()){
- case 5:
- return 0.15;
- case 4:
- return 0.2;
- case 3:
- return 0.3;
- case 2:
- return 0.1;
- case 1:
- return 0.6;
- default:
- return 4;
- }
- }
-
- public function getDrops(Item $item, Player $player){
- if($item->getPickaxeLevel() >= 1){
- return array(
- array(SANDSTONE, $this->meta & 0x03, 1),
- );
- }else{
- return array();
- }
- }
-
-}
\ No newline at end of file
diff --git a/src/material/block/solid/SnowBlock.php b/src/material/block/solid/SnowBlock.php
deleted file mode 100644
index 563f0985..00000000
--- a/src/material/block/solid/SnowBlock.php
+++ /dev/null
@@ -1,17 +0,0 @@
-hardness = 1;
- }
-
- public function getDrops(Item $item, Player $player){
- if($item->isShovel() !== false){
- return array(
- array(SNOWBALL, 0, 4),
- );
- }
- }
-
-}
\ No newline at end of file
diff --git a/src/material/block/solid/SoulSandBlock.php b/src/material/block/solid/SoulSandBlock.php
deleted file mode 100644
index 10ff2e49..00000000
--- a/src/material/block/solid/SoulSandBlock.php
+++ /dev/null
@@ -1,9 +0,0 @@
-hardness = 2.5;
- }
-
-}
\ No newline at end of file
diff --git a/src/material/block/solid/SpongeBlock.php b/src/material/block/solid/SpongeBlock.php
deleted file mode 100644
index 5ab60495..00000000
--- a/src/material/block/solid/SpongeBlock.php
+++ /dev/null
@@ -1,9 +0,0 @@
-hardness = 3;
- }
-
-}
diff --git a/src/material/block/solid/StainedClayBlock.php b/src/material/block/solid/StainedClayBlock.php
deleted file mode 100644
index a6855ad3..00000000
--- a/src/material/block/solid/StainedClayBlock.php
+++ /dev/null
@@ -1,58 +0,0 @@
- "White Stained Clay",
- 1 => "Orange Stained Clay",
- 2 => "Magenta Stained Clay",
- 3 => "Light Blue Stained Clay",
- 4 => "Yellow Stained Clay",
- 5 => "Lime Stained Clay",
- 6 => "Pink Stained Clay",
- 7 => "Gray Stained Clay",
- 8 => "Light Gray Stained Clay",
- 9 => "Cyan Stained Clay",
- 10 => "Purple Stained Clay",
- 11 => "Blue Stained Clay",
- 12 => "Brown Stained Clay",
- 13 => "Green Stained Clay",
- 14 => "Red Stained Clay",
- 15 => "Black Stained Clay",
- );
- $this->name = $names[$this->meta & 0x15];
- $this->hardness = 30;
- }
-
- public function getBreakTime(Item $item, Player $player){
- if(($player->gamemode & 0x01) === 0x01){
- return 0.20;
- }
- switch($item->getPickaxeLevel()){
- case 5:
- return 0.25;
- case 4:
- return 0.35;
- case 3:
- return 0.5;
- case 2:
- return 0.2;
- case 1:
- return 0.95;
- default:
- return 6.25;
- }
- }
-
- public function getDrops(Item $item, Player $player){
- if($item->getPickaxeLevel() >= 1){
- return array(
- array(STAINED_CLAY, $this->meta & 0x15, 1)
- );
- }else{
- return array();
- }
- }
-
-}
\ No newline at end of file
diff --git a/src/material/block/solid/StoneBlock.php b/src/material/block/solid/StoneBlock.php
deleted file mode 100644
index cf0f6e4c..00000000
--- a/src/material/block/solid/StoneBlock.php
+++ /dev/null
@@ -1,50 +0,0 @@
- "Stone",
- 1 => "Granite",
- 2 => "Polished Granite",
- 3 => "Diorite",
- 4 => "Polished Diorite",
- 5 => "Andesite",
- 6 => "Polished Andesite",
- ];
-
- public function __construct($meta = 0){
- parent::__construct(STONE, $meta, self::$names[$meta] ?? "Stone");
- $this->hardness = 30;
- }
-
- public function getBreakTime(Item $item, Player $player){
- if(($player->gamemode & 0x01) === 0x01){
- return 0.20;
- }
- switch($item->getPickaxeLevel()){
- case 5:
- return 0.4;
- case 4:
- return 0.5;
- case 3:
- return 0.75;
- case 2:
- return 0.25;
- case 1:
- return 1.5;
- default:
- return 7.5;
- }
- }
-
- public function getDrops(Item $item, Player $player){
- if($item->getPickaxeLevel() >= 1){
- return array(
- array($this->meta == 0 ? COBBLESTONE : $this->id, $this->meta, 1),
- );
- }else{
- return array();
- }
- }
-
-}
\ No newline at end of file
diff --git a/src/material/block/solid/StoneBricksBlock.php b/src/material/block/solid/StoneBricksBlock.php
deleted file mode 100644
index 1a25f8f1..00000000
--- a/src/material/block/solid/StoneBricksBlock.php
+++ /dev/null
@@ -1,46 +0,0 @@
- "Stone Bricks",
- 1 => "Mossy Stone Bricks",
- 2 => "Cracked Stone Bricks",
- 3 => "Chiseled Stone Bricks",
- );
- $this->name = $names[$this->meta & 0x03];
- $this->hardness = 30;
- }
-
- public function getBreakTime(Item $item, Player $player){
- if(($player->gamemode & 0x01) === 0x01){
- return 0.20;
- }
- switch($item->getPickaxeLevel()){
- case 5:
- return 0.4;
- case 4:
- return 0.5;
- case 3:
- return 0.75;
- case 2:
- return 0.25;
- case 1:
- return 1.5;
- default:
- return 7.5;
- }
- }
-
- public function getDrops(Item $item, Player $player){
- if($item->getPickaxeLevel() >= 1){
- return array(
- array(STONE_BRICKS, $this->meta & 0x03, 1),
- );
- }else{
- return array();
- }
- }
-
-}
\ No newline at end of file
diff --git a/src/material/block/solid/StonecutterBlock.php b/src/material/block/solid/StonecutterBlock.php
deleted file mode 100644
index 0d37687a..00000000
--- a/src/material/block/solid/StonecutterBlock.php
+++ /dev/null
@@ -1,19 +0,0 @@
-isActivable = true;
- }
-
- public function onActivate(Item $item, Player $player){
- $player->toCraft[-1] = 2;
- return true;
- }
-
- public function getDrops(Item $item, Player $player){
- return array(
- array($this->id, 0, 1),
- );
- }
-}
\ No newline at end of file
diff --git a/src/material/block/solid/WoodBlock.php b/src/material/block/solid/WoodBlock.php
deleted file mode 100644
index e68efd21..00000000
--- a/src/material/block/solid/WoodBlock.php
+++ /dev/null
@@ -1,41 +0,0 @@
- "Oak Log",
- WoodBlock::SPRUCE => "Spruce Log",
- WoodBlock::BIRCH => "Birch Log",
- WoodBlock::JUNGLE => "Jungle Log",
- );
- $this->name = $names[$this->meta & 0x03];
- $this->hardness = 10;
- }
-
- public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
- $faces = array(
- 0 => 0,
- 1 => 0,
- 2 => 0b1000,
- 3 => 0b1000,
- 4 => 0b0100,
- 5 => 0b0100,
- );
-
- $this->meta = ($this->meta & 0x03) | $faces[$face];
- $this->level->setBlock($block, $this, true, false, true);
- return true;
- }
-
- public function getDrops(Item $item, Player $player){
- return array(
- array($this->id, $this->meta & 0x03, 1),
- );
- }
-}
\ No newline at end of file
diff --git a/src/material/block/solid/WoolBlock.php b/src/material/block/solid/WoolBlock.php
deleted file mode 100644
index b891858e..00000000
--- a/src/material/block/solid/WoolBlock.php
+++ /dev/null
@@ -1,29 +0,0 @@
- "White Wool",
- 1 => "Orange Wool",
- 2 => "Magenta Wool",
- 3 => "Light Blue Wool",
- 4 => "Yellow Wool",
- 5 => "Lime Wool",
- 6 => "Pink Wool",
- 7 => "Gray Wool",
- 8 => "Light Gray Wool",
- 9 => "Cyan Wool",
- 10 => "Purple Wool",
- 11 => "Blue Wool",
- 12 => "Brown Wool",
- 13 => "Green Wool",
- 14 => "Red Wool",
- 15 => "Black Wool",
- );
-
- public function __construct($meta = 0){
- parent::__construct(WOOL, $meta, self::$names[$meta] ?? "Wool");
- $this->hardness = 4;
- }
-
-}
\ No newline at end of file
diff --git a/src/material/block/solid/WorkbenchBlock.php b/src/material/block/solid/WorkbenchBlock.php
deleted file mode 100644
index 3a559e25..00000000
--- a/src/material/block/solid/WorkbenchBlock.php
+++ /dev/null
@@ -1,20 +0,0 @@
-isActivable = true;
- $this->hardness = 15;
- }
-
- public function onActivate(Item $item, Player $player){
- $player->toCraft[-1] = 1;
- return true;
- }
-
- public function getDrops(Item $item, Player $player){
- return array(
- array($this->id, 0, 1),
- );
- }
-}
\ No newline at end of file
diff --git a/src/material/item/armor/ArmorItem.php b/src/material/item/armor/ArmorItem.php
deleted file mode 100644
index ebb5536d..00000000
--- a/src/material/item/armor/ArmorItem.php
+++ /dev/null
@@ -1,18 +0,0 @@
-getMaterialDurability() * $this->getBaseDurability();
- }
-}
\ No newline at end of file
diff --git a/src/material/item/armor/ChainBootsItem.php b/src/material/item/armor/ChainBootsItem.php
deleted file mode 100644
index 73083238..00000000
--- a/src/material/item/armor/ChainBootsItem.php
+++ /dev/null
@@ -1,22 +0,0 @@
-id){
- case WOODEN_AXE:
- return 1;
- case GOLDEN_AXE:
- return 2;
- case STONE_AXE:
- return 3;
- case IRON_AXE:
- return 4;
- case DIAMOND_AXE:
- return 5;
- default:
- return false;
- }
- }
-}
-
diff --git a/src/material/item/base/ItemHoe.php b/src/material/item/base/ItemHoe.php
deleted file mode 100644
index b239b9cf..00000000
--- a/src/material/item/base/ItemHoe.php
+++ /dev/null
@@ -1,35 +0,0 @@
-getID() === GRASS or $object->getID() === DIRT)){
- $this->meta++;
- return true;
- }else{
- return parent::useOn($object, $force);
- }
- }
-
- public function getLevel(){
- switch($this->id){
- case WOODEN_HOE:
- return 1;
- case GOLDEN_HOE:
- return 2;
- case STONE_HOE:
- return 3;
- case IRON_HOE:
- return 4;
- case DIAMOND_HOE:
- return 5;
- default:
- return false;
- }
- }
-}
-
diff --git a/src/material/item/base/ItemPickaxe.php b/src/material/item/base/ItemPickaxe.php
deleted file mode 100644
index c501aa99..00000000
--- a/src/material/item/base/ItemPickaxe.php
+++ /dev/null
@@ -1,30 +0,0 @@
-id){
- case WOODEN_PICKAXE:
- return 1;
- case GOLDEN_PICKAXE:
- return 2;
- case STONE_PICKAXE:
- return 3;
- case IRON_PICKAXE:
- return 4;
- case DIAMOND_PICKAXE:
- return 5;
- default:
- return false;
- }
- }
-}
-
diff --git a/src/material/item/base/ItemShovel.php b/src/material/item/base/ItemShovel.php
deleted file mode 100644
index 08c20b8f..00000000
--- a/src/material/item/base/ItemShovel.php
+++ /dev/null
@@ -1,26 +0,0 @@
-id){
- case WOODEN_SHOVEL:
- return 1;
- case GOLDEN_SHOVEL:
- return 2;
- case STONE_SHOVEL:
- return 3;
- case IRON_SHOVEL:
- return 4;
- case DIAMOND_SHOVEL:
- return 5;
- default:
- return false;
- }
- }
-}
-
diff --git a/src/material/item/base/ItemSword.php b/src/material/item/base/ItemSword.php
deleted file mode 100644
index 37f54b4d..00000000
--- a/src/material/item/base/ItemSword.php
+++ /dev/null
@@ -1,27 +0,0 @@
-id){
- case WOODEN_SWORD:
- return 1;
- case GOLDEN_SWORD:
- return 2;
- case STONE_SWORD:
- return 3;
- case IRON_SWORD:
- return 4;
- case DIAMOND_SWORD:
- return 5;
- default:
- return false;
- }
- }
-}
-
diff --git a/src/material/item/base/ItemTool.php b/src/material/item/base/ItemTool.php
deleted file mode 100644
index 3ba90125..00000000
--- a/src/material/item/base/ItemTool.php
+++ /dev/null
@@ -1,17 +0,0 @@
-isSword()){
- $this->meta += 2;
- }else{
- $this->meta++;
- }
- return true;
- }
-}
-
diff --git a/src/material/item/food/AppleItem.php b/src/material/item/food/AppleItem.php
deleted file mode 100755
index 8a74ec98..00000000
--- a/src/material/item/food/AppleItem.php
+++ /dev/null
@@ -1,8 +0,0 @@
-maxStackSize = 1;
- }
-
-}
\ No newline at end of file
diff --git a/src/material/item/food/BreadItem.php b/src/material/item/food/BreadItem.php
deleted file mode 100755
index c67e92bb..00000000
--- a/src/material/item/food/BreadItem.php
+++ /dev/null
@@ -1,8 +0,0 @@
-block = BlockAPI::get(CAKE_BLOCK);
- $this->maxStackSize = 1;
- }
-}
\ No newline at end of file
diff --git a/src/material/item/food/CarrotItem.php b/src/material/item/food/CarrotItem.php
deleted file mode 100755
index 8a29a17c..00000000
--- a/src/material/item/food/CarrotItem.php
+++ /dev/null
@@ -1,8 +0,0 @@
-block = BlockAPI::get(CARROT_BLOCK);
- parent::__construct(CARROT, 0, $count, "Carrot");
- }
-}
\ No newline at end of file
diff --git a/src/material/item/food/CookedChickenItem.php b/src/material/item/food/CookedChickenItem.php
deleted file mode 100644
index a543697f..00000000
--- a/src/material/item/food/CookedChickenItem.php
+++ /dev/null
@@ -1,8 +0,0 @@
-maxStackSize = 1;
- }
-
-}
\ No newline at end of file
diff --git a/src/material/item/food/PotatoItem.php b/src/material/item/food/PotatoItem.php
deleted file mode 100755
index 9aaa46a1..00000000
--- a/src/material/item/food/PotatoItem.php
+++ /dev/null
@@ -1,9 +0,0 @@
-block = BlockAPI::get(POTATO_BLOCK);
- parent::__construct(POTATO, 0, $count, "Potato");
- }
-
-}
\ No newline at end of file
diff --git a/src/material/item/food/PumpkinPieItem.php b/src/material/item/food/PumpkinPieItem.php
deleted file mode 100644
index 3c3ca3e2..00000000
--- a/src/material/item/food/PumpkinPieItem.php
+++ /dev/null
@@ -1,8 +0,0 @@
-block = BlockAPI::get(BED_BLOCK);
- parent::__construct(BED, 0, $count, "Bed");
- $this->maxStackSize = 1;
- }
-}
\ No newline at end of file
diff --git a/src/material/item/generic/BeetrootSeedsItem.php b/src/material/item/generic/BeetrootSeedsItem.php
deleted file mode 100644
index f0a1ddab..00000000
--- a/src/material/item/generic/BeetrootSeedsItem.php
+++ /dev/null
@@ -1,8 +0,0 @@
-block = BlockAPI::get(BEETROOT_BLOCK);
- parent::__construct(BEETROOT_SEEDS, 0, $count, "Beetroot Seeds");
- }
-}
\ No newline at end of file
diff --git a/src/material/item/generic/BoneItem.php b/src/material/item/generic/BoneItem.php
deleted file mode 100755
index 3a30ebfa..00000000
--- a/src/material/item/generic/BoneItem.php
+++ /dev/null
@@ -1,8 +0,0 @@
- "Bucket",
- 1 => "Milk Bucket",
- 8 => "Water Bucket",
- 10 => "Lava Bucket"
- );
- public function __construct($meta = 0, $count = 1){
- parent::__construct(BUCKET, $meta, $count, self::$possiblenames[$meta] ?? "Bucket");
- $this->isActivable = true;
- $this->maxStackSize = 1;
- }
-
- public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
- if($this->meta === AIR){
- if($target instanceof LiquidBlock){
- $level->setBlock($target, new AirBlock(), true, false, true);
- if(($player->gamemode & 0x01) === 0){
- $this->meta = ($target instanceof WaterBlock) ? WATER : LAVA;
- }
- return true;
- }
- }elseif($this->meta === WATER){
- //Support Make Non-Support Water to Support Water
- if($block->getID() === AIR || ( $block instanceof WaterBlock && ($block->getMetadata() & 0x07) != 0x00 ) ){
- $water = new WaterBlock();
- $level->setBlock($block, $water, true, false, true);
- $water->place($this, $player, $block, $target, $face, $fx, $fy, $fz);
- if(($player->gamemode & 0x01) === 0){
- $this->meta = 0;
- }
- return true;
- }
- }elseif($this->meta === LAVA){
- if($block->getID() === AIR){
- $lava = new LavaBlock();
- $level->setBlock($block, $lava, true, false, true);
- $lava->place(clone $this, $player, $block, $target, $face, $fx, $fy, $fz);
- if(($player->gamemode & 0x01) === 0){
- $this->meta = 0;
- }
- return true;
- }
- }
- return false;
- }
-}
diff --git a/src/material/item/generic/CameraItem.php b/src/material/item/generic/CameraItem.php
deleted file mode 100755
index 289f56a5..00000000
--- a/src/material/item/generic/CameraItem.php
+++ /dev/null
@@ -1,8 +0,0 @@
-meta === 1){
- $this->name = "Charcoal";
- }
- }
-
-}
\ No newline at end of file
diff --git a/src/material/item/generic/DiamondItem.php b/src/material/item/generic/DiamondItem.php
deleted file mode 100644
index 51404406..00000000
--- a/src/material/item/generic/DiamondItem.php
+++ /dev/null
@@ -1,8 +0,0 @@
- "Inc Sac",
- 1 => "Rose Red",
- 2 => "Cactus Green",
- 3 => "Cocoa Beans",
- 4 => "Lapis Lazuli",
- 5 => "Purple Dye",
- 6 => "Cyan Dye",
- 7 => "Light Gray Dye",
- 8 => "Gray Dye",
- 9 => "Pink Dye",
- 10 => "Lime Dye",
- 11 => "Dandelion Yellow",
- 12 => "Light Blue Dye",
- 13 => "Magenta Dye",
- 14 => "Orange Dye",
- 15 => "Bone Meal",
- );
-
- public function __construct($meta = 0, $count = 1){
- parent::__construct(DYE, $meta, $count, self::$names[$meta] ?? "Dye");
- }
-}
diff --git a/src/material/item/generic/EggItem.php b/src/material/item/generic/EggItem.php
deleted file mode 100755
index 5188b3c4..00000000
--- a/src/material/item/generic/EggItem.php
+++ /dev/null
@@ -1,9 +0,0 @@
-maxStackSize = 16;
- }
-
-}
\ No newline at end of file
diff --git a/src/material/item/generic/EmeraldItem.php b/src/material/item/generic/EmeraldItem.php
deleted file mode 100644
index 4bea0157..00000000
--- a/src/material/item/generic/EmeraldItem.php
+++ /dev/null
@@ -1,8 +0,0 @@
-block = BlockAPI::get(IRON_DOOR_BLOCK);
- parent::__construct(IRON_DOOR, 0, $count, "Iron Door");
- $this->maxStackSize = 1;
- }
-}
\ No newline at end of file
diff --git a/src/material/item/generic/IronIngotItem.php b/src/material/item/generic/IronIngotItem.php
deleted file mode 100755
index 8e9e4e2f..00000000
--- a/src/material/item/generic/IronIngotItem.php
+++ /dev/null
@@ -1,8 +0,0 @@
-block = BlockAPI::get(MELON_STEM);
- parent::__construct(MELON_SEEDS, 0, $count, "Melon Seeds");
- }
-}
\ No newline at end of file
diff --git a/src/material/item/generic/MinecartItem.php b/src/material/item/generic/MinecartItem.php
deleted file mode 100755
index 6d1f2cc0..00000000
--- a/src/material/item/generic/MinecartItem.php
+++ /dev/null
@@ -1,25 +0,0 @@
-isActivable = true;
- $this->maxStackSize = 1;
- }
- public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
- if($target->getID() !== 66 and $target->getID() !== 27){
- return;
- }
- $server = ServerAPI::request();
- $data = [
- "x" => $target->getX() + 0.5,
- "y" => $target->getY() + 0.8,
- "z" => $target->getZ() + 0.5,
- ];
- $e = $server->api->entity->add($level, ENTITY_OBJECT, OBJECT_MINECART, $data);
- $server->api->entity->spawnToAll($e);
- if(($player->gamemode & 0x01) === 0x00){
- $player->removeItem($this->getID(), $this->getMetadata(), 1, false);
- }
- }
-}
\ No newline at end of file
diff --git a/src/material/item/generic/NetherBrickItem.php b/src/material/item/generic/NetherBrickItem.php
deleted file mode 100755
index 7acda9d7..00000000
--- a/src/material/item/generic/NetherBrickItem.php
+++ /dev/null
@@ -1,8 +0,0 @@
-isActivable = true;
- }
- private static $motives = array(
- // Motive Width Height
- array("Wasteland", 1, 1),
- array("Wanderer", 1, 2),
- array("Graham", 1, 2),
- array("Pool", 2, 1),
- array("Courbet", 2, 1),
- array("Sunset", 2, 1),
- array("Sea", 2, 1),
- array("Creebet", 2, 1),
- array("Match", 2, 2),
- array("Bust", 2, 2),
- array("Stage", 2, 2),
- array("Void", 2, 2),
- array("SkullAndRoses", 2, 2),
- //array("Wither", 2, 2),
- array("Fighters", 4, 2),
- array("Skeleton", 4, 3),
- array("DonkeyKong", 4, 3),
- array("Pointer", 4, 4),
- array("Pigscene", 4, 4),
- array("Flaming Skull", 4, 4),
- );
- private static $direction = array(2, 0, 1, 3);
- private static $right = array(4, 5, 3, 2);
-
- public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
- if($target->isTransparent === false and $face > 1 and $block->isSolid === false){
- $server = ServerAPI::request();
- $faces = array(
- 2 => 1,
- 3 => 3,
- 4 => 0,
- 5 => 2,
-
- );
-
- $validMotives = array(
- array("Kebab", 1, 1),
- array("Aztec", 1, 1),
- array("Alban", 1, 1),
- array("Aztec2", 1, 1),
- array("Bomb", 1, 1),
- array("Plant", 1, 1),
- );
- foreach(PaintingItem::$motives as $motive){
- $valid = true;
- for($x = 0; $x <= $motive[1]; $x++){
- for($y = 0; $y <= $motive[2]; $y++){
- if ($target->getSide(PaintingItem::$right[$face - 2], $x)->isTransparent || $target->getSide(1, $y)->isTransparent
- || $block->getSide(PaintingItem::$right[$face - 2], $x)->isSolid || $block->getSide(1, $y)->isSolid) {
- $valid = false;
- break;
- }
- }
- if(!$valid){
- break;
- }
- }
- if ($valid) {
- $validMotives[] = $motive;
- }
- }
- $motive = $validMotives[array_rand($validMotives)]; //TODO simplify if possible
- $data = array(
- "x" => $target->x,
- "y" => $target->y,
- "z" => $target->z,
- "yaw" => $faces[$face] * 90,
- "Motive" => $motive[0],
- );
- $e = $server->api->entity->add($level, ENTITY_OBJECT, OBJECT_PAINTING, $data);
- $server->api->entity->spawnToAll($e);
- if(($player->gamemode & 0x01) === 0x00){
- $player->removeItem($this->getID(), $this->getMetadata(), 1, false);
- }
- return true;
- }
- return false;
- }
-
-}
\ No newline at end of file
diff --git a/src/material/item/generic/PaperItem.php b/src/material/item/generic/PaperItem.php
deleted file mode 100755
index 174fcdc8..00000000
--- a/src/material/item/generic/PaperItem.php
+++ /dev/null
@@ -1,8 +0,0 @@
-block = BlockAPI::get(PUMPKIN_STEM);
- parent::__construct(PUMPKIN_SEEDS, 0, $count, "Pumpkin Seeds");
- }
-}
\ No newline at end of file
diff --git a/src/material/item/generic/QuartzItem.php b/src/material/item/generic/QuartzItem.php
deleted file mode 100755
index 989559d4..00000000
--- a/src/material/item/generic/QuartzItem.php
+++ /dev/null
@@ -1,8 +0,0 @@
-block = BlockAPI::get(SIGN_POST);
- $this->maxStackSize = 16;
- }
-}
\ No newline at end of file
diff --git a/src/material/item/generic/SlimeballItem.php b/src/material/item/generic/SlimeballItem.php
deleted file mode 100755
index c5d1a4fb..00000000
--- a/src/material/item/generic/SlimeballItem.php
+++ /dev/null
@@ -1,8 +0,0 @@
-maxStackSize = 16;
- }
-
-}
\ No newline at end of file
diff --git a/src/material/item/generic/SpawnEggItem.php b/src/material/item/generic/SpawnEggItem.php
deleted file mode 100644
index 9deb6c76..00000000
--- a/src/material/item/generic/SpawnEggItem.php
+++ /dev/null
@@ -1,37 +0,0 @@
-meta = $meta;
- $this->isActivable = true;
- }
-
- public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
-
- if($target instanceof MonsterSpawnerBlock){
- $tile = ServerAPI::request()->api->tile->get($target);
- if($tile instanceof Tile){
- $tile->data["EntityId"] = $this->meta;
- //TODO update tile somehow
- }else{
- ConsoleAPI::warn("No tile was found at $target!");
- }
- return false;
- }
-
- $ageable = $this->meta === MOB_CHICKEN || $this->meta === MOB_COW || $this->meta === MOB_SHEEP || $this->meta === MOB_PIG;
- $data = array(
- "x" => $block->x + 0.5,
- "y" => $block->y,
- "z" => $block->z + 0.5,
- "IsBaby" => $ageable ? Utils::chance(5) ? 1 : 0 : 0
- );
- $e = ServerAPI::request()->api->entity->add($block->level, ENTITY_MOB, $this->meta, $data);
- ServerAPI::request()->api->entity->spawnToAll($e);
- if(($player->gamemode & 0x01) === 0){
- -- $this->count;
- }
- return true;
- }
-}
\ No newline at end of file
diff --git a/src/material/item/generic/StickItem.php b/src/material/item/generic/StickItem.php
deleted file mode 100644
index 9895daa1..00000000
--- a/src/material/item/generic/StickItem.php
+++ /dev/null
@@ -1,8 +0,0 @@
-block = BlockAPI::get(SUGARCANE_BLOCK);
- parent::__construct(SUGARCANE, 0, $count, "Sugar Cane");
- }
-}
\ No newline at end of file
diff --git a/src/material/item/generic/WheatItem.php b/src/material/item/generic/WheatItem.php
deleted file mode 100644
index 0c8e0eac..00000000
--- a/src/material/item/generic/WheatItem.php
+++ /dev/null
@@ -1,8 +0,0 @@
-block = BlockAPI::get(WHEAT_BLOCK);
- parent::__construct(WHEAT_SEEDS, 0, $count, "Wheat Seeds");
- }
-}
\ No newline at end of file
diff --git a/src/material/item/generic/WoodenDoorItem.php b/src/material/item/generic/WoodenDoorItem.php
deleted file mode 100644
index a9f50031..00000000
--- a/src/material/item/generic/WoodenDoorItem.php
+++ /dev/null
@@ -1,9 +0,0 @@
-block = BlockAPI::get(WOODEN_DOOR_BLOCK);
- parent::__construct(WOODEN_DOOR, 0, $count, "Wooden Door");
- $this->maxStackSize = 1;
- }
-}
\ No newline at end of file
diff --git a/src/material/item/tool/BowItem.php b/src/material/item/tool/BowItem.php
deleted file mode 100644
index 0b2d5ef8..00000000
--- a/src/material/item/tool/BowItem.php
+++ /dev/null
@@ -1,10 +0,0 @@
-maxStackSize = 1;
- }
-
-}
\ No newline at end of file
diff --git a/src/material/item/tool/DiamondAxeItem.php b/src/material/item/tool/DiamondAxeItem.php
deleted file mode 100644
index 7cb03b24..00000000
--- a/src/material/item/tool/DiamondAxeItem.php
+++ /dev/null
@@ -1,11 +0,0 @@
-isActivable = true;
- $this->maxStackSize = 1;
- }
-
- public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
- if(($player->gamemode & 0x01) === 0 and $this->useOn($block) and $this->getMetadata() >= $this->getMaxDurability()){
- $player->setSlot($player->slot, new Item(AIR, 0, 0), false); //TODO check
- }
-
- if($block->getID() === AIR and ($target instanceof SolidBlock)){
- $level->setBlock($block, new FireBlock(), true, false, true);
- $block->level->scheduleBlockUpdate($block, Utils::getRandomUpdateTicks(), BLOCK_UPDATE_RANDOM);
- return true;
- }
- return false;
- }
-
- public function useOn($object, $force = false){
- if(($object instanceof Creeper) and $this->id === FLINT_STEEL){
- $this->meta++;
- return true;
- }else{
- return $force ? parent::useOn($object, $force) : $force;
- }
- }
-}
\ No newline at end of file
diff --git a/src/material/item/tool/GoldenAxeItem.php b/src/material/item/tool/GoldenAxeItem.php
deleted file mode 100755
index 0bf1e57e..00000000
--- a/src/material/item/tool/GoldenAxeItem.php
+++ /dev/null
@@ -1,10 +0,0 @@
-id === SHEARS){
- $this->meta++;
- return true;
- }
- parent::useOn($object, $force);
- }
-}
\ No newline at end of file
diff --git a/src/material/item/tool/StoneAxeItem.php b/src/material/item/tool/StoneAxeItem.php
deleted file mode 100644
index b3f948f7..00000000
--- a/src/material/item/tool/StoneAxeItem.php
+++ /dev/null
@@ -1,11 +0,0 @@
-minX = $minX;
- $this->minY = $minY;
- $this->minZ = $minZ;
- $this->maxX = $maxX;
- $this->maxY = $maxY;
- $this->maxZ = $maxZ;
- }
-
- public function setBounds($minX, $minY, $minZ, $maxX, $maxY, $maxZ){
- $this->minX = $minX;
- $this->minY = $minY;
- $this->minZ = $minZ;
- $this->maxX = $maxX;
- $this->maxY = $maxY;
- $this->maxZ = $maxZ;
-
- return $this;
- }
-
- public function addCoord($x, $y, $z){
- $minX = $this->minX;
- $minY = $this->minY;
- $minZ = $this->minZ;
- $maxX = $this->maxX;
- $maxY = $this->maxY;
- $maxZ = $this->maxZ;
-
- if($x < 0){
- $minX += $x;
- }elseif($x > 0){
- $maxX += $x;
- }
-
- if($y < 0){
- $minY += $y;
- }elseif($y > 0){
- $maxY += $y;
- }
-
- if($z < 0){
- $minZ += $z;
- }elseif($z > 0){
- $maxZ += $z;
- }
-
- return new AxisAlignedBB($minX, $minY, $minZ, $maxX, $maxY, $maxZ);
- }
-
- public function grow($x, $y, $z){
- return new AxisAlignedBB($this->minX - $x, $this->minY - $y, $this->minZ - $z, $this->maxX + $x, $this->maxY + $y, $this->maxZ + $z);
- }
-
- public function expand($x, $y, $z){
- $this->minX -= $x;
- $this->minY -= $y;
- $this->minZ -= $z;
- $this->maxX += $x;
- $this->maxY += $y;
- $this->maxZ += $z;
-
- return $this;
- }
-
-
- public function offset($x, $y, $z){
- $this->minX += $x;
- $this->minY += $y;
- $this->minZ += $z;
- $this->maxX += $x;
- $this->maxY += $y;
- $this->maxZ += $z;
-
- return $this;
- }
-
- public function shrink($x, $y, $z){
- return new AxisAlignedBB($this->minX + $x, $this->minY + $y, $this->minZ + $z, $this->maxX - $x, $this->maxY - $y, $this->maxZ - $z);
- }
-
- public function contract($x, $y, $z){
- $this->minX += $x;
- $this->minY += $y;
- $this->minZ += $z;
- $this->maxX -= $x;
- $this->maxY -= $y;
- $this->maxZ -= $z;
-
- return $this;
- }
-
- public function setBB(AxisAlignedBB $bb){
- $this->minX = $bb->minX;
- $this->minY = $bb->minY;
- $this->minZ = $bb->minZ;
- $this->maxX = $bb->maxX;
- $this->maxY = $bb->maxY;
- $this->maxZ = $bb->maxZ;
- return $this;
- }
-
- public function getOffsetBoundingBox($x, $y, $z){
- return new AxisAlignedBB($this->minX + $x, $this->minY + $y, $this->minZ + $z, $this->maxX + $x, $this->maxY + $y, $this->maxZ + $z);
- }
-
- public function calculateXOffset(AxisAlignedBB $bb, $x){
- if($bb->maxY <= $this->minY or $bb->minY >= $this->maxY){
- return $x;
- }
- if($bb->maxZ <= $this->minZ or $bb->minZ >= $this->maxZ){
- return $x;
- }
- if($x > 0 and $bb->maxX <= $this->minX){
- $x1 = $this->minX - $bb->maxX;
- if($x1 < $x){
- $x = $x1;
- }
- }
- if($x < 0 and $bb->minX >= $this->maxX){
- $x2 = $this->maxX - $bb->minX;
- if($x2 > $x){
- $x = $x2;
- }
- }
-
- return $x;
- }
-
- public function calculateYOffset(AxisAlignedBB $bb, $y){
- if($bb->maxX <= $this->minX or $bb->minX >= $this->maxX){
- return $y;
- }
- if($bb->maxZ <= $this->minZ or $bb->minZ >= $this->maxZ){
- return $y;
- }
- if($y > 0 and $bb->maxY <= $this->minY){
- $y1 = $this->minY - $bb->maxY;
- if($y1 < $y){
- $y = $y1;
- }
- }
- if($y < 0 and $bb->minY >= $this->maxY){
- $y2 = $this->maxY - $bb->minY;
- if($y2 > $y){
- $y = $y2;
- }
- }
-
- return $y;
- }
-
- public function calculateZOffset(AxisAlignedBB $bb, $z){
- if($bb->maxX <= $this->minX or $bb->minX >= $this->maxX){
- return $z;
- }
- if($bb->maxY <= $this->minY or $bb->minY >= $this->maxY){
- return $z;
- }
- if($z > 0 and $bb->maxZ <= $this->minZ){
- $z1 = $this->minZ - $bb->maxZ;
- if($z1 < $z){
- $z = $z1;
- }
- }
- if($z < 0 and $bb->minZ >= $this->maxZ){
- $z2 = $this->maxZ - $bb->minZ;
- if($z2 > $z){
- $z = $z2;
- }
- }
-
- return $z;
- }
-
- public function intersectsWith(AxisAlignedBB $bb){
- if($bb->maxX > $this->minX and $bb->minX < $this->maxX){
- if($bb->maxY > $this->minY and $bb->minY < $this->maxY){
- return $bb->maxZ > $this->minZ and $bb->minZ < $this->maxZ;
- }
- }
-
- return false;
- }
-
- public function isXYZInside($x, $y, $z){
- if($x <= $this->minX or $x >= $this->maxX){
- return false;
- }
- if($y <= $this->minY or $y >= $this->maxY){
- return false;
- }
-
- return $z > $this->minZ and $z < $this->maxZ;
- }
- public function isVectorInside(Vector3 $vector){
- if($vector->x <= $this->minX or $vector->x >= $this->maxX){
- return false;
- }
- if($vector->y <= $this->minY or $vector->y >= $this->maxY){
- return false;
- }
-
- return $vector->z > $this->minZ and $vector->z < $this->maxZ;
- }
-
- public function getAverageEdgeLength(){
- return ($this->maxX - $this->minX + $this->maxY - $this->minY + $this->maxZ - $this->minZ) / 3;
- }
-
- public function isVectorInYZ(Vector3 $vector){
- return $vector->y >= $this->minY and $vector->y <= $this->maxY and $vector->z >= $this->minZ and $vector->z <= $this->maxZ;
- }
-
- public function isVectorInXZ(Vector3 $vector){
- return $vector->x >= $this->minX and $vector->x <= $this->maxX and $vector->z >= $this->minZ and $vector->z <= $this->maxZ;
- }
-
- public function isVectorInXY(Vector3 $vector){
- return $vector->x >= $this->minX and $vector->x <= $this->maxX and $vector->y >= $this->minY and $vector->y <= $this->maxY;
- }
-
- public function calculateIntercept(Vector3 $pos1, Vector3 $pos2){
- $v1 = $pos1->getIntermediateWithXValue($pos2, $this->minX);
- $v2 = $pos1->getIntermediateWithXValue($pos2, $this->maxX);
- $v3 = $pos1->getIntermediateWithYValue($pos2, $this->minY);
- $v4 = $pos1->getIntermediateWithYValue($pos2, $this->maxY);
- $v5 = $pos1->getIntermediateWithZValue($pos2, $this->minZ);
- $v6 = $pos1->getIntermediateWithZValue($pos2, $this->maxZ);
-
- if($v1 !== null and !$this->isVectorInYZ($v1)){
- $v1 = null;
- }
-
- if($v2 !== null and !$this->isVectorInYZ($v2)){
- $v2 = null;
- }
-
- if($v3 !== null and !$this->isVectorInXZ($v3)){
- $v3 = null;
- }
-
- if($v4 !== null and !$this->isVectorInXZ($v4)){
- $v4 = null;
- }
-
- if($v5 !== null and !$this->isVectorInXY($v5)){
- $v5 = null;
- }
-
- if($v6 !== null and !$this->isVectorInXY($v6)){
- $v6 = null;
- }
-
- $vector = $v1;
-
- if($v2 !== null and ($vector === null or $pos1->distanceSquared($v2) < $pos1->distanceSquared($vector))){
- $vector = $v2;
- }
-
- if($v3 !== null and ($vector === null or $pos1->distanceSquared($v3) < $pos1->distanceSquared($vector))){
- $vector = $v3;
- }
-
- if($v4 !== null and ($vector === null or $pos1->distanceSquared($v4) < $pos1->distanceSquared($vector))){
- $vector = $v4;
- }
-
- if($v5 !== null and ($vector === null or $pos1->distanceSquared($v5) < $pos1->distanceSquared($vector))){
- $vector = $v5;
- }
-
- if($v6 !== null and ($vector === null or $pos1->distanceSquared($v6) < $pos1->distanceSquared($vector))){
- $vector = $v6;
- }
-
- if($vector === null){
- return null;
- }
-
- $f = -1;
-
- if($vector === $v1){
- $f = 4;
- }elseif($vector === $v2){
- $f = 5;
- }elseif($vector === $v3){
- $f = 0;
- }elseif($vector === $v4){
- $f = 1;
- }elseif($vector === $v5){
- $f = 2;
- }elseif($vector === $v6){
- $f = 3;
- }
-
- return MovingObjectPosition::fromBlock(0, 0, 0, $f, $vector);
- }
-
- public function expandTo(AxisAlignedBB $bb){
- $this->minX = min($this->minX, $bb->minX);
- $this->minY = min($this->minY, $bb->minY);
- $this->minZ = min($this->minZ, $bb->minZ);
- $this->maxX = max($this->maxX, $bb->maxX);
- $this->maxY = max($this->maxY, $bb->maxY);
- $this->maxZ = max($this->maxZ, $bb->maxZ);
- }
-
- public function getXSize(){
- return $this->maxX - $this->minX + 1;
- }
-
- public function getYSize(){
- return $this->maxY - $this->minY + 1;
- }
-
- public function getZSize(){
- return $this->maxZ - $this->minZ + 1;
- }
-
-
- public function __toString(){
- return "min: {$this->minX}, {$this->minY}, {$this->minZ}, max: {$this->maxX}, {$this->maxY}, {$this->maxZ}";
- }
-
-}
\ No newline at end of file
diff --git a/src/math/Matrix.php b/src/math/Matrix.php
deleted file mode 100644
index c62bbb98..00000000
--- a/src/math/Matrix.php
+++ /dev/null
@@ -1,169 +0,0 @@
-rows = max(1, (int) $rows);
- $this->columns = max(1, (int) $columns);
- $this->set($set);
- }
-
- public function set(array $m){
- for($r = 0; $r < $this->rows; ++$r){
- $this->matrix[$r] = [];
- for($c = 0; $c < $this->columns; ++$c){
- $this->matrix[$r][$c] = isset($m[$r][$c]) ? $m[$r][$c] : 0;
- }
- }
- }
-
- public function offsetExists(mixed $offset): bool{
- return isset($this->matrix[(int) $offset]);
- }
-
- public function offsetGet(mixed $offset): mixed{
- return $this->matrix[(int) $offset];
- }
-
- public function offsetSet(mixed $offset, mixed $value): void{
- $this->matrix[(int) $offset] = $value;
- }
-
- public function offsetUnset(mixed $offset): void{
- unset($this->matrix[(int) $offset]);
- }
-
- public function add(Matrix $matrix){
- if($this->rows !== $matrix->getRows() or $this->columns !== $matrix->getColumns()){
- return false;
- }
- $result = new Matrix($this->rows, $this->columns);
- for($r = 0; $r < $this->rows; ++$r){
- for($c = 0; $c < $this->columns; ++$c){
- $result->setElement($r, $c, $this->matrix[$r][$c] + $matrix->getElement($r, $c));
- }
- }
- return $result;
- }
-
- public function getRows(){
- return ($this->rows);
- }
-
- public function getColumns(){
- return ($this->columns);
- }
-
- public function setElement($row, $column, $value){
- if($row > $this->rows or $row < 0 or $column > $this->columns or $column < 0){
- return false;
- }
- $this->matrix[(int) $row][(int) $column] = $value;
- return true;
- }
-
- public function getElement($row, $column){
- if($row > $this->rows or $row < 0 or $column > $this->columns or $column < 0){
- return false;
- }
- return $this->matrix[(int) $row][(int) $column];
- }
-
- public function substract(Matrix $matrix){
- if($this->rows !== $matrix->getRows() or $this->columns !== $matrix->getColumns()){
- return false;
- }
- $result = clone $this;
- for($r = 0; $r < $this->rows; ++$r){
- for($c = 0; $c < $this->columns; ++$c){
- $result->setElement($r, $c, $this->matrix[$r][$c] - $matrix->getElement($r, $c));
- }
- }
- return $result;
- }
-
- public function multiplyScalar($number){
- $result = clone $this;
- for($r = 0; $r < $this->rows; ++$r){
- for($c = 0; $c < $this->columns; ++$c){
- $result->setElement($r, $c, $this->matrix[$r][$c] * $number);
- }
- }
- return $result;
- }
-
- public function divideScalar($number){
- $result = clone $this;
- for($r = 0; $r < $this->rows; ++$r){
- for($c = 0; $c < $this->columns; ++$c){
- $result->setElement($r, $c, $this->matrix[$r][$c] / $number);
- }
- }
- return $result;
- }
-
- public function transpose(){
- $result = new Matrix($this->columns, $this->rows);
- for($r = 0; $r < $this->rows; ++$r){
- for($c = 0; $c < $this->columns; ++$c){
- $result->setElement($c, $r, $this->matrix[$r][$c]);
- }
- }
- return $result;
- }
-
- public function product(Matrix $matrix){
- if($this->columns !== $matrix->getRows()){
- return false;
- }
- $c = $matrix->getColumns();
- $result = new Matrix($this->rows, $c);
- for($i = 0; $i < $this->rows; ++$i){
- for($j = 0; $j < $c; ++$j){
- $sum = 0;
- for($k = 0; $k < $this->columns; ++$k){
- $sum += $this->matrix[$i][$k] * $matrix->getElement($k, $j);
- }
- $result->setElement($i, $j, $sum);
- }
- }
- return $result;
- }
-
- //Naive Matrix product, O(n^3)
-
- public function determinant(){
- if($this->isSquare() !== true){
- return false;
- }
- switch($this->rows){
- case 1:
- return 0;
- case 2:
- return $this->matrix[0][0] * $this->matrix[1][1] - $this->matrix[0][1] * $this->matrix[1][0];
- case 3:
- return $this->matrix[0][0] * $this->matrix[1][1] * $this->matrix[2][2] + $this->matrix[0][1] * $this->matrix[1][2] * $this->matrix[2][0] + $this->matrix[0][2] * $this->matrix[1][0] * $this->matrix[2][1] - $this->matrix[2][0] * $this->matrix[1][1] * $this->matrix[0][2] - $this->matrix[2][1] * $this->matrix[1][2] * $this->matrix[0][0] - $this->matrix[2][2] * $this->matrix[1][0] * $this->matrix[0][1];
- }
- return false;
- }
-
-
- //Computation of the determinant of 2x2 and 3x3 matrices
-
- public function isSquare(){
- return $this->rows === $this->columns;
- }
-
- public function __toString(){
- $s = "";
- for($r = 0; $r < $this->rows; ++$r){
- $s .= implode(",", $this->matrix[$r]) . ";";
- }
- return "Matrix({$this->rows}x{$this->columns};" . substr($s, 0, -1) . ")";
- }
-
-}
\ No newline at end of file
diff --git a/src/math/StructureAABB.php b/src/math/StructureAABB.php
deleted file mode 100644
index f85f8709..00000000
--- a/src/math/StructureAABB.php
+++ /dev/null
@@ -1,18 +0,0 @@
-intersectsWith($bb->minX, $bb->minZ, $bb->maxX, $bb->maxZ);
- }
- return $this->maxX >= $bb && $this->minX <= $maxX && $this->maxZ >= $minZ && $this->minZ <= $maxZ;
- }
-
-}
-
diff --git a/src/math/Vector2.php b/src/math/Vector2.php
deleted file mode 100644
index 8ce96c4d..00000000
--- a/src/math/Vector2.php
+++ /dev/null
@@ -1,109 +0,0 @@
-x = $x;
- $this->y = $y;
- }
-
- public function getX(){
- return $this->x;
- }
-
- public function getY(){
- return $this->y;
- }
-
- public function getFloorX(){
- return (int) $this->x;
- }
-
- public function getFloorY(){
- return (int) $this->y;
- }
-
- public function subtract($x = 0, $y = 0){
- if(($x instanceof Vector2) === true){
- return $this->add(-$x->x, -$x->y);
- }else{
- return $this->add(-$x, -$y);
- }
- }
-
- public function add($x = 0, $y = 0){
- if(($x instanceof Vector2) === true){
- return $this->add($x->x, $x->y);
- }else{
- $this->x += $x;
- $this->y += $y;
- return new Vector2($this->x + $x, $this->y + $y);
- }
- }
-
- public function ceil(){
- return new Vector2((int) ($this->x + 1), (int) ($this->y + 1));
- }
-
- public function floor(){
- return new Vector2((int) $this->x, (int) $this->y);
- }
-
- public function round(){
- return new Vector2(round($this->x), round($this->y));
- }
-
- public function abs(){
- return new Vector2(abs($this->x), abs($this->y));
- }
-
- public function multiply($number){
- return new Vector2($this->x * $number, $this->y * $number);
- }
-
- public function distance($x = 0, $y = 0){
- if(($x instanceof Vector2) === true){
- return sqrt($this->distanceSquared($x->x, $x->y));
- }else{
- return sqrt($this->distanceSquared($x, $y));
- }
- }
-
- public function distanceSquared($x = 0, $y = 0){
- if(($x instanceof Vector2) === true){
- return $this->distanceSquared($x->x, $x->y);
- }else{
- return pow($this->x - $x, 2) + pow($this->y - $y, 2);
- }
- }
-
- public function normalize(){
- $len = $this->length();
- if($len != 0){
- return $this->divide($len);
- }
- return new Vector2(0, 0);
- }
-
- public function length(){
- return sqrt($this->lengthSquared());
- }
-
- public function lengthSquared(){
- return $this->x * $this->x + $this->y * $this->y;
- }
-
- public function divide($number){
- return new Vector2($this->x / $number, $this->y / $number);
- }
-
- public function dot(Vector2 $v){
- return $this->x * $v->x + $this->y * $v->y;
- }
-
- public function __toString(){
- return "Vector2(x=" . $this->x . ",y=" . $this->y . ")";
- }
-}
\ No newline at end of file
diff --git a/src/math/Vector3.php b/src/math/Vector3.php
deleted file mode 100644
index e472039a..00000000
--- a/src/math/Vector3.php
+++ /dev/null
@@ -1,189 +0,0 @@
-x = $x;
- $this->y = $y;
- $this->z = $z;
- }
-
- public function setXYZ($x, $y, $z){
- $this->x = $x;
- $this->y = $y;
- $this->z = $z;
- }
-
- public function copy(){
- return new Vector3($this->x, $this->y, $this->z);
- }
-
- public function toArray(){
- return ["x" => $this->x, "y" => $this->y, "z" => $this->z];
- }
-
- public function getFloorX(){
- return (int) $this->x;
- }
-
- public function getFloorY(){
- return (int) $this->y;
- }
-
- public function getFloorZ(){
- return (int) $this->z;
- }
-
- public function getRight(){
- return $this->getX();
- }
-
- public function getX(){
- return $this->x;
- }
-
- public function getUp(){
- return $this->getY();
- }
-
- public function getY(){
- return $this->y;
- }
-
- public function getForward(){
- return $this->getZ();
- }
-
- public function getZ(){
- return $this->z;
- }
-
- public function getSouth(){
- return $this->getX();
- }
-
- public function getWest(){
- return $this->getZ();
- }
-
- public function subtract($x = 0, $y = 0, $z = 0){
- if(($x instanceof Vector3) === true){
- return $this->subtract($x->x, $x->y, $x->z);
- }else{
- return new Vector3($this->x - $x, $this->y - $y, $this->z - $z);
- }
- }
-
- public function add($x = 0, $y = 0, $z = 0){
- if(($x instanceof Vector3) === true){
- return $this->add($x->x, $x->y, $x->z);
- }else{
- return new Vector3($this->x + $x, $this->y + $y, $this->z + $z);
- }
- }
-
- public function multiply($number){
- return new Vector3($this->x * $number, $this->y * $number, $this->z * $number);
- }
-
- public function ceil(){
- return new Vector3((int) ($this->x + 1), (int) ($this->y + 1), (int) ($this->z + 1));
- }
-
- public function floor(){
- return new Vector3((int) $this->x, (int) $this->y, (int) $this->z);
- }
-
- public function round(){
- return new Vector3(round($this->x), round($this->y), round($this->z));
- }
-
- public function abs(){
- return new Vector3(abs($this->x), abs($this->y), abs($this->z));
- }
-
- public function getSide($side, $step = 1){
- switch((int) $side){
- case 0:
- return new Vector3($this->x, $this->y - $step, $this->z);
- case 1:
- return new Vector3($this->x, $this->y + $step, $this->z);
- case 2:
- return new Vector3($this->x, $this->y, $this->z - $step);
- case 3:
- return new Vector3($this->x, $this->y, $this->z + $step);
- case 4:
- return new Vector3($this->x - $step, $this->y, $this->z);
- case 5:
- return new Vector3($this->x + $step, $this->y, $this->z);
- default:
- return $this;
- }
- }
-
- public function distance($x = 0, $y = 0, $z = 0){
- if(($x instanceof Vector3) === true){
- return sqrt($this->distanceSquared($x->x, $x->y, $x->z));
- }else{
- return sqrt($this->distanceSquared($x, $y, $z));
- }
- }
-
- public function distanceSquared($x = 0, $y = 0, $z = 0){
- if(($x instanceof Vector3) === true){
- return $this->distanceSquared($x->x, $x->y, $x->z);
- }else{
- return pow($this->x - $x, 2) + pow($this->y - $y, 2) + pow($this->z - $z, 2);
- }
- }
-
- public function maxPlainDistance($x = 0, $z = 0){
- if(($x instanceof Vector3) === true){
- return $this->maxPlainDistance($x->x, $x->z);
- }else{
- return max(abs($this->x - $x), abs($this->z - $z));
- }
- }
-
- public function normalize(){
- $len = $this->length();
- if($len != 0){
- return $this->divide($len);
- }
- return new Vector3(0, 0, 0);
- }
-
- public function length(){
- return sqrt($this->lengthSquared());
- }
-
- public function lengthSquared(){
- return $this->x * $this->x + $this->y * $this->y + $this->z * $this->z;
- }
-
- public function divide($number){
- return new Vector3($this->x / $number, $this->y / $number, $this->z / $number);
- }
-
- public function dot(Vector3 $v){
- return $this->x * $v->x + $this->y * $v->y + $this->z * $v->z;
- }
-
- public function cross(Vector3 $v){
- return new Vector3(
- $this->y * $v->z - $this->z * $v->y,
- $this->z * $v->x - $this->x * $v->z,
- $this->x * $v->y - $this->y * $v->x
- );
- }
-
- public static function fromArray($arr){
- return new Vector3($arr[0], $arr[1], $arr[2]);
- }
-
- public function __toString(){
- return "Vector3(x=" . $this->x . ",y=" . $this->y . ",z=" . $this->z . ")";
- }
-}
\ No newline at end of file
diff --git a/src/math/Vector3Pos.php b/src/math/Vector3Pos.php
deleted file mode 100644
index 7edf577f..00000000
--- a/src/math/Vector3Pos.php
+++ /dev/null
@@ -1,20 +0,0 @@
-x = &$x;
- $this->y = &$y;
- $this->z = &$z;
- }
-
- public function addToValues($v){
- $this->x += $v->x;
- $this->y += $v->y;
- $this->z += $v->z;
- return $this;
- }
-
-}
-
diff --git a/src/math/VectorMath.php b/src/math/VectorMath.php
deleted file mode 100644
index ba65b941..00000000
--- a/src/math/VectorMath.php
+++ /dev/null
@@ -1,8 +0,0 @@
-offset = strlen($this->buffer) - 1;
-
- return "";
- }elseif($len === true){
- return substr($this->buffer, $this->offset);
- }
- if($len > 1024){
- return substr($this->buffer, ($this->offset += $len) - $len, $len);
- }
- $buffer = "";
- for(; $len > 0; --$len, ++$this->offset){
- $buffer .= @$this->buffer[$this->offset];
- }
-
- return $buffer;
- }
-
- public function put($v){
- $this->buffer .= $v;
- }
-
- public function feof(){
- return !isset($this->buffer{$this->offset});
- }
-
- public function __construct($endianness = self::LITTLE_ENDIAN){
- $this->offset = 0;
- $this->endianness = $endianness & 0x01;
- }
-
- public function read($buffer){
- $this->offset = 0;
- $this->buffer = $buffer;
- $this->data = $this->readTag();
- $this->buffer = "";
- }
-
- public function readCompressed($buffer, $compression = ZLIB_ENCODING_GZIP){
- $this->read(zlib_decode($buffer));
- }
-
- public function write(){
- $this->offset = 0;
- if($this->data instanceof Compound){
- $this->writeTag($this->data);
-
- return $this->buffer;
- }else{
- return false;
- }
- }
-
- public function writeCompressed($compression = ZLIB_ENCODING_GZIP, $level = 7){
- if(($write = $this->write()) !== false){
- return zlib_encode($write, $compression, $level);
- }
-
- return false;
- }
-
- public function readTag(){
- switch($this->getByte()){
- case NBT::TAG_Byte:
- $tag = new Byte($this->getString());
- $tag->read($this);
- break;
- case NBT::TAG_Short:
- $tag = new Short($this->getString());
- $tag->read($this);
- break;
- case NBT::TAG_Int:
- $tag = new IntTag($this->getString());
- $tag->read($this);
- break;
- case NBT::TAG_Long:
- $tag = new Long($this->getString());
- $tag->read($this);
- break;
- case NBT::TAG_Float:
- $tag = new FloatTag($this->getString());
- $tag->read($this);
- break;
- case NBT::TAG_Double:
- $tag = new Double($this->getString());
- $tag->read($this);
- break;
- case NBT::TAG_ByteArray:
- $tag = new ByteArray($this->getString());
- $tag->read($this);
- break;
- case NBT::TAG_String:
- $tag = new StringTag($this->getString());
- $tag->read($this);
- break;
- case NBT::TAG_Enum:
- $tag = new EnumTag($this->getString());
- $tag->read($this);
- break;
- case NBT::TAG_Compound:
- $tag = new Compound($this->getString());
- $tag->read($this);
- break;
- case NBT::TAG_IntArray:
- $tag = new IntArray($this->getString());
- $tag->read($this);
- break;
-
- case NBT::TAG_End: //No named tag
- default:
- $tag = new End;
- break;
- }
- return $tag;
- }
-
- public function writeTag(Tag $tag){
- $this->putByte($tag->getType());
- if($tag instanceof NamedTAG){
- $this->putString($tag->getName());
- }
- $tag->write($this);
- }
-
- public function getByte($signed = false){
- return Utils::readByte($this->get(1), $signed);
- }
-
- public function putByte($v){
- $this->buffer .= Utils::writeByte($v);
- }
-
- public function getShort(){
- return $this->endianness === self::BIG_ENDIAN ? Utils::readShort($this->get(2)) : Utils::readLShort($this->get(2));
- }
-
- public function putShort($v){
- $this->buffer .= $this->endianness === self::BIG_ENDIAN ? Utils::writeShort($v) : Utils::writeLShort($v);
- }
-
- public function getInt(){
- return $this->endianness === self::BIG_ENDIAN ? Utils::readInt($this->get(4)) : Utils::readLInt($this->get(4));
- }
-
- public function putInt($v){
- $this->buffer .= $this->endianness === self::BIG_ENDIAN ? Utils::writeInt($v) : Utils::writeLInt($v);
- }
-
- public function getLong(){
- return $this->endianness === self::BIG_ENDIAN ? Utils::readLong($this->get(8)) : Utils::readLLong($this->get(8));
- }
-
- public function putLong($v){
- $this->buffer .= $this->endianness === self::BIG_ENDIAN ? Utils::writeLong($v) : Utils::writeLLong($v);
- }
-
- public function getFloat(){
- return $this->endianness === self::BIG_ENDIAN ? Utils::readFloat($this->get(4)) : Utils::readLFloat($this->get(4));
- }
-
- public function putFloat($v){
- $this->buffer .= $this->endianness === self::BIG_ENDIAN ? Utils::writeFloat($v) : Utils::writeLFloat($v);
- }
-
- public function getDouble(){
- return $this->endianness === self::BIG_ENDIAN ? Utils::readDouble($this->get(8)) : Utils::readLDouble($this->get(8));
- }
-
- public function putDouble($v){
- $this->buffer .= $this->endianness === self::BIG_ENDIAN ? Utils::writeDouble($v) : Utils::writeLDouble($v);
- }
-
- public function getString(){
- return $this->get($this->getShort());
- }
-
- public function putString($v){
- $this->putShort(strlen($v));
- $this->buffer .= $v;
- }
-
- public function getData(){
- return $this->data;
- }
-
- public function setData(Compound $data){
- $this->data = $data;
- }
-
-}
diff --git a/src/nbt/tag/Byte.php b/src/nbt/tag/Byte.php
deleted file mode 100644
index 4b0a5141..00000000
--- a/src/nbt/tag/Byte.php
+++ /dev/null
@@ -1,35 +0,0 @@
-value = $NBT_new->getByte(true);
- }
-
- public function write(NBT_new $NBT_new){
- $NBT_new->putByte($this->value);
- }
-}
\ No newline at end of file
diff --git a/src/nbt/tag/ByteArray.php b/src/nbt/tag/ByteArray.php
deleted file mode 100644
index c7abc98e..00000000
--- a/src/nbt/tag/ByteArray.php
+++ /dev/null
@@ -1,36 +0,0 @@
-value = $NBT_new->get($NBT_new->getInt());
- }
-
- public function write(NBT_new $NBT_new){
- $NBT_new->putInt(strlen($this->value));
- $NBT_new->put($this->value);
- }
-}
\ No newline at end of file
diff --git a/src/nbt/tag/Compound.php b/src/nbt/tag/Compound.php
deleted file mode 100644
index fa08fb92..00000000
--- a/src/nbt/tag/Compound.php
+++ /dev/null
@@ -1,81 +0,0 @@
-name = $name;
- foreach($value as $tag){
- $this->{$tag->getName()} = $tag;
- }
- }
-
- public function offsetExists(mixed $offset): bool{
- return isset($this->{$offset});
- }
-
- public function offsetGet(mixed $offset): mixed{
- if($this->{$offset} instanceof Tag){
- if($this->{$offset} instanceof \ArrayAccess){
- return $this->{$offset};
- }else{
- return $this->{$offset}->getValue();
- }
- }
-
- return null;
- }
-
- public function offsetSet(mixed $offset, mixed $value): void{
- if($value instanceof Tag){
- $this->{$offset} = $value;
- }elseif(isset($this->{$offset}) and $this->{$offset} instanceof Tag){
- $this->{$offset}->setValue($value);
- }
- }
-
- public function offsetUnset(mixed $offset): void{
- unset($this->{$offset});
- }
-
- public function getType(){
- return NBT_new::TAG_Compound;
- }
-
- public function read(NBT_new $NBT_new){
- $this->value = [];
- do{
- $tag = $NBT_new->readTag();
- if($tag instanceof NamedTag and $tag->getName() !== ""){
- $this->{$tag->getName()} = $tag;
- }
- }while(!($tag instanceof End) and !$NBT_new->feof());
- }
-
- public function write(NBT_new $NBT_new){
- foreach($this as $tag){
- if($tag instanceof Tag and !($tag instanceof End)){
- $NBT_new->writeTag($tag);
- }
- }
- $NBT_new->writeTag(new End);
- }
-}
\ No newline at end of file
diff --git a/src/nbt/tag/Double.php b/src/nbt/tag/Double.php
deleted file mode 100644
index 9e7f8c75..00000000
--- a/src/nbt/tag/Double.php
+++ /dev/null
@@ -1,35 +0,0 @@
-value = $NBT_new->getDouble();
- }
-
- public function write(NBT_new $NBT_new){
- $NBT_new->putDouble($this->value);
- }
-}
\ No newline at end of file
diff --git a/src/nbt/tag/End.php b/src/nbt/tag/End.php
deleted file mode 100644
index 35c0ea84..00000000
--- a/src/nbt/tag/End.php
+++ /dev/null
@@ -1,35 +0,0 @@
-name = $name;
- foreach($value as $k => $v){
- $this->{$k} = $v;
- }
- }
-
- public function &getValue(){
- $value = [];
- foreach($this as $k => $v){
- if($v instanceof Tag){
- $value[$k] = $v;
- }
- }
- return $value;
- }
-
- public function offsetExists(mixed $offset): bool{
- return isset($this->{$offset});
- }
-
- public function offsetGet(mixed $offset): mixed{
- if($this->{$offset} instanceof Tag){
- if($this->{$offset} instanceof \ArrayAccess){
- return $this->{$offset};
- }else{
- return $this->{$offset}->getValue();
- }
- }
-
- return null;
- }
-
- public function offsetSet(mixed $offset, mixed $value): void{
- if($value instanceof Tag){
- $this->{$offset} = $value;
- }elseif($this->{$offset} instanceof Tag){
- $this->{$offset}->setValue($value);
- }
- }
-
- public function offsetUnset(mixed $offset): void{
- unset($this->{$offset});
- }
-
- public function count(mixed $mode = COUNT_NORMAL): int{
- for($i = 0; true; $i++){
- if(!isset($this->{$i})){
- return $i;
- }
- if($mode === COUNT_RECURSIVE){
- if($this->{$i} instanceof \Countable){
- $i += count($this->{$i});
- }
- }
- }
- }
-
- public function getType(){
- return NBT_new::TAG_Enum;
- }
-
- public function setTagType($type){
- $this->tagType = $type;
- }
-
- public function getTagType(){
- return $this->tagType;
- }
-
- public function read(NBT_new $NBT_new){
- $this->value = [];
- $this->tagType = $NBT_new->getByte();
- $size = $NBT_new->getInt();
- for($i = 0; $i < $size and !$NBT_new->feof(); ++$i){
- switch($this->tagType){
- case NBT_new::TAG_Byte:
- $tag = new Byte(false);
- $tag->read($NBT_new);
- $this->{$i} = $tag;
- break;
- case NBT_new::TAG_Short:
- $tag = new Short(false);
- $tag->read($NBT_new);
- $this->{$i} = $tag;
- break;
- case NBT_new::TAG_Int:
- $tag = new IntTag(false);
- $tag->read($NBT_new);
- $this->{$i} = $tag;
- break;
- case NBT_new::TAG_Long:
- $tag = new Long(false);
- $tag->read($NBT_new);
- $this->{$i} = $tag;
- break;
- case NBT_new::TAG_Float:
- $tag = new FloatTag(false);
- $tag->read($NBT_new);
- $this->{$i} = $tag;
- break;
- case NBT_new::TAG_Double:
- $tag = new Double(false);
- $tag->read($NBT_new);
- $this->{$i} = $tag;
- break;
- case NBT_new::TAG_ByteArray:
- $tag = new ByteArray(false);
- $tag->read($NBT_new);
- $this->{$i} = $tag;
- break;
- case NBT_new::TAG_String:
- $tag = new StringTag(false);
- $tag->read($NBT_new);
- $this->{$i} = $tag;
- break;
- case NBT_new::TAG_Enum:
- $tag = new $this(false);
- $tag->read($NBT_new);
- $this->{$i} = $tag;
- break;
- case NBT_new::TAG_Compound:
- $tag = new Compound(false);
- $tag->read($NBT_new);
- $this->{$i} = $tag;
- break;
- case NBT_new::TAG_IntArray:
- $tag = new IntArray(false);
- $tag->read($NBT_new);
- $this->{$i} = $tag;
- break;
- }
- }
- }
-
- public function write(NBT_new $NBT_new){
- if(!isset($this->tagType)){
- foreach($this as $tag){
- if($tag instanceof Tag){
- if(!isset($id)){
- $id = $tag->getType();
- }elseif($id !== $tag->getType()){
- return false;
- }
- }
- }
- $this->tagType = @$id;
- }
-
- $NBT_new->putByte($this->tagType);
-
- /** @var Tag[] $tags */
- $tags = [];
- foreach($this as $tag){
- if($tag instanceof Tag){
- $tags[] = $tag;
- }
- }
- $NBT_new->putInt(count($tags));
- foreach($tags as $tag){
- $tag->write($NBT_new);
- }
- }
-}
diff --git a/src/nbt/tag/Float.php b/src/nbt/tag/Float.php
deleted file mode 100644
index d2ecc209..00000000
--- a/src/nbt/tag/Float.php
+++ /dev/null
@@ -1,35 +0,0 @@
-value = $NBT_new->getFloat();
- }
-
- public function write(NBT_new $NBT_new){
- $NBT_new->putFloat($this->value);
- }
-}
diff --git a/src/nbt/tag/Int.php b/src/nbt/tag/Int.php
deleted file mode 100644
index ae893249..00000000
--- a/src/nbt/tag/Int.php
+++ /dev/null
@@ -1,35 +0,0 @@
-value = $NBT_new->getInt();
- }
-
- public function write(NBT_new $NBT_new){
- $NBT_new->putInt($this->value);
- }
-}
diff --git a/src/nbt/tag/IntArray.php b/src/nbt/tag/IntArray.php
deleted file mode 100644
index 1d9a3b69..00000000
--- a/src/nbt/tag/IntArray.php
+++ /dev/null
@@ -1,42 +0,0 @@
-value = [];
- $size = $NBT_new->getInt();
- for($i = 0; $i < $size and !$NBT_new->feof(); ++$i){
- $this->value[] = $NBT_new->getInt();
- }
- }
-
- public function write(NBT_new $NBT_new){
- $NBT_new->putInt(count($this->value));
- foreach($this->value as $v){
- $NBT_new->putInt($v);
- }
- }
-}
\ No newline at end of file
diff --git a/src/nbt/tag/Long.php b/src/nbt/tag/Long.php
deleted file mode 100644
index b4c24c51..00000000
--- a/src/nbt/tag/Long.php
+++ /dev/null
@@ -1,35 +0,0 @@
-value = $NBT_new->getLong();
- }
-
- public function write(NBT_new $NBT_new){
- $NBT_new->putLong($this->value);
- }
-}
\ No newline at end of file
diff --git a/src/nbt/tag/NamedTag.php b/src/nbt/tag/NamedTag.php
deleted file mode 100644
index 690b149d..00000000
--- a/src/nbt/tag/NamedTag.php
+++ /dev/null
@@ -1,45 +0,0 @@
-name = $name;
- if($value !== false){
- $this->value = $value;
- }
- }
-
- public function getName(){
- return $this->name === false ? "" : $this->name;
- }
-
- public function setName($name){
- $this->name = $name;
- }
-}
diff --git a/src/nbt/tag/Short.php b/src/nbt/tag/Short.php
deleted file mode 100644
index dd977393..00000000
--- a/src/nbt/tag/Short.php
+++ /dev/null
@@ -1,36 +0,0 @@
-value = $NBT_new->getShort();
- }
-
- public function write(NBT_new $NBT_new){
- $NBT_new->putShort($this->value);
- }
-}
\ No newline at end of file
diff --git a/src/nbt/tag/String.php b/src/nbt/tag/String.php
deleted file mode 100644
index de6e3110..00000000
--- a/src/nbt/tag/String.php
+++ /dev/null
@@ -1,36 +0,0 @@
-value = $NBT_new->get($NBT_new->getShort());
- }
-
- public function write(NBT_new $NBT_new){
- $NBT_new->putShort(strlen($this->value));
- $NBT_new->put($this->value);
- }
-}
diff --git a/src/nbt/tag/Tag.php b/src/nbt/tag/Tag.php
deleted file mode 100644
index a2bc9e99..00000000
--- a/src/nbt/tag/Tag.php
+++ /dev/null
@@ -1,47 +0,0 @@
-value;
- }
-
- public abstract function getType();
-
- public function setValue($value){
- $this->value = $value;
- }
-
- abstract public function write(NBT_new $NBT_new);
-
- abstract public function read(NBT_new $NBT_new);
-
- public final function __toString(){
- return $this->value;
- }
-}
diff --git a/src/network/MinecraftInterface.php b/src/network/MinecraftInterface.php
deleted file mode 100644
index 11db0660..00000000
--- a/src/network/MinecraftInterface.php
+++ /dev/null
@@ -1,83 +0,0 @@
-socket = new UDPSocket($server, $port, true, $serverip);
- if($this->socket->connected === false){
- console("[SEVERE] Couldn't bind to $serverip:" . $port, true, true, 0);
- exit(1);
- }
- $this->bandwidth = [0, 0, microtime(true)];
- $this->start = microtime(true);
- $this->packets = [];
- }
-
- public function close(){
- return $this->socket->close(false);
- }
-
- public function readPacket(){
- if($this->socket->connected === false){
- return false;
- }
- $buf = "";
- $source = false;
- $port = 1;
- $len = $this->socket->read($buf, $source, $port);
- if($len === false or $len === 0){
- return false;
- }
- $this->bandwidth[0] += $len;
- ServerAPI::request()->api->dhandle("mcinterface.read", ["buffer" => $buf, "source" => $source, "port" => $port]);
- return $this->parsePacket($buf, $source, $port);
- }
-
- private function parsePacket($buffer, $source, $port){
- $pid = ord($buffer[0]);
-
- if(RakNetInfo::isValid($pid)){
- $parser = new RakNetParser($buffer);
- if($parser->packet !== false){
- $parser->packet->ip = $source;
- $parser->packet->port = $port;
- if(EventHandler::callEvent(new PacketReceiveEvent($parser->packet)) === BaseEvent::DENY){
- return false;
- }
- return $parser->packet;
- }
- return false;
- }elseif($pid === 0xfe and $buffer[1] === "\xfd" and ServerAPI::request()->api->query instanceof QueryHandler){
- $packet = new QueryPacket;
- $packet->ip = $source;
- $packet->port = $port;
- $packet->buffer =& $buffer;
- if(EventHandler::callEvent(new PacketReceiveEvent($packet)) === BaseEvent::DENY){
- return false;
- }
- ServerAPI::request()->api->query->handle($packet);
- }else{
- $packet = new Packet();
- $packet->ip = $source;
- $packet->port = $port;
- $packet->buffer =& $buffer;
- EventHandler::callEvent(new PacketReceiveEvent($packet));
- return false;
- }
- }
-
- public function writePacket(Packet $packet){
- if(EventHandler::callEvent(new PacketSendEvent($packet)) === BaseEvent::DENY){
- return 0;
- }elseif($packet instanceof RakNetPacket){
- $codec = new RakNetCodec($packet);
- }
- $write = $this->socket->write($packet->buffer, $packet->ip, $packet->port);
- $this->bandwidth[1] += $write;
- return $write;
- }
-}
\ No newline at end of file
diff --git a/src/network/Packet.php b/src/network/Packet.php
deleted file mode 100644
index 9499ca69..00000000
--- a/src/network/Packet.php
+++ /dev/null
@@ -1,9 +0,0 @@
-workers = [];
- $this->password = (string) $password;
- console("[INFO] Starting remote control listener");
- if($this->password === ""){
- console("[ERROR] RCON can't be started: Empty password");
- return;
- }
- $this->threads = (int) max(1, $threads);
- $this->clientsPerThread = (int) max(1, $clientsPerThread);
- $this->socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
- if($this->socket === false or !socket_bind($this->socket, $interface, (int) $port) or !socket_listen($this->socket)){
- console("[ERROR] RCON can't be started: " . socket_strerror(socket_last_error()));
- return;
- }
- @socket_set_block($this->socket);
- for($n = 0; $n < $this->threads; ++$n){
- $this->workers[$n] = new RCONInstance($this->socket, $this->password, $this->clientsPerThread);
- }
- @socket_getsockname($this->socket, $addr, $port);
- console("[INFO] RCON running on $addr:$port");
- ServerAPI::request()->schedule(2, [$this, "check"], [], true);
- }
-
- public function stop(){
- for($n = 0; $n < $this->threads; ++$n){
- $this->workers[$n]->close();
- $this->workers[$n]->join();
- usleep(50000);
- $this->workers[$n]->kill();
- }
- @socket_close($this->socket);
- $this->threads = 0;
- }
-
- public function check(){
- foreach($this->workers as $w){
- $w->synchronized(function($rcon, $worker){
- if($worker->isTerminated()){
- $worker = new RCONInstance($rcon->socket, $rcon->password, $rcon->clientsPerThread);
- }//elseif($worker->isWaiting()){
- $worker->response = ServerAPI::request()->api->console->run($worker->cmd, "rcon");
- $worker->cmd = "";
- $worker->notify();
- //}
- }, $this, $w);
- }
- }
-
-}
-
-class RCONInstance extends Thread{
-
- public $stop;
- public $cmd;
- public $response;
- private $socket;
- private $password;
- private $maxClients;
- public function __construct($socket, $password, $maxClients = 50){
- $this->stop = false;
- $this->cmd = "";
- $this->response = "";
- $this->socket = $socket;
- $this->password = $password;
- $this->maxClients = (int) $maxClients;
- $this->start();
- }
-
- public function close(){
- $this->stop = true;
- }
-
- public function run(){
- $clients = [];
- $authenticated = [];
- $timeouts = [];
- $nextClientId = 0;
- while($this->stop !== true){
- $r = $clients;
- $r["main"] = $this->socket; //this is ugly, but we need to be able to mass-select()
- $w = null;
- $e = null;
- $disconnect = [];
- if(socket_select($r, $w, $e, 5, 0) > 0){
- foreach($r as $id => $sock){
- if($sock === $this->socket){
- if(($client = socket_accept($this->socket)) !== false){
- if(count($clients) >= $this->maxClients){
- @socket_close($client);
- }else{
- socket_set_nonblock($client);
- socket_set_option($client, SOL_SOCKET, SO_KEEPALIVE, 1);
-
- $id = $nextClientId++;
- $clients[$id] = $client;
- $authenticated[$id] = false;
- $timeouts[$id] = microtime(true) + 5;
- }
- }
- }else{
- $p = $this->readPacket($sock, $size, $requestID, $packetType, $payload);
- if($p === false){
- $disconnect[$id] = $sock;
- continue;
- }
-
- switch($packetType){
- case 3: //Login
- if($authenticated[$id]){
- $disconnect[$id] = $sock;
- break;
- }
- socket_getpeername($sock, $addr, $port);
- if($payload === $this->password){
- console("Successful Rcon connection from: /$addr:$port");
- $this->writePacket($sock, $requestID, 2, "");
- $authenticated[$id] = true;
- }else{
- $disconnect[$id] = $sock;
- $this->writePacket($sock, -1, 2, "");
- $this->logger->info("Unsuccessful connection from: /$addr:$port (wrong password)");
- }
- break;
- case 2: //Command
- if(!$authenticated[$id]){
- $disconnect[$id] = $sock;
- break;
- }
- if($payload !== ""){
- $this->synchronized(function($payload){
- $this->cmd = ltrim($payload);
- $this->wait();
- }, $payload);
- if($this->writePacket($sock, $requestID, 0, str_replace("\n", "\r\n", trim($this->response))) === false){
- $disconnect[$id] = $sock;
- }
- $this->response = "";
- $this->cmd = "";
- }
- break;
- }
- }
- }
- }
-
- foreach($authenticated as $id => $status){
- if(!isset($disconnect[$id]) and !$authenticated[$id] and $timeouts[$id] < microtime(true)){ //Timeout
- $disconnect[$id] = $clients[$id];
- }
- }
-
- foreach($disconnect as $id => $client){
- $this->disconnectClient($client);
- unset($clients[$id], $authenticated[$id], $timeouts[$id]);
- }
-
-
- }
- foreach($clients as $client){
- $this->disconnectClient($client);
- }
- unset($this->socket, $this->cmd, $this->response, $this->stop);
- exit(0);
- }
-
- private function disconnectClient($client){
- socket_getpeername($client, $ip, $port);
- @socket_set_option($client, SOL_SOCKET, SO_LINGER, ["l_onoff" => 1, "l_linger" => 1]);
- @socket_shutdown($client, 2);
- @socket_set_block($client);
- @socket_read($client, 1);
- @socket_close($client);
- console("Disconnected client: /$ip:$port");
- }
-
- private function readPacket($client, &$size, &$requestID, &$packetType, &$payload){
- @socket_set_nonblock($client);
- $d = @socket_read($client, 4);
- if($this->stop){
- return false;
- }elseif($d === false){
- return null;
- }elseif($d === "" or strlen($d) < 4){
- return false;
- }
- $size = Utils::readLInt($d);
- if($size < 0 or $size > 65535){
- return false;
- }
- $requestID = Utils::readLInt(socket_read($client, 4));
- $packetType = Utils::readLInt(socket_read($client, 4));
- $payload = rtrim(socket_read($client, $size + 2)); //Strip two null bytes
- return true;
- }
-
- private function writePacket($client, $requestID, $packetType, $payload){
- $pk = Utils::writeLInt((int) $requestID)
- . Utils::writeLInt((int) $packetType)
- . $payload
- . "\x00\x00"; //Terminate payload and packet
- return @socket_write($client, Utils::writeLInt(strlen($pk)) . $pk);
- }
-}
diff --git a/src/network/UDPSocket.php b/src/network/UDPSocket.php
deleted file mode 100644
index c8291bd9..00000000
--- a/src/network/UDPSocket.php
+++ /dev/null
@@ -1,55 +0,0 @@
-server = $server;
- $this->port = $port;
- $this->sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
- socket_set_option($this->sock, SOL_SOCKET, SO_BROADCAST, 1); //Allow sending broadcast messages
- if($listen !== true){
- $this->connected = true;
- $this->unblock();
- }else{
- if(socket_bind($this->sock, $serverip, $port) === true){
- socket_set_option($this->sock, SOL_SOCKET, SO_REUSEADDR, 0);
- socket_set_option($this->sock, SOL_SOCKET, SO_SNDBUF, 1024 * 1024 * 8); //8MB
- socket_set_option($this->sock, SOL_SOCKET, SO_RCVBUF, 1024 * 1024); //1MB
- $this->unblock();
- $this->connected = true;
- }else{
- $this->connected = false;
- }
- }
- }
-
- public function unblock(){
- socket_set_nonblock($this->sock);
- }
-
- public function close($error = 125){
- $this->connected = false;
- return @socket_close($this->sock);
- }
-
- public function block(){
- socket_set_block($this->sock);
- }
-
- public function read(&$buf, &$source, &$port){
- if($this->connected === false){
- return false;
- }
- return @socket_recvfrom($this->sock, $buf, 65535, 0, $source, $port);;
- }
-
- public function write($data, $dest, $port){
- if($this->connected === false){
- return false;
- }
-
- return @socket_sendto($this->sock, $data, strlen($data), 0, $dest, $port);
- }
-}
\ No newline at end of file
diff --git a/src/network/protocol/ProtocolInfo.php b/src/network/protocol/ProtocolInfo.php
deleted file mode 100644
index d59cb9e2..00000000
--- a/src/network/protocol/ProtocolInfo.php
+++ /dev/null
@@ -1,88 +0,0 @@
-reset();
- $this->putInt($this->eid);
- $this->putInt($this->type);
- $this->putFloat($this->x);
- $this->putFloat($this->y);
- $this->putFloat($this->z);
- $this->putInt($this->did);
- if($this->did > 0){
- $this->putShort($this->speedX);
- $this->putShort($this->speedY);
- $this->putShort($this->speedZ);
- }
- }
-
-}
diff --git a/src/network/protocol/packet/AddItemEntityPacket.php b/src/network/protocol/packet/AddItemEntityPacket.php
deleted file mode 100644
index fb68f60a..00000000
--- a/src/network/protocol/packet/AddItemEntityPacket.php
+++ /dev/null
@@ -1,33 +0,0 @@
-reset();
- $this->putInt($this->eid);
- $this->putSlot($this->item);
- $this->putFloat($this->x);
- $this->putFloat($this->y);
- $this->putFloat($this->z);
- $this->putByte($this->yaw);
- $this->putByte($this->pitch);
- $this->putByte($this->roll);
- }
-
-}
\ No newline at end of file
diff --git a/src/network/protocol/packet/AddMobPacket.php b/src/network/protocol/packet/AddMobPacket.php
deleted file mode 100644
index 70b3bfca..00000000
--- a/src/network/protocol/packet/AddMobPacket.php
+++ /dev/null
@@ -1,33 +0,0 @@
-reset();
- $this->putInt($this->eid);
- $this->putInt($this->type);
- $this->putInt($this->x);
- $this->putInt($this->y);
- $this->putInt($this->z);
- $this->putByte($this->yaw);
- $this->putByte($this->pitch);
- $this->put(Utils::writeMetadata($this->metadata));
- }
-
-}
\ No newline at end of file
diff --git a/src/network/protocol/packet/AddPaintingPacket.php b/src/network/protocol/packet/AddPaintingPacket.php
deleted file mode 100644
index bd50ab0a..00000000
--- a/src/network/protocol/packet/AddPaintingPacket.php
+++ /dev/null
@@ -1,29 +0,0 @@
-reset();
- $this->putInt($this->eid);
- $this->putInt($this->x);
- $this->putInt($this->y);
- $this->putInt($this->z);
- $this->putInt($this->direction);
- $this->putString($this->title);
- }
-
-}
\ No newline at end of file
diff --git a/src/network/protocol/packet/AddPlayerPacket.php b/src/network/protocol/packet/AddPlayerPacket.php
deleted file mode 100644
index 044f119a..00000000
--- a/src/network/protocol/packet/AddPlayerPacket.php
+++ /dev/null
@@ -1,50 +0,0 @@
-reset();
- $this->putLong($this->clientID);
- $this->putString($this->username);
- $this->putInt($this->eid);
- $this->putFloat($this->x);
- $this->putFloat($this->y);
- $this->putFloat($this->z);
- $this->putByte($this->yaw);
- $this->putByte($this->pitch);
- $this->putShort($this->itemID);
- $this->putShort($this->itemAuxValue); //Example: bow shooting power
- $this->put(Utils::writeMetadata($this->metadata));
- }
-
-}
\ No newline at end of file
diff --git a/src/network/protocol/packet/AdventureSettingsPacket.php b/src/network/protocol/packet/AdventureSettingsPacket.php
deleted file mode 100644
index b395975c..00000000
--- a/src/network/protocol/packet/AdventureSettingsPacket.php
+++ /dev/null
@@ -1,19 +0,0 @@
-reset();
- $this->putInt($this->flags);
- }
-
-}
\ No newline at end of file
diff --git a/src/network/protocol/packet/AnimatePacket.php b/src/network/protocol/packet/AnimatePacket.php
deleted file mode 100644
index 6a33b5e5..00000000
--- a/src/network/protocol/packet/AnimatePacket.php
+++ /dev/null
@@ -1,27 +0,0 @@
-action = $this->getByte();
- $this->eid = $this->getInt();
- }
-
- public function encode(){
- $this->reset();
- $this->putByte($this->action);
- $this->putInt($this->eid);
- }
-
-}
\ No newline at end of file
diff --git a/src/network/protocol/packet/ChatPacket.php b/src/network/protocol/packet/ChatPacket.php
deleted file mode 100644
index cbe5998a..00000000
--- a/src/network/protocol/packet/ChatPacket.php
+++ /dev/null
@@ -1,19 +0,0 @@
-reset();
- $this->putString($this->message);
- }
-
-}
\ No newline at end of file
diff --git a/src/network/protocol/packet/ChunkDataPacket.php b/src/network/protocol/packet/ChunkDataPacket.php
deleted file mode 100644
index 024bebbb..00000000
--- a/src/network/protocol/packet/ChunkDataPacket.php
+++ /dev/null
@@ -1,23 +0,0 @@
-reset();
- $this->putInt($this->chunkX);
- $this->putInt($this->chunkZ);
- $this->put($this->data);
- }
-
-}
\ No newline at end of file
diff --git a/src/network/protocol/packet/ClientConnectPacket.php b/src/network/protocol/packet/ClientConnectPacket.php
deleted file mode 100644
index f4a95243..00000000
--- a/src/network/protocol/packet/ClientConnectPacket.php
+++ /dev/null
@@ -1,22 +0,0 @@
-clientID = $this->getLong();
- $this->session = $this->getLong();
- $this->unknown1 = $this->get(1);
- }
-
- public function encode(){
-
- }
-
-}
\ No newline at end of file
diff --git a/src/network/protocol/packet/ClientHandshakePacket.php b/src/network/protocol/packet/ClientHandshakePacket.php
deleted file mode 100644
index 7d807d9c..00000000
--- a/src/network/protocol/packet/ClientHandshakePacket.php
+++ /dev/null
@@ -1,32 +0,0 @@
-cookie = $this->get(4);
- $this->security = $this->get(1);
- $this->port = $this->getShort(true);
- $this->dataArray0 = $this->get($this->getByte());
- $this->dataArray = $this->getDataArray(9);
- $this->timestamp = $this->get(2);
- $this->session2 = $this->getLong();
- $this->session = $this->getLong();
- }
-
- public function encode(){
-
- }
-
-}
\ No newline at end of file
diff --git a/src/network/protocol/packet/ContainerClosePacket.php b/src/network/protocol/packet/ContainerClosePacket.php
deleted file mode 100644
index 008d8097..00000000
--- a/src/network/protocol/packet/ContainerClosePacket.php
+++ /dev/null
@@ -1,19 +0,0 @@
-windowid = $this->getByte();
- }
-
- public function encode(){
- $this->reset();
- $this->putByte($this->windowid);
- }
-
-}
\ No newline at end of file
diff --git a/src/network/protocol/packet/ContainerOpenPacket.php b/src/network/protocol/packet/ContainerOpenPacket.php
deleted file mode 100644
index fcac7b54..00000000
--- a/src/network/protocol/packet/ContainerOpenPacket.php
+++ /dev/null
@@ -1,29 +0,0 @@
-reset();
- $this->putByte($this->windowid);
- $this->putByte($this->type);
- $this->putShort($this->slots);
- $this->putInt($this->x);
- $this->putInt($this->y);
- $this->putInt($this->z);
- }
-
-}
\ No newline at end of file
diff --git a/src/network/protocol/packet/ContainerSetContentPacket.php b/src/network/protocol/packet/ContainerSetContentPacket.php
deleted file mode 100644
index a4afe1db..00000000
--- a/src/network/protocol/packet/ContainerSetContentPacket.php
+++ /dev/null
@@ -1,41 +0,0 @@
-windowid = $this->getByte();
- $count = $this->getShort();
- for($s = 0; $s < $count and !$this->feof(); ++$s){
- $this->slots[$s] = $this->getSlot();
- }
- if($this->windowid === 0){
- $count = $this->getShort();
- for($s = 0; $s < $count and !$this->feof(); ++$s){
- $this->hotbar[$s] = $this->getInt();
- }
- }
- }
-
- public function encode(){
- $this->reset();
- $this->putByte($this->windowid);
- $this->putShort(count($this->slots));
- foreach($this->slots as $slot){
- $this->putSlot($slot);
- }
- if($this->windowid === 0 and count($this->hotbar) > 0){
- $this->putShort(count($this->hotbar));
- foreach($this->hotbar as $slot){
- $this->putInt($slot);
- }
- }
- }
-
-}
\ No newline at end of file
diff --git a/src/network/protocol/packet/ContainerSetDataPacket.php b/src/network/protocol/packet/ContainerSetDataPacket.php
deleted file mode 100644
index 0d93c4e1..00000000
--- a/src/network/protocol/packet/ContainerSetDataPacket.php
+++ /dev/null
@@ -1,23 +0,0 @@
-reset();
- $this->putByte($this->windowid);
- $this->putShort($this->property);
- $this->putShort($this->value);
- }
-
-}
\ No newline at end of file
diff --git a/src/network/protocol/packet/ContainerSetSlotPacket.php b/src/network/protocol/packet/ContainerSetSlotPacket.php
deleted file mode 100644
index fab25153..00000000
--- a/src/network/protocol/packet/ContainerSetSlotPacket.php
+++ /dev/null
@@ -1,25 +0,0 @@
-windowid = $this->getByte();
- $this->slot = $this->getShort();
- $this->item = $this->getSlot();
- }
-
- public function encode(){
- $this->reset();
- $this->putByte($this->windowid);
- $this->putShort($this->slot);
- $this->putSlot($this->item);
- }
-
-}
\ No newline at end of file
diff --git a/src/network/protocol/packet/DisconnectPacket.php b/src/network/protocol/packet/DisconnectPacket.php
deleted file mode 100644
index f0cc9fe8..00000000
--- a/src/network/protocol/packet/DisconnectPacket.php
+++ /dev/null
@@ -1,16 +0,0 @@
-reset();
- }
-
-}
\ No newline at end of file
diff --git a/src/network/protocol/packet/DropItemPacket.php b/src/network/protocol/packet/DropItemPacket.php
deleted file mode 100644
index 41531160..00000000
--- a/src/network/protocol/packet/DropItemPacket.php
+++ /dev/null
@@ -1,22 +0,0 @@
-eid = $this->getInt();
- $this->unknown = $this->getByte();
- $this->item = $this->getSlot();
- }
-
- public function encode(){
-
- }
-
-}
\ No newline at end of file
diff --git a/src/network/protocol/packet/EntityDataPacket.php b/src/network/protocol/packet/EntityDataPacket.php
deleted file mode 100644
index c914bd20..00000000
--- a/src/network/protocol/packet/EntityDataPacket.php
+++ /dev/null
@@ -1,28 +0,0 @@
-x = $this->getInt();
- $this->y = $this->getByte();
- $this->z = $this->getInt();
- $this->namedtag = $this->get(true);
- }
-
- public function encode(){
- $this->reset();
- $this->putInt($this->x);
- $this->putByte($this->y);
- $this->putInt($this->z);
- $this->put($this->namedtag);
- }
-
-}
\ No newline at end of file
diff --git a/src/network/protocol/packet/EntityEventPacket.php b/src/network/protocol/packet/EntityEventPacket.php
deleted file mode 100644
index c7faf41b..00000000
--- a/src/network/protocol/packet/EntityEventPacket.php
+++ /dev/null
@@ -1,25 +0,0 @@
-eid = $this->getInt();
- $this->event = $this->getByte();
- }
-
- public function encode(){
- $this->reset();
- $this->putInt($this->eid);
- $this->putByte($this->event);
- }
-
-}
\ No newline at end of file
diff --git a/src/network/protocol/packet/ExplodePacket.php b/src/network/protocol/packet/ExplodePacket.php
deleted file mode 100644
index c5aebd6e..00000000
--- a/src/network/protocol/packet/ExplodePacket.php
+++ /dev/null
@@ -1,34 +0,0 @@
-reset();
- $this->putFloat($this->x);
- $this->putFloat($this->y);
- $this->putFloat($this->z);
- $this->putFloat($this->radius);
- $this->putInt(@count($this->records));
- if(@count($this->records) > 0){
- foreach($this->records as $record){
- $this->putByte($record->x);
- $this->putByte($record->y);
- $this->putByte($record->z);
- }
- }
- }
-
-}
\ No newline at end of file
diff --git a/src/network/protocol/packet/FullChunkDataPacket.php b/src/network/protocol/packet/FullChunkDataPacket.php
deleted file mode 100644
index f79b5d68..00000000
--- a/src/network/protocol/packet/FullChunkDataPacket.php
+++ /dev/null
@@ -1,21 +0,0 @@
-reset();
- $this->put($this->data);
- }
-
-}
diff --git a/src/network/protocol/packet/HurtArmorPacket.php b/src/network/protocol/packet/HurtArmorPacket.php
deleted file mode 100644
index e23aac3e..00000000
--- a/src/network/protocol/packet/HurtArmorPacket.php
+++ /dev/null
@@ -1,19 +0,0 @@
-reset();
- $this->putByte($this->health);
- }
-
-}
\ No newline at end of file
diff --git a/src/network/protocol/packet/InteractPacket.php b/src/network/protocol/packet/InteractPacket.php
deleted file mode 100644
index 2d33773d..00000000
--- a/src/network/protocol/packet/InteractPacket.php
+++ /dev/null
@@ -1,28 +0,0 @@
-action = $this->getByte();
- $this->eid = $this->getInt();
- $this->target = $this->getInt();
- }
-
- public function encode(){
- $this->reset();
- $this->putByte($this->action);
- $this->putInt($this->eid);
- $this->putInt($this->target);
- }
-
-}
\ No newline at end of file
diff --git a/src/network/protocol/packet/LevelEventPacket.php b/src/network/protocol/packet/LevelEventPacket.php
deleted file mode 100644
index dcddd653..00000000
--- a/src/network/protocol/packet/LevelEventPacket.php
+++ /dev/null
@@ -1,27 +0,0 @@
-reset();
- $this->putShort($this->evid);
- $this->putShort($this->x);
- $this->putShort($this->y);
- $this->putShort($this->z);
- $this->putInt($this->data);
- }
-
-}
\ No newline at end of file
diff --git a/src/network/protocol/packet/LoginPacket.php b/src/network/protocol/packet/LoginPacket.php
deleted file mode 100644
index 34f04955..00000000
--- a/src/network/protocol/packet/LoginPacket.php
+++ /dev/null
@@ -1,26 +0,0 @@
-username = $this->getString();
- $this->protocol1 = $this->getInt();
- $this->protocol2 = $this->getInt();
- $this->clientId = $this->getInt();
- $this->loginData = $this->getString();
- }
-
- public function encode(){
-
- }
-
-}
\ No newline at end of file
diff --git a/src/network/protocol/packet/LoginStatusPacket.php b/src/network/protocol/packet/LoginStatusPacket.php
deleted file mode 100644
index bd501917..00000000
--- a/src/network/protocol/packet/LoginStatusPacket.php
+++ /dev/null
@@ -1,19 +0,0 @@
-reset();
- $this->putInt($this->status);
- }
-
-}
\ No newline at end of file
diff --git a/src/network/protocol/packet/MessagePacket.php b/src/network/protocol/packet/MessagePacket.php
deleted file mode 100644
index dcb1b0bb..00000000
--- a/src/network/protocol/packet/MessagePacket.php
+++ /dev/null
@@ -1,22 +0,0 @@
-source = $this->getString();
- $this->message = $this->getString();
- }
-
- public function encode(){
- $this->reset();
- $this->putString($this->source);
- $this->putString($this->message);
- }
-
-}
\ No newline at end of file
diff --git a/src/network/protocol/packet/MoveEntityPacket.php b/src/network/protocol/packet/MoveEntityPacket.php
deleted file mode 100644
index 16456d2a..00000000
--- a/src/network/protocol/packet/MoveEntityPacket.php
+++ /dev/null
@@ -1,35 +0,0 @@
-reset();
- $this->putInt(count($this->entities));
- foreach($this->entities as $d){
- $this->putInt($d[0]); //eid
- $this->putFloat($d[1]); //x
- $this->putFloat($d[2]); //y
- $this->putFloat($d[3]); //z
- $this->putFloat($d[4]); //yaw
- $this->putFloat($d[5]); //pitch
- }
- }
-
-}
\ No newline at end of file
diff --git a/src/network/protocol/packet/MoveEntityPacket_PosRot.php b/src/network/protocol/packet/MoveEntityPacket_PosRot.php
deleted file mode 100644
index c2143c18..00000000
--- a/src/network/protocol/packet/MoveEntityPacket_PosRot.php
+++ /dev/null
@@ -1,35 +0,0 @@
-get(7);
- $this->eid = $this->getInt();
- $this->x = $this->getFloat();
- $this->y = $this->getFloat();
- $this->z = $this->getFloat();
- $this->yaw = $this->getFloat();
- $this->pitch = $this->getFloat();
- }
-
- public function encode(){
- $this->reset();
- $this->putInt($this->eid);
- $this->putFloat($this->x);
- $this->putFloat($this->y);
- $this->putFloat($this->z);
- $this->putFloat($this->yaw);
- $this->putFloat($this->pitch);
- }
-
-}
\ No newline at end of file
diff --git a/src/network/protocol/packet/MovePlayerPacket.php b/src/network/protocol/packet/MovePlayerPacket.php
deleted file mode 100644
index 45c8229c..00000000
--- a/src/network/protocol/packet/MovePlayerPacket.php
+++ /dev/null
@@ -1,39 +0,0 @@
-eid = $this->getInt();
- $this->x = $this->getFloat();
- $this->y = $this->getFloat();
- $this->z = $this->getFloat();
- $this->yaw = $this->getFloat();
- $this->pitch = $this->getFloat();
- $this->bodyYaw = $this->getFloat();
- $this->teleport = ($this->getByte() & 0x80) > 0;
- }
-
- public function encode(){
- $this->reset();
- $this->putInt($this->eid);
- $this->putFloat($this->x);
- $this->putFloat($this->y);
- $this->putFloat($this->z);
- $this->putFloat($this->yaw);
- $this->putFloat($this->pitch);
- $this->putFloat($this->bodyYaw);
- $this->putByte($this->teleport ? 0x80 : 0x00);
- }
-
-}
diff --git a/src/network/protocol/packet/PingPacket.php b/src/network/protocol/packet/PingPacket.php
deleted file mode 100644
index 77e380dc..00000000
--- a/src/network/protocol/packet/PingPacket.php
+++ /dev/null
@@ -1,19 +0,0 @@
-time = $this->getLong();
- }
-
- public function encode(){
- $this->reset();
- $this->putLong($this->time);
- }
-
-}
\ No newline at end of file
diff --git a/src/network/protocol/packet/PlayerActionPacket.php b/src/network/protocol/packet/PlayerActionPacket.php
deleted file mode 100644
index cdcc64ad..00000000
--- a/src/network/protocol/packet/PlayerActionPacket.php
+++ /dev/null
@@ -1,28 +0,0 @@
-action = $this->getInt();
- $this->x = $this->getInt();
- $this->y = $this->getInt();
- $this->z = $this->getInt();
- $this->face = $this->getInt();
- $this->eid = $this->getInt();
- }
-
- public function encode(){
-
- }
-
-}
\ No newline at end of file
diff --git a/src/network/protocol/packet/PlayerArmorEquipmentPacket.php b/src/network/protocol/packet/PlayerArmorEquipmentPacket.php
deleted file mode 100644
index d32be316..00000000
--- a/src/network/protocol/packet/PlayerArmorEquipmentPacket.php
+++ /dev/null
@@ -1,28 +0,0 @@
-eid = $this->getInt();
- $this->slots[0] = $this->getByte();
- $this->slots[1] = $this->getByte();
- $this->slots[2] = $this->getByte();
- $this->slots[3] = $this->getByte();
- }
-
- public function encode(){
- $this->reset();
- $this->putInt($this->eid);
- $this->putByte($this->slots[0]);
- $this->putByte($this->slots[1]);
- $this->putByte($this->slots[2]);
- $this->putByte($this->slots[3]);
- }
-
-}
\ No newline at end of file
diff --git a/src/network/protocol/packet/PlayerEquipmentPacket.php b/src/network/protocol/packet/PlayerEquipmentPacket.php
deleted file mode 100644
index ab9bf9f0..00000000
--- a/src/network/protocol/packet/PlayerEquipmentPacket.php
+++ /dev/null
@@ -1,28 +0,0 @@
-eid = $this->getInt();
- $this->item = $this->getShort();
- $this->meta = $this->getShort();
- $this->slot = $this->getByte();
- }
-
- public function encode(){
- $this->reset();
- $this->putInt($this->eid);
- $this->putShort($this->item);
- $this->putShort($this->meta);
- $this->putByte($this->slot);
- }
-
-}
\ No newline at end of file
diff --git a/src/network/protocol/packet/PlayerInputPacket.php b/src/network/protocol/packet/PlayerInputPacket.php
deleted file mode 100644
index af3a5e94..00000000
--- a/src/network/protocol/packet/PlayerInputPacket.php
+++ /dev/null
@@ -1,23 +0,0 @@
-unk1 = $this->getFloat();
- $this->unk2 = $this->getFloat();
- $this->sneaking = bin2hex($this->buffer)[$this->getOffset()] === 4;
- $this->unk4 = bin2hex($this->buffer)[$this->getOffset()+1] === 4;
- }
-
-}
-
diff --git a/src/network/protocol/packet/PongPacket.php b/src/network/protocol/packet/PongPacket.php
deleted file mode 100644
index ab1a1948..00000000
--- a/src/network/protocol/packet/PongPacket.php
+++ /dev/null
@@ -1,22 +0,0 @@
-ptime = $this->getLong();
- $this->time = $this->getLong();
- }
-
- public function encode(){
- $this->reset();
- $this->putLong($this->ptime);
- $this->putLong($this->time);
- }
-
-}
\ No newline at end of file
diff --git a/src/network/protocol/packet/ReadyPacket.php b/src/network/protocol/packet/ReadyPacket.php
deleted file mode 100644
index 2fa12b5e..00000000
--- a/src/network/protocol/packet/ReadyPacket.php
+++ /dev/null
@@ -1,18 +0,0 @@
-status = $this->getByte();
- }
-
- public function encode(){
-
- }
-
-}
\ No newline at end of file
diff --git a/src/network/protocol/packet/RemoveBlockPacket.php b/src/network/protocol/packet/RemoveBlockPacket.php
deleted file mode 100644
index d3e3a969..00000000
--- a/src/network/protocol/packet/RemoveBlockPacket.php
+++ /dev/null
@@ -1,24 +0,0 @@
-eid = $this->getInt();
- $this->x = $this->getInt();
- $this->z = $this->getInt();
- $this->y = $this->getByte();
- }
-
- public function encode(){
-
- }
-
-}
\ No newline at end of file
diff --git a/src/network/protocol/packet/RemoveEntityPacket.php b/src/network/protocol/packet/RemoveEntityPacket.php
deleted file mode 100644
index 27d6c42b..00000000
--- a/src/network/protocol/packet/RemoveEntityPacket.php
+++ /dev/null
@@ -1,19 +0,0 @@
-reset();
- $this->putInt($this->eid);
- }
-
-}
\ No newline at end of file
diff --git a/src/network/protocol/packet/RemovePlayerPacket.php b/src/network/protocol/packet/RemovePlayerPacket.php
deleted file mode 100644
index f23cd4df..00000000
--- a/src/network/protocol/packet/RemovePlayerPacket.php
+++ /dev/null
@@ -1,21 +0,0 @@
-reset();
- $this->putInt($this->eid);
- $this->putLong($this->clientID);
- }
-
-}
\ No newline at end of file
diff --git a/src/network/protocol/packet/RequestChunkPacket.php b/src/network/protocol/packet/RequestChunkPacket.php
deleted file mode 100644
index d0650748..00000000
--- a/src/network/protocol/packet/RequestChunkPacket.php
+++ /dev/null
@@ -1,20 +0,0 @@
-chunkX = $this->getInt();
- $this->chunkZ = $this->getInt();
- }
-
- public function encode(){
-
- }
-
-}
\ No newline at end of file
diff --git a/src/network/protocol/packet/RespawnPacket.php b/src/network/protocol/packet/RespawnPacket.php
deleted file mode 100644
index 1d3c208e..00000000
--- a/src/network/protocol/packet/RespawnPacket.php
+++ /dev/null
@@ -1,28 +0,0 @@
-eid = $this->getInt();
- $this->x = $this->getFloat();
- $this->y = $this->getFloat();
- $this->z = $this->getFloat();
- }
-
- public function encode(){
- $this->reset();
- $this->putInt($this->eid);
- $this->putFloat($this->x);
- $this->putFloat($this->y);
- $this->putFloat($this->z);
- }
-
-}
\ No newline at end of file
diff --git a/src/network/protocol/packet/RotateHeadPacket.php b/src/network/protocol/packet/RotateHeadPacket.php
deleted file mode 100644
index d091607f..00000000
--- a/src/network/protocol/packet/RotateHeadPacket.php
+++ /dev/null
@@ -1,31 +0,0 @@
-
- * false = yaw / 360 / 0.0039062
- * true = yaw
- * @var boolean
- */
- public $rawYaw = false;
- public function pid(){
- return ProtocolInfo::ROTATE_HEAD_PACKET;
- }
-
- public function decode(){
- $this->get(7); //id + data
- $this->eid = $this->getInt();
- $this->yaw = $this->getByte();
- }
-
- public function encode(){
- $this->reset();
- $this->putInt(count($this->entities));
- foreach($this->entities as $d){
- $this->putInt($d[0]); //eid
- $this->putByte((int) ($d[1] / 360 / 0.0039062)); //wraps 360 angle to 0xff
- }
- }
-
-}
\ No newline at end of file
diff --git a/src/network/protocol/packet/SendInventoryPacket.php b/src/network/protocol/packet/SendInventoryPacket.php
deleted file mode 100644
index 1bddca97..00000000
--- a/src/network/protocol/packet/SendInventoryPacket.php
+++ /dev/null
@@ -1,42 +0,0 @@
-eid = $this->getInt();
- $this->windowid = $this->getByte();
- $count = $this->getShort();
- for($s = 0; $s < $count and !$this->feof(); ++$s){
- $this->slots[$s] = $this->getSlot();
- }
- if($this->windowid === 1){ //Armor is sent
- for($s = 0; $s < 4; ++$s){
- $this->armor[$s] = $this->getSlot();
- }
- }
- }
-
- public function encode(){
- $this->reset();
- $this->putInt($this->eid);
- $this->putByte($this->windowid);
- $this->putShort(count($this->slots));
- foreach($this->slots as $slot){
- $this->putSlot($slot);
- }
- if($this->windowid === 1 and count($this->armor) === 4){
- for($s = 0; $s < 4; ++$s){
- $this->putSlot($this->armor[$s]);
- }
- }
- }
-
-}
\ No newline at end of file
diff --git a/src/network/protocol/packet/ServerHandshakePacket.php b/src/network/protocol/packet/ServerHandshakePacket.php
deleted file mode 100644
index 4931aa23..00000000
--- a/src/network/protocol/packet/ServerHandshakePacket.php
+++ /dev/null
@@ -1,38 +0,0 @@
-reset();
- $this->put("\x04\x3f\x57\xfe"); //cookie
- $this->put("\xcd"); //Security flags
- $this->putShort($this->port);
- $this->putDataArray(array(
- "\xf5\xff\xff\xf5",
- "\xff\xff\xff\xff",
- "\xff\xff\xff\xff",
- "\xff\xff\xff\xff",
- "\xff\xff\xff\xff",
- "\xff\xff\xff\xff",
- "\xff\xff\xff\xff",
- "\xff\xff\xff\xff",
- "\xff\xff\xff\xff",
- "\xff\xff\xff\xff",
- ));
- $this->put("\x00\x00");
- $this->putLong($this->session);
- $this->putLong($this->session2);
- }
-
-}
\ No newline at end of file
diff --git a/src/network/protocol/packet/SetEntityDataPacket.php b/src/network/protocol/packet/SetEntityDataPacket.php
deleted file mode 100644
index f9191190..00000000
--- a/src/network/protocol/packet/SetEntityDataPacket.php
+++ /dev/null
@@ -1,23 +0,0 @@
-eid = $this->getInt();
- $b = $this->get(true);
- $this->metadata = Utils::readMetadata($b, true);
- }
-
- public function encode(){
- $this->reset();
- $this->putInt($this->eid);
- $this->put(Utils::writeMetadata($this->metadata));
- }
-
-}
\ No newline at end of file
diff --git a/src/network/protocol/packet/SetEntityLinkPacket.php b/src/network/protocol/packet/SetEntityLinkPacket.php
deleted file mode 100644
index 34de37c1..00000000
--- a/src/network/protocol/packet/SetEntityLinkPacket.php
+++ /dev/null
@@ -1,29 +0,0 @@
-reset();
- $this->putInt($this->rider);
- $this->putInt($this->riding);
- $this->putInt($this->type);
- }
-
-
- public function pid(){
- return ProtocolInfo::SET_ENTITY_LINK_PACKET;
- }
-
-}
\ No newline at end of file
diff --git a/src/network/protocol/packet/SetEntityMotionPacket.php b/src/network/protocol/packet/SetEntityMotionPacket.php
deleted file mode 100644
index 30a8b4de..00000000
--- a/src/network/protocol/packet/SetEntityMotionPacket.php
+++ /dev/null
@@ -1,25 +0,0 @@
-reset();
- $this->putInt(count($this->entities));
- foreach($this->entities as $d){
- $this->putInt($d[0]);
- $this->putShort((int) ($d[1]*8000));
- $this->putShort((int) ($d[2]*8000));
- $this->putShort((int) ($d[3]*8000));
- }
- }
-
-}
diff --git a/src/network/protocol/packet/SetHealthPacket.php b/src/network/protocol/packet/SetHealthPacket.php
deleted file mode 100644
index 42e52f81..00000000
--- a/src/network/protocol/packet/SetHealthPacket.php
+++ /dev/null
@@ -1,19 +0,0 @@
-health = $this->getByte();
- }
-
- public function encode(){
- $this->reset();
- $this->putByte($this->health);
- }
-
-}
\ No newline at end of file
diff --git a/src/network/protocol/packet/SetSpawnPositionPacket.php b/src/network/protocol/packet/SetSpawnPositionPacket.php
deleted file mode 100644
index 3da187ea..00000000
--- a/src/network/protocol/packet/SetSpawnPositionPacket.php
+++ /dev/null
@@ -1,23 +0,0 @@
-reset();
- $this->putInt($this->x);
- $this->putInt($this->z);
- $this->putByte($this->y);
- }
-
-}
\ No newline at end of file
diff --git a/src/network/protocol/packet/SetTimePacket.php b/src/network/protocol/packet/SetTimePacket.php
deleted file mode 100644
index b78c9f94..00000000
--- a/src/network/protocol/packet/SetTimePacket.php
+++ /dev/null
@@ -1,21 +0,0 @@
-reset();
- $this->putInt($this->time);
- $this->putByte($this->started == true ? 0x80:0x00);
- }
-
-}
\ No newline at end of file
diff --git a/src/network/protocol/packet/StartGamePacket.php b/src/network/protocol/packet/StartGamePacket.php
deleted file mode 100644
index 7a198007..00000000
--- a/src/network/protocol/packet/StartGamePacket.php
+++ /dev/null
@@ -1,31 +0,0 @@
-reset();
- $this->putInt($this->seed);
- $this->putInt($this->generator);
- $this->putInt($this->gamemode);
- $this->putInt($this->eid);
- $this->putInt($this->spawnX);
- $this->putInt($this->spawnY);
- $this->putInt($this->spawnZ);
- $this->putFloat($this->x);
- $this->putFloat($this->y);
- $this->putFloat($this->z);
- }
-
-}
diff --git a/src/network/protocol/packet/TakeItemEntityPacket.php b/src/network/protocol/packet/TakeItemEntityPacket.php
deleted file mode 100644
index 85221c38..00000000
--- a/src/network/protocol/packet/TakeItemEntityPacket.php
+++ /dev/null
@@ -1,21 +0,0 @@
-reset();
- $this->putInt($this->target);
- $this->putInt($this->eid);
- }
-
-}
\ No newline at end of file
diff --git a/src/network/protocol/packet/TileEventPacket.php b/src/network/protocol/packet/TileEventPacket.php
deleted file mode 100644
index e2266896..00000000
--- a/src/network/protocol/packet/TileEventPacket.php
+++ /dev/null
@@ -1,27 +0,0 @@
-reset();
- $this->putInt($this->x);
- $this->putInt($this->y);
- $this->putInt($this->z);
- $this->putInt($this->case1);
- $this->putInt($this->case2);
- }
-
-}
\ No newline at end of file
diff --git a/src/network/protocol/packet/UnknownPacket.php b/src/network/protocol/packet/UnknownPacket.php
deleted file mode 100644
index d183dce1..00000000
--- a/src/network/protocol/packet/UnknownPacket.php
+++ /dev/null
@@ -1,18 +0,0 @@
-packetID;
- }
-
- public function decode(){
-
- }
-
- public function encode(){
-
- }
-
-}
\ No newline at end of file
diff --git a/src/network/protocol/packet/UnloadChunkPacket.php b/src/network/protocol/packet/UnloadChunkPacket.php
deleted file mode 100644
index 0153915a..00000000
--- a/src/network/protocol/packet/UnloadChunkPacket.php
+++ /dev/null
@@ -1,28 +0,0 @@
-chunkX = $chunkX;
- $this->chunkZ = $chunkZ;
- }
-
- public function encode()
- {
- $this->reset();
- $this->putInt($this->chunkX);
- $this->putInt($this->chunkZ);
- }
-
- public function pid()
- {
- return ProtocolInfo::UNLOAD_CHUNK_PACKET;
- }
-
- public function decode()
- {}
-
-}
-
diff --git a/src/network/protocol/packet/UpdateBlockPacket.php b/src/network/protocol/packet/UpdateBlockPacket.php
deleted file mode 100644
index 141f61b1..00000000
--- a/src/network/protocol/packet/UpdateBlockPacket.php
+++ /dev/null
@@ -1,31 +0,0 @@
-x = $this->getInt();
- $this->z = $this->getInt();
- $this->y = $this->getByte();
- $this->block = $this->getByte();
- $this->meta = $this->getByte();
- }
-
- public function encode(){
- $this->reset();
- $this->putInt($this->x);
- $this->putInt($this->z);
- $this->putByte($this->y);
- $this->putByte($this->block);
- $this->putByte($this->meta);
- }
-
-}
\ No newline at end of file
diff --git a/src/network/protocol/packet/UseItemPacket.php b/src/network/protocol/packet/UseItemPacket.php
deleted file mode 100644
index b4807724..00000000
--- a/src/network/protocol/packet/UseItemPacket.php
+++ /dev/null
@@ -1,42 +0,0 @@
-x = $this->getInt();
- $this->y = $this->getInt();
- $this->z = $this->getInt();
- $this->face = $this->getInt();
- $this->item = $this->getShort();
- $this->meta = $this->getShort();
- $this->eid = $this->getInt();
- $this->fx = $this->getFloat();
- $this->fy = $this->getFloat();
- $this->fz = $this->getFloat();
- $this->posX = $this->getFloat();
- $this->posY = $this->getFloat();
- $this->posZ = $this->getFloat();
- }
-
- public function encode(){
-
- }
-
-}
\ No newline at end of file
diff --git a/src/network/query/QueryHandler.php b/src/network/query/QueryHandler.php
deleted file mode 100644
index 8b92ec1f..00000000
--- a/src/network/query/QueryHandler.php
+++ /dev/null
@@ -1,110 +0,0 @@
-server = ServerAPI::request();
- $addr = ($ip = $this->server->api->getProperty("server-ip")) != "" ? $ip : "0.0.0.0";
- $port = $this->server->api->getProperty("server-port");
- console("[INFO] Setting query port to $port");
- /*
- The Query protocol is built on top of the existing Minecraft PE UDP network stack.
- Because the 0xFE packet does not exist in the MCPE protocol,
- we can identify Query packets and remove them from the packet queue.
-
- Then, the Query class handles itself sending the packets in raw form, because
- packets can conflict with the MCPE ones.
- */
-
- $this->server->schedule(20 * 30, [$this, "regenerateToken"], [], true);
- $this->regenerateToken();
- $this->lastToken = $this->token;
- $this->regenerateInfo();
- console("[INFO] Query running on $addr:$port");
- }
-
- public function regenerateToken(){
- $this->lastToken = $this->token;
- $this->token = Utils::readInt("\x00" . Utils::getRandomBytes(3, false));
- }
-
- public function regenerateInfo(){
- $str = "";
- $plist = "NostalgiaCore " . MAJOR_VERSION;
- if($this->server->extraprops->get("query-plugins") == true){
- $pl = $this->server->api->plugin->getList();
- if(count($pl) > 0){
- $plist .= ":";
- foreach($pl as $p){
- $plist .= " " . str_replace([";", ":", " "], ["", "", "_"], $p["name"]) . " " . str_replace([";", ":", " "], ["", "", "_"], $p["version"]) . ";";
- }
- $plist = substr($plist, 0, -1);
- }
- }
- $this->server->api->queryAPI->updateQueryData("plugins", $plist);
- $this->server->api->queryAPI->updateQueryData("map", $this->server->api->level->getDefault()->getName());
- $this->server->api->queryAPI->updateQueryData("numplayers", count($this->server->clients));
- $this->server->api->queryAPI->updateQueryData("tps", $this->server->debugInfo()["tps"]);
- $this->server->api->dhandle("query.update", null);
- $KVdata = $this->server->api->queryAPI->getQueryData();
-
- foreach($KVdata as $key => $value){
- $str .= $key . "\x00" . $value . "\x00";
- }
- $str .= "\x00\x01player_\x00\x00";
- foreach($this->server->clients as $player){
- if($player->username != ""){
- $str .= $player->username . "\x00";
- }
- }
- $str .= "\x00";
- $this->longData = $str;
- $this->timeout = microtime(true) + 5;
- }
-
- public function handle(QueryPacket $packet){
- $packet->decode();
- switch($packet->packetType){
- case QueryPacket::HANDSHAKE: //Handshake
- $pk = new QueryPacket;
- $pk->ip = $packet->ip;
- $pk->port = $packet->port;
- $pk->packetType = QueryPacket::HANDSHAKE;
- $pk->sessionID = $packet->sessionID;
- $pk->payload = $this->token . "\x00";
- $pk->encode();
- $this->server->send($pk);
- break;
- case QueryPacket::STATISTICS: //Stat
- $token = Utils::readInt(substr($packet->payload, 0, 4));
- if($token !== $this->token and $token !== $this->lastToken){
- break;
- }
- $pk = new QueryPacket;
- $pk->ip = $packet->ip;
- $pk->port = $packet->port;
- $pk->packetType = QueryPacket::STATISTICS;
- $pk->sessionID = $packet->sessionID;
- if(strlen($packet->payload) === 8){
- if($this->timeout < microtime(true)){
- $this->regenerateInfo();
- }
- $pk->payload = $this->longData;
- }else{
- $pk->payload = $this->server->name . "\x00" . (($this->server->gamemode & 0x01) === 0 ? "SMP" : "CMP") . "\x00" . $this->server->api->level->getDefault()->getName() . "\x00" . count($this->server->clients) . "\x00" . $this->server->maxClients . "\x00" . Utils::writeLShort($this->server->api->getProperty("server-port")) . $this->server->api->getProperty("server-ip", "0.0.0.0") . "\x00";
- }
- $pk->encode();
- $this->server->send($pk);
- break;
- }
- }
-
-}
diff --git a/src/network/query/QueryPacket.php b/src/network/query/QueryPacket.php
deleted file mode 100644
index be8a674d..00000000
--- a/src/network/query/QueryPacket.php
+++ /dev/null
@@ -1,23 +0,0 @@
-packetType = ord($this->buffer[2]);
- $this->sessionID = Utils::readInt(substr($this->buffer, 3, 4));
- $this->payload = substr($this->buffer, 7);
- }
-
- public function encode(){
- $this->buffer .= chr($this->packetType);
- $this->buffer .= Utils::writeInt($this->sessionID);
- $this->buffer .= $this->payload;
- }
-}
\ No newline at end of file
diff --git a/src/network/raknet/RakNetCodec.php b/src/network/raknet/RakNetCodec.php
deleted file mode 100644
index 34393bc6..00000000
--- a/src/network/raknet/RakNetCodec.php
+++ /dev/null
@@ -1,167 +0,0 @@
-packet = $packet;
- $this->buffer = &$this->packet->buffer;
- $this->encode();
- }
-
- private function encode(){
- if($this->packet->buffer != null && strlen($this->packet->buffer) > 0){
- return;
- }
- $this->buffer .= chr($this->packet->pid());
-
- switch($this->packet->pid()){
- case RakNetInfo::OPEN_CONNECTION_REPLY_1:
- $this->buffer .= RakNetInfo::MAGIC;
- $this->putLong($this->packet->serverID);
- $this->putByte(0); //server security
- $this->putShort($this->packet->mtuSize);
- break;
- case RakNetInfo::OPEN_CONNECTION_REPLY_2:
- $this->buffer .= RakNetInfo::MAGIC;
- $this->putLong($this->packet->serverID);
- $this->putShort($this->packet->port);
- $this->putShort($this->packet->mtuSize);
- $this->putByte(0); //Server security
- break;
- case RakNetInfo::INCOMPATIBLE_PROTOCOL_VERSION:
- $this->putByte(RakNetInfo::STRUCTURE);
- $this->buffer .= RakNetInfo::MAGIC;
- $this->putLong($this->packet->serverID);
- break;
- case RakNetInfo::UNCONNECTED_PONG:
- case RakNetInfo::ADVERTISE_SYSTEM:
- $this->putLong($this->packet->pingID);
- $this->putLong($this->packet->serverID);
- $this->buffer .= RakNetInfo::MAGIC;
- $this->putString($this->packet->serverType);
- break;
- case RakNetInfo::DATA_PACKET_0:
- case RakNetInfo::DATA_PACKET_1:
- case RakNetInfo::DATA_PACKET_2:
- case RakNetInfo::DATA_PACKET_3:
- case RakNetInfo::DATA_PACKET_4:
- case RakNetInfo::DATA_PACKET_5:
- case RakNetInfo::DATA_PACKET_6:
- case RakNetInfo::DATA_PACKET_7:
- case RakNetInfo::DATA_PACKET_8:
- case RakNetInfo::DATA_PACKET_9:
- case RakNetInfo::DATA_PACKET_A:
- case RakNetInfo::DATA_PACKET_B:
- case RakNetInfo::DATA_PACKET_C:
- case RakNetInfo::DATA_PACKET_D:
- case RakNetInfo::DATA_PACKET_E:
- case RakNetInfo::DATA_PACKET_F:
- $this->putLTriad($this->packet->seqNumber);
- foreach($this->packet->data as $pk){
- $this->encodeDataPacket($pk);
- }
- break;
- case RakNetInfo::NACK:
- case RakNetInfo::ACK:
- $payload = b"";
- $records = 0;
- $pointer = 0;
- sort($this->packet->packets, SORT_NUMERIC);
- $max = count($this->packet->packets);
-
- while($pointer < $max){
- $type = true;
- $curr = $start = $this->packet->packets[$pointer];
- for($i = $start + 1; $i < $max; ++$i){
- $n = $this->packet->packets[$i];
- if(($n - $curr) === 1){
- $curr = $end = $n;
- $type = false;
- $pointer = $i + 1;
- }else{
- break;
- }
- }
- ++$pointer;
- if($type === false){
- $payload .= "\x00";
- $payload .= Utils::writeLTriad($start);
- $payload .= Utils::writeLTriad($end);
- }else{
- $payload .= Utils::writeBool(true);
- $payload .= Utils::writeLTriad($start);
- }
- ++$records;
- }
- $this->putShort($records);
- $this->buffer .= $payload;
- break;
- default:
-
- }
-
- }
-
- protected function putLong($v){
- $this->buffer .= Utils::writeLong($v);
- }
-
- protected function putByte($v){
- $this->buffer .= chr($v);
- }
-
- protected function putShort($v){
- $this->buffer .= Utils::writeShort($v);
- }
-
- protected function putString($v){
- $this->putShort(strlen($v));
- $this->put($v);
- }
-
- protected function put($str){
- $this->buffer .= $str;
- }
-
- protected function putLTriad($v){
- $this->buffer .= Utils::writeLTriad($v);
- }
-
- private function encodeDataPacket(RakNetDataPacket $pk){
- $this->putByte(($pk->reliability << 5) | ($pk->hasSplit > 0 ? 0b00010000 : 0));
- $this->putShort(strlen($pk->buffer) << 3);
- if($pk->reliability === 2
- or $pk->reliability === 3
- or $pk->reliability === 4
- or $pk->reliability === 6
- or $pk->reliability === 7){
- $this->putLTriad($pk->messageIndex);
- }
-
- if($pk->reliability === 1
- or $pk->reliability === 3
- or $pk->reliability === 4
- or $pk->reliability === 7){
- $this->putLTriad($pk->orderIndex);
- $this->putByte($pk->orderChannel);
- }
-
- if($pk->hasSplit === true){
- $this->putInt($pk->splitCount);
- $this->putShort($pk->splitID);
- $this->putInt($pk->splitIndex);
- }
-
- $this->buffer .= $pk->buffer;
- }
-
- protected function putInt($v){
- $this->buffer .= Utils::writeInt($v);
- }
-
- protected function putTriad($v){
- $this->buffer .= Utils::writeTriad($v);
- }
-}
\ No newline at end of file
diff --git a/src/network/raknet/RakNetDataPacket.php b/src/network/raknet/RakNetDataPacket.php
deleted file mode 100755
index 012fd7c7..00000000
--- a/src/network/raknet/RakNetDataPacket.php
+++ /dev/null
@@ -1,153 +0,0 @@
-buffer;
- }
-
- public function getOffset(){
- return $this->offset;
- }
-
- public function setBuffer($buffer = ""){
- $this->buffer = $buffer;
- $this->offset = 0;
- }
-
- protected function reset(){
- $this->setBuffer(chr($this->pid()));
- }
-
- abstract public function pid();
-
- protected function getLong($unsigned = false){
- return Utils::readLong($this->get(8), $unsigned);
- }
-
- protected function get($len){
- if($len <= 0){
- $this->offset = strlen($this->buffer) - 1;
- return "";
- }elseif($len === true){
- return substr($this->buffer, $this->offset);
- }
- $this->offset += $len;
- return substr($this->buffer, $this->offset - $len, $len);
- }
-
- protected function putLong($v){
- $this->buffer .= Utils::writeLong($v);
- }
-
- protected function getInt($unsigned = false){
- return Utils::readInt($this->get(4), $unsigned);
- }
-
- protected function putInt($v){
- $this->buffer .= Utils::writeInt($v);
- }
-
- protected function getFloat(){
- return Utils::readFloat($this->get(4));
- }
-
- protected function putFloat($v){
- $this->buffer .= Utils::writeFloat($v);
- }
-
- protected function getLTriad(){
- return Utils::readTriad(strrev($this->get(3)));
- }
-
- protected function putLTriad($v){
- $this->buffer .= Utils::writeLTriad($v);
- }
-
- protected function getDataArray($len = 10){
- $data = [];
- for($i = 1; $i <= $len and !$this->feof(); ++$i){
- $data[] = $this->get($this->getTriad());
- }
- return $data;
- }
-
- protected function feof(){
- return !isset($this->buffer[$this->offset]);
- }
-
- protected function getTriad(){
- return Utils::readTriad($this->get(3));
- }
-
- protected function putDataArray(array $data = []){
- foreach($data as $v){
- $this->putTriad(strlen($v));
- $this->put($v);
- }
- }
-
- protected function putTriad($v){
- $this->buffer .= Utils::writeTriad($v);
- }
-
- protected function put($str){
- $this->buffer .= $str;
- }
-
- protected function getSlot(){
- $id = $this->getShort();
- $cnt = $this->getByte();
- return BlockAPI::getItem(
- $id,
- $this->getShort(),
- $cnt
- );
- }
-
- protected function getShort($unsigned = false){
- return Utils::readShort($this->get(2), $unsigned);
- }
-
- protected function getByte(){
- return ord($this->get(1));
- }
-
- protected function putSlot(Item $item){
- $this->putShort($item->getID());
- $this->putByte($item->count);
- $this->putShort($item->getMetadata());
- }
-
- protected function putShort($v){
- $this->buffer .= Utils::writeShort($v);
- }
-
- protected function putByte($v){
- $this->buffer .= chr((int)$v);
- }
-
- protected function getString(){
- return $this->get($this->getShort(true));
- }
-
- protected function putString($v){
- $this->putShort(strlen($v));
- $this->put($v);
- }
-}
diff --git a/src/network/raknet/RakNetInfo.php b/src/network/raknet/RakNetInfo.php
deleted file mode 100644
index 0093a4ce..00000000
--- a/src/network/raknet/RakNetInfo.php
+++ /dev/null
@@ -1,74 +0,0 @@
-packetID = (int) $packetID;
- }
-
- public function pid(){
- return $this->packetID;
- }
-
- public function __destruct(){
- }
-}
\ No newline at end of file
diff --git a/src/network/raknet/RakNetParser.php b/src/network/raknet/RakNetParser.php
deleted file mode 100644
index c87bef72..00000000
--- a/src/network/raknet/RakNetParser.php
+++ /dev/null
@@ -1,353 +0,0 @@
-buffer =& $buffer;
- $this->offset = 0;
- if(strlen($this->buffer) > 0){
- $this->parse();
- }else{
- $this->packet = false;
- }
- }
-
- private function parse(){
- $this->packet = new RakNetPacket(ord($this->get(1)));
- $this->packet->buffer =& $this->buffer;
- $this->packet->length = strlen($this->buffer);
- switch($this->packet->pid()){
- case RakNetInfo::UNCONNECTED_PING:
- case RakNetInfo::UNCONNECTED_PING_OPEN_CONNECTIONS:
- $this->packet->pingID = $this->getLong();
- $this->offset += 16; //Magic
- break;
- case RakNetInfo::OPEN_CONNECTION_REQUEST_1:
- $this->offset += 16; //Magic
- $this->packet->structure = $this->getByte();
- $this->packet->mtuSize = strlen($this->get(true));
- break;
- case RakNetInfo::OPEN_CONNECTION_REQUEST_2:
- $this->offset += 16; //Magic
- $this->packet->security = $this->get(5);
- $this->packet->port = $this->getShort(false);
- $this->packet->mtuSize = $this->getShort(false);
- $this->packet->clientID = $this->getLong();
- break;
- case RakNetInfo::DATA_PACKET_0:
- case RakNetInfo::DATA_PACKET_1:
- case RakNetInfo::DATA_PACKET_2:
- case RakNetInfo::DATA_PACKET_3:
- case RakNetInfo::DATA_PACKET_4:
- case RakNetInfo::DATA_PACKET_5:
- case RakNetInfo::DATA_PACKET_6:
- case RakNetInfo::DATA_PACKET_7:
- case RakNetInfo::DATA_PACKET_8:
- case RakNetInfo::DATA_PACKET_9:
- case RakNetInfo::DATA_PACKET_A:
- case RakNetInfo::DATA_PACKET_B:
- case RakNetInfo::DATA_PACKET_C:
- case RakNetInfo::DATA_PACKET_D:
- case RakNetInfo::DATA_PACKET_E:
- case RakNetInfo::DATA_PACKET_F:
- $this->packet->seqNumber = $this->getLTriad();
- $this->packet->data = [];
- while(!$this->feof() and ($pk = $this->parseDataPacket()) instanceof RakNetDataPacket){
- $this->packet->data[] = $pk;
- }
- break;
- case RakNetInfo::NACK:
- case RakNetInfo::ACK:
- $count = $this->getShort();
- $this->packet->packets = [];
- for($i = 0; $i < $count and !$this->feof(); ++$i){
- if($this->getByte() === 0){
- $start = $this->getLTriad();
- $end = $this->getLTriad();
- if(($end - $start) > 4096){
- $end = $start + 4096;
- }
- for($c = $start; $c <= $end; ++$c){
- $this->packet->packets[] = $c;
- }
- }else{
- $this->packet->packets[] = $this->getLTriad();
- }
- }
- break;
- default:
- $this->packet = false;
- break;
- }
- }
-
- private function get($len){
- if($len <= 0){
- $this->offset = strlen($this->buffer) - 1;
- return "";
- }
- if($len === true){
- return substr($this->buffer, $this->offset);
- }
- $this->offset += $len;
- return substr($this->buffer, $this->offset - $len, $len);
- }
-
- private function getLong($unsigned = false){
- return Utils::readLong($this->get(8), $unsigned);
- }
-
- private function getByte(){
- return ord($this->get(1));
- }
-
- private function getShort($unsigned = false){
- return Utils::readShort($this->get(2), $unsigned);
- }
-
- private function getLTriad(){
- return Utils::readTriad(strrev($this->get(3)));
- }
-
- private function feof(){
- return !isset($this->buffer[$this->offset]);
- }
-
- private function parseDataPacket(){
- $packetFlags = $this->getByte();
- $reliability = ($packetFlags & 0b11100000) >> 5;
- $hasSplit = ($packetFlags & 0b00010000) > 0;
- $length = (int) ceil($this->getShort() / 8);
- if($reliability === 2
- or $reliability === 3
- or $reliability === 4
- or $reliability === 6
- or $reliability === 7){
- $messageIndex = $this->getLTriad();
- }else{
- $messageIndex = false;
- }
-
- if($reliability === 1
- or $reliability === 3
- or $reliability === 4
- or $reliability === 7){
- $orderIndex = $this->getLTriad();
- $orderChannel = $this->getByte();
- }else{
- $orderIndex = false;
- $orderChannel = false;
- }
-
- if($hasSplit == true){
- $splitCount = $this->getInt();
- $splitID = $this->getShort();
- $splitIndex = $this->getInt();
- }else{
- $splitCount = false;
- $splitID = false;
- $splitIndex = false;
- }
-
- if($length <= 0
- or $orderChannel >= 32
- or ($hasSplit === true and $splitIndex >= $splitCount)){
- return false;
- }else{
- $pid = $this->getByte();
- $buffer = $this->get($length - 1);
- if(strlen($buffer) < ($length - 1)){
- return false;
- }
- switch($pid){
- case ProtocolInfo::PING_PACKET:
- $data = new PingPacket;
- break;
- case ProtocolInfo::PONG_PACKET:
- $data = new PongPacket;
- break;
- case ProtocolInfo::CLIENT_CONNECT_PACKET:
- $data = new ClientConnectPacket;
- break;
- case ProtocolInfo::SERVER_HANDSHAKE_PACKET:
- $data = new ServerHandshakePacket;
- break;
- case ProtocolInfo::DISCONNECT_PACKET:
- $data = new DisconnectPacket;
- break;
- case ProtocolInfo::LOGIN_PACKET:
- $data = new LoginPacket;
- break;
- case ProtocolInfo::LOGIN_STATUS_PACKET:
- $data = new LoginStatusPacket;
- break;
- case ProtocolInfo::READY_PACKET:
- $data = new ReadyPacket;
- break;
- case ProtocolInfo::MESSAGE_PACKET:
- $data = new MessagePacket;
- break;
- case ProtocolInfo::SET_TIME_PACKET:
- $data = new SetTimePacket;
- break;
- case ProtocolInfo::START_GAME_PACKET:
- $data = new StartGamePacket;
- break;
- case ProtocolInfo::ADD_MOB_PACKET:
- $data = new AddMobPacket;
- break;
- case ProtocolInfo::ADD_PLAYER_PACKET:
- $data = new AddPlayerPacket;
- break;
- case ProtocolInfo::REMOVE_PLAYER_PACKET:
- $data = new RemovePlayerPacket;
- break;
- case ProtocolInfo::ADD_ENTITY_PACKET:
- $data = new AddEntityPacket;
- break;
- case ProtocolInfo::REMOVE_ENTITY_PACKET:
- $data = new RemoveEntityPacket;
- break;
- case ProtocolInfo::ADD_ITEM_ENTITY_PACKET:
- $data = new AddItemEntityPacket;
- break;
- case ProtocolInfo::TAKE_ITEM_ENTITY_PACKET:
- $data = new TakeItemEntityPacket;
- break;
- case ProtocolInfo::MOVE_ENTITY_PACKET:
- $data = new MoveEntityPacket;
- break;
- case ProtocolInfo::MOVE_ENTITY_PACKET_POSROT:
- $data = new MoveEntityPacket_PosRot;
- break;
- case ProtocolInfo::ROTATE_HEAD_PACKET:
- $data = new RotateHeadPacket;
- break;
- case ProtocolInfo::MOVE_PLAYER_PACKET:
- $data = new MovePlayerPacket;
- break;
- case ProtocolInfo::REMOVE_BLOCK_PACKET:
- $data = new RemoveBlockPacket;
- break;
- case ProtocolInfo::UPDATE_BLOCK_PACKET:
- $data = new UpdateBlockPacket;
- break;
- case ProtocolInfo::ADD_PAINTING_PACKET:
- $data = new AddPaintingPacket;
- break;
- case ProtocolInfo::EXPLODE_PACKET:
- $data = new ExplodePacket;
- break;
- case ProtocolInfo::LEVEL_EVENT_PACKET:
- $data = new LevelEventPacket;
- break;
- case ProtocolInfo::TILE_EVENT_PACKET:
- $data = new TileEventPacket;
- break;
- case ProtocolInfo::ENTITY_EVENT_PACKET:
- $data = new EntityEventPacket;
- break;
- case ProtocolInfo::REQUEST_CHUNK_PACKET:
- $data = new RequestChunkPacket;
- break;
- case ProtocolInfo::CHUNK_DATA_PACKET:
- $data = new ChunkDataPacket;
- break;
- case ProtocolInfo::PLAYER_EQUIPMENT_PACKET:
- $data = new PlayerEquipmentPacket;
- break;
- case ProtocolInfo::PLAYER_ARMOR_EQUIPMENT_PACKET:
- $data = new PlayerArmorEquipmentPacket;
- break;
- case ProtocolInfo::INTERACT_PACKET:
- $data = new InteractPacket;
- break;
- case ProtocolInfo::USE_ITEM_PACKET:
- $data = new UseItemPacket;
- break;
- case ProtocolInfo::PLAYER_ACTION_PACKET:
- $data = new PlayerActionPacket;
- break;
- case ProtocolInfo::HURT_ARMOR_PACKET:
- $data = new HurtArmorPacket;
- break;
- case ProtocolInfo::SET_ENTITY_DATA_PACKET:
- $data = new SetEntityDataPacket;
- break;
- case ProtocolInfo::SET_ENTITY_MOTION_PACKET:
- $data = new SetEntityMotionPacket;
- break;
- case ProtocolInfo::SET_HEALTH_PACKET:
- $data = new SetHealthPacket;
- break;
- case ProtocolInfo::SET_SPAWN_POSITION_PACKET:
- $data = new SetSpawnPositionPacket;
- break;
- case ProtocolInfo::ANIMATE_PACKET:
- $data = new AnimatePacket;
- break;
- case ProtocolInfo::RESPAWN_PACKET:
- $data = new RespawnPacket;
- break;
- case ProtocolInfo::SEND_INVENTORY_PACKET:
- $data = new SendInventoryPacket;
- break;
- case ProtocolInfo::DROP_ITEM_PACKET:
- $data = new DropItemPacket;
- break;
- case ProtocolInfo::CONTAINER_OPEN_PACKET:
- $data = new ContainerOpenPacket;
- break;
- case ProtocolInfo::CONTAINER_CLOSE_PACKET:
- $data = new ContainerClosePacket;
- break;
- case ProtocolInfo::CONTAINER_SET_SLOT_PACKET:
- $data = new ContainerSetSlotPacket;
- break;
- case ProtocolInfo::CONTAINER_SET_DATA_PACKET:
- $data = new ContainerSetDataPacket;
- break;
- case ProtocolInfo::CONTAINER_SET_CONTENT_PACKET:
- $data = new ContainerSetContentPacket;
- break;
- case ProtocolInfo::CHAT_PACKET:
- $data = new ChatPacket;
- break;
- case ProtocolInfo::ADVENTURE_SETTINGS_PACKET:
- $data = new AdventureSettingsPacket;
- break;
- case ProtocolInfo::ENTITY_DATA_PACKET:
- $data = new EntityDataPacket;
- break;
- case ProtocolInfo::SET_ENTITY_LINK_PACKET:
- $data = new SetEntityLinkPacket;
- case ProtocolInfo::PLAYER_INPUT_PACKET:
- $data = new PlayerInputPacket;
- break;
- default:
- $data = new UnknownPacket();
- $data->packetID = $pid;
- break;
- }
- $data->reliability = $reliability;
- $data->hasSplit = $hasSplit;
- $data->messageIndex = $messageIndex;
- $data->orderIndex = $orderIndex;
- $data->orderChannel = $orderChannel;
- $data->splitCount = $splitCount;
- $data->splitID = $splitID;
- $data->splitIndex = $splitIndex;
- $data->setBuffer($buffer);
- }
- return $data;
- }
-
- private function getInt($unsigned = false){
- return Utils::readInt($this->get(4), $unsigned);
- }
-
-}
\ No newline at end of file
diff --git a/src/plugin/DummyPlugin.php b/src/plugin/DummyPlugin.php
deleted file mode 100644
index 34d8abcc..00000000
--- a/src/plugin/DummyPlugin.php
+++ /dev/null
@@ -1,13 +0,0 @@
- $line){
- if(!strpos($line, "=")){
- continue;
- }
-
- $line = explode("=", $line);
- $content[$line[0]] = $line[1];
- }
-
- $pluginData["name"] = trim($content["name"]);
- $pluginData["description"] = trim($content["description"]);
- $pluginData["version"] = trim($content["version"]);
- $pluginData["author"] = trim($content["author"]);
- $pluginData["mainFile"] = trim($content["mainFile"]);
- $pluginData["api"] = explode(",", trim($content["api"]));
- $pluginData["classLoader"] = trim($content["classLoader"]);
- $pluginData["CLClass"] = self::getNameSpaceClass($pluginData["classLoader"]);
- return $pluginData;
- }
-
- public static function getNameSpaceClass($content){
- return trim(substr(str_replace("/", "\\", $content), 0, -4));
- }
-
-
-}
\ No newline at end of file
diff --git a/src/pmf/PMF.php b/src/pmf/PMF.php
deleted file mode 100644
index 8cf45ebe..00000000
--- a/src/pmf/PMF.php
+++ /dev/null
@@ -1,114 +0,0 @@
-create($file, $type, $version);
- }else{
- if($this->load($file) !== true){
- $this->parseInfo();
- }
- }
- }
-
- public function create($file, $type, $version = PMF_CURRENT_VERSION){
- $this->file = $file;
- $dirname = dirname($this->file);
- if(!is_dir($dirname)){
- @mkdir($dirname, 0755, true);
- }
-
-
- if(!is_resource($this->fp)){
- if(($this->fp = @fopen($file, "c+b")) === false){
- return false;
- }
- }
- $this->seek(0);
- $this->write("PMF" . chr((int) $version) . chr((int) $type));
- }
-
- public function seek($offset, $whence = SEEK_SET){
- if(is_resource($this->fp)){
- return fseek($this->fp, (int) $offset, (int) $whence);
- }
- return false;
- }
-
- public function write($string, $length = false){
- if(is_resource($this->fp)){
- return ($length === false ? fwrite($this->fp, $string) : fwrite($this->fp, $string, $length));
- }
- return false;
- }
-
- public function load($file){
- $this->close();
- $this->file = $file;
- if(($this->fp = @fopen($file, "c+b")) !== false){
- fseek($this->fp, 0, SEEK_END);
- if(ftell($this->fp) >= 5){ //Header + 2 Bytes
- @flock($this->fp, LOCK_EX);
- return true;
- }
- $this->close();
- }
- return false;
- }
-
- public function close(){
- unset($this->version, $this->type, $this->file);
- if(is_object($this->fp)){
- @flock($this->fp, LOCK_UN);
- fclose($this->fp);
- }
- }
-
- public function parseInfo(){
- $this->seek(0);
- if(fread($this->fp, 3) !== "PMF"){
- return false;
- }
- $this->version = ord($this->read(1));
- switch($this->version){
- case 0x01:
- $this->type = ord($this->read(1));
- break;
- default:
- console("[ERROR] Tried loading non-supported PMF version " . $this->version . " on file " . $this->file);
- return false;
- }
- return true;
- }
-
- public function read($length){
- if($length <= 0){
- return "";
- }
- if(is_resource($this->fp)){
- return fread($this->fp, (int) $length);
- }
- return false;
- }
-
- public function getVersion(){
- return $this->version;
- }
-
- public function getType(){
- return $this->type;
- }
-
- public function getFile(){
- return $this->file;
- }
-
-}
\ No newline at end of file
diff --git a/src/pmf/PMFLevel.php b/src/pmf/PMFLevel.php
deleted file mode 100644
index 529f9139..00000000
--- a/src/pmf/PMFLevel.php
+++ /dev/null
@@ -1,910 +0,0 @@
-create($file, 0);
- $this->levelData = $blank;
- $this->createBlank();
- $this->isLoaded = true;
- $this->log = (int) ((string) log($this->levelData["width"], 2));
- }else{
- if($this->load($file) !== false){
- $this->parseInfo();
- if($this->parseLevel($file) === false){
- $this->isLoaded = false;
- }else{
- $this->isLoaded = true;
- $this->log = (int) ((string) log($this->levelData["width"], 2));
- }
- }else{
- $this->isLoaded = false;
- }
- }
- }
-
- public function setPopulated($X, $Z, $bool = true){
- $this->populated[self::getIndex($X, $Z)] = $bool;
- }
-
- private function createBlank(){
- $this->saveData(false);
- $this->locationTable = [];
- //$cnt = pow($this->levelData["width"], 2);
- $dirname = dirname($this->file) . "/chunks/";
- if(!is_dir($dirname)){
- @mkdir($dirname , 0755);
- }
-
- for($X = 0; $X < 16; ++$X){
- for($Z = 0; $Z < 16; ++$Z){
- $index = $this->getIndex($X, $Z);
- $this->initCleanChunk($X, $Z);
- //$this->chunks[$index] = false;
- //$this->chunkChange[$index] = false;
- //$this->locationTable[$index] = [0 => 0,];
- //$this->write(Utils::writeShort(0));
- //$X = $Z = null;
- //$this->getXZ($index, $X, $Z);
- @file_put_contents($this->getChunkPath($X, $Z), gzdeflate("", PMF_LEVEL_DEFLATE_LEVEL));
- }
- }
- if(!file_exists(dirname($this->file) . "/entities.yml")){
- $entities = new Config(dirname($this->file) . "/entities.yml", CONFIG_YAML);
- $entities->save();
- }
- if(!file_exists(dirname($this->file) . "/tiles.yml")){
- $tiles = new Config(dirname($this->file) . "/tiles.yml", CONFIG_YAML);
- $tiles->save();
- }
- }
-
- public function saveData($locationTable = true){
- $this->levelData["version"] = PMF_CURRENT_LEVEL_VERSION;
- @ftruncate($this->fp, 5);
- $this->seek(5);
- $this->write(chr($this->levelData["version"]));
- $this->write(Utils::writeShort(strlen($this->levelData["name"])) . $this->levelData["name"]);
- $this->write(Utils::writeInt($this->levelData["seed"]));
- $this->write(Utils::writeInt($this->levelData["time"]));
- $this->write(Utils::writeFloat($this->levelData["spawnX"]));
- $this->write(Utils::writeFloat($this->levelData["spawnY"]));
- $this->write(Utils::writeFloat($this->levelData["spawnZ"]));
- $this->write(chr($this->levelData["width"]));
- $this->write(chr($this->levelData["height"]));
- $this->write(Utils::writeShort(strlen($this->levelData["generator"])).$this->levelData["generator"]);
- $extra = gzdeflate($this->levelData["extra"], PMF_LEVEL_DEFLATE_LEVEL);
- $this->write(Utils::writeShort(strlen($extra)) . $extra);
- $this->payloadOffset = ftell($this->fp);
-
- if($locationTable !== false){
- //$this->writeLocationTable();
- }
- }
-
- private function writeLocationTable(){
- //$cnt = pow($this->levelData["width"], 2);
- @ftruncate($this->fp, $this->payloadOffset);
- $this->seek($this->payloadOffset);
- for($X = 0; $X < 16; ++$X){
- for($Z = 0; $Z < 16; ++$Z){
- $this->write(Utils::writeShort($this->locationTable[$this->getIndex($X, $Z)][0]));
- }
- }
- }
-
- public function getXZ($index, &$X = null, &$Z = null){
- $Z = $index >> 16;
- $X = ($index & 0x8000) === 0x8000 ? -($index & 0x7fff) : $index & 0x7fff;
- return array($X, $Z);
- }
-
- private function getChunkPath($X, $Z){
- return dirname($this->file) . "/chunks/" . $Z . "." . $X . ".pmc";
- }
-
- public function loadNCPMF0Chunk($X, $Z){
- $index = $this->getIndex($X, $Z);
-
- if($this->isChunkLoaded($X, $Z)){
- return true;
-
- }elseif(!isset($this->locationTable[$index])){
- return false;
- }
-
- $info = $this->locationTable[$index];
- //$this->seek($info[0]);
-
- $chunk = @gzopen($this->getChunkPath($X, $Z), "rb");
- if($chunk === false){
- return false;
- }
- $this->chunks[$index] = [];
- $this->chunkChange[$index] = [-1 => false];
- $this->chunkInfo[$index][0] = str_repeat(ord(BIOME_PLAINS), 256);
- $this->setPopulated($X, $Z);
-
- for($Y = 0; $Y < $this->levelData["height"]; ++$Y){
- $t = 1 << $Y;
- if(($info[0] & $t) === $t){
- // 4096 + 2048 + 2048, Block Data, Meta, Light
- if(strlen($chunkDataHere = gzread($chunk, 8192)) < 8192){
- console("[NOTICE] Empty corrupt chunk detected [$X,$Z,:$Y], recovering contents", true, true, 2);
- $this->fillMiniChunk($X, $Z, $Y);
- }else{
-
- $this->chunks[$index][$Y] = str_repeat("\x00", 16384);
- $this->chunkChange[$index][-1] = true;
- $this->chunkChange[$index][$Y] = 16384;
- $this->chunkInfo[$index][0] = str_repeat("\x00", 256);
-
- //Convert id-meta to id-meta-light-light
- for($x = 0; $x < 16; ++$x){
- for($z = 0; $z < 16; ++$z){
- for($y = 0; $y < 16; ++$y){
- $id = $chunkDataHere[($y + ($x << 5) + ($z << 9))] ?? "\x00";
- $meta = $chunkDataHere[(($y >> 1) + 16 + ($x << 5) + ($z << 9))] ?? "\x00";
-
- $bindex = (int) ($y + ($x << 6) + ($z << 10));
- $mindex = (int) (($y >> 1) + 16 + ($x << 6) + ($z << 10));
-
- $this->chunks[$index][$Y][$bindex] = $id;
- $this->chunks[$index][$Y][$mindex] = $meta;
- }
- }
- }
- }
- }else{
- $this->chunks[$index][$Y] = false;
- }
- }
- @gzclose($chunk);
- return true;
- }
-
- public function loadNCPMF1Chunk($X, $Z){
- $index = $this->getIndex($X, $Z);
-
- if($this->isChunkLoaded($X, $Z)){
- return true;
- }
-
- $cp = $this->getChunkPath($X, $Z);
- if(!is_file($cp)) return false;
- $chunk = file_get_contents($cp);
- if($chunk === false){
- return false;
- }
- $chunk = zlib_decode($chunk);
- $offset = 0;
- if(strlen($chunk) === 0) return false;
- $info = [0 => Utils::readShort(substr($chunk, $offset, 2))];
- $offset+=2;
- $this->chunks[$index] = [];
- $this->chunkChange[$index] = [-1 => false];
- $this->chunkInfo[$index][0] = substr($chunk, $offset, 256); //Biome data
- $offset += 256;
- for($Y = 0; $Y < $this->levelData["height"]; ++$Y){
- $t = 1 << $Y;
- if(($info[0] & $t) === $t){
- // 4096 + 4096 + 4096 + 4096, Id, Meta, BlockLight, Skylight
- if(strlen($this->chunks[$index][$Y] = substr($chunk, $offset, 16384)) < 16384){
- console("[NOTICE] Empty corrupt chunk detected [$X,$Z,:$Y], recovering contents", true, true, 2);
- $this->fillMiniChunk($X, $Z, $Y);
- }
- $offset += 16384;
- }else{
- $this->chunks[$index][$Y] = false;
- }
- }
-
- $this->setPopulated($X, $Z, true);
-
- $this->chunkChange[$index][-1] = true; //force save
- return true;
- }
-
- protected function parseLevel($worldFile){
- if($this->getType() !== 0x00){
- return false;
- }
- $this->seek(5);
- $this->levelData["version"] = ord($this->read(1));
- if($this->levelData["version"] != PMF_CURRENT_LEVEL_VERSION){
- $cv = PMF_CURRENT_LEVEL_VERSION;
- ConsoleAPI::warn("The level version does not match current. ({$this->levelData["version"]} != {$cv})");
-
- switch($this->levelData["version"]){
- case 0:
- ConsoleAPI::notice("Converting the world from NCPMF-{$this->levelData["version"]} to NCPMF-$cv...");
- $worldDir = substr($worldFile, 0, -strlen("/level.pmf"));
- $backupDir = "auto-world-backup-".microtime(true);
- ConsoleAPI::info("Creating backup in $backupDir...");
- copydir($worldDir, $backupDir);
-
- ConsoleAPI::info("Starting converting...");
- $this->levelData["name"] = $this->read(Utils::readShort($this->read(2), false));
- $this->levelData["seed"] = Utils::readInt($this->read(4));
- $this->levelData["time"] = Utils::readInt($this->read(4));
- $this->levelData["spawnX"] = Utils::readFloat($this->read(4));
- $this->levelData["spawnY"] = Utils::readFloat($this->read(4));
- $this->levelData["spawnZ"] = Utils::readFloat($this->read(4));
- $this->levelData["width"] = ord($this->read(1));
- $this->levelData["height"] = ord($this->read(1));
-
- ConsoleAPI::notice("Choosing ".LevelAPI::$defaultLevelType." generator.");
- $generator = LevelAPI::createGenerator(LevelAPI::$defaultLevelType);
- $this->levelData["generator"] = get_class($generator);
-
- $lastseek = ftell($this->fp);
- if(($len = $this->read(2)) === false or ($this->levelData["extra"] = @gzinflate($this->read(Utils::readShort($len, false)))) === false){ //Corruption protection
- console("[NOTICE] Empty/corrupt location table detected, forcing recovery");
- fseek($this->fp, $lastseek);
- $c = gzdeflate("");
- $this->write(Utils::writeShort(strlen($c)) . $c);
- $this->payloadOffset = ftell($this->fp);
- $this->levelData["extra"] = "";
- //$cnt = pow($this->levelData["width"], 2);
- for($X = 0; $X < 16; ++$X){
- for($Z = 0; $Z < 16; ++$Z){
- $this->write("\x00\xFF"); //Force index recreation
- }
- }
- fseek($this->fp, $this->payloadOffset);
- }else{
- $this->payloadOffset = ftell($this->fp);
- }
- $this->locationTable = [];
- $this->seek($this->payloadOffset);
- for($Z = 0; $Z < 16; ++$Z){
- for($X = 0; $X < 16; ++$X){
- $index = $this->getIndex($X, $Z);
- $this->chunks[$index] = false;
- $this->chunkChange[$index] = false;
- $this->locationTable[$index] = [
- 0 => Utils::readShort($this->read(2)), //16 bit flags
- ];
- }
- }
-
- foreach(scandir("$worldDir/chunks/") as $f){
- if($f != "." && $f != ".."){
- $xz = explode(".", $f);
- $X = (int) $xz[0];
- $Z = (int) $xz[1];
- ConsoleAPI::info("Converting $X-$Z...");
- $this->loadNCPMF0Chunk($X, $Z);
- $this->unloadChunk($X, $Z);
- }
- }
-
- ConsoleAPI::notice("Modifying level.pmf...");
- $this->saveData(false);
- ConsoleAPI::notice("World converted. Reloading...");
- break;
- case 1:
- ConsoleAPI::notice("Converting the world from NCPMF-{$this->levelData["version"]} to NCPMF-$cv...");
- $worldDir = substr($worldFile, 0, -strlen("/level.pmf"));
- $backupDir = "auto-world-backup-".microtime(true);
- ConsoleAPI::info("Creating backup in $backupDir...");
- copydir($worldDir, $backupDir);
- ConsoleAPI::info("Starting converting...");
- $this->levelData["name"] = $this->read(Utils::readShort($this->read(2), false));
- $this->levelData["seed"] = Utils::readInt($this->read(4));
- $this->levelData["time"] = Utils::readInt($this->read(4));
- $this->levelData["spawnX"] = Utils::readFloat($this->read(4));
- $this->levelData["spawnY"] = Utils::readFloat($this->read(4));
- $this->levelData["spawnZ"] = Utils::readFloat($this->read(4));
- $this->levelData["width"] = ord($this->read(1));
- $this->levelData["height"] = ord($this->read(1));
- $this->levelData["generator"] = $this->read(Utils::readShort($this->read(2), false));
- $lastseek = ftell($this->fp);
- if(($len = $this->read(2)) === false or ($this->levelData["extra"] = @gzinflate($this->read(Utils::readShort($len, false)))) === false){ //Corruption protection
- console("[NOTICE] Empty/corrupt location table detected, forcing recovery");
- fseek($this->fp, $lastseek);
- $c = gzdeflate("");
- $this->write(Utils::writeShort(strlen($c)) . $c);
- $this->payloadOffset = ftell($this->fp);
- $this->levelData["extra"] = "";
- for($Z = 0; $X < 16; ++$Z){
- for($X = 0; $X < 16; ++$X){
- $this->write("\x00\xFF"); //Force index recreation
- }
- }
- fseek($this->fp, $this->payloadOffset);
- }else{
- $this->payloadOffset = ftell($this->fp);
- }
-
-
- foreach(scandir("$worldDir/chunks/") as $f){
- if($f != "." && $f != ".."){
- $xz = explode(".", $f);
- $X = (int) $xz[0];
- $Z = (int) $xz[1];
- ConsoleAPI::info("Converting $X-$Z...");
- $this->loadNCPMF1Chunk($X, $Z);
- $this->unloadChunk($X, $Z);
- }
- }
-
- ConsoleAPI::notice("Modifying level.pmf...");
- $this->saveData(false);
- ConsoleAPI::notice("World converted. Reloading...");
- break;
- }
-
- return false;
- }
-
-
-
- $this->levelData["name"] = $this->read(Utils::readShort($this->read(2), false));
- $this->levelData["seed"] = Utils::readInt($this->read(4));
- $this->levelData["time"] = Utils::readInt($this->read(4));
- $this->levelData["spawnX"] = Utils::readFloat($this->read(4));
- $this->levelData["spawnY"] = Utils::readFloat($this->read(4));
- $this->levelData["spawnZ"] = Utils::readFloat($this->read(4));
- $this->levelData["width"] = ord($this->read(1));
- $this->levelData["height"] = ord($this->read(1));
- $this->levelData["generator"] = $this->read(Utils::readShort($this->read(2), false));
- if(($this->levelData["width"] !== 16 and $this->levelData["width"] !== 32) or $this->levelData["height"] !== 8){
- return false;
- }
- $lastseek = ftell($this->fp);
- if(($len = $this->read(2)) === false or ($this->levelData["extra"] = @gzinflate($this->read(Utils::readShort($len, false)))) === false){ //Corruption protection
- console("[NOTICE] Empty/corrupt location table detected, forcing recovery");
- fseek($this->fp, $lastseek);
- $c = gzdeflate("");
- $this->write(Utils::writeShort(strlen($c)) . $c);
- $this->payloadOffset = ftell($this->fp);
- $this->levelData["extra"] = "";
- //$cnt = pow($this->levelData["width"], 2);
- for($X = 0; $X < 16; ++$X){
- for($Z = 0; $Z < 16; ++$Z){
- $this->write("\x00\xFF"); //Force index recreation
- }
- }
- fseek($this->fp, $this->payloadOffset);
- }else{
- $this->payloadOffset = ftell($this->fp);
- }
- return $this->readLocationTable();
- }
-
- private function readLocationTable(){
- //$this->locationTable = [];
- //$cnt = pow($this->levelData["width"], 2);
- //$this->seek($this->payloadOffset);
- for($Z = 0; $Z < 16; ++$Z){
- for($X = 0; $X < 16; ++$X){
- $index = $this->getIndex($X, $Z);
- $this->chunks[$index] = false;
- $this->chunkChange[$index] = false;
- //$this->locationTable[$index] = [
- // 0 => Utils::readShort($this->read(2)), //16 bit flags
- //];
- }
- }
- //var_dump($this->locationTable);
- return true;
- }
-
- public function getSeed(): int{
- return $this->levelData["seed"];
- }
-
- public function getData($index){
- if(!isset($this->levelData[$index])){
- return false;
- }
- return ($this->levelData[$index]);
- }
-
- public function setData($index, $data){
- if(!isset($this->levelData[$index])){
- return false;
- }
- $this->levelData[$index] = $data;
- return true;
- }
-
- public function close(){
- $chunks = null;
- unset($chunks, $chunkChange, $locationTable);
- parent::close();
- }
-
- public function getBiomeId($x, $z){
- $X = $x >> 4;
- $Z = $z >> 4;
- $index = $this->getIndex($X, $Z);
- if(!isset($this->chunkInfo[$index])){
- return 0;
- }
- $aX = $x & 15;
- $aZ = $z & 15;
-
- return ord($this->chunkInfo[$index][0][$aX + ($aZ << 4)]);
- }
- public function setBiomeIdArrayForChunk($x, $z, $biomeIds){
- $this->chunkInfo[$this->getIndex($x, $z)][0] = $biomeIds;
- }
- public function setBiomeId($x, $z, $id){
- $X = $x >> 4;
- $Z = $z >> 4;
- $index = $this->getIndex($X, $Z);
- if(!isset($this->chunkInfo[$index])){
- return 0;
- }
- $aX = $x & 15;
- $aZ = $z & 15;
- $this->chunkInfo[$index][0][$aX + ($aZ << 4)] = chr($id);
- }
- public function forceUnloadChunk($X, $Z, $save = true){
- $X = (int) $X;
- $Z = (int) $Z;
- $index = $this->getIndex($X, $Z);
- $this->chunks[$index] = null;
- $this->chunkChange[$index] = null;
- unset($this->chunks[$index], $this->chunkChange[$index]);
- }
- public function unloadChunk($X, $Z, $save = true){
- $X = (int) $X;
- $Z = (int) $Z;
- if(!$this->isChunkLoaded($X, $Z)){
- return false;
- }elseif($save !== false){
- $this->saveChunk($X, $Z);
- }
- $index = $this->getIndex($X, $Z);
- $this->chunks[$index] = null;
- $this->chunkChange[$index] = null;
- unset($this->chunks[$index], $this->chunkChange[$index]);
- return true;
- }
-
- public function isChunkLoaded($X, $Z){
- $index = $this->getIndex($X, $Z);
- if(!isset($this->chunks[$index]) or $this->chunks[$index] === false){
- return false;
- }
- return true;
- }
-
- public function getIndex($X, $Z){
- return ($Z << 16) | ($X < 0 ? (~--$X & 0x7fff) | 0x8000 : $X & 0x7fff);
- }
-
- public function saveChunk($X, $Z){
- $X = (int) $X;
- $Z = (int) $Z;
- if(!$this->isChunkLoaded($X, $Z)){
- return false;
- }
- $index = $this->getIndex($X, $Z);
- if(!isset($this->chunkChange[$index]) or $this->chunkChange[$index][-1] === false){//No changes in chunk
- return true;
- }
-
- $chunk = @gzopen($this->getChunkPath($X, $Z), "wb" . PMF_LEVEL_DEFLATE_LEVEL);
- $bitmap = 0;
- for($Y = 0; $Y < 8; ++$Y){
- $bitmap |= ($this->chunks[$index][$Y] !== false and ((isset($this->chunkChange[$index][$Y]) and $this->chunkChange[$index][$Y] === 0) or !$this->isMiniChunkEmpty($X, $Z, $Y))) << $Y;
- }
- gzwrite($chunk, Utils::writeShort($bitmap), 2); //2 bytes locmap(actually it should be only 1)
- gzwrite($chunk, chr($this->populated[$index]), 1); //isPopulated
- $biomedata = $this->chunkInfo[$index][0];
- if(strlen($biomedata) < 256){
- $biomedata = str_repeat("\x01", 256);
- }
-
- gzwrite($chunk, $biomedata);
- for($Y = 0; $Y < 8; ++$Y){
- if($this->chunks[$index][$Y] !== false and ((isset($this->chunkChange[$index][$Y]) and $this->chunkChange[$index][$Y] === 0) or !$this->isMiniChunkEmpty($X, $Z, $Y))){
- gzwrite($chunk, $this->chunks[$index][$Y]);
- }else{
- $this->chunks[$index][$Y] = false;
- }
- $this->chunkChange[$index][$Y] = 0;
- }
- $this->chunkChange[$index][-1] = false;
- //$this->locationTable[$index][0] = $bitmap;
- //$this->seek($this->payloadOffset + ($index << 1));
- //$this->write(Utils::writeShort($this->locationTable[$index][0]));
- return true;
- }
-
- protected function isMiniChunkEmpty($X, $Z, $Y){
- $index = $this->getIndex($X, $Z);
- if($this->chunks[$index][$Y] !== false){
- if(substr_count($this->chunks[$index][$Y], "\x00") < 16384){
- return false;
- }
- }
- return true;
- }
-
- public function getMiniChunk($X, $Z, $Y){
- if($this->loadChunk($X, $Z) === false){
- return str_repeat("\x00", 16384);
- }
- $index = $this->getIndex($X, $Z);
- if(!isset($this->chunks[$index][$Y]) or $this->chunks[$index][$Y] === false){
- return str_repeat("\x00", 16384);
- }
- return $this->chunks[$index][$Y];
- }
-
- public function generateChunk($X, $Z, LevelGenerator $generator){
- $index = $this->getIndex($X, $Z);
- if(isset($this->chunks[$index])){
- return false;
- }
- $this->initCleanChunk($X, $Z);
- $this->fillFullChunk($X, $Z);
- $generator->generateChunk($X, $Z);
- $generator->populateChunk($X, $Z);
- }
-
- public function fillFullChunk($X, $Z){
- for($Y = 0; $Y < 16; ++$Y){
- $this->fillMiniChunk($X, $Z, $Y);
- }
- }
-
- public function loadChunk($X, $Z, $populate = false){
-
- $index = $this->getIndex($X, $Z);
-
- if($this->isChunkLoaded($X, $Z)){
- return true;
-
- }//elseif(!isset($this->locationTable[$index])){
- // return false;
- //}
-
- //$info = $this->locationTable[$index];
- //$this->seek($info[0]);
- $cp = $this->getChunkPath($X, $Z);
- if(!is_file($cp)) return false;
- $chunk = file_get_contents($cp);
- if($chunk === false){
- return false;
- }
- $chunk = zlib_decode($chunk);
- $offset = 0;
- if(strlen($chunk) === 0) return false;
- $info = [0 => Utils::readShort(substr($chunk, $offset, 2))];
- $offset+=2;
- $populated = ord($chunk[$offset]) > 0;
- ++$offset;
- $this->chunks[$index] = [];
- $this->chunkChange[$index] = [-1 => false];
- $this->chunkInfo[$index][0] = substr($chunk, $offset, 256); //Biome data
- $offset += 256;
- for($Y = 0; $Y < $this->levelData["height"]; ++$Y){
- $t = 1 << $Y;
- if(($info[0] & $t) === $t){
- // 4096 + 4096 + 4096 + 4096, Id, Meta, BlockLight, Skylight
- if(strlen($this->chunks[$index][$Y] = substr($chunk, $offset, 16384)) < 16384){
- console("[NOTICE] Empty corrupt chunk detected [$X,$Z,:$Y], recovering contents", true, true, 2);
- $this->fillMiniChunk($X, $Z, $Y);
- }
- $offset += 16384;
- }else{
- $this->chunks[$index][$Y] = false;
- }
- }
- $this->setPopulated($X, $Z, $populated);
- if($populate && !$populated){
- $this->level->generator->populateChunk($X, $Z);
- }
- return true;
- }
-
- protected function fillMiniChunk($X, $Z, $Y){
- if($this->isChunkLoaded($X, $Z) === false){
- return false;
- }
- $index = $this->getIndex($X, $Z);
-
- $this->chunks[$index][$Y] = str_repeat("\x00", 16384);
- $this->chunkChange[$index][-1] = true;
- $this->chunkChange[$index][$Y] = 16384;
- //$this->locationTable[$index][0] |= 1 << $Y;
- $this->chunkInfo[$index][0] = str_repeat("\x00", 256);
- return true;
- }
- public function initCleanChunk($X, $Z){
- $index = $this->getIndex($X, $Z);
- if(!isset($this->chunks[$index])){
- $this->chunks[$index] = array(
- 0 => false,
- 1 => false,
- 2 => false,
- 3 => false,
- 4 => false,
- 5 => false,
- 6 => false,
- 7 => false,
- );
- $this->chunkChange[$index] = array(
- -1 => true,
- 0 => 16384,
- 1 => 16384,
- 2 => 16384,
- 3 => 16384,
- 4 => 16384,
- 5 => 16384,
- 6 => 16384,
- 7 => 16384,
- );
- $this->chunkInfo[$index] = array(
- 0 => str_repeat("\x00", 256)
- );
- $this->locationTable[$index] = array(0);
- $this->setPopulated($X, $Z, false);
- }
- }
- public function setMiniChunk($X, $Z, $Y, $data){
- if($this->isChunkLoaded($X, $Z) === false){
- $this->loadChunk($X, $Z);
- }
- if(strlen($data) !== 16384){
- return false;
- }
- $index = $this->getIndex($X, $Z);
- $this->chunks[$index][$Y] = (string) $data;
- $this->chunkChange[$index][-1] = true;
- $this->chunkChange[$index][$Y] = 16384;
- $this->locationTable[$index][0] |= 1 << $Y;
- return true;
- }
- private function report(){
- console("[ERROR] A weird error in PMFLevel just happeneed. Values: ");
- var_dump(func_get_args());
- console("[NOTICE] If you see this message, you should send the log with error to the devs.");
- }
- public function getBlockIDsXZ($x, $z){
- $X = $x >> 4;
- $Z = $z >> 4;
- $index = $this->getIndex($X, $Z);
- return $this->chunks[$index] ?? 0;
- }
-
- public function getBlockID($x, $y, $z){
- if($y > 127 or $y < 0){
- return 0;
- }
- $X = $x >> 4;
- $Z = $z >> 4;
- $Y = $y >> 4;
- $index = $this->getIndex($X, $Z);
- if(!isset($this->chunks[$index]) || $this->chunks[$index] === false || ($this->chunks[$index][$Y] === false)){
- return 0;
- }
- $aX = $x & 0xf;
- $aZ = $z & 0xf;
- $aY = $y & 0xf;
- $b = ord($this->chunks[$index][$Y][($aY + ($aX << 6) + ($aZ << 10))]);
-
- return $b;
- }
-
- public function setBlockID($x, $y, $z, $block){
- if($y >= 128 or $y < 0){
- return false;
- }
- if($y > 127 or $y < 0){
- return false;
- }
- $X = $x >> 4;
- $Z = $z >> 4;
- $Y = $y >> 4;
- $block &= 0xFF;
- $index = $this->getIndex($X, $Z);
- if(!isset($this->chunks[$index]) or $this->chunks[$index] === false){
- if($this->loadChunk($X, $Z, false) === false){
- $this->createUnpopulatedChunk($X, $Z);
- }
- }
- if($this->chunks[$index][$Y] === false){
- $this->fillMiniChunk($X, $Z, $Y);
- }
-
- $aX = $x & 0xf;
- $aZ = $z & 0xf;
- $aY = $y & 0xf;
- $this->chunks[$index][$Y][(int) ($aY + ($aX << 6) + ($aZ << 10))] = chr($block);
- if(!isset($this->chunkChange[$index][$Y])){
- $this->chunkChange[$index][$Y] = 1;
- }else{
- ++$this->chunkChange[$index][$Y];
- }
- $this->chunkChange[$index][-1] = true;
- return true;
- }
-
- public function getBlockDamage($x, $y, $z){
- if($y > 127 or $y < 0){
- return 0;
- }
- $X = $x >> 4;
- $Z = $z >> 4;
- $Y = $y >> 4;
- $index = $this->getIndex($X, $Z);
- if(!isset($this->chunks[$index]) || $this->chunks[$index] === false || ($this->chunks[$index][$Y] === false)){
- return 0;
- }
- $aX = $x & 0xf;
- $aZ = $z & 0xf;
- $aY = $y & 0xf;
- //if(is_array($this->chunks) && isset($this->chunks[$index]) && is_array($this->chunks[$index]) && isset($this->chunks[$index][$Y]) && is_string($this->chunks[$index][$Y])){
- $m = ord($this->chunks[$index][$Y][(int) (($aY >> 1) + 16 + ($aX << 6) + ($aZ << 10))]);
- //}else{ //php8 fix
- // $m = 0;
- //}
-
- if(($y & 1) === 0){
- $m = $m & 0x0F;
- }else{
- $m = $m >> 4;
- }
- return $m;
- }
-
- public function setBlockDamage($x, $y, $z, $damage){
- if($y > 127 or $y < 0){
- return false;
- }
- $X = $x >> 4;
- $Z = $z >> 4;
- $Y = $y >> 4;
- $damage &= 0x0F;
- $index = $this->getIndex($X, $Z);
- $aX = $x & 0xf;
- $aZ = $z & 0xf;
- $aY = $y & 0xf;
- $mindex = (int) (($aY >> 1) + 16 + ($aX << 6) + ($aZ << 10));
- $old_m = ord($this->chunks[$index][$Y][$mindex]);
- if(($y & 1) === 0){
- $m = ($old_m & 0xF0) | $damage;
- }else{
- $m = ($damage << 4) | ($old_m & 0x0F);
- }
-
- if($old_m != $m){
- $this->chunks[$index][$Y][$mindex] = chr($m);
- if(!isset($this->chunkChange[$index][$Y])){
- $this->chunkChange[$index][$Y] = 1;
- }else{
- ++$this->chunkChange[$index][$Y];
- }
- $this->chunkChange[$index][-1] = true;
- return true;
- }
- return false;
- }
-
- public function getBlock($x, $y, $z){
- $X = $x >> 4;
- $Z = $z >> 4;
- $Y = $y >> 4;
- if($y >= 128 or $y < 0){
- return [AIR, 0];
- }
- $index = $this->getIndex($X, $Z);
- if(!isset($this->chunks[$index]) or $this->chunks[$index] === false){
- if($this->loadChunk($X, $Z) === false){
- return [AIR, 0];
- }
- }
- if($this->chunks[$index][$Y] === false){
- return [AIR, 0];
- }
- $aX = $x & 0xf;
- $aZ = $z & 0xf;
- $aY = $y & 0xf;
- #Need to fix. But idk how.
- //if(is_array($this->chunks) && is_array($this->chunks[$index]) && is_string($this->chunks[$index][$Y])){ //PHP8 warn fix
- $b = ord($this->chunks[$index][$Y][($aY + ($aX << 6) + ($aZ << 10))]);
- $m = ord($this->chunks[$index][$Y][(($aY >> 1) + 16 + ($aX << 6) + ($aZ << 10))]);
- //}else{
- // $b = 0;
- // $m = 0;
- //}
-
- if(($y & 1) === 0){
- $m = $m & 0x0F;
- }else{
- $m = $m >> 4;
- }
- return [$b, $m];
- }
-
- public function createUnpopulatedChunk($X, $Z){
- $this->initCleanChunk($X, $Z);
- $this->level->generator->generateChunk($X, $Z);
- $this->fakeLoaded[self::getIndex($X, $Z)] = "$X.$Z"; //TODO do not use string
- }
-
- public function setBlock($x, $y, $z, $block, $meta = 0){
- $X = $x >> 4;
- $Z = $z >> 4;
- $Y = $y >> 4;
- $block &= 0xFF;
- $meta &= 0x0F;
- if($Y >= 128 or $y < 0){
- return false;
- }
-
- $index = $this->getIndex($X, $Z);
- if(!isset($this->chunks[$index]) or $this->chunks[$index] === false){
- if($this->loadChunk($X, $Z, false) === false){
- $this->createUnpopulatedChunk($X, $Z);
- }
- }
- if(!isset($this->chunks[$index][$Y]) || $this->chunks[$index][$Y] === false){
- $this->fillMiniChunk($X, $Z, $Y);
- }
- $aX = $x - ($X << 4);
- $aZ = $z - ($Z << 4);
- $aY = $y - ($Y << 4);
- $bindex = (int) ($aY + ($aX << 6) + ($aZ << 10));
- $mindex = (int) (($aY >> 1) + 16 + ($aX << 6) + ($aZ << 10));
- $old_b = ord($this->chunks[$index][$Y][$bindex] ?? '\x00');
- $old_m = ord($this->chunks[$index][$Y][$mindex] ?? '\x00');
- if(($y & 1) === 0){
- $m = ($old_m & 0xF0) | $meta;
- }else{
- $m = ($meta << 4) | ($old_m & 0x0F);
- }
-
- if($old_b !== $block or $old_m !== $m){
- $this->chunks[$index][$Y][$bindex] = chr($block);
- $this->chunks[$index][$Y][$mindex] = chr($m);
- if(!isset($this->chunkChange[$index][$Y])){
- $this->chunkChange[$index][$Y] = 1;
- }else{
- ++$this->chunkChange[$index][$Y];
- }
- $this->chunkChange[$index][-1] = true;
- if($old_b instanceof LiquidBlock){
- $pos = new Position($x, $y, $z, $this->level);
- for($side = 0; $side <= 5; ++$side){
- $b = $pos->getSide($side);
- ServerAPI::request()->api->block->scheduleBlockUpdate($b, ($b instanceof LavaBlock ? 40: 10), BLOCK_UPDATE_NORMAL);
- }
- }
- return true;
- }
- return false;
- }
-
- public function doSaveRound(){
- foreach($this->chunks as $index => $chunk){ //TODO fix variables($X, $Z are undefined)
- $this->getXZ($index, $X, $Z);
- $this->saveChunk($X, $Z);
- }
- }
-
-}
diff --git a/src/pmf/PMFPlugin.php b/src/pmf/PMFPlugin.php
deleted file mode 100644
index d5f12692..00000000
--- a/src/pmf/PMFPlugin.php
+++ /dev/null
@@ -1,64 +0,0 @@
-load($file);
- $this->parseInfo();
- $this->parsePlugin();
- }
-
- protected function parsePlugin(){
- if($this->getType() !== 0x01){
- return false;
- }
- $this->seek(5);
- $this->pluginData["fversion"] = ord($this->read(1));
- if($this->pluginData["fversion"] > PMF_CURRENT_PLUGIN_VERSION){
- return false;
- }
- $this->pluginData["name"] = $this->read(Utils::readShort($this->read(2), false));
- $this->pluginData["version"] = $this->read(Utils::readShort($this->read(2), false));
- $this->pluginData["author"] = $this->read(Utils::readShort($this->read(2), false));
- if($this->pluginData["fversion"] >= 0x01){
- $this->pluginData["apiversion"] = $this->read(Utils::readShort($this->read(2), false));
- }else{
- $this->pluginData["apiversion"] = Utils::readShort($this->read(2), false);
- }
- $this->pluginData["class"] = $this->read(Utils::readShort($this->read(2), false));
- $this->pluginData["identifier"] = $this->read(Utils::readShort($this->read(2), false)); //Will be used to check for updates
- if($this->pluginData["fversion"] >= 0x02){
- $data = explode(";", gzinflate($this->read(Utils::readInt($this->read(4)))));
- $this->pluginData["extra"] = [];
- foreach($data as $v){
- $v = trim($v);
- if($v != ""){
- $v = base64_decode($v);
- $kl = strpos($v, ":");
- $this->pluginData["extra"][substr($v, 0, $kl)] = substr($v, $kl + 1);
- }
- }
-
- }else{
- $this->pluginData["extra"] = gzinflate($this->read(Utils::readShort($this->read(2), false)));
- }
- $this->pluginData["code"] = "";
- while(!feof($this->fp)){
- $this->pluginData["code"] .= $this->read(4096);
- }
- $this->pluginData["code"] = gzinflate($this->pluginData["code"]);
- }
-
- public function getPluginInfo(){
- return $this->pluginData;
- }
-
-}
\ No newline at end of file
diff --git a/src/recipes/CraftingRecipes.php b/src/recipes/CraftingRecipes.php
deleted file mode 100644
index 666719f9..00000000
--- a/src/recipes/CraftingRecipes.php
+++ /dev/null
@@ -1,328 +0,0 @@
-CLAY_BLOCK:0x1",
- "WOODEN_PLANKS:?x4=>WORKBENCH:0x1",
- "GLOWSTONE_DUST:?x4=>GLOWSTONE_BLOCK:0x1",
- "PUMPKIN:?x1,TORCH:?x1=>LIT_PUMPKIN:0x1",
- "SNOWBALL:?x4=>SNOW_BLOCK:0x1",
- "WOODEN_PLANKS:?x2=>STICK:0x4",
- "COBBLESTONE:?x4=>STONECUTTER:0x1",
- "WOOD:0x1=>WOODEN_PLANKS:0x4",
- "WOOD:1x1=>WOODEN_PLANKS:1x4",
- "WOOD:2x1=>WOODEN_PLANKS:2x4",
- "WOOD:3x1=>WOODEN_PLANKS:3x4",
- "WOOL:0x1,DYE:0x1=>WOOL:15x1",
- "WOOL:0x1,DYE:1x1=>WOOL:14x1",
- "WOOL:0x1,DYE:2x1=>WOOL:13x1",
- "WOOL:0x1,DYE:3x1=>WOOL:12x1",
- "WOOL:0x1,DYE:4x1=>WOOL:11x1",
- "WOOL:0x1,DYE:5x1=>WOOL:10x1",
- "WOOL:0x1,DYE:6x1=>WOOL:9x1",
- "WOOL:0x1,DYE:7x1=>WOOL:8x1",
- "WOOL:0x1,DYE:8x1=>WOOL:7x1",
- "WOOL:0x1,DYE:9x1=>WOOL:6x1",
- "WOOL:0x1,DYE:10x1=>WOOL:5x1",
- "WOOL:0x1,DYE:11x1=>WOOL:4x1",
- "WOOL:0x1,DYE:12x1=>WOOL:3x1",
- "WOOL:0x1,DYE:13x1=>WOOL:2x1",
- "WOOL:0x1,DYE:14x1=>WOOL:1x1",
- "STRING:?x4=>WOOL:0x1",
-
- //Tools
- "IRON_INGOT:?x1,FLINT:?x1=>FLINT_STEEL:0x1",
- "IRON_INGOT:?x2=>SHEARS:0x1",
- "COAL:0x1,STICK:?x1=>TORCH:0x4",
- "COAL:1x1,STICK:?x1=>TORCH:0x4",
-
- //Food & protection
- "MELON_SLICE:?x1=>MELON_SEEDS:0x1",
- "PUMPKIN:?x1=>PUMPKIN_SEEDS:0x4",
- "PUMPKIN:?x1,EGG:?x1,SUGAR:?x1=>PUMPKIN_PIE:0x1",
- "BROWN_MUSHROOM:?x1,RED_MUSHROOM:?x1,BOWL:?x1=>MUSHROOM_STEW:0x1",
- "SUGARCANE:?x1=>SUGAR:0x1",
- "MELON_SLICE:?x1=>MELON_SEEDS:0x1",
- "HAY_BALE:?x1=>WHEAT:0x9",
-
- //Items
- "EMERALD_BLOCK:?x1=>EMERALD:0x9",
- "DIAMOND_BLOCK:?x1=>DIAMOND:0x9",
- "GOLD_BLOCK:?x1=>GOLD_INGOT:0x9",
- "IRON_BLOCK:?x1=>IRON_INGOT:0x9",
- "LAPIS_BLOCK:?x1=>DYE:4x9",//Lapis Lazuli
- "DANDELION:?x1=>DYE:11x2",//Dandelion Yellow
- "BONE:?x1=>DYE:15x3",//Bone Meal
- "DYE:0x1,DYE:14x1=>DYE:3x2",//Cocoa Beans
- "DYE:0x1,DYE:1x1,DYE:11x1=>DYE:3x3",//Cocoa Beans
- "DYE:1x1,DYE:15x1=>DYE:9x2",//Pink Dye
- "DYE:1x1,DYE:11x1=>DYE:14x2",//Orange Dye
- "DYE:2x1,DYE:15x1=>DYE:10x2",//Lime Dye
- "DYE:4x1,DYE:15x1=>DYE:12x2",//Light Blue Dye
- "DYE:2x1,DYE:4x1=>DYE:6x2",//Cyan Dye
- "DYE:1x1,DYE:4x1=>DYE:5x2",//Purple Dye
- "DYE:1x1,DYE:4x1,DYE:15x1=>DYE:13x3",//Magenta Dye
- "BEETROOT:?x1=>DYE:1x2",//Rose Red
- "DYE:15x1,DYE:1x2,DYE:4x1=>DYE:13x4",//Magenta Dye
- "DYE:5x1,DYE:9x1=>DYE:13x2",//Magenta Dye
- "DYE:0x1,DYE:15x1=>DYE:8x2",//Gray Dye
- "DYE:0x1,DYE:15x2=>DYE:7x3",//Light Gray Dye
- "DYE:0x1,DYE:8x1=>DYE:7x2",//Light Gray Dye
- "WOOL:0x2=>CARPET:0x3",
- "WOOL:1x2=>CARPET:1x3",
- "WOOL:2x2=>CARPET:2x3",
- "WOOL:3x2=>CARPET:3x3",
- "WOOL:4x2=>CARPET:4x3",
- "WOOL:5x2=>CARPET:5x3",
- "WOOL:6x2=>CARPET:6x3",
- "WOOL:7x2=>CARPET:7x3",
- "WOOL:8x2=>CARPET:8x3",
- "WOOL:9x2=>CARPET:9x3",
- "WOOL:10x2=>CARPET:10x3",
- "WOOL:11x2=>CARPET:11x3",
- "WOOL:12x2=>CARPET:12x3",
- "WOOL:13x2=>CARPET:13x3",
- "WOOL:14x2=>CARPET:14x3",
- "WOOL:15x2=>CARPET:15x3",
-
- ];
-
- private static $big = [//Probably means only craftable on crafting bench. Name it better!
- //Building
- "WOOL:?x3,WOODEN_PLANKS:?x3=>BED:0x1",
- "WOODEN_PLANKS:?x8=>CHEST:0x1",
- "STICK:?x6=>FENCE:0x2",
- "STICK:?x4,WOODEN_PLANKS:?x2=>FENCE_GATE:0x1",
- "COBBLESTONE:?x8=>FURNACE:0x1",
- "GLASS:?x6=>GLASS_PANE:0x16",
- "STICK:?x7=>LADDER:0x2",
- "DIAMOND:?x3,IRON_INGOT:?x6=>NETHER_REACTOR:0x1",
- "WOODEN_PLANKS:?x6=>TRAPDOOR:0x2",
- "WOODEN_PLANKS:?x6=>WOODEN_DOOR:0x1",
- "WOODEN_PLANKS:0x6=>WOODEN_STAIRS:0x4",
- "WOODEN_PLANKS:0x3=>WOOD_SLAB:0x6",
- "WOODEN_PLANKS:1x6=>SPRUCE_WOOD_STAIRS:0x4",
- "WOODEN_PLANKS:1x3=>WOOD_SLAB:1x6",
- "WOODEN_PLANKS:2x6=>BIRCH_WOOD_STAIRS:0x4",
- "WOODEN_PLANKS:2x3=>WOOD_SLAB:2x6",
- "WOODEN_PLANKS:3x6=>JUNGLE_WOOD_STAIRS:0x4",
- "WOODEN_PLANKS:3x3=>WOOD_SLAB:3x6",
-
- //Tools
- "STICK:?x1,FEATHER:?x1,FLINT:?x1=>ARROW:0x4",
- "STICK:?x3,STRING:?x3=>BOW:0x1",
- "IRON_INGOT:?x3=>BUCKET:0x1",
- "GOLD_INGOT:?x4,REDSTONE_DUST:?x1=>CLOCK:0x1",
- "IRON_INGOT:?x4,REDSTONE_DUST:?x1=>COMPASS:0x1",
- "DIAMOND:?x3,STICK:?x2=>DIAMOND_AXE:0x1",
- "DIAMOND:?x2,STICK:?x2=>DIAMOND_HOE:0x1",
- "DIAMOND:?x3,STICK:?x2=>DIAMOND_PICKAXE:0x1",
- "DIAMOND:?x1,STICK:?x2=>DIAMOND_SHOVEL:0x1",
- "DIAMOND:?x2,STICK:?x1=>DIAMOND_SWORD:0x1",
- "GOLD_INGOT:?x3,STICK:?x2=>GOLDEN_AXE:0x1",
- "GOLD_INGOT:?x2,STICK:?x2=>GOLDEN_HOE:0x1",
- "GOLD_INGOT:?x3,STICK:?x2=>GOLDEN_PICKAXE:0x1",
- "GOLD_INGOT:?x1,STICK:?x2=>GOLDEN_SHOVEL:0x1",
- "GOLD_INGOT:?x2,STICK:?x1=>GOLDEN_SWORD:0x1",
- "IRON_INGOT:?x3,STICK:?x2=>IRON_AXE:0x1",
- "IRON_INGOT:?x2,STICK:?x2=>IRON_HOE:0x1",
- "IRON_INGOT:?x3,STICK:?x2=>IRON_PICKAXE:0x1",
- "IRON_INGOT:?x1,STICK:?x2=>IRON_SHOVEL:0x1",
- "IRON_INGOT:?x2,STICK:?x1=>IRON_SWORD:0x1",
- "COBBLESTONE:?x3,STICK:?x2=>STONE_AXE:0x1",
- "COBBLESTONE:?x2,STICK:?x2=>STONE_HOE:0x1",
- "COBBLESTONE:?x3,STICK:?x2=>STONE_PICKAXE:0x1",
- "COBBLESTONE:?x1,STICK:?x2=>STONE_SHOVEL:0x1",
- "COBBLESTONE:?x2,STICK:?x1=>STONE_SWORD:0x1",
- "SAND:?x4,GUNPOWDER:?x5=>TNT:0x1",
- "WOODEN_PLANKS:?x3,STICK:?x2=>WOODEN_AXE:0x1",
- "WOODEN_PLANKS:?x2,STICK:?x2=>WOODEN_HOE:0x1",
- "WOODEN_PLANKS:?x3,STICK:?x2=>WOODEN_PICKAXE:0x1",
- "WOODEN_PLANKS:?x1,STICK:?x2=>WOODEN_SHOVEL:0x1",
- "WOODEN_PLANKS:?x2,STICK:?x1=>WOODEN_SWORD:0x1",
- "IRON_INGOT:?x6,STICK:?x1=>RAIL:0x16",
- "GOLD_INGOT:?x6,STICK:?x1,REDSTONE:?x1=>POWERED_RAIL:0x6",
-
- //Food & protection
- "BEETROOT:?x4,BOWL:?x1=>BEETROOT_SOUP:0x1",
- "WOODEN_PLANKS:?x3=>BOWL:0x4",
- "WHEAT:?x3=>BREAD:0x1",
- "WHEAT:?x3,BUCKET:1x3,EGG:?x1,SUGAR:?x2=>CAKE:0x1",
- "DIAMOND:?x4=>DIAMOND_BOOTS:0x1",
- "DIAMOND:?x8=>DIAMOND_CHESTPLATE:0x1",
- "DIAMOND:?x5=>DIAMOND_HELMET:0x1",
- "DIAMOND:?x7=>DIAMOND_LEGGINGS:0x1",
- "GOLD_INGOT:?x4=>GOLDEN_BOOTS:0x1",
- "GOLD_INGOT:?x8=>GOLDEN_CHESTPLATE:0x1",
- "GOLD_INGOT:?x5=>GOLDEN_HELMET:0x1",
- "GOLD_INGOT:?x7=>GOLDEN_LEGGINGS:0x1",
- "IRON_INGOT:?x4=>IRON_BOOTS:0x1",
- "IRON_INGOT:?x8=>IRON_CHESTPLATE:0x1",
- "IRON_INGOT:?x5=>IRON_HELMET:0x1",
- "IRON_INGOT:?x7=>IRON_LEGGINGS:0x1",
- "LEATHER:?x4=>LEATHER_BOOTS:0x1",
- "LEATHER:?x8=>LEATHER_TUNIC:0x1",
- "LEATHER:?x5=>LEATHER_CAP:0x1",
- "LEATHER:?x7=>LEATHER_PANTS:0x1",
- //"FIRE:?x4=>CHAIN_BOOTS:0x1",
- //"FIRE:?x8=>CHAIN_CHESTPLATE:0x1",
- //"FIRE:?x5=>CHAIN_HELMET:0x1",
- //"FIRE:?x7=>CHAIN_LEGGINGS:0x1",
-
- //Items
- "EMERALD:?x9=>EMERALD_BLOCK:0x1",
- "DIAMOND:?x9=>DIAMOND_BLOCK:0x1",
- "GOLD_INGOT:?x9=>GOLD_BLOCK:0x1",
- "IRON_INGOT:?x9=>IRON_BLOCK:0x1",
- "IRON_INGOT:?x5=>MINECART:0x1",
- "WHEAT:?x9=>HAY_BALE:0x1",
- "PAPER:?x3=>BOOK:0x1",
- "WOODEN_PLANKS:?x6,BOOK:?x3=>BOOKSHELF:0x1",
- "DYE:4x9=>LAPIS_BLOCK:0x1",
- "WOOL:?x1,STICK:?x8=>PAINTING:0x1",
- "SUGARCANE:?x3=>PAPER:0x3",
- "WOODEN_PLANKS:?x6,STICK:?x1=>SIGN:0x3",
- "IRON_INGOT:?x6=>IRON_BARS:0x16",
- "COAL:0x9=>COAL_BLOCK:0x1",
- "COAL_BLOCK:?x1=>COAL:0x9",
-"MELON_SLICE:?x9=>MELON_BLOCK:0x1",
- ];
-
- private static $stone = [
- "QUARTZ:?x4=>QUARTZ_BLOCK:0x1",
- "BRICKS_BLOCK:?x6=>BRICK_STAIRS:0x4",
- "BRICK:?x4=>BRICKS_BLOCK:0x1",
- "BRICKS_BLOCK:?x3=>SLAB:4x6",
- "SLAB:6x2=>QUARTZ_BLOCK:1x1",
- "COBBLESTONE:?x3=>SLAB:3x6",
- "COBBLESTONE:0x6=>STONE_WALL:0x6",
- "MOSSY_STONE:0x6=>STONE_WALL:1x6",
- "NETHER_BRICK:?x4=>NETHER_BRICKS:0x1",
- "NETHER_BRICKS:?x6=>NETHER_BRICKS_STAIRS:0x4",
- "QUARTZ_BLOCK:0x2=>QUARTZ_BLOCK:2x2",
- "QUARTZ_BLOCK:?x3=>SLAB:6x6",
- "SANDSTONE:0x6=>SANDSTONE_STAIRS:0x4",
- "SAND:?x4=>SANDSTONE:0x1",
- "SANDSTONE:0x4=>SANDSTONE:2x4",
- "SLAB:1x2=>SANDSTONE:1x1",
- "SANDSTONE:0x3=>SLAB:1x6",
- "STONE_BRICK:?x6=>STONE_BRICK_STAIRS:0x4",
- "STONE:?x4=>STONE_BRICK:0x4",
- "STONE_BRICKS:?x3=>SLAB:5x6",
- "STONE:?x3=>SLAB:0x6",
- "COBBLESTONE:?x6=>COBBLESTONE_STAIRS:0x4",
- ];
-
- private static $recipes = [];
-
- public static function init(){
- $server = ServerAPI::request();
- $id = 1;
- foreach(CraftingRecipes::$small as $recipe){
- $recipe = CraftingRecipes::parseRecipe($recipe);
- $recipe[3] = 0; //Type
- CraftingRecipes::$recipes[$id] = $recipe;
- ++$id;
- }
- foreach(CraftingRecipes::$big as $recipe){
- $recipe = CraftingRecipes::parseRecipe($recipe);
- $recipe[3] = 1;
- CraftingRecipes::$recipes[$id] = $recipe;
- ++$id;
- }
- foreach(CraftingRecipes::$stone as $recipe){
- $recipe = CraftingRecipes::parseRecipe($recipe);
- $recipe[3] = 2;
- CraftingRecipes::$recipes[$id] = $recipe;
- ++$id;
- }
-
- foreach(CraftingRecipes::$recipes as $id => $recipe){
- $server->query("INSERT INTO recipes (id, type, recipe) VALUES (" . $id . ", " . $recipe[3] . ", '" . $recipe[2] . "');");
- }
- }
-
- private static function parseRecipe($recipe){
- $recipe = explode("=>", $recipe);
- $recipeItems = [];
- foreach(explode(",", $recipe[0]) as $item){
- $item = explode("x", $item);
- $id = explode(":", $item[0]);
- $meta = array_pop($id);
- $id = $id[0];
-
- $it = BlockAPI::fromString($id);
- if(!isset($recipeItems[$it->getID()])){
- $recipeItems[$it->getID()] = [$it->getID(), $meta === "?" ? false : intval($meta) & 0xFFFF, intval($item[1])];
- }else{
- if($it->getMetadata() !== $recipeItems[$it->getID()][1]){
- $recipeItems[$it->getID()][1] = false;
- }
- $recipeItems[$it->getID()][2] += $it->count;
- }
- }
- ksort($recipeItems);
- $item = explode("x", $recipe[1]);
- $id = explode(":", $item[0]);
- $meta = array_pop($id);
- $id = $id[0];
-
- $it = BlockAPI::fromString($id);
-
- $craftItem = [$it->getID(), intval($meta) & 0xFFFF, intval($item[1])];
-
- $recipeString = "";
- foreach($recipeItems as $item){
- $recipeString .= $item[0] . "x" . $item[2] . ",";
- }
- $recipeString = substr($recipeString, 0, -1) . "=>" . $craftItem[0] . "x" . $craftItem[2];
-
- return [$recipeItems, $craftItem, $recipeString];
- }
-
- public static function canCraft(array $craftItem, array $recipeItems, $type){
- ksort($recipeItems);
- $recipeString = "";
- foreach($recipeItems as $item){
- if($craftItem[0] === CAKE && $item[0] === BUCKET && $item[1] === 1){ //some dark magic with recipe happened in mcpe, pmmp restores it back to normal
- $item[2] = 3;
- }
- $recipeString .= $item[0] . "x" . $item[2] . ",";
- }
- $recipeString = substr($recipeString, 0, -1) . "=>" . $craftItem[0] . "x" . $craftItem[2];
- $server = ServerAPI::request();
- $result = $server->query("SELECT id FROM recipes WHERE type == " . $type . " AND recipe == '" . $recipeString . "';");
- if($result instanceof SQLite3Result){
- $continue = true;
- while(($r = $result->fetchArray(SQLITE3_NUM)) !== false){
- $continue = true;
- $recipe = CraftingRecipes::$recipes[$r[0]];
- foreach($recipe[0] as $item){
- if(!isset($recipeItems[$item[0]])){
- $continue = false;
- break;
- }
- $oitem = $recipeItems[$item[0]];
- if($craftItem[0] === CAKE && $oitem[0] === BUCKET && $item[1] === 1){ //some dark magic with recipe happened in mcpe, pmmp restores it back to normal x2
- $oitem[2] = 3;
- }
- if(($oitem[1] !== $item[1] and $item[1] !== false) or $oitem[2] !== $item[2]){
- $continue = false;
- break;
- }
- }
- if($continue === false or $craftItem[0] !== $recipe[1][0] or $recipe[1][1] !== $recipe[1][1] or $recipe[1][2] !== $recipe[1][2]){
- $continue = false;
- continue;
- }
- $continue = $recipe;
- break;
- }
- }else{
- return true;
- }
- return $continue;
- }
-
-}
diff --git a/src/recipes/FuelData.php b/src/recipes/FuelData.php
deleted file mode 100644
index e0c61bab..00000000
--- a/src/recipes/FuelData.php
+++ /dev/null
@@ -1,30 +0,0 @@
- 80,
- COAL_BLOCK => 800,
- TRUNK => 15,
- WOODEN_PLANKS => 15,
- SAPLING => 5,
- WOODEN_AXE => 10,
- WOODEN_PICKAXE => 10,
- WOODEN_SWORD => 10,
- WOODEN_SHOVEL => 10,
- WOODEN_HOE => 10,
- STICK => 5,
- FENCE => 15,
- FENCE_GATE => 15,
- WOODEN_STAIRS => 15,
- SPRUCE_WOOD_STAIRS => 15,
- BIRCH_WOOD_STAIRS => 15,
- JUNGLE_WOOD_STAIRS => 15,
- TRAPDOOR => 15,
- WORKBENCH => 15,
- BOOKSHELF => 15,
- CHEST => 15,
- BUCKET => 1000,
- ];
-
-}
\ No newline at end of file
diff --git a/src/recipes/SmeltingData.php b/src/recipes/SmeltingData.php
deleted file mode 100644
index a34e05b3..00000000
--- a/src/recipes/SmeltingData.php
+++ /dev/null
@@ -1,23 +0,0 @@
- [STONE, 0],
- SAND => [GLASS, 0],
- TRUNK => [COAL, 1], //Charcoal
- GOLD_ORE => [GOLD_INGOT, 0],
- IRON_ORE => [IRON_INGOT, 0],
- DIAMOND_ORE => [DIAMOND, 0],
- EMERALD_ORE => [EMERALD, 0],
- NETHERRACK => [NETHER_BRICK, 0],
- RAW_PORKCHOP => [COOKED_PORKCHOP, 0],
- CLAY => [BRICK, 0],
- CACTUS => [DYE, 2],
- RED_MUSHROOM => [DYE, 1],
- RAW_BEEF => [STEAK, 0],
- RAW_CHICKEN => [COOKED_CHICKEN, 0],
- RED_MUSHROOM => [DYE, 1],
- POTATO => [BAKED_POTATO, 0],
- ];
-}
diff --git a/src/structure/DesertWellStructure.php b/src/structure/DesertWellStructure.php
deleted file mode 100644
index 4aa70ba3..00000000
--- a/src/structure/DesertWellStructure.php
+++ /dev/null
@@ -1,84 +0,0 @@
- [
- "SSSSS",
- "SSSSS",
- "SSSSS",
- "SSSSS",
- "SSSSS",
- ],
- -1 => [
- "SSSSS",
- "SSWSS",
- "SWWWS",
- "SSWSS",
- "SSSSS",
- ],
- 0 => [
- "SSsSS",
- "SS SS",
- "s s",
- "SS SS",
- "SSsSS",
- ],
- 1 => [
- "",
- " S S ",
- "",
- " S S ",
- "",
- ],
- 2 => [
- "",
- " S S ",
- "",
- " S S ",
- "",
- ],
- 3 => [
- "",
- " sss ",
- " sSs ",
- " sss ",
- "",
- ],
- ];
-
- public static function buildStructure($level, $x, $y, $z){ /*use CENTER positions*/
- $offsetX = 0;
- $offsetZ = 0;
- foreach(self::$structure as $layerCount => $layer){
- foreach($layer as $line){
- $line = rtrim($line); //remove useless spaces(only from right)
- foreach(str_split($line) as $char){
- $vector = new Vector3($x - floor(self::$width / 2) + $offsetX, $y + $layerCount, $z - floor(self::$width / 2) + $offsetZ);
- switch($char){
- case "S":
- $level->setBlockRaw($vector, new SandStoneBlock());
- break;
- case "s":
- $level->setBlockRaw($vector, new SlabBlock(1));
- break;
- case "W":
- $level->setBlockRaw($vector, new WaterBlock());
- break;
- case " ":
- $block = $level->getBlock($vector)->getID();
- if($block === AIR){
- break;
- }
- $level->setBlockRaw($vector, new AirBlock());
- break;
- }
- ++$offsetX;
- }
- ++$offsetZ;
- $offsetX = 0;
- }
- $offsetZ = 0;
- }
- }
-}
\ No newline at end of file
diff --git a/src/structure/MonsterRoomStructure.php b/src/structure/MonsterRoomStructure.php
deleted file mode 100644
index 7bdf5347..00000000
--- a/src/structure/MonsterRoomStructure.php
+++ /dev/null
@@ -1,89 +0,0 @@
- [], 0 => [], 1 => [], 2 => [], 3 => [], 4 => []];
- return mt_rand(0, 1) === 1 ? self::$width = 7 : self::$width = 9;
- }
-
- public static function generateFloor(){
- for($i = 0; $i < self::$width; $i++){
- $line = "";
- for($j = 0; $j < self::$width; $j++){
- $line .= Utils::chance(75) ? "M" : "C";
- }
- array_push(self::$structure[-1], $line);
- }
- }
-
- public static function generateWalls(){
- for($wallsLevel = 0; $wallsLevel < 5; $wallsLevel++){
- for($i = 0; $i < self::$width; $i++){
- $line = "";
- if($i == 0 or ($i == self::$width - 1)){
- $line = str_repeat("C", self::$width);
- }
- else{
- $line = self::$width == 7 ? "C C" : "C C";
- }
- array_push(self::$structure[$wallsLevel], $line);
- }
- }
- }
-
- public static function generateChests($level, $x, $y, $z){
- $level->setBlockRaw(new Vector3($x - floor(self::$width / 3), $y, $z), new ChestBlock());
- $level->setBlockRaw(new Vector3($x, $y, $z - floor(self::$width / 3)), new ChestBlock());
- }
-
- /*public static function getSpawnerMob(){
- $rand = Utils::randomFloat();
- if($rand <= 0.5) return MOB_ZOMBIE;
- elseif($rand <= 0.75) return MOB_SKELETON;
- else return MOB_SPIDER;
- }*/
-
- public static function buildStructure($level, $x, $y, $z){ /*use CENTER positions*/
- self::getWidth();
- self::generateFloor();
- self::generateWalls();
- $offsetX = 0;
- $offsetZ = 0;
- foreach(self::$structure as $layerCount => $layer){
- foreach($layer as $line){
- $line = rtrim($line); //remove useless spaces(only from right)
- foreach(str_split($line) as $char){
- $vector = new Vector3($x - floor(self::$width / 2) + $offsetX, $y + $layerCount, $z - floor(self::$width / 2) + $offsetZ);
- switch($char){
- case "C":
- $level->setBlockRaw($vector, new CobblestoneBlock());
- break;
- case "M":
- $level->setBlockRaw($vector, new MossStoneBlock());
- break;
- case " ":
- $block = $level->getBlock($vector)->getID();
- if($block === AIR){
- break;
- }
- $level->setBlockRaw($vector, new AirBlock());
- break;
- }
- ++$offsetX;
- }
- ++$offsetZ;
- $offsetX = 0;
- }
- $offsetZ = 0;
- }
- $level->setBlockRaw(new Vector3($x, $y, $z), new MonsterSpawnerBlock());
- self::generateChests($level, $x, $y, $z);
- }
-
- public static $possibleLoot = [
- "bone", "gunpowder", "string", "wheat", "bread"/*, "saddle"*/, "coal", "redstone_dust", "beetroot_seeds", "melon_seeds", "pumpkin_seeds", "iron_ingot", "bucket", "gold_ingot"
- ];
-}
\ No newline at end of file
diff --git a/src/structure/NetherReactorStructure.php b/src/structure/NetherReactorStructure.php
deleted file mode 100644
index c74e1886..00000000
--- a/src/structure/NetherReactorStructure.php
+++ /dev/null
@@ -1,622 +0,0 @@
- [
- "NNNNNNNNNNNNNNNNN",
- "NNNNNNNNNNNNNNNNN",
- "NNNNNNNNNNNNNNNNN",
- "NNNNNNNNNNNNNNNNN",
- "NNNNNNNNNNNNNNNNN",
- "NNNNNNNNNNNNNNNNN",
- "NNNNNNNNNNNNNNNNN",
- "NNNNNNNNNNNNNNNNN",
- "NNNNNNNNNNNNNNNNN",
- "NNNNNNNNNNNNNNNNN",
- "NNNNNNNNNNNNNNNNN",
- "NNNNNNNNNNNNNNNNN",
- "NNNNNNNNNNNNNNNNN",
- "NNNNNNNNNNNNNNNNN",
- "NNNNNNNNNNNNNNNNN",
- "NNNNNNNNNNNNNNNNN",
- "NNNNNNNNNNNNNNNNN"
- ],
- -1 => [
- "NNNNNNNNNNNNNNNNN",
- "NNNNNNNNNNNNNNNNN",
- "NNNNNNNNNNNNNNNNN",
- "NNNNNNNNNNNNNNNNN",
- "NNNNNNNNNNNNNNNNN",
- "NNNNNNNNNNNNNNNNN",
- "NNNNNNNNNNNNNNNNN",
- "NNNNNNNNNNNNNNNNN",
- "NNNNNNNNNNNNNNNNN",
- "NNNNNNNNNNNNNNNNN",
- "NNNNNNNNNNNNNNNNN",
- "NNNNNNNNNNNNNNNNN",
- "NNNNNNNNNNNNNNNNN",
- "NNNNNNNNNNNNNNNNN",
- "NNNNNNNNNNNNNNNNN",
- "NNNNNNNNNNNNNNNNN",
- "NNNNNNNNNNNNNNNNN"
- ],
- 0 => [
- "NNNNNNNNNNNNNNNNN",
- "N N",
- "N N",
- "N N",
- "N N",
- "N N",
- "N N",
- "N ___ N",
- "N ___ N",
- "N ___ N",
- "N N",
- "N N",
- "N N",
- "N N",
- "N N",
- "N N",
- "NNNNNNNNNNNNNNNNN"
- ],
- 1 => [
- "NNNNNNNNNNNNNNNNN",
- "N N",
- "N N",
- "N N",
- "N N",
- "N N",
- "N N",
- "N ___ N",
- "N ___ N",
- "N ___ N",
- "N N",
- "N N",
- "N N",
- "N N",
- "N N",
- "N N",
- "NNNNNNNNNNNNNNNNN"
- ],
- 2 => [
- "NNNNNNNNNNNNNNNNN",
- "N N",
- "N N",
- "N N",
- "N N",
- "N N",
- "N N",
- "N N",
- "N ___ N",
- "N ___ N",
- "N ___ N",
- "N N",
- "N N",
- "N N",
- "N N",
- "N N",
- "NNNNNNNNNNNNNNNNN"
- ],
- 3 => [
- "NNNNNNNNNNNNNNNNN",
- "N N",
- "N N",
- "N N",
- "N N",
- "N N",
- "N N",
- "N N",
- "N N",
- "N N",
- "N N",
- "N N",
- "N N",
- "N N",
- "N N",
- "N N",
- "NNNNNNNNNNNNNNNNN"
- ],
- 4 => [
- "NNNNNNNNNNNNNNNNN",
- "NNNNNNNNNNNNNNNNN",
- "NNNNNNNNNNNNNNNNN",
- "NNNNNNNNNNNNNNNNN",
- "NNNNNNNNNNNNNNNNN",
- "NNNNNNNNNNNNNNNNN",
- "NNNNNNNNNNNNNNNNN",
- "NNNNNNNNNNNNNNNNN",
- "NNNNNNNNNNNNNNNNN",
- "NNNNNNNNNNNNNNNNN",
- "NNNNNNNNNNNNNNNNN",
- "NNNNNNNNNNNNNNNNN",
- "NNNNNNNNNNNNNNNNN",
- "NNNNNNNNNNNNNNNNN",
- "NNNNNNNNNNNNNNNNN",
- "NNNNNNNNNNNNNNNNN",
- "NNNNNNNNNNNNNNNNN"
- ],
- 5 => [
- "NNNNNNNNNNNNNNNNN",
- "N N",
- "N N",
- "N N",
- "N N",
- "N N",
- "N N",
- "N N",
- "N N",
- "N N",
- "N N",
- "N N",
- "N N",
- "N N",
- "N N",
- "N N",
- "NNNNNNNNNNNNNNNNN"
- ],
- 6 => [
- "NNNNNNNNNNNNNNNNN",
- "N N",
- "N N",
- "N NNNNNNNNNNN N",
- "N N N N",
- "N N N N",
- "N N N N",
- "N N N N",
- "N N N N",
- "N N N N",
- "N N N N",
- "N N N N",
- "N N N N",
- "N NNNNNNNNNNN N",
- "N N",
- "N N",
- "NNNNNNNNNNNNNNNNN",
- ],
- 7 => [ //spaces are required
- "NNNNNNNNNNNNNNNNN",
- "N N",
- "N N",
- "N NNNNNNNNNNN N",
- "N N N N",
- "N N N N",
- "N N N N",
- "N N N N",
- "N N N N",
- "N N N N",
- "N N N N",
- "N N N N",
- "N N N N",
- "N NNNNNNNNNNN N",
- "N NN",
- "N NNN",
- "NNNNNNNNNNNNNNNN ",
- ],
- 8 => [
- "NNNNNNNNNNNNNNNNN",
- "N N",
- "N N",
- "N NNNNNNNNNNN N",
- "N N N N",
- "N N N N",
- "N N N N",
- "N N N N",
- "N N N N",
- "N N N N",
- "N N N N",
- "N N N N",
- "N N N NN",
- "N NNNNNNNNNNNNNN",
- "N NNN ",
- "N NNN ",
- "NNNNNNNNNNNNNN ",
- ],
- 9 => [
- "NNNNNNNNNNNNNNNNN",
- "N N",
- "N N",
- "N NNNNNNNNNNN N",
- "N N N N",
- "N N N N",
- "N N N N",
- "N N N N",
- "N N N N",
- "N N N N",
- "N N N NN",
- "N N NNNN",
- "N N NNN ",
- "N NNNNNNNNNNNN ",
- "N NNN ",
- "N NNN ",
- "NNNNNNNNNNNN ",
- ],
- 10 => [
- "NNNNNNNNNNNNNNNNN",
- "N N",
- "N N",
- "N NNNNNNNNNNN N",
- "N N N N",
- "N N N N",
- "N N N N",
- "N N N N",
- "N N N NN",
- "N N NNNN",
- "N N NNN ",
- "N N NNN ",
- "N N NNN ",
- "N NNNNNNNNNNN ",
- "N NNN ",
- "N NNN ",
- "NNNNNNNNNN ",
- ],
- 11 => [
- "NNNNNNNNNNNNNNNNN",
- "N N",
- "N N",
- "N NNNNNNNNNNN N",
- "N N N N",
- "N N N N",
- "N N N NN",
- "N N NNNN",
- "N N NNN ",
- "N N NNN ",
- "N N NNN ",
- "N N NNNN ",
- "N N NNN N ",
- "N NNNNNNNNNNN ",
- "N NNN ",
- "N NNN ",
- "NNNNNNNN ",
- ],
- 12 => [
- "NNNNNNNNNNNNNNNNN",
- "N N",
- "N N",
- "N NNNNNNNNNNN N",
- "N N N NN",
- "N N NNNNNNN NNNN",
- "N N N N NNN ",
- "N N N NNNN ",
- "N N N NNN ",
- "N N N NNNN ",
- "N N N NNN N ",
- "N N NNNNNNN N ",
- "N N NNN N ",
- "N NNNNNNNNNNN ",
- "N NNN ",
- "N NNN ",
- "NNNNNN ",
- ],
- 13 => [
- "NNNNNNNNNNNNNNNNN",
- "N N",
- "N NN",
- "N NNNNNNNNNNNNNN",
- "N N NNN ",
- "N N NNNNNNNNNN ",
- "N N N NNN ",
- "N N N NNNN ",
- "N N N NNN N ",
- "N N N NNNN N ",
- "N N N NNN N N ",
- "N N NNNNNNN N ",
- "N N NNN N ",
- "N NNNNNNNNNNN ",
- "N NNN ",
- "N NNN ",
- "NNNN ",
- ],
- 14 => [
- "NNNNNNNNNNNNNNNNN",
- "N NNN",
- "N NNN ",
- "N NNNNNNNNNNNN ",
- "N NN NNN ",
- "N N NNNNNNNNN ",
- "N N N NNN N ",
- "N N N NNNN N ",
- "N N N NNN N N ",
- "N N NNNN N N ",
- "N N NNN N N ",
- "N NNNNNNNNN N ",
- "N NNN N ",
- "N NNNNNNNNNNNN ",
- "NNNN ",
- "NNN ",
- "NN ",
- ],
- 15 => [
- "NNNNNNNNNNNNNNNN ",
- "N NNN ",
- "N NNN ",
- "N NNNNNNNNN ",
- "N NNN NNN N ",
- "N NNNNNNNNN N ",
- "N NNN NNN N N ",
- "N N NNNN N N ",
- "N N NNN N N ",
- "N NNNN N N ",
- "N NNN N N ",
- "N NNNNNNNNNN N ",
- "NNNN N ",
- "NNNNNNNNNNNNNN ",
- "NN ",
- "N ",
- ],
- 16 => [
- "NNNNNNNNNNNNNN ",
- "N NNN ",
- "N NNN ",
- "N NNNNNNN ",
- "N NNNN N ",
- "N NNNNNNN N ",
- "N NNNN N N ",
- "N NNNN N N ",
- "N NNN N N ",
- "N NNNN N N ",
- "NNNN N N N ",
- "NNNN NNNNNNN N ",
- "NN N N ",
- "N NNNNNNNNNNN ",
- ],
- 17 => [
- "NNNNNNNNNNNN ",
- "N NNN ",
- "N NNN ",
- "N NNNNNNNN ",
- "N NNNNNN N ",
- "N NNNNNNNN N ",
- "N NNNNNN N N ",
- "N NNNNNN N N ",
- "NNNNNNN N N ",
- "NNNNNN N N ",
- "NN NNN N N ",
- "N N NNNNNNN N ",
- " N N ",
- " NNNNNNNNNNN ",
- ],
- 18 => [
- "NNNNNNNNNN ",
- "N NNN ",
- "N NNN ",
- "N NNN NNN ",
- "N NNN NNNN ",
- "N NNNNNNNNNN N ",
- "NNNN N NNNN N ",
- "NNN N NNN N N ",
- "NN NNNN N N ",
- "N NNN N N ",
- " NNN N N ",
- " NNNNNNNNN N ",
- " NN N ",
- " NNNNNNNNNNN ",
- ],
- 19 => [
- "NNNNNNNN ",
- "N NNN ",
- "N NNN ",
- "N NNN N ",
- "NNNN NN ",
- "NNN NNNNNNNNN ",
- "NN N NNNN ",
- "N N NNN N ",
- " N NNNN N ",
- " N NNN N N ",
- " NNNN N N ",
- " NNNNNNN N ",
- " NNN N ",
- " NNNNNNNNNNN ",
- ],
- 20 => [
- "NNNNNN ",
- "N NNN ",
- "NNNN ",
- "NNN ",
- "NN ",
- "N NNNNNNN N ",
- " N NNN ",
- " N NNN ",
- " N NNNN ",
- " N NNN N ",
- " N NNNN N ",
- " NNNNNNN N ",
- " NNN N ",
- " NNNNNNNNN ",
- ],
- 21 => [
- "NNNN ",
- "NNN ",
- "NN ",
- "N ",
- "", //nothing is here =D
- " NNNNNNN ",
- " N N ",
- " N N N ",
- " N NNN ",
- " N NNN ",
- " N NNNN ",
- " NNNNNNN N ",
- " NNN N ",
- " NNNNNNN ",
- ],
- 22 => [
- "NN ",
- "N ",
- "",
- "",
- "",
- " NNNNNNN ",
- " N N ",
- " N N ",
- " N N ",
- " N N N ",
- " N NNN ",
- " NNNNNNNNN ",
- " NNNN ",
- " NNNNN ",
- ],
- 23 => [
- "",
- "",
- "",
- "",
- "",
- " NNNNNNN ",
- " N N ",
- " N N ",
- " N N ",
- " N N ",
- " N N ",
- " NNNNNNN N ",
- " NN ",
- " NNN ",
- ],
- 24 => [
- "",
- "",
- "",
- "",
- "",
- " NNNNNNN ",
- " N N ",
- " N N ",
- " N N ",
- " N N ",
- " N N ",
- " NNNNNNN ",
- ],
- 25 => [
- "",
- "",
- "",
- "",
- "",
- " NNNNNNN ",
- " N N ",
- " N N ",
- " N N ",
- " N N ",
- " N N ",
- " NNNNNNN ",
- ],
- 26 => [
- "",
- "",
- "",
- "",
- "",
- " NNNNNNN ",
- " N N ",
- " N N ",
- " N N ",
- " N N ",
- " N N ",
- " NNNNNNN ",
- ],
- 27 => [
- "",
- "",
- "",
- "",
- "",
- " NNNNNNN ",
- " N N ",
- " N N ",
- " N N ",
- " N NN ",
- " N NNN ",
- " NNNNNN ",
- ],
- 28 => [
- "",
- "",
- "",
- "",
- "",
- " NNNNNNN ",
- " N N ",
- " N NN ",
- " N NNN ",
- " N NNN ",
- " N NNN ",
- " NNNN ",
- ],
- 29 => [
- "",
- "",
- "",
- "",
- "",
- " NNNNNNN ",
- " N NNN ",
- " N NNN ",
- " N NNN ",
- " NNNN ",
- " NNN ",
- " NN ",
- ],
- 30 => [
- "",
- "",
- "",
- "",
- "",
- " NNNNNN ",
- " N NNN ",
- " NNNN ",
- " NNN ",
- " NN ",
- " N ",
- ],
- 31 => [
- "",
- "",
- "",
- "",
- "",
- " NNNN ",
- " NNN ",
- " NN ",
- " N ",
- ],
- 32 => [
- "",
- "",
- "",
- "",
- "",
- " NN ",
- " N ",
- ],
- ];
-
- public static function buildReactor($level, $x, $y, $z){ /*use CENTER positions*/
- $offsetX = 0;
- $offsetZ = 0;
- foreach(NetherReactorStructure::$structure as $layerCount => $layer){
- foreach($layer as $line){
- $line = rtrim($line); //remove useless spaces(only from right)
- foreach(str_split($line) as $char){
- switch($char){
- case "N": //Netherrack
- $level->setBlockRaw(new Vector3($x - 8 + $offsetX, $y + $layerCount, $z - 8 + $offsetZ), new NetherrackBlock());
- break;
- case " ":
- $block = $level->getBlock(new Vector3($x - 8 + $offsetX, $y + $layerCount, $z - 8 + $offsetZ))->getID();
- if($block == 0){
- break;
- }
- $level->setBlockRaw(new Vector3($x - 8 + $offsetX, $y + $layerCount, $z - 8 + $offsetZ), new AirBlock());
- break;
- }
- ++$offsetX;
- }
- ++$offsetZ;
- $offsetX = 0;
- }
- $offsetZ = 0;
- }
- }
-}
\ No newline at end of file
diff --git a/src/structure/Structure.php b/src/structure/Structure.php
deleted file mode 100644
index 6ad313a8..00000000
--- a/src/structure/Structure.php
+++ /dev/null
@@ -1,130 +0,0 @@
-x+
-|
-|z+
-*/
-abstract class Structure{
- const MAP_NO_KEY = -127;
- const DEG_90 = 0;
- const DEG_180 = 1;
- const DEG_240 = 2;
-
- protected $structure;
- protected $map;
- public $width, $length;
- public $name;
-
- public function __construct(){
- foreach($this->structure as &$s){
- foreach($s as &$e){
- if(strlen($e) < $this->width){
- $e .= str_repeat(" ", $this->width - strlen($e));
- }
- }
- }
- }
-
- protected function getMappingFor($char){
- return $this->map[$char] ?? self::MAP_NO_KEY;
- }
-
- protected function placeBlock(Level $level, $char, $vector){
- if($char === "" || (($mk = $this->getMappingFor($char)) === self::MAP_NO_KEY)) return;
- $id = is_array($mk) ? $mk[0] : $mk;
- $meta = is_array($mk) ? $mk[1] : 0;
- return $level->setBlockRaw($vector, BlockAPI::get($id, $meta));
- }
-
- protected function init(){}
-
- protected function getFinalStructure(Level $level, $x, $y, $z){
- return $this->structure;
- }
-
- public function rotate($rotationLevel = self::DEG_90, $level = null, $x = 0, $y = 0, $z = 0){
- $str = $level instanceof Level ? $this->getFinalStructure($level, $x, $y, $z) : $this->structure;
- var_dump($str);
- switch($rotationLevel){
- case self::DEG_90:
- $l = $this->width;
- $this->width = $this->length;
- $this->length = $l;
-
- foreach($str as &$arr){
- foreach($arr as &$e){
- $e = str_split($e);
- }
- $new = [];
- for($i = 0; $i < $this->length; ++$i){
- $new[] = implode("", array_reverse(array_column($arr, $i)));
- }
- $arr = $new;
- }
- break;
- case self::DEG_180:
- foreach($str as &$lay){
- $keys = array_keys($lay);
- $ak = count($keys)-1;
- $lay = array_reverse($lay, true);
- foreach($lay as $k => $v){
- unset($lay[$k]);
- $lay[$keys[$ak--]] = strrev($v);
- }
- }
- break;
- case self::DEG_240:
- $l = $this->width;
- $this->width = $this->length;
- $this->length = $l;
- foreach($str as &$arr){
- foreach($arr as &$e){
- $e = str_split(strrev($e));
- }
- $new = [];
- for($i = 0; $i < $this->length; ++$i){
- $new[] = implode("", array_column($arr, $i));
- }
- $arr = $new;
- }
-
- break; //TODO fix
- default:
- ConsoleAPI::warn(self::class." tried to rotate to invalid state($rotationLevel)");
- return $this;
- }
- //var_dump($str);
- $s = (clone $this);
- return $s->setStructure($str, $this->width, $this->length);
- }
-
- private function setStructure($struct, $width, $length){
- $this->structure = $struct;
- $this->width = $width;
- $this->length = $length;
- ConsoleAPI::debug("Modifed");
- return $this;
- }
-
- public function build(Level $level, $centerX, $centerY, $centerZ){
- $offsetX = $offsetZ = 0;
- $centWidth = floor($this->width / 2);
- $centLength = floor($this->length / 2);
- foreach($this->getFinalStructure($level, $centerX, $centerY, $centerZ) as $offsetY => $blocksXZ){
- foreach($blocksXZ as $blocks){
- $blocks = rtrim($blocks);
- foreach(str_split($blocks) as $block){
- if($centerY + $offsetY == 128) return false;
- $this->placeBlock($level, $block, new Vector3($centerX - $centWidth + $offsetX, $centerY + $offsetY, $centerZ - $centLength + $offsetZ));
- ++$offsetX;
- }
- ++$offsetZ;
- $offsetX = 0;
- }
- $offsetZ = 0;
- }
- console("builded! ".$this->name);
- }
-
-}
\ No newline at end of file
diff --git a/src/structure/Structures.php b/src/structure/Structures.php
deleted file mode 100644
index 58f78872..00000000
--- a/src/structure/Structures.php
+++ /dev/null
@@ -1,11 +0,0 @@
- [
- "SSSSSSSSSSSSSS",
- "SSSSSSSSSSSSSS",
- "SSSSSSSSSSSSSS",
- "SSSSSSSSSSSSSS",
- "SSSSSSSSSSSSSS",
- "SSSSSSSSSSSSSS",
- "SSSSSSSSSSSSSS",
- "SSSSSSSSSSSSSS",
- "SSSSSSSSSSSSSS",
- "SSSSSSSSSSSSSS",
- "SSSSSSSSSSSSSS",
- "SSSSSSSSSSSSSS",
- "SSSSSSSSSSSSSS",
- "SSSSSSSSSSSSSS",
- "SSSSSSSSSSSSSS",
- ],
- 0 => [
- "SSSSSSI ISSSSS",
- "SP L PS",
- "SB BS",
- "SB BB BB BB BS",
- "SB BS",
- "SP BB BB BB PS",
- "SB BS",
- "SB BB BB BB BS",
- "SB BS",
- "SP BB BB BB PS",
- "SB BS",
- "SB BB BB BB BS",
- "SB BS",
- "SP PS",
- "SSSSSSSSSSSSSS",
- ],
- 1 => [
- "SSSSSSI ISSSSS",
- "SP L PS",
- "SB BS",
- "SB BB BB BB BS",
- "SB BS",
- "SP BB BB BB PS",
- "SB BS",
- "SB BB BB BB BS",
- "SB BS",
- "SP BB BB BB PS",
- "SB BS",
- "SB BB BB BB BS",
- "SB BS",
- "SP PS",
- "SSSSSSSSSSSSSS",
- ],
- 2 => [
- "SSSSSSIIISSSSS",
- "SPT L PS",
- "SB BS",
- "SB BB BB BB BS",
- "SB BS",
- "SPTBB BB BB PS",
- "SB BS",
- "SB BB BB BB BS",
- "SB BS",
- "SPTBB BB BB PS",
- "SB BS",
- "SB BB BB BB BS",
- "SB BS",
- "SPT PS",
- "SSSSSSSSSSSSSS",
- ],
- 3 => [
- "SSSSSSIIISSSSS",
- "SP L PS",
- "SB BS",
- "SB BS",
- "SB BS",
- "SP PS",
- "SB BS",
- "SB BS",
- "SB BS",
- "SP PS",
- "SB BS",
- "SB BS",
- "SB BS",
- "SP PS",
- "SSSSSSSSSSSSSS",
- ],
- 4 => [
- "SSSSSSSSSSSSSS",
- "SPPPPPPPPPLPPS",
- "SPPPPPPPPPPPPS",
- "SPPP PPPPPS",
- "SPPP PPPPS",
- "SPPP PPPS",
- "SPPP PPPS",
- "SPPP PPPS",
- "SPPP PPPS",
- "SPPP PPPS",
- "SPPP PPPS",
- "SPPP PPPS",
- "SPPPPPPPPPPPPS",
- "SPPPPPPPPPPPPS",
- "SSSSSSSSSSSSSS",
- ],
- 5 =>[
- "SSSSSSSSSSSSSS",
- "SP L PS",
- "SB FFFFFF BS",
- "SB F FF BS",
- "SB F FF BS",
- "SP F F PS",
- "SB F F BS",
- "SB F F BS",
- "SB F F BS",
- "SP F F PS",
- "SB F F BS",
- "SB F F BS",
- "SB FFFFFFFF BS",
- "SP PS",
- "SSSSSSSSSSSSSS",
- ],
- 6 => [
- "SSSSSSSSSSSSSS",
- "SP L PS",
- "SB BS",
- "SB BS",
- "SB BS",
- "SP PS",
- "SB FF BS",
- "SB FFFF BS",
- "SB FF BS",
- "SP PS",
- "SB BS",
- "SB BS",
- "SB BS",
- "SP PS",
- "SSSSSSSSSSSSSS",
- ],
- 7 => [
- "SSSSSSSSSSSSSS",
- "SP PS",
- "SB BS",
- "SB BS",
- "SB BS",
- "SP PS",
- "SB TT BS",
- "SB TFFT BS",
- "SB TT BS",
- "SP PS",
- "SB BS",
- "SB BS",
- "SB BS",
- "SP PS",
- "SSSSSSSSSSSSSS",
- ],
- 8 => [
- "SSSSSSSSSSSSSS",
- "SP PS",
- "SB BS",
- "SB BS",
- "SB BS",
- "SP PS",
- "SB BS",
- "SB FF BS",
- "SB BS",
- "SP PS",
- "SB BS",
- "SB BS",
- "SB BS",
- "SP PS",
- "SSSSSSSSSSSSSS",
- ],
- 9 => [
- "SSSSSSSSSSSSSS",
- "SSSSSSSSSSSSSS",
- "SSSSSSSSSSSSSS",
- "SSSSSSSSSSSSSS",
- "SSSSSSSSSSSSSS",
- "SSSSSSSSSSSSSS",
- "SSSSSSSSSSSSSS",
- "SSSSSSSSSSSSSS",
- "SSSSSSSSSSSSSS",
- "SSSSSSSSSSSSSS",
- "SSSSSSSSSSSSSS",
- "SSSSSSSSSSSSSS",
- "SSSSSSSSSSSSSS",
- "SSSSSSSSSSSSSS",
- "SSSSSSSSSSSSSS",
- ]
- ];
-
- public function replaceStoneBricks(){
- foreach(self::$structure as $layerInt => $layer){
- foreach($layer as $key => $str){
- $line = str_split($str);
- for($i = 0; $i < count($line); $i++){
- $str = $line[$i];
- if($str == "S"){
- if(Utils::chance(33)){
- $line[$i] = "S";
- }
- else{
- $line[$i] = Utils::chance(50) ? "M" : "C";
- }
- }
- }
- self::$tmpStructure[$layerInt][$key] = implode("", $line);
- }
- }
- }
-
- public function placeCobweb(){
- foreach(self::$tmpStructure as $layerInt => $layer){
- if($layerInt >= 0 and $layerInt <= 3){
- foreach($layer as $key => $str){
- $line = str_split($str);
- for($i = 0; $i < count($line); $i++){
- $str = $line[$i];
- if($str == " "){
- if(Utils::chance(5)){
- $line[$i] = "W";
- }
- else{
- $line[$i] = " ";
- }
- }
- }
- self::$tmpStructure[$layerInt][$key] = implode("", $line);
- }
- }
- }
- }
-
- public static function buildStructure($level, $x, $y, $z){ /*use CENTER positions*/
- self::replaceStoneBricks();
- self::placeCobweb();
-
- $offsetX = 0;
- $offsetZ = 0;
- foreach(self::$tmpStructure as $layerCount => $layer){
- foreach($layer as $line){
- $line = rtrim($line); //remove useless spaces(only from right)
- foreach(str_split($line) as $char){
- $vector = new Vector3($x - floor(self::$width / 2) + $offsetX, $y + $layerCount, $z + $offsetZ);
- switch($char){
- case "S":
- $level->setBlockRaw($vector, new StoneBricksBlock(0));
- break;
- case "M":
- $level->setBlockRaw($vector, new StoneBricksBlock(1));
- break;
- case "C":
- $level->setBlockRaw($vector, new StoneBricksBlock(2));
- break;
- case "B":
- $level->setBlockRaw($vector, new BookshelfBlock());
- break;
- case "W":
- $level->setBlockRaw($vector, new CobwebBlock());
- break;
- case "P":
- $level->setBlockRaw($vector, new PlanksBlock());
- break;
- case "T":
- if($layerCount == 2) $level->setBlockRaw($vector, new TorchBlock(1));
- else $level->setBlockRaw($vector, new TorchBlock(0));
- break;
- case "F":
- $level->setBlockRaw($vector, new FenceBlock());
- break;
- case "L":
- $level->setBlockRaw($vector, new LadderBlock(3));
- break;
- case "I":
- $level->setBlockRaw($vector, new IronBarsBlock());
- break;
- case " ":
- $block = $level->getBlock($vector)->getID();
- if($block === AIR){
- break;
- }
- $level->setBlockRaw($vector, new AirBlock());
- break;
- }
- ++$offsetX;
- }
- ++$offsetZ;
- $offsetX = 0;
- }
- $offsetZ = 0;
- }
- }
-}
\ No newline at end of file
diff --git a/src/structure/stronghold/StrongholdPortalRoomStructure.php b/src/structure/stronghold/StrongholdPortalRoomStructure.php
deleted file mode 100644
index b5e9775b..00000000
--- a/src/structure/stronghold/StrongholdPortalRoomStructure.php
+++ /dev/null
@@ -1,203 +0,0 @@
- [
- "SSSSSSSSSSS",
- "SSSSSSSSSSS",
- "SSSSSSSSSSS",
- "SSSSSSSSSSS",
- "SSSSSSSSSSS",
- "SSSSSSSSSSS",
- "SSSSSSSSSSS",
- "SSSSSSSSSSS",
- "SSSSSSSSSSS",
- "SSSSSSSSSSS",
- "SSSSSSSSSSS",
- "SSSSSSSSSSS",
- "SSSSSSSSSSS",
- "SSSSSSSSSSS",
- "SSSSSSSSSSS",
- "SSSSSSSSSSS",
- ],
- 0 => [
- "SSSSI ISSSS",
- "SLS SLS",
- "SLS SLS",
- "SLS SLS",
- "SSS sss SSS",
- "S SSS S",
- "S SSS S",
- "S SSS S",
- "S SSSSS S",
- "S SLLLS S",
- "S SLLLS S",
- "S SLLLS S",
- "S SSSSS S",
- "S S",
- "S S",
- "SSSSSSSSSSS",
- ],
- 1 => [
- "SSSSI ISSSS",
- "S S",
- "S S",
- "S S",
- "S S",
- "S sss S",
- "S SSS S",
- "S SSS S",
- "S S",
- "S S",
- "S S",
- "S S",
- "S S",
- "S S",
- "S S",
- "SSSSSSSSSSS",
- ],
- 2 => [
- "SSSSIIISSSS",
- "S S",
- "S S",
- "I I",
- "S S",
- "I I",
- "S sms S",
- "I SSS I",
- "S 000 S",
- "I 1 3 I",
- "S 1 3 S",
- "I 1 3 I",
- "S 222 S",
- "I I",
- "S S",
- "SSSSSSSSSSS",
- ],
- 3 => [
- "SSSSSSSSSSS",
- "S S",
- "S S",
- "I I",
- "S S",
- "I I",
- "S S",
- "I I",
- "S S",
- "I I",
- "S S",
- "I I",
- "S S",
- "I I",
- "S S",
- "SSSSSSSSSSS",
- ],
- 4 => [
- "SSSSSSSSSSS",
- "S S",
- "S S",
- "S S",
- "S S",
- "S S",
- "S S",
- "S S",
- "S S",
- "S S",
- "S S",
- "S S",
- "S S",
- "S S",
- "S S",
- "SSSSSSSSSSS",
- ],
- 5 => [
- "SSSSSSSSSSS",
- "SSSSSSSSSSS",
- "SSSSSSSSSSS",
- "SSSSSSSSSSS",
- "SSSSSSSSSSS",
- "SSSSSSSSSSS",
- "SSSSSSSSSSS",
- "SSSSSSSSSSS",
- "SSSSSSSSSSS",
- "SSSSSSSSSSS",
- "SSSSSSSSSSS",
- "SSSSSSSSSSS",
- "SSSSSSSSSSS",
- "SSSSSSSSSSS",
- "SSSSSSSSSSS",
- "SSSSSSSSSSS",
- ]
- ];
- protected $map = [
- "S" => "StoneBricksBlock",
- "M" => ["StoneBricksBlock", 1],
- "C" => ["StoneBricksBlock", 2],
- "I" => "IronBarsBlock",
- "L" => "LavaBlock",
- "s" => ["StoneBrickStairsBlock", 2],
- "m" => "MonsterSpawnerBlock",
- "0" => ["EndPortalFrameBlock", 0],
- "1" => ["EndPortalFrameBlock", 1],
- "2" => ["EndPortalFrameBlock", 2],
- "3" => ["EndPortalFrameBlock", 3],
- "4" => ["EndPortalFrameBlock", 4],
- "5" => ["EndPortalFrameBlock", 5],
- "6" => ["EndPortalFrameBlock", 6],
- "7" => ["EndPortalFrameBlock", 7],
- " " => "AirBlock",
- ];
-
- private function replaceStoneBricks(){
- foreach(self::$structure as $layerInt => $layer){
- foreach($layer as $key => $str){
- $line = str_split($str);
- for($i = 0; $i < count($line); $i++){
- $str = $line[$i];
- if($str == "S"){
- if(Utils::chance(33)){
- $line[$i] = "S";
- }
- else{
- $line[$i] = Utils::chance(50) ? "M" : "C";
- }
- }
- }
- self::$tmpStructure[$layerInt][$key] = implode("", $line);
- }
- }
- }
-
- private function placeEyes(){
- $lines = [
- "S 000 S",
- "I 1 3 I",
- "S 1 3 S",
- "I 1 3 I",
- "S 222 S",
- ];
- foreach($lines as $id => $str){
- $line = str_split($str);
- for($i = 0; $i < count($line); $i++){
- if(is_numeric($line[$i]) and Utils::chance(10)){
- $line[$i] = strval(intval($line[$i]) + 4);
- }
- }
- self::$tmpStructure[2][8 + $id] = implode("", $line);
- }
- }
-
- public function __construct(){
- parent::__construct($this->width, $this->length, $this->name, $this->map);
- }
-
- /*public function build($level, $x, $y, $z, $structure = 0){
- $this->replaceStoneBricks();
- $this->placeEyes();
-
- parent::build($level, $x, $y, $z, self::$tmpStructure);
- }*/ // TODO
-}
\ No newline at end of file
diff --git a/src/structure/tree/OakTreeStructure.php b/src/structure/tree/OakTreeStructure.php
deleted file mode 100644
index 01945249..00000000
--- a/src/structure/tree/OakTreeStructure.php
+++ /dev/null
@@ -1,154 +0,0 @@
- WOOD,
- //" " => 0,
- "D" => DIRT,
- "L" => LEAVES,
- "V" => [VINES, 2]
- ];
- protected $dead = false;
-
- protected function getType(){
- if(mt_rand(0, 1)){
- return 0; //normal oak
- }
- //return 1; //fallen oak
- //return 2; //fancy oak
- return 3; //balloon oak
- //return 4; //swamp oak
- }
-
- protected function makeFallen(){
-
- }
-
- protected function makeDead(){
- if(mt_rand(0, 1)){
- $this->dead = true;
- }
- }
-
- protected function createLog(){
- $this->trunk = mt_rand(3, 5);
- $layers = [];
- for($i = 0; $i < $this->trunk - 2; $i++){
- if($this->dead){
- $layers[$i] = [
- "",
- " V ",
- " VWV ",
- " V ",
- ];
- }
- else{
- $layers[$i] = [
- "",
- "",
- " W ",
- ];
- }
- }
- $this->structure = $layers;
- }
-
- protected function createLeaves(){
- $type = $this->getType();
- $layers = [];
- if($type == 0){
- $layers[$this->trunk - 2] = [
- "0LLL0",
- "LLLLL",
- "LLWLL",
- "LLLLL",
- "0LLL0",
- ];
- $layers[$this->trunk - 1] = [
- "0LLL0",
- "LLLLL",
- "LLWLL",
- "LLLLL",
- "0LLL0",
- ];
- $layers[$this->trunk] = [
- "",
- " 0L0 ",
- " LWL ",
- " 0L0 ",
- ];
- $layers[$this->trunk + 1] = [
- "",
- " L ",
- " LLL ",
- " L ",
- ];
- }
- elseif($type == 3){
- $layers[$this->trunk == 3 ? $this->trunk - 2 : $this->trunk - 3] = [
- "",
- " L ",
- " LWL ",
- " L ",
- ];
- if($this->trunk != 3){
- $layers[$this->trunk - 2] = [
- " LLL ",
- "LLLLL",
- "LLWLL",
- "LLLLL",
- " LLL ",
- ];
- }
- $layers[$this->trunk - 1] = [
- " LLL ",
- "LLLLL",
- "LLWLL",
- "LLLLL",
- " LLL ",
- ];
- $layers[$this->trunk] = [
- " LLL ",
- "LLLLL",
- "LLWLL",
- "LLLLL",
- " LLL ",
- ];
- $layers[$this->trunk + 1] = [
- "",
- " L ",
- " LLL ",
- " L ",
- ];
- }
-
- foreach($layers as $layerID => $arrays){
- foreach($arrays as $lineID => $str){
- $line = str_split($str);
- for($i = 0; $i < count($line); $i++){
- if(is_numeric($line[$i]) and Utils::chance(75)){
- $line[$i] = " ";
- }
- elseif(is_numeric($line[$i])){
- $line[$i] = "L";
- }
- }
- $this->structure[$layerID][$lineID] = implode("", $line);
- }
- }
- }
-
- protected function getFinalStructure(Level $level, $x, $y, $z){
- //$this->makeDead();
- $this->createLog();
- $this->createLeaves();
-
- return $this->structure;
- //return parent::getFinalStructure($level, $x, $y, $z);
- }
-}
\ No newline at end of file
diff --git a/src/structure/tree/TreeStructure.php b/src/structure/tree/TreeStructure.php
deleted file mode 100644
index 8277df8b..00000000
--- a/src/structure/tree/TreeStructure.php
+++ /dev/null
@@ -1,13 +0,0 @@
- [
- "WWWWWWW",
- "WFFwFFW",
- "WFFwFFW",
- "WFFwFFW",
- "WFFwFFW",
- "WFFwFFW",
- "WFFwFFW",
- "WFFwFFW",
- "WWWWWWW",
- ],
- 1 => [
- "",
- " RR RR ",
- " RR RR ",
- " RR RR ",
- " RR RR ",
- " RR RR ",
- " RR RR ",
- " RR RR ",
- "",
- ],
- ];
-
- protected $map = [
- "W" => WOOD,
- "F" => FARMLAND,
- "w" => WATER,
- " " => 0,
- "D" => DIRT
- ];
-
- protected function getFinalStructure(Level $level, $x, $y, $z){
- if(!$level->getBlockWithoutVector($x, $y - 1, $z)->isSolid){
- $structCopy = $this->structure;
- $structCopy[-1] = array_fill(0, $this->length, str_repeat("D", $this->width)); //TODO sand or clay, check for the whole row of water?
- return $structCopy;
- }
- return parent::getFinalStructure($level, $x, $y, $z);
- }
-
- protected function getMappingFor($char){
- if($char === "R"){
- $f = lcg_value();
-
- if($f <= 0.5){
- return [WHEAT_BLOCK, 0];
- }
- if($f <= 0.7){
- return [CARROT_BLOCK, 0];
- }
- if($f <= 0.9){
- return [POTATO_BLOCK, 0];
- }
- return [BEETROOT_BLOCK, 0];
- }
- return parent::getMappingFor($char);
- }
-}
\ No newline at end of file
diff --git a/src/structure/village/SmallHouseStructure.php b/src/structure/village/SmallHouseStructure.php
deleted file mode 100644
index 822af498..00000000
--- a/src/structure/village/SmallHouseStructure.php
+++ /dev/null
@@ -1,78 +0,0 @@
- [
- "CCCCC",
- "CCCCC",
- "CCCCC",
- "CCCCC",
- "CCCCC",
- ],
- 1 => [
- "CP PC",
- "P P",
- "P P",
- "P P",
- "CPPPC",
- ],
- 2 => [
- "CP PC",
- "P P",
- "G G",
- "P P",
- "CPPPC",
- ],
- 3 => [
- "CPPPC",
- "P P",
- "P P",
- "P P",
- "CPPPC",
- ],
- 4 => [
- "WWWWW",
- "WPPPW",
- "WPPPW",
- "WPPPW",
- "WWWWW",
- ],
- ];
- protected $map = [
- "C" => "CobbleStoneBlock",
- "P" => "PlanksBlock",
- "W" => "WoodBlock",
- "D" => "DirtBlock",
- "G" => "GlassPaneBlock",
- "L" => ["LadderBlock", 2],
- "F" => "FenceBlock",
- " " => "AirBlock"
- ];
-
- private function generateFence(){
- self::$tmpStructure = self::$structure;
- if(Utils::chance(50)){
- parent::setName($this->name." with Fence");
- self::$tmpStructure[1][3] = "P L P";
- self::$tmpStructure[2][3] = "P L P";
- self::$tmpStructure[3][3] = "P L P";
- self::$tmpStructure[4][3] = "WPLPW";
- self::$tmpStructure[5] = [
- "FFFFF",
- "F F",
- "F F",
- "F F",
- "FFFFF",
- ];
- }
- }
-
- /*public function build($level, $x, $y, $z, $structure = 0){
- $this->generateFence();
-
- parent::build($level, $x, $y, $z, self::$tmpStructure);
- }*/ //TODO
-}
\ No newline at end of file
diff --git a/src/structure/village/VillageLibraryStructure.php b/src/structure/village/VillageLibraryStructure.php
deleted file mode 100644
index edab3644..00000000
--- a/src/structure/village/VillageLibraryStructure.php
+++ /dev/null
@@ -1,125 +0,0 @@
- [
- " S ",
- "CCCCCCCCC",
- "CCCCCCCCC",
- "CCCCCCCCC",
- "CCCCCCCCC",
- "CCCCCCCCC",
- "CCCCCCCCC",
- "",
- ],
- 1 => [
- "",
- "CdCCCCCCC",
- "C TC",
- "C C",
- "C F F1C",
- "C 2222PC",
- "CCCCCCCCC",
- "",
- ],
- 2 => [
- "",
- "C8PPGGGPC",
- "P P",
- "G G",
- "G c c G",
- "P P",
- "CPGGPGGPC",
- "",
- ],
- 3 => [
- "",
- "CPPPGGGPC",
- "P P",
- "G G",
- "G G",
- "PBBBBBBBP",
- "CPPPPPPPC",
- "",
- ],
- 4 => [
- "",
- "CPPPPPPPC",
- "PPPPPPPPP",
- "P P",
- "P P",
- "PPPPPPPPP",
- "CPPPPPPPC",
- "",
- ],
- 5 => [
- "222222222",
- "CCCCCCCCC",
- "CCCCCCCCC",
- "CCCCCCCCC",
- "CCCCCCCCC",
- "CCCCCCCCC",
- "CCCCCCCCC",
- "333333333",
- ],
- 6 => [
- "",
- "222222222",
- "CCCCCCCCC",
- "CCCCCCCCC",
- "CCCCCCCCC",
- "CCCCCCCCC",
- "333333333",
- "",
- ],
- 7 => [
- "",
- "",
- "222222222",
- "CCCCCCCCC",
- "CCCCCCCCC",
- "333333333",
- "",
- "",
- ],
- 8 => [
- "",
- "",
- "",
- "222222222",
- "333333333",
- "",
- "",
- "",
- ]
- ];
- protected $map = [
- "S" => ["CobbleStoneStairsBlock", 2],
- "C" => "CobbleStoneBlock",
- "P" => "PlanksBlock",
- "W" => "WoodBlock",
- "d" => ["DoorBlock", 64, 0x01],
- "8" => ["DoorBlock", 64, 0x09],
- "G" => "GlassPaneBlock",
- "B" => "BookshelfBlock",
- "F" => "FenceBlock",
- "c" => ["CarpetBlock", 12],
- "1" => ["WoodStairsBlock", 1],
- "2" => ["WoodStairsBlock", 2],
- "3" => ["WoodStairsBlock", 3],
- "T" => "WorkbenchBlock",
- " " => "AirBlock"
- ];
-
- public function __construct(){
- parent::__construct();
- }
- /*
- public function build($level, $x, $y, $z, $structure = 0){
- parent::build($level, $x, $y, $z, self::$structure);
- }
- */
-}
\ No newline at end of file
diff --git a/src/structure/village/WoodHutStructure.php b/src/structure/village/WoodHutStructure.php
deleted file mode 100644
index b69d438d..00000000
--- a/src/structure/village/WoodHutStructure.php
+++ /dev/null
@@ -1,101 +0,0 @@
- [
- " S ",
- "CCCC",
- "CDDC",
- "CDDC",
- "CDDC",
- "CCCC",
- ],
- 1 => [
- "",
- "WdPW",
- "P P",
- "P P",
- "P P",
- "WPPW",
- ],
- 2 => [
- "",
- "W8PW",
- "P P",
- "G G",
- "P P",
- "WPPW",
- ],
- 3 => [
- "",
- "WPPW",
- "P P",
- "P P",
- "P P",
- "WPPW",
- ],
- ];
- protected $map = [
- "S" => ["CobbleStoneStairsBlock", 2],
- "C" => "CobbleStoneBlock",
- "P" => "PlanksBlock",
- "W" => "WoodBlock",
- "D" => "DirtBlock",
- "d" => ["DoorBlock", 64, 0x01],
- "8" => ["DoorBlock", 64, 0x09],
- "G" => "GlassPaneBlock",
- "F" => "FenceBlock",
- "c" => ["CarpetBlock", 12],
- " " => "AirBlock"
- ];
-
- public function generateRoof(){
- self::$tmpStructure = self::$structure;
- if(Utils::chance(50)){
- self::$tmpStructure[4] = [
- "",
- " WW ",
- "W W",
- "W W",
- "W W",
- " WW ",
- ];
- self::$tmpStructure[5] = [
- "",
- "",
- " WW ",
- " WW ",
- " WW ",
- "",
- ];
- }
- else{
- self::$tmpStructure[4] = [
- "",
- " WW ",
- "WWWW",
- "WWWW",
- "WWWW",
- " WW ",
- ];
- }
- }
-
- public function generateTable(){
- if(Utils::chance(66)){
- parent::setName($this->name." with Table");
- self::$tmpStructure[1][4] = "P FP";
- self::$tmpStructure[2][4] = "P cP";
- }
- }
-
- /*public function build($level, $x, $y, $z, $structure = 0){
- $this->generateRoof();
- $this->generateTable();
-
- parent::build($level, $x, $y, $z, self::$tmpStructure);
- }*/ //TODO
-}
\ No newline at end of file
diff --git a/src/tests/ServerSuiteTest.php b/src/tests/ServerSuiteTest.php
deleted file mode 100644
index e033c274..00000000
--- a/src/tests/ServerSuiteTest.php
+++ /dev/null
@@ -1,61 +0,0 @@
-load();
- testCase("event attached", is_integer($server->event("server.start", [$this, "hook"])), true);
- $server->init();
- }
-
- public function hook(){
- testCase("event fired", true, true);
- $server = ServerAPI::request();
- testCase("defaultgamemode", $server->getGamemode(), "survival");
-
-
- //Everything done!
- $server->close();
- }
-}
-/***REM_END***/
\ No newline at end of file
diff --git a/src/utils/AsyncMultipleQueue.php b/src/utils/AsyncMultipleQueue.php
deleted file mode 100644
index 688c531d..00000000
--- a/src/utils/AsyncMultipleQueue.php
+++ /dev/null
@@ -1,118 +0,0 @@
-input = "";
- $this->output = "";
- $this->stop = false;
- $this->start();
- }
-
- 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)){
- case ASYNC_CURL_GET:
- $url = $this->get(Utils::readShort($this->get(2), false));
- $timeout = Utils::readShort($this->get(2));
- $headers = $this->get(Utils::readShort($this->get(2), false));
- $res = (string) Utils::curl_get($url, $timeout, $headers);
- //$this->lock();
- $this->output .= Utils::writeInt($rID) . Utils::writeShort(ASYNC_CURL_GET) . 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);
- $d = [];
- for($c = 0; $c < $cnt; ++$c){
- $key = $this->get(Utils::readShort($this->get(2), false));
- $d[$key] = $this->get(Utils::readInt($this->get(4), false));
- }
- $res = (string) Utils::curl_post($url, $d, $timeout);
- //$this->lock();
- $this->output .= Utils::writeInt($rID) . Utils::writeShort(ASYNC_CURL_POST) . Utils::writeInt(strlen($res)) . $res;
- //$this->unlock();
- break;
- }
- }
- usleep(10000);
- }
- }
-
- private function get($len){
- $str = "";
- if($len <= 0){
- return $len;
- }
- $offset = 0;
- while(!isset($str[$len - 1])){
- if(isset($this->input[$offset])){
- $str .= $this->input[$offset];
- ++$offset;
- }
- }
- $this->input = (string) substr($this->input, $offset);
- return $str;
- }
-}
-
-class Async extends Thread{
-
- public function __construct($method, $params = []){
- $this->method = $method;
- $this->params = $params;
- $this->result = null;
- $this->joined = false;
- }
-
- public static function call($method, $params = []){
- $thread = new Async($method, $params);
- if($thread->start()){
- return $thread;
- }
- }
-
- public function run(){
- if(($this->result = call_user_func_array($this->method, $this->params))){
- return true;
- }else{
- return false;
- }
- }
-
- public function __toString(){
- if(!$this->joined){
- $this->joined = true;
- $this->join();
- }
-
- return $this->result;
- }
-}
-
-/*class StackableArray extends Stackable{
- public function __construct(){
- foreach(func_get_args() as $n => $value){
- if(is_array($value)){
- $this->{$n} = new StackableArray();
- call_user_func_array(array($this->{$n}, "__construct"), $value);
- }else{
- $this->{$n} = $value;
- }
- }
- }
-
- public function __destruct(){}
-
- public function run(){}
-}*/
diff --git a/src/utils/Cache.php b/src/utils/Cache.php
deleted file mode 100644
index 9091e6f5..00000000
--- a/src/utils/Cache.php
+++ /dev/null
@@ -1,36 +0,0 @@
- $data){
- if($data[1] < $time){
- unset(self::$cached[$index]);
- }
- }
- }
-}
\ No newline at end of file
diff --git a/src/utils/Config.php b/src/utils/Config.php
deleted file mode 100644
index 7c9db694..00000000
--- a/src/utils/Config.php
+++ /dev/null
@@ -1,346 +0,0 @@
- CONFIG_PROPERTIES,
- "cnf" => CONFIG_CNF,
- "conf" => CONFIG_CNF,
- "config" => CONFIG_CNF,
- "json" => CONFIG_JSON,
- "js" => CONFIG_JSON,
- "yml" => CONFIG_YAML,
- "yaml" => CONFIG_YAML,
- //"export" => CONFIG_EXPORT,
- //"xport" => CONFIG_EXPORT,
- "sl" => CONFIG_SERIALIZED,
- "serialize" => CONFIG_SERIALIZED,
- "txt" => CONFIG_LIST,
- "list" => CONFIG_LIST,
- ];
- /**
- * @var array
- */
- private $config;
- /**
- * @var string
- */
- private $file;
- /**
- * @var boolean
- */
- private $correct;
- /**
- * @var integer
- */
- private $type = CONFIG_DETECT;
-
- /**
- * @param string $file
- * @param int $type
- * @param array $default
- * @param null|boolean $correct
- */
- public function __construct($file, $type = CONFIG_DETECT, $default = [], &$correct = null){
- $this->load($file, $type, $default);
- $correct = $this->check();
- }
-
- /**
- * @param string $file
- * @param int $type
- * @param array $default
- *
- * @return boolean
- */
- public function load($file, $type = CONFIG_DETECT, $default = []){
- $this->correct = true;
- $this->type = (int) $type;
- $this->file = $file;
- if(!is_array($default)){
- $default = [];
- }
- if(!file_exists($file)){
- $this->config = $default;
- $this->save();
- }else{
- if($this->type === CONFIG_DETECT){
- $extension = explode(".", basename($this->file));
- $extension = strtolower(trim(array_pop($extension)));
- if(isset(Config::$formats[$extension])){
- $this->type = Config::$formats[$extension];
- }else{
- $this->correct = false;
- }
- }
- if($this->correct === true){
- $content = @file_get_contents($this->file);
- switch($this->type){
- case CONFIG_PROPERTIES:
- case CONFIG_CNF:
- $this->parseProperties($content);
- break;
- case CONFIG_JSON:
- $this->config = @json_decode($content, true);
- break;
- case CONFIG_YAML:
- $content = $this->fixYAMLIndexes($content);
- $this->config = yaml_parse($content);
- break;
- case CONFIG_SERIALIZED:
- $this->config = @unserialize($content);
- break;
- case CONFIG_LIST:
- $this->parseList($content);
- break;
- default:
- $this->correct = false;
- return false;
- break;
- }
- if(!is_array($this->config)){
- $this->config = $default;
- }
- if($this->fillDefaults($default, $this->config) > 0){
- $this->save();
- }
- }else{
- return false;
- }
- }
- return true;
- }
- /**
- * @return boolean
- */
- public function save(){
- if($this->correct === true){
- switch($this->type){
- case CONFIG_PROPERTIES:
- case CONFIG_CNF:
- $content = $this->writeProperties();
- break;
- case CONFIG_JSON:
- $content = json_encode($this->config, JSON_PRETTY_PRINT | JSON_BIGINT_AS_STRING);
- break;
- case CONFIG_YAML:
- $content = yaml_emit($this->config, YAML_UTF8_ENCODING);
- break;
- case CONFIG_SERIALIZED:
- $content = @serialize($this->config);
- break;
- case CONFIG_LIST:
- $content = implode("\r\n", array_keys($this->config));
- break;
- }
- @file_put_contents($this->file, $content, LOCK_EX);
- return true;
- }else{
- return false;
- }
- }
-
- /**
- * @return string
- */
- private function writeProperties(){
- $content = "#Properties Config file\r\n#" . date("D M j H:i:s T Y") . "\r\n";
- foreach($this->config as $k => $v){
- if(is_bool($v) === true){
- $v = $v === true ? "on" : "off";
- }elseif(is_array($v)){
- $v = implode(";", $v);
- }
- $content .= $k . "=" . $v . "\r\n";
- }
- return $content;
- }
-
- /**
- * @param $content
- */
- private function parseProperties($content){
- if(preg_match_all('/([a-zA-Z0-9\-_\.]*)=([^\r\n]*)/u', $content, $matches) > 0){ //false or 0 matches
- foreach($matches[1] as $i => $k){
- $v = trim($matches[2][$i]);
- switch(strtolower($v)){
- case "on":
- case "true":
- case "yes":
- $v = true;
- break;
- case "off":
- case "false":
- case "no":
- $v = false;
- break;
- }
- if(isset($this->config[$k])){
- console("[NOTICE] [Config] Repeated property " . $k . " on file " . $this->file, true, true, 2);
- }
- $this->config[$k] = $v;
- }
- }
- }
-
- public function fixYAMLIndexes($str){
- return preg_replace("#^([ ]*)([a-zA-Z_]{1}[^\:]*)\:#m", "$1\"$2\":", $str);
- }
-
- /**
- * @param $content
- */
- private function parseList($content){
- foreach(explode("\n", trim(str_replace("\r\n", "\n", $content))) as $v){
- $v = trim($v);
- if($v == ""){
- continue;
- }
- $this->config[$v] = true;
- }
- }
-
- /**
- * @param $default
- * @param $data
- *
- * @return integer
- */
- private function fillDefaults($default, &$data){
- $changed = 0;
- foreach($default as $k => $v){
- if(is_array($v)){
- if(!isset($data[$k]) or !is_array($data[$k])){
- $data[$k] = [];
- }
- $changed += $this->fillDefaults($v, $data[$k]);
- }elseif(!isset($data[$k])){
- $data[$k] = $v;
- ++$changed;
- }
- }
- return $changed;
- }
-
- /**
- * @return boolean
- */
- public function check(){
- return $this->correct === true;
- }
-
- public function reload(){
- unset($this->config);
- unset($this->correct);
- unset($this->type);
- $this->load($this->file);
- $correct = $this->check();
- }
-
- /**
- * @param $k
- *
- * @return boolean|mixed
- */
- public function &__get($k){
- return $this->get($k);
- }
-
- /**
- * @param $k
- * @param $v
- */
- public function __set($k, $v){
- $this->set($k, $v);
- }
-
- /**
- * @param $k
- *
- * @return boolean|mixed
- */
- public function &get($k){
- if(isset($this->correct) and ($this->correct === false or !isset($this->config[$k]))){
- $false = false;
- return $false;
- }
- return $this->config[$k];
- }
-
- /**
- * @param $k
- * @param bool $v
- */
- public function set($k, $v = true){
- $this->config[$k] = $v;
- }
-
- /**
- * @param $k
- *
- * @return boolean
- */
- public function __isset($k){
- return $this->exists($k);
- }
-
- /**
- * @param $k
- * @param bool $lowercase If set, searches Config in single-case / lowercase.
- *
- * @return boolean
- */
- public function exists($k, $lowercase = false){
- if($lowercase === true){
- $k = strtolower($k);//Convert requested key to lower
- $array = array_change_key_case($this->config, CASE_LOWER);//Change all keys in array to lower
- return isset($array[$k]);//Find $k in modified array
- }else{
- return isset($this->config[$k]);
- }
- }
-
- /**
- * @param $k
- */
- public function __unset($k){
- $this->remove($k);
- }
-
- /**
- * @param $k
- */
- public function remove($k){
- unset($this->config[$k]);
- }
-
- /**
- * @param array $v
- */
- public function setAll($v){
- $this->config = $v;
- }
-
- /**
- * @param bool $keys
- *
- * @return array
- */
- public function getAll($keys = false){
- return ($keys === true ? array_keys($this->config) : $this->config);
- }
-
-}
diff --git a/src/utils/Container.php b/src/utils/Container.php
deleted file mode 100644
index 0d22f2c0..00000000
--- a/src/utils/Container.php
+++ /dev/null
@@ -1,50 +0,0 @@
-payload = $payload;
- if(is_array($whitelist)){
- $this->whitelist = $whitelist;
- }
- if(is_array($blacklist)){
- $this->blacklist = $blacklist;
- }
- }
-
- public function get(){
- return $this->payload;
- }
-
- public function check($target){
- $w = true;
- $b = false;
- if($this->whitelist !== false){
- $w = false;
- if(in_array($target, $this->whitelist, true)){
- $w = true;
- }
- }else{
- $w = true;
- }
- if($this->blacklist !== false){
- $b = false;
- if(in_array($target, $this->blacklist, true)){
- $b = true;
- }
- }else{
- $b = false;
- }
- if($w === false or $b === true){
- return false;
- }
- return true;
- }
-
-
- public function __toString(){
- return $this->payload;
- }
-}
\ No newline at end of file
diff --git a/src/utils/Direction.php b/src/utils/Direction.php
deleted file mode 100644
index 3029d450..00000000
--- a/src/utils/Direction.php
+++ /dev/null
@@ -1,10 +0,0 @@
-x - $block->x)*($source->x - $block->x) + ($source->y - $block->y)*($source->y - $block->y) + ($source->z - $block->z)*($source->z - $block->z));
- $result = floor($source->getMaxLightValue() - $distance);
- return $result < 0 ? 0 : $result;
- }
-}
\ No newline at end of file
diff --git a/src/utils/MTRandom.php b/src/utils/MTRandom.php
deleted file mode 100644
index a3ceae43..00000000
--- a/src/utils/MTRandom.php
+++ /dev/null
@@ -1,83 +0,0 @@
-native = new \Random\Randomizer(new \Random\Engine\Mt19937($seed));
- }
- public function setSeed($seed){
- $this->native = new \Random\Randomizer(new \Random\Engine\Mt19937($seed));
- }
-
- public function genRandInt(){
- return $this->native->getInt(0, 0x7fffffff);
- }
-
- public function nextInt($bound = null){
- return $bound == null ? $this->native->nextInt() : $this->native->getInt(0, $bound - 1);
- }
-
- public function nextFloat(){
- return $this->native->getInt(0, 0x7fffffff) / 0x7fffffff;
- }
- }
-');
-}else{
-eval('
- class MTRandom
- {
- const MAG = [0, 0x9908b0df];
- public $mt;
- public $index = 0;
- public function __construct($seed = null){
- $this->setSeed($seed == null ? (int)microtime(1) : $seed);
- }
-
- public function setSeed($seed){
- $this->mt[0] = $seed & 0xffffffff;
- for($this->index = 1; $this->index < 624; ++$this->index){
- $this->mt[$this->index] = (0x6c078965 * ($this->mt[$this->index-1] >> 30 ^ $this->mt[$this->index - 1]) + $this->index) & 0xffffffff;
- }
- }
-
- public function genRandInt(){
- if($this->index >= 624 || $this->index < 0){
- if($this->index >= 625 || $this->index < 0) $this->setSeed(4357);
-
- for($kk = 0; $kk < 227; ++$kk){
- $y = ($this->mt[$kk] & 0x80000000) | ($this->mt[$kk + 1] & 0x7fffffff);
- $this->mt[$kk] = $this->mt[$kk+397] ^ ($y >> 1) ^ MTRandom::MAG[$y & 0x1];
- }
-
- for(;$kk < 623; ++$kk){
- $y = ($this->mt[$kk] & 0x80000000) | ($this->mt[$kk + 1] & 0x7fffffff);
- $this->mt[$kk] = $this->mt[$kk-227] ^ ($y >> 1) ^ MTRandom::MAG[$y & 0x1];
- }
-
- $y = ($this->mt[623] & 0x80000000) | ($this->mt[0] & 0x7fffffff);
- $this->mt[623] = $this->mt[396] ^ ($y >> 1) ^ MTRandom::MAG[$y & 0x1];
- $this->index = 0;
- }
-
- $y = $this->mt[$this->index++];
- $y ^= ($y >> 11);
- $y ^= ($y << 7) & 0x9d2c5680;
- $y ^= ($y << 15) & 0xefc60000;
- $y ^= ($y >> 18);
- return $y;
- }
-
- public function nextInt($bound = null){
- return $bound == null ? $this->genRandInt() >> 1 : $this->genRandInt() % $bound;
- }
-
- public function nextFloat(){
- return $this->genRandInt() / 0xffffffff;
- }
- }
-');
-}
-
-
diff --git a/src/utils/MersenneTwister.php b/src/utils/MersenneTwister.php
deleted file mode 100644
index 35742daa..00000000
--- a/src/utils/MersenneTwister.php
+++ /dev/null
@@ -1,490 +0,0 @@
-init_with_integer($seed == null ? ((int)microtime(1) & 0xffffffff) : $seed);
- }
-
- function init_with_integer($integer_seed){
- $this->mt[0] = $integer_seed;
- for($this->mti = 1; $this->mti < 624; ++$this->mti){
- $this->mt[$this->mti] = add_2(mul(1812433253, ($this->mt[$this->mti - 1] ^ (($this->mt[$this->mti - 1] >> 30) & 3))), $this->mti);
- }
- }
-
- function init_with_file($filename, $max_ints = -1){
- $this->init_with_files([$filename], $max_ints);
- }
-
- function init_with_files(array $filenames, $max_ints = -1){
- $limit_applies = $max_ints !== -1;
-
- if($limit_applies){
- $limit = $max_ints * 4; # 32 bits is 4 characters
- }
- $data = "";
-
- foreach($filenames as $filename){
- $contents =
- file_get_contents($filename, false, null, 0,
- $limit_applies ? $limit - strlen($data) : -1);
-
- if($contents === false){
- throw new Exception("problem reading from $filename");
- }else{
- $data .= $contents;
-
- if($limit_applies && strlen($data) == $limit){
- break;
- }
- }
- }
-
- $this->init_with_string($data);
- }
-
- function init_with_string($string){
- $remainder = strlen($string) % 4;
-
- if($remainder > 0){
- $string .= str_repeat("\0", 4 - $remainder);
- }
-
- $integer_array = array_values(unpack("N*", $string));
-
- $this->init_with_array($integer_array);
- }
-
- function init_with_array(array $integer_array){
- $integer_array =
- array_map("force_32_bit_int", $integer_array);
-
- $mt = &$this->mt;
-
- $key_length = count($integer_array);
-
- $this->init_with_integer(19650218);
- $i = 1;
- $j = 0;
- $k = (N > $key_length ? N : $key_length);
- for(; $k; $k--){
- $mt[$i] = add_3($mt[$i] ^
- mul_by_1664525($mt[$i - 1] ^ (($mt[$i - 1] >> 30) & 3)),
- $integer_array[$j], $j);
- /*
- mt[i] = (mt[i] ^ ((mt[i-1] ^ (mt[i-1] >> 30)) * 1664525UL))
- + init_key[j] + j;
- */
- $i++;
- $j++;
- if($i >= N){
- $mt[0] = $mt[N - 1];
- $i = 1;
- }
- if($j >= $key_length){
- $j = 0;
- }
- }
- for($k = N - 1; $k; $k--){
- $mt[$i] = sub($mt[$i] ^
- mul($mt[$i - 1] ^ (($mt[$i - 1] >> 30) & 3), 1566083941), $i);
- /*
- mt[i] = (mt[i] ^ ((mt[i-1] ^ (mt[i-1] >> 30)) * 1566083941UL))
- - i;
- */
- $i++;
- if($i >= N){
- $mt[0] = $mt[N - 1];
- $i = 1;
- }
- }
-
- $mt[0] = (1 << 31); /* MSB is 1; assuring non-zero initial array */
- }
-
- function int31(){
- return $this->int32() & MASK31;
- }
-
- function int32(){
- if($this->mti >= N){ /* generate N words all at once */
- for($kk = 0; $kk < N - M; ++$kk){
- $y = ($this->mt[$kk] & UPPER_MASK) | ($this->mt[$kk + 1] & LOWER_MASK);
- $this->mt[$kk] = $this->mt[$kk + M] ^ (($y >> 1) & MASK31) ^ self::$MAG_01[$y & 1];
- }
- for(; $kk < N - 1; ++$kk){
- $y = ($this->mt[$kk] & UPPER_MASK) | ($this->mt[$kk + 1] & LOWER_MASK);
- $this->mt[$kk] = $this->mt[$kk + (M - N)] ^ (($y >> 1) & MASK31) ^ self::$MAG_01[$y & 1];
- }
- $y = ($this->mt[N - 1] & UPPER_MASK) | ($this->mt[0] & LOWER_MASK);
- $this->mt[N - 1] = $this->mt[M - 1] ^ (($y >> 1) & MASK31) ^ self::$MAG_01[$y & 1];
-
- $this->mti = 0;
- }
-
- $y = $this->mt[$this->mti++];
-
- /* Tempering */
- $y ^= ($y >> 11) & MASK21;
- $y ^= ($y << 7) & ((0x9d2c << 16) | 0x5680);
- $y ^= ($y << 15) & (0xefc6 << 16);
- $y ^= ($y >> 18) & MASK14;
-
- return $y & 0xFFFFFFFF;
- }
-
- /* generates a random number on [0,1]-real-interval */
-
- function real_closed(){
- return signed2unsigned($this->int32()) * (1.0 / 4294967295.0);
- }
-
- /* generates a random number on [0,1)-real-interval */
-
- function rangeint($lower_bound, $upper_bound){
- $lower_bound = intval($lower_bound);
- $upper_bound = intval($upper_bound);
-
- if($this->bits32){
- $pow_2_32 = pow(2, 32);
-
- $size_of_range = $upper_bound - $lower_bound + 1;
-
- $remainder = fmod($pow_2_32, $size_of_range);
-
- if($remainder == 0){
- return $lower_bound +
- ($this->int32() & unsigned2signed($size_of_range - 1));
- }else{
- $start_of_partial_range = $pow_2_32 - $remainder;
- $start_as_int = unsigned2signed($start_of_partial_range);
- do{
- $rand = $this->int32();
- }while($rand >= $start_as_int && $rand < 0);
-
- $result = $lower_bound +
- fmod(signed2unsigned($rand), $size_of_range);
-
- return intval($result);
- }
- }else{
- if($lower_bound == -PHP_INT_MAX - 1 && $upper_bound == PHP_INT_MAX){
- return ($this->int32() << 32) & $this->int32();
- }else{
- $pow_2_32 = 1 << 32;
-
- $size_of_range = $upper_bound - $lower_bound + 1;
-
- if($size_of_range > $pow_2_32){
- $size_of_range >>= 32;
- $shift = 32;
- $low_bits = $this->int32();
- }else{
- $shift = 0;
- $low_bits = 0;
- }
-
- $remainder = $pow_2_32 % $size_of_range;
-
- if($remainder == 0){
- $high_bits = $this->int32() & ($size_of_range - 1);
- }else{
- $start_of_partial_range = $pow_2_32 - $remainder;
- do{
- $rand = $this->int32();
- }while($rand >= $start_of_partial_range);
-
- $high_bits = $rand % $size_of_range;
- }
-
- return $lower_bound + (($high_bits << $shift) | $low_bits);
- }
- }
- }
-
- /* generates a random number on (0,1)-real-interval */
-
- function rangereal_open($lower_bound, $upper_bound){
- do{
- $rand = $lower_bound +
- $this->real_open() * ($upper_bound - $lower_bound);
- }while($rand <= $lower_bound || $rand >= $upper_bound);
-
- return $rand;
- }
-
- /* generates a random number on [0,1) with 53-bit resolution */
-
- function real_open(){
- return (signed2unsigned($this->int32()) + .5) * (1.0 / 4294967296.0);
- }
-
- function rangereal_halfopen($lower_bound, $upper_bound){
- do{
- $rand = $lower_bound +
- $this->real_halfopen() * ($upper_bound - $lower_bound);
- }while($rand >= $upper_bound);
- /*
- $rand cannot go any lower than $lower_bound, because
- $this->real_halfopen() cannot go any lower than 0
- */
-
- return $rand;
- }
-
- /*
- in each of the next 3 functions, we loop until we have a number that
- meets the function's post-condition. this may be more work than
- is really necessary, but i am concerned about rounding errors.
-
- why no rangereal_closed? because, due to the aforementioned
- rounding errors, i am unable to guarantee that $upper_bound
- would be a possible return value of such a function.
- */
-
- function real_halfopen(){
- return signed2unsigned($this->int32()) * (1.0 / 4294967296.0);
- }
-
- function rangereal_halfopen2($lower_bound, $upper_bound){
- do{
- $rand = $lower_bound +
- $this->real_halfopen2() * ($upper_bound - $lower_bound);
- }while($rand >= $upper_bound);
-
- return $rand;
- }
-
- function real_halfopen2(){
- return ((($this->int32() & MASK27) * 67108864.0) +
- ($this->int32() & MASK26)) *
- (1.0 / 9007199254740992.0);
- }
- function nextIntBndn($bound){
- return ($this->int32() % $bound);
- }
- function nextInt($bound = null){
- return $bound == null ? ($this->int32() >> 1) : ($this->int32() % $bound);
- }
-
- function nextFloat(){
- return $this->int32() * 2.32830644e-10;
- }
-
- function setSeed($seed){
- $this->init_with_integer($seed);
- }
-
-}
-
-function signed2unsigned($signed_integer){
- ## assert(is_integer($signed_integer));
- ## assert(($signed_integer & ~MASK32) === 0);
-
- return $signed_integer >= 0 ? $signed_integer :
- TWO_TO_THE_32 + $signed_integer;
-}
-
-function unsigned2signed($unsigned_integer){
- ## assert($unsigned_integer >= 0);
- ## assert($unsigned_integer < pow(2, 32));
- ## assert(floor($unsigned_integer) === floatval($unsigned_integer));
-
- return intval($unsigned_integer < TWO_TO_THE_31 ? $unsigned_integer :
- $unsigned_integer - TWO_TO_THE_32);
-}
-
-function force_32_bit_int($x){
- /*
- it would be un-PHP-like to require is_integer($x),
- so we have to handle cases like this:
-
- $x === pow(2, 31)
- $x === strval(pow(2, 31))
-
- we are also opting to do something sensible (rather than dying)
- if the seed is outside the range of a 32-bit unsigned integer.
- */
-
- if(is_integer($x)){
- /*
- we mask in case we are on a 64-bit machine and at least one
- bit is set between position 32 and position 63.
- */
- return $x & MASK32;
- }else{
- $x = floatval($x);
-
- $x = $x < 0 ? ceil($x) : floor($x);
-
- $x = fmod($x, TWO_TO_THE_32);
-
- if($x < 0){
- $x += TWO_TO_THE_32;
- }
-
- return unsigned2signed($x);
- }
-}
-
-/*
- takes 2 integers, treats them as unsigned 32-bit integers,
- and adds them.
-
- it works by splitting each integer into
- 2 "half-integers", then adding the high and low half-integers
- separately.
-
- a slight complication is that the sum of the low half-integers
- may not fit into 16 bits; any "overspill" is added to the sum
- of the high half-integers.
- */
-function add_2($n1, $n2){
- $x = ($n1 & 0xffff) + ($n2 & 0xffff);
-
- return (((($n1 >> 16) & 0xffff) +
- (($n2 >> 16) & 0xffff) +
- ($x >> 16)) << 16) | ($x & 0xffff);
-}
-
-# takes 2 integers, treats them as unsigned 32-bit integers,
-# and adds them.
-#
-# for how it works, see the comment for add_2.
-#
-function add_3($n1, $n2, $n3){
- $x = ($n1 & 0xffff) + ($n2 & 0xffff) + ($n3 & 0xffff);
-
- return (((($n1 >> 16) & 0xffff) +
- (($n2 >> 16) & 0xffff) +
- (($n3 >> 16) & 0xffff) +
- ($x >> 16)) << 16) | ($x & 0xffff);
-}
-
-# takes 2 integers, treats them as unsigned 32-bit integers,
-# and subtracts the second from the first.
-#
-# the explanation of why this works is too long to be
-# included here, so it has been moved into the file why-sub-works.txt.
-#
-function sub($a, $b){
- return (($a & MASK31) - ($b & MASK31)) ^
- (($a ^ $b) & 0x80000000);
-}
-
-function mul($a, $b){
- /*
- a and b, considered as unsigned integers, can be expressed as follows:
-
- a = 2**16 * a1 + a2,
-
- b = 2**16 * b1 + b2,
-
- where
-
- 0 <= a2 < 2**16,
- 0 <= b2 < 2**16.
-
- given those 2 equations, what this function essentially does is to
- use the following identity:
-
- a * b = 2**32 * a1 * b1 + 2**16 * a1 * b2 + 2**16 * b1 * a2 + a2 * b2
-
- note that the first term, i.e. 2**32 * a1 * b1, is unnecessary here,
- so we don't compute it.
-
- we could make the following code clearer by using intermediate
- variables, but that would probably hurt performance.
- */
-
- return unsigned2signed(
- fmod(
- TWO_TO_THE_16 *
- /*
- the next line of code calculates a1 * b2,
- the line after that calculates b1 * a2,
- and the line after that calculates a2 * b2.
- */
- ((($a >> 16) & 0xffff) * ($b & 0xffff) +
- (($b >> 16) & 0xffff) * ($a & 0xffff)) +
- ($a & 0xffff) * ($b & 0xffff),
-
- TWO_TO_THE_32));
-}
-
-/*
- mul_by_1664525($x) should be more efficient than mul(1664525, $x).
- */
-function mul_by_1664525($n){
- return unsigned2signed(fmod(1664525 * ($n >= 0 ?
- $n : (TWO_TO_THE_32 + $n)), TWO_TO_THE_32));
-}
-
-function do_bc_op($bc_op, array $numbers){
- $modulus = pow(2, 32);
-
- $result =
- call_user_func_array($bc_op,
- array_map("signed2unsigned", $numbers));
-
- $result = bcmod($result, $modulus);
-
- return unsigned2signed(bccomp($result, 0) < 0 ?
- bcadd($result, $modulus) : $result);
-}
-
-function get_random_32bit_int(){
- return rand(0, 0xffff) | (rand(0, 0xffff) << 16);
-}
\ No newline at end of file
diff --git a/src/utils/NBT.php b/src/utils/NBT.php
deleted file mode 100644
index 1c3dfa51..00000000
--- a/src/utils/NBT.php
+++ /dev/null
@@ -1,195 +0,0 @@
-binary .= $bin;
- }
-
- public function load($str){
- $this->offset = 0;
- $this->binary = (string) $str;
- $this->parseTree($this->tree);
- }
-
- private function parseTree(&$node){
- while(($tag = ord($this->read(1))) !== self::TAG_END and !$this->feof()){
- $name = $this->readTAG_STRING();
- switch($tag){
- case self::TAG_BYTE:
- $value = $this->readTAG_BYTE();
- break;
- case self::TAG_SHORT:
- $value = $this->readTAG_SHORT();
- break;
- case self::TAG_INT:
- $value = $this->readTAG_INT();
- break;
- case self::TAG_LONG:
- $value = $this->readTAG_LONG();
- break;
- case self::TAG_FLOAT:
- $value = $this->readTAG_FLOAT();
- break;
- case self::TAG_DOUBLE:
- $value = $this->readTAG_DOUBLE();
- break;
- case self::TAG_BYTE_ARRAY:
- $value = $this->readTAG_BYTE_ARRAY();
- break;
- case self::TAG_STRING:
- $value = $this->readTAG_STRING();
- break;
- case self::TAG_LIST:
- $value = [];
- $this->parseList($value, ord($this->read(1)), Utils::readLInt($this->read(4)));
- break;
- case self::TAG_COMPOUND:
- $value = [];
- $this->parseTree($value);
- break;
- default:
- echo bin2hex(substr($this->binary, $this->offset - 1)) . PHP_EOL . PHP_EOL;
- die("Invalid NBT Tag $tag");
- break;
- }
- $node[$name] = $value;
- }
- }
-
- public function read($n){
- if($n <= 0){
- return "";
- }
- $this->offset += $n;
- return substr($this->binary, $this->offset - $n, $n);
- }
-
- private function feof(){
- return !isset($this->binary[$this->offset]);
- }
-
- public function readTAG_STRING(){
- return $this->read(Utils::readLShort($this->read(2), false));
- }
-
- public function readTAG_BYTE(){
- return Utils::readByte($this->read(1));
- }
-
- public function readTAG_SHORT(){
- return Utils::readLShort($this->read(2));
- }
-
- public function readTAG_INT(){
- return Utils::readLInt($this->read(4));
- }
-
- public function readTAG_LONG(){
- return Utils::readLLong($this->read(8));
- }
-
- public function readTAG_FLOAT(){
- return Utils::readLFloat($this->read(4));
- }
-
- public function readTAG_DOUBLE(){
- return Utils::readLDouble($this->read(8));
- }
-
- public function readTAG_BYTE_ARRAY(){
- return $this->read($this->readTAG_INT());
- }
-
- private function parseList(&$node, $tag, $cnt){
- for($i = 0; $i < $cnt and !$this->feof(); ++$i){
- switch($tag){
- case self::TAG_BYTE:
- $value = $this->readTAG_BYTE();
- break;
- case self::TAG_SHORT:
- $value = $this->readTAG_SHORT();
- break;
- case self::TAG_INT:
- $value = $this->readTAG_INT();
- break;
- case self::TAG_LONG:
- $value = $this->readTAG_LONG();
- break;
- case self::TAG_FLOAT:
- $value = $this->readTAG_FLOAT();
- break;
- case self::TAG_DOUBLE:
- $value = $this->readTAG_DOUBLE();
- break;
- case self::TAG_BYTE_ARRAY:
- $value = $this->readTAG_BYTE_ARRAY();
- break;
- case self::TAG_STRING:
- $value = $this->readTAG_STRING();
- break;
- case self::TAG_LIST:
- $value = [];
- $this->parseList($value, ord($this->read(1)), Utils::readLInt($this->read(4)));
- break;
- case self::TAG_COMPOUND:
- $value = [];
- $this->parseTree($value);
- break;
- default:
- echo bin2hex(substr($this->binary, $this->offset - 1)) . PHP_EOL . PHP_EOL;
- die("Invalid NBT Tag $tag");
- break;
- }
- $node[] = $value;
- }
- }
-
- public function writeTAG_BYTE($v){
- $this->binary .= chr($v);
- }
-
- public function writeTAG_LONG($v){
- $this->binary .= Utils::writeLLong($v);
- }
-
- public function writeTAG_FLOAT($v){
- $this->binary .= Utils::writeLFloar($v);
- }
-
- public function writeTAG_DOUBLE($v){
- $this->binary .= Utils::writeLDouble($v);
- }
-
- public function writeTAG_BYTE_ARRAY($v){
- $this->binary .= $this->writeTAG_INT(strlen($v)) . $v;
- }
-
- public function writeTAG_INT($v){
- $this->binary .= Utils::writeLInt($v);
- }
-
- public function writeTAG_STRING($v){
- $this->binary .= $this->writeTAG_SHORT(strlen($v)) . $v;
- }
-
- public function writeTAG_SHORT($v){
- $this->binary .= Utils::writeLShort($v);
- }
-}
\ No newline at end of file
diff --git a/src/utils/RailLogic.php b/src/utils/RailLogic.php
deleted file mode 100644
index 63c191f3..00000000
--- a/src/utils/RailLogic.php
+++ /dev/null
@@ -1,248 +0,0 @@
-getID();
- $meta = $rail->getMetadata();
- $this->level = $rail->level;
- $this->x = $rail->x;
- $this->y = $rail->y;
- $this->z = $rail->z;
- $this->isStraight = $id === POWERED_RAIL;
-
- $this->updateConnections($meta);
- }
- public function getRail($v){
- if(($b = $this->level->getBlock($v)) instanceof RailBaseBlock){
- return new RailLogic($b);
- }elseif(($b = $this->level->getBlockWithoutVector($v->x, $v->y + 1, $v->z)) instanceof RailBaseBlock){
- return new RailLogic($b);
- }elseif(($b = $this->level->getBlockWithoutVector($v->x, $v->y - 1, $v->z)) instanceof RailBaseBlock){
- return new RailLogic($b);
- }
-
- return null;
- }
-
- public function hasRail($x, $y, $z){
- return RailBaseBlock::isRailBlock($this->level, $x, $y, $z) || RailBaseBlock::isRailBlock($this->level, $x, $y + 1, $z) || RailBaseBlock::isRailBlock($this->level, $x, $y - 1, $z);
- }
-
- public function countPotentialConnections(){
- return $this->hasRail($this->x, $this->y, $this->z - 1) + $this->hasRail($this->x, $this->y, $this->z + 1) + $this->hasRail($this->x - 1, $this->y, $this->z) + $this->hasRail($this->x + 1, $this->y, $this->z);
- }
-
- public function removeSoftConnections(){
- for($ind = 0; $ind < count($this->railPositions); ++$ind){
- $logic = $this->getRail($this->railPositions[$ind]);
- if($logic != null && $this->connectsTo($logic)){
- $this->railPositions[$ind] = new Vector3($logic->x, $logic->y, $logic->z);
- }else{
- unset($this->railPositions[$ind--]); //TODO check?
- $this->railPositions = array_values($this->railPositions); //reindexing
- }
- }
- }
-
- public function connectsTo(RailLogic $logic){
- foreach($this->railPositions as $rpos){
- if(($rpos->x === $logic->x) && ($rpos->z === $logic->z)){
- return true;
- }
- }
- return false;
- }
-
- public function canConnectTo(RailLogic $rail){
- //return this.isRailChunkPositionCorrect(par1BlockBaseRailLogic) ? true : (this.railChunkPosition.size() == 2 ? false : (this.railChunkPosition.isEmpty() ? true : true));
- return $this->connectsTo($rail) ? true : (count($this->railPositions) == 2 ? false : (empty($this->railPositions) ? true : true));
- }
-
- public function hasNeighborRail($x, $y, $z){
- $logic = $this->getRail(new Vector3($x, $y, $z));
- if($logic === null){
- return false;
- }else{
- $logic->removeSoftConnections(); //i place $this here and was searching why isnt it working correctly for 2 hours
- return $logic->canConnectTo($this);
- }
-
- }
-
- public function place($b, $b1){
- $hasZneg = $this->hasNeighborRail($this->x, $this->y, $this->z - 1);
- $hasZpos = $this->hasNeighborRail($this->x, $this->y, $this->z + 1);
- $hasXneg = $this->hasNeighborRail($this->x - 1, $this->y, $this->z);
- $hasXpos = $this->hasNeighborRail($this->x + 1, $this->y, $this->z);
- $state = -1;
- if(($hasZneg || $hasZpos) && !($hasXneg && $hasXpos)){
- $state = 0;
- }
- if(($hasXneg || $hasXpos) && !($hasZneg && $hasZpos)){
- $state = 1;
- }
-
- if(!$this->isStraight){
- if($hasZpos && $hasXpos && !($hasZneg && $hasXneg)) $state = 6;
- if($hasZpos && $hasXneg && !($hasZneg && $hasXpos)) $state = 7;
- if($hasZneg && $hasXneg && !($hasZpos && $hasXpos)) $state = 8;
- if($hasZneg && $hasXpos && !($hasZpos && $hasXneg)) $state = 9;
- }
-
- if($state === -1){
- if($hasZneg || $hasZpos) $state = 0;
- if($hasXneg || $hasXpos) $state = 1;
-
- if(!$this->isStraight){
- if($b){
- if($hasZpos && $hasXpos) $state = 6;
- if($hasXneg && $hasZpos) $state = 7;
- if($hasXpos && $hasZneg) $state = 9;
- if($hasZneg && $hasXneg) $state = 8;
- }else{
- if($hasZneg && $hasXneg) $state = 8;
- if($hasXpos && $hasZneg) $state = 9;
- if($hasXneg && $hasZpos) $state = 7;
- if($hasZpos && $hasXpos) $state = 6;
- }
- }
- }
-
-
- if($state === 0){
- if(RailBaseBlock::isRailBlock($this->level, $this->x, $this->y + 1, $this->z - 1)) $state = 4;
- if(RailBaseBlock::isRailBlock($this->level, $this->x, $this->y + 1, $this->z + 1)) $state = 5;
- }elseif($state === 1){
- if(RailBaseBlock::isRailBlock($this->level, $this->x + 1, $this->y + 1, $this->z)) $state = 2;
- if(RailBaseBlock::isRailBlock($this->level, $this->x - 1, $this->y + 1, $this->z)) $state = 3;
- }elseif($state < 0) $state = 0;
-
- $this->updateConnections($state);
- $meta = $state;
- if($this->isStraight){
- $meta = $this->level->level->getBlockDamage($this->x, $this->x, $this->z) & 8 | $state;
- }
-
- if($b1 || $this->level->level->getBlockDamage($this->x, $this->y, $this->z)){
- //this.logicWorld.setBlockMetadataWithNotify(this.railX, this.railY, this.railZ, var8, 3);
- $bl = $this->level->getBlockWithoutVector($this->x, $this->y, $this->z);
- $bl->setMetadata($meta);
- $this->level->setBlock(new Vector3($this->x, $this->y, $this->z), $bl, true, false, true);
- foreach($this->railPositions as $rpos){
- $logic = $this->getRail($rpos);
- if($logic !== null){
- $logic->removeSoftConnections();
- if($logic->canConnectTo($this)){
- $logic->connectTo($this);
- }
-
- }
- }
-
- }
-
- }
-
- public function hasConnection($x, $y, $z){
- foreach($this->railPositions as $rpos){
- if($rpos->x === $x && $rpos->z === $z) return true;
- }
- return false;
- }
-
- public function connectTo(RailLogic $logic){
- $this->railPositions[] = new Vector3($logic->x, $logic->y, $logic->z);
-
- $hasZneg = $this->hasConnection($this->x, $this->y, $this->z - 1);
- $hasZpos = $this->hasConnection($this->x, $this->y, $this->z + 1);
- $hasXneg = $this->hasConnection($this->x - 1, $this->y, $this->z);
- $hasXpos = $this->hasConnection($this->x + 1, $this->y, $this->z);
- $state = -1;
-
- if($hasZneg || $hasZpos) $state = 0;
- if($hasXneg || $hasXpos) $state = 1;
-
- if(!$this->isStraight){
- if($hasZpos && $hasXpos && !($hasZneg && $hasXneg)) $state = 6;
- if($hasZpos && $hasXneg && !($hasZneg && $hasXpos)) $state = 7;
- if($hasZneg && $hasXneg && !($hasZpos && $hasXpos)) $state = 8;
- if($hasZneg && $hasXpos && !($hasZpos && $hasXneg)) $state = 9;
- }
-
- if($state == 0){
- if(RailBaseBlock::isRailBlock($this->level, $this->x, $this->y + 1, $this->z - 1)) $state = 4;
- if(RailBaseBlock::isRailBlock($this->level, $this->x, $this->y + 1, $this->z + 1)) $state = 5;
- }elseif($state == 1){
- if(RailBaseBlock::isRailBlock($this->level, $this->x + 1, $this->y + 1, $this->z)) $state = 2;
- if(RailBaseBlock::isRailBlock($this->level, $this->x - 1, $this->y + 1, $this->z)) $state = 3;
- }elseif($state < 0) $state = 0;
-
- $meta = $state;
-
- if($this->isStraight){
- $meta = $this->level->level->getBlockDamage($this->x, $this->x, $this->z) & 8 | $state;
- }
-
- //$b = $this->level->getBlockWithoutVector($this->x, $this->y, $this->z);
- //$b->setMetadata($meta);
- //$this->level->setBlock(new Vector3($this->x, $this->y, $this->z), $b, true, false, true);
- $this->level->fastSetBlockUpdateMeta($this->x, $this->y, $this->z, $meta, true);
- }
-
- public function updateConnections($meta){
-
- $this->railPositions = [];
-
- switch($meta){
- case 0:
- $this->railPositions[] = new Vector3($this->x, $this->y, $this->z - 1);
- $this->railPositions[] = new Vector3($this->x, $this->y, $this->z + 1);
- break;
- case 1:
- $this->railPositions[] = new Vector3($this->x - 1, $this->y, $this->z);
- $this->railPositions[] = new Vector3($this->x + 1, $this->y, $this->z);
- break;
- case 2:
- $this->railPositions[] = new Vector3($this->x - 1, $this->y, $this->z);
- $this->railPositions[] = new Vector3($this->x + 1, $this->y + 1, $this->z);
- break;
- case 3:
- $this->railPositions[] = new Vector3($this->x - 1, $this->y + 1, $this->z);
- $this->railPositions[] = new Vector3($this->x + 1, $this->y, $this->z);
- break;
- case 4:
- $this->railPositions[] = new Vector3($this->x, $this->y + 1, $this->z - 1);
- $this->railPositions[] = new Vector3($this->x, $this->y, $this->z + 1);
- break;
- case 5:
- $this->railPositions[] = new Vector3($this->x, $this->y, $this->z - 1);
- $this->railPositions[] = new Vector3($this->x, $this->y + 1, $this->z + 1);
- break;
- case 6:
- $this->railPositions[] = new Vector3($this->x + 1, $this->y, $this->z);
- $this->railPositions[] = new Vector3($this->x, $this->y, $this->z + 1);
- break;
- case 7:
- $this->railPositions[] = new Vector3($this->x - 1, $this->y, $this->z);
- $this->railPositions[] = new Vector3($this->x, $this->y, $this->z + 1);
- break;
- case 8:
- $this->railPositions[] = new Vector3($this->x - 1, $this->y, $this->z);
- $this->railPositions[] = new Vector3($this->x, $this->y, $this->z - 1);
- break;
- case 9:
- $this->railPositions[] = new Vector3($this->x + 1, $this->y, $this->z);
- $this->railPositions[] = new Vector3($this->x, $this->y, $this->z - 1);
- break;
- }
- }
-}
diff --git a/src/utils/Random.php b/src/utils/Random.php
deleted file mode 100644
index 595b4eaf..00000000
--- a/src/utils/Random.php
+++ /dev/null
@@ -1,96 +0,0 @@
-setSeed($seed);
- }
-
- public function setSeed($seed = false){
- $seed = $seed !== false ? Utils::writeInt((int) $seed) : Utils::getRandomBytes(4, false);
- $state = [];
- for($i = 0; $i < 256; ++$i){
- $state[] = $i;
- }
- for($i = $j = 0; $i < 256; ++$i){
- $j = ($j + ord($seed[$i & 0x03]) + $state[$i]) & 0xFF;
- $state[$i] ^= $state[$j];
- $state[$j] ^= $state[$i];
- $state[$i] ^= $state[$j];
- }
- $this->state = $state;
- $this->i = $this->j = 0;
- }
-
- public function nextGaussian(){
- if($this->haveNextNextGaussian){
- $this->haveNextNextGaussian = false;
- return $this->nextNextGaussian;
- }else{
- $v1 = $v2 = $s = null;
- do{
- $v1 = 2 * $this->nextFloat() - 1; // between -1.0 and 1.0
- $v2 = 2 * $this->nextFloat() - 1; // between -1.0 and 1.0
- $s = $v1 * $v1 + $v2 * $v2;
- }while($s >= 1 || $s == 0);
- $multiplier = sqrt(-2 * log($s) / $s);
- $this->nextNextGaussian = $v2 * $multiplier;
- $this->haveNextNextGaussian = true;
- return $v1 * $multiplier;
- }
- }
-
- public function nextFloat(){
- return $this->nextInt() / 0x7FFFFFFF;
- }
-
- public function nextLong($n = -1){
- if($n > 0){
- return Utils::readLong($this->nextBytes(8)) & 0x7FFFFFFF % $n;
- }
- return Utils::readLong($this->nextBytes(8)) & 0x7FFFFFFF;
- }
-
- public function nextInt($n = -1){
- if($n > 0){
- return Utils::readInt($this->nextBytes(4)) & 0x7FFFFFFF % $n;
- }
- return Utils::readInt($this->nextBytes(4)) & 0x7FFFFFFF;
- }
-
- public function nextBytes($byteCount){
- $bytes = "";
- for($i = 0; $i < $byteCount; ++$i){
- $this->i = ($this->i + 1) & 0xFF;
- $this->j = ($this->j + $this->state[$this->i]) & 0xFF;
- $this->state[$this->i] ^= $this->state[$this->j];
- $this->state[$this->j] ^= $this->state[$this->i];
- $this->state[$this->i] ^= $this->state[$this->j];
- $bytes .= chr($this->state[($this->state[$this->i] + $this->state[$this->j]) & 0xFF]);
- }
- return $bytes;
- }
-
- public function nextSignedFloat(){
- return $this->nextSignedInt() / 0x7FFFFFFF;
- }
-
- public function nextSignedInt(){
- return Utils::readInt($this->nextBytes(4));
- }
-
- public function nextBoolean(){
- return ($this->nextBytes(1) & 0x01) == 0;
- }
-
- public function nextRange($start = 0, $end = PHP_INT_MAX){
- return $start + ($this->nextInt() % ($end + 1 - $start));
- }
-
-}
\ No newline at end of file
diff --git a/src/utils/StopMessageThread.php b/src/utils/StopMessageThread.php
deleted file mode 100644
index 5e23086a..00000000
--- a/src/utils/StopMessageThread.php
+++ /dev/null
@@ -1,21 +0,0 @@
-extraprops->get("discord-msg") == true and ($this->page = $server->extraprops->get("discord-webhook-url")) !== "none"){
- $this->msg = $server->extraprops->get("discord-ru-smiles") ? str_replace("@", " ", str_replace("Û", "<:ru_cool:960113011383738369>", str_replace("Ü", "<:ru_cry:960112920346390548>", str_replace("Ú", "<:ru_happy:960112868601237504>", $msg)))) : str_replace("@", "", $msg);
- $this->name = $server->extraprops->get("discord-bot-name");
- $this->start();
- }
-
- }
-
- public function run(){
- Utils::curl_post($this->page, [
- "username" => $this->name,
- "content" => $this->msg
- ]);
- }
-}
\ No newline at end of file
diff --git a/src/utils/TextFormat.php b/src/utils/TextFormat.php
deleted file mode 100644
index d11672f5..00000000
--- a/src/utils/TextFormat.php
+++ /dev/null
@@ -1,225 +0,0 @@
-";
- ++$tokens;
- break;
- case TextFormat::OBFUSCATED:
- //$newString .= "";
- //++$tokens;
- break;
- case TextFormat::ITALIC:
- $newString .= "";
- ++$tokens;
- break;
- case TextFormat::UNDERLINE:
- $newString .= "";
- ++$tokens;
- break;
- case TextFormat::STRIKETHROUGH:
- $newString .= "";
- ++$tokens;
- break;
- case TextFormat::RESET:
- $newString .= str_repeat("", $tokens);
- $tokens = 0;
- break;
-
- //Colors
- case TextFormat::BLACK:
- $newString .= "";
- ++$tokens;
- break;
- case TextFormat::DARK_BLUE:
- $newString .= "";
- ++$tokens;
- break;
- case TextFormat::DARK_GREEN:
- $newString .= "";
- ++$tokens;
- break;
- case TextFormat::DARK_AQUA:
- $newString .= "";
- ++$tokens;
- break;
- case TextFormat::DARK_RED:
- $newString .= "";
- ++$tokens;
- break;
- case TextFormat::DARK_PURPLE:
- $newString .= "";
- ++$tokens;
- break;
- case TextFormat::GOLD:
- $newString .= "";
- ++$tokens;
- break;
- case TextFormat::GRAY:
- $newString .= "";
- ++$tokens;
- break;
- case TextFormat::DARK_GRAY:
- $newString .= "";
- ++$tokens;
- break;
- case TextFormat::BLUE:
- $newString .= "";
- ++$tokens;
- break;
- case TextFormat::GREEN:
- $newString .= "";
- ++$tokens;
- break;
- case TextFormat::AQUA:
- $newString .= "";
- ++$tokens;
- break;
- case TextFormat::RED:
- $newString .= "";
- ++$tokens;
- break;
- case TextFormat::LIGHT_PURPLE:
- $newString .= "";
- ++$tokens;
- break;
- case TextFormat::YELLOW:
- $newString .= "";
- ++$tokens;
- break;
- case TextFormat::WHITE:
- $newString .= "";
- ++$tokens;
- break;
- default:
- $newString .= $token;
- break;
- }
- }
-
- $newString .= str_repeat("", $tokens);
- return $newString;
- }
-
- public static function toANSI($string){
- if(!is_array($string)){
- $string = self::tokenize($string);
- }
- $newString = "";
- foreach($string as $token){
- switch($token){
- case FORMAT_BOLD:
- break;
- case FORMAT_OBFUSCATED:
- $newString .= "\x1b[8m";
- break;
- case FORMAT_ITALIC:
- $newString .= "\x1b[3m";
- break;
- case FORMAT_UNDERLINE:
- $newString .= "\x1b[4m";
- break;
- case FORMAT_STRIKETHROUGH:
- $newString .= "\x1b[9m";
- break;
- case FORMAT_RESET:
- $newString .= "\x1b[0m";
- break;
- //Colors
- case FORMAT_BLACK:
- $newString .= "\x1b[30m";
- break;
- case FORMAT_DARK_BLUE:
- $newString .= "\x1b[34m";
- break;
- case FORMAT_DARK_GREEN:
- $newString .= "\x1b[32m";
- break;
- case FORMAT_DARK_AQUA:
- $newString .= "\x1b[36m";
- break;
- case FORMAT_DARK_RED:
- $newString .= "\x1b[31m";
- break;
- case FORMAT_DARK_PURPLE:
- $newString .= "\x1b[35m";
- break;
- case FORMAT_GOLD:
- $newString .= "\x1b[33m";
- break;
- case FORMAT_GRAY:
- $newString .= "\x1b[37m";
- break;
- case FORMAT_DARK_GRAY:
- $newString .= "\x1b[30;1m";
- break;
- case FORMAT_BLUE:
- $newString .= "\x1b[34;1m";
- break;
- case FORMAT_GREEN:
- $newString .= "\x1b[32;1m";
- break;
- case FORMAT_AQUA:
- $newString .= "\x1b[36;1m";
- break;
- case FORMAT_RED:
- $newString .= "\x1b[31;1m";
- break;
- case FORMAT_LIGHT_PURPLE:
- $newString .= "\x1b[35;1m";
- break;
- case FORMAT_YELLOW:
- $newString .= "\x1b[33;1m";
- break;
- case FORMAT_WHITE:
- $newString .= "\x1b[37;1m";
- break;
- default:
- $newString .= $token;
- break;
- }
- }
- return $newString;
- }
-
-}
\ No newline at end of file
diff --git a/src/utils/UPnP.php b/src/utils/UPnP.php
deleted file mode 100644
index 93782437..00000000
--- a/src/utils/UPnP.php
+++ /dev/null
@@ -1,42 +0,0 @@
-StaticPortMappingCollection)){
- return false;
- }
- $com->StaticPortMappingCollection->Add($port, "UDP", $port, $myLocalIP, true, "NostalgiaCore");
- }catch(Exception $e){
- return false;
- }
- return true;
-}
-
-function UPnP_RemovePortForward($port){
- if(Utils::$online === false){
- return false;
- }
- if(Utils::getOS() != "win" or !class_exists("COM")){
- return false;
- }
- $port = (int) $port;
- try{
- $com = new COM("HNetCfg.NATUPnP") or false;
- if($com === false or !is_object($com->StaticPortMappingCollection)){
- return false;
- }
- $com->StaticPortMappingCollection->Remove($port, "UDP");
- }catch(Exception $e){
- return false;
- }
- return true;
-}
\ No newline at end of file
diff --git a/src/utils/Utils.php b/src/utils/Utils.php
deleted file mode 100644
index af77f218..00000000
--- a/src/utils/Utils.php
+++ /dev/null
@@ -1,665 +0,0 @@
-\\xEF\\xB8\\x8F)?\\xE2\\x83\\xA3|\\xC2[\\xA9\\xAE]|\\xE2..(\\xF0\\x9F\\x8F[\\xBB-\\xBF])?(?>\\xEF\\xB8\\x8F)?|\\xE3(?>\\x80[\\xB0\\xBD]|\\x8A[\\x97\\x99])(?>\\xEF\\xB8\\x8F)?|\\xF0\\x9F(?>[\\x80-\\x86].(?>\\xEF\\xB8\\x8F)?|\\x87.\\xF0\\x9F\\x87.|..(\\xF0\\x9F\\x8F[\\xBB-\\xBF])?|(((?\\xE2\\x80\\x8D)\\xE2\\x9D\\xA4\\xEF\\xB8\\x8F\k\\xF0\\x9F..(\k\\xF0\\x9F\\x91.)?|(\\xE2\\x80\\x8D\\xF0\\x9F\\x91.){2,3}))?))";
- public static function getEntityTypeByID($id){
- return match($id){
- MOB_CHICKEN, MOB_COW, MOB_CREEPER, MOB_ENDERMAN, MOB_MOOSHROOM, MOB_PIG, MOB_PIGMAN, MOB_SHEEP, MOB_SILVERFISH, MOB_SKELETON, MOB_SLIME, MOB_SPIDER,
- MOB_VILLAGER, MOB_WOLF, MOB_ZOMBIE => ENTITY_MOB,
- OBJECT_ARROW, OBJECT_EGG, OBJECT_MINECART, OBJECT_PAINTING, OBJECT_PRIMEDTNT, OBJECT_SNOWBALL, OBJECT_TRIPOD_CAMERA => ENTITY_OBJECT,
- default => $id,
- };
- }
-
- public static function wrapAngleTo360($angle)
- {
- $angle = (int)$angle % 360;
- return $angle < 0 ? $angle + 360 : $angle;
- }
-
- public static function chunkPos2Int($x, $z){
- return ($x & 0xFFFFFFFF) | (($z & 0xFFFFFFFF) << 32);
- }
-
- public static function wrapAngleTo180($angle)
- {
- $angle = fmod($angle+180, 360);
- return $angle < 0 ? $angle + 360 : $angle - 180;
- }
-
- public static function getSign($v){
- return $v > 0 ? 1 : ($v < 0 ? -1 : 0);
- }
-
- public static function clampDegrees($v){
- return floor(($v % 360 + 360) % 360);
- }
-
- public static function endsWith($str, $check) {
- return substr($str, -strlen($check)) === $check;
- }
-
- public static function hasEmoji($s){
- return preg_match(Utils::emojiRegex, $s);
- }
-
- public static function getCallableIdentifier(callable $variable){
- if(is_array($variable)){
- return sha1(strtolower(get_class($variable[0])) . "::" . strtolower($variable[1]));
- }else{
- return sha1(strtolower($variable));
- }
- }
-
- public static function in_range($num, $min, $max){
- return $num >= $min && $num <= $max;
- }
-
- public function xrange($start, $limit, $step = 1) {
- if ($start <= $limit) {
- if ($step <= 0) {
- throw new LogicException('Step must be positive');
- }
-
- for ($i = $start; $i <= $limit; $i += $step) {
- yield $i;
- }
- } else {
- if ($step >= 0) {
- throw new LogicException('Step must be negative');
- }
-
- for ($i = $start; $i >= $limit; $i += $step) {
- yield $i;
- }
- }
- }
-
- public static function getUniqueID($raw = false, $extra = ""){
- $machine = php_uname("a");
- $machine .= file_exists("/proc/cpuinfo") ? file_get_contents("/proc/cpuinfo") : "";
- $machine .= sys_get_temp_dir();
- $machine .= $extra;
- if(Utils::getOS() == "win"){
- exec("ipconfig /ALL", $mac);
- $mac = implode("\n", $mac);
- if(preg_match_all("#Physical Address[. ]{1,}: ([0-9A-F\-]{17})#", $mac, $matches)){
- foreach($matches[1] as $i => $v){
- if($v == "00-00-00-00-00-00"){
- unset($matches[1][$i]);
- }
- }
- $machine .= implode(" ", $matches[1]); //Mac Addresses
- }
- }
- $data = $machine . PHP_MAXPATHLEN;
- $data .= PHP_INT_MAX;
- $data .= PHP_INT_SIZE;
- $data .= get_current_user();
- foreach(get_loaded_extensions() as $ext){
- $data .= $ext . ":" . phpversion($ext);
- }
- return hash("md5", $machine, $raw) . hash("sha512", $data, $raw);
- }
-
- public static function getOS(){
- $uname = php_uname("s");
- if(stripos($uname, "Darwin") !== false){
- if(strpos(php_uname("m"), "iP") === 0){
- return "ios";
- }else{
- return "mac";
- }
- }elseif(stripos($uname, "Win") !== false or $uname === "Msys"){
- return "win";
- }elseif(stripos($uname, "Linux") !== false){
- if(@file_exists("/system/build.prop")){
- return "android";
- }else{
- return "linux";
- }
- }elseif(stripos($uname, "BSD") !== false or $uname === "DragonFly"){
- return "bsd";
- }else{
- return "other";
- }
- }
-
- public static function getIP($force = false){
- if(Utils::$online === false){
- return false;
- }elseif(Utils::$ip !== false and $force !== true){
- return Utils::$ip;
- }
- $ip = trim(strip_tags(Utils::curl_get("http://checkip.dyndns.org/")));
- if(preg_match('#Current IP Address\: ([0-9a-fA-F\:\.]*)#', $ip, $matches) > 0){
- Utils::$ip = $matches[1];
- }else{
- $ip = Utils::curl_get("http://www.checkip.org/");
- if(preg_match('#">([0-9a-fA-F\:\.]*)#', $ip, $matches) > 0){
- Utils::$ip = $matches[1];
- }else{
- $ip = Utils::curl_get("http://checkmyip.org/");
- if(preg_match('#Your IP address is ([0-9a-fA-F\:\.]*)#', $ip, $matches) > 0){
- Utils::$ip = $matches[1];
- }else{
- $ip = trim(Utils::curl_get("http://ifconfig.me/ip"));
- if($ip != ""){
- Utils::$ip = $ip;
- }else{
- return false;
- }
- }
- }
- }
- return Utils::$ip;
-
- }
-
- public static function makeHeaders($json){
- $arr = json_decode($json);
- $rarr = [];
- foreach ($arr as $key => $value){
- $rarr[] = $key.": ".$value;
- }
- return $rarr;
- }
-
- public static function curl_get($page, $timeout = 10, $headers = " "){
- if(Utils::$online === false){
- return false;
- }
-
- if($headers != " "){
- $headers = Utils::makeHeaders($headers);
- }else{
- $headers = ["User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20100101 Firefox/12.0 PocketMine-MP"];
- }
- $ch = curl_init($page);
- curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
- curl_setopt($ch, CURLOPT_AUTOREFERER, true);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
- curl_setopt($ch, CURLOPT_FORBID_REUSE, 1);
- curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1);
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, (int) $timeout);
- $ret = curl_exec($ch);
- curl_close($ch);
- return $ret;
- }
-
- public static function hexdump($bin){
- $output = "";
- $bin = str_split($bin, 16);
- foreach($bin as $counter => $line){
- $hex = chunk_split(chunk_split(str_pad(bin2hex($line), 32, " ", STR_PAD_RIGHT), 2, " "), 24, " ");
- $ascii = preg_replace('#([^\x20-\x7E])#', ".", $line);
- $output .= str_pad(dechex($counter << 4), 4, "0", STR_PAD_LEFT) . " " . $hex . " " . $ascii . PHP_EOL;
- }
- return $output;
- }
-
- public static function printable($str){
- if(!is_string($str)){
- return gettype($str);
- }
- return preg_replace('#([^\x20-\x7E])#', '.', $str);
- }
-
- public static function getRandomUpdateTicks(){
- return -log(lcg_value()) * 1365.4; //Poisson distribution (1/(68.27 * 20))
- }
-
- public static function writeMetadata($data){
- $m = "";
- foreach($data as $bottom => $d){
- $m .= chr(($d["type"] << 5) | ($bottom & 0b00011111));
- switch($d["type"]){
- case 0:
- $m .= Utils::writeByte($d["value"]);
- break;
- case 1:
- $m .= Utils::writeLShort($d["value"]);
- break;
- case 2:
- $m .= Utils::writeLInt($d["value"]);
- break;
- case 3:
- $m .= Utils::writeLFloat($d["value"]);
- break;
- case 4:
- $m .= Utils::writeLShort(strlen($d["value"]));
- $m .= $data["value"];
- break;
- case 5:
- $m .= Utils::writeLShort($d["value"][0]);
- $m .= Utils::writeByte($d["value"][1]);
- $m .= Utils::writeLShort($d["value"][2]);
- break;
- case 6:
- for($i = 0; $i < 3; ++$i){
- $m .= Utils::writeLInt($d["value"][$i]);
- }
- break;
- }
- }
- $m .= "\x7f";
- return $m;
- }
-
- public static function writeByte($c){
- if($c > 0xff){
- return false;
- }
- if($c < 0 and $c >= -0x80){
- $c = 0xff + $c + 1;
- }
- return chr($c);
- }
-
- public static function writeLShort($value){
- return pack("v", $value);
- }
-
- public static function writeLInt($value){
- if($value < 0){
- $value += 0x100000000;
- }
- return pack("V", $value);
- }
-
- public static function writeLFloat($value){
- return ENDIANNESS === BIG_ENDIAN ? strrev(pack("f", $value)) : pack("f", $value);
- }
-
- public static function writeSlot(Item $item){
- return Utils::writeShort($item->getID()) . chr($item->count) . Utils::writeShort($item->getMetadata());
- }
-
- public static function writeShort($value){
- return pack("n", $value);
- }
-
- public static function readSlot($ob){
- $id = Utils::readShort($ob->get(2));
- $cnt = ord($ob->get(1));
- return BlockAPI::getItem(
- $id,
- Utils::readShort($ob->get(2)),
- $cnt
- );
- }
-
- public static function readShort($str, $signed = true){
- if(strlen($str) === 0){
- return;
- }
-
- list(, $unpacked) = unpack("n", $str);
- if($unpacked > 0x7fff and $signed === true){
- $unpacked -= 0x10000; // Convert unsigned short to signed short
- }
-
- return $unpacked;
- }
-
- public static function readMetadata($value, $types = false){
- $offset = 0;
- $m = [];
- $b = ord($value[$offset]);
- ++$offset;
- while($b !== 127 and isset($value[$offset])){
- $bottom = $b & 0x1F;
- $type = $b >> 5;
- switch($type){
- case 0:
- $r = Utils::readByte($value[$offset]);
- ++$offset;
- break;
- case 1:
- $r = Utils::readLShort(substr($value, $offset, 2));
- $offset += 2;
- break;
- case 2:
- $r = Utils::readLInt(substr($value, $offset, 4));
- $offset += 4;
- break;
- case 3:
- $r = Utils::readLFloat(substr($value, $offset, 4));
- $offset += 4;
- break;
- case 4:
- $len = Utils::readLShort(substr($value, $offset, 2));
- $offset += 2;
- $r = substr($value, $offset, $len);
- $offset += $len;
- break;
- case 5:
- $r = [];
- $r[] = Utils::readLShort(substr($value, $offset, 2));
- $offset += 2;
- $r[] = ord($value[$offset]);
- ++$offset;
- $r[] = Utils::readLShort(substr($value, $offset, 2));
- $offset += 2;
- break;
- case 6:
- $r = [];
- for($i = 0; $i < 3; ++$i){
- $r[] = Utils::readLInt(substr($value, $offset, 4));
- $offset += 4;
- }
- break;
-
- }
- if($types === true){
- $m[$bottom] = [$r, $type];
- }else{
- $m[$bottom] = $r;
- }
- $b = ord($value[$offset]);
- ++$offset;
- }
- return $m;
- }
-
- public static function readByte($c, $signed = true){
- $b = ord($c[0]);
- if($signed === true and ($b & 0x80) === 0x80){ //calculate Two's complement
- $b = -0x80 + ($b & 0x7f);
- }
- return $b;
- }
-
- public static function readLShort($str, $signed = true){
- list(, $unpacked) = @unpack("v", $str);
- if($unpacked > 0x7fff and $signed === true){
- $unpacked -= 0x10000; // Convert unsigned short to signed short
- }
- return $unpacked;
- }
-
- public static function readLInt($str){
- if(PHP_INT_SIZE === 8){
- return @unpack("V", $str)[1] << 32 >> 32;
- }else{
- return @unpack("V", $str)[1];
- }
- }
-
- public static function readLFloat($str){
- list(, $value) = ENDIANNESS === BIG_ENDIAN ? @unpack("f", strrev($str)) : @unpack("f", $str);
- return $value;
- }
-
- public static function readDataArray($str, $len = 10, &$offset = null){
- $data = [];
- $offset = 0;
- for($i = 1; $i <= $len and isset($str[$offset]); ++$i){
- $l = Utils::readTriad(substr($str, $offset, 3));
- $offset += 3;
- $data[] = substr($str, $offset, $l);
- $offset += $l;
- }
- return $data;
- }
-
- public static function php8_nulcoal(&$arr, $else){
- return isset($arr) ? $arr : $else;
- }
-
- public static function readTriad($str){
- return @unpack("N", "\x00" . $str)[1];
- }
-
- public static function writeDataArray($data){
- $raw = "";
- foreach($data as $v){
- $raw .= Utils::writeTriad(strlen($v));
- $raw .= $v;
- }
- return $raw;
- }
-
- public static function writeLTriad($value){
- return substr(pack("V", $value), 0, -1);
- }
-
- public static function writeTriad($value){
- return substr(pack("N", $value), 1);
- }
-
- public static function getRandomBytes($length = 16, $secure = true, $raw = true, $startEntropy = "", &$rounds = 0, &$drop = 0){
- return $raw ? random_bytes($length) : bin2hex(random_bytes($length)); //nobody would ever notice other parameters
- }
-
- public static function chance($i){
- return lcg_value() <= $i / 100;
- }
- /**
- * @deprecated use lcg_value() instead.
- * @return number
- */
- public static function randomFloat(){
- return rand() / getrandmax();
- }
-
- public static function round($number){
- return round($number, 0, PHP_ROUND_HALF_DOWN);
- }
- /**
- * manhattan distance
- */
- public static function manh_distance($pos1, $pos2){
- if($pos1 instanceof Vector3){
- $pos1 = $pos1->toArray();
- }
- if($pos2 instanceof Vector3){
- $pos2 = $pos2->toArray();
- }
-
- return abs($pos2["x"] - $pos1["x"]) + abs($pos2["y"] - $pos1["y"]) + abs($pos2["z"] - $pos1["z"]);
- }
-
- /**
- * Euclidian distance, but without square roots
- */
- public static function distance_noroot($pos1, $pos2){
- if($pos1 instanceof Vector3){
- $pos1 = $pos1->toArray();
- }
- if($pos2 instanceof Vector3){
- $pos2 = $pos2->toArray();
- }
- $pX = ($pos1["x"] - $pos2["x"]);
- $pY = ($pos1["y"] - $pos2["y"]);
- $pZ = ($pos1["z"] - $pos2["z"]);
- return ($pX*$pX) + ($pY*$pY) + ($pZ*$pZ);
- }
-
- /**
- *
- * @param $pos1
- * @param $pos2
- * @return number
- */
- public static function distance($pos1, $pos2){
- if($pos1 instanceof Vector3){
- $pos1 = $pos1->toArray();
- }
- if($pos2 instanceof Vector3){
- $pos2 = $pos2->toArray();
- }
- return sqrt(($pos1["x"] - $pos2["x"])*($pos1["x"] - $pos2["x"]) + ($pos1["y"] - $pos2["y"])*($pos1["y"] - $pos2["y"]) + ($pos1["z"] - $pos2["z"])*($pos1["z"] - $pos2["z"]));
- }
-
- public static function angle3D($pos1, $pos2){
- if($pos1 instanceof Vector3){
- $pos1 = $pos1->toArray();
- }
- if($pos2 instanceof Vector3){
- $pos2 = $pos2->toArray();
- }
- $X = $pos1["x"] - $pos2["x"];
- $Z = $pos1["z"] - $pos2["z"];
- $dXZ = sqrt(pow($X, 2) + pow($Z, 2));
- $Y = $pos1["y"] - $pos2["y"];
- $hAngle = rad2deg(atan2($Z, $X) - M_PI_2);
- $vAngle = rad2deg(-atan2($Y, $dXZ));
- return ["yaw" => $hAngle, "pitch" => $vAngle];
- }
-
- public static function curl_post($page, $args, $timeout = 10){
- if(Utils::$online === false){
- return false;
- }
-
- $ch = curl_init($page);
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
- curl_setopt($ch, CURLOPT_FORBID_REUSE, 1);
- curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $args);
- curl_setopt($ch, CURLOPT_AUTOREFERER, true);
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
- curl_setopt($ch, CURLOPT_HTTPHEADER, ["User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20100101 Firefox/12.0 PocketMine-MP"]);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, (int) $timeout);
- $ret = curl_exec($ch);
- curl_close($ch);
- return $ret;
- }
-
- public static function strToHex($str){
- return bin2hex($str);
- }
-
- public static function hexToStr($hex){
- return hex2bin($hex);
- }
-
- public static function readBool($b){
- return Utils::readByte($b, false) === 0 ? false : true;
- }
-
- public static function writeBool($b){
- return Utils::writeByte($b === true ? 1 : 0);
- }
-
- public static function readInt($str){
- if(strlen($str) <= 0) return;
- if(PHP_INT_SIZE === 8){
- return @unpack("N", $str)[1] << 32 >> 32;
- }else{
- return @unpack("N", $str)[1];
- }
- }
-
- public static function writeInt($value){
- if($value < 0){
- $value += 0x100000000;
- }
- return pack("N", $value);
- }
-
- public static function readFloat($str){
- list(, $value) = ENDIANNESS === BIG_ENDIAN ? @unpack("f", $str) : @unpack("f", strrev($str));
- return $value;
- }
-
- public static function writeFloat($value){
- return ENDIANNESS === BIG_ENDIAN ? pack("f", $value) : strrev(pack("f", $value));
- }
-
- public static function printFloat($value){
- return preg_replace("/(\.\d+?)0+$/", "$1", sprintf("%F", $value));
- }
-
- public static function readDouble($str){
- list(, $value) = ENDIANNESS === BIG_ENDIAN ? @unpack("d", $str) : @unpack("d", strrev($str));
- return $value;
- }
-
- public static function writeDouble($value){
- return ENDIANNESS === BIG_ENDIAN ? pack("d", $value) : strrev(pack("d", $value));
- }
-
- public static function readLDouble($str){
- list(, $value) = ENDIANNESS === BIG_ENDIAN ? @unpack("d", strrev($str)) : @unpack("d", $str);
- return $value;
- }
-
- public static function writeLDouble($value){
- return ENDIANNESS === BIG_ENDIAN ? strrev(pack("d", $value)) : pack("d", $value);
- }
-
- public static function readLLong($str){
- return Utils::readLong(strrev($str));
- }
-
- public static function readLong($x, $signed = true){
- $value = "0";
- if($signed === true){
- $negative = ((ord($x[0]) & 0x80) === 0x80) ? true : false;
- if($negative){
- $x = ~$x;
- }
- }else{
- $negative = false;
- }
-
- for($i = 0; $i < 8; $i += 4){
- $value = bcmul($value, "4294967296", 0); //4294967296 == 2^32
- $value = bcadd($value, 0x1000000 * ord(@$x[$i]) + ((ord(@$x[$i + 1]) << 16) | (ord(@$x[$i + 2]) << 8) | ord(@$x[$i + 3])), 0);
- }
- return ($negative === true ? "-" . $value : $value);
- }
-
- public static function writeLLong($value){
- return strrev(Utils::writeLong($value));
- }
-
- public static function writeLong($value){
- $x = "";
- $value = (string) $value;
- if(!is_float($value)){
- if(strval($value[0] == null ? '' : $value[0]) === "-"){
- $negative = true;
- $value = bcadd($value, "1");
- if(strval($value[0]) === "-"){
- $value = substr($value, 1);
- }
- }else{
- $negative = false;
- }
- while(bccomp($value, "0", 0) > 0){
- $temp = bcmod($value, "16777216");
- $x = chr($temp >> 16) . chr($temp >> 8) . chr($temp) . $x;
- $value = bcdiv($value, "16777216", 0);
- }
- $x = str_pad(substr($x, 0, 8), 8, "\x00", STR_PAD_LEFT);
- if($negative === true){
- $x = ~$x;
- }
- return $x;
- }
- }
-}
-
-//if(Utils::isOnline() === false){
-//Utils::$online = false;
-//}
\ No newline at end of file
diff --git a/src/utils/VersionString.php b/src/utils/VersionString.php
deleted file mode 100644
index 83cf76f8..00000000
--- a/src/utils/VersionString.php
+++ /dev/null
@@ -1,18 +0,0 @@
-development = Utils::endsWith($version, "dev");
- }
-
- public function isDev(){
- return $this->development === true;
- }
-
- public function __toString(){
- return MAJOR_VERSION;
- }
-}
\ No newline at end of file
diff --git a/src/world/Explosion.php b/src/world/Explosion.php
deleted file mode 100644
index 2a961b71..00000000
--- a/src/world/Explosion.php
+++ /dev/null
@@ -1,127 +0,0 @@
- DIRT,
- STONE => COBBLESTONE,
- COAL_ORE => COAL,
- DIAMOND_ORE => DIAMOND,
- REDSTONE_ORE => REDSTONE,
- ];
- public static $enableExplosions = true;
- public $level; //Rays
- public $source;
- public $size;
- public $affectedBlocks = [];
- public $stepLen = 0.3;
- private $rays = 16;
- private $air;
- private $nullPlayer;
-
- public function __construct(Position $center, $size){
- $this->level = $center->level;
- $this->source = $center;
- $this->size = max($size, 0);
- $this->air = BlockAPI::getItem(AIR, 0, 1);
- $this->nullPlayer = new PlayerNull();
- }
-
- public function explode(){
- $radius = 2 * $this->size;
- $server = ServerAPI::request();
- if(!Explosion::$enableExplosions){ /*Disable Explosions*/
- foreach($server->api->entity->getRadius($this->source, $radius) as $entity){
- $impact = (1 - $this->source->distance($entity) / $radius) * 0.5; //pla>
- $damage = (int) (($impact * $impact + $impact) * 8 * $this->size + 1);
- $entity->harm($damage, "explosion");
- }
- $pk = new ExplodePacket; //sound fix
- $pk->x = $this->source->x;
- $pk->y = $this->source->y;
- $pk->z = $this->source->z;
- $pk->radius = $this->size;
- $pk->records = [];
- $server->api->player->broadcastPacket($this->level->players, $pk);
- return;
- }
- if($this->size < 0.1 or $server->api->dhandle("entity.explosion", [
- "level" => $this->level,
- "source" => $this->source,
- "size" => $this->size
- ]) === false){
- return false;
- }
- $mRays = $this->rays - 1;
- for($i = 0; $i < $this->rays; ++$i){
- for($j = 0; $j < $this->rays; ++$j){
- for($k = 0; $k < $this->rays; ++$k){
- if($i == 0 or $i == $mRays or $j == 0 or $j == $mRays or $k == 0 or $k == $mRays){
- $vector = new Vector3($i / $mRays * 2 - 1, $j / $mRays * 2 - 1, $k / $mRays * 2 - 1); //($i / $mRays) * 2 - 1
- $vector = $vector->normalize()->multiply($this->stepLen);
- $pointer = clone $this->source;
-
- for($blastForce = $this->size * (mt_rand(700, 1300) / 1000); $blastForce > 0; $blastForce -= $this->stepLen * 0.75){
- $vBlock = $pointer->floor();
- $blockID = $this->level->level->getBlockID($vBlock->x, $vBlock->y, $vBlock->z);
- $blockMeta = $this->level->level->getBlockDamage($vBlock->x, $vBlock->y, $vBlock->z);
- if($blockID > 0){
- $block = BlockAPI::get($blockID, $blockMeta);
- $block->x = $vBlock->x;
- $block->y = $vBlock->y;
- $block->z = $vBlock->z;
- $block->level = $this->level;
- $blastForce -= ($block->getHardness() / 5 + 0.3) * $this->stepLen;
- if($blastForce > 0){
- $index = ($block->x << 15) + ($block->z << 7) + $block->y;
- if(!isset($this->affectedBlocks[$index])){
- $this->affectedBlocks[$index] = $block;
- }
- }
- }
- $pointer = $pointer->add($vector);
- }
- }
- }
- }
- }
-
- $send = [];
- $source = $this->source->floor();
- foreach($server->api->entity->getRadius($this->source, $radius) as $entity){
- $impact = (1 - $this->source->distance($entity) / $radius) * 0.5; //placeholder, 0.7 should be exposure
- $damage = (int) (($impact * $impact + $impact) * 8 * $this->size + 1);
- $entity->harm($damage, "explosion");
- }
-
- foreach($this->affectedBlocks as $block){
- if($block instanceof TNTBlock){
- $data = [
- "x" => $block->x + 0.5,
- "y" => $block->y + 0.5,
- "z" => $block->z + 0.5,
- "power" => 4,
- "fuse" => mt_rand(10, 30), //0.5 to 1.5 seconds
- ];
- $e = $server->api->entity->add($this->level, ENTITY_OBJECT, OBJECT_PRIMEDTNT, $data);
- $server->api->entity->spawnToAll($e);
- }elseif(mt_rand(0, 10000) < ((1 / $this->size) * 10000)){
- $dropz = $block->getDrops($this->air, $this->nullPlayer);
- if(is_array($dropz)){
- foreach($dropz as $drop){
- $server->api->entity->drop(new Position($block->x + 0.5, $block->y, $block->z + 0.5, $this->level), BlockAPI::getItem($drop[0], $drop[1], $drop[2])); //id, meta, count
- }
- }
- }
- $this->level->setBlock($block, new AirBlock(), true);
- $send[] = $block->subtract($source);
- }
- $pk = new ExplodePacket;
- $pk->x = $this->source->x;
- $pk->y = $this->source->y;
- $pk->z = $this->source->z;
- $pk->radius = $this->size;
- $pk->records = $send;
- $server->api->player->broadcastPacket($this->level->players, $pk);
- }
-}
diff --git a/src/world/Level.php b/src/world/Level.php
deleted file mode 100644
index 524af4f2..00000000
--- a/src/world/Level.php
+++ /dev/null
@@ -1,777 +0,0 @@
-server = ServerAPI::request();
- $this->level = $level;
- $this->level->level = $this;
- $this->entityList = [];
- $this->entities = $entities;
- $this->tiles = $tiles;
- $this->blockUpdates = $blockUpdates;
- $this->startTime = $this->time = (int) $this->level->getData("time");
- $this->nextSave = $this->startCheck = microtime(true);
- $this->nextSave += 90;
- $this->stopTime = false;
- $this->server->schedule(15, [$this, "checkThings"], [], true);
- $this->server->schedule(20 * 7, [$this, "checkTime"], [], true);
- $this->name = $name;
- $this->usedChunks = [];
- $this->changedBlocks = [];
- $this->changedCount = [];
- $this->mobSpawner = new MobSpawner($this);
- $gen = $this->level->levelData["generator"];
- $this->generator = new $gen([]);
- $this->generator->init($this, new Random($this->getSeed()));
- }
-
- public function close(){
- $this->__destruct();
- }
-
-
- /**
- * @param AxisAlignedBB $aABB
- * @return AxisAlignedBB[]
- */
- public function getCubes(AxisAlignedBB $aABB) {
- $aABBs = [];
- $x0 = floor($aABB->minX);
- $x1 = ceil($aABB->maxX);
- $y0 = floor($aABB->minY);
- $y1 = round($aABB->maxY);
- $z0 = floor($aABB->minZ);
- $z1 = ceil($aABB->maxZ);
- $x0 = $x0 < 0 ? 0 : $x0;
- $y0 = $y0 < 0 ? 0 : $y0;
- $z0 = $z0 < 0 ? 0 : $z0;
- $x1 = $x1 > 256 ? 256 : $x1;
- $y1 = $y1 > 128 ? 128 : $y1;
- $z1 = $z1 > 256 ? 256 : $z1;
-
- for($x = $x0; $x < $x1; ++$x) {
- for($y = $y0; $y < $y1; ++$y) {
- for($z = $z0; $z < $z1; ++$z) {
- $b = $this->getBlockWithoutVector($x, $y, $z);
- if($b != false && $b->boundingBox->intersectsWith($aABB) && $b->isSolid) {
- $aABBs[] = $b->boundingBox;
- }
- }
- }
- }
-
- return $aABBs;
- }
-
- public function fastSetBlockUpdate($x, $y, $z, $id, $meta, $updateBlocksAround = false){
- $x = (int)$x;
- $y = (int)$y;
- $z = (int)$z;
- $this->level->setBlock($x, $y, $z, $id, $meta);
- $this->sendBlockToAll($x, $y, $z);
- if($updateBlocksAround){
- $this->server->api->block->blockUpdateAround(new Position($x, $y, $z, $this), BLOCK_UPDATE_NORMAL, 1);
- }
- }
-
- public function sendBlockToAll($x, $y, $z){
- foreach($this->players as $p){
- $this->resendBlocksToPlayers[$p->CID]["$x.$y.$z"] = true;
- }
- }
-
- public function __destruct(){
- if(isset($this->level)){
- $this->save(false, false);
- $this->level->close();
- unset($this->level);
- }
- unset($this->mobSpawner->level);
- }
-
- public function checkSleep(){ //TODO events?
- if(count($this->players) == 0) return false;
- if($this->server->api->time->getPhase($this->level) === "night"){ //TODO vanilla
- foreach($this->players as $p){
- if($p->isSleeping == false || $p->sleepingTime < 100){
- return false;
- }
- }
- $this->server->api->time->set("day", $this->level);
- }
- foreach($this->players as $p){
- $p->stopSleep();
- }
- }
-
- public function fastSetBlockUpdateMeta($x, $y, $z, $meta, $updateBlock = false){
- $this->level->setBlockDamage($x, $y, $z, $meta);
- $pk = new UpdateBlockPacket;
- $pk->x = $x;
- $pk->y = $y;
- $pk->z = $z;
- $pk->block = $this->level->getBlockID($x, $y, $z);
- $pk->meta = $meta;
- $this->server->api->player->broadcastPacket($this->players, $pk);
- if($updateBlock){
- $this->server->api->block->blockUpdateAround(new Position($x, $y, $z, $this), BLOCK_UPDATE_NORMAL, 1);
- }
- }
-
- public function getOrderedFullChunk($X, $Z){
- $X = (int)$X;
- $Z = (int)$Z;
- //todo: make asynchronous
- if(!isset($this->level)){
- return false;
- }
-
- $gen = $this->generatorType === 1 || !($X > 15 || $X < 0 || $Z > 15 || $Z < 0);
- $orderedIds = "";
- $orderedData = "";
- $orderedSkyLight = ""; //str_repeat("\xff", 16*16*64);
- $orderedLight = ""; //str_repeat("\xff", 16*16*64);
- $orderedBiomeIds = ""; //
- $orderedBiomeColors = str_repeat("\x00\x85\xb2\x4a", 256); // also PM 1.4
- $tileEntities = "";
- if($gen) $this->level->generateChunk($X, $Z, $this->generator);
- if(!$this->level->isChunkLoaded($X, $Z)){
- $this->level->loadChunk($X, $Z, true);
- }
- $miniChunks = [];
-
- for($y = 0; $y < 8; ++$y){
- $miniChunks[$y] = $gen ? $this->level->getMiniChunk($X, $Z, $y) : str_repeat("\x00", 8192);
- }
- $orderedBiomeIds = $this->level->chunkInfo[$this->level->getIndex($X, $Z)][0];
-
- for ($i = 0; $i < 16; $i++){
- for ($j = 0; $j < 16; $j++){
- $bIndex = ($i << 6) + ($j << 10);
- foreach($miniChunks as $chunk){
- $orderedIds .= substr($chunk, $bIndex, 16);
- $orderedData .= substr($chunk, $bIndex + 16, 8);
- $orderedLight .= substr($chunk, $bIndex + 32, 8);
- $orderedSkyLight .= substr($chunk, $bIndex + 48, 8);
- }
- }
- }
- $chunkTiles = [];
- $tiles = $this->server->query("SELECT ID FROM tiles WHERE spawnable = 1 AND level = '".$this->getName()."' AND x >= ".($X * 16 - 1)." AND x < ".($X * 16 + 17)." AND z >= ".($Z * 16 - 1)." AND z < ".($Z * 16 + 17).";");
- if($tiles !== false and $tiles !== true){
- while(($tile = $tiles->fetchArray(SQLITE3_ASSOC)) !== false){
- $tile = $this->server->api->tile->getByID($tile["ID"]);
- if($tile instanceof Tile){
- $chunkTiles[] = $tile;
- }
- }
- }
-
- $nbt = new NBT_new(NBT_new::LITTLE_ENDIAN);
- foreach($chunkTiles as $tile){ //TODO rewrite TileEntity system
- switch($tile->class){
- case TILE_SIGN:
- $text = $tile->getText();
- $nbt->setData(new Compound("", array(
- new StringTag("Text1", $text[0]),
- new StringTag("Text2", $text[1]),
- new StringTag("Text3", $text[2]),
- new StringTag("Text4", $text[3]),
- new StringTag("id", TILE_SIGN),
- new IntTag("x", (int) $tile->x),
- new IntTag("y", (int) $tile->y),
- new IntTag("z", (int) $tile->z)
- )));
- $tileEntities .= $nbt->write();
- break;
- case TILE_FURNACE:
- //nutting, not spawnable :D
- break;
- case TILE_CHEST:
- if($tile->isPaired()){
- $nbt->setData(new Compound("", array(
- new StringTag("id", "Chest"),
- new IntTag("x", (int) $tile->x),
- new IntTag("y", (int) $tile->y),
- new IntTag("z", (int) $tile->z),
- new IntTag("pairx", (int) $tile->getPair()->x),
- new IntTag("pairz", (int) $tile->getPair()->z)
- )));
- }else{
- $nbt->setData(new Compound("", array(
- new StringTag("id", TILE_CHEST),
- new IntTag("x", (int) $tile->x),
- new IntTag("y", (int) $tile->y),
- new IntTag("z", (int) $tile->z),
- )));
- }
- $tileEntities .= $nbt->write();
- break;
- case TILE_MOB_SPAWNER:
- $nbt->setData(new Compound("", array(
- new StringTag("id", TILE_MOB_SPAWNER),
- new IntTag("x", (int) $tile->x),
- new IntTag("y", (int) $tile->y),
- new IntTag("z", (int) $tile->z),
- new IntTag("EntityId", (int) $tile->data["EntityId"]),
- )));
- $tileEntities .= $nbt->write();
- break;
- }
- }
- $orderedUncompressed = Utils::writeLInt($X) . Utils::writeLInt($Z) .
- $orderedIds . $orderedData . $orderedSkyLight . $orderedLight .
- $orderedBiomeIds . $orderedBiomeColors . $tileEntities;
- $ordered = zlib_encode($orderedUncompressed, ZLIB_ENCODING_DEFLATE, 6);
- return $ordered;
- }
-
- public function isDay(){
- return $this->getTime() % 19200 < TimeAPI::$phases["sunset"];
- }
- public function isNight(){
- $t = $this->getTime() % 19200;
- return $t < TimeAPI::$phases["sunrise"] && $t > TimeAPI::$phases["sunset"];
- }
- public function save($force = false, $extra = true){
- if(!isset($this->level)){
- return false;
- }
- if($this->server->saveEnabled === false and $force === false){
- return;
- }
-
- if($extra !== false){
- $entities = [];
- foreach($this->entityList as $entity){
- if($entity instanceof Entity){
- $entities[] = $entity->createSaveData();
- }
- }
- $this->entities->setAll($entities);
- $this->entities->save();
- $tiles = [];
- foreach($this->server->api->tile->getAll($this) as $tile){
- $tiles[] = $tile->data;
- }
- $this->tiles->setAll($tiles);
- $this->tiles->save();
-
- $blockUpdates = [];
- $updates = $this->server->query("SELECT x,y,z,type,delay FROM blockUpdates WHERE level = '" . $this->getName() . "';");
- if($updates !== false and $updates !== true){
- $timeu = microtime(true);
- while(($bupdate = $updates->fetchArray(SQLITE3_ASSOC)) !== false){
- $bupdate["delay"] = max(1, ($bupdate["delay"] - $timeu) * 20);
- $blockUpdates[] = $bupdate;
- }
- }
-
- $this->blockUpdates->setAll($blockUpdates);
- $this->blockUpdates->save();
-
- }
-
- $this->level->setData("time", (int) $this->time);
- $this->level->doSaveRound();
- $this->level->saveData();
- $this->nextSave = microtime(true) + 45;
- }
-
- public function getName(){
- return $this->name;//return $this->level->getData("name");
- }
-
- public function useChunk($X, $Z, Player $player){
- //ConsoleAPI::debug("$player uses $X $Z");
- if(!isset($this->usedChunks[$X . "." . $Z])){
- $this->usedChunks[$X . "." . $Z] = [];
- }
- $this->usedChunks[$X . "." . $Z][$player->CID] = true;
- if(isset($this->level)){
- $this->level->loadChunk($X, $Z);
- }
- }
-
- public function freeAllChunks(Player $player){
- foreach($player->chunksLoaded as $chunk => $c){
- $xz = explode(":", $chunk);
- $x = $xz[0];
- $z = $xz[1];
- $player->stopUsingChunk($x, $z);
- }
- }
-
- public function freeChunk($X, $Z, Player $player){
- unset($this->usedChunks[$X . "." . $Z][$player->CID]);
- }
-
- public function checkCollisionsFor(Entity $e){
- if($e->level->getName() != $this->getName()){
- return false; //not the same world
- }
- foreach($this->entityList as $e1){
- if($e->boundingBox->intersectsWith($e1->boundingBox) && $e1->isCollidable){
- $e->onCollideWith($e1);
- $e1->onCollideWith($e);
- }
- }
- }
- public function isObstructed($e){
-
- }
-
- public function checkThings(){
- if(!isset($this->level)){
- return false;
- }
- $now = microtime(true);
- $this->players = $this->server->api->player->getAll($this);
- $this->checkSleep();
- if(count($this->changedCount) > 0){
- arsort($this->changedCount);
- $resendChunks = [];
- foreach($this->changedCount as $index => $count){
- if($count < 582){//Optimal value, calculated using the relation between minichunks and single packets
- break;
- }
- foreach($this->players as $p){
- unset($p->chunksLoaded[$index]);
- }
- unset($this->changedBlocks[$index]);
- }
- $this->changedCount = [];
-
- if(count($this->changedBlocks) > 0){
- foreach($this->changedBlocks as $blocks){
- foreach($blocks as $b){
- $pk = new UpdateBlockPacket;
- $pk->x = $b->x;
- $pk->y = $b->y;
- $pk->z = $b->z;
- $pk->block = $b->getID();
- $pk->meta = $b->getMetadata();
- $this->server->api->player->broadcastPacket($this->players, $pk);
- }
- }
- $this->changedBlocks = [];
- }
- }
-
- if($this->nextSave < $now){
- $this->save(false, false);
- }
- }
-
- public function isSpawnChunk($X, $Z){
- $spawnX = $this->level->getData("spawnX") >> 4;
- $spawnZ = $this->level->getData("spawnZ") >> 4;
- return abs($X - $spawnX) <= 1 and abs($Z - $spawnZ) <= 1;
- }
-
- public function getBlockRaw(Vector3 $pos){
- $b = $this->level->getBlock($pos->x, $pos->y, $pos->z);
- return BlockAPI::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){
- if(($ret = $this->level->setBlock($pos->x, $pos->y, $pos->z, $block->getID(), $block->getMetadata())) === true and $send !== false){
- if($direct === true){
- $pk = new UpdateBlockPacket;
- $pk->x = $pos->x;
- $pk->y = $pos->y;
- $pk->z = $pos->z;
- $pk->block = $block->getID();
- $pk->meta = $block->getMetadata();
- $this->server->api->player->broadcastPacket($this->players, $pk);
- }elseif($direct === false){
- if(!($pos instanceof Position)){
- $pos = new Position($pos->x, $pos->y, $pos->z, $this);
- }
- $block->position($pos);
- $i = ($pos->x >> 4) . ":" . ($pos->y >> 4) . ":" . ($pos->z >> 4);
- if(ADVANCED_CACHE == true){
- Cache::remove("world:{$this->name}:" . ($pos->x >> 4) . ":" . ($pos->z >> 4));
- }
- if(!isset($this->changedBlocks[$i])){
- $this->changedBlocks[$i] = [];
- $this->changedCount[$i] = 0;
- }
- $this->changedBlocks[$i][] = clone $block;
- ++$this->changedCount[$i];
- }
- }
- return $ret;
- }
-
- public function onTick(PocketMinecraftServer $server){
- //$ents = $server->api->entity->getAll($this);
- if(!$this->stopTime) $this->time+=2;
- foreach($this->entityList as $k => $e){
- if(!($e instanceof Entity)){
- unset($this->entityList[$k]);
- continue;
- }
- if($e->needsUpdate){
- $e->update();
- }
- }
- if(Entity::$updateOnTick && $server->ticks % 40 === 0){ //40 ticks delay
- $this->mobSpawner->handle();
- }
-
- if($this->generatorType !== 0){ //chunk unloading
- foreach($this->usedChunks as $c => $eids){
- $xz = explode(".", $c); //bad idea, TODO use better indexes
- foreach($eids as $cid => $_){
- $p = $this->server->clients[$cid] ?? false;
- if($p instanceof Player){
- $dist = abs($xz[0] - (((int)$p->entity->x) >> 4)) + abs($xz[1] - (((int)$p->entity->z) >> 4));
- if($dist > PocketMinecraftServer::$chunkLoadingRadius*2){
- //ConsoleAPI::debug("{$p->player} freeing chunk: {$xz[0]} {$xz[1]}");
- $this->freeChunk($xz[0], $xz[1], $p);
- $p->stopUsingChunk($xz[0], $xz[1]);
- }
- }else{
- unset($eids[$cid]);
- unset($this->usedChunks[$c][$cid]);
- ConsoleAPI::debug("Unloaded $c because $cid is not Player");
- }
- }
- if(count($eids) <= 0){
- $outcome = $this->unloadChunk($xz[0], $xz[1], true);
- unset($this->usedChunks[$c]);
- //ConsoleAPI::debug("Unloading: {$xz[0]} {$xz[1]}, status: $outcome");
- }
- }
- }
-
- foreach($this->level->fakeLoaded as $ind => $val){
- $xz = explode(".", $val);
- $this->level->unloadChunk($xz[0], $xz[1]);
- unset($this->level->fakeLoaded[$ind]);
- }
- foreach($this->resendBlocksToPlayers as $playerCID => $blockz){
- /**
- * @var Player $player
- */
- $player = $this->server->clients[$playerCID] ?? false;
- if($player instanceof Player){
- foreach($blockz as $xyz => $_){
- $xyzz = explode(".", $xyz);
- if(count($xyzz) == 3){
- $x = (int) $xyzz[0];
- $y = (int) $xyzz[1];
- $z = (int) $xyzz[2];
- $idm = $this->level->getBlock($x, $y, $z);
- //$player->addToBlockSendQueue(new UpdateBlockPacket($x, $y, $z, $idm[0], $idm[1]));
- $pk = new UpdateBlockPacket;
- $pk->x = $x;
- $pk->y = $y;
- $pk->z = $z;
- $pk->block = $idm[0] & 0xff;
- $pk->meta = $idm[1] & 0xff;
- $player->addToBlockSendQueue($pk);
- }
- unset($blockz[$xyz]);
- }
- $player->sendBlockUpdateQueue();
- }
- unset($this->resendBlocksToPlayers[$playerCID]);
- }
- }
-
- public function setBlock(Vector3 $pos, Block $block, $update = true, $tiles = false, $direct = false){
- $pos->x = (int)$pos->x;
- $pos->y = (int)$pos->y;
- $pos->z = (int)$pos->z;
- if(!isset($this->level) or (($pos instanceof Position) and $pos->level !== $this) or $pos->y < 0){
- return false;
- }
- $ret = $this->level->setBlock($pos->x, $pos->y, $pos->z, $block->getID(), $block->getMetadata());
- if($ret === true){
- if(!($pos instanceof Position)){
- $pos = new Position($pos->x, $pos->y, $pos->z, $this);
- }
- $block->position($pos);
- if($direct === true){
- $this->sendBlockToAll($pos->x, $pos->y, $pos->z);
- }else{
- $i = ($pos->x >> 4) . ":" . ($pos->y >> 4) . ":" . ($pos->z >> 4);
- if(!isset($this->changedBlocks[$i])){
- $this->changedBlocks[$i] = [];
- $this->changedCount[$i] = 0;
- }
- if(ADVANCED_CACHE == true){
- Cache::remove("world:{$this->name}:" . ($pos->x >> 4) . ":" . ($pos->z >> 4));
- }
- $this->changedBlocks[$i][] = clone $block;
- ++$this->changedCount[$i];
- }
-
- if($update === true){
- $this->server->api->block->blockUpdateAround($pos, BLOCK_UPDATE_NORMAL, 1);
- $this->server->api->entity->updateRadius($pos, 3);
- }
- if($tiles === true){
- if(($t = $this->server->api->tile->get($pos)) !== false){
- $t->close();
- }
- }
- }
- return $ret;
- }
-
- public function getMiniChunk($X, $Z, $Y){
- if(!isset($this->level)){
- return false;
- }
- return $this->level->getMiniChunk($X, $Z, $Y);
- }
-
- public function setMiniChunk($X, $Z, $Y, $data){
- if(!isset($this->level)){
- return false;
- }
- $this->changedCount[$X . ":" . $Y . ":" . $Z] = 4096;
- if(ADVANCED_CACHE){
- Cache::remove("world:{$this->name}:$X:$Z");
- }
- return $this->level->setMiniChunk($X, $Z, $Y, $data);
- }
-
- public function loadChunk($X, $Z){
- if(!isset($this->level)){
- return false;
- }
- return $this->level->loadChunk($X, $Z);
- }
-
- public function unloadChunk($X, $Z, $force = false){
- if(!isset($this->level)){
- return false;
- }
-
- if($force !== true and $this->isSpawnChunk($X, $Z)){
- return false;
- }
- Cache::remove("world:{$this->name}:$X:$Z");
- return $this->level->unloadChunk($X, $Z, $this->server->saveEnabled);
- }
-
- public function getOrderedChunk($X, $Z, $Yndex){
- if(!isset($this->level)){
- return false;
- }
- if(ADVANCED_CACHE == true and $Yndex == 0xff){
- $identifier = "world:{$this->name}:$X:$Z";
- if(($cache = Cache::get($identifier)) !== false){
- return $cache;
- }
- }
-
-
- $raw = [];
- for($Y = 0; $Y < 8; ++$Y){
- if(($Yndex & (1 << $Y)) > 0){
- $raw[$Y] = $this->level->getMiniChunk($X, $Z, $Y);
- }
- }
-
- $ordered = "";
- $flag = chr($Yndex);
- for($j = 0; $j < 256; ++$j){
- $ordered .= $flag;
- foreach($raw as $mini){
- $ordered .= substr($mini, $j << 5, 24); //16 + 8
- }
- }
- if(ADVANCED_CACHE == true and $Yndex == 0xff){
- Cache::add($identifier, $ordered, 60);
- }
- return $ordered;
- }
-
- public function getOrderedMiniChunk($X, $Z, $Y){
- if(!isset($this->level)){
- return false;
- }
- $raw = $this->level->getMiniChunk($X, $Z, $Y);
- $ordered = "";
- $flag = chr(1 << $Y);
- for($j = 0; $j < 256; ++$j){
- $ordered .= $flag . substr($raw, $j << 5, 24); //16 + 8
- }
- return $ordered;
- }
-
- public function getSafeSpawn($spawn = false){
- if($spawn === false){
- $spawn = $this->getSpawn();
- }
- if($spawn instanceof Vector3){
- $x = (int) round($spawn->x);
- $y = (int) round($spawn->y);
- $z = (int) round($spawn->z);
- if($x < 0 || $x > 255 || $z < 0 || $z > 255){
- return new Position($x, 128, $z, $this);
- }
- for(; $y > 0; --$y){
- $v = new Vector3($x, $y, $z);
- $b = $this->getBlock($v->getSide(0));
- if($b === false){
- return $spawn;
- }elseif(!($b instanceof AirBlock)){
- break;
- }
- }
- for(; $y < 128; ++$y){
- $v = new Vector3($x, $y, $z);
- if($this->getBlock($v->getSide(1)) instanceof AirBlock){
- if($this->getBlock($v) instanceof AirBlock){
- return new Position($x, $y, $z, $this);
- }
- }else{
- ++$y;
- }
- }
- return new Position($x, $y, $z, $this);
- }
- return false;
- }
-
- public function getSpawn(){
- if(!isset($this->level)){
- return false;
- }
- return new Position($this->level->getData("spawnX"), $this->level->getData("spawnY"), $this->level->getData("spawnZ"), $this);
- }
-
- /**
- * @param number $x
- * @param number $y
- * @param number $z
- * @param boolean $positionfy assign coordinates to block or not
- * @return GenericBlock | false if failed
- */
-
- public function getBlockWithoutVector($x, $y, $z, $positionfy = true){
- $b = $this->level->getBlock((int)$x, (int)$y, (int)$z);
- return BlockAPI::get($b[0], $b[1], $positionfy ? new Position($x, $y, $z, $this) : false);
- }
-
- /**
- * Recommended to use {@link getBlockWithoutVector()} if you dont have the vector
- * @param Vector3 $pos
- * @return Block|false if failed
- */
- public function getBlock(Vector3 $pos){
- if(!isset($this->level) or ($pos instanceof Position) and $pos->level !== $this){
- return false;
- }
- return $this->getBlockWithoutVector($pos->x, $pos->y, $pos->z);
- }
-
- public function setSpawn(Vector3 $pos){
- if(!isset($this->level)){
- return false;
- }
- $this->level->setData("spawnX", $pos->x);
- $this->level->setData("spawnY", $pos->y);
- $this->level->setData("spawnZ", $pos->z);
- }
-
- public function getTime(){
- return (int) ($this->time);
- }
-
- public function setTime($time){
- $this->startTime = $this->time = (int) $time;
- $this->startCheck = microtime(true);
- $this->checkTime();
- }
-
- public function checkTime(){
- /*if(!isset($this->level)){
- return false;
- }
- $now = microtime(true);
- if($this->stopTime == true){
- $time = $this->startTime;
- }else{
- $time = $this->startTime + ($now - $this->startCheck) * 20;
- }
- if($this->server->api->dhandle("time.change", ["level" => $this, "time" => $time]) !== false){ //send time to player every 5 ticks
- $this->time = $time;
- $pk = new SetTimePacket;
- $pk->time = (int) $this->time;
- console($pk->time);
- $pk->started = $this->stopTime == false;
- $this->server->api->player->broadcastPacket($this->players, $pk);
- }else{
- $this->time -= 20 * 13;
- }*/
- $pk = new SetTimePacket;
- $pk->time = (int) $this->time;
- $pk->started = $this->stopTime == false;
- $this->server->api->player->broadcastPacket($this->players, $pk);
- }
-
- public function isTimeStopped(){
- return $this->stopTime;
- }
-
- public function stopTime(){
- $this->stopTime = true;
- $this->startCheck = 0;
- $this->checkTime();
- }
-
- public function startTime(){
- $this->stopTime = false;
- $this->startCheck = microtime(true);
- $this->checkTime();
- }
-
- public function getSeed(){
- if(!isset($this->level)){
- return false;
- }
- return (int) $this->level->getSeed();
- }
-
- public function setSeed($seed){
- if(!isset($this->level)){
- return false;
- }
- $this->level->setData("seed", (int) $seed);
- }
-
- public function scheduleBlockUpdate(Position $pos, $delay, $type = BLOCK_UPDATE_SCHEDULED){
- if(!isset($this->level)){
- return false;
- }
- return $this->server->api->block->scheduleBlockUpdate($pos, $delay, $type);
- }
-}
diff --git a/src/world/LevelImport.php b/src/world/LevelImport.php
deleted file mode 100644
index a0677b92..00000000
--- a/src/world/LevelImport.php
+++ /dev/null
@@ -1,105 +0,0 @@
-path = $path;
- }
-
- public function import(){
- if(file_exists($this->path . "tileEntities.dat")){ //OldPM
- $level = unserialize(file_get_contents($this->path . "level.dat"));
- console("[INFO] Importing OldPM level \"" . $level["LevelName"] . "\" to PMF format");
- $entities = new Config($this->path . "entities.yml", CONFIG_YAML, unserialize(file_get_contents($this->path . "entities.dat")));
- $entities->save();
- $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->load(substr(file_get_contents($this->path . "level.dat"), 8));
- $level = array_shift($nbt->tree);
- if($level["LevelName"] == ""){
- $level["LevelName"] = "world" . time();
- }
- console("[INFO] Importing Pocket level \"" . $level["LevelName"] . "\" to PMF format");
- unset($level["Player"]);
- $nbt->load(substr(file_get_contents($this->path . "entities.dat"), 12));
- $entities = array_shift($nbt->tree);
- if(!isset($entities["TileEntities"])){
- $entities["TileEntities"] = [];
- }
- $tiles = $entities["TileEntities"];
- $entities = $entities["Entities"];
- $entities = new Config($this->path . "entities.yml", CONFIG_YAML, $entities);
- $entities->save();
- $tiles = new Config($this->path . "tiles.yml", CONFIG_YAML, $tiles);
- $tiles->save();
- }else{
- return false;
- }
-
- $pmf = new PMFLevel($this->path . "level.pmf", [
- "name" => $level["LevelName"],
- "seed" => $level["RandomSeed"],
- "time" => $level["Time"],
- "spawnX" => $level["SpawnX"],
- "spawnY" => $level["SpawnY"],
- "spawnZ" => $level["SpawnZ"],
- "extra" => "",
- "width" => 16,
- "height" => 8,
- "generator" => get_class(LevelAPI::createGenerator(LevelAPI::$defaultLevelType))
- ]);
- $chunks = new PocketChunkParser();
- $chunks->loadFile($this->path . "chunks.dat");
- $chunks->loadMap();
- for($Z = 0; $Z < 16; ++$Z){
- for($X = 0; $X < 16; ++$X){
- $chunk = [
- 0 => "",
- 1 => "",
- 2 => "",
- 3 => "",
- 4 => "",
- 5 => "",
- 6 => "",
- 7 => ""
- ];
- for($z = 0; $z < 16; ++$z){
- for($x = 0; $x < 16; ++$x){
- $block = $chunks->getChunkColumn($X, $Z, $x, $z, 0);
- $meta = $chunks->getChunkColumn($X, $Z, $x, $z, 1);
- for($Y = 0; $Y < 8; ++$Y){
- $chunk[$Y] .= substr($block, $Y << 4, 16);
- $metaf = str_split(substr($meta, $Y << 3, 8));
- foreach($metaf as $m2){
- $chunk[$Y] .= chr(ord($m2) << 4) . chr(ord($m2) & 0xf);
- }
- $chunk[$Y] .= "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00";
- $chunk[$Y] .= "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00";
- }
- }
- }
- foreach($chunk as $Y => $data){
- $pmf->setMiniChunk($X, $Z, $Y, $data);
- }
- $pmf->saveChunk($X, $Z);
- }
- console("[NOTICE] Importing level " . ceil(($Z + 1) / 0.16) . "%");
- }
- $chunks->map = null;
- $chunks = null;
- if(file_exists($this->path . "level.dat")) @unlink($this->path . "level.dat");
- if(file_exists($this->path . "level.dat_old")) @unlink($this->path . "level.dat_old");
- if(file_exists($this->path . "player.dat")) @unlink($this->path . "player.dat");
- if(file_exists($this->path . "entities.dat")) @unlink($this->path . "entities.dat");
- if(file_exists($this->path . "chunks.dat")) @unlink($this->path . "chunks.dat");
- if(file_exists($this->path . "chunks.dat.gz")) @unlink($this->path . "chunks.dat.gz");
- if(file_exists($this->path . "tiles.dat")) @unlink($this->path . "tiles.dat");
- unset($chunks, $level, $entities, $tiles, $nbt);
- return true;
- }
-
-}
\ No newline at end of file
diff --git a/src/world/MobSpawner.php b/src/world/MobSpawner.php
deleted file mode 100644
index 472110af..00000000
--- a/src/world/MobSpawner.php
+++ /dev/null
@@ -1,83 +0,0 @@
-server = ServerAPI::request();
- $this->level = $level;
- }
-
- public function countEntities(){
- $ents = 0;
- foreach($this->level->entityList as $e){
- if(!$e->isPlayer() && $e->class === ENTITY_MOB) ++$ents;
- }
- return $ents;
- }
-
- public function handle(){
- if($this->countEntities() > self::$MOB_LIMIT || count($this->level->players) <= 0){
- return false; //not spawning
- }
- return $this->spawnMobs();
- }
-
- public function spawnMobs(){
- $phase = $this->server->api->time->getPhase($this->level);
- if(self::$spawnAnimals && $phase == "day"){ //Animal
- $type = mt_rand(10, 13);
- $baby = false; //TODO baby
- $grassOnly = true;
- }elseif(self::$spawnMobs && $phase == "night"){ //Monster, true night
- $type = mt_rand(32, 35);
- $grassOnly = false;
- $baby = 2;
- }else{
- return false;
- }
- if(empty($this->level->usedChunks)) return false;
- $chunk = explode(".", array_rand($this->level->usedChunks, 1));
- $x = $chunk[0] * 16;
- $z = $chunk[1] * 16;
- $y = $this->getSafeY($x, $z, $grassOnly, $type >= 32 && $type <= 36 && $type != 35);
- if(!$y || $y < 0){
- return false;
- }
- $data = $this->genPosData($x, $y + 0.5, $z);
- if($baby != 2) $data["IsBaby"] = $baby;
-
- $e = $this->server->api->entity->add($this->level, 2, $type, $data);
-
- if($e instanceof Entity){
- $this->server->api->entity->spawnToAll($e);
- //console("[DEBUG] $type spawned at $x, $y, $z");
- }
- return true;
- }
-
- private function genPosData($x, $y, $z){
- return [
- "x" => $x + 0.5,
- "y" => $y,
- "z" => $z + 0.5
- ];
- }
-
- protected function getSafeY($x, $z, $grassOnly = false, $highMob = false){ //first safe block //TODO check boundingbox
- $allowed = [];
- for($y = 0; $y < 128; ++$y){
- $b = $this->level->getBlockWithoutVector($x, $y, $z);
- $b2 = $this->level->getBlockWithoutVector($x, $y + 1, $z);
- $b1 = $this->level->getBlockWithoutVector($x, $y - 1, $z);
- if(!$b->isSolid && !$b->isLiquid && ($b1->isSolid && ($grassOnly ? $b1->getID() === GRASS : true) && ($highMob ? !$b2->isSolid && !$b2->isLiquid : true))){
- $allowed[] = $y;
- }
- }
-
- return empty($allowed) ? -1 : $allowed[mt_rand(0, count($allowed) - 1)];
- }
-}
-
diff --git a/src/world/MovingObjectPosition.php b/src/world/MovingObjectPosition.php
deleted file mode 100644
index 7b495b19..00000000
--- a/src/world/MovingObjectPosition.php
+++ /dev/null
@@ -1,58 +0,0 @@
-typeOfHit = 0;
- $ob->blockX = $x;
- $ob->blockY = $y;
- $ob->blockZ = $z;
- $ob->hitVector = new Vector3($hitVector->x, $hitVector->y, $hitVector->z);
- return $ob;
- }
-
- /**
- * @param Entity $entity
- *
- * @return MovingObjectPosition
- */
- public static function fromEntity(Entity $entity){
- $ob = new MovingObjectPosition;
- $ob->typeOfHit = 1;
- $ob->entityHit = $entity;
- $ob->hitVector = new Vector3($entity->x, $entity->y, $entity->z);
- return $ob;
- }
-}
\ No newline at end of file
diff --git a/src/world/PocketChunkParser.php b/src/world/PocketChunkParser.php
deleted file mode 100644
index f9530a8a..00000000
--- a/src/world/PocketChunkParser.php
+++ /dev/null
@@ -1,196 +0,0 @@
-raw = gzinflate(file_get_contents($file . ".gz"));
- $r = @gzinflate($this->raw);
- if($r !== false and $r != ""){
- $this->raw = $r;
- }
- @unlink($file . ".gz");
- file_put_contents($file, $this->raw);
- }elseif(!file_exists($file)){
- return false;
- }else{
- $this->raw = file_get_contents($file);
- }
- $this->file = $file;
- $this->chunkLength = $this->sectorLength * ord($this->raw[0]);
- return true;
- }
-
- public function loadRaw($raw, $file){
- $this->file = $file;
- $this->raw = $raw;
- $this->chunkLength = $this->sectorLength * ord($this->raw[0]);
- return true;
- }
-
- public function getChunk($X, $Z){
- $X = (int) $X;
- $Z = (int) $Z;
- return substr($this->raw, $this->getOffset($X, $Z), $this->chunkLength);
- }
-
- private function getOffset($X, $Z){
- return $this->location[$X + ($Z << 5)];
- }
-
- public function loadMap(){
- if($this->raw == ""){
- return false;
- }
- $this->loadLocationTable();
- console("[DEBUG] Loading chunks...", true, true, 2);
- for($x = 0; $x < 16; ++$x){
- $this->map[$x] = [];
- for($z = 0; $z < 16; ++$z){
- $this->map[$x][$z] = $this->parseChunk($x, $z);
- }
- }
- $this->raw = b"";
- console("[DEBUG] Chunks loaded!", true, true, 2);
- }
-
- private function loadLocationTable(){
- $this->location = [];
- console("[DEBUG] Loading Chunk Location table...", true, true, 2);
- for($offset = 0; $offset < 0x1000; $offset += 4){
- $data = Utils::readLInt(substr($this->raw, $offset, 4));
- $sectors = $data & 0xff;
- if($sectors === 0){
- continue;
- }
- $sectorLocation = $data >> 8;
- $this->location[$offset >> 2] = $sectorLocation * $this->sectorLength;//$this->getOffset($X, $Z, $sectors);
- }
- }
-
- public function parseChunk($X, $Z){
- $X = (int) $X;
- $Z = (int) $Z;
- $offset = $this->getOffset($X, $Z);
- $len = Utils::readLInt(substr($this->raw, $offset, 4));
- $offset += 4;
- $chunk = [
- 0 => [], //Block
- 1 => [], //Data
- 2 => [], //SkyLight
- 3 => [], //BlockLight
- ];
- foreach($chunk as $section => &$data){
- $l = $section === 0 ? 128 : 64;
- for($i = 0; $i < 256; ++$i){
- $data[$i] = substr($this->raw, $offset, $l);
- $offset += $l;
- }
- }
- return $chunk;
- }
-
- public function saveMap($final = false){
- console("[DEBUG] Saving chunks...", true, true, 2);
-
- $fp = fopen($this->file, "r+b");
- flock($fp, LOCK_EX);
- foreach($this->map as $x => $d){
- foreach($d as $z => $chunk){
- fseek($fp, $this->getOffset($x, $z));
- fwrite($fp, $this->writeChunk($x, $z), $this->chunkLength);
- }
- }
- flock($fp, LOCK_UN);
- fclose($fp);
- $original = filesize($this->file);
- file_put_contents($this->file . ".gz", gzdeflate(gzdeflate(file_get_contents($this->file), 9), 9)); //Double compression for flat maps
- $compressed = filesize($this->file . ".gz");
- console("[DEBUG] Saved chunks.dat.gz with " . round(($compressed / $original) * 100, 2) . "% (" . round($compressed / 1024, 2) . "KB) of the original size", true, true, 2);
- if($final === true){
- @unlink($this->file);
- }
- }
-
- public function writeChunk($X, $Z){
- $X = (int) $X;
- $Z = (int) $Z;
- if(!isset($this->map[$X][$Z])){
- return false;
- }
- $chunk = "";
- foreach($this->map[$X][$Z] as $section => $data){
- for($i = 0; $i < 256; ++$i){
- $chunk .= $data[$i];
- }
- }
- return Utils::writeLInt(strlen($chunk)) . $chunk;
- }
-
- public function getFloor($x, $z){
- $X = $x >> 4;
- $Z = $z >> 4;
- $aX = $x - ($X << 4);
- $aZ = $z - ($Z << 4);
- $index = $aZ + ($aX << 4);
- for($y = 127; $y <= 0; --$y){
- if($this->map[$X][$Z][0][$index][$y] !== "\x00"){
- break;
- }
- }
- return $y;
- }
-
- public function getBlock($x, $y, $z){
- $x = (int) $x;
- $y = (int) $y;
- $z = (int) $z;
- $X = $x >> 4;
- $Z = $z >> 4;
- $aX = $x - ($X << 4);
- $aZ = $z - ($Z << 4);
- $index = $aZ + ($aX << 4);
- $block = ord($this->map[$X][$Z][0][$index][$y]);
- $meta = ord($this->map[$X][$Z][1][$index][$y >> 1]);
- if(($y & 1) === 0){
- $meta = $meta & 0x0F;
- }else{
- $meta = $meta >> 4;
- }
- return [$block, $meta];
- }
-
- public function getChunkColumn($X, $Z, $x, $z, $type = 0){
- $index = $z + ($x << 4);
- return $this->map[$X][$Z][$type][$index];
- }
-
- public function setBlock($x, $y, $z, $block, $meta = 0){
- $x = (int) $x;
- $y = (int) $y;
- $z = (int) $z;
- $X = $x >> 4;
- $Z = $z >> 4;
- $aX = $x - ($X << 4);
- $aZ = $z - ($Z << 4);
- $index = $aZ + ($aX << 4);
- $this->map[$X][$Z][0][$index][$y] = chr($block);
- $old_meta = ord($this->map[$X][$Z][1][$index][$y >> 1]);
- if(($y & 1) === 0){
- $meta = ($old_meta & 0xF0) | ($meta & 0x0F);
- }else{
- $meta = (($meta << 4) & 0xF0) | ($old_meta & 0x0F);
- }
- $this->map[$X][$Z][1][$index][$y >> 1] = chr($meta);
- }
-
-}
\ No newline at end of file
diff --git a/src/world/Position.php b/src/world/Position.php
deleted file mode 100644
index ec0c98d5..00000000
--- a/src/world/Position.php
+++ /dev/null
@@ -1,34 +0,0 @@
-x, $x->y, $x->z);
- }else{
- $this->x = $x;
- $this->y = $y;
- $this->z = $z;
- }
-
- $this->level = $level;
- }
-
- public function getSide($side, $step = 1){
- return new Position(parent::getSide($side, $step), 0, 0, $this->level);
- }
-
- public function distance($x = 0, $y = 0, $z = 0){
- if(($x instanceof Position) and $x->level !== $this->level){
- return PHP_INT_MAX;
- }
-
- return parent::distance($x, $y, $z);
- }
-
- public function __toString(){
- return "Position(level=" . $this->level->getName() . ",x=" . $this->x . ",y=" . $this->y . ",z=" . $this->z . ")";
- }
-}
\ No newline at end of file
diff --git a/src/world/Tile.php b/src/world/Tile.php
deleted file mode 100644
index 296d0062..00000000
--- a/src/world/Tile.php
+++ /dev/null
@@ -1,538 +0,0 @@
-server = ServerAPI::request();
- $this->level = $level;
- $this->normal = true;
- $this->class = $class;
- $this->data = $data;
- $this->closed = false;
- if($class === false){
- $this->closed = true;
- }
- $this->name = "";
- $this->lastUpdate = microtime(true);
- $this->scheduledUpdate = false;
- $this->id = (int) $id;
- $this->x = (int) $x;
- $this->y = (int) $y;
- $this->z = (int) $z;
- $this->server->query("INSERT OR REPLACE INTO tiles (ID, level, class, x, y, z) VALUES (" . $this->id . ", '" . $this->level->getName() . "', '" . $this->class . "', " . $this->x . ", " . $this->y . ", " . $this->z . ");");
- switch($this->class){
- case TILE_CHEST:
- case TILE_SIGN:
- case TILE_MOB_SPAWNER:
- $this->server->query("UPDATE tiles SET spawnable = 1 WHERE ID = " . $this->id . ";");
- break;
- case TILE_FURNACE:
- if(!isset($this->data["BurnTime"]) or $this->data["BurnTime"] < 0){
- $this->data["BurnTime"] = 0;
- }
- if(!isset($this->data["CookTime"]) or $this->data["CookTime"] < 0 or ($this->data["BurnTime"] === 0 and $this->data["CookTime"] > 0)){
- $this->data["CookTime"] = 0;
- }
- if(!isset($this->data["MaxTime"])){
- $this->data["MaxTime"] = $this->data["BurnTime"];
- $this->data["BurnTicks"] = 0;
- }
- if($this->data["BurnTime"] > 0){
- $this->update();
- }
- break;
- }
- }
-
- public function update(){
- if($this->closed === true){
- return false;
- }
-
- if($this->class === TILE_FURNACE){
- $fuel = $this->getSlot(1);
- $raw = $this->getSlot(0);
- $product = $this->getSlot(2);
- $smelt = $raw->getSmeltItem();
- $canSmelt = ($smelt !== false and $raw->count > 0 and (($product->getID() === $smelt->getID() and $product->getMetadata() === $smelt->getMetadata() and $product->count < $product->getMaxStackSize()) or $product->getID() === AIR));
- if($this->data["BurnTime"] <= 0 and $canSmelt and $fuel->getFuelTime() !== false and $fuel->count > 0){
- $this->lastUpdate = microtime(true);
- $this->data["MaxTime"] = $this->data["BurnTime"] = floor($fuel->getFuelTime() * 20);
- $this->data["BurnTicks"] = 0;
- --$fuel->count;
- if($fuel->count === 0){
- $fuel = BlockAPI::getItem(AIR, 0, 0);
- }
- $this->setSlot(1, $fuel, false);
- $current = $this->level->getBlock($this);
- if($current->getID() === FURNACE){
- $this->level->setBlock($this, BlockAPI::get(BURNING_FURNACE, $current->getMetadata()), true, false, true);
- }
- }
- if($this->data["BurnTime"] > 0){
- $ticks = (microtime(true) - $this->lastUpdate) * 20;
- $this->data["BurnTime"] -= $ticks;
- $this->data["BurnTicks"] = ceil(($this->data["BurnTime"] / $this->data["MaxTime"]) * 200);
- if($smelt !== false and $canSmelt){
- $this->data["CookTime"] += $ticks;
- if($this->data["CookTime"] >= 200){ //10 seconds
- $product = BlockAPI::getItem($smelt->getID(), $smelt->getMetadata(), $product->count + 1);
- $this->setSlot(2, $product, false);
- --$raw->count;
- if($raw->count === 0){
- $raw = BlockAPI::getItem(AIR, 0, 0);
- }
- $this->setSlot(0, $raw, false);
- $this->data["CookTime"] -= 200;
- }
- }elseif($this->data["BurnTime"] <= 0){
- $this->data["BurnTime"] = 0;
- $this->data["CookTime"] = 0;
- $this->data["BurnTicks"] = 0;
- }else{
- $this->data["CookTime"] = 0;
- }
-
- $this->server->schedule(2, [$this, "update"]);
- $this->scheduledUpdate = true;
- }else{
- $current = $this->level->getBlock($this);
- if($current->getID() === BURNING_FURNACE){
- $this->level->setBlock($this, BlockAPI::get(FURNACE, $current->getMetadata()), true, false, true);
- }
- $this->data["CookTime"] = 0;
- $this->data["BurnTime"] = 0;
- $this->data["BurnTicks"] = 0;
- $this->scheduledUpdate = false;
- }
- }
- $this->server->handle("tile.update", $this);
- $this->lastUpdate = microtime(true);
- }
-
- public function getSlot($s){
- $i = $this->getSlotIndex($s);
- if($i === false or $i < 0){
- return BlockAPI::getItem(AIR, 0, 0);
- }else{
- return BlockAPI::getItem($this->data["Items"][$i]["id"], $this->data["Items"][$i]["Damage"], $this->data["Items"][$i]["Count"]);
- }
- }
-
- public function getSlotIndex($s){
- if($this->class !== TILE_CHEST and $this->class !== TILE_FURNACE){
- return false;
- }
- foreach($this->data["Items"] as $i => $slot){
- if($slot["Slot"] === $s){
- return $i;
- }
- }
- return -1;
- }
-
- public function setSlot($s, Item $item, $update = true, $offset = 0){
- $i = $this->getSlotIndex($s);
- $d = [
- "Count" => $item->count,
- "Slot" => $s,
- "id" => $item->getID(),
- "Damage" => $item->getMetadata(),
- ];
- if($i === false){
- return false;
- }elseif($item->getID() === AIR or $item->count <= 0){
- if($i >= 0){
- unset($this->data["Items"][$i]);
- }
- }elseif($i < 0){
- $this->data["Items"][] = $d;
- }else{
- $this->data["Items"][$i] = $d;
- }
- $this->server->api->dhandle("tile.container.slot", [
- "tile" => $this,
- "slot" => $s,
- "offset" => $offset,
- "slotdata" => $item,
- ]);
-
- if($update === true and $this->scheduledUpdate === false){
- $this->update();
- }
- return true;
- }
-
- public function pairWith(Tile $tile){
- if($this->isPaired() or $tile->isPaired()){
- return false;
- }
-
- $this->data["pairx"] = $tile->x;
- $this->data["pairz"] = $tile->z;
-
- $tile->data["pairx"] = $this->x;
- $tile->data["pairz"] = $this->z;
-
- $this->server->api->tile->spawnToAll($this);
- $this->server->api->tile->spawnToAll($tile);
- $this->server->handle("tile.update", $this);
- $this->server->handle("tile.update", $tile);
- }
-
- public function isPaired(){
- if($this->class !== TILE_CHEST){
- return false;
- }
- if(!isset($this->data["pairx"]) or !isset($this->data["pairz"])){
- return false;
- }
- return true;
- }
-
- public function unpair(){
- if(!$this->isPaired()){
- return false;
- }
-
- $tile = $this->getPair();
- unset($this->data["pairx"], $this->data["pairz"], $tile->data["pairx"], $tile->data["pairz"]);
-
- $this->server->api->tile->spawnToAll($this);
- $this->server->handle("tile.update", $this);
- if($tile instanceof Tile){
- $this->server->api->tile->spawnToAll($tile);
- $this->server->handle("tile.update", $tile);
- }
- }
-
- public function getPair(){
- if($this->isPaired()){
- return $this->server->api->tile->get(new Position((int) $this->data["pairx"], $this->y, (int) $this->data["pairz"], $this->level));
- }
- return false;
- }
-
- public function openInventory(Player $player){
- if($this->class === TILE_CHEST){
- $player->windowCnt++;
- $player->windowCnt = $id = max(2, $player->windowCnt % 99);
- if(($pair = $this->getPair()) !== false){
- if(($pair->x + ($pair->z << 13)) > ($this->x + ($this->z << 13))){ //Order them correctly
- $player->windows[$id] = [
- $pair,
- $this
- ];
- }else{
- $player->windows[$id] = [
- $this,
- $pair
- ];
- }
- }else{
- $player->windows[$id] = $this;
- }
-
- $pk = new ContainerOpenPacket;
- $pk->windowid = $id;
- $pk->type = WINDOW_CHEST;
- $pk->slots = is_array($player->windows[$id]) ? CHEST_SLOTS << 1 : CHEST_SLOTS;
- $pk->x = $this->x;
- $pk->y = $this->y;
- $pk->z = $this->z;
- $player->dataPacket($pk);
- $slots = [];
-
- if(is_array($player->windows[$id])){
- $all = $this->server->api->player->getAll($this->level);
- foreach($player->windows[$id] as $ob){
- $pk = new TileEventPacket;
- $pk->x = $ob->x;
- $pk->y = $ob->y;
- $pk->z = $ob->z;
- $pk->case1 = 1;
- $pk->case2 = 2;
- $this->server->api->player->broadcastPacket($all, $pk);
- for($s = 0; $s < CHEST_SLOTS; ++$s){
- $slot = $ob->getSlot($s);
- if($slot->getID() > AIR and $slot->count > 0){
- $slots[] = $slot;
- }else{
- $slots[] = BlockAPI::getItem(AIR, 0, 0);
- }
- }
- }
- }else{
- $pk = new TileEventPacket;
- $pk->x = $this->x;
- $pk->y = $this->y;
- $pk->z = $this->z;
- $pk->case1 = 1;
- $pk->case2 = 2;
- $this->server->api->player->broadcastPacket($this->server->api->player->getAll($this->level), $pk);
- for($s = 0; $s < CHEST_SLOTS; ++$s){
- $slot = $this->getSlot($s);
- if($slot->getID() > AIR and $slot->count > 0){
- $slots[] = $slot;
- }else{
- $slots[] = BlockAPI::getItem(AIR, 0, 0);
- }
- }
- }
-
- $pk = new ContainerSetContentPacket;
- $pk->windowid = $id;
- $pk->slots = $slots;
- $player->dataPacket($pk);
- return true;
- }elseif($this->class === TILE_FURNACE){
- $player->windowCnt++;
- $player->windowCnt = $id = max(2, $player->windowCnt % 99);
- $player->windows[$id] = $this;
-
- $pk = new ContainerOpenPacket;
- $pk->windowid = $id;
- $pk->type = WINDOW_FURNACE;
- $pk->slots = FURNACE_SLOTS;
- $pk->x = $this->x;
- $pk->y = $this->y;
- $pk->z = $this->z;
- $player->dataPacket($pk);
-
- $slots = [];
- for($s = 0; $s < FURNACE_SLOTS; ++$s){
- $slot = $this->getSlot($s);
- if($slot->getID() > AIR and $slot->count > 0){
- $slots[] = $slot;
- }else{
- $slots[] = BlockAPI::getItem(AIR, 0, 0);
- }
- }
- $pk = new ContainerSetContentPacket;
- $pk->windowid = $id;
- $pk->slots = $slots;
- $player->dataPacket($pk);
- return true;
- }
- }
-
- public function spawn($player){
- if($this->closed){
- return false;
- }
- if(!($player instanceof Player)){
- $player = $this->server->api->player->get($player);
- }
- switch($this->class){
- case TILE_MOB_SPAWNER:
- $nbt = new NBT(); //TODO fix
- $nbt->write(chr(NBT::TAG_COMPOUND) . "\x00\x00");
-
- $nbt->write(chr(NBT::TAG_STRING));
- $nbt->writeTAG_String("id");
- $nbt->writeTAG_String($this->class);
-
- $nbt->write(chr(NBT::TAG_INT));
- $nbt->writeTAG_String("x");
- $nbt->writeTAG_Int((int) $this->x);
-
- $nbt->write(chr(NBT::TAG_INT));
- $nbt->writeTAG_String("y");
- $nbt->writeTAG_Int((int) $this->y);
-
- $nbt->write(chr(NBT::TAG_INT));
- $nbt->writeTAG_String("z");
- $nbt->writeTAG_Int((int) $this->z);
-
- $nbt->write(chr(NBT::TAG_INT));
- $nbt->writeTAG_String("EntityId");
- $nbt->writeTAG_Int((int) $this->data["EntityId"]);
-
- /*$nbt->write(chr(NBT::TAG_SHORT));
- $nbt->writeTAG_String("Delay");
- $nbt->writeTAG_SHORT((int) $this->data["Delay"]);
-
- $nbt->write(chr(NBT::TAG_SHORT));
- $nbt->writeTAG_String("MinSpawnDelay");
- $nbt->writeTAG_SHORT((int) $this->data["MinSpawnDelay"]);
-
- $nbt->write(chr(NBT::TAG_SHORT));
- $nbt->writeTAG_String("MaxSpawnDelay");
- $nbt->writeTAG_SHORT((int) $this->data["MaxSpawnDelay"]);
-
- $nbt->write(chr(NBT::TAG_SHORT));
- $nbt->writeTAG_String("SpawnCount");
- $nbt->writeTAG_SHORT((int) $this->data["SpawnCount"]);
-
- $nbt->write(chr(NBT::TAG_SHORT));
- $nbt->writeTAG_String("MaxNearbyEntities");
- $nbt->writeTAG_SHORT((int) $this->data["MaxNearbyEntities"]);
-
- $nbt->write(chr(NBT::TAG_SHORT));
- $nbt->writeTAG_String("RequiredPlayerRange");
- $nbt->writeTAG_SHORT((int) $this->data["RequiredPlayerRange"]);
-
- $nbt->write(chr(NBT::TAG_SHORT));
- $nbt->writeTAG_String("SpawnRange");
- $nbt->writeTAG_SHORT((int) $this->data["SpawnRange"]);*/
-
- //console(bin2hex($nbt->binary));
-
- $pk = new EntityDataPacket;
- $pk->x = $this->x;
- $pk->y = $this->y;
- $pk->z = $this->z;
- $pk->namedtag = $nbt->binary;
- $player->dataPacket($pk);
- break;
- case TILE_CHEST:
- $nbt = new NBT();
- $nbt->write(chr(NBT::TAG_COMPOUND) . "\x00\x00");
-
- $nbt->write(chr(NBT::TAG_STRING));
- $nbt->writeTAG_String("id");
- $nbt->writeTAG_String($this->class);
-
- $nbt->write(chr(NBT::TAG_INT));
- $nbt->writeTAG_String("x");
- $nbt->writeTAG_Int((int) $this->x);
-
- $nbt->write(chr(NBT::TAG_INT));
- $nbt->writeTAG_String("y");
- $nbt->writeTAG_Int((int) $this->y);
-
- $nbt->write(chr(NBT::TAG_INT));
- $nbt->writeTAG_String("z");
- $nbt->writeTAG_Int((int) $this->z);
-
- if($this->isPaired()){
- $nbt->write(chr(NBT::TAG_INT));
- $nbt->writeTAG_String("pairx");
- $nbt->writeTAG_Int((int) $this->data["pairx"]);
-
- $nbt->write(chr(NBT::TAG_INT));
- $nbt->writeTAG_String("pairz");
- $nbt->writeTAG_Int((int) $this->data["pairz"]);
- }
-
- $nbt->write(chr(NBT::TAG_END));
-
- $pk = new EntityDataPacket;
- $pk->x = $this->x;
- $pk->y = $this->y;
- $pk->z = $this->z;
- $pk->namedtag = $nbt->binary;
- $player->dataPacket($pk);
- break;
- case TILE_SIGN:
- $nbt = new NBT();
- $nbt->write(chr(NBT::TAG_COMPOUND) . "\x00\x00");
-
- $nbt->write(chr(NBT::TAG_STRING));
- $nbt->writeTAG_String("Text1");
- $nbt->writeTAG_String($this->data["Text1"]);
-
- $nbt->write(chr(NBT::TAG_STRING));
- $nbt->writeTAG_String("Text2");
- $nbt->writeTAG_String($this->data["Text2"]);
-
- $nbt->write(chr(NBT::TAG_STRING));
- $nbt->writeTAG_String("Text3");
- $nbt->writeTAG_String($this->data["Text3"]);
-
- $nbt->write(chr(NBT::TAG_STRING));
- $nbt->writeTAG_String("Text4");
- $nbt->writeTAG_String($this->data["Text4"]);
-
- $nbt->write(chr(NBT::TAG_STRING));
- $nbt->writeTAG_String("id");
- $nbt->writeTAG_String($this->class);
-
- $nbt->write(chr(NBT::TAG_INT));
- $nbt->writeTAG_String("x");
- $nbt->writeTAG_Int((int) $this->x);
-
- $nbt->write(chr(NBT::TAG_INT));
- $nbt->writeTAG_String("y");
- $nbt->writeTAG_Int((int) $this->y);
-
- $nbt->write(chr(NBT::TAG_INT));
- $nbt->writeTAG_String("z");
- $nbt->writeTAG_Int((int) $this->z);
-
- $nbt->write(chr(NBT::TAG_END));
-
- $pk = new EntityDataPacket;
- $pk->x = $this->x;
- $pk->y = $this->y;
- $pk->z = $this->z;
- $pk->namedtag = $nbt->binary;
- $player->dataPacket($pk);
- break;
- }
- }
-
- public function setText($line1 = "", $line2 = "", $line3 = "", $line4 = ""){
- if($this->class !== TILE_SIGN){
- return false;
- }
- $this->data["Text1"] = $line1;
- $this->data["Text2"] = $line2;
- $this->data["Text3"] = $line3;
- $this->data["Text4"] = $line4;
- $this->server->api->tile->spawnToAll($this);
- $this->server->handle("tile.update", $this);
- return true;
- }
-
- public function getText(){
- return [
- $this->data["Text1"],
- $this->data["Text2"],
- $this->data["Text3"],
- $this->data["Text4"]
- ];
- }
-
- public function __destruct(){
- $this->close();
- }
-
- public function close(){
- if($this->closed === false){
- $this->closed = true;
- $this->server->api->tile->remove($this->id);
- }
- }
-
- public function getName(){
- return $this->name;
- }
-
-
- public function setPosition(Vector3 $pos){
- if($pos instanceof Position){
- $this->level = $pos->level;
- $this->server->query("UPDATE tiles SET level = '" . $this->level->getName() . "' WHERE ID = " . $this->id . ";");
- }
- $this->x = (int) $pos->x;
- $this->y = (int) $pos->y;
- $this->z = (int) $pos->z;
- $this->server->query("UPDATE tiles SET x = " . $this->x . ", y = " . $this->y . ", z = " . $this->z . " WHERE ID = " . $this->id . ";");
- }
-}
diff --git a/src/world/generator/EndGenerator.php b/src/world/generator/EndGenerator.php
deleted file mode 100644
index eaa18936..00000000
--- a/src/world/generator/EndGenerator.php
+++ /dev/null
@@ -1,127 +0,0 @@
-level = $level;
- $this->random = $random;
- $this->random->setSeed($this->level->getSeed());
- $this->noiseBase = new NoiseGeneratorSimplex($this->random, 4, 1 / 4, 1 / 64);
-
- /*$ores = new Ore();
- $ores->setOreTypes([
- new OreType(new CoalOre(), 20, 16, 0, 128),
- new OreType(New IronOre(), 20, 8, 0, 64),
- new OreType(new RedstoneOre(), 8, 7, 0, 16),
- new OreType(new LapisOre(), 1, 6, 0, 32),
- new OreType(new GoldOre(), 2, 8, 0, 32),
- new OreType(new DiamondOre(), 1, 7, 0, 16),
- new OreType(new Dirt(), 20, 32, 0, 128),
- new OreType(new Gravel(), 10, 16, 0, 128)
- ]);
- $this->populators[] = $ores;*/
- }
-
- public function generateChunk($chunkX, $chunkZ){
- $this->random->setSeed(0xdeadbeef ^ ($chunkX << 8) ^ $chunkZ ^ $this->level->getSeed());
-
- $noise = ExperimentalGenerator::getFastNoise3D($this->noiseBase, 16, 128, 16, 4, 8, 4, $chunkX * 16, 0, $chunkZ * 16);
-
- for($chunkY = 0; $chunkY < 8; ++$chunkY){
- $chunk = "";
- $startY = $chunkY << 4;
- $endY = $startY + 16;
- for($z = 0; $z < 16; ++$z){
- for($x = 0; $x < 16; ++$x){
- $lightChunk = "";
- for($y = $startY; $y < $endY; ++$y){
- $noiseValue = $noise[$x][$z][$y];
- $noiseValue -= 1 - $this->density;
-
- if($noiseValue > 0){
- $lightChunk .= "\x00";
- $chunk .= "\x79";
- }
- else{//Air
- $lightChunk .= "\x00";
- $chunk .= "\x00";
- }
- }
- $chunk .= str_repeat("\x00", 16); //meta
- $chunk .= $lightChunk; //blocklight
- $chunk .= str_repeat("\x00", 16); //skylight
- $lightChunk = "";
- //$chunk .= "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"; //light
- //$chunk .= "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"; //more light
- }
- }
- $this->level->setMiniChunk($chunkX, $chunkZ, $chunkY, $chunk);
- }
- $this->level->level->setBiomeIdArrayForChunk($chunkX, $chunkZ, str_repeat(chr(9), 256));
- foreach($this->generationPopulators as $populator){
- $populator->populate($this->level, $chunkX, $chunkZ, $this->random);
- }
- }
-
- public function populateChunk($chunkX, $chunkZ){
- $this->random->setSeed(0xdeadbeef ^ ($chunkX << 8) ^ $chunkZ ^ $this->level->getSeed());
- foreach($this->populators as $populator){
- $this->random->setSeed(0xdeadbeef ^ ($chunkX << 8) ^ $chunkZ ^ $this->level->getSeed());
- $populator->populate($this->level, $chunkX, $chunkZ, $this->random);
- }
- }
-
- public function getSpawn(){
- return new Vector3(127.5, 128, 127.5);
- }
-
- public function populateLevel()
- {}
-}
\ No newline at end of file
diff --git a/src/world/generator/ExperimentalGenerator.php b/src/world/generator/ExperimentalGenerator.php
deleted file mode 100644
index bd8e407a..00000000
--- a/src/world/generator/ExperimentalGenerator.php
+++ /dev/null
@@ -1,230 +0,0 @@
-level = $level;
- $this->random = $random;
- $this->random->setSeed($this->level->level->getSeed());
- $this->noiseBase = new NoiseGeneratorPerlin($this->random, 4);
- $this->selector = new BiomeSelector($this->random, BiomeSelector::$biomes[BIOME_PLAINS]);
- $ores = new OrePopulator();
- $ores->setOreTypes(array(
- new OreType(new CoalOreBlock(), 20, 16, 0, 128),
- new OreType(New IronOreBlock(), 20, 8, 0, 64),
- new OreType(new RedstoneOreBlock(), 8, 7, 0, 16),
- new OreType(new LapisOreBlock(), 1, 6, 0, 32),
- new OreType(new GoldOreBlock(), 2, 8, 0, 32),
- new OreType(new DiamondOreBlock(), 1, 7, 0, 16),
- new OreType(new EmeraldOreBlock(), 1, 2, 0, 16), //TODO vanilla
-
- new OreType(new DirtBlock(), 20, 32, 0, 128),
- new OreType(new GravelBlock(), 10, 16, 0, 128),
- new OreType(new StoneBlock(1), 12, 16, 0, 128),
- new OreType(new StoneBlock(3), 12, 16, 0, 128),
- new OreType(new StoneBlock(5), 12, 16, 0, 128),
- ));
- $this->populators[] = $ores;
- $this->genPopulators[] = new GroundCover();
- $trees = new TreePopulator();
- $trees->setBaseAmount(3);
- $trees->setRandomAmount(0);
- $this->populators[] = $trees;
-
- $tallGrass = new TallGrassPopulator();
- $tallGrass->setBaseAmount(5);
- $tallGrass->setRandomAmount(0);
- $this->populators[] = $tallGrass;
- $this->caveGenerator = new CaveGenerator($this->level->getSeed());
- }
-
- public function pickBiome(int $x, int $z){
- $hash = $x * 2345803 ^ $z * 9236449 ^ $this->level->level->getSeed();
- $hash *= $hash + 223;
- $xNoise = ((int)$hash) >> 20 & 3; //why dont u have types for local variables??
- $zNoise = ((int)$hash) >> 22 & 3;
- if($xNoise == 3){
- $xNoise = 1;
- }
- if($zNoise == 3){
- $zNoise = 1;
- }
- return $this->selector->pickBiome($x + $xNoise - 1, $z + $zNoise - 1);
- }
-
- public function generateChunk($chunkX, $chunkZ){
- $this->random->setSeed(0xdeadbeef ^ ($chunkX << 8) ^ $chunkZ ^ $this->level->level->getSeed());
- $noiseArray = ExperimentalGenerator::getFastNoise3D($this->noiseBase, 16, 128, 16, 4, 8, 4, $chunkX * 16, 0, $chunkZ * 16);
- $biomeCache = [];
- for($chunkY = 0; $chunkY < 8; ++$chunkY){
- $chunk = "";
- $startY = $chunkY << 4;
- $endY = $startY + 16;
- for($z = 0; $z < 16; ++$z){
- for($x = 0; $x < 16; ++$x){
- $minSum = 0;
- $maxSum = 0;
- $weightSum = 0;
-
- $biome = $this->pickBiome($chunkX * 16 + $x, $chunkZ * 16 + $z);
- $this->level->level->setBiomeId(($chunkX << 4) + $x, ($chunkZ << 4) + $z, $biome->id);
- for($sx = -ExperimentalGenerator::$SMOOTH_SIZE; $sx <= ExperimentalGenerator::$SMOOTH_SIZE; ++$sx){
- for($sz = -ExperimentalGenerator::$SMOOTH_SIZE; $sz <= ExperimentalGenerator::$SMOOTH_SIZE; ++$sz){
- $weight = ExperimentalGenerator::$GAUSSIAN_KERNEL[$sx + ExperimentalGenerator::$SMOOTH_SIZE][$sz + ExperimentalGenerator::$SMOOTH_SIZE];
-
- if($sx === 0 and $sz === 0){
- $adjacent = $biome;
- }else{
- $index = ($chunkX * 16 + $x + $sx).":".($chunkZ * 16 + $z + $sz);
- if(isset($biomeCache[$index])){
- $adjacent = $biomeCache[$index];
- }else{
- $biomeCache[$index] = $adjacent = $this->pickBiome($chunkX * 16 + $x + $sx, $chunkZ * 16 + $z + $sz);
- }
- }
-
- $minSum += ($adjacent->minY - 1) * $weight;
- $maxSum += $adjacent->maxY * $weight;
-
- $weightSum += $weight;
- }
- }
- $minSum /= $weightSum;
- $maxSum /= $weightSum;
- for($y = $startY; $y < $endY; ++$y){
- if($y == 0){
- $chunk .= "\x07";
- continue;
- }
- $noiseAdjustment = 2 * (($maxSum - $y) / ($maxSum - $minSum)) - 1;
- $caveLevel = $minSum - 10;
- $distAboveCaveLevel = $y - $caveLevel > 0 ? $y - $caveLevel : 0; //max(0, $y - $caveLevel); // must be positive, looks like max is slower
- $noiseAdjustment = ($noiseAdjustment < (0.4 + ($distAboveCaveLevel / 10))) ? $noiseAdjustment : (0.4 + ($distAboveCaveLevel / 10)); //min($noiseAdjustment, 0.4 + ($distAboveCaveLevel / 10));
- $noiseValue = $noiseArray[$x][$z][$y] + $noiseAdjustment;
- $chunk .= (($noiseValue > 0) ? "\x01" : (($y <= $this->waterHeight) ? "\x09" : "\x00"));
- }
- $chunk .= "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00";
- $chunk .= "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"; //light
- $chunk .= "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"; //more light
- }
- }
- $this->level->setMiniChunk($chunkX, $chunkZ, $chunkY, $chunk);
- }
-
- foreach($this->genPopulators as $pop){
- $pop->populate($this->level, $chunkX, $chunkZ, $this->random);
- }
-
- $this->caveGenerator->generate($this->level, $chunkX, $chunkZ);
- }
-
- public function populateChunk($chunkX, $chunkZ){
- $this->level->level->setPopulated($chunkX, $chunkZ, true);
- $this->random->setSeed(0xdeadbeef ^ ($chunkX << 8) ^ $chunkZ ^ $this->level->level->getSeed());
- foreach($this->populators as $populator){
- $populator->populate($this->level, $chunkX, $chunkZ, $this->random);
- }
- }
- public static function getFastNoise3D(NoiseGenerator $noise, $xSize, $ySize, $zSize, $xSamplingRate, $ySamplingRate, $zSamplingRate, $x, $y, $z){
- $noiseArray = array_fill(0, $xSize + 1, array_fill(0, $zSize + 1, []));
-
- for($xx = 0; $xx <= $xSize; $xx += $xSamplingRate){
- for($zz = 0; $zz <= $zSize; $zz += $zSamplingRate){
- for($yy = 0; $yy <= $ySize; $yy += $ySamplingRate){
- $noiseArray[$xx][$zz][$yy] = $noise->noise3D(($x + $xx) / 32, ($y + $yy) / 32, ($z + $zz) / 32, 2, 1/4, true);
- }
- }
- }
-
- for($xx = 0; $xx < $xSize; ++$xx){
- for($zz = 0; $zz < $zSize; ++$zz){
- for($yy = 0; $yy < $ySize; ++$yy){
- if($xx % $xSamplingRate != 0 or $zz % $zSamplingRate != 0 or $yy % $ySamplingRate != 0){
- $nx = (int) ($xx / $xSamplingRate) * $xSamplingRate;
- $ny = (int) ($yy / $ySamplingRate) * $ySamplingRate;
- $nz = (int) ($zz / $zSamplingRate) * $zSamplingRate;
-
- $nnx = $nx + $xSamplingRate;
- $nny = $ny + $ySamplingRate;
- $nnz = $nz + $zSamplingRate;
-
- $dx1 = (($nnx - $xx) / ($nnx - $nx));
- $dx2 = (($xx - $nx) / ($nnx - $nx));
- $dy1 = (($nny - $yy) / ($nny - $ny));
- $dy2 = (($yy - $ny) / ($nny - $ny));
-
- $noiseArray[$xx][$zz][$yy] = (($nnz - $zz) / ($nnz - $nz)) *
- (
- $dy1 * ($dx1 * $noiseArray[$nx][$nz][$ny] + $dx2 * $noiseArray[$nnx][$nz][$ny]) +
- $dy2 * ($dx1 * $noiseArray[$nx][$nz][$nny] + $dx2 * $noiseArray[$nnx][$nz][$nny])
- ) +
- (($zz - $nz) / ($nnz - $nz)) *
- (
- $dy1 * ($dx1 * $noiseArray[$nx][$nnz][$ny] + $dx2 * $noiseArray[$nnx][$nnz][$ny]) +
- $dy2 * ($dx1 * $noiseArray[$nx][$nnz][$nny] + $dx2 * $noiseArray[$nnx][$nnz][$nny])
- );
- }
- }
- }
- }
-
- return $noiseArray;
- }
- public function getSpawn(){
- return $this->level->getSafeSpawn(new Vector3(127.5, 128, 127.5));
- }
- public function populateLevel()
- {}
-
-
-}
diff --git a/src/world/generator/HellGenerator.php b/src/world/generator/HellGenerator.php
deleted file mode 100644
index 3d24ce6d..00000000
--- a/src/world/generator/HellGenerator.php
+++ /dev/null
@@ -1,138 +0,0 @@
-level = $level;
- $this->random = $random;
- $this->random->setSeed($this->level->getSeed());
- $this->noiseBase = new NoiseGeneratorSimplex($this->random, 4, 1 / 4, 1 / 64);
-
- /*$ores = new Ore();
- $ores->setOreTypes([
- new OreType(new CoalOre(), 20, 16, 0, 128),
- new OreType(New IronOre(), 20, 8, 0, 64),
- new OreType(new RedstoneOre(), 8, 7, 0, 16),
- new OreType(new LapisOre(), 1, 6, 0, 32),
- new OreType(new GoldOre(), 2, 8, 0, 32),
- new OreType(new DiamondOre(), 1, 7, 0, 16),
- new OreType(new Dirt(), 20, 32, 0, 128),
- new OreType(new Gravel(), 10, 16, 0, 128)
- ]);
- $this->populators[] = $ores;*/
- }
-
- public function generateChunk($chunkX, $chunkZ){
- $this->random->setSeed(0xdeadbeef ^ ($chunkX << 8) ^ $chunkZ ^ $this->level->getSeed());
-
- $noise = ExperimentalGenerator::getFastNoise3D($this->noiseBase, 16, 128, 16, 4, 8, 4, $chunkX * 16, 0, $chunkZ * 16);
- for($chunkY = 0; $chunkY < 8; ++$chunkY){
- $chunk = "";
- $startY = $chunkY << 4;
- $endY = $startY + 16;
- for($z = 0; $z < 16; ++$z){
- for($x = 0; $x < 16; ++$x){
- $lightChunk = "";
- for($y = $startY; $y < $endY; ++$y){
- if($y === 0 or $y === 127){//Bedrock
- $lightChunk .= "\x00";
- $chunk .= "\x07";
- continue;
- }
- $noiseValue = (abs($this->emptyHeight - $y) / $this->emptyHeight) * $this->emptyAmplitude - $noise[$x][$z][$y];
- $noiseValue -= 1 - $this->density;
-
- if($noiseValue > 0){//Netherrack
- $lightChunk .= "\x00";
- $chunk .= "\x57";
- }elseif($y <= $this->waterHeight){//Lava
- $lightChunk .= "\xff";
- $chunk .= "\x0b";
- }
- else{//Air
- $lightChunk .= "\x00";
- $chunk .= "\x00";
- }
- }
- $chunk .= str_repeat("\x00", 16); //meta
- $chunk .= $lightChunk; //blocklight
- $chunk .= str_repeat("\x00", 16); //skylight
- //$chunk .= "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"; //light
- //$chunk .= "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"; //more light
- }
- }
- $this->level->setMiniChunk($chunkX, $chunkZ, $chunkY, $chunk);
- }
- $this->level->level->setBiomeIdArrayForChunk($chunkX, $chunkZ, str_repeat(chr(BIOME_HELL), 256));
- foreach($this->generationPopulators as $populator){
- $populator->populate($this->level, $chunkX, $chunkZ, $this->random);
- }
- }
-
- public function populateChunk($chunkX, $chunkZ){
- $this->level->level->setPopulated($chunkX, $chunkZ, true);
- $this->random->setSeed(0xdeadbeef ^ ($chunkX << 8) ^ $chunkZ ^ $this->level->getSeed());
- foreach($this->populators as $populator){
- $this->random->setSeed(0xdeadbeef ^ ($chunkX << 8) ^ $chunkZ ^ $this->level->getSeed());
- $populator->populate($this->level, $chunkX, $chunkZ, $this->random);
- }
- }
-
- public function getSpawn(){
- return new Vector3(127.5, 128, 127.5);
- }
-
- public function populateLevel()
- {}
-}
\ No newline at end of file
diff --git a/src/world/generator/LevelGenerator.php b/src/world/generator/LevelGenerator.php
deleted file mode 100644
index a018deea..00000000
--- a/src/world/generator/LevelGenerator.php
+++ /dev/null
@@ -1,16 +0,0 @@
-level = $level;
- $this->random = $random;
- $this->random->setSeed($this->level->getSeed());
- $this->mtrandom = new MTRandom($this->level->getSeed());
- $this->noiseHills = new NoiseGeneratorPerlin($this->random, 3);
- $this->noisePatches = new NoiseGeneratorPerlin($this->random, 2);
- $this->noisePatchesSmall = new NoiseGeneratorPerlin($this->random, 2);
- $this->noiseBase = new NoiseGeneratorPerlin($this->random, 16);
- $this->biomeSelector = new NormalGeneratorBiomeSelector($this->random, BiomeSelector::$biomes[BIOME_PLAINS]);
-
- $ores = new OrePopulator();
- $ores->setOreTypes(array(
- new OreType(new CoalOreBlock(), 20, 16, 0, 128),
- new OreType(New IronOreBlock(), 20, 8, 0, 64),
- new OreType(new RedstoneOreBlock(), 8, 7, 0, 16),
- new OreType(new LapisOreBlock(), 1, 6, 0, 32),
- new OreType(new GoldOreBlock(), 2, 8, 0, 32),
- new OreType(new DiamondOreBlock(), 1, 7, 0, 16),
- new OreType(new EmeraldOreBlock(), 1, 2, 0, 16), //TODO vanilla
-
- new OreType(new DirtBlock(), 20, 32, 0, 128),
- new OreType(new GravelBlock(), 10, 16, 0, 128),
- new OreType(new StoneBlock(1), 12, 16, 0, 128),
- new OreType(new StoneBlock(3), 12, 16, 0, 128),
- new OreType(new StoneBlock(5), 12, 16, 0, 128),
- ));
- $this->populators[] = $ores;
- $trees = new BiomeBasedTreePopulator();
- $trees->setBaseAmount(8); //TODO biome based amount?
- $trees->setRandomAmount(4);
- $this->populators[] = $trees;
-
- $this->populators[] = new FlowerPatchPopulator();
-
- $tallGrass = new TallGrassPopulator();
- $tallGrass->setBaseAmount(5);
- $tallGrass->setRandomAmount(0);
- $this->populators[] = $tallGrass;
- $this->caveGenerator = new CaveGenerator($this->level->getSeed());
- $this->mineshaftGenerator = new MineshaftGenerator($this->level->getSeed());
- }
-
- public function pickBiome(int $x, int $z){
- $hash = $x * 2345803 ^ $z * 9236449 ^ $this->level->level->getSeed();
- $hash *= $hash + 223;
- $xNoise = ((int)$hash) >> 20 & 3; //why dont u have types for local variables??
- $zNoise = ((int)$hash) >> 22 & 3;
- if($xNoise == 3){
- $xNoise = 1;
- }
- if($zNoise == 3){
- $zNoise = 1;
- }
- return $this->biomeSelector->pickBiome($x + $xNoise - 1, $z + $zNoise - 1);
- }
-
- public function generateChunk($chunkX, $chunkZ){
- $this->random->setSeed(0xdeadbeef ^ ($chunkX << 8) ^ $chunkZ ^ $this->level->getSeed());
- $hills = array();
- $base = array();
- $biomes = str_repeat(chr(BIOME_PLAINS), 256);
- for($z = 0; $z < 16; ++$z){
- for($x = 0; $x < 16; ++$x){
- $biomes[($z << 4) + $x] = chr($this->pickBiome($chunkX * 16 + $x, $chunkZ * 16 + $z)->id);
- $i = ($z << 4) + $x;
- $hills[$i] = $this->noiseHills->noise2D($x + ($chunkX << 4), $z + ($chunkZ << 4), 0.11, 12, true);
- $patches[$i] = $this->noisePatches->noise2D($x + ($chunkX << 4), $z + ($chunkZ << 4), 0.03, 16, true);
- $base[$i] = $this->noiseBase->noise2D($x + ($chunkX << 4), $z + ($chunkZ << 4), 0.7, 16, true);
- if($base[$i] < 0){
- $base[$i] *= 0.5;
- }
- }
- }
- for($chunkY = 0; $chunkY < 8; ++$chunkY){
- $chunk = "";
- $startY = $chunkY << 4;
- $endY = $startY + 16;
- for($z = 0; $z < 16; ++$z){
- for($x = 0; $x < 16; ++$x){
- $i = ($z << 4) + $x;
- $height = $this->worldHeight + $hills[$i] * 14 + $base[$i] * 7;
- $height = (int) $height;
- $biomeID = ord($biomes[$i]);
- for($y = $startY; $y < $endY; ++$y){
- $diff = $height - $y;
- if($y <= 4 and ($y === 0 or $this->random->nextFloat() < 0.33)){
- $chunk .= "\x07"; //bedrock
- }elseif($diff > 2){
- $chunk .= "\x01"; //stone
- }elseif($diff > 0){
- if($patches[$i] > 0.9){
- $chunk .= "\x01"; //stone
- }elseif($patches[$i] < -0.8){
- $chunk .= "\x0d"; //gravel
- }else{
- $chunk .= $biomeID === BIOME_DESERT ? chr(SANDSTONE) : chr(DIRT);
- }
- }elseif($y <= $this->waterHeight){
- if(($this->waterHeight - $y) <= 1 and $diff === 0){
- $chunk .= ($biomeID === BIOME_TAIGA) ? chr(GRASS) : chr(SAND);
- }elseif($diff === 0){
- $chunk .= "\x03"; //dirt
- }else{
- //if($y === $this->waterHeight && $biomeID == BIOME_TAIGA){
- // $chunk .= chr(ICE);
- ///}else{
- $chunk .= "\x09"; //still_water
- //}
- }
- }elseif($diff === 0){
- if($patches[$i] > 0.7){
- $chunk .= "\x01"; //stone
- }elseif($patches[$i] < -0.8){
- $chunk .= "\x0d"; //gravel
- }else{
- $chunk .= $biomeID === BIOME_DESERT ? chr(SAND) : chr(GRASS);
- }
- }else{
- $chunk .= "\x00";
- }
- }
- $chunk .= "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"; //meta
- $chunk .= "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"; //light/skylight
- $chunk .= "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"; //skylight/light
- }
- }
- $this->level->setMiniChunk($chunkX, $chunkZ, $chunkY, $chunk);
- }
- $this->level->level->setBiomeIdArrayForChunk($chunkX, $chunkZ, $biomes);
- if(self::HIDDEN_FEATURES) {
- $this->caveGenerator->generate($this->level, $chunkX, $chunkZ); //TODO speedup
- $this->mineshaftGenerator->generate($this->level, $chunkX, $chunkZ);
- }
- }
-
- public function populateChunk($chunkX, $chunkZ){
- $blockX = $chunkX * 16;
- $blockZ = $chunkZ * 16;
-
- $this->level->level->setPopulated($chunkX, $chunkZ, true);
-
- $this->random->setSeed(0xdeadbeef ^ ($chunkX << 8) ^ $chunkZ ^ $this->level->getSeed());
- $this->mtrandom->setSeed(0xdeadbeef ^ ($chunkX << 8) ^ $chunkZ ^ $this->level->getSeed());
-
- $biomeID = $this->level->level->getBiomeId($chunkX*16, $chunkZ*16);
- $biome = BiomeSelector::get($biomeID);
- if($biome === false){
- ConsoleAPI::warn("Failed to get Biome with id {$biomeID} at $chunkX, $chunkZ");
- }else{
- $biome->decorator->decorate($this->level, $chunkX, $chunkZ, $this->random);
- }
-
- if(self::HIDDEN_FEATURES) {
- //this.mineshaftGenerator.generateStructuresInChunk(this.worldObj, this.rand, par2, par3);
- $this->mineshaftGenerator->generateStructuresInChunk($this->level, $this->mtrandom, $chunkX, $chunkZ);
- for ($i = 0; $i < 8; ++$i){
- $x = $blockX + $this->mtrandom->nextInt(16) + 8;
- $y = $this->mtrandom->nextInt(128);
- $z = $blockZ + $this->mtrandom->nextInt(16) + 8;
- if(Feature::$DUNGEON->place($this->level, $this->mtrandom, $x, $y, $z)){
- ConsoleAPI::debug("Placed Dungeon at $x $y $z");
- }
- }
- }
- foreach($this->populators as $populator){
- $this->random->setSeed(0xdeadbeef ^ ($chunkX << 8) ^ $chunkZ ^ $this->level->getSeed()); //ty shoghicp for 250k bytes of randomness (where ~65536 are usable)
- $populator->populate($this->level, $chunkX, $chunkZ, $this->random);
- }
- }
-
- public function getSpawn(){
- return $this->level->getSafeSpawn(new Vector3(127.5, 128, 127.5));
- }
- public function populateLevel()
- {}
-
-
-}
diff --git a/src/world/generator/Populator.php b/src/world/generator/Populator.php
deleted file mode 100644
index abda2046..00000000
--- a/src/world/generator/Populator.php
+++ /dev/null
@@ -1,6 +0,0 @@
-preset = "2;7,59x1,3x3,2;1;spawn(radius=10 block=89),decoration(treecount=80 grasscount=45)";
- $this->options = $options;
- if(isset($options["preset"])){
- $this->parsePreset($options["preset"]);
- }else{
- $this->parsePreset($this->preset);
- }
- if(isset($this->options["decoration"])){
- $ores = new OrePopulator();
- $ores->setOreTypes([
- new OreType(new CoalOreBlock(), 20, 16, 0, 128),
- new OreType(new IronOreBlock(), 20, 8, 0, 64),
- new OreType(new RedstoneOreBlock(), 8, 7, 0, 16),
- new OreType(new LapisOreBlock(), 1, 6, 0, 32),
- new OreType(new GoldOreBlock(), 2, 8, 0, 32),
- new OreType(new DiamondOreBlock(), 1, 7, 0, 16),
- new OreType(new EmeraldOreBlock(), 1, 7, 0, 16), //TODO
-
- new OreType(new DirtBlock(), 20, 32, 0, 128),
- new OreType(new GravelBlock(), 10, 16, 0, 128),
- new OreType(new StoneBlock(1), 20, 32, 0, 128),
- new OreType(new StoneBlock(3), 20, 32, 0, 128),
- new OreType(new StoneBlock(5), 20, 32, 0, 128),
- ]);
- $this->populators[] = $ores;
- //$this->populators[] = new PondPopulator();
- }
-
- /*if(isset($this->options["mineshaft"])){
- $this->populators[] = new MineshaftPopulator(isset($this->options["mineshaft"]["chance"]) ? floatval($this->options["mineshaft"]["chance"]) : 0.01);
- }*/
- }
-
- public function parsePreset($preset){
- $this->preset = $preset;
- $preset = explode(";", $preset);
- $version = (int) $preset[0];
- $blocks = @$preset[1];
- $biome = isset($preset[2]) ? $preset[2] : 1;
- $options = isset($preset[3]) ? $preset[3] : "";
- preg_match_all('#(([0-9]{0,})x?([0-9]{1,3}:?[0-9]{0,2})),?#', $blocks, $matches);
- $y = 0;
- $this->structure = [];
- $this->chunks = [];
- foreach($matches[3] as $i => $b){
- $b = BlockAPI::fromString($b);
- $cnt = $matches[2][$i] === "" ? 1 : intval($matches[2][$i]);
- for($cY = $y, $y += $cnt; $cY < $y; ++$cY){
- $this->structure[$cY] = $b;
- }
- }
-
- $this->floorLevel = $y;
-
- for(; $y < 0xFF; ++$y){
- $this->structure[$y] = new AirBlock();
- }
-
-
- for($Y = 0; $Y < 8; ++$Y){
- $this->chunks[$Y] = "";
- $startY = $Y << 4;
- $endY = $startY + 16;
- for($Z = 0; $Z < 16; ++$Z){
- for($X = 0; $X < 16; ++$X){
- $blocks = "";
- $metas = "";
- for($y = $startY; $y < $endY; ++$y){
- $blocks .= chr($this->structure[$y]->getID());
- $metas .= chr($this->structure[$y]->getMetadata());
- }
- $this->chunks[$Y] .= $blocks . $metas . "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" . "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00";
- }
- }
- }
-
- preg_match_all('#(([0-9a-z_]{1,})\(?([0-9a-z_ =:]{0,})\)?),?#', $options, $matches);
- foreach($matches[2] as $i => $option){
- $params = true;
- if($matches[3][$i] !== ""){
- $params = [];
- $p = explode(" ", $matches[3][$i]);
- foreach($p as $k){
- $k = explode("=", $k);
- if(isset($k[1])){
- $params[$k[0]] = $k[1];
- }
- }
- }
- $this->options[$option] = $params;
- }
- }
-
- public function init(Level $level, Random $random){
- $this->level = $level;
- $this->random = $random;
- }
-
- public function generateChunk($chunkX, $chunkZ){
- for($Y = 0; $Y < 8; ++$Y){
- $this->level->setMiniChunk($chunkX, $chunkZ, $Y, $this->chunks[$Y]);
- }
- $this->level->level->setBiomeIdArrayForChunk($chunkX, $chunkZ, str_repeat(chr(BIOME_PLAINS), 256));
- }
-
- public function populateChunk($chunkX, $chunkZ){
- foreach($this->populators as $populator){
- $this->random->setSeed((int) ($chunkX * 0xdead + $chunkZ * 0xbeef) ^ $this->level->getSeed());
- $populator->populate($this->level, $chunkX, $chunkZ, $this->random);
- }
- }
-
- public function populateLevel(){
- $this->random->setSeed($this->level->getSeed());
- if(isset($this->options["spawn"])){
- $spawn = [10, new SandstoneBlock()];
- if(isset($this->options["spawn"]["radius"])){
- $spawn[0] = intval($this->options["spawn"]["radius"]);
- }
- if(isset($this->options["spawn"]["block"])){
- $spawn[1] = BlockAPI::fromString($this->options["spawn"]["block"])->getBlock();
- if(!($spawn[1] instanceof Block)){
- $spawn[1] = new SandstoneBlock();
- }
- }
-
- $start = 128 - $spawn[0];
- $end = 128 + $spawn[0];
- for($x = $start; $x <= $end; ++$x){
- for($z = $start; $z <= $end; ++$z){
- if(floor(sqrt(pow($x - 128, 2) + pow($z - 128, 2))) <= $spawn[0]){
- $this->level->setBlockRaw(new Vector3($x, $this->floorLevel - 1, $z), $spawn[1], null);
- }
- }
- }
- }
-
- if(isset($this->options["decoration"])){
- $treecount = 80;
- $grasscount = 120;
- if(isset($this->options["spawn"]["treecount"])){
- $treecount = intval($this->options["spawn"]["treecount"]);
- }
- if(isset($this->options["spawn"]["grasscount"])){
- $grasscount = intval($this->options["spawn"]["grasscount"]);
- }
- for($t = 0; $t < $treecount; ++$t){
- $centerX = $this->random->nextRange(0, 255);
- $centerZ = $this->random->nextRange(0, 255);
- $down = $this->level->level->getBlockID($centerX, $this->floorLevel - 1, $centerZ);
- if($down === DIRT or $down === GRASS or $down === FARMLAND){
- TreeObject::growTree($this->level, new Vector3($centerX, $this->floorLevel, $centerZ), $this->random, $this->random->nextRange(0, 3));
- }
- }
- for($t = 0; $t < $grasscount; ++$t){
- $centerX = $this->random->nextRange(0, 255);
- $centerZ = $this->random->nextRange(0, 255);
- $down = $this->level->level->getBlockID($centerX, $this->floorLevel - 1, $centerZ);
- if($down === GRASS){
- TallGrassObject::growGrass($this->level, new Vector3($centerX, $this->floorLevel - 1, $centerZ), $this->random, $this->random->nextRange(8, 40));
- }
- }
- }
- }
-
- public function getSpawn(){
- return new Vector3(128, $this->floorLevel, 128);
- }
-}
\ No newline at end of file
diff --git a/src/world/generator/VoidGenerator.php b/src/world/generator/VoidGenerator.php
deleted file mode 100644
index afa04d02..00000000
--- a/src/world/generator/VoidGenerator.php
+++ /dev/null
@@ -1,61 +0,0 @@
-options = $options;
- /*if(isset($this->options["mineshaft"])){
- $this->populators[] = new MineshaftPopulator(isset($this->options["mineshaft"]["chance"]) ? floatval($this->options["mineshaft"]["chance"]) : 0.01);
- }*/
- }
-
- public function init(Level $level, Random $random){
- $this->level = $level;
- $this->random = $random;
- }
-
- public function generateChunk($chunkX, $chunkZ){
- for($Y = 0; $Y < 8; ++$Y){
- $this->level->setMiniChunk($chunkX, $chunkZ, $Y, $this->chunks[$Y]);
- }
- }
-
- public function populateChunk($chunkX, $chunkZ){
- foreach($this->populators as $populator){
- $this->random->setSeed((int) ($chunkX * 0xdead + $chunkZ * 0xbeef) ^ $this->level->getSeed());
- $populator->populate($this->level, $chunkX, $chunkZ, $this->random);
- }
- }
-
- public function populateLevel(){
- $this->random->setSeed($this->level->getSeed());
- }
-
- public function getSpawn(){
- return new Vector3(128, $this->floorLevel, 128);
- }
-}
\ No newline at end of file
diff --git a/src/world/generator/WorldGenerator.php b/src/world/generator/WorldGenerator.php
deleted file mode 100644
index 84c11742..00000000
--- a/src/world/generator/WorldGenerator.php
+++ /dev/null
@@ -1,57 +0,0 @@
-seed = $seed !== false ? (int) $seed : Utils::readInt(Utils::getRandomBytes(4, false));
- $this->random = new Random($this->seed);
- $this->width = (int) $width;
- $this->height = (int) $height;
- $this->path = DATA_PATH . "worlds/" . $name . "/";
- $this->generator = $generator;
- $level = new PMFLevel($this->path . "level.pmf", [
- "name" => $name,
- "seed" => $this->seed,
- "time" => 0,
- "spawnX" => 128,
- "spawnY" => 128,
- "spawnZ" => 128,
- "extra" => "",
- "width" => $this->width,
- "height" => $this->height,
- "generator" => get_class($generator),
- ]);
- $entities = new Config($this->path . "entities.yml", CONFIG_YAML);
- $tiles = new Config($this->path . "tiles.yml", CONFIG_YAML);
- $blockUpdates = new Config($this->path . "bupdates.yml", CONFIG_YAML);
- $this->level = new Level($level, $entities, $tiles, $blockUpdates, $name);
- }
-
- public function generate(){
- $this->generator->init($this->level, $this->random);
- for($Z = 0; $Z < $this->width; ++$Z){
- for($X = 0; $X < $this->width; ++$X){
- $this->generator->generateChunk($X, $Z);
- }
- console("[NOTICE] Generating level " . ceil((($Z + 1) / $this->width) * 100) . "%");
- }
- console("[NOTICE] Populating level");
- $this->generator->populateLevel();
- for($Z = 0; $Z < $this->width; ++$Z){
- for($X = 0; $X < $this->width; ++$X){
- $this->generator->populateChunk($X, $Z);
- }
- console("[NOTICE] Populating level " . ceil((($Z + 1) / $this->width) * 100) . "%");
- }
-
- $this->level->setSpawn($this->generator->getSpawn());
- $this->level->save(true, true);
- }
-
- public function close(){
- $this->level->close();
- }
-
-}
\ No newline at end of file
diff --git a/src/world/generator/biome/Biome.php b/src/world/generator/biome/Biome.php
deleted file mode 100644
index 8822ff69..00000000
--- a/src/world/generator/biome/Biome.php
+++ /dev/null
@@ -1,79 +0,0 @@
-name = $name;
- $this->id = $id;
- $this->decorator = $this->createBiomeDecorator();
- }
-
- public function setTopBlocks($id){
- $this->topBlocks = $id;
- }
-
- public function createBiomeDecorator(){
- return new BiomeDecorator();
- }
-
- public function getTree(Random $random){
- return null;
- }
-
- public function getID(){
- return $this->id;
- }
-
- public function setMinMax($min, $max){
- $this->minY = $min;
- $this->maxY = $max;
- }
-
- public function getMin(){
- return $this->minY;
- }
-
- public function getTopBlocks(){
- return $this->topBlocks;
- }
-
- public function getMax(){
- return $this->maxY;
- }
-
- public function setFillerBlock($id){
- $this->fillerBlock = $id;
- }
-
- public function getBiomeAt($x, $z){
- self::$biomeLookup[$x + $z * 64];
- }
-
- public function __toString(){
- return $this->name;
- }
-
- public static function init(){
- ConsoleAPI::debug("Init Biomes");
- BiomeSelector::registerBiome(new BiomeExtremeHills(BIOME_EXTREME_HILLS, "Extreme Hills"));
- BiomeSelector::registerBiome(new BiomePlains(BIOME_PLAINS, "Plains"));
- BiomeSelector::registerBiome(new BiomeExtremeHillsEdge(BIOME_EXTREME_HILLS_EDGE, "Extreme Hills Edge"));
- BiomeSelector::registerBiome(new BiomeRiver(BIOME_RIVER, "River"));
- BiomeSelector::registerBiome(new BiomeOcean(BIOME_OCEAN, "Ocean"));
- BiomeSelector::registerBiome(new BiomeSwamp(BIOME_SWAMP, "Swamp"));
- BiomeSelector::registerBiome(new BiomeIcePlains(BIOME_ICE_PLAINS, "Ice Plains"));
- BiomeSelector::registerBiome(new BiomeDesert(BIOME_DESERT, "Desert"));
- BiomeSelector::registerBiome(new BiomeTaiga(BIOME_TAIGA, "Taiga"));
- BiomeSelector::registerBiome(new BiomeForest(BIOME_FOREST, "Forest"));
- BiomeSelector::registerBiome(new BiomeForest(BIOME_BIRCH_FOREST, "Birch Forest"));
- BiomeSelector::registerBiome(new BiomeJungle(BIOME_JUNGLE, "Jungle"));
-
- }
-
- private static $initialized = false;
- public static $temperature, $rainfall;
- public static $biomes = [];
-}
diff --git a/src/world/generator/biome/BiomeDecorator.php b/src/world/generator/biome/BiomeDecorator.php
deleted file mode 100644
index 435b2b71..00000000
--- a/src/world/generator/biome/BiomeDecorator.php
+++ /dev/null
@@ -1,9 +0,0 @@
-fallback = $fallback;
- $this->temperature = new NoiseGeneratorSimplex($random, 2);
- $this->rainfall = new NoiseGeneratorSimplex($random, 2);
- $this->generateBiomeLookup();
- }
-
- public static function registerBiome(Biome $b){
- ConsoleAPI::debug("Registered $b");
- self::$biomes[$b->id] = $b;
- }
- /**
- * @param int $id
- * @return Biome | false
- */
- public static function get($id){
- return self::$biomes[$id] ?? false;
- }
-
- public function generateBiomeLookup(){
- for($t = 0; $t < 64; ++$t){
- for($r = 0; $r < 64; ++$r){
- $this->map[$t + ($r << 6)] = $this->getBiomeTR($t / 63, $r / 63);
- }
- }
- }
-
- public function getBiomeTR($t, $r){
- if($r < 0.25){
- if($t < 0.7){
- return BIOME_OCEAN;
- }else if($t < 0.85){
- return BIOME_RIVER;
- }else{
- return BIOME_SWAMP;
- }
- }else if($r < 0.60){
- if($t < 0.25){
- return BIOME_ICE_PLAINS;
- }else if($t < 0.75){
- return BIOME_PLAINS;
- }else{
- return BIOME_DESERT;
- }
- }else if($r < 0.80){
- if($t < 0.25){
- return BIOME_TAIGA;
- }else if($t < 0.75){
- return BIOME_FOREST;
- }else{
- return BIOME_BIRCH_FOREST;
- }
- }else{
- if($t < 0.25){
- return BIOME_EXTREME_HILLS;
- }else if($t < 0.70){
- return BIOME_EXTREME_HILLS_EDGE;
- }else{
- return BIOME_RIVER;
- }
- }
- }
-
- public function getTemperature($x, $z){ //TODO cache
- return ($this->temperature->noise2D($x * 0.001953125, $z * 0.001953125, 2, 0.0625, true) + 1) / 2;
- }
-
- public function getRainfall($x, $z){
- return ($this->rainfall->noise2D($x * 0.001953125, $z * 0.001953125, 2, 0.0625, true) + 1) / 2;
- }
-
- public function pickBiome($x, $z){
- $temperature = (int) ($this->getTemperature($x, $z) * 63);
- $rainfall = (int) ($this->getRainfall($x, $z) * 63);
- $biomeId = $this->map[$temperature + ($rainfall << 6)] ?? -1;
- return self::$biomes[$biomeId] ?? $this->fallback;
- }
-}
-
diff --git a/src/world/generator/biome/NormalGeneratorBiomeSelector.php b/src/world/generator/biome/NormalGeneratorBiomeSelector.php
deleted file mode 100644
index bd483645..00000000
--- a/src/world/generator/biome/NormalGeneratorBiomeSelector.php
+++ /dev/null
@@ -1,32 +0,0 @@
-temperature->noise2D($x * 0.001953125, $z * 0.001953125, 4, 0.0625, true) + 1) / 2;
- }
-
- public function getRainfall($x, $z){
- return ($this->rainfall->noise2D($x * 0.001953125, $z * 0.001953125, 4, 0.0625, true) + 1) / 2;
- }
-
- public function getBiomeTR($t, $r){
- if($r < 0.60){
- if($t < 0.75){
- return BIOME_PLAINS;
- }else{
- return BIOME_DESERT;
- }
- }else if($r < 0.80){
- if($t < 0.25){
- return BIOME_TAIGA;
- }else if($t < 0.75){
- return BIOME_FOREST;
- }else{
- return BIOME_JUNGLE;
- }
- }
- return BIOME_PLAINS;
- }
-}
-
diff --git a/src/world/generator/biome/biomes/BiomeDesert.php b/src/world/generator/biome/biomes/BiomeDesert.php
deleted file mode 100644
index 35865cc1..00000000
--- a/src/world/generator/biome/biomes/BiomeDesert.php
+++ /dev/null
@@ -1,14 +0,0 @@
-setMinMax(63, 74);
- }
-
- public function createBiomeDecorator(){
- return new DesertBiomeDecorator();
- }
-}
-
diff --git a/src/world/generator/biome/biomes/BiomeExtremeHills.php b/src/world/generator/biome/biomes/BiomeExtremeHills.php
deleted file mode 100644
index 0bc2560f..00000000
--- a/src/world/generator/biome/biomes/BiomeExtremeHills.php
+++ /dev/null
@@ -1,8 +0,0 @@
-setMinMax(63, 127);
- }
-}
diff --git a/src/world/generator/biome/biomes/BiomeExtremeHillsEdge.php b/src/world/generator/biome/biomes/BiomeExtremeHillsEdge.php
deleted file mode 100644
index 54a4766c..00000000
--- a/src/world/generator/biome/biomes/BiomeExtremeHillsEdge.php
+++ /dev/null
@@ -1,10 +0,0 @@
-setMinMax(63, 97);
- }
-}
-
diff --git a/src/world/generator/biome/biomes/BiomeForest.php b/src/world/generator/biome/biomes/BiomeForest.php
deleted file mode 100644
index 709f889f..00000000
--- a/src/world/generator/biome/biomes/BiomeForest.php
+++ /dev/null
@@ -1,19 +0,0 @@
-setMinMax(63, 81);
- }
-
- public function getTree(Random $random){
- $f = $random->nextFloat();
- if($f > 0.75){
- return new SmallTreeObject(SaplingBlock::BIRCH);
- }
- return new SmallTreeObject(SaplingBlock::OAK);
- }
-}
-
diff --git a/src/world/generator/biome/biomes/BiomeIcePlains.php b/src/world/generator/biome/biomes/BiomeIcePlains.php
deleted file mode 100644
index 0724f35c..00000000
--- a/src/world/generator/biome/biomes/BiomeIcePlains.php
+++ /dev/null
@@ -1,11 +0,0 @@
-setMinMax(63, 74);
- }
-}
-
diff --git a/src/world/generator/biome/biomes/BiomeJungle.php b/src/world/generator/biome/biomes/BiomeJungle.php
deleted file mode 100644
index 87e5a097..00000000
--- a/src/world/generator/biome/biomes/BiomeJungle.php
+++ /dev/null
@@ -1,14 +0,0 @@
-setMinMax(63, 81);
- }
-
- public function getTree(Random $random){
- return new SmallTreeObject(SaplingBlock::JUNGLE);
- }
-}
-
diff --git a/src/world/generator/biome/biomes/BiomeOcean.php b/src/world/generator/biome/biomes/BiomeOcean.php
deleted file mode 100644
index da3969b3..00000000
--- a/src/world/generator/biome/biomes/BiomeOcean.php
+++ /dev/null
@@ -1,11 +0,0 @@
-setMinMax(46, 68);
- }
-}
-
diff --git a/src/world/generator/biome/biomes/BiomePlains.php b/src/world/generator/biome/biomes/BiomePlains.php
deleted file mode 100644
index 88506ab2..00000000
--- a/src/world/generator/biome/biomes/BiomePlains.php
+++ /dev/null
@@ -1,12 +0,0 @@
-setMinMax(61, 68);
- }
-
- public function getTree(Random $random){
- return $random->nextInt(10) == 0 ? new SmallTreeObject(SaplingBlock::OAK) : null;
- }
-}
diff --git a/src/world/generator/biome/biomes/BiomeRiver.php b/src/world/generator/biome/biomes/BiomeRiver.php
deleted file mode 100644
index 9f3cd4a1..00000000
--- a/src/world/generator/biome/biomes/BiomeRiver.php
+++ /dev/null
@@ -1,18 +0,0 @@
-setBaseAmount(6);
- $tallGrass = new TallGrass();
- $tallGrass->setBaseAmount(5);
-
- $this->addPopulator($sugarcane);
- $this->addPopulator($tallGrass);
- */
- $this->setMinMax(58, 62);
- }
-}
diff --git a/src/world/generator/biome/biomes/BiomeSwamp.php b/src/world/generator/biome/biomes/BiomeSwamp.php
deleted file mode 100644
index 4461041e..00000000
--- a/src/world/generator/biome/biomes/BiomeSwamp.php
+++ /dev/null
@@ -1,20 +0,0 @@
-setBaseAmount(8);
- $flower->addType([Block::RED_FLOWER, FlowerBlock::TYPE_BLUE_ORCHID]);
-
- $this->addPopulator($flower);
-
- $lilypad = new LilyPad();
- $lilypad->setBaseAmount(4);
- $this->addPopulator($lilypad);
- */
- $this->setMinMax(62, 63);
- }
-}
-
diff --git a/src/world/generator/biome/biomes/BiomeTaiga.php b/src/world/generator/biome/biomes/BiomeTaiga.php
deleted file mode 100644
index ddf9f17e..00000000
--- a/src/world/generator/biome/biomes/BiomeTaiga.php
+++ /dev/null
@@ -1,25 +0,0 @@
-setMinMax(63, 81);
- $this->setTopBlocks([
- [GRASS, 0],
- [DIRT, 0],
- [DIRT, 0],
- [DIRT, 0],
- ]);
- }
-
- public function getTree(Random $random){
- $n = $random->nextInt(3);
- if($n == 0){
- return new PineTreeObject();
- }
- return new SpruceTreeObject();
- }
-}
-
diff --git a/src/world/generator/biome/biomes/BiomeWithGrass.php b/src/world/generator/biome/biomes/BiomeWithGrass.php
deleted file mode 100644
index 3afa81f7..00000000
--- a/src/world/generator/biome/biomes/BiomeWithGrass.php
+++ /dev/null
@@ -1,17 +0,0 @@
-setTopBlocks([
- [GRASS, 0],
- [DIRT, 0],
- [DIRT, 0],
- [DIRT, 0],
- [DIRT, 0],
- ]);
- $this->setFillerBlock(STONE);
- }
-}
-
diff --git a/src/world/generator/biome/biomes/BiomeWithSand.php b/src/world/generator/biome/biomes/BiomeWithSand.php
deleted file mode 100644
index cf790b73..00000000
--- a/src/world/generator/biome/biomes/BiomeWithSand.php
+++ /dev/null
@@ -1,21 +0,0 @@
-setMinMax(63, 81);
- $this->setTopBlocks([
- [SAND, 0],
- [SAND, 0],
- [SAND, 0],
- [SAND, 0],
- [SANDSTONE, 0],
- [SANDSTONE, 0],
- [SANDSTONE, 0],
- [SANDSTONE, 0],
- ]);
- $this->setFillerBlock(STONE);
- }
-}
-
diff --git a/src/world/generator/biome/biomes/BiomeWithSnow.php b/src/world/generator/biome/biomes/BiomeWithSnow.php
deleted file mode 100644
index 6b56e038..00000000
--- a/src/world/generator/biome/biomes/BiomeWithSnow.php
+++ /dev/null
@@ -1,17 +0,0 @@
-setTopBlocks([
- [SNOW_LAYER, 0],
- [GRASS, 0],
- [DIRT, 0],
- [DIRT, 0],
- [DIRT, 0],
- ]);
- $this->setFillerBlock(STONE);
- }
-}
-
diff --git a/src/world/generator/biome/decorator/DesertBiomeDecorator.php b/src/world/generator/biome/decorator/DesertBiomeDecorator.php
deleted file mode 100644
index 4f5054c3..00000000
--- a/src/world/generator/biome/decorator/DesertBiomeDecorator.php
+++ /dev/null
@@ -1,34 +0,0 @@
-nextInt(16);
- $z = $chunkZ*16 + $random->nextInt(16);
- $y = $this->getHighestWorkableBlock($level, $x, $z);
- $level->level->setBlockID($x, $y, $z, DEAD_BUSH);
- }
-
- for($i = 0; $i < 2; ++$i){
- $x = $chunkX*16 + $random->nextInt(16);
- $z = $chunkZ*16 + $random->nextInt(16);
- $y = $this->getHighestWorkableBlock($level, $x, $z);
- $cactiSize = $random->nextRange(0, 3);
- for($yOff = 0; $yOff < $cactiSize; ++$yOff){
- $level->level->setBlockID($x, $y + $yOff, $z, CACTUS);
- }
- }
- }
-
- private function getHighestWorkableBlock(Level $level, $x, $z){
- for($y = 128; $y > 0; --$y){
- $b = $level->level->getBlockID($x, $y, $z);
- if($b == SAND && $level->level->getBlockID($x, $y + 1, $z) == 0){
- return $y + 1;
- }
- }
- return -1;
- }
-}
-
diff --git a/src/world/generator/cave/CaveGenerator.php b/src/world/generator/cave/CaveGenerator.php
deleted file mode 100644
index 38acbd7a..00000000
--- a/src/world/generator/cave/CaveGenerator.php
+++ /dev/null
@@ -1,167 +0,0 @@
-rand->nextInt($this->rand->nextInt($this->rand->nextInt(40) + 1) + 1);
- if($this->rand->nextInt(15) != 0){
- $nextInt = 0;
- }
-
- for($i = 0; $i < $nextInt; ++$i){
- $randX = ($chunkXoffsetted * 16) + $this->rand->nextInt(16);
- $randY = $this->rand->nextInt($this->rand->nextInt(120) + 8);
- $randZ = ($chunkZoffsetted * 16) + $this->rand->nextInt(16);
-
- $i2 = 1;
- if($this->rand->nextInt(4) == 0){
- $this->generateLargeCaveNode($level, $chunkX, $chunkZ, $randX, $randY, $randZ);
- $i2 = 1 + $this->rand->nextInt(4);
- }
-
- for($i3 = 0; $i3 < $i2; ++$i3){
-
- $v17 = $this->rand->nextFloat() * M_PI * 2;
- $v18 = ($this->rand->nextFloat() - 0.5) * 2 / 8;
- $v19 = $this->rand->nextFloat() * 2 + $this->rand->nextFloat();
- if($this->rand->nextInt(10) == 0) {
- $v19 *= $this->rand->nextFloat() * $this->rand->nextFloat() * 3 + 1;
- }
-
-
- $this->generateCaveNode($level, $chunkX, $chunkZ, $randX, $randY, $randZ, $v19, $v17, $v18, 0, 0, 1);
- }
- }
- }
-
- public function generateLargeCaveNode(Level $level, $xCenter, $zCenter, $x, $y, $z){
- $this->generateCaveNode($level, $xCenter, $zCenter, $x, $y, $z, 1 + ($this->rand->nextFloat() * 6), 0, 0, -1, -1, 0.5);
- }
-
- public function generateCaveNode(Level $level, $chunkX, $chunkZ, $x, $y, $z, $randFloat, $f1, $f2, $unk_1, $unk_2, $d3){
- $chunkCenterX = $chunkX*16 + 8;
- $chunkCenterZ = $chunkZ*16 + 8;
- $f = $f3 = 0;
- $random = new MTRandom($this->rand->nextInt());
-
- if($unk_2 <= 0){
- $i = ($this->range * 16) - 16;
- $unk_2 = $i - $random->nextInt((int)($i / 4));
- }
- $z2 = false;
- if($unk_1 == -1){
- $unk_1 = (int)($unk_2 / 2);
- $z2 = true;
- }
-
- $var27 = $random->nextInt((int)($unk_2 / 2)) + ($unk_2 / 4);
- for($var28 = ($random->nextInt(6) == 0); $unk_1 < $unk_2; ++$unk_1){
- $horizontalDiff = 1.5 + sin($unk_1 * M_PI / $unk_2) * $randFloat /* * 1 */;
- $verticalDiff = $horizontalDiff * $d3;
- $var33 = cos($f2);
- $var34 = sin($f2);
- $x += cos($f1) * $var33;
- $y += $var34;
- $z += sin($f1) * $var33;
-
- $f2 = $var28 ? ($f2 * 0.92) : ($f2 * 0.7);
-
- $f2 += $f3 * 0.1;
- $f1 += $f * 0.1;
-
- $f3 *= 0.9;
- $f *= 0.75;
- $f3 += ($random->nextFloat() - $random->nextFloat()) * $random->nextFloat() * 2;
- $f += ($random->nextFloat() - $random->nextFloat()) * $random->nextFloat() * 2;
-
- if(!$z2 && $unk_1 == $var27 && $randFloat > 1 && $unk_2 > 0){
- //this.generateCaveNode(random.nextLong(), chunkX, chunkZ, par5ArrayOfByte, x, y, z, random.nextFloat() * 0.5F + 0.5F, f1 - ((float)Math.PI / 2F), f2 / 3.0F, unk_1, unk_2, 1.0D);
- //this.generateCaveNode(random.nextLong(), chunkX, chunkZ, par5ArrayOfByte, x, y, z, random.nextFloat() * 0.5F + 0.5F, f1 + ((float)Math.PI / 2F), f2 / 3.0F, unk_1, unk_2, 1.0D);
- $this->generateCaveNode($level, $chunkX, $chunkZ, $x, $y, $z, $random->nextFloat() * 0.5 + 0.5, $f1 - (M_PI / 2), $f2 / 3, $unk_1, $unk_2, 1);
- $this->generateCaveNode($level, $chunkX, $chunkZ, $x, $y, $z, $random->nextFloat() * 0.5 + 0.5, $f1 + (M_PI / 2), $f2 / 3, $unk_1, $unk_2, 1);
- return;
- }
-
- if($z2 || $random->nextInt(4) != 0){
- $distFromCenterX = $x - $chunkCenterX;
- $distFromCenterZ = $z - $chunkCenterZ;
-
- $var39 = ($unk_2 - $unk_1);
- $var41 = $randFloat + /*2 + 16*/ 18;
-
- if($distFromCenterX*$distFromCenterX + $distFromCenterZ*$distFromCenterZ - $var39*$var39 > $var41*$var41){
- return;
- }
- //if (x >= chunkCenterX - 16.0D - var29 * 2.0D && z >= chunkCenterZ - 16.0D - var29 * 2.0D && x <= chunkCenterX + 16.0D + var29 * 2.0D && z <= chunkCenterZ + 16.0D + var29 * 2.0D)
- if($x >= $chunkCenterX - 16 - $horizontalDiff*2 && $z >= $chunkCenterZ - 16 - $horizontalDiff*2 && $x <= $chunkCenterX + 16 + $horizontalDiff*2 && $z <= $chunkCenterZ + 16 + $horizontalDiff*2){
- $minX = floor($x - $horizontalDiff) - $chunkX*16 - 1;
- $maxX = floor($x + $horizontalDiff) - $chunkX*16 + 1;
- $minY = floor($y - $verticalDiff) - 1;
- $maxY = floor($y + $verticalDiff) + 1;
- $minZ = floor($z - $horizontalDiff) - $chunkZ*16 - 1;
- $maxZ = floor($z + $horizontalDiff) - $chunkZ*16 + 1;
-
- if($minX < 0) $minX = 0;
- if($maxX > 16) $maxX = 16;
-
- if($minY < 1) $minY = 1;
- if($maxY > 120) $maxY = 120;
-
- if($minZ < 0) $minZ = 0;
- if($maxZ > 16) $maxZ = 16;
-
- $hasWater = false;
- for($blockX = $minX; !$hasWater && $blockX < $maxX; ++$blockX){
- for($blockZ = $minZ; !$hasWater && $blockZ < $maxZ; ++$blockZ){
- for($blockY = $maxY + 1; !$hasWater && $blockY >= $minY - 1; --$blockY){
- if($blockY >= 0 && $blockY < 128){
- $id = $level->level->getBlockID($blockX + $chunkX*16, $blockY, $blockZ + $chunkZ * 16);
- $hasWater = $id == WATER || $id == STILL_WATER;
- //if (blockY != minY - 1 && blockX != minX && blockX != maxX - 1 && blockZ != minZ && blockZ != maxZ - 1)
- if($blockY != $minY - 1 && $blockX != $minX && $blockX != $maxX - 1 && $blockZ != $minZ && $blockZ != $maxZ - 1){
- $blockY = $minY;
- }
- }
- }
- }
- }
-
- if(!$hasWater){
- for($blockX = $minX; $blockX < $maxX; ++$blockX){
- $var59 = (($blockX + $chunkX*16) + 0.5 - $x) / $horizontalDiff;
- for($blockZ = $minZ; $blockZ < $maxZ; ++$blockZ){
- $var46 = (($blockZ + $chunkZ*16) + 0.5 - $z) / $horizontalDiff;
- $yPosition = $maxY;
- $hasGrass = false;
-
- if($var59*$var59 + $var46*$var46 < 1){
- for($blockY = $maxY - 1; $blockY >= $minY; --$blockY){
- $var51 = ($blockY + 0.5 - $y) / $verticalDiff;
- if($var51 > -0.7 && $var59*$var59 + $var51*$var51 + $var46*$var46 < 1){
- $blockID = $level->level->getBlockID($blockX + $chunkX*16, $yPosition, $blockZ + $chunkZ * 16);
- $hasGrass = $blockID == GRASS;
- if($blockID == STONE || $blockID == DIRT || $hasGrass){
- if($blockY < 10){
- $level->level->setBlockID($blockX + $chunkX*16, $yPosition, $blockZ + $chunkZ * 16, LAVA);
- }else{
- $level->level->setBlockID($blockX + $chunkX*16, $yPosition, $blockZ + $chunkZ * 16, 0);
- if($hasGrass && $level->level->getBlockID($blockX + $chunkX*16, $yPosition - 1, $blockZ + $chunkZ * 16) == DIRT){
- //ConsoleAPI::debug("place grass at ".($blockX + $chunkX*16).":".($yPosition - 1).":".($blockZ + $chunkZ * 16));
- $level->level->setBlockID($blockX + $chunkX*16, $yPosition - 1, $blockZ + $chunkZ * 16, GRASS);
- }
- }
- }
- }
- --$yPosition;
- }
- }
- }
- }
- }
- }
- }
- }
- }
-}
-
diff --git a/src/world/generator/cave/MineshaftGenerator.php b/src/world/generator/cave/MineshaftGenerator.php
deleted file mode 100644
index 1e198290..00000000
--- a/src/world/generator/cave/MineshaftGenerator.php
+++ /dev/null
@@ -1,19 +0,0 @@
-rand->nextFloat() < $this->spawnChance && $this->rand->nextInt(80) < max(abs($chunkX), abs($chunkZ));
- if($v) ConsoleAPI::debug("u can spawn mineshaft at $chunkX $chunkZ");
- return $v;
- }
-
- public function getStructureStart(Level $level, $chunkX, $chunkZ)
- {
- return new StructureMineshaftStart($level, $this->rand, $chunkX, $chunkZ);
- }
-}
-
diff --git a/src/world/generator/noise/NoiseGenerator.php b/src/world/generator/noise/NoiseGenerator.php
deleted file mode 100644
index 53408938..00000000
--- a/src/world/generator/noise/NoiseGenerator.php
+++ /dev/null
@@ -1,92 +0,0 @@
-octaves; ++$i){
- $result += $this->getNoise2D($x * $freq, $z * $freq) * $amp;
- $max += $amp;
- $freq *= $frequency;
- $amp *= $amplitude;
- }
- if($normalized === true){
- $result /= $max;
- }
-
- return $result;
- }
-
- public function noise3D($x, $y, $z, $frequency, $amplitude, $normalized = false){
- $result = 0;
- $amp = 1;
- $freq = 1;
- $max = 0;
-
- for($i = 0; $i < $this->octaves; ++$i){
- $result += $this->getNoise3D($x * $freq, $y * $freq, $z * $freq) * $amp;
- $max += $amp;
- $freq *= $frequency;
- $amp *= $amplitude;
- }
- if($normalized === true){
- $result /= $max;
- }
-
- return $result;
- }
-
- public function setOffset($x, $y, $z){
- $this->offsetX = $x;
- $this->offsetY = $y;
- $this->offsetZ = $z;
- }
-}
\ No newline at end of file
diff --git a/src/world/generator/noise/NoiseGeneratorOctaves.php b/src/world/generator/noise/NoiseGeneratorOctaves.php
deleted file mode 100644
index cc977171..00000000
--- a/src/world/generator/noise/NoiseGeneratorOctaves.php
+++ /dev/null
@@ -1,68 +0,0 @@
-generatorCollection = array();
- $this->octaves = (int) $octaves;
- for($o = 0; $o < $this->octaves; ++$o){
- $this->generatorCollection[$o] = new NoiseGeneratorPerlin($random);
- }
- }
-
- public function generateNoiseOctaves($int1, $int2, $int3, $int4, $int5, $int6, $par1 = false, $par2 = false, $par3 = false){
- if($par1 === false or $par2 === false or $par3 === false){
- return $this->generateNoiseOctaves($int1, 10, $int2, $int3, 1, $int4, $int5, 1, $int6);
- }
-
- $floats = array();
- $cnt = $int4 * $int5 * $int6;
- for($i = 0; $i < $cnt; ++$i){
- $floats[$i] = 0;
- }
-
- $d1 = 1;
-
- for($j = 0; $j < $this->octaves; ++$j){
- $d2 = $int1 * $d1 * $par1;
- $d3 = $int2 * $d1 * $par2;
- $d4 = $int3 * $d1 * $par3;
- $l1 = floor($d2);
- $l2 = floor($d4);
- $d2 -= $l1;
- $d4 -= $l2;
- $l1 %= 16777216;
- $l2 %= 16777216;
-
- $d2 += $l1;
- $d4 += $l2;
- $this->generatorCollection[$j]->populateNoiseArray($floats, $d2, $d3, $d4, $int4, $int5, $int6, $par1 * $d1, $par2 * $d1, $par3 * $d1, $d1);
- $d1 /= 2;
- }
- return $floats;
- }
-}
\ No newline at end of file
diff --git a/src/world/generator/noise/NoiseGeneratorPerlin.php b/src/world/generator/noise/NoiseGeneratorPerlin.php
deleted file mode 100644
index c4e8d770..00000000
--- a/src/world/generator/noise/NoiseGeneratorPerlin.php
+++ /dev/null
@@ -1,104 +0,0 @@
-octaves = $octaves;
- $this->offsetX = $random->nextFloat() * 256;
- $this->offsetY = $random->nextFloat() * 256;
- $this->offsetZ = $random->nextFloat() * 256;
-
- for($i = 0; $i < 512; ++$i){
- $this->perm[$i] = 0;
- }
-
- for($i = 0; $i < 256; ++$i){
- $this->perm[$i] = $random->nextRange(0, 255);
- }
-
- for($i = 0; $i < 256; ++$i){
- $pos = $random->nextRange(0, 255 - $i) + $i;
- $old = $this->perm[$i];
-
- $this->perm[$i] = $this->perm[$pos];
- $this->perm[$pos] = $old;
- $this->perm[$i + 256] = $this->perm[$i];
- }
-
- }
-
- public function getNoise3D($x, $y, $z){
- $x += $this->offsetX;
- $y += $this->offsetY;
- $z += $this->offsetZ;
-
- $floorX = floor($x); //normal floor is faster
- $floorY = floor($y);
- $floorZ = floor($z);
-
- $X = $floorX & 0xFF;
- $Y = $floorY & 0xFF;
- $Z = $floorZ & 0xFF;
-
- $x -= $floorX;
- $y -= $floorY;
- $z -= $floorZ;
-
- //Fade curves
- $fX = $x * $x * $x * ($x * ($x * 6 - 15) + 10);
- $fY = $y * $y * $y * ($y * ($y * 6 - 15) + 10);
- $fZ = $z * $z * $z * ($z * ($z * 6 - 15) + 10);
-
- //Cube corners
- $A = $this->perm[$X] + $Y;
- $AA = $this->perm[$A] + $Z;
- $AB = $this->perm[$A + 1] + $Z;
- $B = $this->perm[$X + 1] + $Y;
- $BA = $this->perm[$B] + $Z;
- $BB = $this->perm[$B + 1] + $Z;
-
- return self::lerp($fZ,
- self::lerp($fY,
- self::lerp($fX, self::grad($this->perm[$AA], $x, $y, $z), self::grad($this->perm[$BA], $x - 1, $y, $z)),
- self::lerp($fX, self::grad($this->perm[$AB], $x, $y - 1, $z), self::grad($this->perm[$BB], $x - 1, $y - 1, $z))
- ),
- self::lerp($fY,
- self::lerp($fX, self::grad($this->perm[$AA + 1], $x, $y, $z - 1), self::grad($this->perm[$BA + 1], $x - 1, $y, $z - 1)),
- self::lerp($fX, self::grad($this->perm[$AB + 1], $x, $y - 1, $z - 1), self::grad($this->perm[$BB + 1], $x - 1, $y - 1, $z - 1))
- )
- );
- }
-
- public function getNoise2D($x, $y){
- return $this->getNoise3D($x, $y, 0);
- }
-}
\ No newline at end of file
diff --git a/src/world/generator/noise/NoiseGeneratorSimplex.php b/src/world/generator/noise/NoiseGeneratorSimplex.php
deleted file mode 100644
index 88dbe62d..00000000
--- a/src/world/generator/noise/NoiseGeneratorSimplex.php
+++ /dev/null
@@ -1,282 +0,0 @@
-
- * This is a modified version of the freely published version in the paper by
- * Stefan Gustavson at
- *
- * http://staffwww.itn.liu.se/~stegu/simplexnoise/simplexnoise.pdf
- */
-class NoiseGeneratorSimplex extends NoiseGeneratorPerlin{
- protected static $SQRT_3;
- protected static $SQRT_5;
- protected static $F2;
- protected static $G2;
- protected static $G22;
- protected static $F3;
- protected static $G3;
- protected static $F4;
- protected static $G4;
- protected static $G42;
- protected static $G43;
- protected static $G44;
- protected static $grad4 = [[0, 1, 1, 1],[0, 1, 1, -1],[0, 1, -1, 1],[0, 1, -1, -1],
- [0, -1, 1, 1],[0, -1, 1, -1],[0, -1, -1, 1],[0, -1, -1, -1],
- [1, 0, 1, 1],[1, 0, 1, -1],[1, 0, -1, 1],[1, 0, -1, -1],
- [-1, 0, 1, 1],[-1, 0, 1, -1],[-1, 0, -1, 1],[-1, 0, -1, -1],
- [1, 1, 0, 1],[1, 1, 0, -1],[1, -1, 0, 1],[1, -1, 0, -1],
- [-1, 1, 0, 1],[-1, 1, 0, -1],[-1, -1, 0, 1],[-1, -1, 0, -1],
- [1, 1, 1, 0],[1, 1, -1, 0],[1, -1, 1, 0],[1, -1, -1, 0],
- [-1, 1, 1, 0],[-1, 1, -1, 0],[-1, -1, 1, 0],[-1, -1, -1, 0]];
- protected static $simplex = [
- [0, 1, 2, 3],[0, 1, 3, 2],[0, 0, 0, 0],[0, 2, 3, 1],[0, 0, 0, 0],[0, 0, 0, 0],[0, 0, 0, 0],[1, 2, 3, 0],
- [0, 2, 1, 3],[0, 0, 0, 0],[0, 3, 1, 2],[0, 3, 2, 1],[0, 0, 0, 0],[0, 0, 0, 0],[0, 0, 0, 0],[1, 3, 2, 0],
- [0, 0, 0, 0],[0, 0, 0, 0],[0, 0, 0, 0],[0, 0, 0, 0],[0, 0, 0, 0],[0, 0, 0, 0],[0, 0, 0, 0],[0, 0, 0, 0],
- [1, 2, 0, 3],[0, 0, 0, 0],[1, 3, 0, 2],[0, 0, 0, 0],[0, 0, 0, 0],[0, 0, 0, 0],[2, 3, 0, 1],[2, 3, 1, 0],
- [1, 0, 2, 3],[1, 0, 3, 2],[0, 0, 0, 0],[0, 0, 0, 0],[0, 0, 0, 0],[2, 0, 3, 1],[0, 0, 0, 0],[2, 1, 3, 0],
- [0, 0, 0, 0],[0, 0, 0, 0],[0, 0, 0, 0],[0, 0, 0, 0],[0, 0, 0, 0],[0, 0, 0, 0],[0, 0, 0, 0],[0, 0, 0, 0],
- [2, 0, 1, 3],[0, 0, 0, 0],[0, 0, 0, 0],[0, 0, 0, 0],[3, 0, 1, 2],[3, 0, 2, 1],[0, 0, 0, 0],[3, 1, 2, 0],
- [2, 1, 0, 3],[0, 0, 0, 0],[0, 0, 0, 0],[0, 0, 0, 0],[3, 1, 0, 2],[0, 0, 0, 0],[3, 2, 0, 1],[3, 2, 1, 0]];
- protected $offsetW;
-
- public function __construct(Random $random, $octaves){
- parent::__construct($random, $octaves);
- $this->offsetW = $random->nextFloat() * 256;
- self::$SQRT_3 = sqrt(3);
- self::$SQRT_5 = sqrt(5);
- self::$F2 = 0.5 * (self::$SQRT_3 - 1);
- self::$G2 = (3 - self::$SQRT_3) / 6;
- self::$G22 = self::$G2 * 2.0 - 1;
- self::$F3 = 1.0 / 3.0;
- self::$G3 = 1.0 / 6.0;
- self::$F4 = (self::$SQRT_5 - 1.0) / 4.0;
- self::$G4 = (5.0 - self::$SQRT_5) / 20.0;
- self::$G42 = self::$G4 * 2.0;
- self::$G43 = self::$G4 * 3.0;
- self::$G44 = self::$G4 * 4.0 - 1.0;
- }
-
- protected static function dot2D($g, $x, $y){
- return $g[0] * $x + $g[1] * $y;
- }
-
- protected static function dot3D($g, $x, $y, $z){
- return $g[0] * $x + $g[1] * $y + $g[2] * $z;
- }
-
- protected static function dot4D($g, $x, $y, $z, $w){
- return $g[0] * $x + $g[1] * $y + $g[2] * $z + $g[3] * $w;
- }
-
- public function getNoise3D($x, $y, $z){
- $x += $this->offsetX;
- $y += $this->offsetY;
- $z += $this->offsetZ;
-
- // Skew the input space to determine which simplex cell we're in
- $s = ($x + $y + $z) * self::$F3; // Very nice and simple skew factor for 3D
- $i = floor($x + $s);
- $j = floor($y + $s);
- $k = floor($z + $s);
- $t = ($i + $j + $k) * self::$G3;
- $X0 = $i - $t; // Unskew the cell origin back to (x,y,z) space
- $Y0 = $j - $t;
- $Z0 = $k - $t;
- $x0 = $x - $X0; // The x,y,z distances from the cell origin
- $y0 = $y - $Y0;
- $z0 = $z - $Z0;
-
- // For the 3D case, the simplex shape is a slightly irregular tetrahedron.
-
- // Determine which simplex we are in.
- if($x0 >= $y0){
- if($y0 >= $z0){
- $i1 = 1;
- $j1 = 0;
- $k1 = 0;
- $i2 = 1;
- $j2 = 1;
- $k2 = 0;
- }// X Y Z order
- elseif($x0 >= $z0){
- $i1 = 1;
- $j1 = 0;
- $k1 = 0;
- $i2 = 1;
- $j2 = 0;
- $k2 = 1;
- }// X Z Y order
- else{
- $i1 = 0;
- $j1 = 0;
- $k1 = 1;
- $i2 = 1;
- $j2 = 0;
- $k2 = 1;
- }// Z X Y order
- }else{ // x0perm[$ii + $this->perm[$jj + $this->perm[$kk]]] % 12;
- $gi1 = $this->perm[$ii + $i1 + $this->perm[$jj + $j1 + $this->perm[$kk + $k1]]] % 12;
- $gi2 = $this->perm[$ii + $i2 + $this->perm[$jj + $j2 + $this->perm[$kk + $k2]]] % 12;
- $gi3 = $this->perm[$ii + 1 + $this->perm[$jj + 1 + $this->perm[$kk + 1]]] % 12;
-
- // Calculate the contribution from the four corners
- $t0 = 0.6 - $x0 * $x0 - $y0 * $y0 - $z0 * $z0;
- if($t0 < 0){
- $n0 = 0.0;
- }else{
- $t0 *= $t0;
- $n0 = $t0 * $t0 * self::dot3D(self::$grad3[$gi0], $x0, $y0, $z0);
- }
-
- $t1 = 0.6 - $x1 * $x1 - $y1 * $y1 - $z1 * $z1;
- if($t1 < 0){
- $n1 = 0.0;
- }else{
- $t1 *= $t1;
- $n1 = $t1 * $t1 * self::dot3D(self::$grad3[$gi1], $x1, $y1, $z1);
- }
-
- $t2 = 0.6 - $x2 * $x2 - $y2 * $y2 - $z2 * $z2;
- if($t2 < 0){
- $n2 = 0.0;
- }else{
- $t2 *= $t2;
- $n2 = $t2 * $t2 * self::dot3D(self::$grad3[$gi2], $x2, $y2, $z2);
- }
-
- $t3 = 0.6 - $x3 * $x3 - $y3 * $y3 - $z3 * $z3;
- if($t3 < 0){
- $n3 = 0.0;
- }else{
- $t3 *= $t3;
- $n3 = $t3 * $t3 * self::dot3D(self::$grad3[$gi3], $x3, $y3, $z3);
- }
-
- // Add contributions from each corner to get the noise value.
- // The result is scaled to stay just inside [-1,1]
- return 32.0 * ($n0 + $n1 + $n2 + $n3);
- }
-
- public function getNoise2D($x, $y){
- $x += $this->offsetX;
- $y += $this->offsetY;
-
- // Skew the input space to determine which simplex cell we're in
- $s = ($x + $y) * self::$F2; // Hairy factor for 2D
- $i = floor($x + $s);
- $j = floor($y + $s);
- $t = ($i + $j) * self::$G2;
- $X0 = $i - $t; // Unskew the cell origin back to (x,y) space
- $Y0 = $j - $t;
- $x0 = $x - $X0; // The x,y distances from the cell origin
- $y0 = $y - $Y0;
-
- // For the 2D case, the simplex shape is an equilateral triangle.
-
- // Determine which simplex we are in.
- if($x0 > $y0){
- $i1 = 1;
- $j1 = 0;
- }// lower triangle, XY order: (0,0)->(1,0)->(1,1)
- else{
- $i1 = 0;
- $j1 = 1;
- }// upper triangle, YX order: (0,0)->(0,1)->(1,1)
-
- // A step of (1,0) in (i,j) means a step of (1-c,-c) in (x,y), and
- // a step of (0,1) in (i,j) means a step of (-c,1-c) in (x,y), where
- // c = (3-sqrt(3))/6
-
- $x1 = $x0 - $i1 + self::$G2; // Offsets for middle corner in (x,y) unskewed coords
- $y1 = $y0 - $j1 + self::$G2;
- $x2 = $x0 + self::$G22; // Offsets for last corner in (x,y) unskewed coords
- $y2 = $y0 + self::$G22;
-
- // Work out the hashed gradient indices of the three simplex corners
- $ii = $i & 255;
- $jj = $j & 255;
- $gi0 = $this->perm[$ii + $this->perm[$jj]] % 12;
- $gi1 = $this->perm[$ii + $i1 + $this->perm[$jj + $j1]] % 12;
- $gi2 = $this->perm[$ii + 1 + $this->perm[$jj + 1]] % 12;
-
- // Calculate the contribution from the three corners
- $t0 = 0.5 - $x0 * $x0 - $y0 * $y0;
- if($t0 < 0){
- $n0 = 0.0;
- }else{
- $t0 *= $t0;
- $n0 = $t0 * $t0 * self::dot2D(self::$grad3[$gi0], $x0, $y0); // (x,y) of grad3 used for 2D gradient
- }
-
- $t1 = 0.5 - $x1 * $x1 - $y1 * $y1;
- if($t1 < 0){
- $n1 = 0.0;
- }else{
- $t1 *= $t1;
- $n1 = $t1 * $t1 * self::dot2D(self::$grad3[$gi1], $x1, $y1);
- }
-
- $t2 = 0.5 - $x2 * $x2 - $y2 * $y2;
- if($t2 < 0){
- $n2 = 0.0;
- }else{
- $t2 *= $t2;
- $n2 = $t2 * $t2 * self::dot2D(self::$grad3[$gi2], $x2, $y2);
- }
-
- // Add contributions from each corner to get the noise value.
- // The result is scaled to return values in the interval [-1,1].
- return 70.0 * ($n0 + $n1 + $n2);
- }
-}
\ No newline at end of file
diff --git a/src/world/generator/noise/OctaveGenerator.php b/src/world/generator/noise/OctaveGenerator.php
deleted file mode 100644
index 8424b35d..00000000
--- a/src/world/generator/noise/OctaveGenerator.php
+++ /dev/null
@@ -1,108 +0,0 @@
-octaves = $octaves;
- }
-
- public function setScale($scale){
- $this->setXScale($scale);
- $this->setYScale($scale);
- $this->setZScale($scale);
- }
-
- public function getXScale(){
- return $this->xScale;
- }
-
- public function setXScale($scale){
- $this->xScale = $scale;
- }
-
- public function getYScale(){
- return $this->yScale;
- }
-
- public function setYScale($scale){
- $this->yScale = $scale;
- }
-
- public function getZScale(){
- return $this->zScale;
- }
-
- public function setZScale($scale){
- $this->zScale = $scale;
- }
-
- public function getOctaves(){
- $array = array();
- foreach($this->octaves as $index => $value){
- $array[$index] = clone $value;
- }
- return $array;
- }
-
- //1D-noise
- public function noise1D($x, $frequency, $amplitude, $normalized = false){
- return $this->noise3D($x, 0, 0, $frequency, $amplitude, $normalized);
- }
-
- //2D-noise
- public function noise2D($x, $y, $frequency, $amplitude, $normalized = false){
- return $this->noise3D($x, $y, 0, $frequency, $amplitude, $normalized);
- }
-
- //3D-noise
- public function noise3D($x, $y, $z, $frequency, $amplitude, $normalized = false){
- $result = 0;
- $amp = 1;
- $freq = 1;
- $max = 0;
-
- $x *= $this->xScale;
- $y *= $this->yScale;
- $z *= $this->zScale;
-
- foreach($this->octaves as $octave){
- $result += $octave->noise($x * $freq, $y * $freq, $z * $freq) * $amp;
- $max += $amp;
- $freq *= $frequency;
- $amp *= $amplitude;
- }
- if($normalized === true){
- $result /= $max;
- }
-
- return $result;
- }
-
- /*public function generateNoiseOctaves($x, $y, $z, $frequency, $amplitude){
-
- }*/
-}
\ No newline at end of file
diff --git a/src/world/generator/noise/PerlinOctaveGenerator.php b/src/world/generator/noise/PerlinOctaveGenerator.php
deleted file mode 100644
index 474c4a3f..00000000
--- a/src/world/generator/noise/PerlinOctaveGenerator.php
+++ /dev/null
@@ -1,63 +0,0 @@
-octaves = array();
- for($o = 0; $o < $octaves; ++$o){
- $this->octaves[$o] = new NoiseGeneratorPerlin($random);
- }
- }
-
- /*public function generateNoiseOctaves($x, $y, $z, $sizeX, $sizeY, $sizeZ, $fX, $fY, $fZ){
- $adouble = array_fill(0, $sizeX * $sizeY * $sizeZ, 0.0);
-
- $d3 = 1.0;
-
- foreach($this->octaves as $octave){
- $dX = $x * $d3 * $fX;
- $dY = $y * $d3 * $fY;
- $dZ = $x * $d3 * $fZ;
-
- $x1 = NoiseGenerator::floor($dX);
- $z1 = NoiseGenerator::floor($dZ);
-
- $dX -= $x1;
- $dZ -= $z1;
-
- $x1 %= 16777216;
- $z1 %= 16777216;
- //$x1 &= 0xFFFFFF;
- //$z1 &= 0xFFFFFF;
-
- $dX += $x1;
- $dZ += $z1;
- $octave->populateNoiseArray($adouble, $dX, $dY, $dZ, $sizeX, $sizeY, $sizeZ, $fX * $d3, $fY * $d3, $fZ * $d3, $d3);
- $d3 *= 0.5;
- }
-
- return $adouble;
- }*/
-}
\ No newline at end of file
diff --git a/src/world/generator/object/Feature.php b/src/world/generator/object/Feature.php
deleted file mode 100644
index cb2682a3..00000000
--- a/src/world/generator/object/Feature.php
+++ /dev/null
@@ -1,13 +0,0 @@
-type = $type;
- $this->random = $random;
- }
-
- public function getType(){
- return $this->type;
- }
-
- public function canPlaceObject(Level $level, $x, $y, $z){
- return ($level->level->getBlockID($x, $y, $z) != AIR);
- }
-
- public function placeObject(Level $level, $xVect, $yVect, $zVect){
- $clusterSize = (int) $this->type->clusterSize;
- $angle = $this->random->nextFloat() * M_PI;
- $offset = VectorMath::getDirection2D($angle)->multiply($clusterSize)->divide(8);
- $x1 = $xVect + 8 + $offset->x;
- $x2 = $xVect + 8 - $offset->x;
- $z1 = $zVect + 8 + $offset->y;
- $z2 = $zVect + 8 - $offset->y;
- $y1 = $yVect + $this->random->nextRange(0, 3) + 2;
- $y2 = $yVect + $this->random->nextRange(0, 3) + 2;
- for($count = 0; $count <= $clusterSize; ++$count){
- $seedX = $x1 + ($x2 - $x1) * $count / $clusterSize;
- $seedY = $y1 + ($y2 - $y1) * $count / $clusterSize;
- $seedZ = $z1 + ($z2 - $z1) * $count / $clusterSize;
- $size = ((sin($count * (M_PI / $clusterSize)) + 1) * $this->random->nextFloat() * $clusterSize / 16 + 1) / 2;
-
- $startX = (int) ($seedX - $size);
- $startY = (int) ($seedY - $size);
- $startZ = (int) ($seedZ - $size);
- $endX = (int) ($seedX + $size);
- $endY = (int) ($seedY + $size);
- $endZ = (int) ($seedZ + $size);
-
- for($x = $startX; $x <= $endX; ++$x){
- $sizeX = ($x + 0.5 - $seedX) / $size;
- $sizeX *= $sizeX;
- if($sizeX < 1){
- for($y = $startY; $y <= $endY; ++$y){
- $sizeY = ($y + 0.5 - $seedY) / $size;
- $sizeY *= $sizeY;
- if($y > 0 and ($sizeX + $sizeY) < 1){
- for($z = $startZ; $z <= $endZ; ++$z){
- $sizeZ = ($z + 0.5 - $seedZ) / $size;
- $sizeZ *= $sizeZ;
- if(($sizeX + $sizeY + $sizeZ) < 1 and $level->level->getBlockID($x, $y, $z) === STONE){
- $level->level->setBlock($x, $y, $z, $this->type->material->getID(), $this->type->material->getMetadata());
- }
- }
- }
- }
- }
- }
- }
- }
-
-}
diff --git a/src/world/generator/object/OreType.php b/src/world/generator/object/OreType.php
deleted file mode 100644
index 27f98a75..00000000
--- a/src/world/generator/object/OreType.php
+++ /dev/null
@@ -1,14 +0,0 @@
-material = $material;
- $this->clusterCount = (int) $clusterCount;
- $this->clusterSize = (int) $clusterSize;
- $this->maxHeight = (int) $maxHeight;
- $this->minHeight = (int) $minHeight;
- }
-}
\ No newline at end of file
diff --git a/src/world/generator/object/PondObject.php b/src/world/generator/object/PondObject.php
deleted file mode 100644
index bb6e8caa..00000000
--- a/src/world/generator/object/PondObject.php
+++ /dev/null
@@ -1,21 +0,0 @@
-type = $type;
- $this->random = $random;
- }
-
- public function canPlaceObject(Level $level, Vector3 $pos){
- //todo checking
- return false;
- }
-
- public function placeObject(Level $level, Vector3 $pos){
- $level->setBlockRaw($pos, new WaterBlock());
- }
-}
\ No newline at end of file
diff --git a/src/world/generator/object/feature/DungeonFeature.php b/src/world/generator/object/feature/DungeonFeature.php
deleted file mode 100644
index 4c625c72..00000000
--- a/src/world/generator/object/feature/DungeonFeature.php
+++ /dev/null
@@ -1,82 +0,0 @@
-nextInt(2) + 2;
- $randomSizeZ = $rand->nextInt(2) + 2;
- $var9 = 0;
-
- $minX = $initialX - $randomSizeX - 1;
- $maxX = $initialX + $randomSizeX + 1;
- $minY = $initialY - 1;
- $maxY = $initialY + $baseSize + 1;
- $minZ = $initialZ - $randomSizeZ - 1;
- $maxZ = $initialZ + $randomSizeZ + 1;
-
- for($x = $minX; $x <= $maxX; ++$x){
- for($y = $minY; $y <= $maxY; ++$y){
- for($z = $minZ; $z <= $maxZ; ++$z){
- $id = $level->level->getBlockID($x, $y, $z);
-
- if($y == $minY && !StaticBlock::getIsSolid($id)){
- return false;
- }
-
- if($y == $maxY && !StaticBlock::getIsSolid($id)){
- return false;
- }
-
- if(($x == $minX || $x == $maxX || $z == $minZ || $z == $maxZ) && $y == $initialY && $id == 0 && $level->level->getBlockID($x, $y + 1, $z) == 0){
- ++$var9;
- }
- }
- }
- }
-
- if($var9 < 1 || $var9 > 5) return false;
-
- for($x = $minX; $x <= $maxX; ++$x){
- for($y = $maxY; $y >= $minY; --$y){
- for($z = $minZ; $z <= $maxZ; ++$z){
- $id = $level->level->getBlockID($x, $y, $z);
- if($x != $minX && $y != $minY && $z != $minZ && $x != $maxX && $y != $maxY && $z != $maxZ){
- $level->fastSetBlockUpdate($x, $y, $z, 0, 0);
- }else if($y >= 0 && !StaticBlock::getIsSolid($id)){
- $level->fastSetBlockUpdate($x, $y, $z, 0, 0);
- }else if(StaticBlock::getIsSolid($id)){
- if($y == $minY && $rand->nextInt(4) != 0){
- $level->fastSetBlockUpdate($x, $y, $z, MOSSY_COBBLESTONE, 0);
- }else{
- $level->fastSetBlockUpdate($x, $y, $z, COBBLESTONE, 0);
- }
- }
- }
- }
- }
-
- //TODO chest gen
-
- $level->fastSetBlockUpdate($initialX, $initialY, $initialZ, MONSTER_SPAWNER, 0); //TODO bteter block placement system
- ServerAPI::request()->api->tile->add($level, TILE_MOB_SPAWNER, $initialX, $initialY, $initialZ, [
- "EntityId" => match($rand->nextInt(4)){
- 0 => MOB_SKELETON,
- 1, 2 => MOB_ZOMBIE,
- 3 => MOB_SPIDER
- },
- "id" => TILE_MOB_SPAWNER,
- "x" => $initialX,
- "y" => $initialY,
- "z" => $initialZ,
- ]);
- return true;
- }
-}
-
diff --git a/src/world/generator/object/grass/TallGrassObject.php b/src/world/generator/object/grass/TallGrassObject.php
deleted file mode 100644
index 3b494b2a..00000000
--- a/src/world/generator/object/grass/TallGrassObject.php
+++ /dev/null
@@ -1,24 +0,0 @@
-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){
- $t = $arr[$random->nextRange(0, $arrC)];
- $level->setBlockRaw(new Vector3($x, $pos->y + 1, $z), $t);
- }
- }
- }
-}
\ No newline at end of file
diff --git a/src/world/generator/object/mushroom/HugeBrownMushroomObject.php b/src/world/generator/object/mushroom/HugeBrownMushroomObject.php
deleted file mode 100644
index e69de29b..00000000
diff --git a/src/world/generator/object/mushroom/HugeRedMushroomObject.php b/src/world/generator/object/mushroom/HugeRedMushroomObject.php
deleted file mode 100644
index e69de29b..00000000
diff --git a/src/world/generator/object/tree/AcaciaTreeObject.php b/src/world/generator/object/tree/AcaciaTreeObject.php
deleted file mode 100644
index e77b0973..00000000
--- a/src/world/generator/object/tree/AcaciaTreeObject.php
+++ /dev/null
@@ -1,170 +0,0 @@
-level->getBlockID($x, $y, $z);
- if($id == AIR || $id == LEAVES || $id == LEAVES2){
- $level->fastSetBlockUpdate($x, $y, $z, LEAVES2, 0);
- }
- }
-
- public function placeObject(Level $level, Vector3 $pos, Random $random){ //World p_76484_1_, Random $random, int $pos->x, int $pos->y, int $pos->z
- $var6 = $this->height;
- $var21 = $level->level->getBlockID($pos->x, $pos->y - 1, $pos->z);
-
- if (($var21 == GRASS || $var21 == DIRT) && $pos->y < 128 - $var6 - 1)
- {
- $level->fastSetBlockUpdate($pos->x, $pos->y - 1, $pos->z, DIRT, 0);
- $var22 = $random->nextInt(4);
- $var10 = $var6 - $random->nextInt(4) - 1;
- $var11 = 3 - $random->nextInt(3);
- $var23 = (int)$pos->x;
- $var13 = (int)$pos->z;
- $var14 = (int)0;
- //int var15;
- //int var16;
-
- for ($var15 = 0; $var15 < $var6; ++$var15)
- {
- $var16 = (int)($pos->y + $var15);
-
- if ($var15 >= $var10 && $var11 > 0)
- {
- $var23 += Direction::offsetX[$var22];
- $var13 += Direction::offsetZ[$var22];
- --$var11;
- }
-
- $var17 = $level->level->getBlockID($var23, $var16, $var13);
-
- if ($var17 == AIR || $var17 == LEAVES || $var17 == LEAVES2 || $var17 == SAPLING)
- {
- $level->fastSetBlockUpdate($var23, $var16, $var13, TRUNK2, 0);
- $var14 = $var16;
- }
- }
-
- for ($var15 = -1; $var15 <= 1; ++$var15)
- {
- for ($var16 = -1; $var16 <= 1; ++$var16)
- {
- $this->setBlockWithSomeAdditionalConditions($level, $var23 + $var15, $var14 + 1, $var13 + $var16);
- }
- }
-
- $this->setBlockWithSomeAdditionalConditions($level, $var23 + 2, $var14 + 1, $var13);
- $this->setBlockWithSomeAdditionalConditions($level, $var23 - 2, $var14 + 1, $var13);
- $this->setBlockWithSomeAdditionalConditions($level, $var23, $var14 + 1, $var13 + 2);
- $this->setBlockWithSomeAdditionalConditions($level, $var23, $var14 + 1, $var13 - 2);
-
- for ($var15 = -3; $var15 <= 3; ++$var15)
- {
- for ($var16 = -3; $var16 <= 3; ++$var16)
- {
- if (abs($var15) != 3 || abs($var16) != 3)
- {
- $this->setBlockWithSomeAdditionalConditions($level, $var23 + $var15, $var14, $var13 + $var16);
- }
- }
- }
-
- $var23 = $pos->x;
- $var13 = $pos->z;
- $var15 = $random->nextInt(4);
-
- if ($var15 != $var22)
- {
- $var16 = $var10 - $random->nextInt(2) - 1;
- $var24 = 1 + $random->nextInt(3);
- $var14 = 0;
- //int var18;
- //int var19;
-
- for ($var18 = $var16; $var18 < $var6 && $var24 > 0; --$var24)
- {
- if ($var18 >= 1)
- {
- $var19 = $pos->y + $var18;
- $var23 += Direction::offsetX[$var15];
- $var13 += Direction::offsetZ[$var15];
- $var20 = $level->level->getBlockID($var23, $var19, $var13);
-
- if ($var20 == AIR || $var20 == LEAVES || $var20 == LEAVES2 || $var20 == SAPLING)
- {
- $level->fastSetBlockUpdate($var23, $var19, $var13, TRUNK2, 0);
- $var14 = $var19;
- }
- }
-
- ++$var18;
- }
-
- if ($var14 > 0)
- {
- for ($var18 = -1; $var18 <= 1; ++$var18)
- {
- for ($var19 = -1; $var19 <= 1; ++$var19)
- {
- $this->setBlockWithSomeAdditionalConditions($level, $var23 + $var18, $var14 + 1, $var13 + $var19);
- }
- }
-
- for ($var18 = -2; $var18 <= 2; ++$var18)
- {
- for ($var19 = -2; $var19 <= 2; ++$var19)
- {
- if (abs($var18) != 2 || abs($var19) != 2)
- {
- $this->setBlockWithSomeAdditionalConditions($level, $var23 + $var18, $var14, $var13 + $var19);
- }
- }
- }
- }
- }
-
- return true;
- }
- }
-
- public function canPlaceObject(Level $level, Vector3 $pos, Random $random)
- {
- $var6 = $this->height = ($random->nextInt(3) + $random->nextInt(3) + 5);
- $var7 = true;
-
- if ($pos->y >= 1 && $pos->y + $var6 + 1 <= 128) {
- for ($var8 = $pos->y; $var8 <= $pos->y + 1 + $var6; ++$var8) {
- $var9 = 1;
-
- if ($var8 == $pos->y) {
- $var9 = 0;
- }
-
- if ($var8 >= $pos->y + 1 + $var6 - 2) {
- $var9 = 2;
- }
-
- for ($var10 = (int)($pos->x - $var9); $var10 <= $pos->x + $var9 && $var7; ++$var10) {
- for ($var11 = (int)($pos->z - $var9); $var11 <= $pos->z + $var9 && $var7; ++$var11) {
- if ($var8 >= 0 && $var8 < 128) {
- $var12 = $level->level->getBlockID($var10, $var8, $var11);
-
- if (! $this->isBlockCorrect($var12)) {
- return false;
- }
- } else {
- return false;
- }
- }
- }
- }
- return true;
- }
- return false;
- }
-}
\ No newline at end of file
diff --git a/src/world/generator/object/tree/BigTreeObject.php b/src/world/generator/object/tree/BigTreeObject.php
deleted file mode 100644
index a4a34e21..00000000
--- a/src/world/generator/object/tree/BigTreeObject.php
+++ /dev/null
@@ -1,65 +0,0 @@
-trunkHeight = (int) ($this->totalHeight * $this->trunkHeightMultiplier);
- $leaves = $this->getLeafGroupPoints($level, $pos);
- foreach($leaves as $leafGroup){
- $groupX = $leafGroup->getBlockX();
- $groupY = $leafGrou->getBlockY();
- $groupZ = $leafGroup->getBlockZ();
- for($yy = $groupY; $yy < $groupY + $this->leafDistanceLimit; ++$yy){
- $this->generateGroupLayer($level, $groupX, $yy, $groupZ, $this->getLeafGroupLayerSize($yy - $groupY));
- }
- }
- /*final BlockIterator trunk = new BlockIterator(new Point(w, x, y - 1, z), new Point(w, x, y + trunkHeight, z));
- while (trunk.hasNext()) {
- trunk.next().setMaterial(VanillaMaterials.LOG, logMetadata);
- }
- generateBranches(w, x, y, z, leaves);
-
- $level->setBlock($x, $pos->y - 1, $z, 3, 0);
- $this->totalHeight += $random->nextRange(0, 2);
- $this->leavesHeight += mt_rand(0, 1);
- for($yy = ($this->totalHeight - $this->leavesHeight); $yy < ($this->totalHeight + 1); ++$yy){
- $yRadius = ($yy - $this->totalHeight);
- $xzRadius = (int) (($this->radiusIncrease + 1) - $yRadius / 2);
- for($xx = -$xzRadius; $xx < ($xzRadius + 1); ++$xx){
- for($zz = -$xzRadius; $zz < ($xzRadius + 1); ++$zz){
- if((abs($xx) != $xzRadius or abs($zz) != $xzRadius) and $yRadius != 0){
- $level->setBlock($pos->x + $xx, $pos->y + $yy, $pos->z + $zz, 18, $type);
- }
- }
- }
- }
- for($yy = 0; $yy < ($this->totalHeight - 1); ++$yy){
- $level->setBlock($x, $pos->y + $yy, $z, 17, $type);
- }
- */
- }
-
-
-}
\ No newline at end of file
diff --git a/src/world/generator/object/tree/DarkOakTreeObject.php b/src/world/generator/object/tree/DarkOakTreeObject.php
deleted file mode 100644
index e69de29b..00000000
diff --git a/src/world/generator/object/tree/FallenTreeObject.php b/src/world/generator/object/tree/FallenTreeObject.php
deleted file mode 100644
index fbb2ae57..00000000
--- a/src/world/generator/object/tree/FallenTreeObject.php
+++ /dev/null
@@ -1,2 +0,0 @@
-findRandomLeavesSize($random);
- $checkRadius = 0;
- for($yy = 0; $yy < $this->totalHeight; ++$yy){
- if($yy === $this->leavesSizeY){
- $checkRadius = $this->leavesAbsoluteMaxRadius;
- }
- for($xx = -$checkRadius; $xx < ($checkRadius + 1); ++$xx){
- for($zz = -$checkRadius; $zz < ($checkRadius + 1); ++$zz){
- if(!isset($this->overridable[$level->level->getBlockID($pos->x + $xx, $pos->y + $yy, $pos->z + $zz)])){
- return false;
- }
- }
- }
- }
- return true;
- }
-
- private function findRandomLeavesSize(Random $random){
- $this->totalHeight += $random->nextRange(-1, 2);
- $this->leavesSizeY = 1 + $random->nextRange(0, 2);
- $this->leavesAbsoluteMaxRadius = 2 + $random->nextRange(0, 1);
- }
-
- public function placeObject(Level $level, Vector3 $pos, Random $random){
- if($this->leavesSizeY === -1 or $this->leavesAbsoluteMaxRadius === -1){
- $this->findRandomLeavesSize($random);
- }
- $level->setBlockRaw(new Vector3($pos->x, $pos->y - 1, $pos->z), new DirtBlock());
- $leavesRadius = 0;
- $leavesMaxRadius = 1;
- $leavesBottomY = $this->totalHeight - $this->leavesSizeY;
- $firstMaxedRadius = false;
- for($leavesY = 0; $leavesY <= $leavesBottomY; ++$leavesY){
- $yy = $this->totalHeight - $leavesY;
- for($xx = -$leavesRadius; $xx <= $leavesRadius; ++$xx){
- for($zz = -$leavesRadius; $zz <= $leavesRadius; ++$zz){
- if(abs($xx) != $leavesRadius or abs($zz) != $leavesRadius or $leavesRadius <= 0){
- $level->setBlockRaw(new Vector3($pos->x + $xx, $pos->y + $yy, $pos->z + $zz), new LeavesBlock($this->type));
- }
- }
- }
- if($leavesRadius >= $leavesMaxRadius){
- $leavesRadius = $firstMaxedRadius ? 1 : 0;
- $firstMaxedRadius = true;
- if(++$leavesMaxRadius > $this->leavesAbsoluteMaxRadius){
- $leavesMaxRadius = $this->leavesAbsoluteMaxRadius;
- }
- }else{
- ++$leavesRadius;
- }
- }
- $trunkHeightReducer = $random->nextRange(0, 3);
- for($yy = 0; $yy < ($this->totalHeight - $trunkHeightReducer); ++$yy){
- $level->setBlockRaw(new Vector3($pos->x, $pos->y + $yy, $pos->z), new WoodBlock($this->type));
- }
- }
-
-
-}
\ No newline at end of file
diff --git a/src/world/generator/object/tree/SmallTreeObject.php b/src/world/generator/object/tree/SmallTreeObject.php
deleted file mode 100644
index 3cf49e0f..00000000
--- a/src/world/generator/object/tree/SmallTreeObject.php
+++ /dev/null
@@ -1,79 +0,0 @@
-type = $treeType;
- }
- public function canPlaceObject(Level $level, Vector3 $pos, Random $random){
- $radiusToCheck = 0;
- for($yy = 0; $yy < $this->trunkHeight + 3; ++$yy){
- if($yy == 1 or $yy === $this->trunkHeight){
- ++$radiusToCheck;
- }
- for($xx = -$radiusToCheck; $xx < ($radiusToCheck + 1); ++$xx){
- for($zz = -$radiusToCheck; $zz < ($radiusToCheck + 1); ++$zz){
- if(!isset($this->overridable[$level->level->getBlockID($pos->x + $xx, $pos->y + $yy, $pos->z + $zz)])){
- return false;
- }
- }
- }
- }
- return true;
- }
-
- public function placeObject(Level $level, Vector3 $pos, Random $random){
- $this->treeHeight = mt_rand(0, 3) + 4; //randomized tree height
- $x = $pos->getX();
- $y = $pos->getY();
- $z = $pos->getZ();
-
- for($yy = $y - 3 + $this->treeHeight; $yy <= $y + $this->treeHeight; ++$yy){
- $yOff = $yy - ($y + $this->treeHeight);
- $mid = (int) (1 - $yOff / 2);
- for($xx = $x - $mid; $xx <= $x + $mid; ++$xx){
- $xOff = abs($xx - $x);
- for($zz = $z - $mid; $zz <= $z + $mid; ++$zz){
- $zOff = abs($zz - $z);
- if($xOff === $mid and $zOff === $mid and ($yOff === 0 or mt_rand(0, 1) === 0)){
- continue;
- }
- $b = $level->getBlock(new Vector3($xx, $yy, $zz));
- if(($b instanceof LeavesBlock) || $b->getID() == 0){
- $level->setBlockRaw($b, new LeavesBlock($this->type));
- }
- }
- }
- }
- $this->placeTrunk($level, $x, $y, $z, $random, $this->treeHeight - 1);
-
- }
-
- protected function placeTrunk(Level $level, $x, $y, $z, Random $random, $trunkHeight){
- // The base dirt block
- $dirtpos = new Vector3($x, $y - 1, $z);
- $level->setBlockRaw($dirtpos, new DirtBlock());
-
- for($yy = 0; $yy < $this->treeHeight; ++$yy){
- $blockId = $level->getBlock(new Vector3($x, $y + $yy, $z))->getID();
- if(isset($this->overridable[$blockId])){
- $trunkpos = new Vector3($x, $y + $yy, $z);
- $level->setBlockRaw($trunkpos, new WoodBlock($this->type));
- }
- }
- }
-
-}
diff --git a/src/world/generator/object/tree/SpruceTreeObject.php b/src/world/generator/object/tree/SpruceTreeObject.php
deleted file mode 100644
index b496454b..00000000
--- a/src/world/generator/object/tree/SpruceTreeObject.php
+++ /dev/null
@@ -1,64 +0,0 @@
-findRandomLeavesSize($random);
- $checkRadius = 0;
- for($yy = 0; $yy < $this->totalHeight + 2; ++$yy){
- if($yy === $this->leavesBottomY){
- $checkRadius = $this->leavesMaxRadius;
- }
- for($xx = -$checkRadius; $xx < ($checkRadius + 1); ++$xx){
- for($zz = -$checkRadius; $zz < ($checkRadius + 1); ++$zz){
- if(!isset($this->overridable[$level->level->getBlockID($pos->x + $xx, $pos->y + $yy, $pos->z + $zz)])){
- return false;
- }
- }
- }
- }
- return true;
- }
-
- private function findRandomLeavesSize(Random $random){
- $this->totalHeight += $random->nextRange(-1, 2);
- $this->leavesBottomY = (int) ($this->totalHeight - $random->nextRange(1, 2) - 3);
- $this->leavesMaxRadius = 1 + $random->nextRange(0, 1);
- }
-
- public function placeObject(Level $level, Vector3 $pos, Random $random){
- if($this->leavesBottomY === -1 or $this->leavesMaxRadius === -1){
- $this->findRandomLeavesSize();
- }
- $level->setBlockRaw(new Vector3($pos->x, $pos->y - 1, $pos->z), new DirtBlock());
- $leavesRadius = 0;
- for($yy = $this->totalHeight; $yy >= $this->leavesBottomY; --$yy){
- for($xx = -$leavesRadius; $xx <= $leavesRadius; ++$xx){
- for($zz = -$leavesRadius; $zz <= $leavesRadius; ++$zz){
- if(abs($xx) != $leavesRadius or abs($zz) != $leavesRadius or $leavesRadius <= 0){
- $level->setBlockRaw(new Vector3($pos->x + $xx, $pos->y + $yy, $pos->z + $zz), new LeavesBlock($this->type));
- }
- }
- }
- if($leavesRadius > 0 and $yy === ($pos->y + $this->leavesBottomY + 1)){
- --$leavesRadius;
- }elseif($leavesRadius < $this->leavesMaxRadius){
- ++$leavesRadius;
- }
- }
- for($yy = 0; $yy < ($this->totalHeight - 1); ++$yy){
- $level->setBlockRaw(new Vector3($pos->x, $pos->y + $yy, $pos->z), new WoodBlock($this->type));
- }
- }
-
-
-}
\ No newline at end of file
diff --git a/src/world/generator/object/tree/SwampTreeObject.php b/src/world/generator/object/tree/SwampTreeObject.php
deleted file mode 100644
index e69de29b..00000000
diff --git a/src/world/generator/object/tree/TreeObject.php b/src/world/generator/object/tree/TreeObject.php
deleted file mode 100644
index c8210c76..00000000
--- a/src/world/generator/object/tree/TreeObject.php
+++ /dev/null
@@ -1,48 +0,0 @@
- true,
- 6 => true,
- 18 => true,
- ];
- public function isBlockCorrect(int $id)
- {
- return $id == 0 || ($id == LEAVES || $id == LEAVES2) || $id == GRASS || $id == DIRT || $id == TRUNK || $id == TRUNK2 || $id == SAPLING || $id == VINES;
- }
- public static function growTree(Level $level, Vector3 $pos, Random $random, $type = 0){
- switch($type & 0xf){
- case SaplingBlock::SPRUCE:
- if($random->nextRange(0, 1) === 1){
- $tree = new SpruceTreeObject();
- }else{
- $tree = new PineTreeObject();
- }
- break;
- case SaplingBlock::BIRCH:
- $tree = new SmallTreeObject(SaplingBlock::BIRCH);
- break;
- case SaplingBlock::JUNGLE:
- $tree = new SmallTreeObject(SaplingBlock::JUNGLE);
- break;
- case SaplingBlock::ACACIA:
- $tree = new AcaciaTreeObject();
- break;
- case SaplingBlock::DARK_OAK:
-
- break;
- default:
- case SaplingBlock::OAK:
- /*if($random->nextRange(0, 9) === 0){
- $tree = new BigTreeObject();
- }else{*/
- $tree = new SmallTreeObject();
- //}
- break;
- }
- if($tree->canPlaceObject($level, $pos, $random)){
- $tree->placeObject($level, $pos, $random);
- }
- }
-}
\ No newline at end of file
diff --git a/src/world/generator/populator/BiomeBasedTreePopulator.php b/src/world/generator/populator/BiomeBasedTreePopulator.php
deleted file mode 100644
index 5dc5dd31..00000000
--- a/src/world/generator/populator/BiomeBasedTreePopulator.php
+++ /dev/null
@@ -1,33 +0,0 @@
-level = $level;
- $amount = $random->nextRange(0, $this->randomAmount + 1) + $this->baseAmount;
- for($i = 0; $i < $amount; ++$i){
- $x = $random->nextRange($chunkX << 4, ($chunkX << 4) + 15);
- $z = $random->nextRange($chunkZ << 4, ($chunkZ << 4) + 15);
- $biomeID = $level->level->getBiomeId($x, $z);
- $biome = BiomeSelector::get($biomeID);
- $treeFeature = null;
- if($biome instanceof Biome){
- $treeFeature = $biome->getTree($random);
- }
-
- if($treeFeature instanceof TreeObject){
- $y = $this->getHighestWorkableBlock($x, $z);
- if($y === -1){
- continue;
- }
- $v3 = new Vector3($x, $y, $z); //TODO no v3
- if($treeFeature->canPlaceObject($level, $v3, $random)){
- $treeFeature->placeObject($level, $v3, $random);
- }
- }else{
- continue;
- }
- }
- }
-}
-
diff --git a/src/world/generator/populator/CavePopulator.php b/src/world/generator/populator/CavePopulator.php
deleted file mode 100644
index e69de29b..00000000
diff --git a/src/world/generator/populator/FlowerPatchPopulator.php b/src/world/generator/populator/FlowerPatchPopulator.php
deleted file mode 100644
index a844d988..00000000
--- a/src/world/generator/populator/FlowerPatchPopulator.php
+++ /dev/null
@@ -1,45 +0,0 @@
-nextRange(0, 15);
- $z = $chunkZ*16 + $random->nextRange(0, 15);
-
- for($i = 0; $i < 4; ++$i){
- $xPos = ($x + $random->nextRange(0, 7)) - $random->nextRange(0, 7);
- $zPos = ($z + $random->nextRange(0, 7)) - $random->nextRange(0, 7);
- $yPos = $this->getHighestWorkableBlock($level, $xPos, $zPos);
- if($level->level->getBlockID($xPos, $yPos, $zPos) == 0){
- $flowerIDMeta = self::$flowerIDS[$random->nextRange(0, count(self::$flowerIDS)-1)];
- $level->level->setBlock($xPos, $yPos, $zPos, $flowerIDMeta[0], $flowerIDMeta[1]);
- }
- }
- }
-
- private function getHighestWorkableBlock(Level $level, $x, $z){
- for($y = 128; $y > 0; --$y){
- $b = $level->level->getBlockID($x, $y, $z);
- if($b == GRASS || $b == DIRT){
- return $y + 1;
- }
- }
- return -1;
- }
-}
-
diff --git a/src/world/generator/populator/GroundCover.php b/src/world/generator/populator/GroundCover.php
deleted file mode 100644
index 29a05887..00000000
--- a/src/world/generator/populator/GroundCover.php
+++ /dev/null
@@ -1,53 +0,0 @@
-level->getBiomeId($pcx, $pcz));
- $cover = $biome->getTopBlocks();
- if(count($cover) > 0){
- $diffY = 0;
-
- if(!StaticBlock::getIsSolid($cover[0][0])){
- $diffY = 1;
- }
-
- $column = $level->level->getBlockIDsXZ($pcx, $pcz);
- for($y = 127; $y > 0; --$y){
- $chunkY = $y >> 4;
- $b = $column[$chunkY][(($y & 0xf) + ($x << 6) + ($z << 10))];
- if($b !== "\x00" and !StaticBlock::getIsTransparent(ord($b))){
- break;
- }
- }
- $startY = min(127, $y + $diffY);
- $endY = $startY - count($cover);
- for($y = $startY; $y > $endY and $y >= 0; --$y){
- $chunkY = $y >> 4;
- $pair = $cover[$startY - $y];
- //$b = BlockAPI::get($pair[0], $pair[1]);
- $bid = $pair[0];
- $bmeta = $pair[1];
- if($column[$chunkY][(($y & 0xf) + ($x << 6) + ($z << 10))] === "\x00" and StaticBlock::getIsSolid($bid)){
- break;
- }
- if($y <= $waterHeight and $bid == GRASS and $level->level->getBlockID($pcx, $y + 1, $pcz) == STILL_WATER){
- $level->level->setBlock($pcx, $y, $pcz, DIRT, 0);
- continue;
- }
- $level->level->setBlock($pcx, $y, $pcz, $bid, $bmeta);
- }
- }
- }
- }
- }
-
-
-}
-
diff --git a/src/world/generator/populator/MineshaftPopulator.php b/src/world/generator/populator/MineshaftPopulator.php
deleted file mode 100644
index 8087defc..00000000
--- a/src/world/generator/populator/MineshaftPopulator.php
+++ /dev/null
@@ -1,17 +0,0 @@
-nextRange(0, MineshaftPopulator::$ODD) === 0){
- //$mineshaft = new Mineshaft($random);
- }
- }
-
-}
\ No newline at end of file
diff --git a/src/world/generator/populator/OrePopulator.php b/src/world/generator/populator/OrePopulator.php
deleted file mode 100644
index de4ac495..00000000
--- a/src/world/generator/populator/OrePopulator.php
+++ /dev/null
@@ -1,24 +0,0 @@
-oreTypes as $type){
- $ore = new OreObject($random, $type);
- for($i = 0; $i < $ore->type->clusterCount; ++$i){
- $x = $random->nextRange($chunkX << 4, ($chunkX << 4) + 16);
- $y = $random->nextRange($ore->type->minHeight, $ore->type->maxHeight);
- $z = $random->nextRange($chunkZ << 4, ($chunkZ << 4) + 16);
- if($ore->canPlaceObject($level, $x, $y, $z)){
- $ore->placeObject($level, $x, $y, $z);
- }
- }
- }
- }
-
- public function setOreTypes(array $types){
- $this->oreTypes = $types;
- }
-}
\ No newline at end of file
diff --git a/src/world/generator/populator/PondPopulator.php b/src/world/generator/populator/PondPopulator.php
deleted file mode 100644
index d928e185..00000000
--- a/src/world/generator/populator/PondPopulator.php
+++ /dev/null
@@ -1,34 +0,0 @@
-nextRange(0, $this->waterOdd) === 0){
- $v = new Vector3(
- $random->nextRange($chunkX << 4, ($chunkX << 4) + 16),
- $random->nextRange(0, 128),
- $random->nextRange($chunkZ << 4, ($chunkZ << 4) + 16)
- );
- $pond = new PondObject($random, new WaterBlock());
- if($pond->canPlaceObject($level, $v)){
- $pond->placeObject($level, $v);
- }
- }
- }
-
- public function setWaterOdd($waterOdd){
- $this->waterOdd = $waterOdd;
- }
-
- public function setLavaOdd($lavaOdd){
- $this->lavaOdd = $lavaOdd;
- }
-
- public function setLavaSurfaceOdd($lavaSurfaceOdd){
- $this->lavaSurfaceOdd = $lavaSurfaceOdd;
- }
-}
\ No newline at end of file
diff --git a/src/world/generator/populator/StrongholdPopulator.php b/src/world/generator/populator/StrongholdPopulator.php
deleted file mode 100644
index e69de29b..00000000
diff --git a/src/world/generator/populator/TallGrassPopulator.php b/src/world/generator/populator/TallGrassPopulator.php
deleted file mode 100644
index bf55c9ee..00000000
--- a/src/world/generator/populator/TallGrassPopulator.php
+++ /dev/null
@@ -1,69 +0,0 @@
-randomAmount = $amount;
- }
-
- public function setBaseAmount($amount){
- $this->baseAmount = $amount;
- }
-
- public function populate(Level $level, $chunkX, $chunkZ, Random $random){
- $this->level = $level;
- $amount = $random->nextRange(0, $this->randomAmount + 1) + $this->baseAmount;
- for($i = 0; $i < $amount; ++$i){
- $x = $random->nextRange($chunkX << 4, ($chunkX << 4) + 15);
- $z = $random->nextRange($chunkZ << 4, ($chunkZ << 4) + 15);
- for($size = 30; $size > 0; --$size){
- $xx = $x - 7 + $random->nextRange(0, 15);
- $zz = $z - 7 + $random->nextRange(0, 15);
- $yy = $this->getHighestWorkableBlock($xx, $zz);
- if($yy !== -1 and $this->canTallGrassStay($this->level->level->getBlockID($xx, $yy, $zz),$this->level->level->getBlockID($xx, $yy - 1, $zz))){
- if(mt_rand(1,4) == 1){
- $this->level->level->setBlock($xx, $yy, $zz, TALL_GRASS, 2);
- }else{
- $this->level->level->setBlock($xx, $yy, $zz, TALL_GRASS, 1);
- }
- }
- }
- }
- }
-
- private function canTallGrassStay($id, $idbottom){
- return $id === AIR and $idbottom === GRASS;
- }
-
- private function getHighestWorkableBlock($x, $z){
- for($y = 128; $y > 0; --$y){
- $b = $this->level->level->getBlockID($x, $y, $z);
- if($b == GRASS){
- return $y + 1;
- }
- }
- return -1;
- }
-}
\ No newline at end of file
diff --git a/src/world/generator/populator/TreePopulator.php b/src/world/generator/populator/TreePopulator.php
deleted file mode 100644
index 50ade1d4..00000000
--- a/src/world/generator/populator/TreePopulator.php
+++ /dev/null
@@ -1,49 +0,0 @@
-randomAmount = $amount;
- }
-
- public function setBaseAmount($amount){
- $this->baseAmount = $amount;
- }
-
- public function populate(Level $level, $chunkX, $chunkZ, Random $random){
- $this->level = $level;
- $amount = $random->nextRange(0, $this->randomAmount + 1) + $this->baseAmount;
- for($i = 0; $i < $amount; ++$i){
- $x = $random->nextRange($chunkX << 4, ($chunkX << 4) + 15);
- $z = $random->nextRange($chunkZ << 4, ($chunkZ << 4) + 15);
- $y = $this->getHighestWorkableBlock($x, $z);
- if($y === -1){
- continue;
- }
- if($random->nextFloat() > 0.75){
- $meta = SaplingBlock::BIRCH;
- }elseif(($random->nextFloat() < 0.75) and ($random->nextFloat() > 0.25)){
- $meta = SaplingBlock::OAK;
- }else{
- $meta = SaplingBlock::JUNGLE;
- }
- TreeObject::growTree($this->level, new Vector3($x, $y, $z), $random, $meta);
- }
- }
-
- public function getHighestWorkableBlock($x, $z){
- for($y = 128; $y > 0; --$y){
- $b = $this->level->level->getBlockID($x, $y, $z);
- if($b !== DIRT and $b !== GRASS){
- if(--$y <= 0){
- return -1;
- }
- }else{
- break;
- }
- }
- return ++$y;
- }
-}
\ No newline at end of file
diff --git a/src/world/generator/structure/StructureBase.php b/src/world/generator/structure/StructureBase.php
deleted file mode 100644
index 7e8222c5..00000000
--- a/src/world/generator/structure/StructureBase.php
+++ /dev/null
@@ -1,28 +0,0 @@
-rand = new MTRandom();
- }
-
- public function generate(Level $level, $chunkX, $chunkZ){
- $range = $this->range;
- $this->rand->setSeed($level->getSeed());
- $seedInt1 = $this->rand->nextInt();
- $seedInt2 = $this->rand->nextInt();
-
- for($x = $chunkX - $range; $x <= $chunkX + $range; ++$x){
- for($z = $chunkZ - $range; $z <= $chunkZ + $range; ++$z){
- $this->rand->setSeed((($x * $seedInt1) + ($z * $seedInt2)) ^ $level->getSeed());
- $this->recursiveGenerate($level, $x, $z, $chunkX, $chunkZ);
- }
- }
- }
-
- public function recursiveGenerate(Level $level, $chunkXoffsetted, $chunkZoffsetted, $chunkX, $chunkZ){}
-}
-
diff --git a/src/world/generator/structure/StructureComponent.php b/src/world/generator/structure/StructureComponent.php
deleted file mode 100644
index 72806380..00000000
--- a/src/world/generator/structure/StructureComponent.php
+++ /dev/null
@@ -1,301 +0,0 @@
-componentType = $type;
- }
-
- public function buildComponent(StructureComponent $component, $aList, MTRandom $random){}
- public abstract function addComponentParts(Level $level, MTRandom $random, AxisAlignedBB $boundingBox): bool;
-
- /**
- * @param StructureComponent[] $aList
- * @param AxisAlignedBB $boundingBox
- */
- public static function findIntersecting($aList, AxisAlignedBB $boundingBox){
- foreach($aList as $component){
- if($component->boundingBox != null && $component->boundingBox->intersectsWith($boundingBox)){
- return $component;
- }
- }
- return null;
- }
-
- public function getCenter(){
- return new Vector3(
- (int)($this->boundingBox->minX + (($this->boundingBox->maxX - $this->boundingBox->minX + 1) / 2)),
- (int)($this->boundingBox->minY + (($this->boundingBox->maxY - $this->boundingBox->minY + 1) / 2)),
- (int)($this->boundingBox->minZ + (($this->boundingBox->maxZ - $this->boundingBox->minZ + 1) / 2)),
- );
- }
- public function isLiquidInStructureBoundingBox(Level $level, AxisAlignedBB $boundingBox){
- $minX = max($boundingBox->minX - 1, $boundingBox->minX); //TODO optimize?
- $minY = max($boundingBox->minY - 1, $boundingBox->minY);
- $minZ = max($boundingBox->minZ - 1, $boundingBox->minZ);
- $maxX = min($boundingBox->maxX + 1, $boundingBox->maxX);
- $maxY = min($boundingBox->maxY + 1, $boundingBox->maxY);
- $maxZ = min($boundingBox->maxZ + 1, $boundingBox->maxZ);
-
- for($x = $minX; $x <= $maxX; ++$x){
- for($z = $minZ; $z <= $maxZ; ++$z){
- $blockID = $level->level->getBlockID($x, $minY, $z);
- if($blockID > 0 && StaticBlock::getIsLiquid($blockID)) return true;
- $blockID = $level->level->getBlockID($x, $maxY, $z);
- if($blockID > 0 && StaticBlock::getIsLiquid($blockID)) return true;
- }
- }
-
- for($x = $minX; $x <= $maxX; ++$x){
- for($y = $minY; $y <= $maxY; ++$y){
- $blockID = $level->level->getBlockID($x, $y, $minZ);
- if($blockID > 0 && StaticBlock::getIsLiquid($blockID)) return true;
- $blockID = $level->level->getBlockID($x, $y, $maxZ);
- if($blockID > 0 && StaticBlock::getIsLiquid($blockID)) return true;
- }
- }
-
-
- for($z = $minZ; $z <= $maxZ; ++$z){
- for($y = $minY; $y <= $maxY; ++$y){
- $blockID = $level->level->getBlockID($minX, $y, $z);
- if($blockID > 0 && StaticBlock::getIsLiquid($blockID)) return true;
- $blockID = $level->level->getBlockID($maxX, $y, $z);
- if($blockID > 0 && StaticBlock::getIsLiquid($blockID)) return true;
- }
- }
- return false;
- }
-
- public function getXWithOffset($par1, $par2){
- return match($this->coordBaseMode){
- 0, 2 => $this->boundingBox->minX + $par1,
- 1 => $this->boundingBox->maxX - $par2,
- 3 => $this->boundingBox->minX + $par2,
- default => $par1
- };
- }
- public function getYWithOffset($par1){
- return $this->coordBaseMode == -1 ? $par1 : $par1 + $this->boundingBox->minY;
- }
- public function getZWithOffset($par1, $par2){
- return match($this->coordBaseMode){
- 0 => $this->boundingBox->minZ + $par2,
- 1, 3 => $this->boundingBox->minZ + $par1,
- 2 => $this->boundingBox->maxZ - $par2,
- default => $par2
- };
- }
- public function getMetadataWithOffset($blockID, $blockMeta){
- switch($blockID){
- case WOODEN_DOOR_BLOCK:
- case IRON_DOOR_BLOCK:
- switch($this->coordBaseMode){
- case 0:
- return match($blockMeta){
- 0 => 2,
- 2 => 0,
- default => $blockMeta
- };
- case 1:
- return $blockMeta + 1 & 3;
- case 3:
- return $blockMeta + 3 & 3;
- }
-
- break;
- case COBBLESTONE_STAIRS:
- case WOODEN_STAIRS:
- case NETHER_BRICKS_STAIRS:
- case STONE_BRICK_STAIRS:
- case SANDSTONE_STAIRS:
- switch($this->coordBaseMode){
- case 0:
- return match($blockMeta){
- 2 => 3,
- 3 => 2,
- default => $blockMeta
- };
- case 1:
- return match($blockMeta){
- 0 => 2,
- 1 => 3,
- 2 => 0,
- 3 => 1,
- default => $blockMeta
- };
- case 3:
- return match($blockMeta){
- 0 => 2,
- 1 => 3,
- 2 => 1,
- 3 => 0,
- default => $blockMeta
- };
- }
- break;
- case RAIL:
- if($this->coordBaseMode == 1 || $this->coordBaseMode == 3){
- return $blockMeta == 1 ? 0 : 1;
- }
- break;
- case LADDER:
- switch($this->coordBaseMode){
- case 0:
- return match($blockMeta){
- 2 => 3,
- 3 => 2,
- default => $blockMeta
- };
- case 1:
- return match($blockMeta){
- 2 => 4,
- 3 => 5,
- 4 => 2,
- 5 => 3,
- default => $blockMeta
- };
- case 3:
- return match($blockMeta){
- 2 => 5,
- 3 => 4,
- 4 => 2,
- 5 => 3,
- default => $blockMeta
- };
- }
- //case stone_button, not needed
- //case pistonbase, pistonstickybase, level, dispenser, not needed
-
- }
- /* TODO directional blocks, tripwire source(not needed prob)
- * if (this.coordBaseMode == 0)
- {
- if (blockMeta == 0 || blockMeta == 2) return Direction.rotateOpposite[blockMeta];
- }
- else if (this.coordBaseMode == 1)
- {
- if (blockMeta == 2) return 1;
-
- if (blockMeta == 0) return 3;
-
- if (blockMeta == 1) return 2;
-
- if (blockMeta == 3) return 0;
- }
- else if (this.coordBaseMode == 3)
- {
- if (blockMeta == 2) return 3;
- if (blockMeta == 0) return 1;
- if (blockMeta == 1) return 2;
- if (blockMeta == 3) return 0;
- }
- */
- return $blockMeta;
- }
-
- public function placeBlockAtCurrentPosition(Level $level, $blockID, $blockMeta, $par4, $par5, $par6, AxisAlignedBB $boundingBox){
- $x = $this->getXWithOffset($par4, $par6);
- $y = $this->getYWithOffset($par5);
- $z = $this->getZWithOffset($par4, $par6);
-
- if($boundingBox->isXYZInside($x, $y, $z)){
- $level->fastSetBlockUpdate($x, $y, $z, $blockID, $blockMeta);
- }
- }
-
- public function getBlockIdAtCurrentPosition(Level $level, $par2, $par3, $par4, AxisAlignedBB $boundingBox){
- $x = $this->getXWithOffset($par2, $par4);
- $y = $this->getYWithOffset($par3);
- $z = $this->getZWithOffset($par2, $par4);
- return !$boundingBox->isXYZInside($x, $y, $z) ? 0 : $level->level->getBlockID($x, $y, $z);
- }
-
- public function fillWithAir(Level $level, AxisAlignedBB $boundingBox, $minX, $minY, $minZ, $maxX, $maxY, $maxZ){
- for($y = $minY; $y <= $maxY; ++$y){
- for($x = $minX; $x <= $maxX; ++$x){
- for($z = $minZ; $z < $maxZ; ++$z){
- $this->placeBlockAtCurrentPosition($level, AIR, 0, $x, $y, $z, $boundingBox);
- }
- }
- }
- }
-
- public function fillWithBlocks(Level $level, AxisAlignedBB $boundingBox, $minX, $minY, $minZ, $maxX, $maxY, $maxZ, $blockID, $replaceID, $alwaysReplace){
- for($y = $minY; $y <= $maxY; ++$y){
- for($x = $minX; $x <= $maxX; ++$x){
- for($z = $minZ; $z < $maxZ; ++$z){
- if(!$alwaysReplace || $this->getBlockIdAtCurrentPosition($level, $x, $y, $z, $boundingBox) != 0){
- if($y != $minY && $y != $maxY && $x != $minX && $x != $maxX && $z != $minZ && $z != $maxZ){
- $this->placeBlockAtCurrentPosition($level, $replaceID, 0, $x, $y, $z, $boundingBox);
- }else{
- $this->placeBlockAtCurrentPosition($level, $blockID, 0, $x, $y, $z, $boundingBox);
- }
- }
- }
- }
- }
- }
-
- public function fillWithMetadataBlocks(){throw new Exception("Not Implemented");} //TODO it is too long + not used for mineshafts i want now
- public function fillWithRandomizedBlocks(){throw new Exception("Not Implemented");} //TODO it is too long + not used for mineshafts i want now
-
- public function randomlyFillWithBlocks(Level $level, AxisAlignedBB $boundingBox, MTRandom $random, $randomChance, $minX, $minY, $minZ, $maxX, $maxY, $maxZ, $blockID, $replaceID, $alwaysReplace){
- for($y = $minY; $y <= $maxY; ++$y){
- for($x = $minX; $x <= $maxX; ++$x){
- for($z = $minZ; $z < $maxZ; ++$z){
- if($random->nextFloat() <= $randomChance && (!$alwaysReplace || $this->getBlockIdAtCurrentPosition($level, $x, $y, $z, $boundingBox) != 0)){
- if($y != $minY && $y != $maxY && $x != $minX && $x != $maxX && $z != $minZ && $z != $maxZ){
- $this->placeBlockAtCurrentPosition($level, $replaceID, 0, $x, $y, $z, $boundingBox);
- }else{
- $this->placeBlockAtCurrentPosition($level, $blockID, 0, $x, $y, $z, $boundingBox);
- }
- }
- }
- }
- }
- }
-
- public function randomlyPlaceBlock(Level $level, AxisAlignedBB $boundingBox, MTRandom $random, $randomChance, $x, $y, $z, $blockID, $blockMeta){
- if($random->nextFloat() < $randomChance) $this->placeBlockAtCurrentPosition($level, $blockID, $blockMeta, $x, $y, $z, $boundingBox);
- }
-
- public function randomlyRareFillWithBlocks(Level $level, AxisAlignedBB $boundingBox, $minX, $minY, $minZ, $maxX, $maxY, $maxZ, $blockID, $alwaysreplace){
- $v11 = ($maxX - $minX + 1);
- $v12 = ($maxY - $minY + 1);
- $v13 = ($maxZ - $minZ + 1);
- $v14 = $minX + $v11 / 2;
- $v15 = $minZ + $v13 / 2;
-
- for($y = $minY; $y <= $maxY; ++$y){
- $v17 = ($y - $minY) / $v12;
- for($x = $minX; $x <= $maxX; ++$x){
- $v19 = ($x - $v14) / ($v11 * 0.5);
- for($z = $minZ; $z <= $maxZ; ++$z){
- $v21 = ($z - $v15) / ($v13 * 0.5);
-
- if(!$alwaysreplace || $this->getBlockIdAtCurrentPosition($level, $x, $y, $z, $boundingBox) != 0){
- $v22 = $v19*$v19 + $v17*$v17 + $v21*$v21;
-
- if($v22 <= 1.05){
- $this->placeBlockAtCurrentPosition($level, $blockID, 0, $x, $y, $z, $boundingBox);
- }
- }
-
- }
- }
- }
- }
-
- public function clearCurrentPositionBlocksUpwards(){throw new Exception("Not Implemented");} //TODO implement, used for villages
- public function fillCurrentPositionBlocksDownwards(){throw new Exception("Not Implemented");} //TODO implement, used for villages
- public function generateStructureChestContents(){throw new Exception("Not Implemented");} //TODO implement
- public function placeDoorAtCurrentPosition(){throw new Exception("Not Implemented");} //TODO implement
-
-}
-
diff --git a/src/world/generator/structure/StructureGenerator.php b/src/world/generator/structure/StructureGenerator.php
deleted file mode 100644
index 71a7ca9e..00000000
--- a/src/world/generator/structure/StructureGenerator.php
+++ /dev/null
@@ -1,39 +0,0 @@
-structureMap[$chunkXZ])){
- $this->rand->nextInt(); //shouldnt be neccessary, but vanilla has it.
-
- if($this->canSpawnStructureAt($chunkXoffsetted, $chunkZoffsetted)){
- $structureStrat = $this->getStructureStart($level, $chunkXoffsetted, $chunkZoffsetted);
- $this->structureMap[$chunkXZ] = $structureStrat;
- }
-
- }
- }
-
- public function generateStructuresInChunk(Level $level, MTRandom $random, $chunkX, $chunkZ){
- $chunkXCenter = ($chunkX << 4) + 8;
- $chunkZCenter = ($chunkZ << 4) + 8;
- $var7 = false;
- foreach($this->structureMap as $start){
- if($start->isSizeableStructure() && $start->boundingBox->intersectsWith($chunkXCenter, $chunkZCenter, $chunkXCenter + 15, $chunkZCenter + 15)){
- $start->generateStructure($level, $random, new StructureAABB($chunkXCenter, 1, $chunkZCenter, $chunkXCenter + 15, 512, $chunkZCenter + 15));
- $var7 = true;
- }
- }
- return $var7;
- }
-
- public abstract function canSpawnStructureAt($chunkX, $chunkZ);
- public abstract function getStructureStart(Level $level, $chunkX, $chunkZ);
-}
-
diff --git a/src/world/generator/structure/StructureStart.php b/src/world/generator/structure/StructureStart.php
deleted file mode 100644
index 36d3eb17..00000000
--- a/src/world/generator/structure/StructureStart.php
+++ /dev/null
@@ -1,54 +0,0 @@
-components as $k => $component){
- if($component->boundingBox->intersectsWith($boundingBox) && !$component->addComponentParts($level, $random, $boundingBox)){
- unset($this->components[$k]);
- }
- }
- }
-
- public function updateBoundingBox(){
- $this->boundingBox = new StructureAABB(0, 0, 0, 0, 0, 0);
- foreach($this->components as $k => $component){
- $this->boundingBox->expandTo($component->boundingBox);
- }
- }
-
- public function markAvailableHeight(Level $level, MTRandom $random, $height){
- $var4 = 63 - $height;
- $var5 = $this->boundingBox->getYSize() + 1;
-
- if($var5 < $var4) $var5 += $random->nextInt($var4 - $var5);
-
- $var6 = (int)($var5 - $this->boundingBox->maxY);
- $this->boundingBox->offset(0, $var6, 0);
-
- foreach($this->components as $component){
- $component->boundingBox->offset(0, $var6, 0);
- }
- }
-
- public function setRandomHeight(Level $level, MTRandom $random, $par3, $par4){
- $var5 = (int)($par4 - $par3 + 1 - $this->boundingBox->getYSize());
- $var10 = $var5 > 1 ? $par3 + $random->nextInt($var5) : $par3;
- $var6 = (int)($var10 - $this->boundingBox->minY);
- $this->boundingBox->offset(0, $var6, 0);
- foreach($this->components as $component){
- $component->boundingBox->offset(0, $var6, 0);
- }
- }
-
- public function isSizeableStructure(){
- return true;
- }
-}
-
diff --git a/src/world/generator/structure/mineshaft/StructureMineshaftPieces.php b/src/world/generator/structure/mineshaft/StructureMineshaftPieces.php
deleted file mode 100644
index ed004585..00000000
--- a/src/world/generator/structure/mineshaft/StructureMineshaftPieces.php
+++ /dev/null
@@ -1,43 +0,0 @@
-nextInt(100);
-
- /*if($var7 >= 80){
- $var8 = ComponentMineshaftCross //TODO
- if($var8 != null) return new ComponentMineshaftCross($par6, $random, $var8, $par5);
- }else if($var7 >= 70){
- $var8 = ComponentMineshaftStairs //TODO
- if($var8 != null) return new ComponentMineshaftStairs($par6, $random, $var8, $par5);
- }else{
- $var8 = ComponentMineshaftCorridor //TODO
- if($var8 != null) return new ComponentMineshaftCorridor($par6, $random, $var8, $par5);
- }*/
-
- return null;
-
- }
-
- public static function getNextMineShaftComponent(StructureComponent $component, $aList, MTRandom $random, $par3, $par4, $par5, $par6, $par7){
- if($par7 > 8) return null;
-
- if(abs($par3 - $component->boundingBox->minX) <= 80 && abs($par5 - $component->boundingBox->minZ) <= 80){
- $var8 = self::getRandomComponent($aList, $random, $par3, $par4, $par5, $par6, $par7 + 1);
- if($var8 != null){
- $aList[] = $var8;
- $var8->buildComponent($component, $aList, $random);
- }
- return $var8;
- }
-
- return null;
- }
-}
-
diff --git a/src/world/generator/structure/mineshaft/StructureMineshaftStart.php b/src/world/generator/structure/mineshaft/StructureMineshaftStart.php
deleted file mode 100644
index f31a715b..00000000
--- a/src/world/generator/structure/mineshaft/StructureMineshaftStart.php
+++ /dev/null
@@ -1,13 +0,0 @@
-components[] = $var5;
- $var5->buildComponent($var5, $this->components, $random);
- $this->updateBoundingBox();
- $this->markAvailableHeight($level, $random, 10);
- }
-}
-
diff --git a/src/world/generator/structure/mineshaft/component/ComponentMineshaftRoom.php b/src/world/generator/structure/mineshaft/component/ComponentMineshaftRoom.php
deleted file mode 100644
index 4d67d413..00000000
--- a/src/world/generator/structure/mineshaft/component/ComponentMineshaftRoom.php
+++ /dev/null
@@ -1,91 +0,0 @@
-boundingBox = new AxisAlignedBB($par3, 50, $par4, $par3 + 7 + $random->nextInt(6), $par4 + 7, $par4 + 7 + $random->nextInt(6));
- }
-
- public function buildComponent(StructureComponent $component, $aList, MTRandom $random){
- $var4 = $this->componentType;
- $var6 = $this->boundingBox->getYSize() - 3 - 1;
- if($var6 <= 0) $var6 = 1;
-
- for($var5 = 0; $var5 < $this->boundingBox->getXSize(); $var5 += 4){
- $var5 += $random->nextInt($this->boundingBox->getXSize());
- if($var5 + 3 < $this->boundingBox->getXSize()) break;
- //var7 = StructureMineshaftPieces.getNextComponent(par1StructureComponent, par2List, par3Random, this.boundingBox.minX + var5, this.boundingBox.minY + par3Random.nextInt(var6) + 1, this.boundingBox.minZ - 1, 2, var4);
- $var7 = StructureMineshaftPieces::getNextMineShaftComponent($component, $aList, $random, $this->boundingBox->minX + $var5, $this->boundingBox->minY + $random->nextInt($var6) + 1, $this->boundingBox->minZ - 1, 2, $var4);
-
- if($var7 != null){
- $var8 = $var7->boundingBox;
- //this.roomsLinkedToTheRoom.add(new StructureBoundingBox(var8.minX, var8.minY, this.boundingBox.minZ, var8.maxX, var8.maxY, this.boundingBox.minZ + 1));
- $this->roomsLinkedToTheRoom[] = new StructureAABB($var8->minX, $var8->minY, $this->boundingBox->minZ, $var8->maxX, $var8->maxY, $this->boundingBox->minZ + 1);
- }
- }
-
- for($var5 = 0; $var5 < $this->boundingBox->getXSize(); $var5 += 4){
- $var5 += $random->nextInt($this->boundingBox->getXSize());
- if($var5 + 3 < $this->boundingBox->getXSize()) break;
- //var7 = StructureMineshaftPieces.getNextComponent(par1StructureComponent, par2List, par3Random, this.boundingBox.minX + var5, this.boundingBox.minY + par3Random.nextInt(var6) + 1, this.boundingBox.maxZ + 1, 0, var4);
- $var7 = StructureMineshaftPieces::getNextMineShaftComponent($component, $aList, $random, $this->boundingBox->minX + $var5, $this->boundingBox->minY + $random->nextInt($var6) + 1, $this->boundingBox->maxZ + 1, 0, $var4);
-
- if($var7 != null){
- $var8 = $var7->boundingBox;
- //this.roomsLinkedToTheRoom.add(new StructureBoundingBox(var8.minX, var8.minY, this.boundingBox.maxZ - 1, var8.maxX, var8.maxY, this.boundingBox.maxZ));
- $this->roomsLinkedToTheRoom[] = new StructureAABB($var8->minX, $var8->minY, $this->boundingBox->maxZ - 1, $var8->maxX, $var8->maxY, $this->boundingBox->maxZ);
- }
- }
-
- for($var5 = 0; $var5 < $this->boundingBox->getZSize(); $var5 += 4){
- $var5 += $random->nextInt($this->boundingBox->getZSize());
- if($var5 + 3 < $this->boundingBox->getZSize()) break;
- //var7 = StructureMineshaftPieces.getNextComponent(par1StructureComponent, par2List, par3Random, this.boundingBox.minX - 1, this.boundingBox.minY + par3Random.nextInt(var6) + 1, this.boundingBox.minZ + var5, 1, var4);
- $var7 = StructureMineshaftPieces::getNextMineShaftComponent($component, $aList, $random, $this->boundingBox->minX - 1, $this->boundingBox->minY + $random->nextInt($var6) + 1, $this->boundingBox->minZ + $var5, 1, $var4);
-
- if($var7 != null){
- $var8 = $var7->boundingBox;
- //this.roomsLinkedToTheRoom.add(new StructureBoundingBox(this.boundingBox.minX, var8.minY, var8.minZ, this.boundingBox.minX + 1, var8.maxY, var8.maxZ));
- $this->roomsLinkedToTheRoom[] = new StructureAABB($this->boundingBox->minX, $var8->minY, $var8->minZ, $this->boundingBox->minX + 1, $var8->maxY, $var8->maxZ);
- }
- }
-
- for($var5 = 0; $var5 < $this->boundingBox->getZSize(); $var5 += 4){
- $var5 += $random->nextInt($this->boundingBox->getZSize());
- if($var5 + 3 < $this->boundingBox->getZSize()) break;
- //var7 = StructureMineshaftPieces.getNextComponent(par1StructureComponent, par2List, par3Random, this.boundingBox.maxX + 1, this.boundingBox.minY + par3Random.nextInt(var6) + 1, this.boundingBox.minZ + var5, 3, var4);
- $var7 = StructureMineshaftPieces::getNextMineShaftComponent($component, $aList, $random, $this->boundingBox->maxX + 1, $this->boundingBox->minY + $random->nextInt($var6) + 1, $this->boundingBox->minZ + $var5, 3, $var4);
-
- if($var7 != null){
- $var8 = $var7->boundingBox;
- // this.roomsLinkedToTheRoom.add(new StructureBoundingBox(this.boundingBox.maxX - 1, var8.minY, var8.minZ, this.boundingBox.maxX, var8.maxY, var8.maxZ));
- $this->roomsLinkedToTheRoom[] = new StructureAABB($this->boundingBox->maxX - 1, $var8->minY, $var8->minZ, $this->boundingBox->maxX, $var8->maxY, $var8->maxZ);
- }
- }
- }
-
- public function addComponentParts(Level $level, MTRandom $random, AxisAlignedBB $boundingBox): bool
- {
- if($this->isLiquidInStructureBoundingBox($level, $boundingBox)){
- return false;
- }
- console("Adding Mineshaft start components! $boundingBox");
- $this->fillWithBlocks($level, $boundingBox, $this->boundingBox->minX, $this->boundingBox->minY, $this->boundingBox->minZ, $this->boundingBox->maxX, $this->boundingBox->maxY, $this->boundingBox->maxZ, DIRT, 0, true);
- $this->fillWithBlocks($level, $boundingBox, $this->boundingBox->minX, $this->boundingBox->minY + 1, $this->boundingBox->minZ, $this->boundingBox->maxX, min($this->boundingBox->minY + 3, $this->boundingBox->maxY), $this->boundingBox->maxZ, 0, 0, false);
-
- foreach($this->roomsLinkedToTheRoom as $bb){
- //this.fillWithBlocks(par1World, par3StructureBoundingBox, var5.minX, var5.maxY - 2, var5.minZ, var5.maxX, var5.maxY, var5.maxZ, 0, 0, false);
- $this->fillWithBlocks($level, $boundingBox, $bb->minX, $bb->maxY - 2, $bb->minZ, $bb->maxX, $bb->maxY, $bb->maxZ, 0, 0, false);
- }
-
- $this->randomlyRareFillWithBlocks($level, $boundingBox, $this->boundingBox->minX, $this->boundingBox->minY + 4, $this->boundingBox->minZ, $this->boundingBox->maxX, $this->boundingBox->maxY, $this->boundingBox->maxZ, 0, false);
- return true;
- }
-}
-
diff --git a/start.cmd b/start.cmd
deleted file mode 100644
index d0585867..00000000
--- a/start.cmd
+++ /dev/null
@@ -1,16 +0,0 @@
-@echo off
-TITLE NostalgiaCore server software for Minecraft: Pocket Edition
-cd /d %~dp0
-if exist bin\php\php.exe (
- if exist bin\mintty.exe (
- start "" bin\mintty.exe -o Columns=88 -o Rows=32 -o AllowBlinking=0 -o FontQuality=3 -o CursorType=0 -o CursorBlinks=1 -h error -t "NostalgiaCore" -i bin/pocketmine.ico -w max bin\php\php.exe -d enable_dl=On PocketMine-MP.php --enable-ansi %*
- ) else (
- bin\php\php.exe -d enable_dl=On PocketMine-MP.php %*
- )
-) else (
- if exist bin\mintty.exe (
- start "" bin\mintty.exe -o Columns=88 -o Rows=32 -o AllowBlinking=0 -o FontQuality=3 -o CursorType=0 -o CursorBlinks=1 -h error -t "NostalgiaCore" -i bin/pocketmine.ico -w max php -d enable_dl=On PocketMine-MP.php --enable-ansi %*
- ) else (
- php -d enable_dl=On PocketMine-MP.php %*
- )
-)
\ No newline at end of file
diff --git a/start.sh b/start.sh
deleted file mode 100644
index e06f3f06..00000000
--- a/start.sh
+++ /dev/null
@@ -1,60 +0,0 @@
-#!/usr/bin/env bash
-DIR="$(cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd)"
-cd "$DIR"
-
-while getopts "p:f:l" OPTION 2> /dev/null; do
- case ${OPTION} in
- p)
- PHP_BINARY="$OPTARG"
- ;;
- f)
- POCKETMINE_FILE="$OPTARG"
- ;;
- l)
- DO_LOOP="yes"
- ;;
- \?)
- break
- ;;
- esac
-done
-
-if [ "$PHP_BINARY" == "" ]; then
- if [ -f ./bin/php7/bin/php ]; then
- export PHPRC=""
- PHP_BINARY="./bin/php7/bin/php"
- elif [[ ! -z $(type php) ]]; then
- PHP_BINARY=$(type -p php)
- else
- echo "Couldn't find a PHP binary in system PATH or $PWD/bin/php5/bin"
- exit 1
- fi
-fi
-
-if [ "$POCKETMINE_FILE" == "" ]; then
- if [ -f ./PocketMine-MP.php ]; then
- POCKETMINE_FILE="./PocketMine-MP.php"
- else
- echo "PocketMine-MP.php not found"
- echo "Downloads can be found at https://github.com/kotyaralih/NostalgiaCore"
- exit 1
- fi
-fi
-
-LOOPS=0
-
-set +e
-
-if [ "$DO_LOOP" == "yes" ]; then
- while true; do
- if [ ${LOOPS} -gt 0 ]; then
- echo "Restarted $LOOPS times"
- fi
- "$PHP_BINARY" "$POCKETMINE_FILE" $@
- echo "To escape the loop, press CTRL+C now. Otherwise, wait 2 seconds for the server to restart."
- sleep 2
- ((LOOPS++))
- done
-else
- exec "$PHP_BINARY" "$POCKETMINE_FILE" $@
-fi