diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index ee9ff70e4..787ba7054 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -401,7 +401,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ * * @return UUID|null */ - public function getUniqueId(){ + public function getUniqueId() : ?UUID{ return parent::getUniqueId(); } @@ -459,7 +459,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ /** * @param Player $player */ - public function spawnTo(Player $player){ + public function spawnTo(Player $player) : void{ if($this->spawned and $player->spawned and $this->isAlive() and $player->isAlive() and $player->getLevel() === $this->level and $player->canSee($this) and !$this->isSpectator()){ parent::spawnTo($player); } @@ -538,7 +538,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ return !$this->isSpectator(); } - public function resetFallDistance(){ + public function resetFallDistance() : void{ parent::resetFallDistance(); if($this->inAirTicks !== 0){ $this->startAirTicks = 5; @@ -812,7 +812,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ * * If null is given, will additionally send the skin to the player itself as well as its viewers. */ - public function sendSkin(array $targets = null) : void{ + public function sendSkin(?array $targets = null) : void{ parent::sendSkin($targets ?? $this->server->getOnlinePlayers()); } @@ -1487,7 +1487,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ return 0; } - protected function checkGroundState(float $movX, float $movY, float $movZ, float $dx, float $dy, float $dz){ + protected function checkGroundState(float $movX, float $movY, float $movZ, float $dx, float $dy, float $dz) : void{ if(!$this->onGround or $movY != 0){ $bb = clone $this->boundingBox; $bb->minY = $this->y - 0.2; @@ -1637,13 +1637,13 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ $this->newPosition = null; } - public function jump(){ + public function jump() : void{ $this->server->getPluginManager()->callEvent(new PlayerJumpEvent($this)); parent::jump(); } - public function setMotion(Vector3 $mot){ - if(parent::setMotion($mot)){ + public function setMotion(Vector3 $motion) : bool{ + if(parent::setMotion($motion)){ $this->broadcastMotion(); if($this->motionY > 0){ @@ -1655,11 +1655,11 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ return false; } - protected function updateMovement(bool $teleport = false){ + protected function updateMovement(bool $teleport = false) : void{ } - protected function tryChangeMovement(){ + protected function tryChangeMovement() : void{ } @@ -1744,7 +1744,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ return true; } - public function doFoodTick(int $tickDiff = 1){ + public function doFoodTick(int $tickDiff = 1) : void{ if($this->isSurvival()){ parent::doFoodTick($tickDiff); } @@ -1827,11 +1827,11 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ return ($targetDot - $eyeDot) >= -$maxDiff; } - protected function initHumanData(){ + protected function initHumanData() : void{ $this->setNameTag($this->username); } - protected function initEntity(){ + protected function initEntity() : void{ parent::initEntity(); $this->addDefaultWindows(); } @@ -3340,7 +3340,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ * @param string $reason Reason showed in console * @param bool $notify */ - final public function close($message = "", string $reason = "generic reason", bool $notify = true){ + final public function close($message = "", string $reason = "generic reason", bool $notify = true) : void{ if($this->isConnected() and !$this->closed){ try{ @@ -3491,7 +3491,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ } } - public function kill(){ + public function kill() : void{ if(!$this->spawned){ return; } @@ -3501,7 +3501,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ $this->sendRespawnPacket($this->getSpawn()); } - protected function onDeath(){ + protected function onDeath() : void{ $message = "death.attack.generic"; $params = [ @@ -3689,7 +3689,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ $this->exhaust(0.3, PlayerExhaustEvent::CAUSE_DAMAGE); } - public function attack(EntityDamageEvent $source){ + public function attack(EntityDamageEvent $source) : void{ if(!$this->isAlive()){ return; } diff --git a/src/pocketmine/entity/Attribute.php b/src/pocketmine/entity/Attribute.php index 3a7284e00..835a2debe 100644 --- a/src/pocketmine/entity/Attribute.php +++ b/src/pocketmine/entity/Attribute.php @@ -51,7 +51,7 @@ class Attribute{ /** @var Attribute[] */ protected static $attributes = []; - public static function init(){ + public static function init() : void{ self::addAttribute(self::ABSORPTION, "minecraft:absorption", 0.00, 340282346638528859811704183484516925440.00, 0.00); self::addAttribute(self::SATURATION, "minecraft:player.saturation", 0.00, 20.00, 20.00); self::addAttribute(self::EXHAUSTION, "minecraft:player.exhaustion", 0.00, 5.00, 0.0); @@ -92,7 +92,7 @@ class Attribute{ * * @return Attribute|null */ - public static function getAttribute(int $id){ + public static function getAttribute(int $id) : ?Attribute{ return isset(self::$attributes[$id]) ? clone self::$attributes[$id] : null; } @@ -101,7 +101,7 @@ class Attribute{ * * @return Attribute|null */ - public static function getAttributeByName(string $name){ + public static function getAttributeByName(string $name) : ?Attribute{ foreach(self::$attributes as $a){ if($a->getName() === $name){ return clone $a; @@ -170,7 +170,7 @@ class Attribute{ return $this; } - public function resetToDefault(){ + public function resetToDefault() : void{ $this->setValue($this->getDefaultValue()); } @@ -219,7 +219,7 @@ class Attribute{ return $this->shouldSend and $this->desynchronized; } - public function markSynchronized(bool $synced = true){ + public function markSynchronized(bool $synced = true) : void{ $this->desynchronized = !$synced; } } diff --git a/src/pocketmine/entity/AttributeMap.php b/src/pocketmine/entity/AttributeMap.php index 1c1c85276..dd07a8619 100644 --- a/src/pocketmine/entity/AttributeMap.php +++ b/src/pocketmine/entity/AttributeMap.php @@ -27,7 +27,7 @@ class AttributeMap implements \ArrayAccess{ /** @var Attribute[] */ private $attributes = []; - public function addAttribute(Attribute $attribute){ + public function addAttribute(Attribute $attribute) : void{ $this->attributes[$attribute->getId()] = $attribute; } @@ -36,7 +36,7 @@ class AttributeMap implements \ArrayAccess{ * * @return Attribute|null */ - public function getAttribute(int $id){ + public function getAttribute(int $id) : ?Attribute{ return $this->attributes[$id] ?? null; } @@ -56,19 +56,28 @@ class AttributeMap implements \ArrayAccess{ }); } - public function offsetExists($offset){ + public function offsetExists($offset) : bool{ return isset($this->attributes[$offset]); } - public function offsetGet($offset){ + /** + * @param int $offset + * + * @return float + */ + public function offsetGet($offset) : float{ return $this->attributes[$offset]->getValue(); } - public function offsetSet($offset, $value){ + /** + * @param int $offset + * @param float $value + */ + public function offsetSet($offset, $value) : void{ $this->attributes[$offset]->setValue($value); } - public function offsetUnset($offset){ + public function offsetUnset($offset) : void{ throw new \RuntimeException("Could not unset an attribute from an attribute map"); } } diff --git a/src/pocketmine/entity/Entity.php b/src/pocketmine/entity/Entity.php index 24ef8b515..fbfa531e3 100644 --- a/src/pocketmine/entity/Entity.php +++ b/src/pocketmine/entity/Entity.php @@ -573,7 +573,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ /** * @return string */ - public function getNameTag(){ + public function getNameTag() : string{ return $this->propertyManager->getString(self::DATA_NAMETAG); } @@ -595,21 +595,21 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ /** * @param string $name */ - public function setNameTag($name){ + public function setNameTag(string $name) : void{ $this->propertyManager->setString(self::DATA_NAMETAG, $name); } /** * @param bool $value */ - public function setNameTagVisible(bool $value = true){ + public function setNameTagVisible(bool $value = true) : void{ $this->setGenericFlag(self::DATA_FLAG_CAN_SHOW_NAMETAG, $value); } /** * @param bool $value */ - public function setNameTagAlwaysVisible(bool $value = true){ + public function setNameTagAlwaysVisible(bool $value = true) : void{ $this->setGenericFlag(self::DATA_FLAG_ALWAYS_SHOW_NAMETAG, $value); } @@ -623,7 +623,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ /** * @param float $value */ - public function setScale(float $value){ + public function setScale(float $value) : void{ $multiplier = $value / $this->getScale(); $this->width *= $multiplier; @@ -635,7 +635,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ $this->propertyManager->setFloat(self::DATA_SCALE, $value); } - public function getBoundingBox(){ + public function getBoundingBox() : AxisAlignedBB{ return $this->boundingBox; } @@ -656,7 +656,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ return $this->getGenericFlag(self::DATA_FLAG_SNEAKING); } - public function setSneaking(bool $value = true){ + public function setSneaking(bool $value = true) : void{ $this->setGenericFlag(self::DATA_FLAG_SNEAKING, $value); } @@ -664,7 +664,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ return $this->getGenericFlag(self::DATA_FLAG_SPRINTING); } - public function setSprinting(bool $value = true){ + public function setSprinting(bool $value = true) : void{ if($value !== $this->isSprinting()){ $this->setGenericFlag(self::DATA_FLAG_SPRINTING, $value); $attr = $this->attributeMap->getAttribute(Attribute::MOVEMENT_SPEED); @@ -676,7 +676,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ return $this->getGenericFlag(self::DATA_FLAG_IMMOBILE); } - public function setImmobile(bool $value = true){ + public function setImmobile(bool $value = true) : void{ $this->setGenericFlag(self::DATA_FLAG_IMMOBILE, $value); } @@ -698,9 +698,10 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ /** * Sets whether the entity is able to climb climbable blocks. + * * @param bool $value */ - public function setCanClimb(bool $value = true){ + public function setCanClimb(bool $value = true) : void{ $this->setGenericFlag(self::DATA_FLAG_CAN_CLIMB, $value); } @@ -718,7 +719,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ * * @param bool $value */ - public function setCanClimbWalls(bool $value = true){ + public function setCanClimbWalls(bool $value = true) : void{ $this->setGenericFlag(self::DATA_FLAG_WALLCLIMBING, $value); } @@ -726,7 +727,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ * Returns the entity ID of the owning entity, or null if the entity doesn't have an owner. * @return int|null */ - public function getOwningEntityId(){ + public function getOwningEntityId() : ?int{ return $this->propertyManager->getLong(self::DATA_OWNER_EID); } @@ -734,7 +735,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ * Returns the owning entity, or null if the entity was not found. * @return Entity|null */ - public function getOwningEntity(){ + public function getOwningEntity() : ?Entity{ $eid = $this->getOwningEntityId(); if($eid !== null){ return $this->server->findEntity($eid, $this->level); @@ -750,7 +751,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ * * @throws \InvalidArgumentException if the supplied entity is not valid */ - public function setOwningEntity(Entity $owner = null){ + public function setOwningEntity(?Entity $owner) : void{ if($owner === null){ $this->propertyManager->removeProperty(self::DATA_OWNER_EID); }elseif($owner->closed){ @@ -764,7 +765,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ * Returns the entity ID of the entity's target, or null if it doesn't have a target. * @return int|null */ - public function getTargetEntityId(){ + public function getTargetEntityId() : ?int{ return $this->propertyManager->getLong(self::DATA_TARGET_EID); } @@ -774,7 +775,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ * * @return Entity|null */ - public function getTargetEntity(){ + public function getTargetEntity() : ?Entity{ $eid = $this->getTargetEntityId(); if($eid !== null){ return $this->server->findEntity($eid, $this->level); @@ -790,7 +791,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ * * @throws \InvalidArgumentException if the target entity is not valid */ - public function setTargetEntity(Entity $target = null){ + public function setTargetEntity(?Entity $target) : void{ if($target === null){ $this->propertyManager->removeProperty(self::DATA_TARGET_EID); }elseif($target->closed){ @@ -823,7 +824,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ * * @return string */ - public function getSaveId(){ + public function getSaveId() : string{ if(!isset(self::$saveNames[static::class])){ throw new \InvalidStateException("Entity is not registered"); } @@ -831,7 +832,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ return current(self::$saveNames[static::class]); } - public function saveNBT(){ + public function saveNBT() : void{ if(!($this instanceof Player)){ $this->namedtag->setString("id", $this->getSaveId(), true); @@ -867,7 +868,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ $this->namedtag->setByte("Invulnerable", $this->invulnerable ? 1 : 0); } - protected function initEntity(){ + protected function initEntity() : void{ assert($this->namedtag instanceof CompoundTag); if($this->namedtag->hasTag("CustomName", StringTag::class)){ @@ -885,14 +886,14 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ $this->scheduleUpdate(); } - protected function addAttributes(){ + protected function addAttributes() : void{ } /** * @param EntityDamageEvent $source */ - public function attack(EntityDamageEvent $source){ + public function attack(EntityDamageEvent $source) : void{ $this->server->getPluginManager()->callEvent($source); if($source->isCancelled()){ return; @@ -906,7 +907,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ /** * @param EntityRegainHealthEvent $source */ - public function heal(EntityRegainHealthEvent $source){ + public function heal(EntityRegainHealthEvent $source) : void{ $this->server->getPluginManager()->callEvent($source); if($source->isCancelled()){ return; @@ -915,7 +916,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ $this->setHealth($this->getHealth() + $source->getAmount()); } - public function kill(){ + public function kill() : void{ $this->health = 0; $this->scheduleUpdate(); } @@ -946,7 +947,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ * * @param float $amount */ - public function setHealth(float $amount){ + public function setHealth(float $amount) : void{ if($amount == $this->health){ return; } @@ -973,25 +974,25 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ /** * @param int $amount */ - public function setMaxHealth(int $amount){ + public function setMaxHealth(int $amount) : void{ $this->maxHealth = $amount; } /** * @param EntityDamageEvent $type */ - public function setLastDamageCause(EntityDamageEvent $type){ + public function setLastDamageCause(EntityDamageEvent $type) : void{ $this->lastDamageCause = $type; } /** * @return EntityDamageEvent|null */ - public function getLastDamageCause(){ + public function getLastDamageCause() : ?EntityDamageEvent{ return $this->lastDamageCause; } - public function getAttributeMap(){ + public function getAttributeMap() : AttributeMap{ return $this->attributeMap; } @@ -1041,7 +1042,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ return $this->fireTicks > 0; } - public function setOnFire(int $seconds){ + public function setOnFire(int $seconds) : void{ $ticks = $seconds * 20; if($ticks > $this->fireTicks){ $this->fireTicks = $ticks; @@ -1064,7 +1065,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ $this->fireTicks = $fireTicks; } - public function extinguish(){ + public function extinguish() : void{ $this->fireTicks = 0; $this->setGenericFlag(self::DATA_FLAG_ONFIRE, false); } @@ -1096,7 +1097,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ /** * Called to deal damage to entities when they are on fire. */ - protected function dealFireDamage(){ + protected function dealFireDamage() : void{ $ev = new EntityDamageEvent($this, EntityDamageEvent::CAUSE_FIRE_TICK, 1); $this->attack($ev); } @@ -1109,7 +1110,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ return true; } - protected function updateMovement(bool $teleport = false){ + protected function updateMovement(bool $teleport = false) : void{ $diffPosition = ($this->x - $this->lastX) ** 2 + ($this->y - $this->lastY) ** 2 + ($this->z - $this->lastZ) ** 2; $diffRotation = ($this->yaw - $this->lastYaw) ** 2 + ($this->pitch - $this->lastPitch) ** 2; @@ -1139,7 +1140,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ return new Vector3($vector3->x, $vector3->y + $this->baseOffset, $vector3->z); } - protected function broadcastMovement(bool $teleport = false){ + protected function broadcastMovement(bool $teleport = false) : void{ if($this->chunk !== null){ $pk = new MoveEntityPacket(); $pk->entityRuntimeId = $this->id; @@ -1153,7 +1154,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ } } - protected function broadcastMotion(){ + protected function broadcastMotion() : void{ if($this->chunk !== null){ $pk = new SetEntityMotionPacket(); $pk->entityRuntimeId = $this->id; @@ -1167,11 +1168,11 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ return false; } - protected function applyGravity(){ + protected function applyGravity() : void{ $this->motionY -= $this->gravity; } - protected function tryChangeMovement(){ + protected function tryChangeMovement() : void{ $friction = 1 - $this->drag; if($this->applyDragBeforeGravity()){ @@ -1290,7 +1291,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ /** * @return int|null */ - public function getDirection(){ + public function getDirection() : ?int{ $rotation = ($this->yaw - 90) % 360; if($rotation < 0){ $rotation += 360.0; @@ -1388,7 +1389,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ //return !($this instanceof Player); } - final public function scheduleUpdate(){ + final public function scheduleUpdate() : void{ $this->level->updateEntities[$this->id] = $this; } @@ -1403,7 +1404,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ * * @param bool $value */ - final public function setForceMovementUpdate(bool $value = true){ + final public function setForceMovementUpdate(bool $value = true) : void{ $this->forceMovementUpdate = $value; $this->blocksAround = null; @@ -1427,7 +1428,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ return true; } - public function resetFallDistance(){ + public function resetFallDistance() : void{ $this->fallDistance = 0.0; } @@ -1435,7 +1436,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ * @param float $distanceThisTick * @param bool $onGround */ - protected function updateFallState(float $distanceThisTick, bool $onGround){ + protected function updateFallState(float $distanceThisTick, bool $onGround) : void{ if($onGround){ if($this->fallDistance > 0){ $this->fall($this->fallDistance); @@ -1451,7 +1452,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ * * @param float $fallDistance */ - public function fall(float $fallDistance){ + public function fall(float $fallDistance) : void{ } @@ -1459,7 +1460,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ return $this->eyeHeight; } - public function onCollideWithPlayer(Player $player){ + public function onCollideWithPlayer(Player $player) : void{ } @@ -1669,7 +1670,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ Timings::$entityMoveTimer->stopTiming(); } - protected function checkGroundState(float $movX, float $movY, float $movZ, float $dx, float $dy, float $dz){ + protected function checkGroundState(float $movX, float $movY, float $movZ, float $dx, float $dy, float $dz) : void{ $this->isCollidedVertically = $movY != $dy; $this->isCollidedHorizontally = ($movX != $dx or $movZ != $dz); $this->isCollided = ($this->isCollidedHorizontally or $this->isCollidedVertically); @@ -1716,7 +1717,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ return true; } - protected function checkBlockCollision(){ + protected function checkBlockCollision() : void{ $vector = $this->temporalVector->setComponents(0, 0, 0); foreach($this->getBlocksAround() as $block){ @@ -1765,7 +1766,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ return true; } - public function setRotation(float $yaw, float $pitch){ + public function setRotation(float $yaw, float $pitch) : void{ $this->yaw = $yaw; $this->pitch = $pitch; $this->scheduleUpdate(); @@ -1781,7 +1782,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ return false; } - protected function checkChunks(){ + protected function checkChunks() : void{ $chunkX = $this->getFloorX() >> 4; $chunkZ = $this->getFloorZ() >> 4; if($this->chunk === null or ($this->chunk->getX() !== $chunkX or $this->chunk->getZ() !== $chunkZ)){ @@ -1812,7 +1813,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ } } - protected function resetLastMovements(){ + protected function resetLastMovements() : void{ list($this->lastX, $this->lastY, $this->lastZ) = [$this->x, $this->y, $this->z]; list($this->lastYaw, $this->lastPitch) = [$this->yaw, $this->pitch]; list($this->lastMotionX, $this->lastMotionY, $this->lastMotionZ) = [$this->motionX, $this->motionY, $this->motionZ]; @@ -1822,7 +1823,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ return new Vector3($this->motionX, $this->motionY, $this->motionZ); } - public function setMotion(Vector3 $motion){ + public function setMotion(Vector3 $motion) : bool{ if(!$this->justCreated){ $this->server->getPluginManager()->callEvent($ev = new EntityMotionEvent($this, $motion)); if($ev->isCancelled()){ @@ -1852,7 +1853,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ * * @return bool */ - public function teleport(Vector3 $pos, float $yaw = null, float $pitch = null) : bool{ + public function teleport(Vector3 $pos, ?float $yaw = null, ?float $pitch = null) : bool{ if($pos instanceof Location){ $yaw = $yaw ?? $pos->yaw; $pitch = $pitch ?? $pos->pitch; @@ -1937,7 +1938,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ /** * @param Player $player */ - public function spawnTo(Player $player){ + public function spawnTo(Player $player) : void{ if(!isset($this->hasSpawned[$player->getLoaderId()]) and $this->chunk !== null and isset($player->usedChunks[Level::chunkHash($this->chunk->getX(), $this->chunk->getZ())])){ $this->hasSpawned[$player->getLoaderId()] = $player; @@ -1945,7 +1946,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ } } - public function spawnToAll(){ + public function spawnToAll() : void{ if($this->chunk === null or $this->closed){ return; } @@ -1956,7 +1957,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ } } - public function respawnToAll(){ + public function respawnToAll() : void{ foreach($this->hasSpawned as $key => $player){ unset($this->hasSpawned[$key]); $this->spawnTo($player); @@ -1967,7 +1968,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ * @param Player $player * @param bool $send */ - public function despawnFrom(Player $player, bool $send = true){ + public function despawnFrom(Player $player, bool $send = true) : void{ if(isset($this->hasSpawned[$player->getLoaderId()])){ if($send){ $pk = new RemoveEntityPacket(); @@ -1978,7 +1979,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ } } - public function despawnFromAll(){ + public function despawnFromAll() : void{ foreach($this->hasSpawned as $player){ $this->despawnFrom($player); } @@ -2008,7 +2009,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ * * WARNING: Entities are unusable after this has been executed! */ - public function close(){ + public function close() : void{ if(!$this->closed){ $this->server->getPluginManager()->callEvent(new EntityDespawnEvent($this)); $this->closed = true; @@ -2037,7 +2038,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ * @param bool $value * @param int $propertyType */ - public function setDataFlag(int $propertyId, int $flagId, bool $value = true, int $propertyType = self::DATA_TYPE_LONG){ + public function setDataFlag(int $propertyId, int $flagId, bool $value = true, int $propertyType = self::DATA_TYPE_LONG) : void{ if($this->getDataFlag($propertyId, $flagId) !== $value){ $flags = (int) $this->propertyManager->getPropertyValue($propertyId, $propertyType); $flags ^= 1 << $flagId; @@ -2071,7 +2072,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ * @param int $flagId * @param bool $value */ - public function setGenericFlag(int $flagId, bool $value = true){ + public function setGenericFlag(int $flagId, bool $value = true) : void{ $this->setDataFlag(self::DATA_FLAGS, $flagId, $value, self::DATA_TYPE_LONG); } @@ -2079,7 +2080,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ * @param Player[]|Player $player * @param array $data Properly formatted entity data, defaults to everything */ - public function sendData($player, array $data = null){ + public function sendData($player, ?array $data = null) : void{ if(!is_array($player)){ $player = [$player]; } diff --git a/src/pocketmine/entity/Human.php b/src/pocketmine/entity/Human.php index 2fd9d71f0..44e965eea 100644 --- a/src/pocketmine/entity/Human.php +++ b/src/pocketmine/entity/Human.php @@ -111,7 +111,7 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{ /** * @return UUID|null */ - public function getUniqueId(){ + public function getUniqueId() : ?UUID{ return $this->uuid; } @@ -151,14 +151,14 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{ * * @param Player[]|null $targets */ - public function sendSkin(array $targets = null) : void{ + public function sendSkin(?array $targets = null) : void{ $pk = new PlayerSkinPacket(); $pk->uuid = $this->getUniqueId(); $pk->skin = $this->skin; $this->server->broadcastPacket($targets ?? $this->hasSpawned, $pk); } - public function jump(){ + public function jump() : void{ parent::jump(); if($this->isSprinting()){ $this->exhaust(0.8, PlayerExhaustEvent::CAUSE_SPRINT_JUMPING); @@ -179,7 +179,7 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{ * * @throws \InvalidArgumentException */ - public function setFood(float $new){ + public function setFood(float $new) : void{ $attr = $this->attributeMap->getAttribute(Attribute::HUNGER); $old = $attr->getValue(); $attr->setValue($new); @@ -202,7 +202,7 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{ return $this->attributeMap->getAttribute(Attribute::HUNGER)->getMaxValue(); } - public function addFood(float $amount){ + public function addFood(float $amount) : void{ $attr = $this->attributeMap->getAttribute(Attribute::HUNGER); $amount += $attr->getValue(); $amount = max(min($amount, $attr->getMaxValue()), $attr->getMinValue()); @@ -230,11 +230,11 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{ * * @throws \InvalidArgumentException */ - public function setSaturation(float $saturation){ + public function setSaturation(float $saturation) : void{ $this->attributeMap->getAttribute(Attribute::SATURATION)->setValue($saturation); } - public function addSaturation(float $amount){ + public function addSaturation(float $amount) : void{ $attr = $this->attributeMap->getAttribute(Attribute::SATURATION); $attr->setValue($attr->getValue() + $amount, true); } @@ -249,7 +249,7 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{ * * @param float $exhaustion */ - public function setExhaustion(float $exhaustion){ + public function setExhaustion(float $exhaustion) : void{ $this->attributeMap->getAttribute(Attribute::EXHAUSTION)->setValue($exhaustion); } @@ -529,14 +529,14 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{ return $this->inventory; } - public function getEnderChestInventory(){ + public function getEnderChestInventory() : EnderChestInventory{ return $this->enderChestInventory; } /** * For Human entities which are not players, sets their properties such as nametag, skin and UUID from NBT. */ - protected function initHumanData(){ + protected function initHumanData() : void{ if($this->namedtag->hasTag("NameTag", StringTag::class)){ $this->setNameTag($this->namedtag->getString("NameTag")); } @@ -555,7 +555,7 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{ $this->uuid = UUID::fromData((string) $this->getId(), $this->skin->getSkinData(), $this->getNameTag()); } - protected function initEntity(){ + protected function initEntity() : void{ parent::initEntity(); $this->setPlayerFlag(self::DATA_PLAYER_FLAG_SLEEP, false); @@ -607,7 +607,7 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{ } } - protected function addAttributes(){ + protected function addAttributes() : void{ parent::addAttributes(); $this->attributeMap->addAttribute(Attribute::getAttribute(Attribute::SATURATION)); @@ -629,7 +629,7 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{ return $hasUpdate; } - public function doFoodTick(int $tickDiff = 1){ + public function doFoodTick(int $tickDiff = 1) : void{ if($this->isAlive()){ $food = $this->getFood(); $health = $this->getHealth(); @@ -681,7 +681,7 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{ ); } - public function saveNBT(){ + public function saveNBT() : void{ parent::saveNBT(); $this->namedtag->setInt("foodLevel", (int) $this->getFood(), true); @@ -743,7 +743,7 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{ } } - public function spawnTo(Player $player){ + public function spawnTo(Player $player) : void{ if($player !== $this){ parent::spawnTo($player); } @@ -776,7 +776,7 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{ } } - public function close(){ + public function close() : void{ if(!$this->closed){ if($this->inventory !== null){ $this->inventory->removeAllViewers(true); @@ -806,7 +806,7 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{ * @param int $flagId * @param bool $value */ - public function setPlayerFlag(int $flagId, bool $value = true){ + public function setPlayerFlag(int $flagId, bool $value = true) : void{ $this->setDataFlag(self::DATA_PLAYER_FLAGS, $flagId, $value, self::DATA_TYPE_BYTE); } } diff --git a/src/pocketmine/entity/Living.php b/src/pocketmine/entity/Living.php index 948fb19d6..be4c56237 100644 --- a/src/pocketmine/entity/Living.php +++ b/src/pocketmine/entity/Living.php @@ -72,7 +72,7 @@ abstract class Living extends Entity implements Damageable{ abstract public function getName() : string; - protected function initEntity(){ + protected function initEntity() : void{ parent::initEntity(); $this->armorInventory = new ArmorInventory($this); @@ -112,7 +112,7 @@ abstract class Living extends Entity implements Damageable{ } } - protected function addAttributes(){ + protected function addAttributes() : void{ $this->attributeMap->addAttribute(Attribute::getAttribute(Attribute::HEALTH)); $this->attributeMap->addAttribute(Attribute::getAttribute(Attribute::FOLLOW_RANGE)); $this->attributeMap->addAttribute(Attribute::getAttribute(Attribute::KNOCKBACK_RESISTANCE)); @@ -121,7 +121,7 @@ abstract class Living extends Entity implements Damageable{ $this->attributeMap->addAttribute(Attribute::getAttribute(Attribute::ABSORPTION)); } - public function setHealth(float $amount){ + public function setHealth(float $amount) : void{ $wasAlive = $this->isAlive(); parent::setHealth($amount); $this->attributeMap->getAttribute(Attribute::HEALTH)->setValue(ceil($this->getHealth()), true); @@ -134,7 +134,7 @@ abstract class Living extends Entity implements Damageable{ return (int) $this->attributeMap->getAttribute(Attribute::HEALTH)->getMaxValue(); } - public function setMaxHealth(int $amount){ + public function setMaxHealth(int $amount) : void{ $this->attributeMap->getAttribute(Attribute::HEALTH)->setMaxValue($amount); } @@ -142,11 +142,11 @@ abstract class Living extends Entity implements Damageable{ return $this->attributeMap->getAttribute(Attribute::ABSORPTION)->getValue(); } - public function setAbsorption(float $absorption){ + public function setAbsorption(float $absorption) : void{ $this->attributeMap->getAttribute(Attribute::ABSORPTION)->setValue($absorption); } - public function saveNBT(){ + public function saveNBT() : void{ parent::saveNBT(); $this->namedtag->setFloat("Health", $this->getHealth(), true); @@ -186,7 +186,7 @@ abstract class Living extends Entity implements Damageable{ /** * Removes all effects from the mob. */ - public function removeAllEffects(){ + public function removeAllEffects() : void{ foreach($this->effects as $effect){ $this->removeEffect($effect->getId()); } @@ -197,7 +197,7 @@ abstract class Living extends Entity implements Damageable{ * * @param int $effectId */ - public function removeEffect(int $effectId){ + public function removeEffect(int $effectId) : void{ if(isset($this->effects[$effectId])){ $effect = $this->effects[$effectId]; $this->server->getPluginManager()->callEvent($ev = new EntityEffectRemoveEvent($this, $effect)); @@ -221,7 +221,7 @@ abstract class Living extends Entity implements Damageable{ * * @return EffectInstance|null */ - public function getEffect(int $effectId){ + public function getEffect(int $effectId) : ?EffectInstance{ return $this->effects[$effectId] ?? null; } @@ -292,7 +292,7 @@ abstract class Living extends Entity implements Damageable{ /** * Recalculates the mob's potion bubbles colour based on the active effects. */ - protected function recalculateEffectColor(){ + protected function recalculateEffectColor() : void{ /** @var Color[] $colors */ $colors = []; $ambient = true; @@ -323,7 +323,7 @@ abstract class Living extends Entity implements Damageable{ * Sends the mob's potion effects to the specified player. * @param Player $player */ - public function sendPotionEffects(Player $player){ + public function sendPotionEffects(Player $player) : void{ foreach($this->effects as $effect){ $pk = new MobEffectPacket(); $pk->entityRuntimeId = $this->id; @@ -374,13 +374,13 @@ abstract class Living extends Entity implements Damageable{ /** * Called when the entity jumps from the ground. This method adds upwards velocity to the entity. */ - public function jump(){ + public function jump() : void{ if($this->onGround){ $this->motionY = $this->getJumpVelocity(); //Y motion should already be 0 if we're jumping from the ground. } } - public function fall(float $fallDistance){ + public function fall(float $fallDistance) : void{ $damage = ceil($fallDistance - 3 - ($this->hasEffect(Effect::JUMP) ? $this->getEffect(Effect::JUMP)->getEffectLevel() : 0)); if($damage > 0){ $ev = new EntityDamageEvent($this, EntityDamageEvent::CAUSE_FALL, $damage); @@ -427,7 +427,7 @@ abstract class Living extends Entity implements Damageable{ return $this->armorInventory; } - public function setOnFire(int $seconds){ + public function setOnFire(int $seconds) : void{ parent::setOnFire($seconds - (int) min($seconds, $seconds * $this->getHighestArmorEnchantmentLevel(Enchantment::FIRE_PROTECTION) * 0.15)); } @@ -492,7 +492,7 @@ abstract class Living extends Entity implements Damageable{ $this->armorInventory->setContents($armor); } - public function attack(EntityDamageEvent $source){ + public function attack(EntityDamageEvent $source) : void{ if($this->attackTime > 0 or $this->noDamageTicks > 0){ $lastCause = $this->getLastDamageCause(); if($lastCause !== null and $lastCause->getDamage() >= $source->getDamage()){ @@ -559,7 +559,7 @@ abstract class Living extends Entity implements Damageable{ $this->broadcastEntityEvent(EntityEventPacket::HURT_ANIMATION); } - public function knockBack(Entity $attacker, float $damage, float $x, float $z, float $base = 0.4){ + public function knockBack(Entity $attacker, float $damage, float $x, float $z, float $base = 0.4) : void{ $f = sqrt($x * $x + $z * $z); if($f <= 0){ return; @@ -583,12 +583,12 @@ abstract class Living extends Entity implements Damageable{ $this->setMotion($motion); } - public function kill(){ + public function kill() : void{ parent::kill(); $this->onDeath(); } - protected function onDeath(){ + protected function onDeath() : void{ $this->server->getPluginManager()->callEvent($ev = new EntityDeathEvent($this, $this->getDrops())); foreach($ev->getDrops() as $item){ $this->getLevel()->dropItem($this, $item); @@ -649,7 +649,7 @@ abstract class Living extends Entity implements Damageable{ return $hasUpdate; } - protected function doEffectsTick(int $tickDiff = 1){ + protected function doEffectsTick(int $tickDiff = 1) : void{ foreach($this->effects as $instance){ $type = $instance->getType(); if($type->canTick($instance)){ @@ -666,7 +666,7 @@ abstract class Living extends Entity implements Damageable{ * Ticks the entity's air supply when it cannot breathe. * @param int $tickDiff */ - protected function doAirSupplyTick(int $tickDiff){ + protected function doAirSupplyTick(int $tickDiff) : void{ if(($respirationLevel = $this->armorInventory->getHelmet()->getEnchantmentLevel(Enchantment::RESPIRATION)) <= 0 or lcg_value() <= (1 / ($respirationLevel + 1)) ){ @@ -703,7 +703,7 @@ abstract class Living extends Entity implements Damageable{ * * @param bool $value */ - public function setBreathing(bool $value = true){ + public function setBreathing(bool $value = true) : void{ $this->setGenericFlag(self::DATA_FLAG_BREATHING, $value); } @@ -721,7 +721,7 @@ abstract class Living extends Entity implements Damageable{ * Sets the number of air ticks left in the entity's air supply. * @param int $ticks */ - public function setAirSupplyTicks(int $ticks){ + public function setAirSupplyTicks(int $ticks) : void{ $this->propertyManager->setShort(self::DATA_AIR, $ticks); } @@ -737,7 +737,7 @@ abstract class Living extends Entity implements Damageable{ * Sets the maximum amount of air ticks the air supply can hold. * @param int $ticks */ - public function setMaxAirSupplyTicks(int $ticks){ + public function setMaxAirSupplyTicks(int $ticks) : void{ $this->propertyManager->setShort(self::DATA_MAX_AIR, $ticks); } @@ -745,7 +745,7 @@ abstract class Living extends Entity implements Damageable{ * Called when the entity's air supply ticks reaches -20 or lower. The entity will usually take damage at this point * and then the supply is reset to 0, so this method will be called roughly every second. */ - public function onAirExpired(){ + public function onAirExpired() : void{ $ev = new EntityDamageEvent($this, EntityDamageEvent::CAUSE_DROWNING, 2); $this->attack($ev); } @@ -815,7 +815,7 @@ abstract class Living extends Entity implements Damageable{ * * @return Block|null */ - public function getTargetBlock(int $maxDistance, array $transparent = []){ + public function getTargetBlock(int $maxDistance, array $transparent = []) : ?Block{ $line = $this->getLineOfSight($maxDistance, 1, $transparent); if(!empty($line)){ return array_shift($line); @@ -849,7 +849,7 @@ abstract class Living extends Entity implements Damageable{ $this->armorInventory->sendContents($player); } - public function close(){ + public function close() : void{ if(!$this->closed){ if($this->armorInventory !== null){ $this->armorInventory->removeAllViewers(true); diff --git a/src/pocketmine/entity/Squid.php b/src/pocketmine/entity/Squid.php index 940c2fe76..a792364d4 100644 --- a/src/pocketmine/entity/Squid.php +++ b/src/pocketmine/entity/Squid.php @@ -42,7 +42,7 @@ class Squid extends WaterAnimal{ private $switchDirectionTicker = 0; - public function initEntity(){ + public function initEntity() : void{ $this->setMaxHealth(10); parent::initEntity(); } @@ -51,7 +51,7 @@ class Squid extends WaterAnimal{ return "Squid"; } - public function attack(EntityDamageEvent $source){ + public function attack(EntityDamageEvent $source) : void{ parent::attack($source); if($source->isCancelled()){ return; @@ -115,7 +115,7 @@ class Squid extends WaterAnimal{ return $hasUpdate; } - protected function applyGravity(){ + protected function applyGravity() : void{ if(!$this->isInsideOfWater()){ parent::applyGravity(); } diff --git a/src/pocketmine/entity/Villager.php b/src/pocketmine/entity/Villager.php index a9090e8ec..233690ca9 100644 --- a/src/pocketmine/entity/Villager.php +++ b/src/pocketmine/entity/Villager.php @@ -39,7 +39,7 @@ class Villager extends Creature implements NPC, Ageable{ return "Villager"; } - protected function initEntity(){ + protected function initEntity() : void{ parent::initEntity(); /** @var int $profession */ @@ -52,7 +52,7 @@ class Villager extends Creature implements NPC, Ageable{ $this->setProfession($profession); } - public function saveNBT(){ + public function saveNBT() : void{ parent::saveNBT(); $this->namedtag->setInt("Profession", $this->getProfession()); } @@ -62,7 +62,7 @@ class Villager extends Creature implements NPC, Ageable{ * * @param int $profession */ - public function setProfession(int $profession){ + public function setProfession(int $profession) : void{ $this->propertyManager->setInt(self::DATA_VARIANT, $profession); } diff --git a/src/pocketmine/entity/WaterAnimal.php b/src/pocketmine/entity/WaterAnimal.php index b811f71da..1396efe6c 100644 --- a/src/pocketmine/entity/WaterAnimal.php +++ b/src/pocketmine/entity/WaterAnimal.php @@ -35,7 +35,7 @@ abstract class WaterAnimal extends Creature implements Ageable{ return $this->isInsideOfWater(); } - public function onAirExpired(){ + public function onAirExpired() : void{ $ev = new EntityDamageEvent($this, EntityDamageEvent::CAUSE_SUFFOCATION, 2); $this->attack($ev); } diff --git a/src/pocketmine/entity/object/ExperienceOrb.php b/src/pocketmine/entity/object/ExperienceOrb.php index 6bbd1f110..4351a6ffa 100644 --- a/src/pocketmine/entity/object/ExperienceOrb.php +++ b/src/pocketmine/entity/object/ExperienceOrb.php @@ -100,7 +100,7 @@ class ExperienceOrb extends Entity{ */ protected $targetPlayerRuntimeId = null; - protected function initEntity(){ + protected function initEntity() : void{ parent::initEntity(); $this->age = $this->namedtag->getShort("Age", 0); @@ -115,7 +115,7 @@ class ExperienceOrb extends Entity{ $this->setXpValue($value); } - public function saveNBT(){ + public function saveNBT() : void{ parent::saveNBT(); $this->namedtag->setShort("Age", $this->age); @@ -210,7 +210,7 @@ class ExperienceOrb extends Entity{ return $hasUpdate; } - protected function tryChangeMovement(){ + protected function tryChangeMovement() : void{ $this->checkObstruction($this->x, $this->y, $this->z); parent::tryChangeMovement(); } diff --git a/src/pocketmine/entity/object/FallingBlock.php b/src/pocketmine/entity/object/FallingBlock.php index 01400e4cd..9a1a91841 100644 --- a/src/pocketmine/entity/object/FallingBlock.php +++ b/src/pocketmine/entity/object/FallingBlock.php @@ -50,7 +50,7 @@ class FallingBlock extends Entity{ public $canCollide = false; - protected function initEntity(){ + protected function initEntity() : void{ parent::initEntity(); $blockId = 0; @@ -83,7 +83,7 @@ class FallingBlock extends Entity{ return false; } - public function attack(EntityDamageEvent $source){ + public function attack(EntityDamageEvent $source) : void{ if($source->getCause() === EntityDamageEvent::CAUSE_VOID){ parent::attack($source); } @@ -126,15 +126,15 @@ class FallingBlock extends Entity{ return $hasUpdate; } - public function getBlock(){ + public function getBlock() : int{ return $this->block->getId(); } - public function getDamage(){ + public function getDamage() : int{ return $this->block->getDamage(); } - public function saveNBT(){ + public function saveNBT() : void{ $this->namedtag->setInt("TileID", $this->block->getId(), true); $this->namedtag->setByte("Data", $this->block->getDamage()); } diff --git a/src/pocketmine/entity/object/ItemEntity.php b/src/pocketmine/entity/object/ItemEntity.php index 7f6a5d5bb..00179186d 100644 --- a/src/pocketmine/entity/object/ItemEntity.php +++ b/src/pocketmine/entity/object/ItemEntity.php @@ -53,7 +53,7 @@ class ItemEntity extends Entity{ public $canCollide = false; - protected function initEntity(){ + protected function initEntity() : void{ parent::initEntity(); $this->setMaxHealth(5); @@ -106,7 +106,7 @@ class ItemEntity extends Entity{ return $hasUpdate; } - protected function tryChangeMovement(){ + protected function tryChangeMovement() : void{ $this->checkObstruction($this->x, $this->y, $this->z); parent::tryChangeMovement(); } @@ -115,7 +115,7 @@ class ItemEntity extends Entity{ return true; } - public function saveNBT(){ + public function saveNBT() : void{ parent::saveNBT(); $this->namedtag->setTag($this->item->nbtSerialize(-1, "Item")); $this->namedtag->setShort("Health", (int) $this->getHealth()); @@ -154,7 +154,7 @@ class ItemEntity extends Entity{ /** * @param int $delay */ - public function setPickupDelay(int $delay){ + public function setPickupDelay(int $delay) : void{ $this->pickupDelay = $delay; } @@ -168,7 +168,7 @@ class ItemEntity extends Entity{ /** * @param string $owner */ - public function setOwner(string $owner){ + public function setOwner(string $owner) : void{ $this->owner = $owner; } @@ -182,7 +182,7 @@ class ItemEntity extends Entity{ /** * @param string $thrower */ - public function setThrower(string $thrower){ + public function setThrower(string $thrower) : void{ $this->thrower = $thrower; } @@ -197,7 +197,7 @@ class ItemEntity extends Entity{ $player->dataPacket($pk); } - public function onCollideWithPlayer(Player $player){ + public function onCollideWithPlayer(Player $player) : void{ if($this->getPickupDelay() > 0){ return; } diff --git a/src/pocketmine/entity/object/Painting.php b/src/pocketmine/entity/object/Painting.php index 54e44a7d1..6279f0dd7 100644 --- a/src/pocketmine/entity/object/Painting.php +++ b/src/pocketmine/entity/object/Painting.php @@ -70,13 +70,13 @@ class Painting extends Entity{ parent::__construct($level, $nbt); } - protected function initEntity(){ + protected function initEntity() : void{ $this->setMaxHealth(1); $this->setHealth(1); parent::initEntity(); } - public function saveNBT(){ + public function saveNBT() : void{ parent::saveNBT(); $this->namedtag->setInt("TileX", (int) $this->blockIn->x); $this->namedtag->setInt("TileY", (int) $this->blockIn->y); @@ -86,7 +86,7 @@ class Painting extends Entity{ $this->namedtag->setByte("Direction", (int) $this->direction); //Save both for full compatibility } - public function kill(){ + public function kill() : void{ parent::kill(); $drops = true; @@ -138,7 +138,7 @@ class Painting extends Entity{ return false; } - protected function updateMovement(bool $teleport = false){ + protected function updateMovement(bool $teleport = false) : void{ } @@ -166,7 +166,7 @@ class Painting extends Entity{ return PaintingMotive::getMotiveByName($this->motive); } - public function getDirection() : int{ + public function getDirection() : ?int{ return $this->direction; } diff --git a/src/pocketmine/entity/object/PrimedTNT.php b/src/pocketmine/entity/object/PrimedTNT.php index e1a12b7db..b7839c2b3 100644 --- a/src/pocketmine/entity/object/PrimedTNT.php +++ b/src/pocketmine/entity/object/PrimedTNT.php @@ -47,13 +47,13 @@ class PrimedTNT extends Entity implements Explosive{ public $canCollide = false; - public function attack(EntityDamageEvent $source){ + public function attack(EntityDamageEvent $source) : void{ if($source->getCause() === EntityDamageEvent::CAUSE_VOID){ parent::attack($source); } } - protected function initEntity(){ + protected function initEntity() : void{ parent::initEntity(); if($this->namedtag->hasTag("Fuse", ShortTag::class)){ @@ -73,7 +73,7 @@ class PrimedTNT extends Entity implements Explosive{ return false; } - public function saveNBT(){ + public function saveNBT() : void{ parent::saveNBT(); $this->namedtag->setShort("Fuse", $this->fuse, true); //older versions incorrectly saved this as a byte } @@ -101,7 +101,7 @@ class PrimedTNT extends Entity implements Explosive{ return $hasUpdate or $this->fuse >= 0; } - public function explode(){ + public function explode() : void{ $this->server->getPluginManager()->callEvent($ev = new ExplosionPrimeEvent($this, 4)); if(!$ev->isCancelled()){ diff --git a/src/pocketmine/entity/projectile/Arrow.php b/src/pocketmine/entity/projectile/Arrow.php index e63d44695..9bfab053b 100644 --- a/src/pocketmine/entity/projectile/Arrow.php +++ b/src/pocketmine/entity/projectile/Arrow.php @@ -48,7 +48,7 @@ class Arrow extends Projectile{ protected $damage = 2; - public function __construct(Level $level, CompoundTag $nbt, Entity $shootingEntity = null, bool $critical = false){ + public function __construct(Level $level, CompoundTag $nbt, ?Entity $shootingEntity = null, bool $critical = false){ parent::__construct($level, $nbt, $shootingEntity); $this->setCritical($critical); } @@ -57,7 +57,7 @@ class Arrow extends Projectile{ return $this->getGenericFlag(self::DATA_FLAG_CRITICAL); } - public function setCritical(bool $value = true){ + public function setCritical(bool $value = true) : void{ $this->setGenericFlag(self::DATA_FLAG_CRITICAL, $value); } @@ -95,7 +95,7 @@ class Arrow extends Projectile{ $this->broadcastEntityEvent(EntityEventPacket::ARROW_SHAKE, 7); //7 ticks } - public function onCollideWithPlayer(Player $player){ + public function onCollideWithPlayer(Player $player) : void{ if($this->blockHit === null){ return; } diff --git a/src/pocketmine/entity/projectile/Projectile.php b/src/pocketmine/entity/projectile/Projectile.php index f70ecf939..b9c96cb7d 100644 --- a/src/pocketmine/entity/projectile/Projectile.php +++ b/src/pocketmine/entity/projectile/Projectile.php @@ -55,20 +55,20 @@ abstract class Projectile extends Entity{ /** @var int|null */ protected $blockHitData; - public function __construct(Level $level, CompoundTag $nbt, Entity $shootingEntity = null){ + public function __construct(Level $level, CompoundTag $nbt, ?Entity $shootingEntity = null){ parent::__construct($level, $nbt); if($shootingEntity !== null){ $this->setOwningEntity($shootingEntity); } } - public function attack(EntityDamageEvent $source){ + public function attack(EntityDamageEvent $source) : void{ if($source->getCause() === EntityDamageEvent::CAUSE_VOID){ parent::attack($source); } } - protected function initEntity(){ + protected function initEntity() : void{ parent::initEntity(); $this->setMaxHealth(1); @@ -120,7 +120,7 @@ abstract class Projectile extends Entity{ return (int) ceil(sqrt($this->motionX ** 2 + $this->motionY ** 2 + $this->motionZ ** 2) * $this->damage); } - public function saveNBT(){ + public function saveNBT() : void{ parent::saveNBT(); $this->namedtag->setShort("Age", $this->age); diff --git a/src/pocketmine/entity/projectile/SplashPotion.php b/src/pocketmine/entity/projectile/SplashPotion.php index e65bd6361..434f854ca 100644 --- a/src/pocketmine/entity/projectile/SplashPotion.php +++ b/src/pocketmine/entity/projectile/SplashPotion.php @@ -42,13 +42,13 @@ class SplashPotion extends Throwable{ protected $gravity = 0.05; protected $drag = 0.01; - protected function initEntity(){ + protected function initEntity() : void{ parent::initEntity(); $this->setPotionId($this->namedtag->getShort("PotionId", 0)); } - public function saveNBT(){ + public function saveNBT() : void{ parent::saveNBT(); $this->namedtag->setShort("PotionId", $this->getPotionId()); }