1
0
mirror of https://github.com/pmmp/PocketMine-MP.git synced 2025-05-29 00:26:56 +00:00

Merge branch 'master' into mcpe-1.0

This commit is contained in:
Dylan K. Taylor 2016-12-19 18:38:13 +00:00
commit d9eb767420
14 changed files with 55 additions and 29 deletions

@ -65,6 +65,7 @@ namespace {
} }
namespace pocketmine { namespace pocketmine {
use pocketmine\network\protocol\Info as ProtocolInfo;
use pocketmine\utils\Binary; use pocketmine\utils\Binary;
use pocketmine\utils\MainLogger; use pocketmine\utils\MainLogger;
use pocketmine\utils\ServerKiller; use pocketmine\utils\ServerKiller;
@ -76,8 +77,6 @@ namespace pocketmine {
const VERSION = "1.6.2dev"; const VERSION = "1.6.2dev";
const API_VERSION = "2.2.0"; const API_VERSION = "2.2.0";
const CODENAME = "Unleashed"; const CODENAME = "Unleashed";
const MINECRAFT_VERSION = "v1.0.0.2";
const MINECRAFT_VERSION_NETWORK = "1.0.0.2";
/* /*
* Startup code. Do not look at it, it may harm you. * Startup code. Do not look at it, it may harm you.
@ -146,6 +145,16 @@ namespace pocketmine {
define('pocketmine\DATA', isset($opts["data"]) ? $opts["data"] . DIRECTORY_SEPARATOR : \getcwd() . DIRECTORY_SEPARATOR); define('pocketmine\DATA', isset($opts["data"]) ? $opts["data"] . DIRECTORY_SEPARATOR : \getcwd() . DIRECTORY_SEPARATOR);
define('pocketmine\PLUGIN_PATH', isset($opts["plugins"]) ? $opts["plugins"] . DIRECTORY_SEPARATOR : \getcwd() . DIRECTORY_SEPARATOR . "plugins" . DIRECTORY_SEPARATOR); define('pocketmine\PLUGIN_PATH', isset($opts["plugins"]) ? $opts["plugins"] . DIRECTORY_SEPARATOR : \getcwd() . DIRECTORY_SEPARATOR . "plugins" . DIRECTORY_SEPARATOR);
/**
* @deprecated This constant has moved to {@link \pocketmine\network\protocol\Info} and will be removed from here in the future.
*/
const MINECRAFT_VERSION = ProtocolInfo::MINECRAFT_VERSION;
/**
* @deprecated This constant has moved to {@link \pocketmine\network\protocol\Info} and will be removed from here in the future.
*/
const MINECRAFT_VERSION_NETWORK = ProtocolInfo::MINECRAFT_VERSION_NETWORK;
Terminal::init(); Terminal::init();
define('pocketmine\ANSI', Terminal::hasFormattingCodes()); define('pocketmine\ANSI', Terminal::hasFormattingCodes());

@ -87,6 +87,7 @@ use pocketmine\network\Network;
use pocketmine\network\protocol\BatchPacket; use pocketmine\network\protocol\BatchPacket;
use pocketmine\network\protocol\CraftingDataPacket; use pocketmine\network\protocol\CraftingDataPacket;
use pocketmine\network\protocol\DataPacket; use pocketmine\network\protocol\DataPacket;
use pocketmine\network\protocol\Info as ProtocolInfo;
use pocketmine\network\protocol\PlayerListPacket; use pocketmine\network\protocol\PlayerListPacket;
use pocketmine\network\query\QueryHandler; use pocketmine\network\query\QueryHandler;
use pocketmine\network\RakLibInterface; use pocketmine\network\RakLibInterface;
@ -301,7 +302,7 @@ class Server{
* @return string * @return string
*/ */
public function getVersion(){ public function getVersion(){
return \pocketmine\MINECRAFT_VERSION; return ProtocolInfo::MINECRAFT_VERSION;
} }
/** /**

@ -52,7 +52,7 @@ class DoublePlant extends Flowable{
public function onUpdate($type){ public function onUpdate($type){
if($type === Level::BLOCK_UPDATE_NORMAL){ if($type === Level::BLOCK_UPDATE_NORMAL){
if($this->getSide(0)->isTransparent() === true){ //Replace with common break method if($this->getSide(0)->isTransparent() === true){ //Replace with common break method
$this->getLevel()->setBlock($this, new Air(), false, false, true); $this->getLevel()->setBlock($this, new Air(), true, true);
return Level::BLOCK_UPDATE_NORMAL; return Level::BLOCK_UPDATE_NORMAL;
} }

@ -22,7 +22,6 @@
namespace pocketmine\block; namespace pocketmine\block;
use pocketmine\entity\Entity; use pocketmine\entity\Entity;
use pocketmine\item\Item;
use pocketmine\level\Level; use pocketmine\level\Level;
use pocketmine\math\Vector3; use pocketmine\math\Vector3;
use pocketmine\nbt\tag\ByteTag; use pocketmine\nbt\tag\ByteTag;
@ -31,16 +30,9 @@ use pocketmine\nbt\tag\DoubleTag;
use pocketmine\nbt\tag\FloatTag; use pocketmine\nbt\tag\FloatTag;
use pocketmine\nbt\tag\IntTag; use pocketmine\nbt\tag\IntTag;
use pocketmine\nbt\tag\ListTag; use pocketmine\nbt\tag\ListTag;
use pocketmine\Player;
abstract class Fallable extends Solid{ abstract class Fallable extends Solid{
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
$ret = $this->getLevel()->setBlock($this, $this, true, true);
return $ret;
}
public function onUpdate($type){ public function onUpdate($type){
if($type === Level::BLOCK_UPDATE_NORMAL){ if($type === Level::BLOCK_UPDATE_NORMAL){
$down = $this->getSide(Vector3::SIDE_DOWN); $down = $this->getSide(Vector3::SIDE_DOWN);

@ -124,11 +124,16 @@ class Ladder extends Transparent{
public function onUpdate($type){ public function onUpdate($type){
if($type === Level::BLOCK_UPDATE_NORMAL){ if($type === Level::BLOCK_UPDATE_NORMAL){
/*if($this->getSide(0)->getId() === self::AIR){ //Replace with common break method $sides = [
Server::getInstance()->api->entity->drop($this, Item::get(LADDER, 0, 1)); 2 => 3,
$this->getLevel()->setBlock($this, new Air(), true, true, true); 3 => 2,
4 => 5,
5 => 4
];
if(!$this->getSide($sides[$this->meta])->isSolid()){ //Replace with common break method
$this->level->useBreakOn($this);
return Level::BLOCK_UPDATE_NORMAL; return Level::BLOCK_UPDATE_NORMAL;
}*/ }
} }
return false; return false;

@ -129,7 +129,7 @@ class Leaves extends Transparent{
if($type === Level::BLOCK_UPDATE_NORMAL){ if($type === Level::BLOCK_UPDATE_NORMAL){
if(($this->meta & 0b00001100) === 0){ if(($this->meta & 0b00001100) === 0){
$this->meta |= 0x08; $this->meta |= 0x08;
$this->getLevel()->setBlock($this, $this, false, false, true); $this->getLevel()->setBlock($this, $this, true, false);
} }
}elseif($type === Level::BLOCK_UPDATE_RANDOM){ }elseif($type === Level::BLOCK_UPDATE_RANDOM){
if(($this->meta & 0b00001100) === 0x08){ if(($this->meta & 0b00001100) === 0x08){

@ -112,7 +112,7 @@ class Leaves2 extends Leaves{
if($type === Level::BLOCK_UPDATE_NORMAL){ if($type === Level::BLOCK_UPDATE_NORMAL){
if(($this->meta & 0b00001100) === 0){ if(($this->meta & 0b00001100) === 0){
$this->meta |= 0x08; $this->meta |= 0x08;
$this->getLevel()->setBlock($this, $this, false, false, true); $this->getLevel()->setBlock($this, $this, true, false);
} }
}elseif($type === Level::BLOCK_UPDATE_RANDOM){ }elseif($type === Level::BLOCK_UPDATE_RANDOM){
if(($this->meta & 0b00001100) === 0x08){ if(($this->meta & 0b00001100) === 0x08){

@ -62,7 +62,7 @@ class TallGrass extends Flowable{
public function onUpdate($type){ public function onUpdate($type){
if($type === Level::BLOCK_UPDATE_NORMAL){ if($type === Level::BLOCK_UPDATE_NORMAL){
if($this->getSide(0)->isTransparent() === true){ //Replace with common break method if($this->getSide(0)->isTransparent() === true){ //Replace with common break method
$this->getLevel()->setBlock($this, new Air(), false, false, true); $this->getLevel()->setBlock($this, new Air(), true, true);
return Level::BLOCK_UPDATE_NORMAL; return Level::BLOCK_UPDATE_NORMAL;
} }

@ -146,7 +146,7 @@ class Vine extends Transparent{
if($type === Level::BLOCK_UPDATE_NORMAL){ if($type === Level::BLOCK_UPDATE_NORMAL){
/*if($this->getSide(0)->getId() === self::AIR){ //Replace with common break method /*if($this->getSide(0)->getId() === self::AIR){ //Replace with common break method
Server::getInstance()->api->entity->drop($this, Item::get(LADDER, 0, 1)); Server::getInstance()->api->entity->drop($this, Item::get(LADDER, 0, 1));
$this->getLevel()->setBlock($this, new Air(), true, true, true); $this->getLevel()->setBlock($this, new Air(), true, true);
return Level::BLOCK_UPDATE_NORMAL; return Level::BLOCK_UPDATE_NORMAL;
}*/ }*/
} }

@ -28,6 +28,7 @@ class CommandReader extends Thread{
/** @var \Threaded */ /** @var \Threaded */
protected $buffer; protected $buffer;
private $shutdown = false; private $shutdown = false;
private $streamBlocking = false;
public function __construct(){ public function __construct(){
$this->buffer = new \Threaded; $this->buffer = new \Threaded;
@ -40,15 +41,28 @@ class CommandReader extends Thread{
$this->shutdown = true; $this->shutdown = true;
} }
private function initStdin(){
global $stdin;
$stdin = fopen("php://stdin", "r");
$this->streamBlocking = (stream_set_blocking($stdin, 0) === false);
}
private function readLine(){ private function readLine(){
if(!$this->readline){ if(!$this->readline){
global $stdin; global $stdin;
if(!is_resource($stdin)){ if(!is_resource($stdin)){
return ""; $this->initStdin();
} }
return trim(fgets($stdin)); $line = fgets($stdin);
if($line === false and $this->streamBlocking === true){ //windows sucks
$this->initStdin();
$line = fgets($stdin);
}
return trim($line);
}else{ }else{
$line = trim(readline("> ")); $line = trim(readline("> "));
if($line != ""){ if($line != ""){
@ -74,9 +88,7 @@ class CommandReader extends Thread{
public function run(){ public function run(){
if(!$this->readline){ if(!$this->readline){
global $stdin; $this->initStdin();
$stdin = fopen("php://stdin", "r");
stream_set_blocking($stdin, 0);
} }
$lastLine = microtime(true); $lastLine = microtime(true);
@ -91,6 +103,11 @@ class CommandReader extends Thread{
$lastLine = microtime(true); $lastLine = microtime(true);
} }
if(!$this->readline){
global $stdin;
fclose($stdin);
}
} }
public function getThreadName(){ public function getThreadName(){

@ -172,7 +172,7 @@ class RakLibInterface implements ServerInstance, AdvancedSourceInterface{
$this->interface->sendOption("name", $this->interface->sendOption("name",
"MCPE;" . addcslashes($name, ";") . ";" . "MCPE;" . addcslashes($name, ";") . ";" .
Info::CURRENT_PROTOCOL . ";" . Info::CURRENT_PROTOCOL . ";" .
\pocketmine\MINECRAFT_VERSION_NETWORK . ";" . Info::MINECRAFT_VERSION_NETWORK . ";" .
$info->getPlayerCount() . ";" . $info->getPlayerCount() . ";" .
$info->getMaxPlayerCount() $info->getMaxPlayerCount()
); );

@ -31,6 +31,8 @@ interface Info{
* Actual Minecraft: PE protocol version * Actual Minecraft: PE protocol version
*/ */
const CURRENT_PROTOCOL = 100; const CURRENT_PROTOCOL = 100;
const MINECRAFT_VERSION = "v1.0.0.16";
const MINECRAFT_VERSION_NETWORK = "1.0.0.16";
const LOGIN_PACKET = 0x01; const LOGIN_PACKET = 0x01;
const PLAY_STATUS_PACKET = 0x02; const PLAY_STATUS_PACKET = 0x02;

@ -105,7 +105,7 @@ class ScriptPluginLoader implements PluginLoader{
$data[$key] = $content; $data[$key] = $content;
} }
if($insideHeader and strpos($line, "**/") !== false){ if($insideHeader and strpos($line, "*/") !== false){
break; break;
} }
} }

@ -1,8 +1,8 @@
#!/bin/bash #!/bin/bash
echo -e "version\nmakeserver\nstop\n" | php src/pocketmine/PocketMine.php --no-wizard --disable-ansi --disable-readline echo -e "version\nmakeserver\nstop\n" | php src/pocketmine/PocketMine.php --no-wizard --disable-ansi --disable-readline --debug.level=2
if ls plugins/DevTools/PocketMine*.phar >/dev/null 2>&1; then if ls plugins/DevTools/PocketMine*.phar >/dev/null 2>&1; then
echo Server phar created successfully. echo Server phar created successfully.
else else
echo No phar created! echo No phar created!
exit 1 exit 1
fi fi