Added interface RuntimeDataDescriber

This commit is contained in:
Dylan K. Taylor 2023-02-16 16:23:32 +00:00
parent ceff230d73
commit c2f6d8139a
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
95 changed files with 395 additions and 331 deletions

View File

@ -64,8 +64,8 @@ function buildWriterFunc(string $virtualTypeName, string $nativeTypeName, array
$bits = getBitsRequired($memberNames); $bits = getBitsRequired($memberNames);
$lines = []; $lines = [];
$lines[] = "public function $functionName(\\$nativeTypeName \$value) : void{"; $lines[] = "public function $functionName(\\$nativeTypeName &\$value) : void{";
$lines[] = "\t\$this->int($bits, match(\$value){"; $lines[] = "\t\$this->writeInt($bits, match(\$value){";
foreach($memberNames as $key => $memberName){ foreach($memberNames as $key => $memberName){
$lines[] = "\t\t$memberName => $key,"; $lines[] = "\t\t$memberName => $key,";
@ -101,6 +101,10 @@ function buildReaderFunc(string $virtualTypeName, string $nativeTypeName, array
return $lines; return $lines;
} }
function buildInterfaceFunc(string $nativeTypeName, string $functionName) : string{
return "public function $functionName(\\$nativeTypeName &\$value) : void;";
}
/** /**
* @param mixed[] $members * @param mixed[] $members
*/ */
@ -143,9 +147,10 @@ $readerFuncs = [
]; ];
$writerFuncs = [ $writerFuncs = [
"" => [ "" => [
"abstract public function int(int \$bits, int \$value) : void;" "abstract protected function writeInt(int \$bits, int \$value) : void;"
] ]
]; ];
$interfaceFuncs = [];
foreach($enumsUsed as $enumMembers){ foreach($enumsUsed as $enumMembers){
if(count($enumMembers) === 0){ if(count($enumMembers) === 0){
@ -169,13 +174,17 @@ foreach($enumsUsed as $enumMembers){
$stringifiedMembers, $stringifiedMembers,
$functionName $functionName
); );
$interfaceFuncs[$functionName] = [buildInterfaceFunc(
$nativeTypeName,
$functionName
)];
} }
/** /**
* @param string[][] $functions * @param string[][] $functions
* @phpstan-param array<string, list<string>> $functions * @phpstan-param array<string, list<string>> $functions
*/ */
function printFunctions(array $functions, string $className) : void{ function printFunctions(array $functions, string $className, string $classType) : void{
ksort($functions, SORT_STRING); ksort($functions, SORT_STRING);
ob_start(); ob_start();
@ -213,14 +222,15 @@ namespace pocketmine\data\runtime;
HEADER; HEADER;
echo "trait $className{\n\n"; echo "$classType $className{\n\n";
echo implode("\n\n", array_map(fn(array $functionLines) => "\t" . implode("\n\t", $functionLines), $functions)); echo implode("\n\n", array_map(fn(array $functionLines) => "\t" . implode("\n\t", $functionLines), $functions));
echo "\n\n}\n"; echo "\n\n}\n";
file_put_contents(dirname(__DIR__) . '/src/data/runtime/' . $className . '.php', ob_get_clean()); file_put_contents(dirname(__DIR__) . '/src/data/runtime/' . $className . '.php', ob_get_clean());
} }
printFunctions($writerFuncs, "RuntimeEnumSerializerTrait"); printFunctions($writerFuncs, "RuntimeEnumSerializerTrait", "trait");
printFunctions($readerFuncs, "RuntimeEnumDeserializerTrait"); printFunctions($readerFuncs, "RuntimeEnumDeserializerTrait", "trait");
printFunctions($interfaceFuncs, "RuntimeEnumDescriber", "interface");
echo "Done. Don't forget to run CS fixup after generating code.\n"; echo "Done. Don't forget to run CS fixup after generating code.\n";

View File

@ -28,8 +28,7 @@ use pocketmine\block\utils\Fallable;
use pocketmine\block\utils\FallableTrait; use pocketmine\block\utils\FallableTrait;
use pocketmine\block\utils\HorizontalFacingTrait; use pocketmine\block\utils\HorizontalFacingTrait;
use pocketmine\block\utils\SupportType; use pocketmine\block\utils\SupportType;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\entity\object\FallingBlock; use pocketmine\entity\object\FallingBlock;
use pocketmine\item\Item; use pocketmine\item\Item;
use pocketmine\math\AxisAlignedBB; use pocketmine\math\AxisAlignedBB;
@ -54,13 +53,13 @@ class Anvil extends Transparent implements Fallable{
public function getRequiredTypeDataBits() : int{ return 2; } public function getRequiredTypeDataBits() : int{ return 2; }
protected function describeType(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeType(RuntimeDataDescriber $w) : void{
$w->boundedInt(2, self::UNDAMAGED, self::VERY_DAMAGED, $this->damage); $w->boundedInt(2, self::UNDAMAGED, self::VERY_DAMAGED, $this->damage);
} }
public function getRequiredStateDataBits() : int{ return 2; } public function getRequiredStateDataBits() : int{ return 2; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeState(RuntimeDataDescriber $w) : void{
$w->horizontalFacing($this->facing); $w->horizontalFacing($this->facing);
} }

View File

@ -24,8 +24,7 @@ declare(strict_types=1);
namespace pocketmine\block; namespace pocketmine\block;
use pocketmine\block\utils\SupportType; use pocketmine\block\utils\SupportType;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\event\block\StructureGrowEvent; use pocketmine\event\block\StructureGrowEvent;
use pocketmine\item\Bamboo as ItemBamboo; use pocketmine\item\Bamboo as ItemBamboo;
use pocketmine\item\Fertilizer; use pocketmine\item\Fertilizer;
@ -58,7 +57,7 @@ class Bamboo extends Transparent{
public function getRequiredStateDataBits() : int{ return 4; } public function getRequiredStateDataBits() : int{ return 4; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeState(RuntimeDataDescriber $w) : void{
$w->boundedInt(2, self::NO_LEAVES, self::LARGE_LEAVES, $this->leafSize); $w->boundedInt(2, self::NO_LEAVES, self::LARGE_LEAVES, $this->leafSize);
$w->bool($this->thick); $w->bool($this->thick);
$w->bool($this->ready); $w->bool($this->ready);

View File

@ -23,8 +23,7 @@ declare(strict_types=1);
namespace pocketmine\block; namespace pocketmine\block;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\event\block\StructureGrowEvent; use pocketmine\event\block\StructureGrowEvent;
use pocketmine\item\Bamboo as ItemBamboo; use pocketmine\item\Bamboo as ItemBamboo;
use pocketmine\item\Fertilizer; use pocketmine\item\Fertilizer;
@ -39,7 +38,7 @@ final class BambooSapling extends Flowable{
public function getRequiredStateDataBits() : int{ return 1; } public function getRequiredStateDataBits() : int{ return 1; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeState(RuntimeDataDescriber $w) : void{
$w->bool($this->ready); $w->bool($this->ready);
} }

View File

@ -25,8 +25,7 @@ namespace pocketmine\block;
use pocketmine\block\tile\Barrel as TileBarrel; use pocketmine\block\tile\Barrel as TileBarrel;
use pocketmine\block\utils\AnyFacingTrait; use pocketmine\block\utils\AnyFacingTrait;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\item\Item; use pocketmine\item\Item;
use pocketmine\math\Facing; use pocketmine\math\Facing;
use pocketmine\math\Vector3; use pocketmine\math\Vector3;
@ -41,7 +40,7 @@ class Barrel extends Opaque{
public function getRequiredStateDataBits() : int{ return 4; } public function getRequiredStateDataBits() : int{ return 4; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeState(RuntimeDataDescriber $w) : void{
$w->facing($this->facing); $w->facing($this->facing);
$w->bool($this->open); $w->bool($this->open);
} }

View File

@ -28,8 +28,7 @@ use pocketmine\block\utils\ColoredTrait;
use pocketmine\block\utils\DyeColor; use pocketmine\block\utils\DyeColor;
use pocketmine\block\utils\HorizontalFacingTrait; use pocketmine\block\utils\HorizontalFacingTrait;
use pocketmine\block\utils\SupportType; use pocketmine\block\utils\SupportType;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\entity\Entity; use pocketmine\entity\Entity;
use pocketmine\entity\Living; use pocketmine\entity\Living;
use pocketmine\item\Item; use pocketmine\item\Item;
@ -56,7 +55,7 @@ class Bed extends Transparent{
public function getRequiredStateDataBits() : int{ return 4; } public function getRequiredStateDataBits() : int{ return 4; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeState(RuntimeDataDescriber $w) : void{
$w->horizontalFacing($this->facing); $w->horizontalFacing($this->facing);
$w->bool($this->occupied); $w->bool($this->occupied);
$w->bool($this->head); $w->bool($this->head);

View File

@ -23,15 +23,14 @@ declare(strict_types=1);
namespace pocketmine\block; namespace pocketmine\block;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
class Bedrock extends Opaque{ class Bedrock extends Opaque{
private bool $burnsForever = false; private bool $burnsForever = false;
public function getRequiredStateDataBits() : int{ return 1; } public function getRequiredStateDataBits() : int{ return 1; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeState(RuntimeDataDescriber $w) : void{
$w->bool($this->burnsForever); $w->bool($this->burnsForever);
} }

View File

@ -27,8 +27,7 @@ use pocketmine\block\tile\Bell as TileBell;
use pocketmine\block\utils\BellAttachmentType; use pocketmine\block\utils\BellAttachmentType;
use pocketmine\block\utils\HorizontalFacingTrait; use pocketmine\block\utils\HorizontalFacingTrait;
use pocketmine\block\utils\SupportType; use pocketmine\block\utils\SupportType;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\entity\projectile\Projectile; use pocketmine\entity\projectile\Projectile;
use pocketmine\item\Item; use pocketmine\item\Item;
use pocketmine\math\AxisAlignedBB; use pocketmine\math\AxisAlignedBB;
@ -51,7 +50,7 @@ final class Bell extends Transparent{
public function getRequiredStateDataBits() : int{ return 4; } public function getRequiredStateDataBits() : int{ return 4; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeState(RuntimeDataDescriber $w) : void{
$w->bellAttachmentType($this->attachmentType); $w->bellAttachmentType($this->attachmentType);
$w->horizontalFacing($this->facing); $w->horizontalFacing($this->facing);
} }

View File

@ -29,6 +29,7 @@ namespace pocketmine\block;
use pocketmine\block\tile\Spawnable; use pocketmine\block\tile\Spawnable;
use pocketmine\block\tile\Tile; use pocketmine\block\tile\Tile;
use pocketmine\block\utils\SupportType; use pocketmine\block\utils\SupportType;
use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataReader;
use pocketmine\data\runtime\RuntimeDataWriter; use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\entity\Entity; use pocketmine\entity\Entity;
@ -174,7 +175,7 @@ class Block{
$stateBits = $this->getRequiredStateDataBits(); $stateBits = $this->getRequiredStateDataBits();
$requiredBits = $typeBits + $stateBits; $requiredBits = $typeBits + $stateBits;
$writer = new RuntimeDataWriter($requiredBits); $writer = new RuntimeDataWriter($requiredBits);
$writer->int($typeBits, $this->computeTypeData()); $writer->writeInt($typeBits, $this->computeTypeData());
$this->describeState($writer); $this->describeState($writer);
$writtenBits = $writer->getOffset() - $typeBits; $writtenBits = $writer->getOffset() - $typeBits;
@ -185,11 +186,11 @@ class Block{
return $writer->getValue(); return $writer->getValue();
} }
protected function describeType(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeType(RuntimeDataDescriber $w) : void{
//NOOP //NOOP
} }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeState(RuntimeDataDescriber $w) : void{
//NOOP //NOOP
} }

View File

@ -26,8 +26,7 @@ namespace pocketmine\block;
use pocketmine\block\tile\BrewingStand as TileBrewingStand; use pocketmine\block\tile\BrewingStand as TileBrewingStand;
use pocketmine\block\utils\BrewingStandSlot; use pocketmine\block\utils\BrewingStandSlot;
use pocketmine\block\utils\SupportType; use pocketmine\block\utils\SupportType;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\item\Item; use pocketmine\item\Item;
use pocketmine\math\Axis; use pocketmine\math\Axis;
use pocketmine\math\AxisAlignedBB; use pocketmine\math\AxisAlignedBB;
@ -46,7 +45,7 @@ class BrewingStand extends Transparent{
public function getRequiredStateDataBits() : int{ return 3; } public function getRequiredStateDataBits() : int{ return 3; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeState(RuntimeDataDescriber $w) : void{
$w->brewingStandSlots($this->slots); $w->brewingStandSlots($this->slots);
} }

View File

@ -24,8 +24,7 @@ declare(strict_types=1);
namespace pocketmine\block; namespace pocketmine\block;
use pocketmine\block\utils\AnyFacingTrait; use pocketmine\block\utils\AnyFacingTrait;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\item\Item; use pocketmine\item\Item;
use pocketmine\math\Facing; use pocketmine\math\Facing;
use pocketmine\math\Vector3; use pocketmine\math\Vector3;
@ -41,7 +40,7 @@ abstract class Button extends Flowable{
public function getRequiredStateDataBits() : int{ return 4; } public function getRequiredStateDataBits() : int{ return 4; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeState(RuntimeDataDescriber $w) : void{
$w->facing($this->facing); $w->facing($this->facing);
$w->bool($this->pressed); $w->bool($this->pressed);
} }

View File

@ -24,8 +24,7 @@ declare(strict_types=1);
namespace pocketmine\block; namespace pocketmine\block;
use pocketmine\block\utils\SupportType; use pocketmine\block\utils\SupportType;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\entity\Entity; use pocketmine\entity\Entity;
use pocketmine\event\block\BlockGrowEvent; use pocketmine\event\block\BlockGrowEvent;
use pocketmine\event\entity\EntityDamageByBlockEvent; use pocketmine\event\entity\EntityDamageByBlockEvent;
@ -44,7 +43,7 @@ class Cactus extends Transparent{
public function getRequiredStateDataBits() : int{ return 4; } public function getRequiredStateDataBits() : int{ return 4; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeState(RuntimeDataDescriber $w) : void{
$w->boundedInt(4, 0, self::MAX_AGE, $this->age); $w->boundedInt(4, 0, self::MAX_AGE, $this->age);
} }

View File

@ -23,8 +23,7 @@ declare(strict_types=1);
namespace pocketmine\block; namespace pocketmine\block;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\item\Item; use pocketmine\item\Item;
use pocketmine\item\ItemBlock; use pocketmine\item\ItemBlock;
use pocketmine\math\AxisAlignedBB; use pocketmine\math\AxisAlignedBB;
@ -39,7 +38,7 @@ class Cake extends BaseCake{
public function getRequiredStateDataBits() : int{ return 3; } public function getRequiredStateDataBits() : int{ return 3; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeState(RuntimeDataDescriber $w) : void{
$w->boundedInt(3, 0, self::MAX_BITES, $this->bites); $w->boundedInt(3, 0, self::MAX_BITES, $this->bites);
} }

View File

@ -25,8 +25,7 @@ namespace pocketmine\block;
use pocketmine\block\utils\CandleTrait; use pocketmine\block\utils\CandleTrait;
use pocketmine\block\utils\SupportType; use pocketmine\block\utils\SupportType;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\item\Item; use pocketmine\item\Item;
use pocketmine\math\Axis; use pocketmine\math\Axis;
use pocketmine\math\AxisAlignedBB; use pocketmine\math\AxisAlignedBB;
@ -51,7 +50,7 @@ class Candle extends Transparent{
return 3; return 3;
} }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeState(RuntimeDataDescriber $w) : void{
$this->encodeLitState($w); $this->encodeLitState($w);
$w->boundedInt(2, self::MIN_COUNT, self::MAX_COUNT, $this->count); $w->boundedInt(2, self::MIN_COUNT, self::MAX_COUNT, $this->count);
} }

View File

@ -23,8 +23,7 @@ declare(strict_types=1);
namespace pocketmine\block; namespace pocketmine\block;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\entity\projectile\Projectile; use pocketmine\entity\projectile\Projectile;
use pocketmine\event\block\StructureGrowEvent; use pocketmine\event\block\StructureGrowEvent;
use pocketmine\item\Item; use pocketmine\item\Item;
@ -52,7 +51,7 @@ final class ChorusFlower extends Flowable{
public function getRequiredStateDataBits() : int{ return 3; } public function getRequiredStateDataBits() : int{ return 3; }
protected function describeState(RuntimeDataWriter|RuntimeDataReader $w) : void{ protected function describeState(RuntimeDataDescriber $w) : void{
$w->boundedInt(3, self::MIN_AGE, self::MAX_AGE, $this->age); $w->boundedInt(3, self::MIN_AGE, self::MAX_AGE, $this->age);
} }

View File

@ -26,8 +26,7 @@ namespace pocketmine\block;
use pocketmine\block\utils\HorizontalFacingTrait; use pocketmine\block\utils\HorizontalFacingTrait;
use pocketmine\block\utils\SupportType; use pocketmine\block\utils\SupportType;
use pocketmine\block\utils\WoodType; use pocketmine\block\utils\WoodType;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\event\block\BlockGrowEvent; use pocketmine\event\block\BlockGrowEvent;
use pocketmine\item\Fertilizer; use pocketmine\item\Fertilizer;
use pocketmine\item\Item; use pocketmine\item\Item;
@ -49,7 +48,7 @@ class CocoaBlock extends Transparent{
public function getRequiredStateDataBits() : int{ return 4; } public function getRequiredStateDataBits() : int{ return 4; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeState(RuntimeDataDescriber $w) : void{
$w->horizontalFacing($this->facing); $w->horizontalFacing($this->facing);
$w->boundedInt(2, 0, self::MAX_AGE, $this->age); $w->boundedInt(2, 0, self::MAX_AGE, $this->age);
} }

View File

@ -23,8 +23,7 @@ declare(strict_types=1);
namespace pocketmine\block; namespace pocketmine\block;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\event\block\BlockGrowEvent; use pocketmine\event\block\BlockGrowEvent;
use pocketmine\item\Fertilizer; use pocketmine\item\Fertilizer;
use pocketmine\item\Item; use pocketmine\item\Item;
@ -41,7 +40,7 @@ abstract class Crops extends Flowable{
public function getRequiredStateDataBits() : int{ return 3; } public function getRequiredStateDataBits() : int{ return 3; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeState(RuntimeDataDescriber $w) : void{
$w->boundedInt(3, 0, self::MAX_AGE, $this->age); $w->boundedInt(3, 0, self::MAX_AGE, $this->age);
} }

View File

@ -25,8 +25,7 @@ namespace pocketmine\block;
use pocketmine\block\utils\AnalogRedstoneSignalEmitterTrait; use pocketmine\block\utils\AnalogRedstoneSignalEmitterTrait;
use pocketmine\block\utils\SupportType; use pocketmine\block\utils\SupportType;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\item\Item; use pocketmine\item\Item;
use pocketmine\math\AxisAlignedBB; use pocketmine\math\AxisAlignedBB;
use pocketmine\math\Facing; use pocketmine\math\Facing;
@ -44,7 +43,7 @@ class DaylightSensor extends Transparent{
public function getRequiredStateDataBits() : int{ return 5; } public function getRequiredStateDataBits() : int{ return 5; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeState(RuntimeDataDescriber $w) : void{
$w->boundedInt(4, 0, 15, $this->signalStrength); $w->boundedInt(4, 0, 15, $this->signalStrength);
$w->bool($this->inverted); $w->bool($this->inverted);
} }

View File

@ -23,15 +23,14 @@ declare(strict_types=1);
namespace pocketmine\block; namespace pocketmine\block;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
class DetectorRail extends StraightOnlyRail{ class DetectorRail extends StraightOnlyRail{
protected bool $activated = false; protected bool $activated = false;
public function getRequiredStateDataBits() : int{ return 4; } public function getRequiredStateDataBits() : int{ return 4; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeState(RuntimeDataDescriber $w) : void{
parent::describeState($w); parent::describeState($w);
$w->bool($this->activated); $w->bool($this->activated);
} }

View File

@ -24,8 +24,7 @@ declare(strict_types=1);
namespace pocketmine\block; namespace pocketmine\block;
use pocketmine\block\utils\DirtType; use pocketmine\block\utils\DirtType;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\item\Fertilizer; use pocketmine\item\Fertilizer;
use pocketmine\item\Hoe; use pocketmine\item\Hoe;
use pocketmine\item\Item; use pocketmine\item\Item;
@ -48,7 +47,7 @@ class Dirt extends Opaque{
public function getRequiredTypeDataBits() : int{ return 2; } public function getRequiredTypeDataBits() : int{ return 2; }
protected function describeType(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeType(RuntimeDataDescriber $w) : void{
$w->dirtType($this->dirtType); $w->dirtType($this->dirtType);
} }

View File

@ -25,8 +25,7 @@ namespace pocketmine\block;
use pocketmine\block\utils\HorizontalFacingTrait; use pocketmine\block\utils\HorizontalFacingTrait;
use pocketmine\block\utils\SupportType; use pocketmine\block\utils\SupportType;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\item\Item; use pocketmine\item\Item;
use pocketmine\math\AxisAlignedBB; use pocketmine\math\AxisAlignedBB;
use pocketmine\math\Facing; use pocketmine\math\Facing;
@ -44,7 +43,7 @@ class Door extends Transparent{
public function getRequiredStateDataBits() : int{ return 5; } public function getRequiredStateDataBits() : int{ return 5; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeState(RuntimeDataDescriber $w) : void{
$w->horizontalFacing($this->facing); $w->horizontalFacing($this->facing);
$w->bool($this->top); $w->bool($this->top);
$w->bool($this->hingeRight); $w->bool($this->hingeRight);

View File

@ -23,8 +23,7 @@ declare(strict_types=1);
namespace pocketmine\block; namespace pocketmine\block;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\item\Item; use pocketmine\item\Item;
use pocketmine\math\Facing; use pocketmine\math\Facing;
use pocketmine\math\Vector3; use pocketmine\math\Vector3;
@ -36,7 +35,7 @@ class DoublePlant extends Flowable{
public function getRequiredStateDataBits() : int{ return 1; } public function getRequiredStateDataBits() : int{ return 1; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeState(RuntimeDataDescriber $w) : void{
$w->bool($this->top); $w->bool($this->top);
} }

View File

@ -25,8 +25,7 @@ namespace pocketmine\block;
use pocketmine\block\utils\FacesOppositePlacingPlayerTrait; use pocketmine\block\utils\FacesOppositePlacingPlayerTrait;
use pocketmine\block\utils\HorizontalFacingTrait; use pocketmine\block\utils\HorizontalFacingTrait;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\math\AxisAlignedBB; use pocketmine\math\AxisAlignedBB;
use pocketmine\math\Facing; use pocketmine\math\Facing;
@ -38,7 +37,7 @@ class EndPortalFrame extends Opaque{
public function getRequiredStateDataBits() : int{ return 3; } public function getRequiredStateDataBits() : int{ return 3; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeState(RuntimeDataDescriber $w) : void{
$w->horizontalFacing($this->facing); $w->horizontalFacing($this->facing);
$w->bool($this->eye); $w->bool($this->eye);
} }

View File

@ -23,8 +23,7 @@ declare(strict_types=1);
namespace pocketmine\block; namespace pocketmine\block;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\entity\Entity; use pocketmine\entity\Entity;
use pocketmine\entity\Living; use pocketmine\entity\Living;
use pocketmine\event\entity\EntityTrampleFarmlandEvent; use pocketmine\event\entity\EntityTrampleFarmlandEvent;
@ -40,7 +39,7 @@ class Farmland extends Transparent{
public function getRequiredStateDataBits() : int{ return 3; } public function getRequiredStateDataBits() : int{ return 3; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeState(RuntimeDataDescriber $w) : void{
$w->boundedInt(3, 0, self::MAX_WETNESS, $this->wetness); $w->boundedInt(3, 0, self::MAX_WETNESS, $this->wetness);
} }

View File

@ -26,8 +26,7 @@ namespace pocketmine\block;
use pocketmine\block\utils\HorizontalFacingTrait; use pocketmine\block\utils\HorizontalFacingTrait;
use pocketmine\block\utils\SupportType; use pocketmine\block\utils\SupportType;
use pocketmine\block\utils\WoodTypeTrait; use pocketmine\block\utils\WoodTypeTrait;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\item\Item; use pocketmine\item\Item;
use pocketmine\math\AxisAlignedBB; use pocketmine\math\AxisAlignedBB;
use pocketmine\math\Facing; use pocketmine\math\Facing;
@ -45,7 +44,7 @@ class FenceGate extends Transparent{
public function getRequiredStateDataBits() : int{ return 4; } public function getRequiredStateDataBits() : int{ return 4; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeState(RuntimeDataDescriber $w) : void{
$w->horizontalFacing($this->facing); $w->horizontalFacing($this->facing);
$w->bool($this->open); $w->bool($this->open);
$w->bool($this->inWall); $w->bool($this->inWall);

View File

@ -24,8 +24,7 @@ declare(strict_types=1);
namespace pocketmine\block; namespace pocketmine\block;
use pocketmine\block\utils\SupportType; use pocketmine\block\utils\SupportType;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\item\Item; use pocketmine\item\Item;
use pocketmine\math\AxisAlignedBB; use pocketmine\math\AxisAlignedBB;
use pocketmine\math\Facing; use pocketmine\math\Facing;
@ -42,7 +41,7 @@ abstract class FillableCauldron extends Transparent{
return 3; return 3;
} }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeState(RuntimeDataDescriber $w) : void{
$w->boundedInt(3, self::MIN_FILL_LEVEL, self::MAX_FILL_LEVEL, $this->fillLevel); $w->boundedInt(3, self::MIN_FILL_LEVEL, self::MAX_FILL_LEVEL, $this->fillLevel);
} }

View File

@ -23,8 +23,7 @@ declare(strict_types=1);
namespace pocketmine\block; namespace pocketmine\block;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\event\block\BlockBurnEvent; use pocketmine\event\block\BlockBurnEvent;
use pocketmine\event\block\BlockSpreadEvent; use pocketmine\event\block\BlockSpreadEvent;
use pocketmine\math\Facing; use pocketmine\math\Facing;
@ -42,7 +41,7 @@ class Fire extends BaseFire{
public function getRequiredStateDataBits() : int{ return 4; } public function getRequiredStateDataBits() : int{ return 4; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeState(RuntimeDataDescriber $w) : void{
$w->boundedInt(4, 0, self::MAX_AGE, $this->age); $w->boundedInt(4, 0, self::MAX_AGE, $this->age);
} }

View File

@ -23,8 +23,7 @@ declare(strict_types=1);
namespace pocketmine\block; namespace pocketmine\block;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\item\Item; use pocketmine\item\Item;
use pocketmine\item\VanillaItems; use pocketmine\item\VanillaItems;
use pocketmine\math\Axis; use pocketmine\math\Axis;
@ -40,7 +39,7 @@ final class FloorCoralFan extends BaseCoral{
public function getRequiredStateDataBits() : int{ return parent::getRequiredStateDataBits() + 1; } public function getRequiredStateDataBits() : int{ return parent::getRequiredStateDataBits() + 1; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeState(RuntimeDataDescriber $w) : void{
$w->horizontalAxis($this->axis); $w->horizontalAxis($this->axis);
} }

View File

@ -24,8 +24,7 @@ declare(strict_types=1);
namespace pocketmine\block; namespace pocketmine\block;
use pocketmine\block\utils\FroglightType; use pocketmine\block\utils\FroglightType;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
final class Froglight extends SimplePillar{ final class Froglight extends SimplePillar{
@ -38,7 +37,7 @@ final class Froglight extends SimplePillar{
public function getRequiredTypeDataBits() : int{ return 2; } public function getRequiredTypeDataBits() : int{ return 2; }
protected function describeType(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeType(RuntimeDataDescriber $w) : void{
$w->froglightType($this->froglightType); $w->froglightType($this->froglightType);
} }

View File

@ -23,8 +23,7 @@ declare(strict_types=1);
namespace pocketmine\block; namespace pocketmine\block;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\event\block\BlockMeltEvent; use pocketmine\event\block\BlockMeltEvent;
use function mt_rand; use function mt_rand;
@ -35,7 +34,7 @@ class FrostedIce extends Ice{
public function getRequiredStateDataBits() : int{ return 2; } public function getRequiredStateDataBits() : int{ return 2; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeState(RuntimeDataDescriber $w) : void{
$w->boundedInt(2, 0, self::MAX_AGE, $this->age); $w->boundedInt(2, 0, self::MAX_AGE, $this->age);
} }

View File

@ -27,8 +27,7 @@ use pocketmine\block\tile\Furnace as TileFurnace;
use pocketmine\block\utils\FacesOppositePlacingPlayerTrait; use pocketmine\block\utils\FacesOppositePlacingPlayerTrait;
use pocketmine\block\utils\HorizontalFacingTrait; use pocketmine\block\utils\HorizontalFacingTrait;
use pocketmine\crafting\FurnaceType; use pocketmine\crafting\FurnaceType;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\item\Item; use pocketmine\item\Item;
use pocketmine\math\Vector3; use pocketmine\math\Vector3;
use pocketmine\player\Player; use pocketmine\player\Player;
@ -49,7 +48,7 @@ class Furnace extends Opaque{
public function getRequiredStateDataBits() : int{ return 3; } public function getRequiredStateDataBits() : int{ return 3; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeState(RuntimeDataDescriber $w) : void{
$w->horizontalFacing($this->facing); $w->horizontalFacing($this->facing);
$w->bool($this->lit); $w->bool($this->lit);
} }

View File

@ -26,8 +26,7 @@ namespace pocketmine\block;
use pocketmine\block\tile\Hopper as TileHopper; use pocketmine\block\tile\Hopper as TileHopper;
use pocketmine\block\utils\PoweredByRedstoneTrait; use pocketmine\block\utils\PoweredByRedstoneTrait;
use pocketmine\block\utils\SupportType; use pocketmine\block\utils\SupportType;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\item\Item; use pocketmine\item\Item;
use pocketmine\math\AxisAlignedBB; use pocketmine\math\AxisAlignedBB;
use pocketmine\math\Facing; use pocketmine\math\Facing;
@ -42,7 +41,7 @@ class Hopper extends Transparent{
public function getRequiredStateDataBits() : int{ return 4; } public function getRequiredStateDataBits() : int{ return 4; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeState(RuntimeDataDescriber $w) : void{
$w->facingExcept($this->facing, Facing::UP); $w->facingExcept($this->facing, Facing::UP);
$w->bool($this->powered); $w->bool($this->powered);
} }

View File

@ -26,8 +26,7 @@ namespace pocketmine\block;
use pocketmine\block\tile\ItemFrame as TileItemFrame; use pocketmine\block\tile\ItemFrame as TileItemFrame;
use pocketmine\block\utils\AnyFacingTrait; use pocketmine\block\utils\AnyFacingTrait;
use pocketmine\block\utils\SupportType; use pocketmine\block\utils\SupportType;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\item\Item; use pocketmine\item\Item;
use pocketmine\math\Facing; use pocketmine\math\Facing;
use pocketmine\math\Vector3; use pocketmine\math\Vector3;
@ -53,7 +52,7 @@ class ItemFrame extends Flowable{
public function getRequiredStateDataBits() : int{ return 4; } public function getRequiredStateDataBits() : int{ return 4; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeState(RuntimeDataDescriber $w) : void{
$w->facing($this->facing); $w->facing($this->facing);
$w->bool($this->hasMap); $w->bool($this->hasMap);
} }

View File

@ -24,8 +24,7 @@ declare(strict_types=1);
namespace pocketmine\block; namespace pocketmine\block;
use pocketmine\block\utils\SupportType; use pocketmine\block\utils\SupportType;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\item\Item; use pocketmine\item\Item;
use pocketmine\math\Axis; use pocketmine\math\Axis;
use pocketmine\math\AxisAlignedBB; use pocketmine\math\AxisAlignedBB;
@ -46,7 +45,7 @@ class Lantern extends Transparent{
public function getRequiredStateDataBits() : int{ return 1; } public function getRequiredStateDataBits() : int{ return 1; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeState(RuntimeDataDescriber $w) : void{
$w->bool($this->hanging); $w->bool($this->hanging);
} }

View File

@ -25,8 +25,7 @@ namespace pocketmine\block;
use pocketmine\block\utils\LeavesType; use pocketmine\block\utils\LeavesType;
use pocketmine\block\utils\SupportType; use pocketmine\block\utils\SupportType;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\event\block\LeavesDecayEvent; use pocketmine\event\block\LeavesDecayEvent;
use pocketmine\item\Item; use pocketmine\item\Item;
use pocketmine\item\VanillaItems; use pocketmine\item\VanillaItems;
@ -50,7 +49,7 @@ class Leaves extends Transparent{
public function getRequiredStateDataBits() : int{ return 2; } public function getRequiredStateDataBits() : int{ return 2; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeState(RuntimeDataDescriber $w) : void{
$w->bool($this->noDecay); $w->bool($this->noDecay);
$w->bool($this->checkDecay); $w->bool($this->checkDecay);
} }

View File

@ -27,8 +27,7 @@ use pocketmine\block\tile\Lectern as TileLectern;
use pocketmine\block\utils\FacesOppositePlacingPlayerTrait; use pocketmine\block\utils\FacesOppositePlacingPlayerTrait;
use pocketmine\block\utils\HorizontalFacingTrait; use pocketmine\block\utils\HorizontalFacingTrait;
use pocketmine\block\utils\SupportType; use pocketmine\block\utils\SupportType;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\item\Item; use pocketmine\item\Item;
use pocketmine\item\WritableBookBase; use pocketmine\item\WritableBookBase;
use pocketmine\math\AxisAlignedBB; use pocketmine\math\AxisAlignedBB;
@ -49,7 +48,7 @@ class Lectern extends Transparent{
public function getRequiredStateDataBits() : int{ return 3; } public function getRequiredStateDataBits() : int{ return 3; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeState(RuntimeDataDescriber $w) : void{
$w->horizontalFacing($this->facing); $w->horizontalFacing($this->facing);
$w->bool($this->producingSignal); $w->bool($this->producingSignal);
} }

View File

@ -24,8 +24,7 @@ declare(strict_types=1);
namespace pocketmine\block; namespace pocketmine\block;
use pocketmine\block\utils\LeverFacing; use pocketmine\block\utils\LeverFacing;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\item\Item; use pocketmine\item\Item;
use pocketmine\math\Axis; use pocketmine\math\Axis;
use pocketmine\math\Facing; use pocketmine\math\Facing;
@ -47,7 +46,7 @@ class Lever extends Flowable{
public function getRequiredStateDataBits() : int{ return 4; } public function getRequiredStateDataBits() : int{ return 4; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeState(RuntimeDataDescriber $w) : void{
$w->leverFacing($this->facing); $w->leverFacing($this->facing);
$w->bool($this->activated); $w->bool($this->activated);
} }

View File

@ -23,8 +23,7 @@ declare(strict_types=1);
namespace pocketmine\block; namespace pocketmine\block;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\item\Item; use pocketmine\item\Item;
use pocketmine\math\Vector3; use pocketmine\math\Vector3;
use pocketmine\player\Player; use pocketmine\player\Player;
@ -37,7 +36,7 @@ final class Light extends Flowable{
public function getRequiredTypeDataBits() : int{ return 4; } public function getRequiredTypeDataBits() : int{ return 4; }
protected function describeType(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeType(RuntimeDataDescriber $w) : void{
$w->boundedInt(4, self::MIN_LIGHT_LEVEL, self::MAX_LIGHT_LEVEL, $this->level); $w->boundedInt(4, self::MIN_LIGHT_LEVEL, self::MAX_LIGHT_LEVEL, $this->level);
} }

View File

@ -25,8 +25,7 @@ namespace pocketmine\block;
use pocketmine\block\utils\MinimumCostFlowCalculator; use pocketmine\block\utils\MinimumCostFlowCalculator;
use pocketmine\block\utils\SupportType; use pocketmine\block\utils\SupportType;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\entity\Entity; use pocketmine\entity\Entity;
use pocketmine\event\block\BlockFormEvent; use pocketmine\event\block\BlockFormEvent;
use pocketmine\event\block\BlockSpreadEvent; use pocketmine\event\block\BlockSpreadEvent;
@ -51,7 +50,7 @@ abstract class Liquid extends Transparent{
public function getRequiredStateDataBits() : int{ return 5; } public function getRequiredStateDataBits() : int{ return 5; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeState(RuntimeDataDescriber $w) : void{
$w->boundedInt(3, 0, self::MAX_DECAY, $this->decay); $w->boundedInt(3, 0, self::MAX_DECAY, $this->decay);
$w->bool($this->falling); $w->bool($this->falling);
$w->bool($this->still); $w->bool($this->still);

View File

@ -24,8 +24,7 @@ declare(strict_types=1);
namespace pocketmine\block; namespace pocketmine\block;
use pocketmine\block\utils\SupportType; use pocketmine\block\utils\SupportType;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\entity\Entity; use pocketmine\entity\Entity;
use pocketmine\item\Item; use pocketmine\item\Item;
use pocketmine\math\Axis; use pocketmine\math\Axis;
@ -37,7 +36,7 @@ class NetherPortal extends Transparent{
public function getRequiredStateDataBits() : int{ return 1; } public function getRequiredStateDataBits() : int{ return 1; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeState(RuntimeDataDescriber $w) : void{
$w->horizontalAxis($this->axis); $w->horizontalAxis($this->axis);
} }

View File

@ -24,8 +24,7 @@ declare(strict_types=1);
namespace pocketmine\block; namespace pocketmine\block;
use pocketmine\block\utils\SupportType; use pocketmine\block\utils\SupportType;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\entity\Entity; use pocketmine\entity\Entity;
use pocketmine\event\block\StructureGrowEvent; use pocketmine\event\block\StructureGrowEvent;
use pocketmine\item\Fertilizer; use pocketmine\item\Fertilizer;
@ -57,7 +56,7 @@ class NetherVines extends Flowable{
return 5; return 5;
} }
public function describeState(RuntimeDataWriter|RuntimeDataReader $w) : void{ public function describeState(RuntimeDataDescriber $w) : void{
$w->boundedInt(5, 0, self::MAX_AGE, $this->age); $w->boundedInt(5, 0, self::MAX_AGE, $this->age);
} }

View File

@ -23,8 +23,7 @@ declare(strict_types=1);
namespace pocketmine\block; namespace pocketmine\block;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\event\block\BlockGrowEvent; use pocketmine\event\block\BlockGrowEvent;
use pocketmine\item\Item; use pocketmine\item\Item;
use pocketmine\math\Facing; use pocketmine\math\Facing;
@ -40,7 +39,7 @@ class NetherWartPlant extends Flowable{
public function getRequiredStateDataBits() : int{ return 2; } public function getRequiredStateDataBits() : int{ return 2; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeState(RuntimeDataDescriber $w) : void{
$w->boundedInt(2, 0, self::MAX_AGE, $this->age); $w->boundedInt(2, 0, self::MAX_AGE, $this->age);
} }

View File

@ -25,8 +25,7 @@ namespace pocketmine\block;
use pocketmine\block\utils\RailConnectionInfo; use pocketmine\block\utils\RailConnectionInfo;
use pocketmine\data\bedrock\block\BlockLegacyMetadata; use pocketmine\data\bedrock\block\BlockLegacyMetadata;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\math\Facing; use pocketmine\math\Facing;
use function array_keys; use function array_keys;
use function implode; use function implode;
@ -37,7 +36,7 @@ class Rail extends BaseRail{
public function getRequiredStateDataBits() : int{ return 4; } public function getRequiredStateDataBits() : int{ return 4; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeState(RuntimeDataDescriber $w) : void{
$w->railShape($this->railShape); $w->railShape($this->railShape);
} }

View File

@ -24,8 +24,7 @@ declare(strict_types=1);
namespace pocketmine\block; namespace pocketmine\block;
use pocketmine\block\utils\MushroomBlockType; use pocketmine\block\utils\MushroomBlockType;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\item\Item; use pocketmine\item\Item;
use function mt_rand; use function mt_rand;
@ -39,7 +38,7 @@ class RedMushroomBlock extends Opaque{
public function getRequiredStateDataBits() : int{ return 4; } public function getRequiredStateDataBits() : int{ return 4; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeState(RuntimeDataDescriber $w) : void{
$w->mushroomBlockType($this->mushroomBlockType); $w->mushroomBlockType($this->mushroomBlockType);
} }

View File

@ -28,8 +28,7 @@ use pocketmine\block\utils\AnalogRedstoneSignalEmitterTrait;
use pocketmine\block\utils\HorizontalFacingTrait; use pocketmine\block\utils\HorizontalFacingTrait;
use pocketmine\block\utils\PoweredByRedstoneTrait; use pocketmine\block\utils\PoweredByRedstoneTrait;
use pocketmine\block\utils\SupportType; use pocketmine\block\utils\SupportType;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\item\Item; use pocketmine\item\Item;
use pocketmine\math\AxisAlignedBB; use pocketmine\math\AxisAlignedBB;
use pocketmine\math\Facing; use pocketmine\math\Facing;
@ -47,7 +46,7 @@ class RedstoneComparator extends Flowable{
public function getRequiredStateDataBits() : int{ return 4; } public function getRequiredStateDataBits() : int{ return 4; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeState(RuntimeDataDescriber $w) : void{
$w->horizontalFacing($this->facing); $w->horizontalFacing($this->facing);
$w->bool($this->isSubtractMode); $w->bool($this->isSubtractMode);
$w->bool($this->powered); $w->bool($this->powered);

View File

@ -24,15 +24,14 @@ declare(strict_types=1);
namespace pocketmine\block; namespace pocketmine\block;
use pocketmine\block\utils\PoweredByRedstoneTrait; use pocketmine\block\utils\PoweredByRedstoneTrait;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
class RedstoneLamp extends Opaque{ class RedstoneLamp extends Opaque{
use PoweredByRedstoneTrait; use PoweredByRedstoneTrait;
public function getRequiredStateDataBits() : int{ return 1; } public function getRequiredStateDataBits() : int{ return 1; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeState(RuntimeDataDescriber $w) : void{
$w->bool($this->powered); $w->bool($this->powered);
} }

View File

@ -23,8 +23,7 @@ declare(strict_types=1);
namespace pocketmine\block; namespace pocketmine\block;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\item\Item; use pocketmine\item\Item;
use pocketmine\item\VanillaItems; use pocketmine\item\VanillaItems;
use pocketmine\math\Vector3; use pocketmine\math\Vector3;
@ -36,7 +35,7 @@ class RedstoneOre extends Opaque{
public function getRequiredStateDataBits() : int{ return 1; } public function getRequiredStateDataBits() : int{ return 1; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeState(RuntimeDataDescriber $w) : void{
$w->bool($this->lit); $w->bool($this->lit);
} }

View File

@ -26,8 +26,7 @@ namespace pocketmine\block;
use pocketmine\block\utils\HorizontalFacingTrait; use pocketmine\block\utils\HorizontalFacingTrait;
use pocketmine\block\utils\PoweredByRedstoneTrait; use pocketmine\block\utils\PoweredByRedstoneTrait;
use pocketmine\block\utils\SupportType; use pocketmine\block\utils\SupportType;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\item\Item; use pocketmine\item\Item;
use pocketmine\math\AxisAlignedBB; use pocketmine\math\AxisAlignedBB;
use pocketmine\math\Facing; use pocketmine\math\Facing;
@ -46,7 +45,7 @@ class RedstoneRepeater extends Flowable{
public function getRequiredStateDataBits() : int{ return 5; } public function getRequiredStateDataBits() : int{ return 5; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeState(RuntimeDataDescriber $w) : void{
$w->horizontalFacing($this->facing); $w->horizontalFacing($this->facing);
$w->boundedInt(2, self::MIN_DELAY, self::MAX_DELAY, $this->delay); $w->boundedInt(2, self::MIN_DELAY, self::MAX_DELAY, $this->delay);
$w->bool($this->powered); $w->bool($this->powered);

View File

@ -23,15 +23,14 @@ declare(strict_types=1);
namespace pocketmine\block; namespace pocketmine\block;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
class RedstoneTorch extends Torch{ class RedstoneTorch extends Torch{
protected bool $lit = true; protected bool $lit = true;
public function getRequiredStateDataBits() : int{ return parent::getRequiredStateDataBits() + 1; } public function getRequiredStateDataBits() : int{ return parent::getRequiredStateDataBits() + 1; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeState(RuntimeDataDescriber $w) : void{
parent::describeState($w); parent::describeState($w);
$w->bool($this->lit); $w->bool($this->lit);
} }

View File

@ -24,8 +24,7 @@ declare(strict_types=1);
namespace pocketmine\block; namespace pocketmine\block;
use pocketmine\block\utils\TreeType; use pocketmine\block\utils\TreeType;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\event\block\StructureGrowEvent; use pocketmine\event\block\StructureGrowEvent;
use pocketmine\item\Fertilizer; use pocketmine\item\Fertilizer;
use pocketmine\item\Item; use pocketmine\item\Item;
@ -49,7 +48,7 @@ class Sapling extends Flowable{
public function getRequiredStateDataBits() : int{ return 1; } public function getRequiredStateDataBits() : int{ return 1; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeState(RuntimeDataDescriber $w) : void{
$w->bool($this->ready); $w->bool($this->ready);
} }

View File

@ -24,8 +24,7 @@ declare(strict_types=1);
namespace pocketmine\block; namespace pocketmine\block;
use pocketmine\block\utils\SupportType; use pocketmine\block\utils\SupportType;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\item\Item; use pocketmine\item\Item;
use pocketmine\math\AxisAlignedBB; use pocketmine\math\AxisAlignedBB;
use pocketmine\math\Vector3; use pocketmine\math\Vector3;
@ -41,7 +40,7 @@ class SeaPickle extends Transparent{
public function getRequiredStateDataBits() : int{ return 3; } public function getRequiredStateDataBits() : int{ return 3; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeState(RuntimeDataDescriber $w) : void{
$w->boundedInt(2, self::MIN_COUNT, self::MAX_COUNT, $this->count); $w->boundedInt(2, self::MIN_COUNT, self::MAX_COUNT, $this->count);
$w->bool($this->underwater); $w->bool($this->underwater);
} }

View File

@ -25,8 +25,7 @@ namespace pocketmine\block;
use pocketmine\block\tile\ShulkerBox as TileShulkerBox; use pocketmine\block\tile\ShulkerBox as TileShulkerBox;
use pocketmine\block\utils\AnyFacingTrait; use pocketmine\block\utils\AnyFacingTrait;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\item\Item; use pocketmine\item\Item;
use pocketmine\math\Vector3; use pocketmine\math\Vector3;
use pocketmine\player\Player; use pocketmine\player\Player;
@ -37,7 +36,7 @@ class ShulkerBox extends Opaque{
public function getRequiredStateDataBits() : int{ return 0; } public function getRequiredStateDataBits() : int{ return 0; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeState(RuntimeDataDescriber $w) : void{
//NOOP - we don't read or write facing here, because the tile persists it //NOOP - we don't read or write facing here, because the tile persists it
} }

View File

@ -23,15 +23,14 @@ declare(strict_types=1);
namespace pocketmine\block; namespace pocketmine\block;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
abstract class SimplePressurePlate extends PressurePlate{ abstract class SimplePressurePlate extends PressurePlate{
protected bool $pressed = false; protected bool $pressed = false;
public function getRequiredStateDataBits() : int{ return 1; } public function getRequiredStateDataBits() : int{ return 1; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeState(RuntimeDataDescriber $w) : void{
$w->bool($this->pressed); $w->bool($this->pressed);
} }

View File

@ -25,8 +25,7 @@ namespace pocketmine\block;
use pocketmine\block\tile\Skull as TileSkull; use pocketmine\block\tile\Skull as TileSkull;
use pocketmine\block\utils\SkullType; use pocketmine\block\utils\SkullType;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\item\Item; use pocketmine\item\Item;
use pocketmine\math\AxisAlignedBB; use pocketmine\math\AxisAlignedBB;
use pocketmine\math\Facing; use pocketmine\math\Facing;
@ -52,13 +51,13 @@ class Skull extends Flowable{
public function getRequiredTypeDataBits() : int{ return 3; } public function getRequiredTypeDataBits() : int{ return 3; }
protected function describeType(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeType(RuntimeDataDescriber $w) : void{
$w->skullType($this->skullType); $w->skullType($this->skullType);
} }
public function getRequiredStateDataBits() : int{ return 3; } public function getRequiredStateDataBits() : int{ return 3; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeState(RuntimeDataDescriber $w) : void{
$w->facingExcept($this->facing, Facing::DOWN); $w->facingExcept($this->facing, Facing::DOWN);
} }

View File

@ -25,8 +25,7 @@ namespace pocketmine\block;
use pocketmine\block\utils\SlabType; use pocketmine\block\utils\SlabType;
use pocketmine\block\utils\SupportType; use pocketmine\block\utils\SupportType;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\item\Item; use pocketmine\item\Item;
use pocketmine\math\AxisAlignedBB; use pocketmine\math\AxisAlignedBB;
use pocketmine\math\Facing; use pocketmine\math\Facing;
@ -44,7 +43,7 @@ class Slab extends Transparent{
public function getRequiredStateDataBits() : int{ return 2; } public function getRequiredStateDataBits() : int{ return 2; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeState(RuntimeDataDescriber $w) : void{
$w->slabType($this->slabType); $w->slabType($this->slabType);
} }

View File

@ -26,8 +26,7 @@ namespace pocketmine\block;
use pocketmine\block\utils\Fallable; use pocketmine\block\utils\Fallable;
use pocketmine\block\utils\FallableTrait; use pocketmine\block\utils\FallableTrait;
use pocketmine\block\utils\SupportType; use pocketmine\block\utils\SupportType;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\event\block\BlockMeltEvent; use pocketmine\event\block\BlockMeltEvent;
use pocketmine\item\Item; use pocketmine\item\Item;
use pocketmine\item\VanillaItems; use pocketmine\item\VanillaItems;
@ -49,7 +48,7 @@ class SnowLayer extends Flowable implements Fallable{
public function getRequiredStateDataBits() : int{ return 3; } public function getRequiredStateDataBits() : int{ return 3; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeState(RuntimeDataDescriber $w) : void{
$w->boundedInt(3, self::MIN_LAYERS, self::MAX_LAYERS, $this->layers); $w->boundedInt(3, self::MIN_LAYERS, self::MAX_LAYERS, $this->layers);
} }

View File

@ -23,15 +23,14 @@ declare(strict_types=1);
namespace pocketmine\block; namespace pocketmine\block;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
class Sponge extends Opaque{ class Sponge extends Opaque{
protected bool $wet = false; protected bool $wet = false;
public function getRequiredTypeDataBits() : int{ return 1; } public function getRequiredTypeDataBits() : int{ return 1; }
protected function describeType(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeType(RuntimeDataDescriber $w) : void{
$w->bool($this->wet); $w->bool($this->wet);
} }

View File

@ -26,8 +26,7 @@ namespace pocketmine\block;
use pocketmine\block\utils\HorizontalFacingTrait; use pocketmine\block\utils\HorizontalFacingTrait;
use pocketmine\block\utils\StairShape; use pocketmine\block\utils\StairShape;
use pocketmine\block\utils\SupportType; use pocketmine\block\utils\SupportType;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\item\Item; use pocketmine\item\Item;
use pocketmine\math\Axis; use pocketmine\math\Axis;
use pocketmine\math\AxisAlignedBB; use pocketmine\math\AxisAlignedBB;
@ -49,7 +48,7 @@ class Stair extends Transparent{
public function getRequiredStateDataBits() : int{ return 3; } public function getRequiredStateDataBits() : int{ return 3; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeState(RuntimeDataDescriber $w) : void{
$w->horizontalFacing($this->facing); $w->horizontalFacing($this->facing);
$w->bool($this->upsideDown); $w->bool($this->upsideDown);
} }

View File

@ -25,8 +25,7 @@ namespace pocketmine\block;
use pocketmine\block\utils\RailConnectionInfo; use pocketmine\block\utils\RailConnectionInfo;
use pocketmine\data\bedrock\block\BlockLegacyMetadata; use pocketmine\data\bedrock\block\BlockLegacyMetadata;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
use function array_keys; use function array_keys;
use function implode; use function implode;
@ -39,7 +38,7 @@ class StraightOnlyRail extends BaseRail{
public function getRequiredStateDataBits() : int{ return 3; } public function getRequiredStateDataBits() : int{ return 3; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeState(RuntimeDataDescriber $w) : void{
$w->straightOnlyRailShape($this->railShape); $w->straightOnlyRailShape($this->railShape);
} }

View File

@ -23,8 +23,7 @@ declare(strict_types=1);
namespace pocketmine\block; namespace pocketmine\block;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\event\block\BlockGrowEvent; use pocketmine\event\block\BlockGrowEvent;
use pocketmine\item\Fertilizer; use pocketmine\item\Fertilizer;
use pocketmine\item\Item; use pocketmine\item\Item;
@ -41,7 +40,7 @@ class Sugarcane extends Flowable{
public function getRequiredStateDataBits() : int{ return 4; } public function getRequiredStateDataBits() : int{ return 4; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeState(RuntimeDataDescriber $w) : void{
$w->boundedInt(4, 0, self::MAX_AGE, $this->age); $w->boundedInt(4, 0, self::MAX_AGE, $this->age);
} }

View File

@ -23,8 +23,7 @@ declare(strict_types=1);
namespace pocketmine\block; namespace pocketmine\block;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\entity\Entity; use pocketmine\entity\Entity;
use pocketmine\entity\Living; use pocketmine\entity\Living;
use pocketmine\event\block\BlockGrowEvent; use pocketmine\event\block\BlockGrowEvent;
@ -48,7 +47,7 @@ class SweetBerryBush extends Flowable{
public function getRequiredStateDataBits() : int{ return 3; } public function getRequiredStateDataBits() : int{ return 3; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeState(RuntimeDataDescriber $w) : void{
$w->boundedInt(3, self::STAGE_SAPLING, self::STAGE_MATURE, $this->age); $w->boundedInt(3, self::STAGE_SAPLING, self::STAGE_MATURE, $this->age);
} }

View File

@ -23,8 +23,7 @@ declare(strict_types=1);
namespace pocketmine\block; namespace pocketmine\block;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\entity\Location; use pocketmine\entity\Location;
use pocketmine\entity\object\PrimedTNT; use pocketmine\entity\object\PrimedTNT;
use pocketmine\entity\projectile\Projectile; use pocketmine\entity\projectile\Projectile;
@ -48,13 +47,13 @@ class TNT extends Opaque{
public function getRequiredTypeDataBits() : int{ return 1; } public function getRequiredTypeDataBits() : int{ return 1; }
protected function describeType(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeType(RuntimeDataDescriber $w) : void{
$w->bool($this->worksUnderwater); $w->bool($this->worksUnderwater);
} }
public function getRequiredStateDataBits() : int{ return 1; } public function getRequiredStateDataBits() : int{ return 1; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeState(RuntimeDataDescriber $w) : void{
$w->bool($this->unstable); $w->bool($this->unstable);
} }

View File

@ -24,8 +24,7 @@ declare(strict_types=1);
namespace pocketmine\block; namespace pocketmine\block;
use pocketmine\block\utils\SupportType; use pocketmine\block\utils\SupportType;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\item\Item; use pocketmine\item\Item;
use pocketmine\math\Axis; use pocketmine\math\Axis;
use pocketmine\math\Facing; use pocketmine\math\Facing;
@ -39,7 +38,7 @@ class Torch extends Flowable{
public function getRequiredStateDataBits() : int{ return 3; } public function getRequiredStateDataBits() : int{ return 3; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeState(RuntimeDataDescriber $w) : void{
$w->facingExcept($this->facing, Facing::DOWN); $w->facingExcept($this->facing, Facing::DOWN);
} }

View File

@ -25,8 +25,7 @@ namespace pocketmine\block;
use pocketmine\block\utils\HorizontalFacingTrait; use pocketmine\block\utils\HorizontalFacingTrait;
use pocketmine\block\utils\SupportType; use pocketmine\block\utils\SupportType;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\item\Item; use pocketmine\item\Item;
use pocketmine\math\AxisAlignedBB; use pocketmine\math\AxisAlignedBB;
use pocketmine\math\Facing; use pocketmine\math\Facing;
@ -43,7 +42,7 @@ class Trapdoor extends Transparent{
public function getRequiredStateDataBits() : int{ return 4; } public function getRequiredStateDataBits() : int{ return 4; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeState(RuntimeDataDescriber $w) : void{
$w->horizontalFacing($this->facing); $w->horizontalFacing($this->facing);
$w->bool($this->top); $w->bool($this->top);
$w->bool($this->open); $w->bool($this->open);

View File

@ -23,8 +23,7 @@ declare(strict_types=1);
namespace pocketmine\block; namespace pocketmine\block;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\item\Item; use pocketmine\item\Item;
use pocketmine\item\VanillaItems; use pocketmine\item\VanillaItems;
@ -36,7 +35,7 @@ class Tripwire extends Flowable{
public function getRequiredStateDataBits() : int{ return 4; } public function getRequiredStateDataBits() : int{ return 4; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeState(RuntimeDataDescriber $w) : void{
$w->bool($this->triggered); $w->bool($this->triggered);
$w->bool($this->suspended); $w->bool($this->suspended);
$w->bool($this->connected); $w->bool($this->connected);

View File

@ -24,8 +24,7 @@ declare(strict_types=1);
namespace pocketmine\block; namespace pocketmine\block;
use pocketmine\block\utils\HorizontalFacingTrait; use pocketmine\block\utils\HorizontalFacingTrait;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\item\Item; use pocketmine\item\Item;
use pocketmine\math\Axis; use pocketmine\math\Axis;
use pocketmine\math\Facing; use pocketmine\math\Facing;
@ -41,7 +40,7 @@ class TripwireHook extends Flowable{
public function getRequiredStateDataBits() : int{ return 4; } public function getRequiredStateDataBits() : int{ return 4; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeState(RuntimeDataDescriber $w) : void{
$w->horizontalFacing($this->facing); $w->horizontalFacing($this->facing);
$w->bool($this->connected); $w->bool($this->connected);
$w->bool($this->powered); $w->bool($this->powered);

View File

@ -23,8 +23,7 @@ declare(strict_types=1);
namespace pocketmine\block; namespace pocketmine\block;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\item\Item; use pocketmine\item\Item;
/** /**
@ -41,7 +40,7 @@ class UnknownBlock extends Transparent{
public function getRequiredTypeDataBits() : int{ return Block::INTERNAL_STATE_DATA_BITS; } public function getRequiredTypeDataBits() : int{ return Block::INTERNAL_STATE_DATA_BITS; }
protected function describeType(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeType(RuntimeDataDescriber $w) : void{
//use type instead of state, so we don't lose any information like colour //use type instead of state, so we don't lose any information like colour
//this might be an improperly registered plugin block //this might be an improperly registered plugin block
$w->int(Block::INTERNAL_STATE_DATA_BITS, $this->stateData); $w->int(Block::INTERNAL_STATE_DATA_BITS, $this->stateData);

View File

@ -23,8 +23,7 @@ declare(strict_types=1);
namespace pocketmine\block; namespace pocketmine\block;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\entity\Entity; use pocketmine\entity\Entity;
use pocketmine\item\Item; use pocketmine\item\Item;
use pocketmine\math\Axis; use pocketmine\math\Axis;
@ -42,7 +41,7 @@ class Vine extends Flowable{
public function getRequiredStateDataBits() : int{ return 4; } public function getRequiredStateDataBits() : int{ return 4; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeState(RuntimeDataDescriber $w) : void{
$w->horizontalFacingFlags($this->faces); $w->horizontalFacingFlags($this->faces);
} }

View File

@ -25,8 +25,7 @@ namespace pocketmine\block;
use pocketmine\block\utils\SupportType; use pocketmine\block\utils\SupportType;
use pocketmine\block\utils\WallConnectionType; use pocketmine\block\utils\WallConnectionType;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\math\Axis; use pocketmine\math\Axis;
use pocketmine\math\AxisAlignedBB; use pocketmine\math\AxisAlignedBB;
use pocketmine\math\Facing; use pocketmine\math\Facing;
@ -45,7 +44,7 @@ class Wall extends Transparent{
public function getRequiredStateDataBits() : int{ return 9; } public function getRequiredStateDataBits() : int{ return 9; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeState(RuntimeDataDescriber $w) : void{
$w->wallConnections($this->connections); $w->wallConnections($this->connections);
$w->bool($this->post); $w->bool($this->post);
} }

View File

@ -24,8 +24,7 @@ declare(strict_types=1);
namespace pocketmine\block; namespace pocketmine\block;
use pocketmine\block\utils\HorizontalFacingTrait; use pocketmine\block\utils\HorizontalFacingTrait;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\item\Item; use pocketmine\item\Item;
use pocketmine\item\VanillaItems; use pocketmine\item\VanillaItems;
use pocketmine\math\Axis; use pocketmine\math\Axis;
@ -39,7 +38,7 @@ final class WallCoralFan extends BaseCoral{
public function getRequiredStateDataBits() : int{ return parent::getRequiredStateDataBits() + 2; } public function getRequiredStateDataBits() : int{ return parent::getRequiredStateDataBits() + 2; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeState(RuntimeDataDescriber $w) : void{
$w->horizontalFacing($this->facing); $w->horizontalFacing($this->facing);
} }

View File

@ -25,8 +25,7 @@ namespace pocketmine\block;
use pocketmine\block\utils\PillarRotationTrait; use pocketmine\block\utils\PillarRotationTrait;
use pocketmine\block\utils\WoodTypeTrait; use pocketmine\block\utils\WoodTypeTrait;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\item\Axe; use pocketmine\item\Axe;
use pocketmine\item\Item; use pocketmine\item\Item;
use pocketmine\math\Vector3; use pocketmine\math\Vector3;
@ -41,7 +40,7 @@ class Wood extends Opaque{
public function getRequiredTypeDataBits() : int{ return 1; } public function getRequiredTypeDataBits() : int{ return 1; }
protected function describeType(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeType(RuntimeDataDescriber $w) : void{
$w->bool($this->stripped); $w->bool($this->stripped);
} }

View File

@ -23,15 +23,14 @@ declare(strict_types=1);
namespace pocketmine\block\utils; namespace pocketmine\block\utils;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
trait AnalogRedstoneSignalEmitterTrait{ trait AnalogRedstoneSignalEmitterTrait{
protected int $signalStrength = 0; protected int $signalStrength = 0;
public function getRequiredStateDataBits() : int{ return 4; } public function getRequiredStateDataBits() : int{ return 4; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeState(RuntimeDataDescriber $w) : void{
$w->boundedInt(4, 0, 15, $this->signalStrength); $w->boundedInt(4, 0, 15, $this->signalStrength);
} }

View File

@ -23,8 +23,7 @@ declare(strict_types=1);
namespace pocketmine\block\utils; namespace pocketmine\block\utils;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\math\Facing; use pocketmine\math\Facing;
trait AnyFacingTrait{ trait AnyFacingTrait{
@ -32,7 +31,7 @@ trait AnyFacingTrait{
public function getRequiredStateDataBits() : int{ return 3; } public function getRequiredStateDataBits() : int{ return 3; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeState(RuntimeDataDescriber $w) : void{
$w->facing($this->facing); $w->facing($this->facing);
} }

View File

@ -24,8 +24,7 @@ declare(strict_types=1);
namespace pocketmine\block\utils; namespace pocketmine\block\utils;
use pocketmine\block\Block; use pocketmine\block\Block;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\entity\projectile\Projectile; use pocketmine\entity\projectile\Projectile;
use pocketmine\item\Durable; use pocketmine\item\Durable;
use pocketmine\item\enchantment\VanillaEnchantments; use pocketmine\item\enchantment\VanillaEnchantments;
@ -42,7 +41,7 @@ trait CandleTrait{
public function getRequiredStateDataBits() : int{ return 1; } public function getRequiredStateDataBits() : int{ return 1; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeState(RuntimeDataDescriber $w) : void{
$w->bool($this->lit); $w->bool($this->lit);
} }

View File

@ -24,8 +24,7 @@ declare(strict_types=1);
namespace pocketmine\block\utils; namespace pocketmine\block\utils;
use pocketmine\block\Block; use pocketmine\block\Block;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
trait ColoredTrait{ trait ColoredTrait{
/** @var DyeColor */ /** @var DyeColor */
@ -34,7 +33,7 @@ trait ColoredTrait{
public function getRequiredTypeDataBits() : int{ return 4; } public function getRequiredTypeDataBits() : int{ return 4; }
/** @see Block::describeType() */ /** @see Block::describeType() */
protected function describeType(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeType(RuntimeDataDescriber $w) : void{
$w->dyeColor($this->color); $w->dyeColor($this->color);
} }

View File

@ -25,8 +25,7 @@ namespace pocketmine\block\utils;
use pocketmine\block\BlockIdentifier; use pocketmine\block\BlockIdentifier;
use pocketmine\block\BlockTypeInfo; use pocketmine\block\BlockTypeInfo;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\item\Axe; use pocketmine\item\Axe;
use pocketmine\item\Item; use pocketmine\item\Item;
use pocketmine\item\ItemTypeIds; use pocketmine\item\ItemTypeIds;
@ -47,7 +46,7 @@ trait CopperTrait{
public function getRequiredTypeDataBits() : int{ return 3; } public function getRequiredTypeDataBits() : int{ return 3; }
protected function describeType(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeType(RuntimeDataDescriber $w) : void{
$w->copperOxidation($this->oxidation); $w->copperOxidation($this->oxidation);
$w->bool($this->waxed); $w->bool($this->waxed);
} }

View File

@ -24,8 +24,7 @@ declare(strict_types=1);
namespace pocketmine\block\utils; namespace pocketmine\block\utils;
use pocketmine\block\Block; use pocketmine\block\Block;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
trait CoralTypeTrait{ trait CoralTypeTrait{
protected CoralType $coralType; protected CoralType $coralType;
@ -34,7 +33,7 @@ trait CoralTypeTrait{
public function getRequiredTypeDataBits() : int{ return 4; } public function getRequiredTypeDataBits() : int{ return 4; }
/** @see Block::describeType() */ /** @see Block::describeType() */
protected function describeType(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeType(RuntimeDataDescriber $w) : void{
$w->coralType($this->coralType); $w->coralType($this->coralType);
$w->bool($this->dead); $w->bool($this->dead);
} }

View File

@ -23,8 +23,7 @@ declare(strict_types=1);
namespace pocketmine\block\utils; namespace pocketmine\block\utils;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\math\Axis; use pocketmine\math\Axis;
use pocketmine\math\Facing; use pocketmine\math\Facing;
@ -33,7 +32,7 @@ trait HorizontalFacingTrait{
public function getRequiredStateDataBits() : int{ return 2; } public function getRequiredStateDataBits() : int{ return 2; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeState(RuntimeDataDescriber $w) : void{
$w->horizontalFacing($this->facing); $w->horizontalFacing($this->facing);
} }

View File

@ -24,8 +24,7 @@ declare(strict_types=1);
namespace pocketmine\block\utils; namespace pocketmine\block\utils;
use pocketmine\block\Block; use pocketmine\block\Block;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\item\Item; use pocketmine\item\Item;
use pocketmine\math\Axis; use pocketmine\math\Axis;
use pocketmine\math\Facing; use pocketmine\math\Facing;
@ -38,7 +37,7 @@ trait PillarRotationTrait{
public function getRequiredStateDataBits() : int{ return 2; } public function getRequiredStateDataBits() : int{ return 2; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeState(RuntimeDataDescriber $w) : void{
$w->axis($this->axis); $w->axis($this->axis);
} }

View File

@ -23,15 +23,14 @@ declare(strict_types=1);
namespace pocketmine\block\utils; namespace pocketmine\block\utils;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
trait RailPoweredByRedstoneTrait{ trait RailPoweredByRedstoneTrait{
use PoweredByRedstoneTrait; use PoweredByRedstoneTrait;
public function getRequiredStateDataBits() : int{ return parent::getRequiredStateDataBits() + 1; } public function getRequiredStateDataBits() : int{ return parent::getRequiredStateDataBits() + 1; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeState(RuntimeDataDescriber $w) : void{
parent::describeState($w); parent::describeState($w);
$w->bool($this->powered); $w->bool($this->powered);
} }

View File

@ -23,8 +23,7 @@ declare(strict_types=1);
namespace pocketmine\block\utils; namespace pocketmine\block\utils;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
use function floor; use function floor;
trait SignLikeRotationTrait{ trait SignLikeRotationTrait{
@ -33,7 +32,7 @@ trait SignLikeRotationTrait{
public function getRequiredStateDataBits() : int{ return 4; } public function getRequiredStateDataBits() : int{ return 4; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeState(RuntimeDataDescriber $w) : void{
$w->boundedInt(4, 0, 15, $this->rotation); $w->boundedInt(4, 0, 15, $this->rotation);
} }

View File

@ -0,0 +1,67 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\data\runtime;
use pocketmine\block\utils\BrewingStandSlot;
use pocketmine\block\utils\WallConnectionType;
use pocketmine\math\Facing;
interface RuntimeDataDescriber extends RuntimeEnumDescriber{
public function int(int $bits, int &$value) : void;
public function boundedInt(int $bits, int $min, int $max, int &$value) : void;
public function bool(bool &$value) : void;
public function horizontalFacing(int &$facing) : void;
/**
* @param int[] $faces
*/
public function horizontalFacingFlags(array &$faces) : void;
public function facing(int &$facing) : void;
public function facingExcept(int &$facing, int $except) : void;
public function axis(int &$axis) : void;
public function horizontalAxis(int &$axis) : void;
/**
* @param WallConnectionType[] $connections
* @phpstan-param array<Facing::NORTH|Facing::EAST|Facing::SOUTH|Facing::WEST, WallConnectionType> $connections
*/
public function wallConnections(array &$connections) : void;
/**
* @param BrewingStandSlot[] $slots
* @phpstan-param array<int, BrewingStandSlot> $slots
*/
public function brewingStandSlots(array &$slots) : void;
public function railShape(int &$railShape) : void;
public function straightOnlyRailShape(int &$railShape) : void;
}

View File

@ -30,7 +30,7 @@ use pocketmine\math\Axis;
use pocketmine\math\Facing; use pocketmine\math\Facing;
use pocketmine\utils\AssumptionFailedError; use pocketmine\utils\AssumptionFailedError;
final class RuntimeDataReader{ final class RuntimeDataReader implements RuntimeDataDescriber{
use RuntimeEnumDeserializerTrait; use RuntimeEnumDeserializerTrait;
private int $offset = 0; private int $offset = 0;
@ -55,12 +55,16 @@ final class RuntimeDataReader{
$value = $this->readInt($bits); $value = $this->readInt($bits);
} }
public function boundedInt(int $bits, int $min, int $max, int &$value) : void{ protected function readBoundedInt(int $bits, int $min, int $max) : int{
$result = $this->readInt($bits) + $min; $result = $this->readInt($bits) + $min;
if($result < $min || $result > $max){ if($result < $min || $result > $max){
throw new InvalidSerializedRuntimeDataException("Value is outside the range $min - $max"); throw new InvalidSerializedRuntimeDataException("Value is outside the range $min - $max");
} }
$value = $result; return $result;
}
public function boundedInt(int $bits, int $min, int $max, int &$value) : void{
$value = $this->readBoundedInt($bits, $min, $max);
} }
protected function readBool() : bool{ protected function readBool() : bool{
@ -142,8 +146,7 @@ final class RuntimeDataReader{
$result = []; $result = [];
//TODO: we can pack this into 7 bits instead of 8 //TODO: we can pack this into 7 bits instead of 8
foreach(Facing::HORIZONTAL as $facing){ foreach(Facing::HORIZONTAL as $facing){
$type = 0; $type = $this->readBoundedInt(2, 0, 2);
$this->boundedInt(2, 0, 2, $type);
if($type !== 0){ if($type !== 0){
$result[$facing] = match($type){ $result[$facing] = match($type){
1 => WallConnectionType::SHORT(), 1 => WallConnectionType::SHORT(),

View File

@ -30,7 +30,7 @@ use pocketmine\math\Facing;
use pocketmine\utils\AssumptionFailedError; use pocketmine\utils\AssumptionFailedError;
use function array_flip; use function array_flip;
final class RuntimeDataWriter{ final class RuntimeDataWriter implements RuntimeDataDescriber{
use RuntimeEnumSerializerTrait; use RuntimeEnumSerializerTrait;
private int $value = 0; private int $value = 0;
@ -40,7 +40,7 @@ final class RuntimeDataWriter{
private int $maxBits private int $maxBits
){} ){}
public function int(int $bits, int $value) : void{ public function writeInt(int $bits, int $value) : void{
if($this->offset + $bits > $this->maxBits){ if($this->offset + $bits > $this->maxBits){
throw new \InvalidArgumentException("Bit buffer cannot be larger than $this->maxBits bits (already have $this->offset bits)"); throw new \InvalidArgumentException("Bit buffer cannot be larger than $this->maxBits bits (already have $this->offset bits)");
} }
@ -52,19 +52,31 @@ final class RuntimeDataWriter{
$this->offset += $bits; $this->offset += $bits;
} }
public function boundedInt(int $bits, int $min, int $max, int $value) : void{ public function int(int $bits, int &$value) : void{
$this->writeInt($bits, $value);
}
protected function writeBoundedInt(int $bits, int $min, int $max, int $value) : void{
if($value < $min || $value > $max){ if($value < $min || $value > $max){
throw new \InvalidArgumentException("Value $value is outside the range $min - $max"); throw new \InvalidArgumentException("Value $value is outside the range $min - $max");
} }
$this->int($bits, $value - $min); $this->writeInt($bits, $value - $min);
} }
public function bool(bool $value) : void{ public function boundedInt(int $bits, int $min, int $max, int &$value) : void{
$this->int(1, $value ? 1 : 0); $this->writeBoundedInt($bits, $min, $max, $value);
} }
public function horizontalFacing(int $facing) : void{ protected function writeBool(bool $value) : void{
$this->int(2, match($facing){ $this->writeInt(1, $value ? 1 : 0);
}
public function bool(bool &$value) : void{
$this->writeBool($value);
}
public function horizontalFacing(int &$facing) : void{
$this->writeInt(2, match($facing){
Facing::NORTH => 0, Facing::NORTH => 0,
Facing::EAST => 1, Facing::EAST => 1,
Facing::SOUTH => 2, Facing::SOUTH => 2,
@ -76,15 +88,15 @@ final class RuntimeDataWriter{
/** /**
* @param int[] $faces * @param int[] $faces
*/ */
public function horizontalFacingFlags(array $faces) : void{ public function horizontalFacingFlags(array &$faces) : void{
$uniqueFaces = array_flip($faces); $uniqueFaces = array_flip($faces);
foreach(Facing::HORIZONTAL as $facing){ foreach(Facing::HORIZONTAL as $facing){
$this->bool(isset($uniqueFaces[$facing])); $this->writeBool(isset($uniqueFaces[$facing]));
} }
} }
public function facing(int $facing) : void{ public function facing(int &$facing) : void{
$this->int(3, match($facing){ $this->writeInt(3, match($facing){
0 => Facing::DOWN, 0 => Facing::DOWN,
1 => Facing::UP, 1 => Facing::UP,
2 => Facing::NORTH, 2 => Facing::NORTH,
@ -95,12 +107,12 @@ final class RuntimeDataWriter{
}); });
} }
public function facingExcept(int $facing, int $except) : void{ public function facingExcept(int &$facing, int $except) : void{
$this->facing($facing); $this->facing($facing);
} }
public function axis(int $axis) : void{ public function axis(int &$axis) : void{
$this->int(2, match($axis){ $this->writeInt(2, match($axis){
Axis::X => 0, Axis::X => 0,
Axis::Z => 1, Axis::Z => 1,
Axis::Y => 2, Axis::Y => 2,
@ -108,8 +120,8 @@ final class RuntimeDataWriter{
}); });
} }
public function horizontalAxis(int $axis) : void{ public function horizontalAxis(int &$axis) : void{
$this->int(1, match($axis){ $this->writeInt(1, match($axis){
Axis::X => 0, Axis::X => 0,
Axis::Z => 1, Axis::Z => 1,
default => throw new \InvalidArgumentException("Invalid horizontal axis $axis") default => throw new \InvalidArgumentException("Invalid horizontal axis $axis")
@ -120,10 +132,10 @@ final class RuntimeDataWriter{
* @param WallConnectionType[] $connections * @param WallConnectionType[] $connections
* @phpstan-param array<Facing::NORTH|Facing::EAST|Facing::SOUTH|Facing::WEST, WallConnectionType> $connections * @phpstan-param array<Facing::NORTH|Facing::EAST|Facing::SOUTH|Facing::WEST, WallConnectionType> $connections
*/ */
public function wallConnections(array $connections) : void{ public function wallConnections(array &$connections) : void{
//TODO: we can pack this into 7 bits instead of 8 //TODO: we can pack this into 7 bits instead of 8
foreach(Facing::HORIZONTAL as $facing){ foreach(Facing::HORIZONTAL as $facing){
$this->boundedInt(2, 0, 2, match($connections[$facing] ?? null){ $this->writeBoundedInt(2, 0, 2, match($connections[$facing] ?? null){
null => 0, null => 0,
WallConnectionType::SHORT() => 1, WallConnectionType::SHORT() => 1,
WallConnectionType::TALL() => 2, WallConnectionType::TALL() => 2,
@ -136,21 +148,21 @@ final class RuntimeDataWriter{
* @param BrewingStandSlot[] $slots * @param BrewingStandSlot[] $slots
* @phpstan-param array<int, BrewingStandSlot> $slots * @phpstan-param array<int, BrewingStandSlot> $slots
*/ */
public function brewingStandSlots(array $slots) : void{ public function brewingStandSlots(array &$slots) : void{
foreach([ foreach([
BrewingStandSlot::EAST(), BrewingStandSlot::EAST(),
BrewingStandSlot::NORTHWEST(), BrewingStandSlot::NORTHWEST(),
BrewingStandSlot::SOUTHWEST(), BrewingStandSlot::SOUTHWEST(),
] as $member){ ] as $member){
$this->bool(isset($slots[$member->id()])); $this->writeBool(isset($slots[$member->id()]));
} }
} }
public function railShape(int $railShape) : void{ public function railShape(int &$railShape) : void{
$this->int(4, $railShape); $this->int(4, $railShape);
} }
public function straightOnlyRailShape(int $railShape) : void{ public function straightOnlyRailShape(int &$railShape) : void{
$this->int(3, $railShape); $this->int(3, $railShape);
} }

View File

@ -0,0 +1,58 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\data\runtime;
/**
* This class is auto-generated. Do not edit it manually.
* @see build/generate-runtime-enum-serializers.php
*/
interface RuntimeEnumDescriber{
public function bellAttachmentType(\pocketmine\block\utils\BellAttachmentType &$value) : void;
public function copperOxidation(\pocketmine\block\utils\CopperOxidation &$value) : void;
public function coralType(\pocketmine\block\utils\CoralType &$value) : void;
public function dirtType(\pocketmine\block\utils\DirtType &$value) : void;
public function dyeColor(\pocketmine\block\utils\DyeColor &$value) : void;
public function froglightType(\pocketmine\block\utils\FroglightType &$value) : void;
public function leverFacing(\pocketmine\block\utils\LeverFacing &$value) : void;
public function medicineType(\pocketmine\item\MedicineType &$value) : void;
public function mushroomBlockType(\pocketmine\block\utils\MushroomBlockType &$value) : void;
public function potionType(\pocketmine\item\PotionType &$value) : void;
public function skullType(\pocketmine\block\utils\SkullType &$value) : void;
public function slabType(\pocketmine\block\utils\SlabType &$value) : void;
public function suspiciousStewType(\pocketmine\item\SuspiciousStewType &$value) : void;
}

View File

@ -29,10 +29,10 @@ namespace pocketmine\data\runtime;
*/ */
trait RuntimeEnumSerializerTrait{ trait RuntimeEnumSerializerTrait{
abstract public function int(int $bits, int $value) : void; abstract protected function writeInt(int $bits, int $value) : void;
public function bellAttachmentType(\pocketmine\block\utils\BellAttachmentType $value) : void{ public function bellAttachmentType(\pocketmine\block\utils\BellAttachmentType &$value) : void{
$this->int(2, match($value){ $this->writeInt(2, match($value){
\pocketmine\block\utils\BellAttachmentType::CEILING() => 0, \pocketmine\block\utils\BellAttachmentType::CEILING() => 0,
\pocketmine\block\utils\BellAttachmentType::FLOOR() => 1, \pocketmine\block\utils\BellAttachmentType::FLOOR() => 1,
\pocketmine\block\utils\BellAttachmentType::ONE_WALL() => 2, \pocketmine\block\utils\BellAttachmentType::ONE_WALL() => 2,
@ -41,8 +41,8 @@ trait RuntimeEnumSerializerTrait{
}); });
} }
public function copperOxidation(\pocketmine\block\utils\CopperOxidation $value) : void{ public function copperOxidation(\pocketmine\block\utils\CopperOxidation &$value) : void{
$this->int(2, match($value){ $this->writeInt(2, match($value){
\pocketmine\block\utils\CopperOxidation::EXPOSED() => 0, \pocketmine\block\utils\CopperOxidation::EXPOSED() => 0,
\pocketmine\block\utils\CopperOxidation::NONE() => 1, \pocketmine\block\utils\CopperOxidation::NONE() => 1,
\pocketmine\block\utils\CopperOxidation::OXIDIZED() => 2, \pocketmine\block\utils\CopperOxidation::OXIDIZED() => 2,
@ -51,8 +51,8 @@ trait RuntimeEnumSerializerTrait{
}); });
} }
public function coralType(\pocketmine\block\utils\CoralType $value) : void{ public function coralType(\pocketmine\block\utils\CoralType &$value) : void{
$this->int(3, match($value){ $this->writeInt(3, match($value){
\pocketmine\block\utils\CoralType::BRAIN() => 0, \pocketmine\block\utils\CoralType::BRAIN() => 0,
\pocketmine\block\utils\CoralType::BUBBLE() => 1, \pocketmine\block\utils\CoralType::BUBBLE() => 1,
\pocketmine\block\utils\CoralType::FIRE() => 2, \pocketmine\block\utils\CoralType::FIRE() => 2,
@ -62,8 +62,8 @@ trait RuntimeEnumSerializerTrait{
}); });
} }
public function dirtType(\pocketmine\block\utils\DirtType $value) : void{ public function dirtType(\pocketmine\block\utils\DirtType &$value) : void{
$this->int(2, match($value){ $this->writeInt(2, match($value){
\pocketmine\block\utils\DirtType::COARSE() => 0, \pocketmine\block\utils\DirtType::COARSE() => 0,
\pocketmine\block\utils\DirtType::NORMAL() => 1, \pocketmine\block\utils\DirtType::NORMAL() => 1,
\pocketmine\block\utils\DirtType::ROOTED() => 2, \pocketmine\block\utils\DirtType::ROOTED() => 2,
@ -71,8 +71,8 @@ trait RuntimeEnumSerializerTrait{
}); });
} }
public function dyeColor(\pocketmine\block\utils\DyeColor $value) : void{ public function dyeColor(\pocketmine\block\utils\DyeColor &$value) : void{
$this->int(4, match($value){ $this->writeInt(4, match($value){
\pocketmine\block\utils\DyeColor::BLACK() => 0, \pocketmine\block\utils\DyeColor::BLACK() => 0,
\pocketmine\block\utils\DyeColor::BLUE() => 1, \pocketmine\block\utils\DyeColor::BLUE() => 1,
\pocketmine\block\utils\DyeColor::BROWN() => 2, \pocketmine\block\utils\DyeColor::BROWN() => 2,
@ -93,8 +93,8 @@ trait RuntimeEnumSerializerTrait{
}); });
} }
public function froglightType(\pocketmine\block\utils\FroglightType $value) : void{ public function froglightType(\pocketmine\block\utils\FroglightType &$value) : void{
$this->int(2, match($value){ $this->writeInt(2, match($value){
\pocketmine\block\utils\FroglightType::OCHRE() => 0, \pocketmine\block\utils\FroglightType::OCHRE() => 0,
\pocketmine\block\utils\FroglightType::PEARLESCENT() => 1, \pocketmine\block\utils\FroglightType::PEARLESCENT() => 1,
\pocketmine\block\utils\FroglightType::VERDANT() => 2, \pocketmine\block\utils\FroglightType::VERDANT() => 2,
@ -102,8 +102,8 @@ trait RuntimeEnumSerializerTrait{
}); });
} }
public function leverFacing(\pocketmine\block\utils\LeverFacing $value) : void{ public function leverFacing(\pocketmine\block\utils\LeverFacing &$value) : void{
$this->int(3, match($value){ $this->writeInt(3, match($value){
\pocketmine\block\utils\LeverFacing::DOWN_AXIS_X() => 0, \pocketmine\block\utils\LeverFacing::DOWN_AXIS_X() => 0,
\pocketmine\block\utils\LeverFacing::DOWN_AXIS_Z() => 1, \pocketmine\block\utils\LeverFacing::DOWN_AXIS_Z() => 1,
\pocketmine\block\utils\LeverFacing::EAST() => 2, \pocketmine\block\utils\LeverFacing::EAST() => 2,
@ -116,8 +116,8 @@ trait RuntimeEnumSerializerTrait{
}); });
} }
public function medicineType(\pocketmine\item\MedicineType $value) : void{ public function medicineType(\pocketmine\item\MedicineType &$value) : void{
$this->int(2, match($value){ $this->writeInt(2, match($value){
\pocketmine\item\MedicineType::ANTIDOTE() => 0, \pocketmine\item\MedicineType::ANTIDOTE() => 0,
\pocketmine\item\MedicineType::ELIXIR() => 1, \pocketmine\item\MedicineType::ELIXIR() => 1,
\pocketmine\item\MedicineType::EYE_DROPS() => 2, \pocketmine\item\MedicineType::EYE_DROPS() => 2,
@ -126,8 +126,8 @@ trait RuntimeEnumSerializerTrait{
}); });
} }
public function mushroomBlockType(\pocketmine\block\utils\MushroomBlockType $value) : void{ public function mushroomBlockType(\pocketmine\block\utils\MushroomBlockType &$value) : void{
$this->int(4, match($value){ $this->writeInt(4, match($value){
\pocketmine\block\utils\MushroomBlockType::ALL_CAP() => 0, \pocketmine\block\utils\MushroomBlockType::ALL_CAP() => 0,
\pocketmine\block\utils\MushroomBlockType::CAP_EAST() => 1, \pocketmine\block\utils\MushroomBlockType::CAP_EAST() => 1,
\pocketmine\block\utils\MushroomBlockType::CAP_MIDDLE() => 2, \pocketmine\block\utils\MushroomBlockType::CAP_MIDDLE() => 2,
@ -143,8 +143,8 @@ trait RuntimeEnumSerializerTrait{
}); });
} }
public function potionType(\pocketmine\item\PotionType $value) : void{ public function potionType(\pocketmine\item\PotionType &$value) : void{
$this->int(6, match($value){ $this->writeInt(6, match($value){
\pocketmine\item\PotionType::AWKWARD() => 0, \pocketmine\item\PotionType::AWKWARD() => 0,
\pocketmine\item\PotionType::FIRE_RESISTANCE() => 1, \pocketmine\item\PotionType::FIRE_RESISTANCE() => 1,
\pocketmine\item\PotionType::HARMING() => 2, \pocketmine\item\PotionType::HARMING() => 2,
@ -191,8 +191,8 @@ trait RuntimeEnumSerializerTrait{
}); });
} }
public function skullType(\pocketmine\block\utils\SkullType $value) : void{ public function skullType(\pocketmine\block\utils\SkullType &$value) : void{
$this->int(3, match($value){ $this->writeInt(3, match($value){
\pocketmine\block\utils\SkullType::CREEPER() => 0, \pocketmine\block\utils\SkullType::CREEPER() => 0,
\pocketmine\block\utils\SkullType::DRAGON() => 1, \pocketmine\block\utils\SkullType::DRAGON() => 1,
\pocketmine\block\utils\SkullType::PLAYER() => 2, \pocketmine\block\utils\SkullType::PLAYER() => 2,
@ -203,8 +203,8 @@ trait RuntimeEnumSerializerTrait{
}); });
} }
public function slabType(\pocketmine\block\utils\SlabType $value) : void{ public function slabType(\pocketmine\block\utils\SlabType &$value) : void{
$this->int(2, match($value){ $this->writeInt(2, match($value){
\pocketmine\block\utils\SlabType::BOTTOM() => 0, \pocketmine\block\utils\SlabType::BOTTOM() => 0,
\pocketmine\block\utils\SlabType::DOUBLE() => 1, \pocketmine\block\utils\SlabType::DOUBLE() => 1,
\pocketmine\block\utils\SlabType::TOP() => 2, \pocketmine\block\utils\SlabType::TOP() => 2,
@ -212,8 +212,8 @@ trait RuntimeEnumSerializerTrait{
}); });
} }
public function suspiciousStewType(\pocketmine\item\SuspiciousStewType $value) : void{ public function suspiciousStewType(\pocketmine\item\SuspiciousStewType &$value) : void{
$this->int(4, match($value){ $this->writeInt(4, match($value){
\pocketmine\item\SuspiciousStewType::ALLIUM() => 0, \pocketmine\item\SuspiciousStewType::ALLIUM() => 0,
\pocketmine\item\SuspiciousStewType::AZURE_BLUET() => 1, \pocketmine\item\SuspiciousStewType::AZURE_BLUET() => 1,
\pocketmine\item\SuspiciousStewType::BLUE_ORCHID() => 2, \pocketmine\item\SuspiciousStewType::BLUE_ORCHID() => 2,

View File

@ -29,8 +29,7 @@ use pocketmine\block\utils\BannerPatternLayer;
use pocketmine\block\utils\DyeColor; use pocketmine\block\utils\DyeColor;
use pocketmine\data\bedrock\BannerPatternTypeIdMap; use pocketmine\data\bedrock\BannerPatternTypeIdMap;
use pocketmine\data\bedrock\DyeColorIdMap; use pocketmine\data\bedrock\DyeColorIdMap;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\nbt\NBT; use pocketmine\nbt\NBT;
use pocketmine\nbt\tag\CompoundTag; use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\tag\ListTag; use pocketmine\nbt\tag\ListTag;
@ -64,7 +63,7 @@ class Banner extends ItemBlockWallOrFloor{
return $this; return $this;
} }
protected function describeType(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeType(RuntimeDataDescriber $w) : void{
$w->dyeColor($this->color); $w->dyeColor($this->color);
} }

View File

@ -27,8 +27,7 @@ use pocketmine\block\Block;
use pocketmine\block\utils\CoralType; use pocketmine\block\utils\CoralType;
use pocketmine\block\utils\CoralTypeTrait; use pocketmine\block\utils\CoralTypeTrait;
use pocketmine\block\VanillaBlocks; use pocketmine\block\VanillaBlocks;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\math\Axis; use pocketmine\math\Axis;
use pocketmine\math\Facing; use pocketmine\math\Facing;
@ -42,7 +41,7 @@ final class CoralFan extends Item{
parent::__construct($identifier, VanillaBlocks::CORAL_FAN()->getName()); parent::__construct($identifier, VanillaBlocks::CORAL_FAN()->getName());
} }
protected function describeType(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeType(RuntimeDataDescriber $w) : void{
//this is aliased to ensure a compile error in case the functions in Item or Block start to differ in future //this is aliased to ensure a compile error in case the functions in Item or Block start to differ in future
//right now we can directly reuse encodeType from CoralTypeTrait, but that might silently stop working if Item //right now we can directly reuse encodeType from CoralTypeTrait, but that might silently stop working if Item
//were to be altered. CoralTypeTrait was originally intended for blocks, so it's better not to assume anything. //were to be altered. CoralTypeTrait was originally intended for blocks, so it's better not to assume anything.

View File

@ -24,8 +24,7 @@ declare(strict_types=1);
namespace pocketmine\item; namespace pocketmine\item;
use pocketmine\block\utils\DyeColor; use pocketmine\block\utils\DyeColor;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
class Dye extends Item{ class Dye extends Item{
private DyeColor $color; private DyeColor $color;
@ -35,7 +34,7 @@ class Dye extends Item{
parent::__construct($identifier, $name); parent::__construct($identifier, $name);
} }
protected function describeType(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeType(RuntimeDataDescriber $w) : void{
$w->dyeColor($this->color); $w->dyeColor($this->color);
} }

View File

@ -32,7 +32,7 @@ use pocketmine\block\BlockToolType;
use pocketmine\block\VanillaBlocks; use pocketmine\block\VanillaBlocks;
use pocketmine\data\bedrock\EnchantmentIdMap; use pocketmine\data\bedrock\EnchantmentIdMap;
use pocketmine\data\bedrock\item\ItemTypeDeserializeException; use pocketmine\data\bedrock\item\ItemTypeDeserializeException;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter; use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\data\SavedDataLoadingException; use pocketmine\data\SavedDataLoadingException;
use pocketmine\entity\Entity; use pocketmine\entity\Entity;
@ -470,7 +470,7 @@ class Item implements \JsonSerializable{
return $writer->getValue(); return $writer->getValue();
} }
protected function describeType(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeType(RuntimeDataDescriber $w) : void{
//NOOP //NOOP
} }

View File

@ -26,8 +26,7 @@ namespace pocketmine\item;
use pocketmine\block\Block; use pocketmine\block\Block;
use pocketmine\block\RuntimeBlockStateRegistry; use pocketmine\block\RuntimeBlockStateRegistry;
use pocketmine\block\VanillaBlocks; use pocketmine\block\VanillaBlocks;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
/** /**
* Class used for Items that directly represent blocks, such as stone, dirt, wood etc. * Class used for Items that directly represent blocks, such as stone, dirt, wood etc.
@ -53,7 +52,7 @@ final class ItemBlock extends Item{
$this->maxStackSize = $block->getMaxStackSize(); $this->maxStackSize = $block->getMaxStackSize();
} }
protected function describeType(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeType(RuntimeDataDescriber $w) : void{
$w->int(Block::INTERNAL_STATE_DATA_BITS, $this->blockTypeData); $w->int(Block::INTERNAL_STATE_DATA_BITS, $this->blockTypeData);
} }

View File

@ -23,8 +23,7 @@ declare(strict_types=1);
namespace pocketmine\item; namespace pocketmine\item;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\entity\Living; use pocketmine\entity\Living;
use pocketmine\player\Player; use pocketmine\player\Player;
@ -37,7 +36,7 @@ class Medicine extends Item implements ConsumableItem{
parent::__construct($identifier, $name); parent::__construct($identifier, $name);
} }
protected function describeType(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeType(RuntimeDataDescriber $w) : void{
$w->medicineType($this->medicineType); $w->medicineType($this->medicineType);
} }

View File

@ -23,8 +23,7 @@ declare(strict_types=1);
namespace pocketmine\item; namespace pocketmine\item;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\entity\Living; use pocketmine\entity\Living;
use pocketmine\player\Player; use pocketmine\player\Player;
@ -37,7 +36,7 @@ class Potion extends Item implements ConsumableItem{
parent::__construct($identifier, $name); parent::__construct($identifier, $name);
} }
protected function describeType(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeType(RuntimeDataDescriber $w) : void{
$w->potionType($this->potionType); $w->potionType($this->potionType);
} }

View File

@ -23,8 +23,7 @@ declare(strict_types=1);
namespace pocketmine\item; namespace pocketmine\item;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\entity\Location; use pocketmine\entity\Location;
use pocketmine\entity\projectile\SplashPotion as SplashPotionEntity; use pocketmine\entity\projectile\SplashPotion as SplashPotionEntity;
use pocketmine\entity\projectile\Throwable; use pocketmine\entity\projectile\Throwable;
@ -39,7 +38,7 @@ class SplashPotion extends ProjectileItem{
parent::__construct($identifier, $name); parent::__construct($identifier, $name);
} }
protected function describeType(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeType(RuntimeDataDescriber $w) : void{
$w->potionType($this->potionType); $w->potionType($this->potionType);
} }

View File

@ -23,8 +23,7 @@ declare(strict_types=1);
namespace pocketmine\item; namespace pocketmine\item;
use pocketmine\data\runtime\RuntimeDataReader; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataWriter;
class SuspiciousStew extends Food{ class SuspiciousStew extends Food{
@ -35,7 +34,7 @@ class SuspiciousStew extends Food{
parent::__construct($identifier, $name); parent::__construct($identifier, $name);
} }
protected function describeType(RuntimeDataReader|RuntimeDataWriter $w) : void{ protected function describeType(RuntimeDataDescriber $w) : void{
$w->suspiciousStewType($this->suspiciousStewType); $w->suspiciousStewType($this->suspiciousStewType);
} }