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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -44,6 +44,7 @@ class TeleportCommand extends VanillaCommand{
return true; return true;
} }
$args = array_filter($args);
if(count($args) < 1 or count($args) > 6){ if(count($args) < 1 or count($args) > 6){
$sender->sendMessage(new TranslationContainer("commands.generic.usage", [$this->usageMessage])); $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) if($this->hasEffect(Effect::FIRE_RESISTANCE)
and $source->getCause() === EntityDamageEvent::CAUSE_FIRE and $source->getCause() === EntityDamageEvent::CAUSE_FIRE
and $source->getCause() === EntityDamageEvent::CAUSE_FIRE_TICK and $source->getCause() === EntityDamageEvent::CAUSE_FIRE_TICK
and $source->getCause() === EntityDamageEvent::CAUSE_LAVA){ and $source->getCause() === EntityDamageEvent::CAUSE_LAVA
){
$source->setCancelled(); $source->setCancelled();
} }
@ -781,7 +782,7 @@ abstract class Entity extends Location implements Metadatable{
} }
if($direction === 5){ if($direction === 5){
$this->motionY = $force; $this->motionZ = $force;
return true; return true;
} }
@ -1555,7 +1556,7 @@ abstract class Entity extends Location implements Metadatable{
} }
/** /**
* @param int $propertyId; * @param int $propertyId
* @param int $id * @param int $id
* @param bool $value * @param bool $value
*/ */

View File

@ -72,12 +72,14 @@ class Item extends Entity{
$this->thrower = $this->namedtag["Thrower"]; $this->thrower = $this->namedtag["Thrower"];
} }
assert($this->namedtag->Item instanceof CompoundTag);
if(!isset($this->namedtag->Item)){ if(!isset($this->namedtag->Item)){
$this->close(); $this->close();
return; return;
} }
assert($this->namedtag->Item instanceof CompoundTag);
$this->item = NBT::getItemHelper($this->namedtag->Item); $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(){ public function getPlayer(){
return $this->player; return $this->player;

View File

@ -83,4 +83,11 @@ abstract class PlayerBucketEvent extends PlayerEvent implements Cancellable{
public function getBlockClicked(){ public function getBlockClicked(){
return $this->blockClicked; 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 $this->entity;
} }
/**
* @return Player
*/
public function getPlayer(){
return $this->entity;
}
/** /**
* @return TextContainer|string * @return TextContainer|string
*/ */

View File

@ -22,21 +22,11 @@
namespace pocketmine\inventory; 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\item\Item;
use pocketmine\utils\UUID;
use pocketmine\Server; use pocketmine\Server;
use pocketmine\utils\MainLogger;
use pocketmine\utils\Config; use pocketmine\utils\Config;
use pocketmine\utils\MainLogger;
use pocketmine\utils\UUID;
class CraftingManager{ class CraftingManager{
@ -55,7 +45,7 @@ class CraftingManager{
// load recipes from src/pocketmine/recipes.json // load recipes from src/pocketmine/recipes.json
$recipes = new Config(Server::getInstance()->getFilePath() . "src/pocketmine/resources/recipes.json", Config::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){ foreach($recipes->getAll() as $recipe){
switch($recipe["Type"]){ switch($recipe["Type"]){
case 0: case 0:

View File

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

View File

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

View File

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

View File

@ -81,6 +81,8 @@ abstract class Generator{
* @param int $z * @param int $z
* *
* @return \SplFixedArray * @return \SplFixedArray
*
* @throws \InvalidArgumentCountException
*/ */
public static function getFastNoise1D(Noise $noise, $xSize, $samplingRate, $x, $y, $z){ public static function getFastNoise1D(Noise $noise, $xSize, $samplingRate, $x, $y, $z){
if($samplingRate === 0){ if($samplingRate === 0){
@ -116,6 +118,9 @@ abstract class Generator{
* @param int $z * @param int $z
* *
* @return \SplFixedArray * @return \SplFixedArray
*
* @throws \InvalidArgumentException
* @throws \InvalidArgumentCountException
*/ */
public static function getFastNoise2D(Noise $noise, $xSize, $zSize, $samplingRate, $x, $y, $z){ public static function getFastNoise2D(Noise $noise, $xSize, $zSize, $samplingRate, $x, $y, $z){
assert($samplingRate !== 0, new \InvalidArgumentException("samplingRate cannot be 0")); assert($samplingRate !== 0, new \InvalidArgumentException("samplingRate cannot be 0"));
@ -166,6 +171,9 @@ abstract class Generator{
* @param int $z * @param int $z
* *
* @return \SplFixedArray * @return \SplFixedArray
*
* @throws \InvalidArgumentException
* @throws \InvalidArgumentCountException
*/ */
public static function getFastNoise3D(Noise $noise, $xSize, $ySize, $zSize, $xSamplingRate, $ySamplingRate, $zSamplingRate, $x, $y, $z){ 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 $level = 7;
public $data; public $data;
public $final; public $final;
public $targets = []; public $targets;
public function __construct($data, array $targets, $level = 7){ public function __construct($data, array $targets, $level = 7){
$this->data = $data; $this->data = $data;
@ -47,6 +47,6 @@ class CompressBatchedTask extends AsyncTask{
} }
public function onCompletion(Server $server){ 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(); 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(); public function getDataFolder();

View File

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