diff --git a/src/block/Anvil.php b/src/block/Anvil.php index 17814e2c9..270004973 100644 --- a/src/block/Anvil.php +++ b/src/block/Anvil.php @@ -51,11 +51,11 @@ class Anvil extends Transparent implements Fallable{ private int $damage = self::UNDAMAGED; - protected function describeType(RuntimeDataDescriber $w) : void{ + public function describeType(RuntimeDataDescriber $w) : void{ $w->boundedInt(2, self::UNDAMAGED, self::VERY_DAMAGED, $this->damage); } - protected function describeState(RuntimeDataDescriber $w) : void{ + public function describeState(RuntimeDataDescriber $w) : void{ $w->horizontalFacing($this->facing); } diff --git a/src/block/Bamboo.php b/src/block/Bamboo.php index a6a08859b..d766cdc2e 100644 --- a/src/block/Bamboo.php +++ b/src/block/Bamboo.php @@ -55,7 +55,7 @@ class Bamboo extends Transparent{ protected bool $ready = false; protected int $leafSize = self::NO_LEAVES; - protected function describeState(RuntimeDataDescriber $w) : void{ + public function describeState(RuntimeDataDescriber $w) : void{ $w->boundedInt(2, self::NO_LEAVES, self::LARGE_LEAVES, $this->leafSize); $w->bool($this->thick); $w->bool($this->ready); diff --git a/src/block/BambooSapling.php b/src/block/BambooSapling.php index cfa81519b..53db4b54b 100644 --- a/src/block/BambooSapling.php +++ b/src/block/BambooSapling.php @@ -36,7 +36,7 @@ use pocketmine\world\BlockTransaction; final class BambooSapling extends Flowable{ private bool $ready = false; - protected function describeState(RuntimeDataDescriber $w) : void{ + public function describeState(RuntimeDataDescriber $w) : void{ $w->bool($this->ready); } diff --git a/src/block/Barrel.php b/src/block/Barrel.php index 68eda5331..e9218db56 100644 --- a/src/block/Barrel.php +++ b/src/block/Barrel.php @@ -38,7 +38,7 @@ class Barrel extends Opaque{ protected bool $open = false; - protected function describeState(RuntimeDataDescriber $w) : void{ + public function describeState(RuntimeDataDescriber $w) : void{ $w->facing($this->facing); $w->bool($this->open); } diff --git a/src/block/Bed.php b/src/block/Bed.php index 678c8a542..4b4262796 100644 --- a/src/block/Bed.php +++ b/src/block/Bed.php @@ -53,7 +53,7 @@ class Bed extends Transparent{ parent::__construct($idInfo, $name, $typeInfo); } - protected function describeState(RuntimeDataDescriber $w) : void{ + public function describeState(RuntimeDataDescriber $w) : void{ $w->horizontalFacing($this->facing); $w->bool($this->occupied); $w->bool($this->head); diff --git a/src/block/Bedrock.php b/src/block/Bedrock.php index 4bca83305..7d8ed647f 100644 --- a/src/block/Bedrock.php +++ b/src/block/Bedrock.php @@ -28,7 +28,7 @@ use pocketmine\data\runtime\RuntimeDataDescriber; class Bedrock extends Opaque{ private bool $burnsForever = false; - protected function describeState(RuntimeDataDescriber $w) : void{ + public function describeState(RuntimeDataDescriber $w) : void{ $w->bool($this->burnsForever); } diff --git a/src/block/Bell.php b/src/block/Bell.php index f20a031c2..6792dc1a4 100644 --- a/src/block/Bell.php +++ b/src/block/Bell.php @@ -48,7 +48,7 @@ final class Bell extends Transparent{ parent::__construct($idInfo, $name, $typeInfo); } - protected function describeState(RuntimeDataDescriber $w) : void{ + public function describeState(RuntimeDataDescriber $w) : void{ $w->bellAttachmentType($this->attachmentType); $w->horizontalFacing($this->facing); } diff --git a/src/block/Block.php b/src/block/Block.php index 6863f47bc..34b327295 100644 --- a/src/block/Block.php +++ b/src/block/Block.php @@ -214,11 +214,11 @@ class Block{ return $writer->getValue(); } - protected function describeType(RuntimeDataDescriber $w) : void{ + public function describeType(RuntimeDataDescriber $w) : void{ //NOOP } - protected function describeState(RuntimeDataDescriber $w) : void{ + public function describeState(RuntimeDataDescriber $w) : void{ //NOOP } diff --git a/src/block/BrewingStand.php b/src/block/BrewingStand.php index 479d20739..8c3d29ba1 100644 --- a/src/block/BrewingStand.php +++ b/src/block/BrewingStand.php @@ -43,7 +43,7 @@ class BrewingStand extends Transparent{ */ protected array $slots = []; - protected function describeState(RuntimeDataDescriber $w) : void{ + public function describeState(RuntimeDataDescriber $w) : void{ $w->brewingStandSlots($this->slots); } diff --git a/src/block/Button.php b/src/block/Button.php index aa6ca8fa0..4573f03a4 100644 --- a/src/block/Button.php +++ b/src/block/Button.php @@ -38,7 +38,7 @@ abstract class Button extends Flowable{ protected bool $pressed = false; - protected function describeState(RuntimeDataDescriber $w) : void{ + public function describeState(RuntimeDataDescriber $w) : void{ $w->facing($this->facing); $w->bool($this->pressed); } diff --git a/src/block/Cactus.php b/src/block/Cactus.php index 18dd726e7..66b8734dd 100644 --- a/src/block/Cactus.php +++ b/src/block/Cactus.php @@ -41,7 +41,7 @@ class Cactus extends Transparent{ protected int $age = 0; - protected function describeState(RuntimeDataDescriber $w) : void{ + public function describeState(RuntimeDataDescriber $w) : void{ $w->boundedInt(4, 0, self::MAX_AGE, $this->age); } diff --git a/src/block/Cake.php b/src/block/Cake.php index 93e51be21..4266ece68 100644 --- a/src/block/Cake.php +++ b/src/block/Cake.php @@ -36,7 +36,7 @@ class Cake extends BaseCake{ protected int $bites = 0; - protected function describeState(RuntimeDataDescriber $w) : void{ + public function describeState(RuntimeDataDescriber $w) : void{ $w->boundedInt(3, 0, self::MAX_BITES, $this->bites); } diff --git a/src/block/Candle.php b/src/block/Candle.php index 4870277cc..4982ae189 100644 --- a/src/block/Candle.php +++ b/src/block/Candle.php @@ -46,7 +46,7 @@ class Candle extends Transparent{ private int $count = self::MIN_COUNT; - protected function describeState(RuntimeDataDescriber $w) : void{ + public function describeState(RuntimeDataDescriber $w) : void{ $this->encodeLitState($w); $w->boundedInt(2, self::MIN_COUNT, self::MAX_COUNT, $this->count); } diff --git a/src/block/ChorusFlower.php b/src/block/ChorusFlower.php index 2aa65d1f6..9236be47a 100644 --- a/src/block/ChorusFlower.php +++ b/src/block/ChorusFlower.php @@ -49,7 +49,7 @@ final class ChorusFlower extends Flowable{ private int $age = self::MIN_AGE; - protected function describeState(RuntimeDataDescriber $w) : void{ + public function describeState(RuntimeDataDescriber $w) : void{ $w->boundedInt(3, self::MIN_AGE, self::MAX_AGE, $this->age); } diff --git a/src/block/CocoaBlock.php b/src/block/CocoaBlock.php index fe4f1736b..bfa0778dc 100644 --- a/src/block/CocoaBlock.php +++ b/src/block/CocoaBlock.php @@ -46,7 +46,7 @@ class CocoaBlock extends Transparent{ protected int $age = 0; - protected function describeState(RuntimeDataDescriber $w) : void{ + public function describeState(RuntimeDataDescriber $w) : void{ $w->horizontalFacing($this->facing); $w->boundedInt(2, 0, self::MAX_AGE, $this->age); } diff --git a/src/block/Crops.php b/src/block/Crops.php index c1c13bee9..de9d3f2db 100644 --- a/src/block/Crops.php +++ b/src/block/Crops.php @@ -38,7 +38,7 @@ abstract class Crops extends Flowable{ protected int $age = 0; - protected function describeState(RuntimeDataDescriber $w) : void{ + public function describeState(RuntimeDataDescriber $w) : void{ $w->boundedInt(3, 0, self::MAX_AGE, $this->age); } diff --git a/src/block/DaylightSensor.php b/src/block/DaylightSensor.php index 2a55500c6..cb296e809 100644 --- a/src/block/DaylightSensor.php +++ b/src/block/DaylightSensor.php @@ -41,7 +41,7 @@ class DaylightSensor extends Transparent{ protected bool $inverted = false; - protected function describeState(RuntimeDataDescriber $w) : void{ + public function describeState(RuntimeDataDescriber $w) : void{ $w->boundedInt(4, 0, 15, $this->signalStrength); $w->bool($this->inverted); } diff --git a/src/block/DetectorRail.php b/src/block/DetectorRail.php index 8af12276b..10f371c66 100644 --- a/src/block/DetectorRail.php +++ b/src/block/DetectorRail.php @@ -28,7 +28,7 @@ use pocketmine\data\runtime\RuntimeDataDescriber; class DetectorRail extends StraightOnlyRail{ protected bool $activated = false; - protected function describeState(RuntimeDataDescriber $w) : void{ + public function describeState(RuntimeDataDescriber $w) : void{ parent::describeState($w); $w->bool($this->activated); } diff --git a/src/block/Dirt.php b/src/block/Dirt.php index 900879433..33f3800d7 100644 --- a/src/block/Dirt.php +++ b/src/block/Dirt.php @@ -45,7 +45,7 @@ class Dirt extends Opaque{ parent::__construct($idInfo, $name, $typeInfo); } - protected function describeType(RuntimeDataDescriber $w) : void{ + public function describeType(RuntimeDataDescriber $w) : void{ $w->dirtType($this->dirtType); } diff --git a/src/block/Door.php b/src/block/Door.php index 98a8f5309..13188ffa3 100644 --- a/src/block/Door.php +++ b/src/block/Door.php @@ -41,7 +41,7 @@ class Door extends Transparent{ protected bool $hingeRight = false; protected bool $open = false; - protected function describeState(RuntimeDataDescriber $w) : void{ + public function describeState(RuntimeDataDescriber $w) : void{ $w->horizontalFacing($this->facing); $w->bool($this->top); $w->bool($this->hingeRight); diff --git a/src/block/DoublePlant.php b/src/block/DoublePlant.php index be231c1ea..4b74cf701 100644 --- a/src/block/DoublePlant.php +++ b/src/block/DoublePlant.php @@ -33,7 +33,7 @@ use pocketmine\world\BlockTransaction; class DoublePlant extends Flowable{ protected bool $top = false; - protected function describeState(RuntimeDataDescriber $w) : void{ + public function describeState(RuntimeDataDescriber $w) : void{ $w->bool($this->top); } diff --git a/src/block/EndPortalFrame.php b/src/block/EndPortalFrame.php index 5a6537d4d..89e700ca2 100644 --- a/src/block/EndPortalFrame.php +++ b/src/block/EndPortalFrame.php @@ -35,7 +35,7 @@ class EndPortalFrame extends Opaque{ protected bool $eye = false; - protected function describeState(RuntimeDataDescriber $w) : void{ + public function describeState(RuntimeDataDescriber $w) : void{ $w->horizontalFacing($this->facing); $w->bool($this->eye); } diff --git a/src/block/Farmland.php b/src/block/Farmland.php index 7ce08c2d9..bd2ff2f85 100644 --- a/src/block/Farmland.php +++ b/src/block/Farmland.php @@ -37,7 +37,7 @@ class Farmland extends Transparent{ protected int $wetness = 0; //"moisture" blockstate property in PC - protected function describeState(RuntimeDataDescriber $w) : void{ + public function describeState(RuntimeDataDescriber $w) : void{ $w->boundedInt(3, 0, self::MAX_WETNESS, $this->wetness); } diff --git a/src/block/FenceGate.php b/src/block/FenceGate.php index 7ad96d842..6bc86853b 100644 --- a/src/block/FenceGate.php +++ b/src/block/FenceGate.php @@ -42,7 +42,7 @@ class FenceGate extends Transparent{ protected bool $open = false; protected bool $inWall = false; - protected function describeState(RuntimeDataDescriber $w) : void{ + public function describeState(RuntimeDataDescriber $w) : void{ $w->horizontalFacing($this->facing); $w->bool($this->open); $w->bool($this->inWall); diff --git a/src/block/FillableCauldron.php b/src/block/FillableCauldron.php index b6d9b995e..5f92eed57 100644 --- a/src/block/FillableCauldron.php +++ b/src/block/FillableCauldron.php @@ -37,7 +37,7 @@ abstract class FillableCauldron extends Transparent{ private int $fillLevel = self::MIN_FILL_LEVEL; - protected function describeState(RuntimeDataDescriber $w) : void{ + public function describeState(RuntimeDataDescriber $w) : void{ $w->boundedInt(3, self::MIN_FILL_LEVEL, self::MAX_FILL_LEVEL, $this->fillLevel); } diff --git a/src/block/Fire.php b/src/block/Fire.php index 6f4332261..e1d463322 100644 --- a/src/block/Fire.php +++ b/src/block/Fire.php @@ -39,7 +39,7 @@ class Fire extends BaseFire{ protected int $age = 0; - protected function describeState(RuntimeDataDescriber $w) : void{ + public function describeState(RuntimeDataDescriber $w) : void{ $w->boundedInt(4, 0, self::MAX_AGE, $this->age); } diff --git a/src/block/FloorCoralFan.php b/src/block/FloorCoralFan.php index 173c87a08..ff484fb78 100644 --- a/src/block/FloorCoralFan.php +++ b/src/block/FloorCoralFan.php @@ -37,7 +37,7 @@ use function rad2deg; final class FloorCoralFan extends BaseCoral{ private int $axis = Axis::X; - protected function describeState(RuntimeDataDescriber $w) : void{ + public function describeState(RuntimeDataDescriber $w) : void{ $w->horizontalAxis($this->axis); } diff --git a/src/block/Froglight.php b/src/block/Froglight.php index 13b68e21e..dcd14c900 100644 --- a/src/block/Froglight.php +++ b/src/block/Froglight.php @@ -35,7 +35,7 @@ final class Froglight extends SimplePillar{ parent::__construct($idInfo, $name, $typeInfo); } - protected function describeType(RuntimeDataDescriber $w) : void{ + public function describeType(RuntimeDataDescriber $w) : void{ $w->froglightType($this->froglightType); } diff --git a/src/block/FrostedIce.php b/src/block/FrostedIce.php index 5953ce8ae..b2d2750a3 100644 --- a/src/block/FrostedIce.php +++ b/src/block/FrostedIce.php @@ -32,7 +32,7 @@ class FrostedIce extends Ice{ protected int $age = 0; - protected function describeState(RuntimeDataDescriber $w) : void{ + public function describeState(RuntimeDataDescriber $w) : void{ $w->boundedInt(2, 0, self::MAX_AGE, $this->age); } diff --git a/src/block/Furnace.php b/src/block/Furnace.php index f830a3835..f6cbe6bcf 100644 --- a/src/block/Furnace.php +++ b/src/block/Furnace.php @@ -46,7 +46,7 @@ class Furnace extends Opaque{ parent::__construct($idInfo, $name, $typeInfo); } - protected function describeState(RuntimeDataDescriber $w) : void{ + public function describeState(RuntimeDataDescriber $w) : void{ $w->horizontalFacing($this->facing); $w->bool($this->lit); } diff --git a/src/block/Hopper.php b/src/block/Hopper.php index 778e5c2a1..42ccb14c7 100644 --- a/src/block/Hopper.php +++ b/src/block/Hopper.php @@ -39,7 +39,7 @@ class Hopper extends Transparent{ private int $facing = Facing::DOWN; - protected function describeState(RuntimeDataDescriber $w) : void{ + public function describeState(RuntimeDataDescriber $w) : void{ $w->facingExcept($this->facing, Facing::UP); $w->bool($this->powered); } diff --git a/src/block/ItemFrame.php b/src/block/ItemFrame.php index 94754910f..63016a390 100644 --- a/src/block/ItemFrame.php +++ b/src/block/ItemFrame.php @@ -50,7 +50,7 @@ class ItemFrame extends Flowable{ protected int $itemRotation = 0; protected float $itemDropChance = 1.0; - protected function describeState(RuntimeDataDescriber $w) : void{ + public function describeState(RuntimeDataDescriber $w) : void{ $w->facing($this->facing); $w->bool($this->hasMap); } diff --git a/src/block/Lantern.php b/src/block/Lantern.php index a5d8031dd..a8fbddd37 100644 --- a/src/block/Lantern.php +++ b/src/block/Lantern.php @@ -43,7 +43,7 @@ class Lantern extends Transparent{ parent::__construct($idInfo, $name, $typeInfo); } - protected function describeState(RuntimeDataDescriber $w) : void{ + public function describeState(RuntimeDataDescriber $w) : void{ $w->bool($this->hanging); } diff --git a/src/block/Leaves.php b/src/block/Leaves.php index b83de2dde..886946425 100644 --- a/src/block/Leaves.php +++ b/src/block/Leaves.php @@ -47,7 +47,7 @@ class Leaves extends Transparent{ $this->leavesType = $leavesType; } - protected function describeState(RuntimeDataDescriber $w) : void{ + public function describeState(RuntimeDataDescriber $w) : void{ $w->bool($this->noDecay); $w->bool($this->checkDecay); } diff --git a/src/block/Lectern.php b/src/block/Lectern.php index ae1df8549..0b4f3f622 100644 --- a/src/block/Lectern.php +++ b/src/block/Lectern.php @@ -46,7 +46,7 @@ class Lectern extends Transparent{ protected bool $producingSignal = false; - protected function describeState(RuntimeDataDescriber $w) : void{ + public function describeState(RuntimeDataDescriber $w) : void{ $w->horizontalFacing($this->facing); $w->bool($this->producingSignal); } diff --git a/src/block/Lever.php b/src/block/Lever.php index 284a646d9..889402815 100644 --- a/src/block/Lever.php +++ b/src/block/Lever.php @@ -44,7 +44,7 @@ class Lever extends Flowable{ parent::__construct($idInfo, $name, $typeInfo); } - protected function describeState(RuntimeDataDescriber $w) : void{ + public function describeState(RuntimeDataDescriber $w) : void{ $w->leverFacing($this->facing); $w->bool($this->activated); } diff --git a/src/block/Light.php b/src/block/Light.php index 5ee7281c9..963c00385 100644 --- a/src/block/Light.php +++ b/src/block/Light.php @@ -34,7 +34,7 @@ final class Light extends Flowable{ private int $level = self::MAX_LIGHT_LEVEL; - protected function describeType(RuntimeDataDescriber $w) : void{ + public function describeType(RuntimeDataDescriber $w) : void{ $w->boundedInt(4, self::MIN_LIGHT_LEVEL, self::MAX_LIGHT_LEVEL, $this->level); } diff --git a/src/block/Liquid.php b/src/block/Liquid.php index 476a8f8c7..7126e4466 100644 --- a/src/block/Liquid.php +++ b/src/block/Liquid.php @@ -48,7 +48,7 @@ abstract class Liquid extends Transparent{ protected int $decay = 0; //PC "level" property protected bool $still = false; - protected function describeState(RuntimeDataDescriber $w) : void{ + public function describeState(RuntimeDataDescriber $w) : void{ $w->boundedInt(3, 0, self::MAX_DECAY, $this->decay); $w->bool($this->falling); $w->bool($this->still); diff --git a/src/block/NetherPortal.php b/src/block/NetherPortal.php index 0c507a166..dcad2a199 100644 --- a/src/block/NetherPortal.php +++ b/src/block/NetherPortal.php @@ -34,7 +34,7 @@ class NetherPortal extends Transparent{ protected int $axis = Axis::X; - protected function describeState(RuntimeDataDescriber $w) : void{ + public function describeState(RuntimeDataDescriber $w) : void{ $w->horizontalAxis($this->axis); } diff --git a/src/block/NetherWartPlant.php b/src/block/NetherWartPlant.php index 787b1f5f8..afdf406cf 100644 --- a/src/block/NetherWartPlant.php +++ b/src/block/NetherWartPlant.php @@ -37,7 +37,7 @@ class NetherWartPlant extends Flowable{ protected int $age = 0; - protected function describeState(RuntimeDataDescriber $w) : void{ + public function describeState(RuntimeDataDescriber $w) : void{ $w->boundedInt(2, 0, self::MAX_AGE, $this->age); } diff --git a/src/block/Rail.php b/src/block/Rail.php index 12b47e6ea..2a0f4059d 100644 --- a/src/block/Rail.php +++ b/src/block/Rail.php @@ -34,7 +34,7 @@ class Rail extends BaseRail{ private int $railShape = BlockLegacyMetadata::RAIL_STRAIGHT_NORTH_SOUTH; - protected function describeState(RuntimeDataDescriber $w) : void{ + public function describeState(RuntimeDataDescriber $w) : void{ $w->railShape($this->railShape); } diff --git a/src/block/RedMushroomBlock.php b/src/block/RedMushroomBlock.php index 17fced412..ab5d89fe9 100644 --- a/src/block/RedMushroomBlock.php +++ b/src/block/RedMushroomBlock.php @@ -36,7 +36,7 @@ class RedMushroomBlock extends Opaque{ parent::__construct($idInfo, $name, $typeInfo); } - protected function describeState(RuntimeDataDescriber $w) : void{ + public function describeState(RuntimeDataDescriber $w) : void{ $w->mushroomBlockType($this->mushroomBlockType); } diff --git a/src/block/RedstoneComparator.php b/src/block/RedstoneComparator.php index 0f8fee840..c7a2917e4 100644 --- a/src/block/RedstoneComparator.php +++ b/src/block/RedstoneComparator.php @@ -44,7 +44,7 @@ class RedstoneComparator extends Flowable{ protected bool $isSubtractMode = false; - protected function describeState(RuntimeDataDescriber $w) : void{ + public function describeState(RuntimeDataDescriber $w) : void{ $w->horizontalFacing($this->facing); $w->bool($this->isSubtractMode); $w->bool($this->powered); diff --git a/src/block/RedstoneLamp.php b/src/block/RedstoneLamp.php index 1d0ff7345..2a4d517d6 100644 --- a/src/block/RedstoneLamp.php +++ b/src/block/RedstoneLamp.php @@ -29,7 +29,7 @@ use pocketmine\data\runtime\RuntimeDataDescriber; class RedstoneLamp extends Opaque{ use PoweredByRedstoneTrait; - protected function describeState(RuntimeDataDescriber $w) : void{ + public function describeState(RuntimeDataDescriber $w) : void{ $w->bool($this->powered); } diff --git a/src/block/RedstoneOre.php b/src/block/RedstoneOre.php index 13cf84205..d0d026837 100644 --- a/src/block/RedstoneOre.php +++ b/src/block/RedstoneOre.php @@ -33,7 +33,7 @@ use function mt_rand; class RedstoneOre extends Opaque{ protected bool $lit = false; - protected function describeState(RuntimeDataDescriber $w) : void{ + public function describeState(RuntimeDataDescriber $w) : void{ $w->bool($this->lit); } diff --git a/src/block/RedstoneRepeater.php b/src/block/RedstoneRepeater.php index d1ad17eeb..6b9362659 100644 --- a/src/block/RedstoneRepeater.php +++ b/src/block/RedstoneRepeater.php @@ -43,7 +43,7 @@ class RedstoneRepeater extends Flowable{ protected int $delay = self::MIN_DELAY; - protected function describeState(RuntimeDataDescriber $w) : void{ + public function describeState(RuntimeDataDescriber $w) : void{ $w->horizontalFacing($this->facing); $w->boundedInt(2, self::MIN_DELAY, self::MAX_DELAY, $this->delay); $w->bool($this->powered); diff --git a/src/block/RedstoneTorch.php b/src/block/RedstoneTorch.php index f85c6c07a..fa1331eeb 100644 --- a/src/block/RedstoneTorch.php +++ b/src/block/RedstoneTorch.php @@ -28,7 +28,7 @@ use pocketmine\data\runtime\RuntimeDataDescriber; class RedstoneTorch extends Torch{ protected bool $lit = true; - protected function describeState(RuntimeDataDescriber $w) : void{ + public function describeState(RuntimeDataDescriber $w) : void{ parent::describeState($w); $w->bool($this->lit); } diff --git a/src/block/RuntimeBlockStateRegistry.php b/src/block/RuntimeBlockStateRegistry.php index ae6386e33..a62e90736 100644 --- a/src/block/RuntimeBlockStateRegistry.php +++ b/src/block/RuntimeBlockStateRegistry.php @@ -151,18 +151,6 @@ class RuntimeBlockStateRegistry{ } } - /** - * @internal - * Returns the default state of the block type associated with the given type ID. - */ - public function fromTypeId(int $typeId) : Block{ - if(isset($this->typeIndex[$typeId])){ - return clone $this->typeIndex[$typeId]; - } - - throw new \InvalidArgumentException("Block ID $typeId is not registered"); - } - public function fromStateId(int $stateId) : Block{ if($stateId < 0){ throw new \InvalidArgumentException("Block state ID cannot be negative"); @@ -178,22 +166,6 @@ class RuntimeBlockStateRegistry{ return $block; } - /** - * Returns whether a specified block state is already registered in the block factory. - */ - public function isRegistered(int $typeId) : bool{ - $b = $this->typeIndex[$typeId] ?? null; - return $b !== null && !($b instanceof UnknownBlock); - } - - /** - * @return Block[] - * @phpstan-return array - */ - public function getAllKnownTypes() : array{ - return $this->typeIndex; - } - /** * @return Block[] */ diff --git a/src/block/Sapling.php b/src/block/Sapling.php index 838a32ce8..9a973c927 100644 --- a/src/block/Sapling.php +++ b/src/block/Sapling.php @@ -46,7 +46,7 @@ class Sapling extends Flowable{ $this->treeType = $treeType; } - protected function describeState(RuntimeDataDescriber $w) : void{ + public function describeState(RuntimeDataDescriber $w) : void{ $w->bool($this->ready); } diff --git a/src/block/SeaPickle.php b/src/block/SeaPickle.php index c2955cbaa..d643f841c 100644 --- a/src/block/SeaPickle.php +++ b/src/block/SeaPickle.php @@ -38,7 +38,7 @@ class SeaPickle extends Transparent{ protected int $count = self::MIN_COUNT; protected bool $underwater = false; - protected function describeState(RuntimeDataDescriber $w) : void{ + public function describeState(RuntimeDataDescriber $w) : void{ $w->boundedInt(2, self::MIN_COUNT, self::MAX_COUNT, $this->count); $w->bool($this->underwater); } diff --git a/src/block/ShulkerBox.php b/src/block/ShulkerBox.php index e979b09e5..88ba6e7b8 100644 --- a/src/block/ShulkerBox.php +++ b/src/block/ShulkerBox.php @@ -34,7 +34,7 @@ use pocketmine\world\BlockTransaction; class ShulkerBox extends Opaque{ use AnyFacingTrait; - protected function describeState(RuntimeDataDescriber $w) : void{ + public function describeState(RuntimeDataDescriber $w) : void{ //NOOP - we don't read or write facing here, because the tile persists it } diff --git a/src/block/SimplePressurePlate.php b/src/block/SimplePressurePlate.php index f4ad37ea4..050654e76 100644 --- a/src/block/SimplePressurePlate.php +++ b/src/block/SimplePressurePlate.php @@ -28,7 +28,7 @@ use pocketmine\data\runtime\RuntimeDataDescriber; abstract class SimplePressurePlate extends PressurePlate{ protected bool $pressed = false; - protected function describeState(RuntimeDataDescriber $w) : void{ + public function describeState(RuntimeDataDescriber $w) : void{ $w->bool($this->pressed); } diff --git a/src/block/Skull.php b/src/block/Skull.php index 10403ab6b..74daa831f 100644 --- a/src/block/Skull.php +++ b/src/block/Skull.php @@ -49,11 +49,11 @@ class Skull extends Flowable{ parent::__construct($idInfo, $name, $typeInfo); } - protected function describeType(RuntimeDataDescriber $w) : void{ + public function describeType(RuntimeDataDescriber $w) : void{ $w->skullType($this->skullType); } - protected function describeState(RuntimeDataDescriber $w) : void{ + public function describeState(RuntimeDataDescriber $w) : void{ $w->facingExcept($this->facing, Facing::DOWN); } diff --git a/src/block/Slab.php b/src/block/Slab.php index 4e25d15a4..95a07e1b0 100644 --- a/src/block/Slab.php +++ b/src/block/Slab.php @@ -41,7 +41,7 @@ class Slab extends Transparent{ $this->slabType = SlabType::BOTTOM(); } - protected function describeState(RuntimeDataDescriber $w) : void{ + public function describeState(RuntimeDataDescriber $w) : void{ $w->slabType($this->slabType); } diff --git a/src/block/SnowLayer.php b/src/block/SnowLayer.php index ec08620c0..a2528e02c 100644 --- a/src/block/SnowLayer.php +++ b/src/block/SnowLayer.php @@ -46,7 +46,7 @@ class SnowLayer extends Flowable implements Fallable{ protected int $layers = self::MIN_LAYERS; - protected function describeState(RuntimeDataDescriber $w) : void{ + public function describeState(RuntimeDataDescriber $w) : void{ $w->boundedInt(3, self::MIN_LAYERS, self::MAX_LAYERS, $this->layers); } diff --git a/src/block/Sponge.php b/src/block/Sponge.php index b4e523ffa..5b283d18b 100644 --- a/src/block/Sponge.php +++ b/src/block/Sponge.php @@ -28,7 +28,7 @@ use pocketmine\data\runtime\RuntimeDataDescriber; class Sponge extends Opaque{ protected bool $wet = false; - protected function describeType(RuntimeDataDescriber $w) : void{ + public function describeType(RuntimeDataDescriber $w) : void{ $w->bool($this->wet); } diff --git a/src/block/Stair.php b/src/block/Stair.php index 971dbc43a..8e299c035 100644 --- a/src/block/Stair.php +++ b/src/block/Stair.php @@ -46,7 +46,7 @@ class Stair extends Transparent{ parent::__construct($idInfo, $name, $typeInfo); } - protected function describeState(RuntimeDataDescriber $w) : void{ + public function describeState(RuntimeDataDescriber $w) : void{ $w->horizontalFacing($this->facing); $w->bool($this->upsideDown); } diff --git a/src/block/StraightOnlyRail.php b/src/block/StraightOnlyRail.php index fe3d19b25..63e43a52e 100644 --- a/src/block/StraightOnlyRail.php +++ b/src/block/StraightOnlyRail.php @@ -36,7 +36,7 @@ class StraightOnlyRail extends BaseRail{ private int $railShape = BlockLegacyMetadata::RAIL_STRAIGHT_NORTH_SOUTH; - protected function describeState(RuntimeDataDescriber $w) : void{ + public function describeState(RuntimeDataDescriber $w) : void{ $w->straightOnlyRailShape($this->railShape); } diff --git a/src/block/Sugarcane.php b/src/block/Sugarcane.php index cc41c0fb0..716c205b1 100644 --- a/src/block/Sugarcane.php +++ b/src/block/Sugarcane.php @@ -38,7 +38,7 @@ class Sugarcane extends Flowable{ protected int $age = 0; - protected function describeState(RuntimeDataDescriber $w) : void{ + public function describeState(RuntimeDataDescriber $w) : void{ $w->boundedInt(4, 0, self::MAX_AGE, $this->age); } diff --git a/src/block/SweetBerryBush.php b/src/block/SweetBerryBush.php index c9e9232e7..0ba065ce6 100644 --- a/src/block/SweetBerryBush.php +++ b/src/block/SweetBerryBush.php @@ -45,7 +45,7 @@ class SweetBerryBush extends Flowable{ protected int $age = self::STAGE_SAPLING; - protected function describeState(RuntimeDataDescriber $w) : void{ + public function describeState(RuntimeDataDescriber $w) : void{ $w->boundedInt(3, self::STAGE_SAPLING, self::STAGE_MATURE, $this->age); } diff --git a/src/block/TNT.php b/src/block/TNT.php index 7012f7145..d35473e11 100644 --- a/src/block/TNT.php +++ b/src/block/TNT.php @@ -45,11 +45,11 @@ class TNT extends Opaque{ protected bool $unstable = false; //TODO: Usage unclear, seems to be a weird hack in vanilla protected bool $worksUnderwater = false; - protected function describeType(RuntimeDataDescriber $w) : void{ + public function describeType(RuntimeDataDescriber $w) : void{ $w->bool($this->worksUnderwater); } - protected function describeState(RuntimeDataDescriber $w) : void{ + public function describeState(RuntimeDataDescriber $w) : void{ $w->bool($this->unstable); } diff --git a/src/block/Torch.php b/src/block/Torch.php index b7bc5136f..1b659891f 100644 --- a/src/block/Torch.php +++ b/src/block/Torch.php @@ -36,7 +36,7 @@ class Torch extends Flowable{ protected int $facing = Facing::UP; - protected function describeState(RuntimeDataDescriber $w) : void{ + public function describeState(RuntimeDataDescriber $w) : void{ $w->facingExcept($this->facing, Facing::DOWN); } diff --git a/src/block/Trapdoor.php b/src/block/Trapdoor.php index 79e3f0e8f..898722f5b 100644 --- a/src/block/Trapdoor.php +++ b/src/block/Trapdoor.php @@ -40,7 +40,7 @@ class Trapdoor extends Transparent{ protected bool $open = false; protected bool $top = false; - protected function describeState(RuntimeDataDescriber $w) : void{ + public function describeState(RuntimeDataDescriber $w) : void{ $w->horizontalFacing($this->facing); $w->bool($this->top); $w->bool($this->open); diff --git a/src/block/Tripwire.php b/src/block/Tripwire.php index b8b3e732d..732b35676 100644 --- a/src/block/Tripwire.php +++ b/src/block/Tripwire.php @@ -33,7 +33,7 @@ class Tripwire extends Flowable{ protected bool $connected = false; protected bool $disarmed = false; - protected function describeState(RuntimeDataDescriber $w) : void{ + public function describeState(RuntimeDataDescriber $w) : void{ $w->bool($this->triggered); $w->bool($this->suspended); $w->bool($this->connected); diff --git a/src/block/TripwireHook.php b/src/block/TripwireHook.php index 2ad6057b8..c13504123 100644 --- a/src/block/TripwireHook.php +++ b/src/block/TripwireHook.php @@ -38,7 +38,7 @@ class TripwireHook extends Flowable{ protected bool $connected = false; protected bool $powered = false; - protected function describeState(RuntimeDataDescriber $w) : void{ + public function describeState(RuntimeDataDescriber $w) : void{ $w->horizontalFacing($this->facing); $w->bool($this->connected); $w->bool($this->powered); diff --git a/src/block/UnknownBlock.php b/src/block/UnknownBlock.php index 7c48b236f..4523fd7ec 100644 --- a/src/block/UnknownBlock.php +++ b/src/block/UnknownBlock.php @@ -38,7 +38,7 @@ class UnknownBlock extends Transparent{ $this->stateData = $stateData; } - protected function describeType(RuntimeDataDescriber $w) : void{ + public function describeType(RuntimeDataDescriber $w) : void{ //use type instead of state, so we don't lose any information like colour //this might be an improperly registered plugin block $w->int(Block::INTERNAL_STATE_DATA_BITS, $this->stateData); diff --git a/src/block/Vine.php b/src/block/Vine.php index 53d4b1efe..a0309d840 100644 --- a/src/block/Vine.php +++ b/src/block/Vine.php @@ -39,7 +39,7 @@ class Vine extends Flowable{ /** @var int[] */ protected array $faces = []; - protected function describeState(RuntimeDataDescriber $w) : void{ + public function describeState(RuntimeDataDescriber $w) : void{ $w->horizontalFacingFlags($this->faces); } diff --git a/src/block/Wall.php b/src/block/Wall.php index 8b128c525..0bad315e9 100644 --- a/src/block/Wall.php +++ b/src/block/Wall.php @@ -42,7 +42,7 @@ class Wall extends Transparent{ protected array $connections = []; protected bool $post = false; - protected function describeState(RuntimeDataDescriber $w) : void{ + public function describeState(RuntimeDataDescriber $w) : void{ $w->wallConnections($this->connections); $w->bool($this->post); } diff --git a/src/block/WallCoralFan.php b/src/block/WallCoralFan.php index c7e350c47..5928f7842 100644 --- a/src/block/WallCoralFan.php +++ b/src/block/WallCoralFan.php @@ -36,7 +36,7 @@ use pocketmine\world\BlockTransaction; final class WallCoralFan extends BaseCoral{ use HorizontalFacingTrait; - protected function describeState(RuntimeDataDescriber $w) : void{ + public function describeState(RuntimeDataDescriber $w) : void{ $w->horizontalFacing($this->facing); } diff --git a/src/block/Wood.php b/src/block/Wood.php index 9a0c36e1d..3fbae40da 100644 --- a/src/block/Wood.php +++ b/src/block/Wood.php @@ -38,7 +38,7 @@ class Wood extends Opaque{ private bool $stripped = false; - protected function describeType(RuntimeDataDescriber $w) : void{ + public function describeType(RuntimeDataDescriber $w) : void{ $w->bool($this->stripped); } diff --git a/src/block/utils/AnalogRedstoneSignalEmitterTrait.php b/src/block/utils/AnalogRedstoneSignalEmitterTrait.php index 783517dcd..e3c4c9442 100644 --- a/src/block/utils/AnalogRedstoneSignalEmitterTrait.php +++ b/src/block/utils/AnalogRedstoneSignalEmitterTrait.php @@ -28,7 +28,7 @@ use pocketmine\data\runtime\RuntimeDataDescriber; trait AnalogRedstoneSignalEmitterTrait{ protected int $signalStrength = 0; - protected function describeState(RuntimeDataDescriber $w) : void{ + public function describeState(RuntimeDataDescriber $w) : void{ $w->boundedInt(4, 0, 15, $this->signalStrength); } diff --git a/src/block/utils/AnyFacingTrait.php b/src/block/utils/AnyFacingTrait.php index 78fdd9bf9..25618d9dc 100644 --- a/src/block/utils/AnyFacingTrait.php +++ b/src/block/utils/AnyFacingTrait.php @@ -29,7 +29,7 @@ use pocketmine\math\Facing; trait AnyFacingTrait{ protected int $facing = Facing::DOWN; - protected function describeState(RuntimeDataDescriber $w) : void{ + public function describeState(RuntimeDataDescriber $w) : void{ $w->facing($this->facing); } diff --git a/src/block/utils/CandleTrait.php b/src/block/utils/CandleTrait.php index 60dd61849..867cf15da 100644 --- a/src/block/utils/CandleTrait.php +++ b/src/block/utils/CandleTrait.php @@ -39,7 +39,7 @@ use pocketmine\world\sound\FlintSteelSound; trait CandleTrait{ private bool $lit = false; - protected function describeState(RuntimeDataDescriber $w) : void{ + public function describeState(RuntimeDataDescriber $w) : void{ $w->bool($this->lit); } diff --git a/src/block/utils/ColoredTrait.php b/src/block/utils/ColoredTrait.php index 42abe64b9..b9a14bee1 100644 --- a/src/block/utils/ColoredTrait.php +++ b/src/block/utils/ColoredTrait.php @@ -31,7 +31,7 @@ trait ColoredTrait{ private $color; /** @see Block::describeType() */ - protected function describeType(RuntimeDataDescriber $w) : void{ + public function describeType(RuntimeDataDescriber $w) : void{ $w->dyeColor($this->color); } diff --git a/src/block/utils/CopperTrait.php b/src/block/utils/CopperTrait.php index ed230c6ba..11c0178f9 100644 --- a/src/block/utils/CopperTrait.php +++ b/src/block/utils/CopperTrait.php @@ -44,7 +44,7 @@ trait CopperTrait{ parent::__construct($identifier, $name, $typeInfo); } - protected function describeType(RuntimeDataDescriber $w) : void{ + public function describeType(RuntimeDataDescriber $w) : void{ $w->copperOxidation($this->oxidation); $w->bool($this->waxed); } diff --git a/src/block/utils/CoralTypeTrait.php b/src/block/utils/CoralTypeTrait.php index d2c96c8f4..4607831c8 100644 --- a/src/block/utils/CoralTypeTrait.php +++ b/src/block/utils/CoralTypeTrait.php @@ -31,7 +31,7 @@ trait CoralTypeTrait{ protected bool $dead = false; /** @see Block::describeType() */ - protected function describeType(RuntimeDataDescriber $w) : void{ + public function describeType(RuntimeDataDescriber $w) : void{ $w->coralType($this->coralType); $w->bool($this->dead); } diff --git a/src/block/utils/HorizontalFacingTrait.php b/src/block/utils/HorizontalFacingTrait.php index b1558b154..624250e11 100644 --- a/src/block/utils/HorizontalFacingTrait.php +++ b/src/block/utils/HorizontalFacingTrait.php @@ -30,7 +30,7 @@ use pocketmine\math\Facing; trait HorizontalFacingTrait{ protected int $facing = Facing::NORTH; - protected function describeState(RuntimeDataDescriber $w) : void{ + public function describeState(RuntimeDataDescriber $w) : void{ $w->horizontalFacing($this->facing); } diff --git a/src/block/utils/PillarRotationTrait.php b/src/block/utils/PillarRotationTrait.php index 0fc206a20..fccd53676 100644 --- a/src/block/utils/PillarRotationTrait.php +++ b/src/block/utils/PillarRotationTrait.php @@ -35,7 +35,7 @@ use pocketmine\world\BlockTransaction; trait PillarRotationTrait{ protected int $axis = Axis::Y; - protected function describeState(RuntimeDataDescriber $w) : void{ + public function describeState(RuntimeDataDescriber $w) : void{ $w->axis($this->axis); } diff --git a/src/block/utils/RailPoweredByRedstoneTrait.php b/src/block/utils/RailPoweredByRedstoneTrait.php index a95fea253..d4e9af665 100644 --- a/src/block/utils/RailPoweredByRedstoneTrait.php +++ b/src/block/utils/RailPoweredByRedstoneTrait.php @@ -28,7 +28,7 @@ use pocketmine\data\runtime\RuntimeDataDescriber; trait RailPoweredByRedstoneTrait{ use PoweredByRedstoneTrait; - protected function describeState(RuntimeDataDescriber $w) : void{ + public function describeState(RuntimeDataDescriber $w) : void{ parent::describeState($w); $w->bool($this->powered); } diff --git a/src/block/utils/SignLikeRotationTrait.php b/src/block/utils/SignLikeRotationTrait.php index 2fed25910..38ab84cb7 100644 --- a/src/block/utils/SignLikeRotationTrait.php +++ b/src/block/utils/SignLikeRotationTrait.php @@ -30,7 +30,7 @@ trait SignLikeRotationTrait{ /** @var int */ private $rotation = 0; - protected function describeState(RuntimeDataDescriber $w) : void{ + public function describeState(RuntimeDataDescriber $w) : void{ $w->boundedInt(4, 0, 15, $this->rotation); } diff --git a/src/item/ItemBlock.php b/src/item/ItemBlock.php index a7e14b5ce..16c4badf3 100644 --- a/src/item/ItemBlock.php +++ b/src/item/ItemBlock.php @@ -24,8 +24,6 @@ declare(strict_types=1); namespace pocketmine\item; use pocketmine\block\Block; -use pocketmine\block\RuntimeBlockStateRegistry; -use pocketmine\block\VanillaBlocks; use pocketmine\data\runtime\RuntimeDataDescriber; /** @@ -35,47 +33,29 @@ use pocketmine\data\runtime\RuntimeDataDescriber; * just place wheat crops when used on the ground). */ final class ItemBlock extends Item{ - private int $blockTypeId; - private int $blockTypeData; - - private int $fuelTime; - private bool $fireProof; - private int $maxStackSize; - - public function __construct(Block $block){ + public function __construct( + private Block $block + ){ parent::__construct(ItemIdentifier::fromBlock($block), $block->getName()); - $this->blockTypeId = $block->getTypeId(); - $this->blockTypeData = $block->computeTypeData(); - - $this->fuelTime = $block->getFuelTime(); - $this->fireProof = $block->isFireProofAsItem(); - $this->maxStackSize = $block->getMaxStackSize(); } protected function describeType(RuntimeDataDescriber $w) : void{ - $w->int(Block::INTERNAL_STATE_DATA_BITS, $this->blockTypeData); + $this->block->describeType($w); } public function getBlock(?int $clickedFace = null) : Block{ - //TODO: HACKY MESS, CLEAN IT UP - $factory = RuntimeBlockStateRegistry::getInstance(); - if(!$factory->isRegistered($this->blockTypeId)){ - return VanillaBlocks::AIR(); - } - $blockType = $factory->fromTypeId($this->blockTypeId); - $blockType->decodeTypeData($this->blockTypeData); - return $blockType; + return clone $this->block; } public function getFuelTime() : int{ - return $this->fuelTime; + return $this->block->getFuelTime(); } public function isFireProof() : bool{ - return $this->fireProof; + return $this->block->isFireProofAsItem(); } public function getMaxStackSize() : int{ - return $this->maxStackSize; + return $this->block->getMaxStackSize(); } } diff --git a/tests/phpunit/block/BlockTest.php b/tests/phpunit/block/BlockTest.php index 3f6dbac95..cfcdf47b2 100644 --- a/tests/phpunit/block/BlockTest.php +++ b/tests/phpunit/block/BlockTest.php @@ -62,16 +62,9 @@ class BlockTest extends TestCase{ * Test registering a new block which does not yet exist */ public function testRegisterNewBlock() : void{ - for($i = BlockTypeIds::FIRST_UNUSED_BLOCK_ID; $i < BlockTypeIds::FIRST_UNUSED_BLOCK_ID + 256; ++$i){ - if(!$this->blockFactory->isRegistered($i)){ - $b = new StrangeNewBlock(new BlockIdentifier($i), "Strange New Block", new BlockTypeInfo(BlockBreakInfo::instant())); - $this->blockFactory->register($b); - self::assertInstanceOf(StrangeNewBlock::class, $this->blockFactory->fromStateId($b->getStateId())); - return; - } - } - - throw new \RuntimeException("Can't test registering new blocks because no unused spaces left"); + $b = new StrangeNewBlock(new BlockIdentifier(BlockTypeIds::newId()), "Strange New Block", new BlockTypeInfo(BlockBreakInfo::instant())); + $this->blockFactory->register($b); + self::assertInstanceOf(StrangeNewBlock::class, $this->blockFactory->fromStateId($b->getStateId())); } /**