diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index 19dd1696b..09c293020 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -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 */ diff --git a/src/pocketmine/PocketMine.php b/src/pocketmine/PocketMine.php index 92e5d084a..67040f078 100644 --- a/src/pocketmine/PocketMine.php +++ b/src/pocketmine/PocketMine.php @@ -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. diff --git a/src/pocketmine/Server.php b/src/pocketmine/Server.php index f997e19dd..12c83dcea 100644 --- a/src/pocketmine/Server.php +++ b/src/pocketmine/Server.php @@ -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){ diff --git a/src/pocketmine/block/DoubleWoodSlab.php b/src/pocketmine/block/DoubleWoodSlab.php index a28170e39..1fc768cab 100644 --- a/src/pocketmine/block/DoubleWoodSlab.php +++ b/src/pocketmine/block/DoubleWoodSlab.php @@ -22,6 +22,7 @@ namespace pocketmine\block; use pocketmine\item\Item; +use pocketmine\item\Tool; class DoubleWoodSlab extends Solid{ diff --git a/src/pocketmine/block/IronTrapdoor.php b/src/pocketmine/block/IronTrapdoor.php index b23d2a225..c2844d51b 100644 --- a/src/pocketmine/block/IronTrapdoor.php +++ b/src/pocketmine/block/IronTrapdoor.php @@ -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{ @@ -153,4 +154,4 @@ class IronTrapdoor extends Transparent{ public function getToolType(){ return Tool::TYPE_PICKAXE; } -} \ No newline at end of file +} diff --git a/src/pocketmine/block/TallGrass.php b/src/pocketmine/block/TallGrass.php index bce7fef36..c912a0787 100644 --- a/src/pocketmine/block/TallGrass.php +++ b/src/pocketmine/block/TallGrass.php @@ -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 []; diff --git a/src/pocketmine/command/defaults/TeleportCommand.php b/src/pocketmine/command/defaults/TeleportCommand.php index c599f9590..b7e21e7ef 100644 --- a/src/pocketmine/command/defaults/TeleportCommand.php +++ b/src/pocketmine/command/defaults/TeleportCommand.php @@ -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])); diff --git a/src/pocketmine/entity/Entity.php b/src/pocketmine/entity/Entity.php index 7aa462dc1..eab6b1e49 100644 --- a/src/pocketmine/entity/Entity.php +++ b/src/pocketmine/entity/Entity.php @@ -83,7 +83,7 @@ abstract class Entity extends Location implements Metadatable{ const DATA_SILENT = 4; const DATA_POTION_COLOR = 7; const DATA_POTION_AMBIENT = 8; - const DATA_NO_AI = 15; + const DATA_NO_AI = 15; const DATA_FLAG_ONFIRE = 0; @@ -567,7 +567,7 @@ abstract class Entity extends Location implements Metadatable{ /** * @param Player[]|Player $player - * @param array $data Properly formatted entity data, defaults to everything + * @param array $data Properly formatted entity data, defaults to everything */ public function sendData($player, array $data = null){ $pk = new SetEntityDataPacket(); @@ -598,23 +598,24 @@ abstract class Entity extends Location implements Metadatable{ * @param EntityDamageEvent $source * */ - public function attack($damage, EntityDamageEvent $source){ - 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){ - $source->setCancelled(); - } + public function attack($damage, EntityDamageEvent $source){ + 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 + ){ + $source->setCancelled(); + } - $this->server->getPluginManager()->callEvent($source); - if($source->isCancelled()){ - return; - } + $this->server->getPluginManager()->callEvent($source); + if($source->isCancelled()){ + return; + } - $this->setLastDamageCause($source); + $this->setLastDamageCause($source); - $this->setHealth($this->getHealth() - $source->getFinalDamage()); - } + $this->setHealth($this->getHealth() - $source->getFinalDamage()); + } /** * @param float $amount @@ -622,13 +623,13 @@ abstract class Entity extends Location implements Metadatable{ * */ public function heal($amount, EntityRegainHealthEvent $source){ - $this->server->getPluginManager()->callEvent($source); - if($source->isCancelled()){ - return; - } + $this->server->getPluginManager()->callEvent($source); + if($source->isCancelled()){ + return; + } - $this->setHealth($this->getHealth() + $source->getAmount()); - } + $this->setHealth($this->getHealth() + $source->getAmount()); + } /** * @return int @@ -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 */ diff --git a/src/pocketmine/entity/Item.php b/src/pocketmine/entity/Item.php index 76269d569..5493ea6e5 100644 --- a/src/pocketmine/entity/Item.php +++ b/src/pocketmine/entity/Item.php @@ -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); diff --git a/src/pocketmine/event/inventory/CraftItemEvent.php b/src/pocketmine/event/inventory/CraftItemEvent.php index b5c466bda..a069c3dfa 100644 --- a/src/pocketmine/event/inventory/CraftItemEvent.php +++ b/src/pocketmine/event/inventory/CraftItemEvent.php @@ -69,7 +69,7 @@ class CraftItemEvent extends Event implements Cancellable{ } /** - * @return \pocktemine\Player + * @return \pocketmine\Player */ public function getPlayer(){ return $this->player; diff --git a/src/pocketmine/event/player/PlayerBucketEvent.php b/src/pocketmine/event/player/PlayerBucketEvent.php index 48d67db21..f0490b14f 100644 --- a/src/pocketmine/event/player/PlayerBucketEvent.php +++ b/src/pocketmine/event/player/PlayerBucketEvent.php @@ -83,4 +83,11 @@ abstract class PlayerBucketEvent extends PlayerEvent implements Cancellable{ public function getBlockClicked(){ return $this->blockClicked; } -} \ No newline at end of file + + /** + * @return int + */ + public function getBlockFace(){ + return $this->blockFace; + } +} diff --git a/src/pocketmine/event/player/PlayerDeathEvent.php b/src/pocketmine/event/player/PlayerDeathEvent.php index f705b7ae7..16bbe33a5 100644 --- a/src/pocketmine/event/player/PlayerDeathEvent.php +++ b/src/pocketmine/event/player/PlayerDeathEvent.php @@ -34,8 +34,8 @@ class PlayerDeathEvent extends EntityDeathEvent{ private $keepInventory = false; /** - * @param Player $entity - * @param Item[] $drops + * @param Player $entity + * @param Item[] $drops * @param string|TextContainer $deathMessage */ public function __construct(Player $entity, array $drops, $deathMessage){ @@ -50,6 +50,13 @@ class PlayerDeathEvent extends EntityDeathEvent{ return $this->entity; } + /** + * @return Player + */ + public function getPlayer(){ + return $this->entity; + } + /** * @return TextContainer|string */ diff --git a/src/pocketmine/inventory/CraftingManager.php b/src/pocketmine/inventory/CraftingManager.php index 5cf0b6763..6ff6f1e0b 100644 --- a/src/pocketmine/inventory/CraftingManager.php +++ b/src/pocketmine/inventory/CraftingManager.php @@ -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: diff --git a/src/pocketmine/level/Level.php b/src/pocketmine/level/Level.php index cb0f228c1..166850df4 100644 --- a/src/pocketmine/level/Level.php +++ b/src/pocketmine/level/Level.php @@ -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){ diff --git a/src/pocketmine/level/format/generic/BaseLevelProvider.php b/src/pocketmine/level/format/generic/BaseLevelProvider.php index dd5d2c11b..5c7bba013 100644 --- a/src/pocketmine/level/format/generic/BaseLevelProvider.php +++ b/src/pocketmine/level/format/generic/BaseLevelProvider.php @@ -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"); } @@ -126,4 +127,4 @@ abstract class BaseLevelProvider implements LevelProvider{ } -} \ No newline at end of file +} diff --git a/src/pocketmine/level/format/mcregion/McRegion.php b/src/pocketmine/level/format/mcregion/McRegion.php index 9d00c0b16..af7e6e418 100644 --- a/src/pocketmine/level/format/mcregion/McRegion.php +++ b/src/pocketmine/level/format/mcregion/McRegion.php @@ -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)), @@ -324,4 +324,4 @@ class McRegion extends BaseLevelProvider{ } $this->level = null; } -} \ No newline at end of file +} diff --git a/src/pocketmine/level/generator/Generator.php b/src/pocketmine/level/generator/Generator.php index 007c82751..2a68ea10a 100644 --- a/src/pocketmine/level/generator/Generator.php +++ b/src/pocketmine/level/generator/Generator.php @@ -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){ diff --git a/src/pocketmine/network/CompressBatchedTask.php b/src/pocketmine/network/CompressBatchedTask.php index e2e68ca7b..c8fdb426b 100644 --- a/src/pocketmine/network/CompressBatchedTask.php +++ b/src/pocketmine/network/CompressBatchedTask.php @@ -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); } -} \ No newline at end of file +} diff --git a/src/pocketmine/network/protocol/ContainerSetSlotPacket.php b/src/pocketmine/network/protocol/ContainerSetSlotPacket.php index 2cf8bfca0..bc385f34c 100644 --- a/src/pocketmine/network/protocol/ContainerSetSlotPacket.php +++ b/src/pocketmine/network/protocol/ContainerSetSlotPacket.php @@ -49,4 +49,4 @@ class ContainerSetSlotPacket extends DataPacket{ $this->putSlot($this->item); } -} \ No newline at end of file +} diff --git a/src/pocketmine/plugin/Plugin.php b/src/pocketmine/plugin/Plugin.php index d01083536..ece3905d1 100644 --- a/src/pocketmine/plugin/Plugin.php +++ b/src/pocketmine/plugin/Plugin.php @@ -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(); @@ -111,4 +112,4 @@ interface Plugin extends CommandExecutor{ */ public function getPluginLoader(); -} \ No newline at end of file +} diff --git a/src/pocketmine/plugin/PluginBase.php b/src/pocketmine/plugin/PluginBase.php index a928fe840..a2e79bde3 100644 --- a/src/pocketmine/plugin/PluginBase.php +++ b/src/pocketmine/plugin/PluginBase.php @@ -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(){