Compare commits

...

87 Commits

Author SHA1 Message Date
3d53b9eb3a Armor drop - tested 2013-11-23 11:06:01 +01:00
f32f379e97 Lava flow code reformatting 2013-11-23 11:04:36 +01:00
809ca802b3 PocketMine-MP Alpha_1.3.10 Stable Release 2013-11-23 11:00:22 +01:00
719df75886 Water flow code reformatting 2013-11-23 10:59:52 +01:00
14a40ac11e Remove keycodes from console input 2013-11-23 10:46:24 +01:00
c973abc36f Added --disable-ansi to disable console colors #887 2013-11-23 10:22:24 +01:00
54d37a432e Check that ServerAPI::request() works, fixes #916 [gh#916] 2013-11-23 10:17:38 +01:00
c7168a6c64 Fixed #926 [gh#926] 2013-11-23 10:11:25 +01:00
079d24055d Updated compile script
* PHP 5.5.6
* pthreads 0.0.45 (stable!)
* cURL 7.33.0
2013-11-22 23:42:48 +01:00
b1748b5393 Removed language include 2013-11-22 15:28:28 +01:00
b66f34b308 Merge pull request #930 from beN39sGroup/master 2013-11-22 23:59:50 +10:30
1cb711d32d Temporaily fix multilanguage bug. Waiting on pull request author to remove multi language. 2013-11-22 22:56:02 +10:30
94a9b7b431 Merge pull request #925 from beN39sGroup/master
Liquid Performance
2013-11-22 03:12:16 -08:00
7acdb0dd3f Fix Performance Problem
Welcome, TPS!
2013-11-17 09:39:40 +09:00
fe70fa467d Slower Unflow & Basic for Multi Language
Slower Unflow!
I wanna Multi Language!
2013-11-15 19:14:02 +09:00
d4a5e4e5c4 Merge pull request #920 from beN39sGroup/master
Liquid Flowing. This requires further testing before stable release.
2013-11-12 21:48:02 -08:00
db289f9871 Mixable Lava & Water
I Wanna Make Cobblestone Generator!
2013-11-10 22:11:45 +09:00
b822b314cb Simple Flowable Lava & English Comment
Still A Flowing
2013-11-10 17:59:36 +09:00
77ca6da14c Simple Flowable Water!
Meet the 'Flowing' Water.
2013-11-10 17:19:50 +09:00
9373c93737 Prefix for Kick Flying when Player on Fence 2013-11-10 13:52:41 +09:00
cb47bf82c9 Reset player's armors after death UNTESTED. Fixes #896. 2013-11-09 20:44:09 +10:30
3498c876df Reset player's armors after death 2013-11-09 20:43:06 +10:30
df01e92ab6 Merge pull request #886 from JWhy/patch-1
Extract plugins/ path lookup to pluginsPath() function in PluginAPI
2013-11-09 01:34:54 -08:00
1f1f955eef Add plugin name info to Evaluation Error. 2013-11-09 20:00:24 +10:30
0e471ab38c Fixed leftover reference in pluginsPath() function 2013-10-22 14:53:12 +02:00
9f211bd7fb Extract plugins/ path lookup to pluginsPath() function in PluginAPI 2013-10-22 14:05:11 +02:00
af486917a1 Fixed #884 2013-10-22 21:26:30 +10:30
c197a58a3a Merge pull request #881 from JWhy/patch-1
Use DIRECTORY_SEPERATOR constant for safer cross-platform file access
2013-10-21 04:22:23 -07:00
ca0d682d87 Use DIRECTORY_SEPERATOR constant for safer cross-platform file access 2013-10-21 12:27:48 +02:00
70ec644658 Merge pull request #880 from JWhy/patch-1
Support other local date format for timezone detection to avoid startup errors
2013-10-20 21:55:48 -07:00
a860f16f4a Support other local date format for timezone detection to avoid startup errors
fixes PocketMine/PocketMine-MP#718
2013-10-21 06:12:27 +02:00
9ac72026b9 Fix #831 2013-10-19 11:47:53 +10:30
0ad0071107 Fix crash bug when @all is used in console. 2013-10-19 11:28:43 +10:30
386b2cb0ef Fix 805 2013-10-19 11:20:33 +10:30
58fce0e939 Fix /me @all critical server crash bug. Fix #840. Disabled usage of @all for non-ops. 2013-10-19 11:12:54 +10:30
780f60554d Fix #871 2013-10-19 10:58:49 +10:30
4aa0ae86fb Update config.php 2013-10-18 18:04:45 +10:30
f005b82a70 Fixed typo. Not Longer -> No Longer 2013-10-09 13:09:35 +10:30
c35c004827 Added the ability to shoot arrows
Credit to ljyloo (http://forums.pocketmine.net/index.php?threads/shooting-arrows-in-pm-server.508/#post-4338).
2013-10-08 16:52:37 -05:00
e179de1613 Better :3 2013-10-02 16:57:37 +02:00
3354df0360 More KiwiIRC Buttons 2013-10-03 00:25:38 +09:30
d8cfc06d3a KiwiIRC! 2013-10-03 00:24:48 +09:30
3b0e553e17 Merge pull request #812 from Humerus/patch-2
Made it so deop doesn't op the player.
2013-09-15 13:18:26 -07:00
c53ea830ea Made it so deop doesn't op the player. 2013-09-15 12:00:00 -04:00
0c1afe15fd Added .idea to .gitignore 2013-09-11 11:13:09 +02:00
6a24700f6e Fix compiler again 2013-09-10 22:52:24 +02:00
000dfc8601 Fix 64 bit builds 2013-09-10 22:49:33 +02:00
a011ad8fb6 Reverted DIAMOND_HOE to IRON_HOE 2013-09-10 20:11:31 +02:00
d41c30945b Level optimizations 2013-09-09 10:44:50 +02:00
b3c51c6d2e Faster level generator 2013-09-09 03:32:24 +02:00
4ccaccc126 Fixed Player::setSpawn() 2013-09-08 15:37:28 +02:00
8aef462a68 Fixed #784 Slabs replacing other slabs 2013-09-08 10:45:36 +02:00
c4a5a9c849 Better explosion damage calculation 2013-09-08 01:35:48 +02:00
275e27f7a9 Low level PMF level interface 2013-09-08 01:21:40 +02:00
1abe7626bf Using Vectors for explosions 2013-09-08 00:27:35 +02:00
7c9255e21e Incremented speedMeasure() size 2013-09-07 21:27:05 +02:00
0c6eaa0609 Fixed entity motion condition 2013-09-07 21:19:47 +02:00
1bc3b66afd Player check is done with equal name, not alike 2013-09-07 14:24:17 +02:00
df174d1b8e Tuned power again xD 2013-09-07 13:35:32 +02:00
f56dd60708 Correct item drop related to explosion power 2013-09-07 12:37:04 +02:00
2271d0b6fc Lowered TNT explosion force from 4 to 3 2013-09-07 12:28:18 +02:00
6d2eea8887 Level::getSafeSpawn() on player normal spawn 2013-09-07 12:05:04 +02:00
fb2bcdb722 Level::getSafeSpawn() look for solid block 2013-09-07 12:04:49 +02:00
c8dd85de75 Better fuse calculation 2013-09-07 11:55:14 +02:00
a00375b1a9 Perfect explosions 2013-09-07 11:40:22 +02:00
e7e05d37b3 Moved -mx32 flag 2013-09-07 10:30:08 +02:00
6ac54925ff Added -mx32 flag 2013-09-07 10:26:22 +02:00
555da94612 Moved patch location :P 2013-09-07 10:21:42 +02:00
774debb299 Fixed #781 2013-09-07 10:18:06 +02:00
9b63a0b0bf Fixed colors on MacOS 2013-09-07 10:13:14 +02:00
397b47d719 Added secondary explosions 2013-09-07 02:51:15 +02:00
5952e34995 PrimedTNT Entity implemented 2013-09-07 02:46:18 +02:00
0ddc48ca80 Vanilla-alike Explosions 2013-09-07 01:28:15 +02:00
24211764ce Tuned TNT force 2013-09-06 22:17:13 +02:00
4a2e3d3611 Fixed Flint & Steel order 2013-09-06 19:33:16 +02:00
e5841e623e Fixed comparison order with flint & steel metadata 2013-09-06 17:50:01 +02:00
215141d552 Added Diamond Hoe, Flint & Steel and Diamond Sword to the Creative inventory 2013-09-06 17:40:07 +02:00
94f8cfb59b Added Single Explosions [ignite TNT using fling & steel] 2013-09-06 13:46:52 +02:00
41b1a0f991 Fixed bottom bed offset 2013-09-05 22:58:49 +02:00
08d93fa021 Fixed #774 [gh#774] 2013-09-05 19:58:31 +02:00
ce65801d14 Keep window open 2013-09-05 17:17:54 +02:00
bb9923d210 Fixed position offset when sleeping on beds 2013-09-05 15:19:27 +02:00
ccac35d5a2 Fixed player catching fire after death 2013-09-05 00:39:06 +02:00
c11ee468a2 Added Door sounds 2013-09-05 00:37:07 +02:00
e48126a0c9 Fixed possible cases on infinite loop on addItem and removeItem 2013-09-04 21:29:21 +02:00
b56ee69f0d Alpha_1.3.10dev 2013-09-04 21:27:13 +02:00
4a46d8fd9c Fixed possible infinite loop in hasSpace 2013-09-04 21:26:22 +02:00
112 changed files with 825 additions and 267 deletions

1
.gitignore vendored
View File

@ -3,6 +3,7 @@ worlds/*
plugins/*
logs/*
bin/*
.idea/*
*.log
*.pmf
*.txt

View File

@ -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);

View File

@ -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
[![#pocketmine channel WebIRC](https://kiwiirc.com/buttons/chat.freenode.net/pocketmine.png)](https://kiwiirc.com/client/chat.freenode.net/#pocketmine)
[![#mcpedevs channel WebIRC](https://kiwiirc.com/buttons/chat.freenode.net/mcpedevs.png)](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)__

View File

@ -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":

View File

@ -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{

View File

@ -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 != ""){

View File

@ -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;

View File

@ -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(){
}
}
}

View File

@ -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();

View File

@ -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,

View File

@ -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; }

View File

@ -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));
}
}

View File

@ -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);

View File

@ -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);

View File

@ -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);
}

View File

@ -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(){

View File

@ -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;
}

View File

@ -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){

View File

@ -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),

View File

@ -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){

View File

@ -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){

View File

@ -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){

View File

@ -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;
}
}

View File

@ -22,6 +22,7 @@
class StillLavaBlock extends LiquidBlock{
public function __construct($meta = 0){
parent::__construct(STILL_LAVA, $meta, "Still Lava");
$this->hardness = 500;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}
}

View File

@ -31,6 +31,7 @@ class AirBlock extends TransparentBlock{
$this->hasPhysics = false;
$this->isSolid = false;
$this->isFullBlock = true;
$this->hardness = 0;
}

View File

@ -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"
));

View File

@ -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){

View File

@ -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;
}
}

View File

@ -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){

View File

@ -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();

View File

@ -23,6 +23,7 @@ class FenceBlock extends TransparentBlock{
public function __construct(){
parent::__construct(FENCE, 0, "Fence");
$this->isFullBlock = false;
$this->hardness = 15;
}
}

View File

@ -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(

View File

@ -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){

View File

@ -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){

View File

@ -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){

View File

@ -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){

View File

@ -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),
);
}
}

View File

@ -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){

View File

@ -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){

View File

@ -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){

View File

@ -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){

View File

@ -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){

View File

@ -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){

View File

@ -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){

View File

@ -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){

View File

@ -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){

View File

@ -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){

View File

@ -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){

View File

@ -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){

View File

@ -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);

View File

@ -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){

View File

@ -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){

View File

@ -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){

View File

@ -29,6 +29,7 @@ class TallGrassBlock extends FlowableBlock{
2 => "Fern",
);
$this->name = $names[$this->meta & 0x03];
$this->hardness = 0;
}
public function onUpdate($type){

View File

@ -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){

View File

@ -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){

View File

@ -22,6 +22,7 @@
class BookshelfBlock extends SolidBlock{
public function __construct(){
parent::__construct(BOOKSHELF, 0, "Bookshelf");
$this->hardness = 7.5;
}
}

View File

@ -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){

View File

@ -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){

View File

@ -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();

View File

@ -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){

View File

@ -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){

View File

@ -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){

View File

@ -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){

View File

@ -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){

View File

@ -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(

View File

@ -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){

View File

@ -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){

View File

@ -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){

View File

@ -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(

View File

@ -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){

View File

@ -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){

View File

@ -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){

View File

@ -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){

View File

@ -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){

View File

@ -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(

View File

@ -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){

View File

@ -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){

View File

@ -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){

View File

@ -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){

View File

@ -22,6 +22,7 @@
class PlanksBlock extends SolidBlock{
public function __construct($meta = 0){
parent::__construct(PLANKS, $meta, "Wooden Planks");
$this->hardness = 15;
}
}

View File

@ -22,6 +22,7 @@
class SandBlock extends FallableBlock{
public function __construct(){
parent::__construct(SAND, 0, "Sand");
$this->hardness = 2.5;
}
}

View File

@ -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){

View File

@ -22,6 +22,7 @@
class SnowBlock extends SolidBlock{
public function __construct(){
parent::__construct(SNOW_BLOCK, 0, "Snow Block");
$this->hardness = 1;
}
}

View File

@ -22,6 +22,7 @@
class SoulSandBlock extends SolidBlock{
public function __construct(){
parent::__construct(SOUL_SAND, 0, "Soul Sand");
$this->hardness = 2.5;
}
}

View File

@ -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){

View File

@ -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){

View File

@ -33,6 +33,7 @@ class WoodBlock extends SolidBlock{
);
$this->meta &= 0x03;
$this->name = $names[$this->meta];
$this->hardness = 10;
}
}

View File

@ -41,6 +41,7 @@ class WoolBlock extends SolidBlock{
15 => "Black Wool",
);
$this->name = $names[$this->meta];
$this->hardness = 4;
}
}

View File

@ -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){

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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(){

View File

@ -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(){

View File

@ -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:

View File

@ -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;

View File

@ -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{
}
}
}
}

View File

@ -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