Typehints on missed sound and particle APIs

This commit is contained in:
Dylan K. Taylor 2018-05-02 11:44:18 +01:00
parent b4068dfd2f
commit d80c471ae1
23 changed files with 38 additions and 35 deletions

View File

@ -26,7 +26,7 @@ namespace pocketmine\level\particle;
use pocketmine\math\Vector3;
class CriticalParticle extends GenericParticle{
public function __construct(Vector3 $pos, $scale = 2){
public function __construct(Vector3 $pos, int $scale = 2){
parent::__construct($pos, Particle::TYPE_CRITICAL, $scale);
}
}

View File

@ -26,7 +26,7 @@ namespace pocketmine\level\particle;
use pocketmine\math\Vector3;
class DustParticle extends GenericParticle{
public function __construct(Vector3 $pos, $r, $g, $b, $a = 255){
public function __construct(Vector3 $pos, int $r, int $g, int $b, int $a = 255){
parent::__construct($pos, Particle::TYPE_DUST, (($a & 0xff) << 24) | (($r & 0xff) << 16) | (($g & 0xff) << 8) | ($b & 0xff));
}
}

View File

@ -72,7 +72,7 @@ class FloatingTextParticle extends Particle{
return $this->invisible;
}
public function setInvisible(bool $value = true){
public function setInvisible(bool $value = true) : void{
$this->invisible = $value;
}

View File

@ -27,11 +27,12 @@ use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelEventPacket;
class GenericParticle extends Particle{
/** @var int */
protected $id;
/** @var int */
protected $data;
public function __construct(Vector3 $pos, $id, $data = 0){
public function __construct(Vector3 $pos, int $id, int $data = 0){
parent::__construct($pos->x, $pos->y, $pos->z);
$this->id = $id & 0xFFF;
$this->data = $data;

View File

@ -26,7 +26,7 @@ namespace pocketmine\level\particle;
use pocketmine\math\Vector3;
class HeartParticle extends GenericParticle{
public function __construct(Vector3 $pos, $scale = 0){
public function __construct(Vector3 $pos, int $scale = 0){
parent::__construct($pos, Particle::TYPE_HEART, $scale);
}
}

View File

@ -26,7 +26,7 @@ namespace pocketmine\level\particle;
use pocketmine\math\Vector3;
class InkParticle extends GenericParticle{
public function __construct(Vector3 $pos, $scale = 0){
public function __construct(Vector3 $pos, int $scale = 0){
parent::__construct($pos, Particle::TYPE_INK, $scale);
}
}

View File

@ -27,11 +27,12 @@ use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelEventPacket;
class MobSpawnParticle extends Particle{
/** @var int */
protected $width;
/** @var int */
protected $height;
public function __construct(Vector3 $pos, $width = 0, $height = 0){
public function __construct(Vector3 $pos, int $width = 0, int $height = 0){
parent::__construct($pos->x, $pos->y, $pos->z);
$this->width = $width;
$this->height = $height;

View File

@ -26,7 +26,7 @@ namespace pocketmine\level\particle;
use pocketmine\math\Vector3;
class RedstoneParticle extends GenericParticle{
public function __construct(Vector3 $pos, $lifetime = 1){
public function __construct(Vector3 $pos, int $lifetime = 1){
parent::__construct($pos, Particle::TYPE_REDSTONE, $lifetime);
}
}

View File

@ -26,7 +26,7 @@ namespace pocketmine\level\particle;
use pocketmine\math\Vector3;
class SmokeParticle extends GenericParticle{
public function __construct(Vector3 $pos, $scale = 0){
parent::__construct($pos, Particle::TYPE_SMOKE, (int) $scale);
public function __construct(Vector3 $pos, int $scale = 0){
parent::__construct($pos, Particle::TYPE_SMOKE, $scale);
}
}

View File

@ -27,7 +27,7 @@ use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelEventPacket;
class AnvilBreakSound extends GenericSound{
public function __construct(Vector3 $pos, $pitch = 0){
public function __construct(Vector3 $pos, float $pitch = 0){
parent::__construct($pos, LevelEventPacket::EVENT_SOUND_ANVIL_BREAK, $pitch);
}
}

View File

@ -27,7 +27,7 @@ use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelEventPacket;
class AnvilFallSound extends GenericSound{
public function __construct(Vector3 $pos, $pitch = 0){
public function __construct(Vector3 $pos, float $pitch = 0){
parent::__construct($pos, LevelEventPacket::EVENT_SOUND_ANVIL_FALL, $pitch);
}
}

View File

@ -27,7 +27,7 @@ use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelEventPacket;
class AnvilUseSound extends GenericSound{
public function __construct(Vector3 $pos, $pitch = 0){
public function __construct(Vector3 $pos, float $pitch = 0){
parent::__construct($pos, LevelEventPacket::EVENT_SOUND_ANVIL_USE, $pitch);
}
}

View File

@ -27,7 +27,7 @@ use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelEventPacket;
class BlazeShootSound extends GenericSound{
public function __construct(Vector3 $pos, $pitch = 0){
public function __construct(Vector3 $pos, float $pitch = 0){
parent::__construct($pos, LevelEventPacket::EVENT_SOUND_BLAZE_SHOOT, $pitch);
}
}

View File

@ -27,7 +27,7 @@ use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelEventPacket;
class ClickSound extends GenericSound{
public function __construct(Vector3 $pos, $pitch = 0){
public function __construct(Vector3 $pos, float $pitch = 0){
parent::__construct($pos, LevelEventPacket::EVENT_SOUND_CLICK, $pitch);
}
}

View File

@ -27,7 +27,7 @@ use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelEventPacket;
class DoorBumpSound extends GenericSound{
public function __construct(Vector3 $pos, $pitch = 0){
public function __construct(Vector3 $pos, float $pitch = 0){
parent::__construct($pos, LevelEventPacket::EVENT_SOUND_DOOR_BUMP, $pitch);
}
}

View File

@ -27,7 +27,7 @@ use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelEventPacket;
class DoorCrashSound extends GenericSound{
public function __construct(Vector3 $pos, $pitch = 0){
public function __construct(Vector3 $pos, float $pitch = 0){
parent::__construct($pos, LevelEventPacket::EVENT_SOUND_DOOR_CRASH, $pitch);
}
}

View File

@ -27,7 +27,7 @@ use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelEventPacket;
class DoorSound extends GenericSound{
public function __construct(Vector3 $pos, $pitch = 0){
public function __construct(Vector3 $pos, float $pitch = 0){
parent::__construct($pos, LevelEventPacket::EVENT_SOUND_DOOR, $pitch);
}
}

View File

@ -27,7 +27,7 @@ use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelEventPacket;
class FizzSound extends GenericSound{
public function __construct(Vector3 $pos, $pitch = 0){
public function __construct(Vector3 $pos, float $pitch = 0){
parent::__construct($pos, LevelEventPacket::EVENT_SOUND_FIZZ, $pitch);
}
}

View File

@ -28,24 +28,25 @@ use pocketmine\network\mcpe\protocol\LevelEventPacket;
class GenericSound extends Sound{
public function __construct(Vector3 $pos, $id, $pitch = 0){
/** @var int */
protected $id;
/** @var float */
protected $pitch = 0;
public function __construct(Vector3 $pos, int $id, float $pitch = 0){
parent::__construct($pos->x, $pos->y, $pos->z);
$this->id = (int) $id;
$this->pitch = (float) $pitch * 1000;
$this->id = $id;
$this->pitch = $pitch * 1000;
}
protected $pitch = 0;
protected $id;
public function getPitch(){
public function getPitch() : float{
return $this->pitch / 1000;
}
public function setPitch($pitch){
$this->pitch = (float) $pitch * 1000;
public function setPitch(float $pitch) : void{
$this->pitch = $pitch * 1000;
}
public function encode(){
$pk = new LevelEventPacket;
$pk->evid = $this->id;

View File

@ -27,7 +27,7 @@ use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelEventPacket;
class GhastShootSound extends GenericSound{
public function __construct(Vector3 $pos, $pitch = 0){
public function __construct(Vector3 $pos, float $pitch = 0){
parent::__construct($pos, LevelEventPacket::EVENT_SOUND_GHAST_SHOOT, $pitch);
}
}

View File

@ -27,7 +27,7 @@ use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelEventPacket;
class GhastSound extends GenericSound{
public function __construct(Vector3 $pos, $pitch = 0){
public function __construct(Vector3 $pos, float $pitch = 0){
parent::__construct($pos, LevelEventPacket::EVENT_SOUND_GHAST, $pitch);
}
}

View File

@ -27,7 +27,7 @@ use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelEventPacket;
class LaunchSound extends GenericSound{
public function __construct(Vector3 $pos, $pitch = 0){
public function __construct(Vector3 $pos, float $pitch = 0){
parent::__construct($pos, LevelEventPacket::EVENT_SOUND_SHOOT, $pitch);
}
}

View File

@ -27,7 +27,7 @@ use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelEventPacket;
class PopSound extends GenericSound{
public function __construct(Vector3 $pos, $pitch = 0){
public function __construct(Vector3 $pos, float $pitch = 0){
parent::__construct($pos, LevelEventPacket::EVENT_SOUND_POP, $pitch);
}
}