mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-09 03:06:55 +00:00
Compare commits
87 Commits
Alpha_1.3.
...
Alpha_1.3.
Author | SHA1 | Date | |
---|---|---|---|
3d53b9eb3a | |||
f32f379e97 | |||
809ca802b3 | |||
719df75886 | |||
14a40ac11e | |||
c973abc36f | |||
54d37a432e | |||
c7168a6c64 | |||
079d24055d | |||
b1748b5393 | |||
b66f34b308 | |||
1cb711d32d | |||
94a9b7b431 | |||
7acdb0dd3f | |||
fe70fa467d | |||
d4a5e4e5c4 | |||
db289f9871 | |||
b822b314cb | |||
77ca6da14c | |||
9373c93737 | |||
cb47bf82c9 | |||
3498c876df | |||
df01e92ab6 | |||
1f1f955eef | |||
0e471ab38c | |||
9f211bd7fb | |||
af486917a1 | |||
c197a58a3a | |||
ca0d682d87 | |||
70ec644658 | |||
a860f16f4a | |||
9ac72026b9 | |||
0ad0071107 | |||
386b2cb0ef | |||
58fce0e939 | |||
780f60554d | |||
4aa0ae86fb | |||
f005b82a70 | |||
c35c004827 | |||
e179de1613 | |||
3354df0360 | |||
d8cfc06d3a | |||
3b0e553e17 | |||
c53ea830ea | |||
0c1afe15fd | |||
6a24700f6e | |||
000dfc8601 | |||
a011ad8fb6 | |||
d41c30945b | |||
b3c51c6d2e | |||
4ccaccc126 | |||
8aef462a68 | |||
c4a5a9c849 | |||
275e27f7a9 | |||
1abe7626bf | |||
7c9255e21e | |||
0c6eaa0609 | |||
1bc3b66afd | |||
df174d1b8e | |||
f56dd60708 | |||
2271d0b6fc | |||
6d2eea8887 | |||
fb2bcdb722 | |||
c8dd85de75 | |||
a00375b1a9 | |||
e7e05d37b3 | |||
6ac54925ff | |||
555da94612 | |||
774debb299 | |||
9b63a0b0bf | |||
397b47d719 | |||
5952e34995 | |||
0ddc48ca80 | |||
24211764ce | |||
4a2e3d3611 | |||
e5841e623e | |||
215141d552 | |||
94f8cfb59b | |||
41b1a0f991 | |||
08d93fa021 | |||
ce65801d14 | |||
bb9923d210 | |||
ccac35d5a2 | |||
c11ee468a2 | |||
e48126a0c9 | |||
b56ee69f0d | |||
4a46d8fd9c |
1
.gitignore
vendored
1
.gitignore
vendored
@ -3,6 +3,7 @@ worlds/*
|
||||
plugins/*
|
||||
logs/*
|
||||
bin/*
|
||||
.idea/*
|
||||
*.log
|
||||
*.pmf
|
||||
*.txt
|
||||
|
@ -22,6 +22,7 @@
|
||||
|
||||
/***REM_START***/
|
||||
require_once(dirname(__FILE__)."/src/config.php");
|
||||
|
||||
require_once(FILE_PATH."/src/functions.php");
|
||||
require_once(FILE_PATH."/src/dependencies.php");
|
||||
/***REM_END***/
|
||||
@ -30,4 +31,4 @@ $server = new ServerAPI();
|
||||
$server->start();
|
||||
|
||||
kill(getmypid()); //Fix for ConsoleAPI being blocked
|
||||
exit(0);
|
||||
exit(0);
|
||||
|
@ -33,8 +33,9 @@ The entire server is done in PHP, and has been tested, profiled and optimized to
|
||||
|
||||
### [Twitter @PocketMine](https://twitter.com/PocketMine)
|
||||
|
||||
## IRC #pocketmine (or #mcpedevs) @ irc.freenode.net
|
||||
* [WebIRC](http://webchat.freenode.net?channels=pocketmine,mcpedevs&uio=d4)
|
||||
## IRC Chat #pocketmine (or #mcpedevs) @ irc.freenode.net
|
||||
[](https://kiwiirc.com/client/chat.freenode.net/#pocketmine)
|
||||
[](https://kiwiirc.com/client/chat.freenode.net/#mcpedevs)
|
||||
|
||||
|
||||
## Third-party Libraries/Protocols Used
|
||||
@ -47,4 +48,4 @@ The entire server is done in PHP, and has been tested, profiled and optimized to
|
||||
* __[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)__
|
||||
* __[UT3 Query Protocol](http://wiki.unrealadmin.org/UT3_query_protocol)__
|
||||
|
@ -132,14 +132,14 @@ class BanAPI{
|
||||
$user = strtolower($params[0]);
|
||||
$player = $this->server->api->player->get($user);
|
||||
if(!($player instanceof Player)){
|
||||
$this->ops->set($user, false);
|
||||
$this->ops->save($user);
|
||||
$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 not longer op\n";
|
||||
$output .= $player->iusername." is no longer op\n";
|
||||
$this->server->api->chat->sendTo(false, "You are no longer op.", $player->iusername);
|
||||
break;
|
||||
case "kick":
|
||||
|
@ -129,14 +129,14 @@ class BlockAPI{
|
||||
array(DYE, 15), //Bonemeal
|
||||
array(IRON_HOE, 0),
|
||||
array(CAKE, 0),
|
||||
array(EGG, 0),
|
||||
array(IRON_SWORD, 0),
|
||||
array(FLINT_STEEL, 0),
|
||||
array(DIAMOND_SWORD, 0),
|
||||
array(BOW, 0),
|
||||
array(SIGN, 0),
|
||||
array(SPAWN_EGG, MOB_CHICKEN),
|
||||
array(SPAWN_EGG, MOB_COW),
|
||||
array(SPAWN_EGG, MOB_PIG),
|
||||
array(SPAWN_EGG, MOB_SHEEP),
|
||||
array(SPAWN_EGG, MOB_SHEEP),
|
||||
);
|
||||
|
||||
public static function fromString($str, $multiple = false){
|
||||
@ -167,12 +167,11 @@ class BlockAPI{
|
||||
}
|
||||
|
||||
public static function get($id, $meta = 0, $v = false){
|
||||
$id = (int) $id;
|
||||
if(isset(Block::$class[$id])){
|
||||
$classname = Block::$class[$id];
|
||||
$b = new $classname($meta);
|
||||
}else{
|
||||
$b = new GenericBlock($id, $meta);
|
||||
$b = new GenericBlock((int) $id, $meta);
|
||||
}
|
||||
if($v instanceof Position){
|
||||
$b->position($v);
|
||||
@ -270,7 +269,7 @@ class BlockAPI{
|
||||
if($target->onBreak($item, $player) === false){
|
||||
return $this->cancelAction($target, $player, false);
|
||||
}
|
||||
if($item->useOn($target) and ($player->gamemode & 0x01) === 0 and $item->getMetadata() >= $item->getMaxDurability()){
|
||||
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{
|
||||
|
@ -204,9 +204,26 @@ class ConsoleAPI{
|
||||
break;
|
||||
case "a":
|
||||
case "all":
|
||||
$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);
|
||||
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":
|
||||
@ -256,7 +273,7 @@ class ConsoleAPI{
|
||||
return;
|
||||
}
|
||||
if($this->loop->line !== false){
|
||||
$line = trim($this->loop->line);
|
||||
$line = preg_replace("#\\x1b\\x5b([^\\x1b]*\\x7e|[\\x40-\\x50])#", "", trim($this->loop->line));
|
||||
$this->loop->line = false;
|
||||
$output = $this->run($line, "console");
|
||||
if($output != ""){
|
||||
|
@ -101,6 +101,9 @@ class PlayerAPI{
|
||||
case "fall":
|
||||
$message = " hit the ground too hard";
|
||||
break;
|
||||
case "explosion":
|
||||
$message = " blew up";
|
||||
break;
|
||||
default:
|
||||
$message = " died";
|
||||
break;
|
||||
|
@ -85,7 +85,7 @@ class PluginAPI extends stdClass{
|
||||
return false;
|
||||
}
|
||||
if(eval($info["code"]) === false or ($info["class"] !== "none" and !class_exists($info["class"]))){
|
||||
console("[ERROR] Failed loading plugin: evaluation error");
|
||||
console("[ERROR] Failed loading {$info['name']}: evaluation error");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -121,12 +121,19 @@ class PluginAPI extends stdClass{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function pluginsPath(){
|
||||
$path = join(DIRECTORY_SEPARATOR, array(DATA_PATH."plugins", ""));
|
||||
@mkdir($path);
|
||||
return $path;
|
||||
}
|
||||
|
||||
|
||||
public function configPath(Plugin $plugin){
|
||||
$p = $this->get($plugin);
|
||||
if($p === false){
|
||||
return false;
|
||||
}
|
||||
$path = DATA_PATH."plugins/".$p[1]["name"]."/";
|
||||
$path = $this->pluginsPath() . $p[1]["name"] . DIRECTORY_SEPARATOR;
|
||||
$this->plugins[$p[1]["class"]][1]["path"] = $path;
|
||||
@mkdir($path);
|
||||
return $path;
|
||||
@ -170,12 +177,12 @@ class PluginAPI extends stdClass{
|
||||
}
|
||||
|
||||
public function loadAll(){
|
||||
$dir = dir(DATA_PATH."plugins/");
|
||||
$dir = dir($this->pluginsPath());
|
||||
while(false !== ($file = $dir->read())){
|
||||
if($file{0} !== "."){
|
||||
$ext = strtolower(substr($file, -3));
|
||||
if($ext === "php" or $ext === "pmf"){
|
||||
$this->load(DATA_PATH."plugins/" . $file);
|
||||
$this->load($dir->path . $file);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -205,4 +212,4 @@ class DummyPlugin implements Plugin{
|
||||
|
||||
public function __destruct(){
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -276,6 +276,10 @@ class ServerAPI{
|
||||
}
|
||||
|
||||
public function init(){
|
||||
if(!(self::$serverRequest instanceof PocketMinecraftServer)){
|
||||
self::$serverRequest = $this->server;
|
||||
}
|
||||
|
||||
if($this->getProperty("send-usage") !== false){
|
||||
$this->server->schedule(6000, array($this, "sendUsage"), array(), true); //Send the info after 5 minutes have passed
|
||||
$this->sendUsage();
|
||||
|
@ -113,7 +113,7 @@ class Player{
|
||||
}
|
||||
|
||||
public function setSpawn(Vector3 $pos){
|
||||
if(!($pos instanceof Level)){
|
||||
if(!($pos instanceof Position)){
|
||||
$level = $this->level;
|
||||
}else{
|
||||
$level = $pos->level;
|
||||
@ -301,7 +301,7 @@ class Player{
|
||||
}
|
||||
}
|
||||
$this->isSleeping = $pos;
|
||||
$this->teleport(new Position($pos->x, $pos->y, $pos->z, $this->level));
|
||||
$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();
|
||||
}
|
||||
@ -351,7 +351,7 @@ class Player{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if($add === 0){
|
||||
if($add <= 0){
|
||||
return false;
|
||||
}
|
||||
$count -= $add;
|
||||
@ -382,7 +382,7 @@ class Player{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if($add === 0){
|
||||
if($add <= 0){
|
||||
return false;
|
||||
}
|
||||
$count -= $add;
|
||||
@ -407,7 +407,7 @@ class Player{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if($remove === 0){
|
||||
if($remove <= 0){
|
||||
return false;
|
||||
}
|
||||
$count -= $remove;
|
||||
@ -746,7 +746,7 @@ class Player{
|
||||
}
|
||||
|
||||
public function teleport(Vector3 $pos, $yaw = false, $pitch = false, $terrain = true, $force = true){
|
||||
if($this->entity instanceof Entity){
|
||||
if($this->entity instanceof Entity and $this->level instanceof Level){
|
||||
$this->entity->check = false;
|
||||
if($yaw === false){
|
||||
$yaw = $this->entity->yaw;
|
||||
@ -1167,7 +1167,7 @@ class Player{
|
||||
}
|
||||
$this->loggedIn = true;
|
||||
|
||||
$u = $this->server->api->player->get($this->iusername);
|
||||
$u = $this->server->api->player->get($this->iusername, false);
|
||||
if($u !== false){
|
||||
$u->close("logged in from another location");
|
||||
}
|
||||
@ -1298,10 +1298,12 @@ class Player{
|
||||
$this->dataPacket(MC_SET_TIME, array(
|
||||
"time" => $this->level->getTime(),
|
||||
));
|
||||
$this->teleport(new Position($this->data->get("position")["x"], $this->data->get("position")["y"], $this->data->get("position")["z"], $this->level));
|
||||
$this->server->schedule(10, array($this, "teleport"), new Position($this->data->get("position")["x"], $this->data->get("position")["y"], $this->data->get("position")["z"], $this->level));
|
||||
$this->server->schedule(20, array($this, "teleport"), new Position($this->data->get("position")["x"], $this->data->get("position")["y"], $this->data->get("position")["z"], $this->level));
|
||||
$this->server->schedule(30, array($this, "teleport"), new Position($this->data->get("position")["x"], $this->data->get("position")["y"], $this->data->get("position")["z"], $this->level));
|
||||
$pos = new Position($this->data->get("position")["x"], $this->data->get("position")["y"], $this->data->get("position")["z"], $this->level);
|
||||
$pos = $this->level->getSafeSpawn($pos);
|
||||
$this->teleport($pos);
|
||||
$this->server->schedule(10, array($this, "teleport"), $pos);
|
||||
$this->server->schedule(20, array($this, "teleport"), $pos);
|
||||
$this->server->schedule(30, array($this, "teleport"), $pos);
|
||||
$this->server->handle("player.spawn", $this);
|
||||
break;
|
||||
case 2://Chunk loaded?
|
||||
@ -1452,6 +1454,53 @@ class Player{
|
||||
"z" => $this->entity->z,
|
||||
);
|
||||
$e = $this->server->api->entity->add($this->level, ENTITY_OBJECT, OBJECT_ARROW, $d);
|
||||
$e->yaw = $this->entity->yaw;
|
||||
$e->pitch = $this->entity->pitch;
|
||||
$rotation = ($this->entity->yaw - 90) % 360;
|
||||
if($rotation < 0){
|
||||
$rotation = (360 + $rotation);
|
||||
}
|
||||
$rotation = ($rotation + 180);
|
||||
if($rotation >= 360){
|
||||
$rotation = ($rotation - 360);
|
||||
}
|
||||
$X = 1;
|
||||
$Z = 1;
|
||||
$overturn = false;
|
||||
if(0 <= $rotation and $rotation < 90){
|
||||
|
||||
}
|
||||
elseif(90 <= $rotation and $rotation < 180){
|
||||
$rotation -= 90;
|
||||
$X = (-1);
|
||||
$overturn = true;
|
||||
}
|
||||
elseif(180 <= $rotation and $rotation < 270){
|
||||
$rotation -= 180;
|
||||
$X = (-1);
|
||||
$Z = (-1);
|
||||
}
|
||||
elseif(270 <= $rotation and $rotation < 360){
|
||||
$rotation -= 270;
|
||||
$Z = (-1);
|
||||
$overturn = true;
|
||||
}
|
||||
$rad = deg2rad($rotation);
|
||||
$pitch = (-($this->entity->pitch));
|
||||
$speed = 80;
|
||||
$speedY = (sin(deg2rad($pitch)) * $speed);
|
||||
$speedXZ = (cos(deg2rad($pitch)) * $speed);
|
||||
if($overturn){
|
||||
$speedX = (sin($rad) * $speedXZ * $X);
|
||||
$speedZ = (cos($rad) * $speedXZ * $Z);
|
||||
}
|
||||
else{
|
||||
$speedX = (cos($rad) * $speedXZ * $X);
|
||||
$speedZ = (sin($rad) * $speedXZ * $Z);
|
||||
}
|
||||
$e->speedX = $speedX;
|
||||
$e->speedZ = $speedZ;
|
||||
$e->speedY = $speedY;
|
||||
$this->server->api->entity->spawnToAll($e);
|
||||
}
|
||||
}
|
||||
@ -1618,6 +1667,7 @@ class Player{
|
||||
}
|
||||
$this->craftingItems = array();
|
||||
$this->toCraft = array();
|
||||
$this->teleport($this->spawnPosition);
|
||||
if($this->entity instanceof Entity){
|
||||
$this->entity->fire = 0;
|
||||
$this->entity->air = 300;
|
||||
@ -1627,7 +1677,6 @@ class Player{
|
||||
break;
|
||||
}
|
||||
$this->sendInventory();
|
||||
$this->teleport($this->spawnPosition);
|
||||
$this->blocked = false;
|
||||
$this->server->handle("player.respawn", $this);
|
||||
break;
|
||||
@ -1718,9 +1767,8 @@ class Player{
|
||||
$this->toCraft = array();
|
||||
if(isset($this->windows[$data["windowid"]])){
|
||||
if(is_array($this->windows[$data["windowid"]])){
|
||||
$all = $this->server->api->player->getAll($this->level);
|
||||
foreach($this->windows[$data["windowid"]] as $ob){
|
||||
$this->server->api->player->broadcastPacket($all, MC_TILE_EVENT, array(
|
||||
$this->server->api->player->broadcastPacket($this->level->players, MC_TILE_EVENT, array(
|
||||
"x" => $ob->x,
|
||||
"y" => $ob->y,
|
||||
"z" => $ob->z,
|
||||
|
@ -1,13 +1,13 @@
|
||||
#!/bin/bash
|
||||
COMPILER_VERSION="0.13"
|
||||
COMPILER_VERSION="0.14"
|
||||
|
||||
PHP_VERSION="5.5.3"
|
||||
PHP_VERSION="5.5.6"
|
||||
ZEND_VM="GOTO"
|
||||
|
||||
LIBEDIT_VERSION="0.3"
|
||||
ZLIB_VERSION="1.2.8"
|
||||
PTHREADS_VERSION="0.0.44"
|
||||
CURL_VERSION="curl-7_32_0"
|
||||
PTHREADS_VERSION="0.0.45"
|
||||
CURL_VERSION="curl-7_33_0"
|
||||
|
||||
echo "[PocketMine] PHP installer and compiler for Linux & Mac"
|
||||
DIR="$(pwd)"
|
||||
@ -78,6 +78,9 @@ elif [ "$1" == "crosscompile" ]; then
|
||||
fi
|
||||
else
|
||||
echo "[INFO] Compiling for current machine"
|
||||
if [ $(uname -m) == "x86_64" ]; then
|
||||
CFLAGS="-mx32 $CFLAGS"
|
||||
fi
|
||||
fi
|
||||
|
||||
type $CC >> "$DIR/install.log" 2>&1 || { echo >&2 "[ERROR] Please install \"$CC\""; read -p "Press [Enter] to continue..."; exit 1; }
|
||||
|
@ -28,7 +28,7 @@ if(strpos(" ".strtoupper(php_uname("s")), " WIN") !== false){
|
||||
exec("time.exe /T", $hour);
|
||||
$i = array_map("intval", explode(":", trim($hour[0])));
|
||||
exec("date.exe /T", $date);
|
||||
$j = array_map("intval", explode("/", trim($date[0])));
|
||||
$j = array_map("intval", explode(substr($date[0], 2, 1), trim($date[0])));
|
||||
$offset = round((mktime($i[0], $i[1], 0, $j[1], $j[0], $j[2]) - $time) / 60) * 60;
|
||||
}else{
|
||||
exec("date +%s", $t);
|
||||
@ -59,8 +59,8 @@ set_include_path(get_include_path() . PATH_SEPARATOR . FILE_PATH);
|
||||
ini_set("memory_limit", "128M"); //Default
|
||||
define("LOG", true);
|
||||
define("START_TIME", microtime(true));
|
||||
define("MAJOR_VERSION", "Alpha_1.3.9");
|
||||
define("CURRENT_MINECRAFT_VERSION", "0.7.5 alpha");
|
||||
define("MAJOR_VERSION", "Alpha_1.3.10");
|
||||
define("CURRENT_MINECRAFT_VERSION", "v0.7.6 alpha");
|
||||
define("CURRENT_API_VERSION", 10);
|
||||
define("CURRENT_PHP_VERSION", "5.5");
|
||||
$gitsha1 = false;
|
||||
@ -68,4 +68,4 @@ if(file_exists(FILE_PATH.".git/refs/heads/master")){ //Found Git information!
|
||||
define(GIT_COMMIT, strtolower(trim(file_get_contents(FILE_PATH.".git/refs/heads/master"))));
|
||||
}else{ //Unknown :(
|
||||
define(GIT_COMMIT, str_repeat("00", 20));
|
||||
}
|
||||
}
|
||||
|
@ -62,6 +62,7 @@ define("ENTITY_MOB", 2);
|
||||
define("MOB_PIGMAN", 36);
|
||||
|
||||
define("ENTITY_OBJECT", 3);
|
||||
define("OBJECT_PRIMEDTNT", 65);
|
||||
define("OBJECT_ARROW", 80);
|
||||
define("OBJECT_PAINTING", 83);
|
||||
|
||||
|
@ -26,7 +26,7 @@ require_once(FILE_PATH."/src/functions.php");
|
||||
/***REM_END***/
|
||||
define(DATA_PATH, realpath(arg("data-path", FILE_PATH))."/");
|
||||
|
||||
if(arg("enable-ansi", strpos(strtoupper(php_uname("s")), "WIN") === false ? true:false) === true){
|
||||
if(arg("enable-ansi", strpos(strtoupper(php_uname("s")), "WIN") === 0 ? false:true) === true and arg("disable-ansi", false) !== true){
|
||||
define("ENABLE_ANSI", true);
|
||||
}else{
|
||||
define("ENABLE_ANSI", false);
|
||||
|
@ -183,7 +183,7 @@ 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 = preg_replace('/\x1b\[[0-9;]*m/', "", $time . $message);
|
||||
$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);
|
||||
}
|
||||
|
@ -131,6 +131,7 @@ abstract class Block extends Position{
|
||||
protected $meta;
|
||||
protected $name;
|
||||
protected $breakTime;
|
||||
protected $hardness;
|
||||
public $isActivable = false;
|
||||
public $breakable = true;
|
||||
public $isFlowable = false;
|
||||
@ -151,6 +152,11 @@ abstract class Block extends Position{
|
||||
$this->meta = (int) $meta;
|
||||
$this->name = $name;
|
||||
$this->breakTime = 0.20;
|
||||
$this->hardness = 10;
|
||||
}
|
||||
|
||||
final public function getHardness(){
|
||||
return ($this->hardness);
|
||||
}
|
||||
|
||||
final public function getName(){
|
||||
|
@ -89,12 +89,30 @@ class DoorBlock extends TransparentBlock{
|
||||
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]);
|
||||
ServerAPI::request()->api->player->broadcastPacket($players, MC_LEVEL_EVENT, array(
|
||||
"x" => $this->x,
|
||||
"y" => $this->y,
|
||||
"z" => $this->z,
|
||||
"evid" => 1003,
|
||||
"data" => 0
|
||||
));
|
||||
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]);
|
||||
ServerAPI::request()->api->player->broadcastPacket($players, MC_LEVEL_EVENT, array(
|
||||
"x" => $this->x,
|
||||
"y" => $this->y,
|
||||
"z" => $this->z,
|
||||
"evid" => 1003,
|
||||
"data" => 0
|
||||
));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ class StairBlock extends TransparentBlock{
|
||||
}else{
|
||||
$this->isFullBlock = false;
|
||||
}
|
||||
$this->hardness = 30;
|
||||
}
|
||||
|
||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
|
@ -24,6 +24,7 @@ class LadderBlock extends TransparentBlock{
|
||||
parent::__construct(LADDER, $meta, "Ladder");
|
||||
$this->isSolid = false;
|
||||
$this->isFullBlock = false;
|
||||
$this->hardness = 2;
|
||||
}
|
||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
if($target->isTransparent === false){
|
||||
@ -41,6 +42,18 @@ class LadderBlock extends TransparentBlock{
|
||||
}
|
||||
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(LADDER, 0, 1));
|
||||
$this->level->setBlock($this, new AirBlock(), true, true, true);
|
||||
return BLOCK_UPDATE_NORMAL;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
return array(
|
||||
array($this->id, 0, 1),
|
||||
|
@ -24,6 +24,7 @@ class SignPostBlock extends TransparentBlock{
|
||||
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){
|
||||
|
@ -22,6 +22,7 @@
|
||||
class TorchBlock extends FlowableBlock{
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(TORCH, $meta, "Torch");
|
||||
$this->hardness = 0;
|
||||
}
|
||||
|
||||
public function onUpdate($type){
|
||||
|
@ -28,6 +28,7 @@ class TrapdoorBlock extends TransparentBlock{
|
||||
}else{
|
||||
$this->isFullBlock = true;
|
||||
}
|
||||
$this->hardness = 15;
|
||||
}
|
||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
if(($target->isTransparent === false or $target->getID() === SLAB) and $face !== 0 and $face !== 1){
|
||||
|
@ -22,6 +22,113 @@
|
||||
class LavaBlock extends LiquidBlock{
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(LAVA, $meta, "Lava");
|
||||
$this->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 getSourceCount(){
|
||||
$count = 0;
|
||||
for($side = 2; $side <= 5; ++$side){
|
||||
if($this->getSide($side) instanceof LavaBlock ){
|
||||
$b = $this->getSide($side);
|
||||
$level = $b->meta & 0x07;
|
||||
if($level == 0x00){
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $count;
|
||||
}
|
||||
|
||||
public function checkWater(){
|
||||
for($side = 1; $side <= 5; ++$side){
|
||||
$b = $this->getSide($side);
|
||||
if($b instanceof WaterBlock){
|
||||
$level = $this->meta & 0x07;
|
||||
if($level == 0x00){
|
||||
$this->level->setBlock($this, new ObsidianBlock(), false, false, true);
|
||||
}else{
|
||||
$this->level->setBlock($this, 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 & 0x07;
|
||||
$level = $this->meta & 0x07;
|
||||
if( ($tlevel + 2) == $level || ($side == 0x01 && $level == 0x01 ) || ($tlevel == 6 && $level == 7 )){
|
||||
return $b;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function onUpdate($type){
|
||||
//return false;
|
||||
$newId = $this->id;
|
||||
$level = $this->meta & 0x07;
|
||||
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($level !== 0x07){
|
||||
if($down instanceof AirBlock || $down instanceof LavaBlock){
|
||||
$this->level->setBlock($down, new LavaBlock(0x01), false, false, true);
|
||||
ServerAPI::request()->api->block->scheduleBlockUpdate(new Position($down, 0, 0, $this->level), 40, BLOCK_UPDATE_NORMAL);
|
||||
}else{
|
||||
for($side = 2; $side <= 5; ++$side){
|
||||
$b = $this->getSide($side);
|
||||
if($b instanceof LavaBlock){
|
||||
|
||||
}else if($b->isFlowable === true){
|
||||
$this->level->setBlock($b, new LavaBlock( min($level + 2,7) ), false, false, true);
|
||||
ServerAPI::request()->api->block->scheduleBlockUpdate(new Position($b, 0, 0, $this->level), 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 & 0x07;
|
||||
if($tlevel != 0x00){
|
||||
$this->level->setBlock($sb, new AirBlock(), false, false, true);
|
||||
}
|
||||
}
|
||||
$b = $this->getSide(0)->getSide($side);
|
||||
if($b instanceof LavaBlock){
|
||||
$tlevel = $b->meta & 0x07;
|
||||
if($tlevel != 0x00){
|
||||
$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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -22,6 +22,7 @@
|
||||
class StillLavaBlock extends LiquidBlock{
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(STILL_LAVA, $meta, "Still Lava");
|
||||
$this->hardness = 500;
|
||||
}
|
||||
|
||||
}
|
@ -27,6 +27,7 @@ require_once("Water.php");
|
||||
class StillWaterBlock extends WaterBlock{
|
||||
public function __construct($meta = 0){
|
||||
LiquidBlock::__construct(STILL_WATER, $meta, "Still Water");
|
||||
$this->hardness = 500;
|
||||
}
|
||||
|
||||
}
|
@ -22,91 +22,117 @@
|
||||
class WaterBlock extends LiquidBlock{
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(WATER, $meta, "Water");
|
||||
}
|
||||
$this->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, 10, BLOCK_UPDATE_NORMAL);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function onUpdate($type){
|
||||
|
||||
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);
|
||||
|
||||
if($falling === 0){
|
||||
$countSources = 0;
|
||||
$maxLevel = $level;
|
||||
$hasPath = false;
|
||||
for($side = 2; $side <= 5; ++$side){
|
||||
$b = $this->getSide($side);
|
||||
if($b->isFlowable === true and $level < 0x07){
|
||||
$d = $b->getSide(0);
|
||||
$this->level->setBlock($b, new WaterBlock($level + 1), false, false, true);
|
||||
ServerAPI::request()->api->block->scheduleBlockUpdate(new Position($b, 0, 0, $this->level), 10, BLOCK_UPDATE_NORMAL);
|
||||
}elseif($b instanceof WaterBlock){
|
||||
$oLevel = $b->getMetadata();
|
||||
$oFalling = $oLevel >> 3;
|
||||
$oLevel &= 0x07;
|
||||
if($oFalling === 0){
|
||||
if($oLevel === 0){
|
||||
++$countSources;
|
||||
$maxLevel = 1;
|
||||
$hasPath = true;
|
||||
}elseif($oLevel < 0x07 and ($oLevel + 1) <= $maxLevel){
|
||||
$maxLevel = $oLevel + 1;
|
||||
$hasPath = true;
|
||||
}elseif(($level + 1) < $oLevel){
|
||||
$from = $this->getFrom();
|
||||
//Has Source or Its Source
|
||||
if($from !== null || $level == 0x00){
|
||||
if($level !== 0x07){
|
||||
if($down instanceof AirBlock || $down instanceof WaterBlock){
|
||||
$this->level->setBlock($down, new WaterBlock(0x01), false, false, true);
|
||||
ServerAPI::request()->api->block->scheduleBlockUpdate(new Position($down, 0, 0, $this->level), 10, BLOCK_UPDATE_NORMAL);
|
||||
}else{
|
||||
for($side = 2; $side <= 5; ++$side){
|
||||
$b = $this->getSide($side);
|
||||
if($b instanceof WaterBlock){
|
||||
if( $this->getSourceCount() >= 2 && $level != 0x00){
|
||||
$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(new Position($b, 0, 0, $this->level), 10, BLOCK_UPDATE_NORMAL);
|
||||
}elseif($level === $oLevel){
|
||||
ServerAPI::request()->api->block->scheduleBlockUpdate(new Position($b, 0, 0, $this->level), 10, BLOCK_UPDATE_NORMAL);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if($countSources >= 2){
|
||||
$level = 0; //Source block
|
||||
}elseif($maxLevel < $level){
|
||||
$level = $maxLevel;
|
||||
}elseif($maxLevel === $level and $level > 0 and $hasPath === false){
|
||||
if($level < 0x07){
|
||||
++$level;
|
||||
}else{
|
||||
$newId = AIR;
|
||||
$level = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($down->isFlowable){
|
||||
$this->level->setBlock($down, new WaterBlock(0b1001), false, false, true);
|
||||
ServerAPI::request()->api->block->scheduleBlockUpdate(new Position($down, 0, 0, $this->level), 5, BLOCK_UPDATE_NORMAL);
|
||||
return false;
|
||||
}elseif($down instanceof LiquidBlock){
|
||||
if($down instanceof WaterBlock and ($down->getMetadata() >> 3) === 0){
|
||||
$this->level->setBlock($down, new WaterBlock(0b1000 & min($down->getMetadata(), 1)), false, false, true);
|
||||
ServerAPI::request()->api->block->scheduleBlockUpdate(new Position($down, 0, 0, $this->level), 5, BLOCK_UPDATE_NORMAL);
|
||||
}
|
||||
}else{
|
||||
$falling = 0;
|
||||
}
|
||||
|
||||
$newMeta = ($falling << 0x03) | $level;
|
||||
if($newMeta !== $this->meta or $newId !== $this->id){
|
||||
$this->id = $newId;
|
||||
$this->meta = $newMeta;
|
||||
$this->level->setBlock($this, $this, false, false, true);
|
||||
ServerAPI::request()->api->block->scheduleBlockUpdate(new Position($this, 0, 0, $this->level), 10, BLOCK_UPDATE_NORMAL);
|
||||
return false;
|
||||
//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){
|
||||
$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){
|
||||
$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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -31,6 +31,7 @@ class AirBlock extends TransparentBlock{
|
||||
$this->hasPhysics = false;
|
||||
$this->isSolid = false;
|
||||
$this->isFullBlock = true;
|
||||
$this->hardness = 0;
|
||||
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,7 @@ class BedBlock extends TransparentBlock{
|
||||
parent::__construct(BED_BLOCK, $type, "Bed Block");
|
||||
$this->isActivable = true;
|
||||
$this->isFullBlock = false;
|
||||
$this->hardness = 1;
|
||||
}
|
||||
|
||||
public function onActivate(Item $item, Player $player){
|
||||
@ -33,7 +34,31 @@ class BedBlock extends TransparentBlock{
|
||||
));
|
||||
return true;
|
||||
}
|
||||
if($player->sleepOn($this) === false){
|
||||
|
||||
$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{
|
||||
$player->dataPacket(MC_CLIENT_MESSAGE, array(
|
||||
"message" => "The bed is incomplete"
|
||||
));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if($player->sleepOn($b) === false){
|
||||
$player->dataPacket(MC_CLIENT_MESSAGE, array(
|
||||
"message" => "This bed is occupied"
|
||||
));
|
||||
|
@ -25,6 +25,7 @@ class FireBlock extends FlowableBlock{
|
||||
$this->isReplaceable = true;
|
||||
$this->breakable = false;
|
||||
$this->isFullBlock = true;
|
||||
$this->hardness = 0;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
|
@ -22,5 +22,27 @@
|
||||
class TNTBlock extends SolidBlock{
|
||||
public function __construct(){
|
||||
parent::__construct(TNT, 0, "TNT");
|
||||
$this->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" => 4,
|
||||
"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;
|
||||
}
|
||||
}
|
@ -25,6 +25,7 @@ class CakeBlock extends TransparentBlock{
|
||||
$this->isFullBlock = false;
|
||||
$this->isActivable = true;
|
||||
$this->meta = $meta & 0x07;
|
||||
$this->hardness = 2.5;
|
||||
}
|
||||
|
||||
public function onUpdate($type){
|
||||
|
@ -24,6 +24,7 @@ class CobwebBlock extends FlowableBlock{
|
||||
parent::__construct(COBWEB, 0, "Cobweb");
|
||||
$this->isSolid = true;
|
||||
$this->isFullBlock = false;
|
||||
$this->hardness = 25;
|
||||
}
|
||||
public function getDrops(Item $item, Player $player){
|
||||
return array();
|
||||
|
@ -23,6 +23,7 @@ class FenceBlock extends TransparentBlock{
|
||||
public function __construct(){
|
||||
parent::__construct(FENCE, 0, "Fence");
|
||||
$this->isFullBlock = false;
|
||||
$this->hardness = 15;
|
||||
}
|
||||
|
||||
}
|
@ -28,6 +28,7 @@ class FenceGateBlock extends TransparentBlock{
|
||||
}else{
|
||||
$this->isFullBlock = false;
|
||||
}
|
||||
$this->hardness = 15;
|
||||
}
|
||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
$faces = array(
|
||||
|
@ -23,6 +23,7 @@ class IronDoorBlock extends DoorBlock{
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(IRON_DOOR_BLOCK, $meta, "Iron Door Block");
|
||||
//$this->isActivable = true;
|
||||
$this->hardness = 25;
|
||||
}
|
||||
|
||||
public function getBreakTime(Item $item, Player $player){
|
||||
|
@ -29,7 +29,6 @@ class SlabBlock extends TransparentBlock{
|
||||
3 => "Cobblestone",
|
||||
4 => "Brick",
|
||||
5 => "Stone Brick",
|
||||
//6 => "Nether Brick",
|
||||
6 => "Quartz",
|
||||
);
|
||||
$this->name = (($this->meta & 0x08) === 0x08 ? "Upper ":"") . $names[$this->meta & 0x07] . " Slab";
|
||||
@ -37,7 +36,8 @@ class SlabBlock extends TransparentBlock{
|
||||
$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){
|
||||
@ -46,6 +46,9 @@ class SlabBlock extends TransparentBlock{
|
||||
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;
|
||||
}
|
||||
@ -53,6 +56,9 @@ class SlabBlock extends TransparentBlock{
|
||||
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){
|
||||
|
@ -25,6 +25,7 @@ class SnowLayerBlock extends FlowableBlock{
|
||||
$this->isReplaceable = true;
|
||||
$this->isSolid = false;
|
||||
$this->isFullBlock = false;
|
||||
$this->hardness = 0.5;
|
||||
}
|
||||
|
||||
public function onUpdate($type){
|
||||
|
@ -23,6 +23,7 @@ class WoodDoorBlock extends DoorBlock{
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(WOOD_DOOR_BLOCK, $meta, "Wood Door Block");
|
||||
$this->isActivable = true;
|
||||
$this->hardness = 15;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
|
@ -23,5 +23,10 @@ class WoodStairsBlock extends StairBlock{
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(WOOD_STAIRS, $meta, "Wood Stairs");
|
||||
}
|
||||
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
return array(
|
||||
array($this->id, 0, 1),
|
||||
);
|
||||
}
|
||||
}
|
@ -22,6 +22,7 @@
|
||||
class CoalOreBlock extends SolidBlock{
|
||||
public function __construct(){
|
||||
parent::__construct(COAL_ORE, 0, "Coal Ore");
|
||||
$this->hardness = 15;
|
||||
}
|
||||
|
||||
public function getBreakTime(Item $item, Player $player){
|
||||
|
@ -22,6 +22,7 @@
|
||||
class DiamondOreBlock extends SolidBlock{
|
||||
public function __construct(){
|
||||
parent::__construct(DIAMOND_ORE, 0, "Diamond Ore");
|
||||
$this->hardness = 15;
|
||||
}
|
||||
|
||||
public function getBreakTime(Item $item, Player $player){
|
||||
|
@ -22,6 +22,7 @@
|
||||
class GlowingRedstoneOreBlock extends SolidBlock{
|
||||
public function __construct(){
|
||||
parent::__construct(GLOWING_REDSTONE_ORE, 0, "Glowing Redstone Ore");
|
||||
$this->hardness = 15;
|
||||
}
|
||||
|
||||
public function onUpdate($type){
|
||||
|
@ -22,6 +22,7 @@
|
||||
class GoldOreBlock extends SolidBlock{
|
||||
public function __construct(){
|
||||
parent::__construct(GOLD_ORE, 0, "Gold Ore");
|
||||
$this->hardness = 15;
|
||||
}
|
||||
|
||||
public function getBreakTime(Item $item, Player $player){
|
||||
|
@ -22,6 +22,7 @@
|
||||
class IronOreBlock extends SolidBlock{
|
||||
public function __construct(){
|
||||
parent::__construct(IRON_ORE, 0, "Iron Ore");
|
||||
$this->hardness = 15;
|
||||
}
|
||||
|
||||
public function getBreakTime(Item $item, Player $player){
|
||||
|
@ -22,6 +22,7 @@
|
||||
class LapisOreBlock extends SolidBlock{
|
||||
public function __construct(){
|
||||
parent::__construct(LAPIS_ORE, 0, "Lapis Ore");
|
||||
$this->hardness = 15;
|
||||
}
|
||||
|
||||
public function getBreakTime(Item $item, Player $player){
|
||||
|
@ -22,6 +22,7 @@
|
||||
class RedstoneOreBlock extends SolidBlock{
|
||||
public function __construct(){
|
||||
parent::__construct(REDSTONE_ORE, 0, "Redstone Ore");
|
||||
$this->hardness = 15;
|
||||
}
|
||||
|
||||
public function onUpdate($type){
|
||||
|
@ -22,6 +22,7 @@
|
||||
class BrownMushroomBlock extends FlowableBlock{
|
||||
public function __construct(){
|
||||
parent::__construct(BROWN_MUSHROOM, 0, "Brown Mushroom");
|
||||
$this->hardness = 0;
|
||||
}
|
||||
|
||||
public function onUpdate($type){
|
||||
|
@ -23,6 +23,7 @@ class CactusBlock extends TransparentBlock{
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(CACTUS, $meta, "Cactus");
|
||||
$this->isFullBlock = false;
|
||||
$this->hardness = 2;
|
||||
}
|
||||
|
||||
public function onUpdate($type){
|
||||
|
@ -22,6 +22,7 @@
|
||||
class CyanFlowerBlock extends FlowableBlock{
|
||||
public function __construct(){
|
||||
parent::__construct(CYAN_FLOWER, 0, "Cyan Flower");
|
||||
$this->hardness = 0;
|
||||
}
|
||||
|
||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
|
@ -22,6 +22,7 @@
|
||||
class DandelionBlock extends FlowableBlock{
|
||||
public function __construct(){
|
||||
parent::__construct(DANDELION, 0, "Dandelion");
|
||||
$this->hardness = 0;
|
||||
}
|
||||
|
||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
|
@ -23,6 +23,7 @@ class DeadBushBlock extends FlowableBlock{
|
||||
public function __construct(){
|
||||
parent::__construct(DEAD_BUSH, 0, "Dead Bush");
|
||||
$this->isReplaceable = true;
|
||||
$this->hardness = 0;
|
||||
}
|
||||
|
||||
public function onUpdate($type){
|
||||
|
@ -23,6 +23,7 @@ class MelonStemBlock extends FlowableBlock{
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(MELON_STEM, $meta, "Melon Stem");
|
||||
$this->isActivable = true;
|
||||
$this->hardness = 0;
|
||||
}
|
||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
$down = $this->getSide(0);
|
||||
|
@ -22,6 +22,7 @@
|
||||
class RedMushroomBlock extends FlowableBlock{
|
||||
public function __construct(){
|
||||
parent::__construct(RED_MUSHROOM, 0, "Red Mushroom");
|
||||
$this->hardness = 0;
|
||||
}
|
||||
|
||||
public function onUpdate($type){
|
||||
|
@ -34,6 +34,7 @@ class SaplingBlock extends FlowableBlock{
|
||||
2 => "Birch Sapling",
|
||||
);
|
||||
$this->name = $names[$this->meta & 0x03];
|
||||
$this->hardness = 0;
|
||||
}
|
||||
|
||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
|
@ -22,6 +22,7 @@
|
||||
class SugarcaneBlock extends FlowableBlock{
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(SUGARCANE_BLOCK, $meta, "Sugarcane");
|
||||
$this->hardness = 0;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
|
@ -29,6 +29,7 @@ class TallGrassBlock extends FlowableBlock{
|
||||
2 => "Fern",
|
||||
);
|
||||
$this->name = $names[$this->meta & 0x03];
|
||||
$this->hardness = 0;
|
||||
}
|
||||
|
||||
public function onUpdate($type){
|
||||
|
@ -23,6 +23,7 @@ class WheatBlock extends FlowableBlock{
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(WHEAT_BLOCK, $meta, "Wheat Block");
|
||||
$this->isActivable = true;
|
||||
$this->hardness = 0;
|
||||
}
|
||||
|
||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
|
@ -23,6 +23,7 @@ class BedrockBlock extends SolidBlock{
|
||||
public function __construct(){
|
||||
parent::__construct(BEDROCK, 0, "Bedrock");
|
||||
$this->breakable = false;
|
||||
$this->hardness = 18000000;
|
||||
}
|
||||
|
||||
public function isBreakable(Item $item, Player $player){
|
||||
|
@ -22,6 +22,7 @@
|
||||
class BookshelfBlock extends SolidBlock{
|
||||
public function __construct(){
|
||||
parent::__construct(BOOKSHELF, 0, "Bookshelf");
|
||||
$this->hardness = 7.5;
|
||||
}
|
||||
|
||||
}
|
@ -22,6 +22,7 @@
|
||||
class BricksBlock extends SolidBlock{
|
||||
public function __construct(){
|
||||
parent::__construct(BRICKS_BLOCK, 0, "Bricks");
|
||||
$this->hardness = 30;
|
||||
}
|
||||
|
||||
public function getBreakTime(Item $item, Player $player){
|
||||
|
@ -23,6 +23,7 @@ class BurningFurnaceBlock extends SolidBlock{
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(BURNING_FURNACE, $meta, "Burning Furnace");
|
||||
$this->isActivable = true;
|
||||
$this->hardness = 17.5;
|
||||
}
|
||||
|
||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
|
@ -23,6 +23,7 @@ class ChestBlock extends TransparentBlock{
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(CHEST, $meta, "Chest");
|
||||
$this->isActivable = true;
|
||||
$this->hardness = 15;
|
||||
}
|
||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
$server = ServerAPI::request();
|
||||
|
@ -22,6 +22,7 @@
|
||||
class ClayBlock extends SolidBlock{
|
||||
public function __construct(){
|
||||
parent::__construct(CLAY_BLOCK, 0, "Clay Block");
|
||||
$this->hardness = 3;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
|
@ -22,6 +22,7 @@
|
||||
class CobblestoneBlock extends SolidBlock{
|
||||
public function __construct(){
|
||||
parent::__construct(COBBLESTONE, 0, "Cobblestone");
|
||||
$this->hardness = 30;
|
||||
}
|
||||
|
||||
public function getBreakTime(Item $item, Player $player){
|
||||
|
@ -22,6 +22,7 @@
|
||||
class DiamondBlock extends SolidBlock{
|
||||
public function __construct(){
|
||||
parent::__construct(DIAMOND_BLOCK, 0, "Diamond Block");
|
||||
$this->hardness = 30;
|
||||
}
|
||||
|
||||
public function getBreakTime(Item $item, Player $player){
|
||||
|
@ -23,6 +23,7 @@ class DirtBlock extends SolidBlock{
|
||||
public function __construct(){
|
||||
parent::__construct(DIRT, 0, "Dirt");
|
||||
$this->isActivable = true;
|
||||
$this->hardness = 2.5;
|
||||
}
|
||||
|
||||
public function onActivate(Item $item, Player $player){
|
||||
|
@ -29,10 +29,10 @@ class DoubleSlabBlock extends SolidBlock{
|
||||
3 => "Cobblestone",
|
||||
4 => "Brick",
|
||||
5 => "Stone Brick",
|
||||
6 => "Nether Brick",
|
||||
7 => "Quartz",
|
||||
6 => "Quartz",
|
||||
);
|
||||
$this->name = "Double " . $names[$this->meta & 0x07] . " Slab";
|
||||
$this->hardness = 30;
|
||||
}
|
||||
|
||||
public function getBreakTime(Item $item, Player $player){
|
||||
|
@ -22,6 +22,7 @@
|
||||
class FarmlandBlock extends SolidBlock{
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(FARMLAND, $meta, "Farmland");
|
||||
$this->hardness = 3;
|
||||
}
|
||||
public function getDrops(Item $item, Player $player){
|
||||
return array(
|
||||
|
@ -22,6 +22,7 @@
|
||||
class GlassBlock extends TransparentBlock{
|
||||
public function __construct(){
|
||||
parent::__construct(GLASS, 0, "Glass");
|
||||
$this->hardness = 1.5;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
|
@ -22,6 +22,7 @@
|
||||
class GlowstoneBlock extends TransparentBlock{
|
||||
public function __construct(){
|
||||
parent::__construct(GLOWSTONE_BLOCK, 0, "Glowstone");
|
||||
$this->hardness = 1.5;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
|
@ -22,6 +22,7 @@
|
||||
class GoldBlock extends SolidBlock{
|
||||
public function __construct(){
|
||||
parent::__construct(GOLD_BLOCK, 0, "Gold Block");
|
||||
$this->hardness = 30;
|
||||
}
|
||||
|
||||
public function getBreakTime(Item $item, Player $player){
|
||||
|
@ -23,6 +23,7 @@ class GrassBlock extends SolidBlock{
|
||||
public function __construct(){
|
||||
parent::__construct(GRASS, 0, "Grass");
|
||||
$this->isActivable = true;
|
||||
$this->hardness = 3;
|
||||
}
|
||||
public function getDrops(Item $item, Player $player){
|
||||
return array(
|
||||
|
@ -22,6 +22,7 @@
|
||||
class GravelBlock extends FallableBlock{
|
||||
public function __construct(){
|
||||
parent::__construct(GRAVEL, 0, "Gravel");
|
||||
$this->hardness = 3;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
|
@ -22,6 +22,7 @@
|
||||
class IceBlock extends TransparentBlock{
|
||||
public function __construct(){
|
||||
parent::__construct(ICE, 0, "Ice");
|
||||
$this->hardness = 2.5;
|
||||
}
|
||||
|
||||
public function onBreak(Item $item, Player $player){
|
||||
|
@ -22,6 +22,7 @@
|
||||
class IronBlock extends SolidBlock{
|
||||
public function __construct(){
|
||||
parent::__construct(IRON_BLOCK, 0, "Iron Block");
|
||||
$this->hardness = 30;
|
||||
}
|
||||
|
||||
public function getBreakTime(Item $item, Player $player){
|
||||
|
@ -22,6 +22,7 @@
|
||||
class LapisBlock extends SolidBlock{
|
||||
public function __construct(){
|
||||
parent::__construct(LAPIS_BLOCK, 0, "Lapis Block");
|
||||
$this->hardness = 15;
|
||||
}
|
||||
|
||||
public function getBreakTime(Item $item, Player $player){
|
||||
|
@ -32,6 +32,7 @@ class LeavesBlock extends TransparentBlock{
|
||||
3 => "",
|
||||
);
|
||||
$this->name = $names[$this->meta & 0x03];
|
||||
$this->hardness = 1;
|
||||
}
|
||||
|
||||
private function findLog(Block $pos, array $visited, $distance, &$check, $fromSide = null){
|
||||
|
@ -22,6 +22,7 @@
|
||||
class MelonBlock extends TransparentBlock{
|
||||
public function __construct(){
|
||||
parent::__construct(MELON_BLOCK, 0, "Melon Block");
|
||||
$this->hardness = 5;
|
||||
}
|
||||
public function getDrops(Item $item, Player $player){
|
||||
return array(
|
||||
|
@ -22,6 +22,7 @@
|
||||
class MossStoneBlock extends SolidBlock{
|
||||
public function __construct(){
|
||||
parent::__construct(MOSS_STONE, 0, "Moss Stone");
|
||||
$this->hardness = 30;
|
||||
}
|
||||
|
||||
public function getBreakTime(Item $item, Player $player){
|
||||
|
@ -22,6 +22,7 @@
|
||||
class NetherBricksBlock extends SolidBlock{
|
||||
public function __construct(){
|
||||
parent::__construct(NETHER_BRICKS, 0, "Nether Bricks");
|
||||
$this->hardness = 30;
|
||||
}
|
||||
|
||||
public function getBreakTime(Item $item, Player $player){
|
||||
|
@ -22,6 +22,7 @@
|
||||
class NetherrackBlock extends SolidBlock{
|
||||
public function __construct(){
|
||||
parent::__construct(NETHERRACK, 0, "Netherrack");
|
||||
$this->hardness = 2;
|
||||
}
|
||||
|
||||
public function getBreakTime(Item $item, Player $player){
|
||||
|
@ -22,7 +22,7 @@
|
||||
class ObsidianBlock extends SolidBlock{
|
||||
public function __construct(){
|
||||
parent::__construct(OBSIDIAN, 0, "Obsidian");
|
||||
|
||||
$this->hardness = 6000;
|
||||
}
|
||||
|
||||
public function getBreakTime(Item $item, Player $player){
|
||||
|
@ -22,6 +22,7 @@
|
||||
class PlanksBlock extends SolidBlock{
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(PLANKS, $meta, "Wooden Planks");
|
||||
$this->hardness = 15;
|
||||
}
|
||||
|
||||
}
|
@ -22,6 +22,7 @@
|
||||
class SandBlock extends FallableBlock{
|
||||
public function __construct(){
|
||||
parent::__construct(SAND, 0, "Sand");
|
||||
$this->hardness = 2.5;
|
||||
}
|
||||
|
||||
}
|
@ -27,7 +27,8 @@ class SandstoneBlock extends SolidBlock{
|
||||
1 => "Chiseled Sandstone",
|
||||
2 => "Smooth Sandstone",
|
||||
);
|
||||
$this->name = $names[$this->meta & 0x03];
|
||||
$this->name = $names[$this->meta & 0x03];
|
||||
$this->hardness = 4;
|
||||
}
|
||||
|
||||
public function getBreakTime(Item $item, Player $player){
|
||||
|
@ -22,6 +22,7 @@
|
||||
class SnowBlock extends SolidBlock{
|
||||
public function __construct(){
|
||||
parent::__construct(SNOW_BLOCK, 0, "Snow Block");
|
||||
$this->hardness = 1;
|
||||
}
|
||||
|
||||
}
|
@ -22,6 +22,7 @@
|
||||
class SoulSandBlock extends SolidBlock{
|
||||
public function __construct(){
|
||||
parent::__construct(SOUL_SAND, 0, "Soul Sand");
|
||||
$this->hardness = 2.5;
|
||||
}
|
||||
|
||||
}
|
@ -22,6 +22,7 @@
|
||||
class StoneBlock extends SolidBlock{
|
||||
public function __construct(){
|
||||
parent::__construct(STONE, 0, "Stone");
|
||||
$this->hardness = 30;
|
||||
}
|
||||
|
||||
public function getBreakTime(Item $item, Player $player){
|
||||
|
@ -29,6 +29,7 @@ class StoneBricksBlock extends SolidBlock{
|
||||
3 => "Chiseled Stone Bricks",
|
||||
);
|
||||
$this->name = $names[$this->meta & 0x03];
|
||||
$this->hardness = 30;
|
||||
}
|
||||
|
||||
public function getBreakTime(Item $item, Player $player){
|
||||
|
@ -33,6 +33,7 @@ class WoodBlock extends SolidBlock{
|
||||
);
|
||||
$this->meta &= 0x03;
|
||||
$this->name = $names[$this->meta];
|
||||
$this->hardness = 10;
|
||||
}
|
||||
|
||||
}
|
@ -41,6 +41,7 @@ class WoolBlock extends SolidBlock{
|
||||
15 => "Black Wool",
|
||||
);
|
||||
$this->name = $names[$this->meta];
|
||||
$this->hardness = 4;
|
||||
}
|
||||
|
||||
}
|
@ -23,6 +23,7 @@ class WorkbenchBlock extends SolidBlock{
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(WORKBENCH, $meta, "Crafting Table");
|
||||
$this->isActivable = true;
|
||||
$this->hardness = 15;
|
||||
}
|
||||
|
||||
public function onActivate(Item $item, Player $player){
|
||||
|
@ -36,8 +36,11 @@ class BucketItem extends Item{
|
||||
return true;
|
||||
}
|
||||
}elseif($this->meta === WATER){
|
||||
if($block->getID() === AIR){
|
||||
$level->setBlock($block, new StillWaterBlock(), true, false, true);
|
||||
//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(clone $this, $player, $block, $target, $face, $fx, $fy, $fz);
|
||||
if(($player->gamemode & 0x01) === 0){
|
||||
$this->meta = 0;
|
||||
}
|
||||
@ -45,7 +48,7 @@ class BucketItem extends Item{
|
||||
}
|
||||
}elseif($this->meta === LAVA){
|
||||
if($block->getID() === AIR){
|
||||
$level->setBlock($block, new StillLavaBlock(), true, false, true);
|
||||
$level->setBlock($block, new LavaBlock(), true, false, true);
|
||||
if(($player->gamemode & 0x01) === 0){
|
||||
$this->meta = 0;
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ class FlintSteelItem extends Item{
|
||||
}
|
||||
|
||||
public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
if($this->useOn($block) and ($player->gamemode & 0x01) === 0 and $this->getMetadata() >= $this->getMaxDurability()){
|
||||
if(($player->gamemode & 0x01) === 0 and $this->useOn($block) and $this->getMetadata() >= $this->getMaxDurability()){
|
||||
$player->setSlot($player->slot, new Item(AIR, 0, 0), false);
|
||||
}
|
||||
|
||||
|
@ -23,12 +23,8 @@ class Vector2{
|
||||
public $x, $y;
|
||||
|
||||
public function __construct($x = 0, $y = 0){
|
||||
if(($x instanceof Vector2) === true){
|
||||
$this->__construct($x->x, $x->y);
|
||||
}else{
|
||||
$this->x = $x;
|
||||
$this->y = $y;
|
||||
}
|
||||
$this->x = $x;
|
||||
$this->y = $y;
|
||||
}
|
||||
|
||||
public function getX(){
|
||||
|
@ -23,13 +23,9 @@ class Vector3{
|
||||
public $x, $y, $z;
|
||||
|
||||
public function __construct($x = 0, $y = 0, $z = 0){
|
||||
if(($x instanceof Vector3) === true){
|
||||
$this->__construct($x->x, $x->y, $x->z);
|
||||
}else{
|
||||
$this->x = $x;
|
||||
$this->y = $y;
|
||||
$this->z = $z;
|
||||
}
|
||||
$this->x = $x;
|
||||
$this->y = $y;
|
||||
$this->z = $z;
|
||||
}
|
||||
|
||||
public function getX(){
|
||||
|
@ -475,17 +475,17 @@ class CustomPacketHandler{
|
||||
break;
|
||||
case MC_LEVEL_EVENT:
|
||||
if($this->c === false){
|
||||
$this->data["unknown1"] = Utils::readShort($this->get(2));
|
||||
$this->data["unknown2"] = Utils::readShort($this->get(2));
|
||||
$this->data["unknown3"] = Utils::readShort($this->get(2));
|
||||
$this->data["unknown4"] = Utils::readShort($this->get(2));
|
||||
$this->data["unknown5"] = Utils::readInt($this->get(4));
|
||||
$this->data["evid"] = Utils::readShort($this->get(2));
|
||||
$this->data["x"] = Utils::readShort($this->get(2));
|
||||
$this->data["y"] = Utils::readShort($this->get(2));
|
||||
$this->data["z"] = Utils::readShort($this->get(2));
|
||||
$this->data["data"] = Utils::readInt($this->get(4));
|
||||
}else{
|
||||
$this->raw .= Utils::writeShort($this->data["unknown1"]);
|
||||
$this->raw .= Utils::writeShort($this->data["unknown2"]);
|
||||
$this->raw .= Utils::writeShort($this->data["unknown3"]);
|
||||
$this->raw .= Utils::writeShort($this->data["unknown4"]);
|
||||
$this->raw .= Utils::writeInt($this->data["unknown5"]);
|
||||
$this->raw .= Utils::writeShort($this->data["evid"]);
|
||||
$this->raw .= Utils::writeShort($this->data["x"]);
|
||||
$this->raw .= Utils::writeShort($this->data["y"]);
|
||||
$this->raw .= Utils::writeShort($this->data["z"]);
|
||||
$this->raw .= Utils::writeInt($this->data["data"]);
|
||||
}
|
||||
break;
|
||||
case MC_TILE_EVENT:
|
||||
|
@ -132,7 +132,7 @@ class RCONInstance extends Thread{
|
||||
|
||||
public function run(){
|
||||
while($this->stop !== true){
|
||||
usleep(1);
|
||||
usleep(2000);
|
||||
$r = array($socket = $this->socket);
|
||||
$w = null;
|
||||
$e = null;
|
||||
|
@ -304,6 +304,104 @@ class PMFLevel extends PMF{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getBlockID($x, $y, $z){
|
||||
if($y > 127 or $y < 0 or $x < 0 or $z < 0 or $x > 255 or $z > 255){
|
||||
return 0;
|
||||
}
|
||||
$X = $x >> 4;
|
||||
$Z = $z >> 4;
|
||||
$Y = $y >> 4;
|
||||
$index = $this->getIndex($X, $Z);
|
||||
$aX = $x - ($X << 4);
|
||||
$aZ = $z - ($Z << 4);
|
||||
$aY = $y - ($Y << 4);
|
||||
$b = ord($this->chunks[$index]
|
||||
[$Y]
|
||||
{(int) ($aY + ($aX << 5) + ($aZ << 9))});
|
||||
return $b;
|
||||
}
|
||||
|
||||
public function setBlockID($x, $y, $z, $block){
|
||||
if($y > 127 or $y < 0 or $x < 0 or $z < 0 or $x > 255 or $z > 255){
|
||||
return false;
|
||||
}
|
||||
$X = $x >> 4;
|
||||
$Z = $z >> 4;
|
||||
$Y = $y >> 4;
|
||||
$block &= 0xFF;
|
||||
if($X >= 32 or $Z >= 32 or $Y >= $this->levelData["height"] or $y < 0){
|
||||
return false;
|
||||
}
|
||||
$index = $this->getIndex($X, $Z);
|
||||
$aX = $x - ($X << 4);
|
||||
$aZ = $z - ($Z << 4);
|
||||
$aY = $y - ($Y << 4);
|
||||
$this->chunks[$index][$Y]{(int) ($aY + ($aX << 5) + ($aZ << 9))} = 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 or $x < 0 or $z < 0 or $x > 255 or $z > 255){
|
||||
return 0;
|
||||
}
|
||||
$X = $x >> 4;
|
||||
$Z = $z >> 4;
|
||||
$Y = $y >> 4;
|
||||
$index = $this->getIndex($X, $Z);
|
||||
$aX = $x - ($X << 4);
|
||||
$aZ = $z - ($Z << 4);
|
||||
$aY = $y - ($Y << 4);
|
||||
$m = ord($this->chunks[$index][$Y]{(int) (($aY >> 1) + 16 + ($aX << 5) + ($aZ << 9))});
|
||||
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 or $x < 0 or $z < 0 or $x > 255 or $z > 255){
|
||||
return false;
|
||||
}
|
||||
$X = $x >> 4;
|
||||
$Z = $z >> 4;
|
||||
$Y = $y >> 4;
|
||||
$damage &= 0x0F;
|
||||
if($X >= 32 or $Z >= 32 or $Y >= $this->levelData["height"] or $y < 0){
|
||||
return false;
|
||||
}
|
||||
$index = $this->getIndex($X, $Z);
|
||||
$aX = $x - ($X << 4);
|
||||
$aZ = $z - ($Z << 4);
|
||||
$aY = $y - ($Y << 4);
|
||||
$mindex = (int) (($aY >> 1) + 16 + ($aX << 5) + ($aZ << 9));
|
||||
$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;
|
||||
@ -322,10 +420,8 @@ class PMFLevel extends PMF{
|
||||
$aX = $x - ($X << 4);
|
||||
$aZ = $z - ($Z << 4);
|
||||
$aY = $y - ($Y << 4);
|
||||
$bindex = (int) ($aY + ($aX << 5) + ($aZ << 9));
|
||||
$mindex = (int) (($aY >> 1) + 16 + ($aX << 5) + ($aZ << 9));
|
||||
$b = ord($this->chunks[$index][$Y]{$bindex});
|
||||
$m = ord($this->chunks[$index][$Y]{$mindex});
|
||||
$b = ord($this->chunks[$index][$Y]{(int) ($aY + ($aX << 5) + ($aZ << 9))});
|
||||
$m = ord($this->chunks[$index][$Y]{(int) (($aY >> 1) + 16 + ($aX << 5) + ($aZ << 9))});
|
||||
if(($y & 1) === 0){
|
||||
$m = $m & 0x0F;
|
||||
}else{
|
||||
@ -373,6 +469,16 @@ class PMFLevel extends PMF{
|
||||
++$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);
|
||||
if($b instanceof LavaBlock) { ServerAPI::request()->api->block->scheduleBlockUpdate(new Position($b, 0, 0, $this->level), 40, BLOCK_UPDATE_NORMAL); }
|
||||
else { ServerAPI::request()->api->block->scheduleBlockUpdate(new Position($b, 0, 0, $this->level), 10, BLOCK_UPDATE_NORMAL); }
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -414,4 +520,4 @@ class PMFLevel extends PMF{
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -22,38 +22,54 @@
|
||||
|
||||
//Unsecure, not used for "Real Randomness"
|
||||
class Random{
|
||||
private $random;
|
||||
private $x, $y, $z, $w;
|
||||
public function __construct($seed = false){
|
||||
$this->random = new twister(0);
|
||||
$this->setSeed($seed);
|
||||
}
|
||||
|
||||
public function setSeed($seed = false){
|
||||
$this->random->init_with_integer($seed !== false ? (int) $seed:Utils::readInt(Utils::getRandomBytes(4, false)));
|
||||
$seed = $seed !== false ? Utils::writeInt((int) $seed):Utils::getRandomBytes(4, false);
|
||||
$state = array();
|
||||
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 nextInt(){
|
||||
return $this->random->int32();
|
||||
return Utils::readInt($this->nextBytes(4)) & 0x7FFFFFFF;
|
||||
}
|
||||
|
||||
public function nextFloat(){
|
||||
return $this->random->real_closed();
|
||||
return $this->nextInt() / 0x7FFFFFFF;
|
||||
}
|
||||
|
||||
public function nextBytes($byteCount){
|
||||
$bytes = "";
|
||||
for($i = 0; $i < $byteCount; ++$i){
|
||||
$bytes .= chr($this->random->rangeint(0, 0xFF));
|
||||
$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 nextBoolean(){
|
||||
return $this->random->rangeint(0, 1) === 1;
|
||||
return ($this->nextBytes(1) & 0x01) == 0;
|
||||
}
|
||||
|
||||
public function nextRange($start = 0, $end = PHP_INT_MAX){
|
||||
return $this->random->rangeint($start, $end);
|
||||
return $start + ($this->nextInt() % ($end + 1 - $start));
|
||||
}
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user