Merge branch master

This commit is contained in:
PEMapModder 2016-02-22 14:32:37 +08:00
commit a2641f923d
21 changed files with 98 additions and 60 deletions

View File

@ -21,6 +21,7 @@
namespace pocketmine;
use pocketmine\block\Air;
use pocketmine\block\Block;
use pocketmine\command\CommandSender;
use pocketmine\entity\Arrow;
@ -132,6 +133,7 @@ use pocketmine\tile\Tile;
use pocketmine\utils\TextFormat;
use raklib\Binary;
/**
* Main class that handles networking, recovery, and packet sending to the server part
*/
@ -598,6 +600,10 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
return $this->sleeping !== null;
}
public function getInAirTicks(){
return $this->inAirTicks;
}
protected function switchLevel(Level $targetLevel){
$oldLevel = $this->level;
if(parent::switchLevel($targetLevel)){
@ -2066,6 +2072,10 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
$this->inventory->sendHeldItem($this);
break;
}
$block = $target->getSide($packet->face);
if($block->getId() === Block::FIRE){
$this->level->setBlock($block, new Air());
}
$this->lastBreak = microtime(true);
break;
case PlayerActionPacket::ACTION_ABORT_BREAK:
@ -3470,9 +3480,10 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
}
/**
* @param $chunkX
* @param $chunkZ
* @param $payload
* @param int $chunkX
* @param int $chunkZ
* @param string $payload
* @param int $ordering
*
* @return DataPacket
*/

View File

