diff --git a/src/pocketmine/command/defaults/ParticleCommand.php b/src/pocketmine/command/defaults/ParticleCommand.php index d9c67aef2..9142cdd8c 100644 --- a/src/pocketmine/command/defaults/ParticleCommand.php +++ b/src/pocketmine/command/defaults/ParticleCommand.php @@ -216,12 +216,12 @@ class ParticleCommand extends VanillaCommand{ }elseif(strpos($name, "blockcrack_") === 0){ $d = explode("_", $name); if(count($d) === 2){ - return new TerrainParticle($pos, BlockFactory::get($d[1] & 0xff, $d[1] >> 12)); + return new TerrainParticle($pos, BlockFactory::get(((int) $d[1]) & 0xff, ((int) $d[1]) >> 12)); } }elseif(strpos($name, "blockdust_") === 0){ $d = explode("_", $name); if(count($d) >= 4){ - return new DustParticle($pos, $d[1] & 0xff, $d[2] & 0xff, $d[3] & 0xff, isset($d[4]) ? $d[4] & 0xff : 255); + return new DustParticle($pos, ((int) $d[1]) & 0xff, ((int) $d[2]) & 0xff, ((int) $d[3]) & 0xff, isset($d[4]) ? ((int) $d[4]) & 0xff : 255); } } diff --git a/src/pocketmine/event/entity/EntityDamageEvent.php b/src/pocketmine/event/entity/EntityDamageEvent.php index 5ab3c6502..96b80ea65 100644 --- a/src/pocketmine/event/entity/EntityDamageEvent.php +++ b/src/pocketmine/event/entity/EntityDamageEvent.php @@ -74,10 +74,10 @@ class EntityDamageEvent extends EntityEvent implements Cancellable{ /** - * @param Entity $entity - * @param int $cause - * @param float $damage - * @param float|float[] $modifiers + * @param Entity $entity + * @param int $cause + * @param float $damage + * @param float[] $modifiers */ public function __construct(Entity $entity, int $cause, float $damage, array $modifiers = []){ $this->entity = $entity; diff --git a/src/pocketmine/inventory/Inventory.php b/src/pocketmine/inventory/Inventory.php index 7e5f5d40a..94677a75e 100644 --- a/src/pocketmine/inventory/Inventory.php +++ b/src/pocketmine/inventory/Inventory.php @@ -27,6 +27,8 @@ declare(strict_types=1); namespace pocketmine\inventory; use pocketmine\item\Item; +use pocketmine\level\Level; +use pocketmine\math\Vector3; use pocketmine\Player; interface Inventory{ @@ -120,6 +122,15 @@ interface Inventory{ */ public function setContents(array $items, bool $send = true) : void; + /** + * Drops the contents of the inventory into the specified Level at the specified position and clears the inventory + * contents. + * + * @param Level $level + * @param Vector3 $position + */ + public function dropContents(Level $level, Vector3 $position) : void; + /** * @param Player|Player[] $target */ diff --git a/src/pocketmine/inventory/PlayerInventory.php b/src/pocketmine/inventory/PlayerInventory.php index 00553ef58..0dfe42a96 100644 --- a/src/pocketmine/inventory/PlayerInventory.php +++ b/src/pocketmine/inventory/PlayerInventory.php @@ -196,16 +196,21 @@ class PlayerInventory extends BaseInventory{ } public function sendCreativeContents(){ + //TODO: this mess shouldn't be in here + $holder = $this->getHolder(); + if(!($holder instanceof Player)){ + throw new \LogicException("Cannot send creative inventory contents to non-player inventory holder"); + } $pk = new InventoryContentPacket(); $pk->windowId = ContainerIds::CREATIVE; - if(!$this->getHolder()->isSpectator()){ //fill it for all gamemodes except spectator + if(!$holder->isSpectator()){ //fill it for all gamemodes except spectator foreach(Item::getCreativeItems() as $i => $item){ $pk->items[$i] = clone $item; } } - $this->getHolder()->dataPacket($pk); + $holder->dataPacket($pk); } /** diff --git a/src/pocketmine/item/Item.php b/src/pocketmine/item/Item.php index 9a65e2e80..b099cfc18 100644 --- a/src/pocketmine/item/Item.php +++ b/src/pocketmine/item/Item.php @@ -153,7 +153,7 @@ class Item implements ItemIds, \JsonSerializable{ } /** - * @param $index + * @param int $index * * @return Item|null */ diff --git a/src/pocketmine/level/Level.php b/src/pocketmine/level/Level.php index ee1935fa0..7c70c37ec 100644 --- a/src/pocketmine/level/Level.php +++ b/src/pocketmine/level/Level.php @@ -686,7 +686,9 @@ class Level implements ChunkManager, Metadatable{ } public function unregisterChunkLoader(ChunkLoader $loader, int $chunkX, int $chunkZ){ - if(isset($this->chunkLoaders[$index = Level::chunkHash($chunkX, $chunkZ)][$hash = $loader->getLoaderId()])){ + $index = Level::chunkHash($chunkX, $chunkZ); + $hash = $loader->getLoaderId(); + if(isset($this->chunkLoaders[$index][$hash])){ unset($this->chunkLoaders[$index][$hash]); unset($this->playerLoaders[$index][$hash]); if(count($this->chunkLoaders[$index]) === 0){ @@ -1346,9 +1348,9 @@ class Level implements ChunkManager, Metadatable{ } /** - * @param $x - * @param $y - * @param $z + * @param int $x + * @param int $y + * @param int $z * * @return int bitmap, (id << 4) | data */ @@ -2079,7 +2081,7 @@ class Level implements ChunkManager, Metadatable{ } /** - * @param $tileId + * @param int $tileId * * @return Tile|null */ @@ -2185,7 +2187,9 @@ class Level implements ChunkManager, Metadatable{ if(!$this->isInWorld($x, $y, $z)){ //TODO: bad hack but fixing this requires BC breaks to do properly :( return; } - unset($this->blockCache[$chunkHash = Level::chunkHash($x >> 4, $z >> 4)][$blockHash = Level::blockHash($x, $y, $z)]); + $chunkHash = Level::chunkHash($x >> 4, $z >> 4); + $blockHash = Level::blockHash($x, $y, $z); + unset($this->blockCache[$chunkHash][$blockHash]); $this->getChunk($x >> 4, $z >> 4, true)->setBlockId($x & 0x0f, $y, $z & 0x0f, $id & 0xff); if(!isset($this->changedBlocks[$chunkHash])){ @@ -2222,7 +2226,9 @@ class Level implements ChunkManager, Metadatable{ if(!$this->isInWorld($x, $y, $z)){ //TODO: bad hack but fixing this requires BC breaks to do properly :( return; } - unset($this->blockCache[$chunkHash = Level::chunkHash($x >> 4, $z >> 4)][$blockHash = Level::blockHash($x, $y, $z)]); + $chunkHash = Level::chunkHash($x >> 4, $z >> 4); + $blockHash = Level::blockHash($x, $y, $z); + unset($this->blockCache[$chunkHash][$blockHash]); $this->getChunk($x >> 4, $z >> 4, true)->setBlockData($x & 0x0f, $y, $z & 0x0f, $data & 0x0f); diff --git a/src/pocketmine/level/format/io/LevelProvider.php b/src/pocketmine/level/format/io/LevelProvider.php index 31a71bbe1..2854f0e38 100644 --- a/src/pocketmine/level/format/io/LevelProvider.php +++ b/src/pocketmine/level/format/io/LevelProvider.php @@ -118,7 +118,7 @@ interface LevelProvider{ public function getTime() : int; /** - * @param int + * @param int $value */ public function setTime(int $value); @@ -128,7 +128,7 @@ interface LevelProvider{ public function getSeed() : int; /** - * @param int + * @param int $value */ public function setSeed(int $value); diff --git a/src/pocketmine/level/generator/biome/BiomeSelector.php b/src/pocketmine/level/generator/biome/BiomeSelector.php index 5d80d607e..d5496775a 100644 --- a/src/pocketmine/level/generator/biome/BiomeSelector.php +++ b/src/pocketmine/level/generator/biome/BiomeSelector.php @@ -75,8 +75,9 @@ abstract class BiomeSelector{ } /** - * @param $x - * @param $z + * TODO: not sure on types here + * @param int|float $x + * @param int|float $z * * @return Biome */ diff --git a/src/pocketmine/metadata/MetadataStore.php b/src/pocketmine/metadata/MetadataStore.php index 58e109494..c6a9736e3 100644 --- a/src/pocketmine/metadata/MetadataStore.php +++ b/src/pocketmine/metadata/MetadataStore.php @@ -100,7 +100,7 @@ abstract class MetadataStore{ * @param Plugin $owningPlugin */ public function invalidateAll(Plugin $owningPlugin){ - /** @var $values MetadataValue[] */ + /** @var MetadataValue[] $values */ foreach($this->metadataMap as $values){ if(isset($values[$owningPlugin])){ $values[$owningPlugin]->invalidate(); diff --git a/src/pocketmine/tile/Tile.php b/src/pocketmine/tile/Tile.php index 9081bbb01..b66d3a3e2 100644 --- a/src/pocketmine/tile/Tile.php +++ b/src/pocketmine/tile/Tile.php @@ -96,7 +96,7 @@ abstract class Tile extends Position{ * @param string $type * @param Level $level * @param CompoundTag $nbt - * @param $args + * @param mixed ...$args * * @return Tile|null */ diff --git a/src/pocketmine/utils/Config.php b/src/pocketmine/utils/Config.php index e11cb4b12..1c84c1b85 100644 --- a/src/pocketmine/utils/Config.php +++ b/src/pocketmine/utils/Config.php @@ -111,9 +111,9 @@ class Config{ } /** - * @param $file - * @param int $type - * @param array $default + * @param string $file + * @param int $type + * @param array $default * * @return bool */ @@ -289,7 +289,7 @@ class Config{ } /** - * @param $k + * @param string $k * * @return bool|mixed */ @@ -298,15 +298,15 @@ class Config{ } /** - * @param $k - * @param $v + * @param string $k + * @param mixed $v */ public function __set($k, $v){ $this->set($k, $v); } /** - * @param $k + * @param string $k * * @return bool */ @@ -315,15 +315,15 @@ class Config{ } /** - * @param $k + * @param string $k */ public function __unset($k){ $this->remove($k); } /** - * @param $key - * @param $value + * @param string $key + * @param mixed $value */ public function setNested($key, $value){ $vars = explode(".", $key); @@ -349,8 +349,8 @@ class Config{ } /** - * @param $key - * @param mixed $default + * @param string $key + * @param mixed $default * * @return mixed */ @@ -401,8 +401,8 @@ class Config{ } /** - * @param $k - * @param mixed $default + * @param string $k + * @param mixed $default * * @return bool|mixed */ @@ -433,8 +433,8 @@ class Config{ } /** - * @param $k - * @param bool $lowercase If set, searches Config in single-case / lowercase. + * @param string $k + * @param bool $lowercase If set, searches Config in single-case / lowercase. * * @return bool */ @@ -449,7 +449,7 @@ class Config{ } /** - * @param $k + * @param string $k */ public function remove($k){ unset($this->config[$k]);