diff --git a/src/pocketmine/command/defaults/ParticleCommand.php b/src/pocketmine/command/defaults/ParticleCommand.php index d875e77016..37b31980b6 100644 --- a/src/pocketmine/command/defaults/ParticleCommand.php +++ b/src/pocketmine/command/defaults/ParticleCommand.php @@ -211,12 +211,12 @@ class ParticleCommand extends VanillaCommand{ }elseif(strpos($name, "blockcrack_") === 0){ $d = explode("_", $name); if(count($d) === 2){ - return new TerrainParticle(BlockFactory::get($d[1] & 0xff, $d[1] >> 12)); + return new TerrainParticle(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($d[1] & 0xff, $d[2] & 0xff, $d[3] & 0xff, isset($d[4]) ? $d[4] & 0xff : 255); + return new DustParticle(((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 5ab3c65026..96b80ea651 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 cf251d03ea..f605961c19 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 830f3c8770..8210865fda 100644 --- a/src/pocketmine/inventory/PlayerInventory.php +++ b/src/pocketmine/inventory/PlayerInventory.php @@ -173,16 +173,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()->sendDataPacket($pk); + $holder->sendDataPacket($pk); } /** diff --git a/src/pocketmine/item/Item.php b/src/pocketmine/item/Item.php index 82c04b35df..6df7f58cf3 100644 --- a/src/pocketmine/item/Item.php +++ b/src/pocketmine/item/Item.php @@ -148,7 +148,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 9eb5b96c78..a0c86882ef 100644 --- a/src/pocketmine/level/Level.php +++ b/src/pocketmine/level/Level.php @@ -678,7 +678,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){ @@ -1306,9 +1308,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 */ diff --git a/src/pocketmine/level/generator/biome/BiomeSelector.php b/src/pocketmine/level/generator/biome/BiomeSelector.php index 0af35246e0..6ff55e9ada 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 58e1094945..c6a9736e38 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/utils/Config.php b/src/pocketmine/utils/Config.php index 353ca1e436..ff5dd2e834 100644 --- a/src/pocketmine/utils/Config.php +++ b/src/pocketmine/utils/Config.php @@ -265,7 +265,7 @@ class Config{ } /** - * @param $k + * @param string $k * * @return bool|mixed */ @@ -274,15 +274,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 */ @@ -291,15 +291,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); @@ -325,8 +325,8 @@ class Config{ } /** - * @param $key - * @param mixed $default + * @param string $key + * @param mixed $default * * @return mixed */ @@ -377,8 +377,8 @@ class Config{ } /** - * @param $k - * @param mixed $default + * @param string $k + * @param mixed $default * * @return bool|mixed */ @@ -409,8 +409,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 */ @@ -425,7 +425,7 @@ class Config{ } /** - * @param $k + * @param string $k */ public function remove($k){ unset($this->config[$k]);