diff --git a/compile_php.sh b/compile_php.sh index 3069d4d9d..5d948d5df 100644 --- a/compile_php.sh +++ b/compile_php.sh @@ -1,14 +1,16 @@ #!/bin/bash -COMPILER_VERSION="0.7" +COMPILER_VERSION="0.8" + PHP_VERSION="5.4.11" ZEND_VM="GOTO" + ZLIB_VERSION="1.2.7" -GMP_VERSION="5.1.0a" -PTHREADS_VERSION="e4700122a89bf759a9c3a024bda0c7d025bcb93d" -CURL_VERSION="curl-7_28_1" +GMP_VERSION="5.1.0" +PTHREADS_VERSION="fc8622882bed09aa181b3eb1cb33c046ce11199b" +CURL_VERSION="curl-7_29_0" #READLINE_VERSION="6.2" -echo "[PocketMine] PHP installer and compiler for Linux - by @shoghicp v$COMPILER_VERSION" +echo "[PocketMine] PHP installer and compiler for Linux & Mac - by @shoghicp v$COMPILER_VERSION" DIR=`pwd` date > $DIR/install.log 2>&1 uname -a >> $DIR/install.log 2>&1 @@ -18,6 +20,7 @@ type autoconf >> $DIR/install.log 2>&1 || { echo >&2 "[ERROR] Please install \"a type automake >> $DIR/install.log 2>&1 || { echo >&2 "[ERROR] Please install \"automake\""; exit 1; } type gcc >> $DIR/install.log 2>&1 || { echo >&2 "[ERROR] Please install \"gcc\""; exit 1; } type m4 >> $DIR/install.log 2>&1 || { echo >&2 "[ERROR] Please install \"m4\""; exit 1; } + rm -r -f install_data/ >> $DIR/install.log 2>&1 rm -r -f php5/ >> $DIR/install.log 2>&1 mkdir -m 0777 install_data >> $DIR/install.log 2>&1 @@ -26,7 +29,7 @@ cd install_data set -e #PHP 5 -echo -n "[PHP5] downloading $PHP_VERSION..." +echo -n "[PHP] downloading $PHP_VERSION..." wget http://php.net/get/php-$PHP_VERSION.tar.gz/from/this/mirror -q -O - | tar -zx >> $DIR/install.log 2>&1 mv php-$PHP_VERSION php echo " done!" @@ -74,6 +77,7 @@ mv gmp-$GMP_VERSION gmp echo -n " checking..." cd gmp ./configure --prefix=$DIR/install_data/php/ext/gmp \ +--disable-assembly \ --disable-shared >> $DIR/install.log 2>&1 echo -n " compiling..." make >> $DIR/install.log 2>&1 @@ -84,6 +88,7 @@ cd .. rm -r -f ./gmp echo " done!" + echo -n "[cURL] downloading $CURL_VERSION..." wget https://github.com/bagder/curl/archive/$CURL_VERSION.tar.gz --no-check-certificate -q -O - | tar -zx >> $DIR/install.log 2>&1 mv curl-$CURL_VERSION curl @@ -108,7 +113,6 @@ mv pthreads-$PTHREADS_VERSION $DIR/install_data/php/ext/pthreads echo " done!" set +e -echo -n "[PHP5] checking..." if which free >/dev/null; then MAX_MEMORY=$(free -m | awk '/^Mem:/{print $2}') else @@ -122,6 +126,7 @@ else OPTIMIZATION="" fi set -e +echo -n "[PHP] checking..." cd php ./buildconf --force >> $DIR/install.log 2>&1 ./configure $OPTIMIZATION--prefix=$DIR/php5 \ @@ -163,4 +168,4 @@ rm -r -f install_data/ >> $DIR/install.log 2>&1 date >> $DIR/install.log 2>&1 echo " done!" echo "[PocketMine] You should start the server now using \"./start.sh\"" -echo "[PocketMine] If it doesn't works, please send the \"install.log\" file to the Bug Tracker" \ No newline at end of file +echo "[PocketMine] If it doesn't works, please send the \"install.log\" file to the Bug Tracker" diff --git a/src/API/BlockAPI.php b/src/API/BlockAPI.php index 2a6294d0f..695055a46 100644 --- a/src/API/BlockAPI.php +++ b/src/API/BlockAPI.php @@ -154,10 +154,10 @@ class BlockAPI{ public function playerBlockBreak(Player $player, Vector3 $vector){ $target = $this->getBlock($vector); - if($target->isBreakable === false or $this->server->gamemode === 2){ - return $this->cancelAction($target); - } $item = $player->equipment; + if(!$target->isBreakable($item, $player) or $this->server->gamemode === 2){ + return $this->cancelAction($target); + } if($this->server->api->dhandle("player.block.break", array("player" => $player, "target" => $target, "item" => $item)) !== false){ diff --git a/src/API/PlayerAPI.php b/src/API/PlayerAPI.php index bc919fffc..d8fdf5466 100644 --- a/src/API/PlayerAPI.php +++ b/src/API/PlayerAPI.php @@ -95,7 +95,7 @@ class PlayerAPI{ $message .= " hit the ground too hard"; break; case "flying": - $message .= " tried to get up to the sky"; + $message .= " tried to fly up to the sky"; break; default: $message .= " died"; @@ -176,6 +176,7 @@ class PlayerAPI{ if($player !== false){ $player->entity->setPosition($x, $y, $z, 0, 0); $player->fallY = false; + $player->fallStart = false; $player->dataPacket(MC_MOVE_PLAYER, array( "eid" => 0, "x" => $x, @@ -185,6 +186,7 @@ class PlayerAPI{ "pitch" => 0, )); $player->fallY = false; + $player->fallStart = false; return true; } return false; diff --git a/src/API/ServerAPI.php b/src/API/ServerAPI.php index 17f093e7e..a4fcb89bf 100644 --- a/src/API/ServerAPI.php +++ b/src/API/ServerAPI.php @@ -133,9 +133,9 @@ class ServerAPI{ $last = $info["development"]["date"]; if($last >= $this->getProperty("last-update") and $this->getProperty("last-update") !== false){ console("[NOTICE] \x1b[33mA new DEVELOPMENT version of PocketMine-MP has been released"); - console("[NOTICE] \x1b[33mA \"".$info["development"]["version"]."\" [".substr($info["development"]["commit"], 0, 10)."]"); + console("[NOTICE] \x1b[33mVersion \"".$info["development"]["version"]."\" [".substr($info["development"]["commit"], 0, 10)."]"); console("[NOTICE] \x1b[36mIf you want to update, get the latest version at ".$info["development"]["download"]); - console("[NOTICE] This message will dissapear when you issue the command \"/update-done\""); + console("[NOTICE] This message will dissapear after issuing the command \"/update-done\""); sleep(3); }else{ $this->setProperty("last-update", time()); diff --git a/src/classes/Player.php b/src/classes/Player.php index 456af5a6c..5874af2a6 100644 --- a/src/classes/Player.php +++ b/src/classes/Player.php @@ -49,6 +49,7 @@ class Player{ public $equipment; var $armor = array(0, 0, 0, 0); var $loggedIn = false; + public $gamemode; private $chunksLoaded = array(); private $chunksOrder = array(); @@ -61,7 +62,8 @@ class Player{ $this->port = $port; $this->timeout = microtime(true) + 20; $this->inventory = array_fill(0, 36, array(AIR, 0, 0)); - if($this->server->gamemode === 0 or $this->server->gamemode === 2){ + $this->gamemode = $this->server->gamemode; + if($this->gamemode === 0 or $this->gamemode === 2){ $this->equipment = BlockAPI::getItem(AIR); }else{ $this->equipment = BlockAPI::getItem(STONE); @@ -272,14 +274,14 @@ class Player{ } break; case "player.block.place": - if($data["eid"] === $this->eid and ($this->server->gamemode === 0 or $this->server->gamemode === 2)){ + if($data["eid"] === $this->eid and ($this->gamemode === 0 or $this->gamemode === 2)){ $this->removeItem($data["original"]->getID(), $data["original"]->getMetadata(), 1); } break; case "player.pickup": if($data["eid"] === $this->eid){ $data["eid"] = 0; - if(($this->server->gamemode === 0 or $this->server->gamemode === 2)){ + if(($this->gamemode === 0 or $this->gamemode === 2)){ $this->addItem($data["entity"]->type, $data["entity"]->meta, $data["entity"]->stack); } } @@ -517,7 +519,7 @@ class Player{ } $this->server->api->player->add($this->CID); $this->auth = true; - if(!isset($this->data["inventory"]) or $this->server->gamemode === 1){ + if(!isset($this->data["inventory"]) or $this->gamemode === 1){ $this->data["inventory"] = $this->inventory; } $this->inventory = &$this->data["inventory"]; @@ -535,7 +537,7 @@ class Player{ "y" => $this->data["spawn"]["y"], "z" => $this->data["spawn"]["z"], "unknown1" => 0, - "gamemode" => $this->server->gamemode, + "gamemode" => $this->gamemode, "eid" => 0, )); break; @@ -600,7 +602,7 @@ class Player{ 0x80 ? */ $flags = 0; - if($this->server->gamemode === 2){ + if($this->gamemode === 2){ $flags |= 0x01; //Not allow placing/breaking blocks } $flags |= 0x20; //Nametags @@ -632,7 +634,7 @@ class Player{ $data["eid"] = $this->eid; if(Utils::distance($this->entity->position, $data) > 10){ break; - }elseif(($this->server->gamemode === 0 or $this->server->gamemode === 2) and !$this->hasItem($data["block"], $data["meta"])){ + }elseif(($this->gamemode === 0 or $this->gamemode === 2) and !$this->hasItem($data["block"], $data["meta"])){ console("[DEBUG] Player \"".$this->username."\" tried to place not got block (or crafted block)", true, true, 2); //break; } @@ -672,7 +674,7 @@ class Player{ $this->entity->updateMetadata(); break; case MC_SET_HEALTH: - if($this->server->gamemode === 1){ + if($this->gamemode === 1){ break; } //$this->entity->setHealth($data["health"], "client"); diff --git a/src/classes/PocketMinecraftServer.php b/src/classes/PocketMinecraftServer.php index 6c52595dd..4212fbf82 100644 --- a/src/classes/PocketMinecraftServer.php +++ b/src/classes/PocketMinecraftServer.php @@ -331,7 +331,7 @@ class PocketMinecraftServer{ "yaw" => $entity["Rotation"][0], "pitch" => $entity["Rotation"][1], )); - }elseif($entity["id"] === 83){ //Painting + }elseif($entity["id"] === OBJECT_PAINTING){ //Painting $e = $this->api->entity->add(ENTITY_OBJECT, $entity["id"], $entity); $e->setPosition($entity["Pos"][0], $entity["Pos"][1], $entity["Pos"][2], $entity["Rotation"][0], $entity["Rotation"][1]); $e->setHealth($entity["Health"]); @@ -363,7 +363,7 @@ class PocketMinecraftServer{ if(count($this->entities) > 0){ $entities = array(); foreach($this->entities as $entity){ - if($entity->class === ENTITY_MOB or $entity->class === ENTITY_OBJECT){ + if($entity->class === ENTITY_MOB){ $entities[] = array( "id" => $entity->type, "Color" => @$entity->data["Color"], @@ -379,6 +379,24 @@ class PocketMinecraftServer{ 1 => $entity->pitch, ), ); + }elseif($entity->class === ENTITY_OBJECT){ + $entities[] = array( + "id" => $entity->type, + "TileX" => $entity->x, + "TileX" => $entity->y, + "TileX" => $entity->z, + "Health" => $entity->health, + "Motive" => $entity->data["Motive"], + "Pos" => array( + 0 => $entity->x, + 1 => $entity->y, + 2 => $entity->z, + ), + "Rotation" => array( + 0 => $entity->yaw, + 1 => $entity->pitch, + ), + ); }elseif($entity->class === ENTITY_ITEM){ $entities[] = array( "id" => 64, diff --git a/src/classes/material/Block.php b/src/classes/material/Block.php index fc50e97bf..49717992e 100644 --- a/src/classes/material/Block.php +++ b/src/classes/material/Block.php @@ -138,7 +138,7 @@ abstract class Block{ protected $shortname = ""; protected $name = ""; public $isActivable = false; - public $isBreakable = true; + public $breakable = true; public $isFlowable = false; public $isTransparent = false; public $isReplaceable = false; @@ -186,6 +186,8 @@ abstract class Block{ } } + abstract function isBreakable(Item $item, Player $player); + abstract function onBreak(BlockAPI $level, Item $item, Player $player); abstract function place(BlockAPI $level, Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz); diff --git a/src/classes/material/IDs.php b/src/classes/material/IDs.php index 35bd3382c..d55526e87 100644 --- a/src/classes/material/IDs.php +++ b/src/classes/material/IDs.php @@ -276,8 +276,3 @@ define("QUARTZ", 406); define("NETHER_QUARTZ", 406); define("CAMERA", 456); - -/* - -define("", ); -*/ \ No newline at end of file diff --git a/src/classes/material/block/GenericBlock.php b/src/classes/material/block/GenericBlock.php index aba1b9336..bc5493503 100644 --- a/src/classes/material/block/GenericBlock.php +++ b/src/classes/material/block/GenericBlock.php @@ -38,6 +38,10 @@ class GenericBlock extends Block{ return false; } + public function isBreakable(Item $item, Player $player){ + return $this->breakable; + } + public function onBreak(BlockAPI $level, Item $item, Player $player){ if($this->inWorld === true){ $level->setBlock($this, AIR, 0); diff --git a/src/classes/material/block/LiquidBlock.php b/src/classes/material/block/LiquidBlock.php index 8766d63de..67f320fae 100644 --- a/src/classes/material/block/LiquidBlock.php +++ b/src/classes/material/block/LiquidBlock.php @@ -29,7 +29,7 @@ class LiquidBlock extends TransparentBlock{ public function __construct($id, $meta = 0, $name = "Unknown"){ parent::__construct($id, $meta, $name); $this->isLiquid = true; - $this->isBreakable = false; + $this->breakable = false; $this->isReplaceable = true; } } \ No newline at end of file diff --git a/src/classes/material/block/TransparentBlock.php b/src/classes/material/block/TransparentBlock.php index 86271f9b8..1e89de1e2 100644 --- a/src/classes/material/block/TransparentBlock.php +++ b/src/classes/material/block/TransparentBlock.php @@ -29,7 +29,7 @@ class TransparentBlock extends GenericBlock{ public function __construct($id, $meta = 0, $name = "Unknown"){ parent::__construct($id, $meta, $name); $this->isActivable = false; - $this->isBreakable = true; + $this->breakable = true; $this->isFlowable = false; $this->isTransparent = true; $this->isReplaceable = false; diff --git a/src/classes/material/block/misc/Air.php b/src/classes/material/block/misc/Air.php index c33e54cab..e874f0b83 100644 --- a/src/classes/material/block/misc/Air.php +++ b/src/classes/material/block/misc/Air.php @@ -29,7 +29,7 @@ class AirBlock extends TransparentBlock{ public function __construct(){ parent::__construct(AIR, 0, "Air"); $this->isActivable = false; - $this->isBreakable = false; + $this->breakable = false; $this->isFlowable = true; $this->isTransparent = true; $this->isReplaceable = true; diff --git a/src/classes/material/block/misc/Fire.php b/src/classes/material/block/misc/Fire.php index 756cd8032..358561186 100644 --- a/src/classes/material/block/misc/Fire.php +++ b/src/classes/material/block/misc/Fire.php @@ -29,7 +29,7 @@ class FireBlock extends FlowableBlock{ public function __construct($meta = 0){ parent::__construct(FIRE, $meta, "Fire"); $this->isReplaceable = true; - $this->isBreakable = false; + $this->breakable = false; } } \ No newline at end of file diff --git a/src/classes/material/block/solid/Bedrock.php b/src/classes/material/block/solid/Bedrock.php index ffd925bf2..9487c26be 100644 --- a/src/classes/material/block/solid/Bedrock.php +++ b/src/classes/material/block/solid/Bedrock.php @@ -28,7 +28,14 @@ the Free Software Foundation, either version 3 of the License, or class BedrockBlock extends SolidBlock{ public function __construct(){ parent::__construct(BEDROCK, 0, "Bedrock"); - $this->isBreakable = false; + $this->breakable = false; + } + + public function isBreakable(Item $item, Player $player){ + if($player->gamemode === 1){ + return true; + } + return false; } } \ No newline at end of file diff --git a/src/classes/material/block/solid/Slab.php b/src/classes/material/block/solid/Slab.php index 65469e2bd..ed5347170 100644 --- a/src/classes/material/block/solid/Slab.php +++ b/src/classes/material/block/solid/Slab.php @@ -71,6 +71,9 @@ class SlabBlock extends TransparentBlock{ }else{ return false; } + if($block->getID() === SLAB and ($target->getMetadata() & 0x07) !== ($this->meta & 0x07)){ + return false; + } $level->setBlock($block, $this->id, $this->meta); return true; } diff --git a/src/classes/material/item/generic/Painting.php b/src/classes/material/item/generic/Painting.php index dcd50a3bd..1dde5c70e 100644 --- a/src/classes/material/item/generic/Painting.php +++ b/src/classes/material/item/generic/Painting.php @@ -33,11 +33,29 @@ class PaintingItem extends Item{ public function onActivate(BlockAPI $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ if($target->isTransparent === false and $face > 1){ + $faces = array( + 2 => 1, + 3 => 3, + 4 => 0, + 5 => 2, + + ); + $motives = array( + "Kebab", + "Aztec", + "Alban", + "Aztec2", + "Bomb", + "Plant", + "Wasteland", + ); + $data = array( "x" => $target->x, "y" => $target->y, "z" => $target->z, - "yaw" => ($face % 4) * 90, + "yaw" => $faces[$face] * 90, + "Motive" => $motives[mt_rand(0, count($motives) - 1)], ); $server = ServerAPI::request(); $e = $server->api->entity->add(ENTITY_OBJECT, OBJECT_PAINTING, $data); diff --git a/src/classes/world/Entity.php b/src/classes/world/Entity.php index 9782ac5b0..0ee15b020 100644 --- a/src/classes/world/Entity.php +++ b/src/classes/world/Entity.php @@ -97,7 +97,6 @@ class Entity extends stdClass{ $this->name = ""; $this->tickCounter = 0; $this->server->query("INSERT OR REPLACE INTO entities (EID, type, class, health) VALUES (".$this->eid.", ".$this->type.", ".$this->class.", ".$this->health.");"); - $this->server->schedule(5, array($this, "update"), array(), true); $this->x = isset($this->data["x"]) ? $this->data["x"]:0; $this->y = isset($this->data["y"]) ? $this->data["y"]:0; $this->z = isset($this->data["z"]) ? $this->data["z"]:0; @@ -112,22 +111,25 @@ class Entity extends stdClass{ case ENTITY_PLAYER: $this->player = $this->data["player"]; $this->setHealth($this->health, "generic"); + $this->server->schedule(5, array($this, "update"), array(), true); break; case ENTITY_ITEM: $this->meta = (int) $this->data["meta"]; $this->stack = (int) $this->data["stack"]; $this->setHealth(5, "generic"); + $this->server->schedule(5, array($this, "update"), array(), true); break; case ENTITY_MOB: $this->setHealth($this->data["Health"], "generic"); + //$this->server->schedule(5, array($this, "update"), array(), true); //$this->setName((isset($mobs[$this->type]) ? $mobs[$this->type]:$this->type)); break; case ENTITY_OBJECT: + $this->x = isset($this->data["TileX"]) ? $this->data["TileX"]:$this->x; + $this->y = isset($this->data["TileY"]) ? $this->data["TileY"]:$this->y; + $this->z = isset($this->data["TileZ"]) ? $this->data["TileZ"]:$this->z; $this->setHealth(1, "generic"); //$this->setName((isset($objects[$this->type]) ? $objects[$this->type]:$this->type)); - break; - case ENTITY_PAINTING: - break; } } @@ -281,7 +283,9 @@ class Entity extends stdClass{ } if($this->fallY !== false and ($this->fallStart + 8) < microtime(true)){ //Flying $this->harm(1, "flying"); - $this->fallY = $y; + if($y > $this->fallY){ + $this->fallY = $y; + } } }elseif($this->fallY !== false){ //Fall damage! if($y < $this->fallY){ @@ -298,7 +302,7 @@ class Entity extends stdClass{ } } - if($this->last[0] != $this->x or $this->last[1] != $this->y or $this->last[2] != $this->z or $this->last[3] != $this->yaw or $this->last[4] != $this->pitch){ + if($this->class !== ENTITY_OBJECT and ($this->last[0] != $this->x or $this->last[1] != $this->y or $this->last[2] != $this->z or $this->last[3] != $this->yaw or $this->last[4] != $this->pitch)){ $this->server->api->dhandle("entity.move", $this); if($this->class === ENTITY_PLAYER){ $this->calculateVelocity(); @@ -400,7 +404,7 @@ class Entity extends stdClass{ "y" => (int) $this->y, "z" => (int) $this->z, "direction" => $this->getDirection(), - "title" => "Creepers", + "title" => $this->data["Motive"], )); } break; @@ -548,6 +552,8 @@ class Entity extends stdClass{ $this->air = 300; $this->fire = 0; $this->crouched = false; + $this->fallY = false; + $this->fallStart = false; $this->updateMetadata(); $this->dead = true; $this->server->api->dhandle("entity.event", array("entity" => $this, "event" => 3)); //Entity dead