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; use pocketmine\math\Vector3;
class CriticalParticle extends GenericParticle{ 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); parent::__construct($pos, Particle::TYPE_CRITICAL, $scale);
} }
} }

View File

@ -26,7 +26,7 @@ namespace pocketmine\level\particle;
use pocketmine\math\Vector3; use pocketmine\math\Vector3;
class DustParticle extends GenericParticle{ 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)); 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; return $this->invisible;
} }
public function setInvisible(bool $value = true){ public function setInvisible(bool $value = true) : void{
$this->invisible = $value; $this->invisible = $value;
} }

View File

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

View File

@ -26,7 +26,7 @@ namespace pocketmine\level\particle;
use pocketmine\math\Vector3; use pocketmine\math\Vector3;
class HeartParticle extends GenericParticle{ 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); parent::__construct($pos, Particle::TYPE_HEART, $scale);
} }
} }

View File

@ -26,7 +26,7 @@ namespace pocketmine\level\particle;
use pocketmine\math\Vector3; use pocketmine\math\Vector3;
class InkParticle extends GenericParticle{ 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); parent::__construct($pos, Particle::TYPE_INK, $scale);
} }
} }

View File

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

View File

@ -26,7 +26,7 @@ namespace pocketmine\level\particle;
use pocketmine\math\Vector3; use pocketmine\math\Vector3;
class RedstoneParticle extends GenericParticle{ 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); parent::__construct($pos, Particle::TYPE_REDSTONE, $lifetime);
} }
} }

View File

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

View File

@ -27,7 +27,7 @@ use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelEventPacket; use pocketmine\network\mcpe\protocol\LevelEventPacket;
class AnvilBreakSound extends GenericSound{ 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); 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; use pocketmine\network\mcpe\protocol\LevelEventPacket;
class AnvilFallSound extends GenericSound{ 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); 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; use pocketmine\network\mcpe\protocol\LevelEventPacket;
class AnvilUseSound extends GenericSound{ 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); 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; use pocketmine\network\mcpe\protocol\LevelEventPacket;
class BlazeShootSound extends GenericSound{ 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); 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; use pocketmine\network\mcpe\protocol\LevelEventPacket;
class ClickSound extends GenericSound{ 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); parent::__construct($pos, LevelEventPacket::EVENT_SOUND_CLICK, $pitch);
} }
} }

View File

@ -27,7 +27,7 @@ use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelEventPacket; use pocketmine\network\mcpe\protocol\LevelEventPacket;
class DoorBumpSound extends GenericSound{ 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); 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; use pocketmine\network\mcpe\protocol\LevelEventPacket;
class DoorCrashSound extends GenericSound{ 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); 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; use pocketmine\network\mcpe\protocol\LevelEventPacket;
class DoorSound extends GenericSound{ 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); parent::__construct($pos, LevelEventPacket::EVENT_SOUND_DOOR, $pitch);
} }
} }

View File

@ -27,7 +27,7 @@ use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelEventPacket; use pocketmine\network\mcpe\protocol\LevelEventPacket;
class FizzSound extends GenericSound{ 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); parent::__construct($pos, LevelEventPacket::EVENT_SOUND_FIZZ, $pitch);
} }
} }

View File

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

View File

@ -27,7 +27,7 @@ use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelEventPacket; use pocketmine\network\mcpe\protocol\LevelEventPacket;
class GhastShootSound extends GenericSound{ 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); 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; use pocketmine\network\mcpe\protocol\LevelEventPacket;
class GhastSound extends GenericSound{ 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); parent::__construct($pos, LevelEventPacket::EVENT_SOUND_GHAST, $pitch);
} }
} }

View File

@ -27,7 +27,7 @@ use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelEventPacket; use pocketmine\network\mcpe\protocol\LevelEventPacket;
class LaunchSound extends GenericSound{ 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); parent::__construct($pos, LevelEventPacket::EVENT_SOUND_SHOOT, $pitch);
} }
} }

View File

@ -27,7 +27,7 @@ use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelEventPacket; use pocketmine\network\mcpe\protocol\LevelEventPacket;
class PopSound extends GenericSound{ 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); parent::__construct($pos, LevelEventPacket::EVENT_SOUND_POP, $pitch);
} }
} }