@ -75,8 +75,8 @@ namespace pocketmine {
const VERSION = "1.6dev";
const API_VERSION = "2.0.0";
const CODENAME = "[REDACTED]";
const MINECRAFT_VERSION = "v0.14.0.7 alpha";
const MINECRAFT_VERSION_NETWORK = "0.14.0.7";
const MINECRAFT_VERSION = "v0.14.0.0 alpha";
const MINECRAFT_VERSION_NETWORK = "0.14.0.0";
/*
* Startup code. Do not look at it, it may harm you.

View File

@ -972,6 +972,8 @@ class Server{
* @param bool $forceUnload
*
* @return bool
*
* @throws \InvalidStateException
*/
public function unloadLevel(Level $level, $forceUnload = false){
if($level === $this->getDefaultLevel() and !$forceUnload){

View File

@ -22,6 +22,7 @@
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\Tool;
class DoubleWoodSlab extends Solid{

View File

@ -24,6 +24,7 @@ namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\Tool;
use pocketmine\math\AxisAlignedBB;
use pocketmine\level\sound\DoorSound;
use pocketmine\Player;
class IronTrapdoor extends Transparent{

View File

@ -73,7 +73,9 @@ class TallGrass extends Flowable{
public function getDrops(Item $item){
if(mt_rand(0, 15) === 0){
return [Item::WHEAT_SEEDS, 0, 1];
return [
[Item::WHEAT_SEEDS, 0, 1]
];
}
return [];

View File

@ -44,6 +44,7 @@ class TeleportCommand extends VanillaCommand{
return true;
}
$args = array_filter($args);
if(count($args) < 1 or count($args) > 6){
$sender->sendMessage(new TranslationContainer("commands.generic.usage", [$this->usageMessage]));

View File

@ -602,7 +602,8 @@ abstract class Entity extends Location implements Metadatable{
if($this->hasEffect(Effect::FIRE_RESISTANCE)
and $source->getCause() === EntityDamageEvent::CAUSE_FIRE
and $source->getCause() === EntityDamageEvent::CAUSE_FIRE_TICK
and $source->getCause() === EntityDamageEvent::CAUSE_LAVA){
and $source->getCause() === EntityDamageEvent::CAUSE_LAVA
){
$source->setCancelled();
}
@ -781,7 +782,7 @@ abstract class Entity extends Location implements Metadatable{
}
if($direction === 5){
$this->motionY = $force;
$this->motionZ = $force;
return true;
}
@ -1555,7 +1556,7 @@ abstract class Entity extends Location implements Metadatable{
}
/**
* @param int $propertyId;
* @param int $propertyId
* @param int $id
* @param bool $value
*/

View File

@ -72,12 +72,14 @@ class Item extends Entity{
$this->thrower = $this->namedtag["Thrower"];
}
assert($this->namedtag->Item instanceof CompoundTag);
if(!isset($this->namedtag->Item)){
$this->close();
return;
}
assert($this->namedtag->Item instanceof CompoundTag);
$this->item = NBT::getItemHelper($this->namedtag->Item);

View File

@ -69,7 +69,7 @@ class CraftItemEvent extends Event implements Cancellable{
}
/**
* @return \pocktemine\Player
* @return \pocketmine\Player
*/
public function getPlayer(){
return $this->player;

View File

@ -83,4 +83,11 @@ abstract class PlayerBucketEvent extends PlayerEvent implements Cancellable{
public function getBlockClicked(){
return $this->blockClicked;
}
/**
* @return int
*/
public function getBlockFace(){
return $this->blockFace;
}
}

View File

@ -50,6 +50,13 @@ class PlayerDeathEvent extends EntityDeathEvent{
return $this->entity;
}
/**
* @return Player
*/
public function getPlayer(){
return $this->entity;
}
/**
* @return TextContainer|string
*/

View File

@ -22,21 +22,11 @@
namespace pocketmine\inventory;
use pocketmine\block\Planks;
use pocketmine\block\Quartz;
use pocketmine\block\Sandstone;
use pocketmine\block\Slab;
use pocketmine\block\Fence;
use pocketmine\block\Stone;
use pocketmine\block\StoneBricks;
use pocketmine\block\StoneWall;
use pocketmine\block\Wood;
use pocketmine\block\Wood2;
use pocketmine\item\Item;
use pocketmine\utils\UUID;
use pocketmine\Server;
use pocketmine\utils\MainLogger;
use pocketmine\utils\Config;
use pocketmine\utils\MainLogger;
use pocketmine\utils\UUID;
class CraftingManager{
@ -55,7 +45,7 @@ class CraftingManager{
// load recipes from src/pocketmine/recipes.json
$recipes = new Config(Server::getInstance()->getFilePath() . "src/pocketmine/resources/recipes.json", Config::JSON, []);
MainLogger::getLogger()->Info("Loading recipes...");
MainLogger::getLogger()->info("Loading recipes...");
foreach($recipes->getAll() as $recipe){
switch($recipe["Type"]){
case 0:

View File

@ -2453,6 +2453,8 @@ class Level implements ChunkManager, Metadatable{
* @param bool $generate
*
* @return bool
*
* @throws \InvalidStateException
*/
public function loadChunk(int $x, int $z, bool $generate = true) : bool{
if(isset($this->chunks[$index = Level::chunkHash($x, $z)])){
@ -2599,7 +2601,7 @@ class Level implements ChunkManager, Metadatable{
* @return bool|Position
*/
public function getSafeSpawn($spawn = null){
if(!($spawn instanceof Vector3) or $spawn->y <= 0){
if(!($spawn instanceof Vector3) or $spawn->y < 1){
$spawn = $this->getSpawnLocation();
}
if($spawn instanceof Vector3){

View File

@ -50,6 +50,7 @@ abstract class BaseLevelProvider implements LevelProvider{
$levelData = $nbt->getData();
if($levelData->Data instanceof CompoundTag){
$this->levelData = $levelData->Data;
assert(is_int($this->levelData["RandomSeed"]));
}else{
throw new LevelException("Invalid level.dat");
}

View File

@ -92,7 +92,7 @@ class McRegion extends BaseLevelProvider{
"version" => new IntTag("version", 19133),
"DayTime" => new IntTag("DayTime", 0),
"LastPlayed" => new LongTag("LastPlayed", microtime(true) * 1000),
"RandomSeed" => new LongTag("RandomSeed", $seed),
"RandomSeed" => new LongTag("RandomSeed", (int) $seed),
"SizeOnDisk" => new LongTag("SizeOnDisk", 0),
"Time" => new LongTag("Time", 0),
"generatorName" => new StringTag("generatorName", Generator::getGeneratorName($generator)),

View File

@ -81,6 +81,8 @@ abstract class Generator{
* @param int $z
*
* @return \SplFixedArray
*
* @throws \InvalidArgumentCountException
*/
public static function getFastNoise1D(Noise $noise, $xSize, $samplingRate, $x, $y, $z){
if($samplingRate === 0){
@ -116,6 +118,9 @@ abstract class Generator{
* @param int $z
*
* @return \SplFixedArray
*
* @throws \InvalidArgumentException
* @throws \InvalidArgumentCountException
*/
public static function getFastNoise2D(Noise $noise, $xSize, $zSize, $samplingRate, $x, $y, $z){
assert($samplingRate !== 0, new \InvalidArgumentException("samplingRate cannot be 0"));
@ -166,6 +171,9 @@ abstract class Generator{
* @param int $z
*
* @return \SplFixedArray
*
* @throws \InvalidArgumentException
* @throws \InvalidArgumentCountException
*/
public static function getFastNoise3D(Noise $noise, $xSize, $ySize, $zSize, $xSamplingRate, $ySamplingRate, $zSamplingRate, $x, $y, $z){

View File

@ -29,7 +29,7 @@ class CompressBatchedTask extends AsyncTask{
public $level = 7;
public $data;
public $final;
public $targets = [];
public $targets;
public function __construct($data, array $targets, $level = 7){
$this->data = $data;
@ -47,6 +47,6 @@ class CompressBatchedTask extends AsyncTask{
}
public function onCompletion(Server $server){
$server->broadcastPacketsCallback($this->final, $this->targets);
$server->broadcastPacketsCallback($this->final, (array) $this->targets);
}
}

View File

@ -54,7 +54,8 @@ interface Plugin extends CommandExecutor{
public function isDisabled();
/**
* Gets the plugin's data folder to save files and configuration
* Gets the plugin's data folder to save files and configuration.
* This directory name has a trailing slash.
*/
public function getDataFolder();

View File

@ -251,8 +251,9 @@ abstract class PluginBase implements Plugin{
public function saveDefaultConfig(){
if(!file_exists($this->configFile)){
$this->saveResource("config.yml", false);
return $this->saveResource("config.yml", false);
}
return false;
}
public function reloadConfig(){