Use typed properties in block namespace

This commit is contained in:
Dylan K. Taylor 2021-05-22 23:52:31 +01:00
parent 73c229a236
commit f68b9e79e1
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
68 changed files with 134 additions and 246 deletions

View File

@ -39,8 +39,7 @@ class Anvil extends Transparent implements Fallable{
use FallableTrait; use FallableTrait;
use HorizontalFacingTrait; use HorizontalFacingTrait;
/** @var int */ private int $damage = 0;
private $damage = 0;
protected function writeStateToMeta() : int{ protected function writeStateToMeta() : int{
return BlockDataSerializer::writeLegacyHorizontalFacing($this->facing) | ($this->damage << 2); return BlockDataSerializer::writeLegacyHorizontalFacing($this->facing) | ($this->damage << 2);

View File

@ -48,12 +48,9 @@ class Bamboo extends Transparent{
public const SMALL_LEAVES = 1; public const SMALL_LEAVES = 1;
public const LARGE_LEAVES = 2; public const LARGE_LEAVES = 2;
/** @var bool */ protected bool $thick = false; //age in PC, but this is 0/1
protected $thick = false; //age in PC, but this is 0/1 protected bool $ready = false;
/** @var bool */ protected int $leafSize = self::NO_LEAVES;
protected $ready = false;
/** @var int */
protected $leafSize = self::NO_LEAVES;
public function readStateFromData(int $id, int $stateMeta) : void{ public function readStateFromData(int $id, int $stateMeta) : void{
$this->thick = ($stateMeta & BlockLegacyMetadata::BAMBOO_FLAG_THICK) !== 0; $this->thick = ($stateMeta & BlockLegacyMetadata::BAMBOO_FLAG_THICK) !== 0;

View File

@ -32,8 +32,7 @@ use pocketmine\world\BlockTransaction;
final class BambooSapling extends Flowable{ final class BambooSapling extends Flowable{
/** @var bool */ private bool $ready = false;
private $ready = false;
public function readStateFromData(int $id, int $stateMeta) : void{ public function readStateFromData(int $id, int $stateMeta) : void{
$this->ready = ($stateMeta & BlockLegacyMetadata::SAPLING_FLAG_READY) !== 0; $this->ready = ($stateMeta & BlockLegacyMetadata::SAPLING_FLAG_READY) !== 0;

View File

@ -36,8 +36,7 @@ use function abs;
class Barrel extends Opaque{ class Barrel extends Opaque{
use AnyFacingTrait; use AnyFacingTrait;
/** @var bool */ protected bool $open = false;
protected $open = false;
protected function writeStateToMeta() : int{ protected function writeStateToMeta() : int{
return BlockDataSerializer::writeFacing($this->facing) | ($this->open ? BlockLegacyMetadata::BARREL_FLAG_OPEN : 0); return BlockDataSerializer::writeFacing($this->facing) | ($this->open ? BlockLegacyMetadata::BARREL_FLAG_OPEN : 0);

View File

@ -40,14 +40,14 @@ use function assert;
use function count; use function count;
abstract class BaseBanner extends Transparent{ abstract class BaseBanner extends Transparent{
/** @var DyeColor */
protected $baseColor; protected DyeColor $baseColor;
/** /**
* @var BannerPatternLayer[] * @var BannerPatternLayer[]
* @phpstan-var list<BannerPatternLayer> * @phpstan-var list<BannerPatternLayer>
*/ */
protected $patterns = []; protected array $patterns = [];
public function __construct(BlockIdentifier $idInfo, string $name, BlockBreakInfo $breakInfo){ public function __construct(BlockIdentifier $idInfo, string $name, BlockBreakInfo $breakInfo){
parent::__construct($idInfo, $name, $breakInfo); parent::__construct($idInfo, $name, $breakInfo);

View File

@ -72,7 +72,7 @@ abstract class BaseRail extends Flowable{
]; ];
/** @var int[] */ /** @var int[] */
protected $connections = []; protected array $connections = [];
protected function writeStateToMeta() : int{ protected function writeStateToMeta() : int{
if(count($this->connections) === 0){ if(count($this->connections) === 0){

View File

@ -39,11 +39,8 @@ use function strlen;
abstract class BaseSign extends Transparent{ abstract class BaseSign extends Transparent{
//TODO: conditionally useless properties, find a way to fix //TODO: conditionally useless properties, find a way to fix
/** @var SignText */ protected SignText $text;
protected $text; protected ?int $editorEntityRuntimeId = null;
/** @var int|null */
protected $editorEntityRuntimeId = null;
public function __construct(BlockIdentifier $idInfo, string $name, BlockBreakInfo $breakInfo){ public function __construct(BlockIdentifier $idInfo, string $name, BlockBreakInfo $breakInfo){
parent::__construct($idInfo, $name, $breakInfo); parent::__construct($idInfo, $name, $breakInfo);

View File

@ -43,12 +43,9 @@ use pocketmine\world\World;
class Bed extends Transparent{ class Bed extends Transparent{
use HorizontalFacingTrait; use HorizontalFacingTrait;
/** @var bool */ protected bool $occupied = false;
protected $occupied = false; protected bool $head = false;
/** @var bool */ protected DyeColor $color;
protected $head = false;
/** @var DyeColor */
protected $color;
public function __construct(BlockIdentifier $idInfo, string $name, BlockBreakInfo $breakInfo){ public function __construct(BlockIdentifier $idInfo, string $name, BlockBreakInfo $breakInfo){
parent::__construct($idInfo, $name, $breakInfo); parent::__construct($idInfo, $name, $breakInfo);

View File

@ -25,8 +25,7 @@ namespace pocketmine\block;
class Bedrock extends Opaque{ class Bedrock extends Opaque{
/** @var bool */ private bool $burnsForever = false;
private $burnsForever = false;
public function readStateFromData(int $id, int $stateMeta) : void{ public function readStateFromData(int $id, int $stateMeta) : void{
$this->burnsForever = ($stateMeta & BlockLegacyMetadata::BEDROCK_FLAG_INFINIBURN) !== 0; $this->burnsForever = ($stateMeta & BlockLegacyMetadata::BEDROCK_FLAG_INFINIBURN) !== 0;

View File

@ -49,20 +49,13 @@ use const PHP_INT_MAX;
class Block{ class Block{
/** @var BlockIdentifier */ protected BlockIdentifier $idInfo;
protected $idInfo; protected string $fallbackName;
protected BlockBreakInfo $breakInfo;
/** @var string */ protected Position $pos;
protected $fallbackName;
/** @var BlockBreakInfo */
protected $breakInfo;
/** @var Position */
protected $pos;
/** @var AxisAlignedBB[]|null */ /** @var AxisAlignedBB[]|null */
protected $collisionBoxes = null; protected ?array $collisionBoxes = null;
/** /**
* @param string $name English name of the block type (TODO: implement translations) * @param string $name English name of the block type (TODO: implement translations)

View File

@ -28,14 +28,10 @@ use function get_class;
class BlockBreakInfo{ class BlockBreakInfo{
/** @var float */ private float $hardness;
private $hardness; private float $blastResistance;
/** @var float */ private int $toolType;
private $blastResistance; private int $toolHarvestLevel;
/** @var int */
private $toolType;
/** @var int */
private $toolHarvestLevel;
/** /**
* @param float|null $blastResistance default 5x hardness * @param float|null $blastResistance default 5x hardness

View File

@ -27,17 +27,11 @@ use pocketmine\block\tile\Tile;
class BlockIdentifier{ class BlockIdentifier{
/** @var int */ private int $blockId;
private $blockId; private int $variant;
/** @var int */ private ?int $itemId;
private $variant; /** @phpstan-var class-string<Tile>|null */
/** @var int|null */ private ?string $tileClass;
private $itemId;
/**
* @var string|null
* @phpstan-var class-string<Tile>|null
*/
private $tileClass;
/** /**
* @phpstan-param class-string<Tile>|null $tileClass * @phpstan-param class-string<Tile>|null $tileClass

View File

@ -36,7 +36,7 @@ class BrewingStand extends Transparent{
* @var BrewingStandSlot[] * @var BrewingStandSlot[]
* @phpstan-var array<int, BrewingStandSlot> * @phpstan-var array<int, BrewingStandSlot>
*/ */
protected $slots = []; protected array $slots = [];
protected function writeStateToMeta() : int{ protected function writeStateToMeta() : int{
$flags = 0; $flags = 0;

View File

@ -36,8 +36,7 @@ use pocketmine\world\sound\RedstonePowerOnSound;
abstract class Button extends Flowable{ abstract class Button extends Flowable{
use AnyFacingTrait; use AnyFacingTrait;
/** @var bool */ protected bool $pressed = false;
protected $pressed = false;
protected function writeStateToMeta() : int{ protected function writeStateToMeta() : int{
return BlockDataSerializer::writeFacing($this->facing) | ($this->pressed ? BlockLegacyMetadata::BUTTON_FLAG_POWERED : 0); return BlockDataSerializer::writeFacing($this->facing) | ($this->pressed ? BlockLegacyMetadata::BUTTON_FLAG_POWERED : 0);

View File

@ -37,8 +37,7 @@ use pocketmine\world\BlockTransaction;
class Cactus extends Transparent{ class Cactus extends Transparent{
/** @var int */ protected int $age = 0;
protected $age = 0;
protected function writeStateToMeta() : int{ protected function writeStateToMeta() : int{
return $this->age; return $this->age;

View File

@ -36,8 +36,7 @@ use pocketmine\world\BlockTransaction;
class Cake extends Transparent implements FoodSource{ class Cake extends Transparent implements FoodSource{
/** @var int */ protected int $bites = 0;
protected $bites = 0;
protected function writeStateToMeta() : int{ protected function writeStateToMeta() : int{
return $this->bites; return $this->bites;

View File

@ -40,8 +40,7 @@ use function mt_rand;
class CocoaBlock extends Transparent{ class CocoaBlock extends Transparent{
use HorizontalFacingTrait; use HorizontalFacingTrait;
/** @var int */ protected int $age = 0;
protected $age = 0;
protected function writeStateToMeta() : int{ protected function writeStateToMeta() : int{
return BlockDataSerializer::writeLegacyHorizontalFacing(Facing::opposite($this->facing)) | ($this->age << 2); return BlockDataSerializer::writeLegacyHorizontalFacing(Facing::opposite($this->facing)) | ($this->age << 2);

View File

@ -31,11 +31,8 @@ use function mt_rand;
final class CoralBlock extends Opaque{ final class CoralBlock extends Opaque{
/** @var CoralType */ private CoralType $coralType;
private $coralType; private bool $dead = false;
/** @var bool */
private $dead = false;
public function __construct(BlockIdentifier $idInfo, string $name, BlockBreakInfo $breakInfo){ public function __construct(BlockIdentifier $idInfo, string $name, BlockBreakInfo $breakInfo){
$this->coralType = CoralType::TUBE(); $this->coralType = CoralType::TUBE();

View File

@ -34,8 +34,8 @@ use pocketmine\world\BlockTransaction;
use function mt_rand; use function mt_rand;
abstract class Crops extends Flowable{ abstract class Crops extends Flowable{
/** @var int */
protected $age = 0; protected int $age = 0;
protected function writeStateToMeta() : int{ protected function writeStateToMeta() : int{
return $this->age; return $this->age;

View File

@ -38,11 +38,9 @@ use const M_PI;
class DaylightSensor extends Transparent{ class DaylightSensor extends Transparent{
use AnalogRedstoneSignalEmitterTrait; use AnalogRedstoneSignalEmitterTrait;
/** @var BlockIdentifierFlattened */ protected BlockIdentifierFlattened $idInfoFlattened;
protected $idInfoFlattened;
/** @var bool */ protected bool $inverted = false;
protected $inverted = false;
public function __construct(BlockIdentifierFlattened $idInfo, string $name, BlockBreakInfo $breakInfo){ public function __construct(BlockIdentifierFlattened $idInfo, string $name, BlockBreakInfo $breakInfo){
$this->idInfoFlattened = $idInfo; $this->idInfoFlattened = $idInfo;

View File

@ -38,13 +38,9 @@ class Door extends Transparent{
use HorizontalFacingTrait; use HorizontalFacingTrait;
use PoweredByRedstoneTrait; use PoweredByRedstoneTrait;
/** @var bool */ protected bool $top = false;
protected $top = false; protected bool $hingeRight = false;
/** @var bool */ protected bool $open = false;
protected $hingeRight = false;
/** @var bool */
protected $open = false;
protected function writeStateToMeta() : int{ protected function writeStateToMeta() : int{
if($this->top){ if($this->top){

View File

@ -31,8 +31,7 @@ use pocketmine\world\BlockTransaction;
class DoublePlant extends Flowable{ class DoublePlant extends Flowable{
/** @var bool */ protected bool $top = false;
protected $top = false;
protected function writeStateToMeta() : int{ protected function writeStateToMeta() : int{
return ($this->top ? BlockLegacyMetadata::DOUBLE_PLANT_FLAG_TOP : 0); return ($this->top ? BlockLegacyMetadata::DOUBLE_PLANT_FLAG_TOP : 0);

View File

@ -25,12 +25,9 @@ namespace pocketmine\block;
class Element extends Opaque{ class Element extends Opaque{
/** @var int */ private int $atomicWeight;
private $atomicWeight; private int $group;
/** @var int */ private string $symbol;
private $group;
/** @var string */
private $symbol;
public function __construct(BlockIdentifier $idInfo, string $name, BlockBreakInfo $breakInfo, string $symbol, int $atomicWeight, int $group){ public function __construct(BlockIdentifier $idInfo, string $name, BlockBreakInfo $breakInfo, string $symbol, int $atomicWeight, int $group){
parent::__construct($idInfo, $name, $breakInfo); parent::__construct($idInfo, $name, $breakInfo);

View File

@ -33,8 +33,7 @@ class EndPortalFrame extends Opaque{
use FacesOppositePlacingPlayerTrait; use FacesOppositePlacingPlayerTrait;
use HorizontalFacingTrait; use HorizontalFacingTrait;
/** @var bool */ protected bool $eye = false;
protected $eye = false;
protected function writeStateToMeta() : int{ protected function writeStateToMeta() : int{
return BlockDataSerializer::writeLegacyHorizontalFacing($this->facing) | ($this->eye ? BlockLegacyMetadata::END_PORTAL_FRAME_FLAG_EYE : 0); return BlockDataSerializer::writeLegacyHorizontalFacing($this->facing) | ($this->eye ? BlockLegacyMetadata::END_PORTAL_FRAME_FLAG_EYE : 0);

View File

@ -30,8 +30,7 @@ use pocketmine\math\Facing;
class Farmland extends Transparent{ class Farmland extends Transparent{
/** @var int */ protected int $wetness = 0; //"moisture" blockstate property in PC
protected $wetness = 0; //"moisture" blockstate property in PC
protected function writeStateToMeta() : int{ protected function writeStateToMeta() : int{
return $this->wetness; return $this->wetness;

View File

@ -30,7 +30,7 @@ use function count;
class Fence extends Transparent{ class Fence extends Transparent{
/** @var bool[] facing => dummy */ /** @var bool[] facing => dummy */
protected $connections = []; protected array $connections = [];
public function getThickness() : float{ public function getThickness() : float{
return 0.25; return 0.25;

View File

@ -36,10 +36,8 @@ use pocketmine\world\sound\DoorSound;
class FenceGate extends Transparent{ class FenceGate extends Transparent{
use HorizontalFacingTrait; use HorizontalFacingTrait;
/** @var bool */ protected bool $open = false;
protected $open = false; protected bool $inWall = false;
/** @var bool */
protected $inWall = false;
protected function writeStateToMeta() : int{ protected function writeStateToMeta() : int{
return BlockDataSerializer::writeLegacyHorizontalFacing($this->facing) | return BlockDataSerializer::writeLegacyHorizontalFacing($this->facing) |

View File

@ -37,8 +37,7 @@ use function mt_rand;
class Fire extends Flowable{ class Fire extends Flowable{
/** @var int */ protected int $age = 0;
protected $age = 0;
protected function writeStateToMeta() : int{ protected function writeStateToMeta() : int{
return $this->age; return $this->age;

View File

@ -36,8 +36,8 @@ use function atan2;
use function rad2deg; use function rad2deg;
final class FloorCoralFan extends BaseCoral{ final class FloorCoralFan extends BaseCoral{
/** @var BlockIdentifierFlattened */
protected $idInfoFlattened; protected BlockIdentifierFlattened $idInfoFlattened;
private int $axis = Axis::X; private int $axis = Axis::X;

View File

@ -36,12 +36,9 @@ class FlowerPot extends Flowable{
/** /**
* TODO: get rid of this hack (it's currently needed to deal with blockfactory state handling) * TODO: get rid of this hack (it's currently needed to deal with blockfactory state handling)
* @var bool
*/ */
protected $occupied = false; protected bool $occupied = false;
protected ?Block $plant = null;
/** @var Block|null */
protected $plant = null;
protected function writeStateToMeta() : int{ protected function writeStateToMeta() : int{
return $this->occupied ? BlockLegacyMetadata::FLOWER_POT_FLAG_OCCUPIED : 0; return $this->occupied ? BlockLegacyMetadata::FLOWER_POT_FLAG_OCCUPIED : 0;

View File

@ -28,8 +28,7 @@ use function mt_rand;
class FrostedIce extends Ice{ class FrostedIce extends Ice{
/** @var int */ protected int $age = 0;
protected $age = 0;
public function readStateFromData(int $id, int $stateMeta) : void{ public function readStateFromData(int $id, int $stateMeta) : void{
$this->age = BlockDataSerializer::readBoundedInt("age", $stateMeta, 0, 3); $this->age = BlockDataSerializer::readBoundedInt("age", $stateMeta, 0, 3);

View File

@ -36,11 +36,9 @@ class Furnace extends Opaque{
readStateFromData as readFacingStateFromData; readStateFromData as readFacingStateFromData;
} }
/** @var BlockIdentifierFlattened */ protected BlockIdentifierFlattened $idInfoFlattened;
protected $idInfoFlattened;
/** @var bool */ protected bool $lit = false; //this is set based on the blockID
protected $lit = false; //this is set based on the blockID
public function __construct(BlockIdentifierFlattened $idInfo, string $name, BlockBreakInfo $breakInfo){ public function __construct(BlockIdentifierFlattened $idInfo, string $name, BlockBreakInfo $breakInfo){
$this->idInfoFlattened = $idInfo; $this->idInfoFlattened = $idInfo;

View File

@ -37,8 +37,7 @@ use pocketmine\world\BlockTransaction;
class Hopper extends Transparent{ class Hopper extends Transparent{
use PoweredByRedstoneTrait; use PoweredByRedstoneTrait;
/** @var int */ private int $facing = Facing::DOWN;
private $facing = Facing::DOWN;
public function readStateFromData(int $id, int $stateMeta) : void{ public function readStateFromData(int $id, int $stateMeta) : void{
$facing = BlockDataSerializer::readFacing($stateMeta & 0x07); $facing = BlockDataSerializer::readFacing($stateMeta & 0x07);

View File

@ -38,14 +38,11 @@ class ItemFrame extends Flowable{
public const ROTATIONS = 8; public const ROTATIONS = 8;
/** @var bool */ protected bool $hasMap = false; //makes frame appear large if set
protected $hasMap = false; //makes frame appear large if set
/** @var Item|null */ protected ?Item $framedItem = null;
protected $framedItem = null; protected int $itemRotation = 0;
/** @var int */ protected float $itemDropChance = 1.0;
protected $itemRotation = 0;
/** @var float */
protected $itemDropChance = 1.0;
protected function writeStateToMeta() : int{ protected function writeStateToMeta() : int{
return BlockDataSerializer::write5MinusHorizontalFacing($this->facing) | ($this->hasMap ? BlockLegacyMetadata::ITEM_FRAME_FLAG_HAS_MAP : 0); return BlockDataSerializer::write5MinusHorizontalFacing($this->facing) | ($this->hasMap ? BlockLegacyMetadata::ITEM_FRAME_FLAG_HAS_MAP : 0);

View File

@ -32,8 +32,8 @@ use pocketmine\world\sound\RecordSound;
use pocketmine\world\sound\RecordStopSound; use pocketmine\world\sound\RecordStopSound;
class Jukebox extends Opaque{ class Jukebox extends Opaque{
/** @var Record|null */
private $record = null; private ?Record $record = null;
public function getFuelTime() : int{ public function getFuelTime() : int{
return 300; return 300;

View File

@ -33,8 +33,7 @@ use pocketmine\world\BlockTransaction;
class Lantern extends Transparent{ class Lantern extends Transparent{
/** @var bool */ protected bool $hanging = false;
protected $hanging = false;
public function readStateFromData(int $id, int $stateMeta) : void{ public function readStateFromData(int $id, int $stateMeta) : void{
$this->hanging = ($stateMeta & BlockLegacyMetadata::LANTERN_FLAG_HANGING) !== 0; $this->hanging = ($stateMeta & BlockLegacyMetadata::LANTERN_FLAG_HANGING) !== 0;

View File

@ -37,13 +37,10 @@ use pocketmine\world\World;
use function mt_rand; use function mt_rand;
class Leaves extends Transparent{ class Leaves extends Transparent{
/** @var TreeType */
protected $treeType;
/** @var bool */ protected TreeType $treeType;
protected $noDecay = false; protected bool $noDecay = false;
/** @var bool */ protected bool $checkDecay = false;
protected $checkDecay = false;
public function __construct(BlockIdentifier $idInfo, string $name, BlockBreakInfo $breakInfo, TreeType $treeType){ public function __construct(BlockIdentifier $idInfo, string $name, BlockBreakInfo $breakInfo, TreeType $treeType){
parent::__construct($idInfo, $name, $breakInfo); parent::__construct($idInfo, $name, $breakInfo);

View File

@ -38,12 +38,9 @@ class Lever extends Flowable{
protected const SIDE = 1; protected const SIDE = 1;
protected const TOP = 2; protected const TOP = 2;
/** @var int */ protected int $leverPos = self::BOTTOM;
protected $leverPos = self::BOTTOM; protected int $facing = Facing::NORTH;
/** @var int */ protected bool $powered = false;
protected $facing = Facing::NORTH;
/** @var bool */
protected $powered = false;
protected function writeStateToMeta() : int{ protected function writeStateToMeta() : int{
if($this->leverPos === self::BOTTOM){ if($this->leverPos === self::BOTTOM){

View File

@ -39,28 +39,23 @@ use function lcg_value;
use function min; use function min;
abstract class Liquid extends Transparent{ abstract class Liquid extends Transparent{
/** @var BlockIdentifierFlattened */
protected $idInfoFlattened;
/** @var int */ protected BlockIdentifierFlattened $idInfoFlattened;
public $adjacentSources = 0;
/** @var Vector3|null */ public int $adjacentSources = 0;
protected $flowVector = null;
protected ?Vector3 $flowVector = null;
/** @var int[] */ /** @var int[] */
private $flowCostVisited = []; private array $flowCostVisited = [];
private const CAN_FLOW_DOWN = 1; private const CAN_FLOW_DOWN = 1;
private const CAN_FLOW = 0; private const CAN_FLOW = 0;
private const BLOCKED = -1; private const BLOCKED = -1;
/** @var bool */ protected bool $falling = false;
protected $falling = false; protected int $decay = 0; //PC "level" property
/** @var int */ protected bool $still = false;
protected $decay = 0; //PC "level" property
/** @var bool */
protected $still = false;
public function __construct(BlockIdentifierFlattened $idInfo, string $name, BlockBreakInfo $breakInfo){ public function __construct(BlockIdentifierFlattened $idInfo, string $name, BlockBreakInfo $breakInfo){
$this->idInfoFlattened = $idInfo; $this->idInfoFlattened = $idInfo;

View File

@ -29,8 +29,8 @@ use pocketmine\math\Axis;
use pocketmine\math\AxisAlignedBB; use pocketmine\math\AxisAlignedBB;
class NetherPortal extends Transparent{ class NetherPortal extends Transparent{
/** @var int */
protected $axis = Axis::X; protected int $axis = Axis::X;
public function readStateFromData(int $id, int $stateMeta) : void{ public function readStateFromData(int $id, int $stateMeta) : void{
$this->axis = $stateMeta === BlockLegacyMetadata::NETHER_PORTAL_AXIS_Z ? Axis::Z : Axis::X; //mojang u dumb $this->axis = $stateMeta === BlockLegacyMetadata::NETHER_PORTAL_AXIS_Z ? Axis::Z : Axis::X; //mojang u dumb

View File

@ -29,8 +29,7 @@ use pocketmine\item\VanillaItems;
class NetherReactor extends Opaque{ class NetherReactor extends Opaque{
/** @var int */ protected int $state = BlockLegacyMetadata::NETHER_REACTOR_INACTIVE;
protected $state = BlockLegacyMetadata::NETHER_REACTOR_INACTIVE;
protected function writeStateToMeta() : int{ protected function writeStateToMeta() : int{
return $this->state; return $this->state;

View File

@ -34,8 +34,7 @@ use function mt_rand;
class NetherWartPlant extends Flowable{ class NetherWartPlant extends Flowable{
/** @var int */ protected int $age = 0;
protected $age = 0;
protected function writeStateToMeta() : int{ protected function writeStateToMeta() : int{
return $this->age; return $this->age;

View File

@ -30,8 +30,7 @@ class Note extends Opaque{
public const MIN_PITCH = 0; public const MIN_PITCH = 0;
public const MAX_PITCH = 24; public const MAX_PITCH = 24;
/** @var int */ private int $pitch = self::MIN_PITCH;
private $pitch = self::MIN_PITCH;
public function readStateFromWorld() : void{ public function readStateFromWorld() : void{
parent::readStateFromWorld(); parent::readStateFromWorld();

View File

@ -35,7 +35,7 @@ class RedMushroomBlock extends Opaque{
* the legacy crap for now. * the legacy crap for now.
* TODO: change this once proper blockstates are implemented * TODO: change this once proper blockstates are implemented
*/ */
protected $rotationData = 0; protected int $rotationData = 0;
protected function writeStateToMeta() : int{ protected function writeStateToMeta() : int{
return $this->rotationData; return $this->rotationData;

View File

@ -41,11 +41,9 @@ class RedstoneComparator extends Flowable{
use AnalogRedstoneSignalEmitterTrait; use AnalogRedstoneSignalEmitterTrait;
use PoweredByRedstoneTrait; use PoweredByRedstoneTrait;
/** @var BlockIdentifierFlattened */ protected BlockIdentifierFlattened $idInfoFlattened;
protected $idInfoFlattened;
/** @var bool */ protected bool $isSubtractMode = false;
protected $isSubtractMode = false;
public function __construct(BlockIdentifierFlattened $idInfo, string $name, BlockBreakInfo $breakInfo){ public function __construct(BlockIdentifierFlattened $idInfo, string $name, BlockBreakInfo $breakInfo){
$this->idInfoFlattened = $idInfo; $this->idInfoFlattened = $idInfo;

View File

@ -28,8 +28,7 @@ use pocketmine\block\utils\PoweredByRedstoneTrait;
class RedstoneLamp extends Opaque{ class RedstoneLamp extends Opaque{
use PoweredByRedstoneTrait; use PoweredByRedstoneTrait;
/** @var BlockIdentifierFlattened */ protected BlockIdentifierFlattened $idInfoFlattened;
protected $idInfoFlattened;
public function __construct(BlockIdentifierFlattened $idInfo, string $name, BlockBreakInfo $breakInfo){ public function __construct(BlockIdentifierFlattened $idInfo, string $name, BlockBreakInfo $breakInfo){
$this->idInfoFlattened = $idInfo; $this->idInfoFlattened = $idInfo;

View File

@ -30,11 +30,10 @@ use pocketmine\player\Player;
use function mt_rand; use function mt_rand;
class RedstoneOre extends Opaque{ class RedstoneOre extends Opaque{
/** @var BlockIdentifierFlattened */
protected $idInfoFlattened;
/** @var bool */ protected BlockIdentifierFlattened $idInfoFlattened;
protected $lit = false;
protected bool $lit = false;
public function __construct(BlockIdentifierFlattened $idInfo, string $name, BlockBreakInfo $breakInfo){ public function __construct(BlockIdentifierFlattened $idInfo, string $name, BlockBreakInfo $breakInfo){
$this->idInfoFlattened = $idInfo; $this->idInfoFlattened = $idInfo;

View File

@ -37,11 +37,9 @@ class RedstoneRepeater extends Flowable{
use HorizontalFacingTrait; use HorizontalFacingTrait;
use PoweredByRedstoneTrait; use PoweredByRedstoneTrait;
/** @var BlockIdentifierFlattened */ protected BlockIdentifierFlattened $idInfoFlattened;
protected $idInfoFlattened;
/** @var int */ protected int $delay = 1;
protected $delay = 1;
public function __construct(BlockIdentifierFlattened $idInfo, string $name, BlockBreakInfo $breakInfo){ public function __construct(BlockIdentifierFlattened $idInfo, string $name, BlockBreakInfo $breakInfo){
$this->idInfoFlattened = $idInfo; $this->idInfoFlattened = $idInfo;

View File

@ -25,11 +25,9 @@ namespace pocketmine\block;
class RedstoneTorch extends Torch{ class RedstoneTorch extends Torch{
/** @var BlockIdentifierFlattened */ protected BlockIdentifierFlattened $idInfoFlattened;
protected $idInfoFlattened;
/** @var bool */ protected bool $lit = true;
protected $lit = true;
public function __construct(BlockIdentifierFlattened $idInfo, string $name, BlockBreakInfo $breakInfo){ public function __construct(BlockIdentifierFlattened $idInfo, string $name, BlockBreakInfo $breakInfo){
$this->idInfoFlattened = $idInfo; $this->idInfoFlattened = $idInfo;

View File

@ -36,10 +36,9 @@ use function mt_rand;
class Sapling extends Flowable{ class Sapling extends Flowable{
/** @var bool */ protected bool $ready = false;
protected $ready = false;
/** @var TreeType */ private TreeType $treeType;
private $treeType;
public function __construct(BlockIdentifier $idInfo, string $name, BlockBreakInfo $breakInfo, TreeType $treeType){ public function __construct(BlockIdentifier $idInfo, string $name, BlockBreakInfo $breakInfo, TreeType $treeType){
parent::__construct($idInfo, $name, $breakInfo); parent::__construct($idInfo, $name, $breakInfo);

View File

@ -30,10 +30,9 @@ use pocketmine\player\Player;
use pocketmine\world\BlockTransaction; use pocketmine\world\BlockTransaction;
class SeaPickle extends Transparent{ class SeaPickle extends Transparent{
/** @var int */
protected $count = 1; protected int $count = 1;
/** @var bool */ protected bool $underwater = false;
protected $underwater = false;
public function readStateFromData(int $id, int $stateMeta) : void{ public function readStateFromData(int $id, int $stateMeta) : void{
$this->count = ($stateMeta & 0x03) + 1; $this->count = ($stateMeta & 0x03) + 1;

View File

@ -25,8 +25,7 @@ namespace pocketmine\block;
abstract class SimplePressurePlate extends PressurePlate{ abstract class SimplePressurePlate extends PressurePlate{
/** @var bool */ protected bool $pressed = false;
protected $pressed = false;
protected function writeStateToMeta() : int{ protected function writeStateToMeta() : int{
return $this->pressed ? BlockLegacyMetadata::PRESSURE_PLATE_FLAG_POWERED : 0; return $this->pressed ? BlockLegacyMetadata::PRESSURE_PLATE_FLAG_POWERED : 0;

View File

@ -39,16 +39,12 @@ use function assert;
use function floor; use function floor;
class Skull extends Flowable{ class Skull extends Flowable{
/** @var SkullType */
protected $skullType;
/** @var int */ protected SkullType $skullType;
protected $facing = Facing::NORTH;
protected int $facing = Facing::NORTH;
protected bool $noDrops = false; protected bool $noDrops = false;
protected int $rotation = 0; //TODO: split this into floor skull and wall skull handling
/** @var int */
protected $rotation = 0; //TODO: split this into floor skull and wall skull handling
public function __construct(BlockIdentifier $idInfo, string $name, BlockBreakInfo $breakInfo){ public function __construct(BlockIdentifier $idInfo, string $name, BlockBreakInfo $breakInfo){
$this->skullType = SkullType::SKELETON(); //TODO: this should be a parameter $this->skullType = SkullType::SKELETON(); //TODO: this should be a parameter

View File

@ -32,11 +32,10 @@ use pocketmine\player\Player;
use pocketmine\world\BlockTransaction; use pocketmine\world\BlockTransaction;
class Slab extends Transparent{ class Slab extends Transparent{
/** @var BlockIdentifierFlattened */
protected $idInfoFlattened;
/** @var SlabType */ protected BlockIdentifierFlattened $idInfoFlattened;
protected $slabType;
protected SlabType $slabType;
public function __construct(BlockIdentifierFlattened $idInfo, string $name, BlockBreakInfo $breakInfo){ public function __construct(BlockIdentifierFlattened $idInfo, string $name, BlockBreakInfo $breakInfo){
$this->idInfoFlattened = $idInfo; $this->idInfoFlattened = $idInfo;

View File

@ -39,8 +39,7 @@ use function max;
class SnowLayer extends Flowable implements Fallable{ class SnowLayer extends Flowable implements Fallable{
use FallableTrait; use FallableTrait;
/** @var int */ protected int $layers = 1;
protected $layers = 1;
protected function writeStateToMeta() : int{ protected function writeStateToMeta() : int{
return $this->layers - 1; return $this->layers - 1;

View File

@ -25,8 +25,7 @@ namespace pocketmine\block;
class Sponge extends Opaque{ class Sponge extends Opaque{
/** @var bool */ protected bool $wet = false;
protected $wet = false;
protected function writeStateToMeta() : int{ protected function writeStateToMeta() : int{
return $this->wet ? BlockLegacyMetadata::SPONGE_FLAG_WET : 0; return $this->wet ? BlockLegacyMetadata::SPONGE_FLAG_WET : 0;

View File

@ -36,11 +36,8 @@ use pocketmine\world\BlockTransaction;
class Stair extends Transparent{ class Stair extends Transparent{
use HorizontalFacingTrait; use HorizontalFacingTrait;
/** @var bool */ protected bool $upsideDown = false;
protected $upsideDown = false; protected StairShape $shape;
/** @var StairShape */
protected $shape;
public function __construct(BlockIdentifier $idInfo, string $name, BlockBreakInfo $breakInfo){ public function __construct(BlockIdentifier $idInfo, string $name, BlockBreakInfo $breakInfo){
$this->shape = StairShape::STRAIGHT(); $this->shape = StairShape::STRAIGHT();

View File

@ -34,8 +34,7 @@ use pocketmine\world\BlockTransaction;
class Sugarcane extends Flowable{ class Sugarcane extends Flowable{
/** @var int */ protected int $age = 0;
protected $age = 0;
protected function writeStateToMeta() : int{ protected function writeStateToMeta() : int{
return $this->age; return $this->age;

View File

@ -41,8 +41,7 @@ use const M_PI;
class TNT extends Opaque{ class TNT extends Opaque{
/** @var bool */ protected bool $unstable = false; //TODO: Usage unclear, seems to be a weird hack in vanilla
protected $unstable = false; //TODO: Usage unclear, seems to be a weird hack in vanilla
protected bool $worksUnderwater = false; protected bool $worksUnderwater = false;
public function readStateFromData(int $id, int $stateMeta) : void{ public function readStateFromData(int $id, int $stateMeta) : void{

View File

@ -30,7 +30,7 @@ use function count;
class Thin extends Transparent{ class Thin extends Transparent{
/** @var bool[] facing => dummy */ /** @var bool[] facing => dummy */
protected $connections = []; protected array $connections = [];
public function readStateFromWorld() : void{ public function readStateFromWorld() : void{
parent::readStateFromWorld(); parent::readStateFromWorld();

View File

@ -32,8 +32,7 @@ use pocketmine\world\BlockTransaction;
class Torch extends Flowable{ class Torch extends Flowable{
/** @var int */ protected int $facing = Facing::UP;
protected $facing = Facing::UP;
protected function writeStateToMeta() : int{ protected function writeStateToMeta() : int{
return $this->facing === Facing::UP ? 5 : 6 - BlockDataSerializer::writeHorizontalFacing($this->facing); return $this->facing === Facing::UP ? 5 : 6 - BlockDataSerializer::writeHorizontalFacing($this->facing);

View File

@ -36,10 +36,8 @@ use pocketmine\world\sound\DoorSound;
class Trapdoor extends Transparent{ class Trapdoor extends Transparent{
use HorizontalFacingTrait; use HorizontalFacingTrait;
/** @var bool */ protected bool $open = false;
protected $open = false; protected bool $top = false;
/** @var bool */
protected $top = false;
protected function writeStateToMeta() : int{ protected function writeStateToMeta() : int{
return BlockDataSerializer::write5MinusHorizontalFacing($this->facing) | ($this->top ? BlockLegacyMetadata::TRAPDOOR_FLAG_UPPER : 0) | ($this->open ? BlockLegacyMetadata::TRAPDOOR_FLAG_OPEN : 0); return BlockDataSerializer::write5MinusHorizontalFacing($this->facing) | ($this->top ? BlockLegacyMetadata::TRAPDOOR_FLAG_UPPER : 0) | ($this->open ? BlockLegacyMetadata::TRAPDOOR_FLAG_OPEN : 0);

View File

@ -25,14 +25,10 @@ namespace pocketmine\block;
class Tripwire extends Flowable{ class Tripwire extends Flowable{
/** @var bool */ protected bool $triggered = false;
protected $triggered = false; protected bool $suspended = false; //unclear usage, makes hitbox bigger if set
/** @var bool */ protected bool $connected = false;
protected $suspended = false; //unclear usage, makes hitbox bigger if set protected bool $disarmed = false;
/** @var bool */
protected $connected = false;
/** @var bool */
protected $disarmed = false;
protected function writeStateToMeta() : int{ protected function writeStateToMeta() : int{
return ($this->triggered ? BlockLegacyMetadata::TRIPWIRE_FLAG_TRIGGERED : 0) | return ($this->triggered ? BlockLegacyMetadata::TRIPWIRE_FLAG_TRIGGERED : 0) |

View File

@ -35,10 +35,8 @@ use pocketmine\world\BlockTransaction;
class TripwireHook extends Flowable{ class TripwireHook extends Flowable{
use HorizontalFacingTrait; use HorizontalFacingTrait;
/** @var bool */ protected bool $connected = false;
protected $connected = false; protected bool $powered = false;
/** @var bool */
protected $powered = false;
protected function writeStateToMeta() : int{ protected function writeStateToMeta() : int{
return BlockDataSerializer::writeLegacyHorizontalFacing($this->facing) | return BlockDataSerializer::writeLegacyHorizontalFacing($this->facing) |

View File

@ -36,7 +36,7 @@ use function count;
class Vine extends Flowable{ class Vine extends Flowable{
/** @var int[] */ /** @var int[] */
protected $faces = []; protected array $faces = [];
protected function writeStateToMeta() : int{ protected function writeStateToMeta() : int{
return return

View File

@ -29,9 +29,8 @@ use pocketmine\math\Facing;
class Wall extends Transparent{ class Wall extends Transparent{
/** @var int[] facing => facing */ /** @var int[] facing => facing */
protected $connections = []; protected array $connections = [];
/** @var bool */ protected bool $up = false;
protected $up = false;
public function readStateFromWorld() : void{ public function readStateFromWorld() : void{
parent::readStateFromWorld(); parent::readStateFromWorld();

View File

@ -41,8 +41,7 @@ use pocketmine\world\BlockTransaction;
final class WallCoralFan extends BaseCoral{ final class WallCoralFan extends BaseCoral{
use HorizontalFacingTrait; use HorizontalFacingTrait;
/** @var BlockIdentifierFlattened */ protected BlockIdentifierFlattened $idInfoFlattened;
protected $idInfoFlattened;
public function __construct(BlockIdentifierFlattened $idInfo, string $name, BlockBreakInfo $breakInfo){ public function __construct(BlockIdentifierFlattened $idInfo, string $name, BlockBreakInfo $breakInfo){
$this->idInfoFlattened = $idInfo; $this->idInfoFlattened = $idInfo;

View File

@ -30,8 +30,7 @@ use pocketmine\player\Player;
class Wood extends Opaque{ class Wood extends Opaque{
/** @var TreeType */ private TreeType $treeType;
private $treeType;
private bool $stripped; private bool $stripped;