From ae9a3dbd81744de750c46d1a08991b2091790b77 Mon Sep 17 00:00:00 2001 From: PEMapModder Date: Tue, 6 Oct 2015 20:32:33 +0800 Subject: [PATCH 01/21] Added additional information to Plugin::getDataFolder() --- src/pocketmine/plugin/Plugin.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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 +} From 680d40d070a692067a2cf0935397f7902d7cdc19 Mon Sep 17 00:00:00 2001 From: SJ Zhu Date: Sun, 1 Nov 2015 20:47:41 +0800 Subject: [PATCH 02/21] fix test php binary in start.sh --- start.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/start.sh b/start.sh index b84f60d73..32d6a5c9a 100755 --- a/start.sh +++ b/start.sh @@ -25,7 +25,7 @@ if [ "$PHP_BINARY" == "" ]; then if [ -f ./bin/php5/bin/php ]; then export PHPRC="" PHP_BINARY="./bin/php5/bin/php" - elif [ type php 2>/dev/null ]; then + elif type php 2>/dev/null; then PHP_BINARY=$(type -p php) else echo "Couldn't find a working PHP binary, please use the installer." From 73b97c94907581246666f1433bfe9a0c34df4f09 Mon Sep 17 00:00:00 2001 From: Pub4Game Date: Tue, 29 Dec 2015 19:11:39 +0300 Subject: [PATCH 03/21] fix sound error --- src/pocketmine/block/IronTrapdoor.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 +} From b66ce90c941ebfa16daaca512ca3f6286d875ee5 Mon Sep 17 00:00:00 2001 From: PEMapModder Date: Sat, 16 Jan 2016 11:39:11 +0800 Subject: [PATCH 04/21] Add return value for PluginBase::saveDefaultConfig() --- src/pocketmine/plugin/PluginBase.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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(){ From 99855773d7d702cf21aed4e0748ffd61e6c6e6ef Mon Sep 17 00:00:00 2001 From: Intyre Date: Sun, 24 Jan 2016 18:33:34 +0100 Subject: [PATCH 05/21] Fix for command alias arguments --- src/pocketmine/command/FormattedCommandAlias.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pocketmine/command/FormattedCommandAlias.php b/src/pocketmine/command/FormattedCommandAlias.php index 842ab59f6..fb5829deb 100644 --- a/src/pocketmine/command/FormattedCommandAlias.php +++ b/src/pocketmine/command/FormattedCommandAlias.php @@ -96,7 +96,7 @@ class FormattedCommandAlias extends Command{ $argStart = $index; - while($index < strlen($formatString) and self::inRange($formatString{$index} - 48, 0, 9)){ + while($index < strlen($formatString) and self::inRange(ord($formatString{$index}) - 48, 0, 9)){ ++$index; } From e5937926cd8b2b7dc041d68cd37667ec05314bfe Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Sat, 30 Jan 2016 14:03:28 +0100 Subject: [PATCH 06/21] Fix typo on ContainerSetSlotPacket hotboar -> hotbar ![](http://i.imgur.com/n97uQb9.png) --- src/pocketmine/network/protocol/ContainerSetSlotPacket.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pocketmine/network/protocol/ContainerSetSlotPacket.php b/src/pocketmine/network/protocol/ContainerSetSlotPacket.php index 43c4d1c34..bc385f34c 100644 --- a/src/pocketmine/network/protocol/ContainerSetSlotPacket.php +++ b/src/pocketmine/network/protocol/ContainerSetSlotPacket.php @@ -37,7 +37,7 @@ class ContainerSetSlotPacket extends DataPacket{ public function decode(){ $this->windowid = $this->getByte(); $this->slot = $this->getShort(); - $this->hotboarSlot = $this->getShort(); + $this->hotbarSlot = $this->getShort(); $this->item = $this->getSlot(); } @@ -49,4 +49,4 @@ class ContainerSetSlotPacket extends DataPacket{ $this->putSlot($this->item); } -} \ No newline at end of file +} From d5d2f46db22aff6c2253bbea269e403297cc113d Mon Sep 17 00:00:00 2001 From: legoboy0215 Date: Mon, 1 Feb 2016 07:25:40 +0800 Subject: [PATCH 07/21] Added "getter" for in air ticks. --- src/pocketmine/Player.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index b2a0f3f82..1a850a2f3 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -608,6 +608,10 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade public function isSleeping(){ return $this->sleeping !== null; } + + public function getInAirTicks(){ + return $this->inAirTicks; + } protected function switchLevel(Level $targetLevel){ $oldLevel = $this->level; From 1b6e8c14f0222c62b6acf5f5425a08793feca341 Mon Sep 17 00:00:00 2001 From: Intyre Date: Sat, 6 Feb 2016 22:01:26 +0100 Subject: [PATCH 08/21] Bump protocol version for 0.13.2 --- src/pocketmine/PocketMine.php | 4 ++-- src/pocketmine/network/protocol/Info.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pocketmine/PocketMine.php b/src/pocketmine/PocketMine.php index f5e70a574..b1a35bab5 100644 --- a/src/pocketmine/PocketMine.php +++ b/src/pocketmine/PocketMine.php @@ -75,8 +75,8 @@ namespace pocketmine { const VERSION = "1.6dev"; const API_VERSION = "1.13.1"; const CODENAME = "[REDACTED]"; - const MINECRAFT_VERSION = "v0.13.1 alpha"; - const MINECRAFT_VERSION_NETWORK = "0.13.1"; + const MINECRAFT_VERSION = "v0.13.2 alpha"; + const MINECRAFT_VERSION_NETWORK = "0.13.2"; /* * Startup code. Do not look at it, it may harm you. diff --git a/src/pocketmine/network/protocol/Info.php b/src/pocketmine/network/protocol/Info.php index 3f0bdd7d6..9b34b39b3 100644 --- a/src/pocketmine/network/protocol/Info.php +++ b/src/pocketmine/network/protocol/Info.php @@ -30,7 +30,7 @@ interface Info{ /** * Actual Minecraft: PE protocol version */ - const CURRENT_PROTOCOL = 38; + const CURRENT_PROTOCOL = 39; const LOGIN_PACKET = 0x8f; const PLAY_STATUS_PACKET = 0x90; From 074d7ed95c465a70eb91261418d5e37465a6fb4c Mon Sep 17 00:00:00 2001 From: 64FF00 <64ff00@gmail.com> Date: Sun, 7 Feb 2016 23:36:16 +0900 Subject: [PATCH 09/21] Resolve CompressBatchedTask-related crashes --- src/pocketmine/network/CompressBatchedTask.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 +} From d538a254ee5c1517ebf436d62ac676846df1afd8 Mon Sep 17 00:00:00 2001 From: PEMapModder Date: Tue, 9 Feb 2016 18:25:16 +0800 Subject: [PATCH 10/21] Resolves #3918 --- src/pocketmine/event/player/PlayerBucketEvent.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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; + } +} From cfca0a8726418efb6990d9ba7da2c4397e8609b7 Mon Sep 17 00:00:00 2001 From: PEMapModder Date: Thu, 11 Feb 2016 16:51:27 +0800 Subject: [PATCH 11/21] Fixed TallGrass::getDrops() --- src/pocketmine/block/TallGrass.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 []; From 3b51d2c21752978b6848f6d8c08bea1a4ac8cae8 Mon Sep 17 00:00:00 2001 From: PEMapModder Date: Fri, 12 Feb 2016 14:08:59 +0800 Subject: [PATCH 12/21] Resolved #3937 --- src/pocketmine/entity/Entity.php | 51 ++++++++++++++++---------------- 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/src/pocketmine/entity/Entity.php b/src/pocketmine/entity/Entity.php index 96ea8d498..8eb99bc6f 100644 --- a/src/pocketmine/entity/Entity.php +++ b/src/pocketmine/entity/Entity.php @@ -53,11 +53,9 @@ use pocketmine\nbt\tag\Float; use pocketmine\nbt\tag\Int; use pocketmine\nbt\tag\Short; use pocketmine\nbt\tag\String; -use pocketmine\network\Network; use pocketmine\network\protocol\MobEffectPacket; use pocketmine\network\protocol\RemoveEntityPacket; use pocketmine\network\protocol\SetEntityDataPacket; - use pocketmine\Player; use pocketmine\plugin\Plugin; use pocketmine\Server; @@ -86,7 +84,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; @@ -564,7 +562,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(); @@ -595,23 +593,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 @@ -619,13 +618,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 @@ -774,7 +773,7 @@ abstract class Entity extends Location implements Metadatable{ } if($direction === 5){ - $this->motionY = $force; + $this->motionZ = $force; return true; } @@ -1548,7 +1547,7 @@ abstract class Entity extends Location implements Metadatable{ } /** - * @param int $propertyId; + * @param int $propertyId * @param int $id * @param bool $value */ From 21c2e2d429cf1fc408bd773b7b28810c502daa67 Mon Sep 17 00:00:00 2001 From: PEMapModder Date: Thu, 18 Feb 2016 00:08:44 +0800 Subject: [PATCH 13/21] Closes #3832 --- src/pocketmine/event/player/PlayerDeathEvent.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) 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 */ From fe2957c31511d76331f860a7f8482b21e4f29554 Mon Sep 17 00:00:00 2001 From: PEMapModder Date: Thu, 18 Feb 2016 01:43:42 +0800 Subject: [PATCH 14/21] Fixed imports --- src/pocketmine/block/DoubleWoodSlab.php | 1 + src/pocketmine/event/inventory/CraftItemEvent.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pocketmine/block/DoubleWoodSlab.php b/src/pocketmine/block/DoubleWoodSlab.php index f8f3310ee..4a207f917 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/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; From 302fb9e65e2b3761250d1b91bd545eb8b0a2bfa1 Mon Sep 17 00:00:00 2001 From: Dongjoon Hyun Date: Wed, 17 Feb 2016 11:41:02 -0800 Subject: [PATCH 15/21] Add @throws docs. Signed-off-by: Dongjoon Hyun --- src/pocketmine/Server.php | 2 ++ src/pocketmine/level/Level.php | 2 ++ src/pocketmine/level/generator/Generator.php | 8 ++++++++ 3 files changed, 12 insertions(+) diff --git a/src/pocketmine/Server.php b/src/pocketmine/Server.php index 93452e7c4..175f66296 100644 --- a/src/pocketmine/Server.php +++ b/src/pocketmine/Server.php @@ -1029,6 +1029,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/level/Level.php b/src/pocketmine/level/Level.php index dec5d55aa..282cdafc7 100644 --- a/src/pocketmine/level/Level.php +++ b/src/pocketmine/level/Level.php @@ -2497,6 +2497,8 @@ class Level implements ChunkManager, Metadatable{ * @param bool $generate * * @return bool + * + * @throws \InvalidStateException */ public function loadChunk($x, $z, $generate = true){ if(isset($this->chunks[$index = Level::chunkHash($x, $z)])){ diff --git a/src/pocketmine/level/generator/Generator.php b/src/pocketmine/level/generator/Generator.php index bd7e6c432..7d9e12160 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){ if($samplingRate === 0){ @@ -171,6 +176,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){ if($xSamplingRate === 0){ From 675583293f9f1949d4022dd2d9b759393278c93f Mon Sep 17 00:00:00 2001 From: redcrab2016 Date: Thu, 18 Feb 2016 10:54:54 +0100 Subject: [PATCH 16/21] Crash if player spawn back to Y coord. >0 & <1 The issue come from line 2664 : $v = $spawn->floor() If $spawn->y is in ]0..1[ then $v->y == 0 Then getBlockId : line 2670 use 'y' as -1 => Crash boom --- src/pocketmine/level/Level.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pocketmine/level/Level.php b/src/pocketmine/level/Level.php index 282cdafc7..a071e204e 100644 --- a/src/pocketmine/level/Level.php +++ b/src/pocketmine/level/Level.php @@ -2657,7 +2657,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){ From 80250aa78e51010463f50c2ac148421f1a0c5ba4 Mon Sep 17 00:00:00 2001 From: PEMapModder Date: Fri, 19 Feb 2016 18:33:21 +0800 Subject: [PATCH 17/21] Resolved :one: in #3961 --- src/pocketmine/Player.php | 132 +++++++++---------- src/pocketmine/inventory/CraftingManager.php | 16 +-- 2 files changed, 69 insertions(+), 79 deletions(-) diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index 819949329..dcac8c90c 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; @@ -76,11 +77,9 @@ use pocketmine\inventory\PlayerInventory; use pocketmine\inventory\ShapedRecipe; use pocketmine\inventory\ShapelessRecipe; use pocketmine\inventory\SimpleTransactionGroup; - use pocketmine\item\Item; use pocketmine\level\ChunkLoader; use pocketmine\level\format\FullChunk; -use pocketmine\level\format\LevelProvider; use pocketmine\level\Level; use pocketmine\level\Location; use pocketmine\level\Position; @@ -93,13 +92,12 @@ use pocketmine\nbt\NBT; use pocketmine\nbt\tag\ByteTag; use pocketmine\nbt\tag\CompoundTag; use pocketmine\nbt\tag\DoubleTag; -use pocketmine\nbt\tag\ListTag; use pocketmine\nbt\tag\FloatTag; use pocketmine\nbt\tag\IntTag; +use pocketmine\nbt\tag\ListTag; use pocketmine\nbt\tag\LongTag; use pocketmine\nbt\tag\ShortTag; use pocketmine\nbt\tag\StringTag; -use pocketmine\network\Network; use pocketmine\network\protocol\AdventureSettingsPacket; use pocketmine\network\protocol\AnimatePacket; use pocketmine\network\protocol\BatchPacket; @@ -110,20 +108,19 @@ use pocketmine\network\protocol\DisconnectPacket; use pocketmine\network\protocol\EntityEventPacket; use pocketmine\network\protocol\FullChunkDataPacket; use pocketmine\network\protocol\Info as ProtocolInfo; +use pocketmine\network\protocol\MovePlayerPacket; use pocketmine\network\protocol\PlayerActionPacket; use pocketmine\network\protocol\PlayStatusPacket; use pocketmine\network\protocol\RespawnPacket; -use pocketmine\network\protocol\SetPlayerGameTypePacket; -use pocketmine\network\protocol\TextPacket; - -use pocketmine\network\protocol\MovePlayerPacket; use pocketmine\network\protocol\SetDifficultyPacket; use pocketmine\network\protocol\SetEntityMotionPacket; use pocketmine\network\protocol\SetHealthPacket; +use pocketmine\network\protocol\SetPlayerGameTypePacket; use pocketmine\network\protocol\SetSpawnPositionPacket; use pocketmine\network\protocol\SetTimePacket; use pocketmine\network\protocol\StartGamePacket; use pocketmine\network\protocol\TakeItemEntityPacket; +use pocketmine\network\protocol\TextPacket; use pocketmine\network\protocol\UpdateBlockPacket; use pocketmine\network\SourceInterface; use pocketmine\permission\PermissibleBase; @@ -133,10 +130,9 @@ use pocketmine\tile\Sign; use pocketmine\tile\Spawnable; use pocketmine\tile\Tile; use pocketmine\utils\TextFormat; - - use raklib\Binary; + /** * Main class that handles networking, recovery, and packet sending to the server part */ @@ -221,7 +217,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade protected $viewDistance; protected $chunksPerTick; - protected $spawnThreshold; + protected $spawnThreshold; /** @var null|Position */ private $spawnPosition = null; @@ -505,7 +501,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade $this->clientID = $clientID; $this->loaderId = Level::generateChunkLoaderId($this); $this->chunksPerTick = (int) $this->server->getProperty("chunk-sending.per-tick", 4); - $this->spawnThreshold = (int) $this->server->getProperty("chunk-sending.spawn-threshold", 56); + $this->spawnThreshold = (int) $this->server->getProperty("chunk-sending.spawn-threshold", 56); $this->spawnPosition = null; $this->gamemode = $this->server->getGamemode(); $this->setLevel($this->server->getDefaultLevel()); @@ -559,9 +555,9 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade return $this->displayName; } - /** - * @param string $name - */ + /** + * @param string $name + */ public function setDisplayName($name){ $this->displayName = $name; if($this->spawned){ @@ -1906,13 +1902,13 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade break; } }else{ - if($packet->selectedSlot >= 0 and $packet->selectedSlot < 9){ - $this->inventory->setHeldItemIndex($packet->selectedSlot); - $this->inventory->setHeldItemSlot($packet->slot); - }else{ - $this->inventory->sendContents($this); - break; - } + if($packet->selectedSlot >= 0 and $packet->selectedSlot < 9){ + $this->inventory->setHeldItemIndex($packet->selectedSlot); + $this->inventory->setHeldItemSlot($packet->slot); + }else{ + $this->inventory->sendContents($this); + break; + } } }elseif($item === null or $slot === -1 or !$item->deepEquals($packet->item)){ // packet error or not implemented $this->inventory->sendContents($this); @@ -1922,13 +1918,13 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade $this->inventory->setItem($packet->selectedSlot, $item); $this->inventory->setHeldItemSlot($packet->selectedSlot); }else{ - if($packet->selectedSlot >= 0 and $packet->selectedSlot < $this->inventory->getHotbarSize()){ - $this->inventory->setHeldItemIndex($packet->selectedSlot); - $this->inventory->setHeldItemSlot($slot); - }else{ - $this->inventory->sendContents($this); - break; - } + if($packet->selectedSlot >= 0 and $packet->selectedSlot < $this->inventory->getHotbarSize()){ + $this->inventory->setHeldItemIndex($packet->selectedSlot); + $this->inventory->setHeldItemSlot($slot); + }else{ + $this->inventory->sendContents($this); + break; + } } $this->inventory->sendHeldItem($this->hasSpawned); @@ -2062,6 +2058,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: @@ -2069,9 +2069,9 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade break; case PlayerActionPacket::ACTION_RELEASE_ITEM: if($this->startAction > -1 and $this->getDataFlag(self::DATA_FLAGS, self::DATA_FLAG_ACTION)){ - if($this->inventory->getItemInHand()->getId() === Item::BOW) { + if($this->inventory->getItemInHand()->getId() === Item::BOW){ $bow = $this->inventory->getItemInHand(); - if ($this->isSurvival() and !$this->inventory->contains(Item::get(Item::ARROW, 0, 1))) { + if($this->isSurvival() and !$this->inventory->contains(Item::get(Item::ARROW, 0, 1))){ $this->inventory->sendContents($this); break; } @@ -2100,35 +2100,35 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade $f = min((($p ** 2) + $p * 2) / 3, 1) * 2; $ev = new EntityShootBowEvent($this, $bow, Entity::createEntity("Arrow", $this->chunk, $nbt, $this, $f == 2 ? true : false), $f); - if ($f < 0.1 or $diff < 5) { + if($f < 0.1 or $diff < 5){ $ev->setCancelled(); } $this->server->getPluginManager()->callEvent($ev); - if ($ev->isCancelled()) { + if($ev->isCancelled()){ $ev->getProjectile()->kill(); $this->inventory->sendContents($this); - } else { + }else{ $ev->getProjectile()->setMotion($ev->getProjectile()->getMotion()->multiply($ev->getForce())); if($this->isSurvival()){ $this->inventory->removeItem(Item::get(Item::ARROW, 0, 1)); $bow->setDamage($bow->getDamage() + 1); - if ($bow->getDamage() >= 385) { + if($bow->getDamage() >= 385){ $this->inventory->setItemInHand(Item::get(Item::AIR, 0, 0)); - } else { + }else{ $this->inventory->setItemInHand($bow); } } - if ($ev->getProjectile() instanceof Projectile) { + if($ev->getProjectile() instanceof Projectile){ $this->server->getPluginManager()->callEvent($projectileEv = new ProjectileLaunchEvent($ev->getProjectile())); - if ($projectileEv->isCancelled()) { + if($projectileEv->isCancelled()){ $ev->getProjectile()->kill(); - } else { + }else{ $ev->getProjectile()->spawnToAll(); $this->level->addSound(new LaunchSound($this), $this->getViewers()); } - } else { + }else{ $ev->getProjectile()->spawnToAll(); } } @@ -2146,7 +2146,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade $this->dataPacket($pk); Server::broadcastPacket($this->getViewers(), $pk); - if ($this->isSurvival()) { + if($this->isSurvival()){ $slot = $this->inventory->getItemInHand(); --$slot->count; $this->inventory->setItemInHand($slot); @@ -2274,7 +2274,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade $this->level->sendBlocks([$this], [$target], UpdateBlockPacket::FLAG_ALL_PRIORITY); - $this->inventory->sendHeldItem($this); + $this->inventory->sendHeldItem($this); if($tile instanceof Spawnable){ $tile->spawnTo($this); @@ -2481,7 +2481,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade if(is_array($amount)){ $amount = isset($amount[$slot->getDamage()]) ? $amount[$slot->getDamage()] : 0; } - $ev = new EntityRegainHealthEvent($this, $amount, EntityRegainHealthEvent::CAUSE_EATING); + $ev = new EntityRegainHealthEvent($this, $amount, EntityRegainHealthEvent::CAUSE_EATING); $this->heal($ev->getAmount(), $ev); --$slot->count; @@ -2645,7 +2645,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade $result = $packet->output[0]; if(!$canCraft or !$recipe->getResult()->deepEquals($result)){ - $this->server->getLogger()->debug("Unmatched recipe ". $recipe->getId() ." from player ". $this->getName() .": expected " . $recipe->getResult() . ", got ". $result .", using: " . implode(", ", $ingredients)); + $this->server->getLogger()->debug("Unmatched recipe " . $recipe->getId() . " from player " . $this->getName() . ": expected " . $recipe->getResult() . ", got " . $result . ", using: " . implode(", ", $ingredients)); $this->inventory->sendContents($this); break; } @@ -2669,7 +2669,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade } if(!$canCraft){ - $this->server->getLogger()->debug("Unmatched recipe ". $recipe->getId() ." from player ". $this->getName() .": client does not have enough items, using: " . implode(", ", $ingredients)); + $this->server->getLogger()->debug("Unmatched recipe " . $recipe->getId() . " from player " . $this->getName() . ": client does not have enough items, using: " . implode(", ", $ingredients)); $this->inventory->sendContents($this); break; } @@ -2883,11 +2883,11 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade $this->server->getPluginManager()->callEvent($ev = new PlayerKickEvent($this, $reason, $this->getLeaveMessage())); if(!$ev->isCancelled()){ if($isAdmin){ - if(!$this->isBanned()) { - $message = "Kicked by admin." . ($reason !== "" ? " Reason: " . $reason : ""); - }else{ - $message = $reason; - } + if(!$this->isBanned()){ + $message = "Kicked by admin." . ($reason !== "" ? " Reason: " . $reason : ""); + }else{ + $message = $reason; + } }else{ if($reason === ""){ $message = "disconnectionScreen.noReason"; @@ -2910,11 +2910,11 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade */ public function sendMessage($message){ if($message instanceof TextContainer){ - if ($message instanceof TranslationContainer) { - $this->sendTranslation($message->getText(), $message->getParameters()); - return; - } - $message = $message->getText(); + if($message instanceof TranslationContainer){ + $this->sendTranslation($message->getText(), $message->getParameters()); + return; + } + $message = $message->getText(); } @@ -2966,7 +2966,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade * * @param string $message Message to be broadcasted * @param string $reason Reason showed in console - * @param bool $notify + * @param bool $notify */ public final function close($message = "", $reason = "generic reason", $notify = true){ @@ -3250,13 +3250,13 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade return; } - if($this->isCreative() - and $source->getCause() !== EntityDamageEvent::CAUSE_MAGIC - and $source->getCause() !== EntityDamageEvent::CAUSE_SUICIDE - and $source->getCause() !== EntityDamageEvent::CAUSE_VOID - ){ - $source->setCancelled(); - }elseif($this->allowFlight and $source->getCause() === EntityDamageEvent::CAUSE_FALL){ + if($this->isCreative() + and $source->getCause() !== EntityDamageEvent::CAUSE_MAGIC + and $source->getCause() !== EntityDamageEvent::CAUSE_SUICIDE + and $source->getCause() !== EntityDamageEvent::CAUSE_VOID + ){ + $source->setCancelled(); + }elseif($this->allowFlight and $source->getCause() === EntityDamageEvent::CAUSE_FALL){ $source->setCancelled(); } @@ -3355,11 +3355,11 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade /** * @param Vector3|Position|Location $pos - * @param float $yaw - * @param float $pitch + * @param float $yaw + * @param float $pitch * * @return bool - */ + */ public function teleport(Vector3 $pos, $yaw = null, $pitch = null){ if(!$this->isOnline()){ return false; 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: From ffa835d7307905f66683d9785ad10487f63921ad Mon Sep 17 00:00:00 2001 From: PEMapModder Date: Fri, 19 Feb 2016 18:50:38 +0800 Subject: [PATCH 18/21] Fixed #3557 --- src/pocketmine/command/defaults/TeleportCommand.php | 1 + 1 file changed, 1 insertion(+) 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])); From 9acbd85b256bcc18258ef8b8c0913d6d3b7becc7 Mon Sep 17 00:00:00 2001 From: Intyre Date: Fri, 19 Feb 2016 13:39:42 +0100 Subject: [PATCH 19/21] Bump version to 0.14.0.0 --- src/pocketmine/PocketMine.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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. From f98f180bbd429c61704cffa0aeffa0e595083bfc Mon Sep 17 00:00:00 2001 From: Intyre Date: Sun, 21 Feb 2016 22:21:50 +0100 Subject: [PATCH 20/21] fix for #3972 --- src/pocketmine/entity/Item.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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); From 3640e13f17db528f2412dbb4e07395d604f2a41e Mon Sep 17 00:00:00 2001 From: PEMapModder Date: Sun, 21 Feb 2016 22:46:44 -0500 Subject: [PATCH 21/21] Added some assertions for level seed --- src/pocketmine/level/format/generic/BaseLevelProvider.php | 3 ++- src/pocketmine/level/format/mcregion/McRegion.php | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) 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 +}