mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-21 16:24:05 +00:00
Generalize runtime block data serialization
we want to reuse this code for item type data
This commit is contained in:
parent
1714e2fd35
commit
325f1cf82e
@ -28,8 +28,8 @@ use pocketmine\block\utils\Fallable;
|
||||
use pocketmine\block\utils\FallableTrait;
|
||||
use pocketmine\block\utils\HorizontalFacingTrait;
|
||||
use pocketmine\block\utils\SupportType;
|
||||
use pocketmine\data\runtime\block\BlockDataReader;
|
||||
use pocketmine\data\runtime\block\BlockDataWriter;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
use pocketmine\math\Facing;
|
||||
@ -49,21 +49,21 @@ class Anvil extends Transparent implements Fallable{
|
||||
|
||||
public function getRequiredTypeDataBits() : int{ return 2; }
|
||||
|
||||
protected function decodeType(BlockDataReader $r) : void{
|
||||
protected function decodeType(RuntimeDataReader $r) : void{
|
||||
$this->setDamage($r->readBoundedInt(2, self::UNDAMAGED, self::VERY_DAMAGED));
|
||||
}
|
||||
|
||||
protected function encodeType(BlockDataWriter $w) : void{
|
||||
protected function encodeType(RuntimeDataWriter $w) : void{
|
||||
$w->writeInt(2, $this->getDamage());
|
||||
}
|
||||
|
||||
public function getRequiredStateDataBits() : int{ return 2; }
|
||||
|
||||
protected function decodeState(BlockDataReader $r) : void{
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->setFacing($r->readHorizontalFacing());
|
||||
}
|
||||
|
||||
protected function encodeState(BlockDataWriter $w) : void{
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeHorizontalFacing($this->getFacing());
|
||||
}
|
||||
|
||||
|
@ -24,8 +24,8 @@ declare(strict_types=1);
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\SupportType;
|
||||
use pocketmine\data\runtime\block\BlockDataReader;
|
||||
use pocketmine\data\runtime\block\BlockDataWriter;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\event\block\StructureGrowEvent;
|
||||
use pocketmine\item\Bamboo as ItemBamboo;
|
||||
use pocketmine\item\Fertilizer;
|
||||
@ -58,13 +58,13 @@ class Bamboo extends Transparent{
|
||||
|
||||
public function getRequiredStateDataBits() : int{ return 4; }
|
||||
|
||||
protected function decodeState(BlockDataReader $r) : void{
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->setLeafSize($r->readBoundedInt(2, self::NO_LEAVES, self::LARGE_LEAVES));
|
||||
$this->setThick($r->readBool());
|
||||
$this->setReady($r->readBool());
|
||||
}
|
||||
|
||||
protected function encodeState(BlockDataWriter $w) : void{
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeInt(2, $this->getLeafSize());
|
||||
$w->writeBool($this->isThick());
|
||||
$w->writeBool($this->isReady());
|
||||
|
@ -23,8 +23,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\data\runtime\block\BlockDataReader;
|
||||
use pocketmine\data\runtime\block\BlockDataWriter;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\event\block\StructureGrowEvent;
|
||||
use pocketmine\item\Bamboo as ItemBamboo;
|
||||
use pocketmine\item\Fertilizer;
|
||||
@ -39,11 +39,11 @@ final class BambooSapling extends Flowable{
|
||||
|
||||
public function getRequiredStateDataBits() : int{ return 1; }
|
||||
|
||||
protected function decodeState(BlockDataReader $r) : void{
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->setReady($r->readBool());
|
||||
}
|
||||
|
||||
protected function encodeState(BlockDataWriter $w) : void{
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeBool($this->isReady());
|
||||
}
|
||||
|
||||
|
@ -25,8 +25,8 @@ namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\tile\Barrel as TileBarrel;
|
||||
use pocketmine\block\utils\AnyFacingTrait;
|
||||
use pocketmine\data\runtime\block\BlockDataReader;
|
||||
use pocketmine\data\runtime\block\BlockDataWriter;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\Facing;
|
||||
use pocketmine\math\Vector3;
|
||||
@ -41,12 +41,12 @@ class Barrel extends Opaque{
|
||||
|
||||
public function getRequiredStateDataBits() : int{ return 4; }
|
||||
|
||||
protected function decodeState(BlockDataReader $r) : void{
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->setFacing($r->readFacing());
|
||||
$this->setOpen($r->readBool());
|
||||
}
|
||||
|
||||
protected function encodeState(BlockDataWriter $w) : void{
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeFacing($this->getFacing());
|
||||
$w->writeBool($this->isOpen());
|
||||
}
|
||||
|
@ -28,8 +28,8 @@ use pocketmine\block\utils\ColoredTrait;
|
||||
use pocketmine\block\utils\DyeColor;
|
||||
use pocketmine\block\utils\HorizontalFacingTrait;
|
||||
use pocketmine\block\utils\SupportType;
|
||||
use pocketmine\data\runtime\block\BlockDataReader;
|
||||
use pocketmine\data\runtime\block\BlockDataWriter;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\entity\Entity;
|
||||
use pocketmine\entity\Living;
|
||||
use pocketmine\item\Item;
|
||||
@ -56,13 +56,13 @@ class Bed extends Transparent{
|
||||
|
||||
public function getRequiredStateDataBits() : int{ return 4; }
|
||||
|
||||
protected function decodeState(BlockDataReader $r) : void{
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->facing = $r->readHorizontalFacing();
|
||||
$this->occupied = $r->readBool();
|
||||
$this->head = $r->readBool();
|
||||
}
|
||||
|
||||
protected function encodeState(BlockDataWriter $w) : void{
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeHorizontalFacing($this->facing);
|
||||
$w->writeBool($this->occupied);
|
||||
$w->writeBool($this->head);
|
||||
|
@ -23,19 +23,19 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\data\runtime\block\BlockDataReader;
|
||||
use pocketmine\data\runtime\block\BlockDataWriter;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
|
||||
class Bedrock extends Opaque{
|
||||
private bool $burnsForever = false;
|
||||
|
||||
public function getRequiredStateDataBits() : int{ return 1; }
|
||||
|
||||
protected function decodeState(BlockDataReader $r) : void{
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->burnsForever = $r->readBool();
|
||||
}
|
||||
|
||||
protected function encodeState(BlockDataWriter $w) : void{
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeBool($this->burnsForever);
|
||||
}
|
||||
|
||||
|
@ -27,10 +27,10 @@ use pocketmine\block\tile\Bell as TileBell;
|
||||
use pocketmine\block\utils\BellAttachmentType;
|
||||
use pocketmine\block\utils\HorizontalFacingTrait;
|
||||
use pocketmine\block\utils\SupportType;
|
||||
use pocketmine\data\runtime\block\BlockDataReader;
|
||||
use pocketmine\data\runtime\block\BlockDataReaderHelper;
|
||||
use pocketmine\data\runtime\block\BlockDataWriter;
|
||||
use pocketmine\data\runtime\block\BlockDataWriterHelper;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\data\runtime\RuntimeEnumDeserializer;
|
||||
use pocketmine\data\runtime\RuntimeEnumSerializer;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
use pocketmine\math\Facing;
|
||||
@ -51,13 +51,13 @@ final class Bell extends Transparent{
|
||||
|
||||
public function getRequiredStateDataBits() : int{ return 4; }
|
||||
|
||||
protected function decodeState(BlockDataReader $r) : void{
|
||||
$this->attachmentType = BlockDataReaderHelper::readBellAttachmentType($r);
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->attachmentType = RuntimeEnumDeserializer::readBellAttachmentType($r);
|
||||
$this->facing = $r->readHorizontalFacing();
|
||||
}
|
||||
|
||||
protected function encodeState(BlockDataWriter $w) : void{
|
||||
BlockDataWriterHelper::writeBellAttachmentType($w, $this->attachmentType);
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
RuntimeEnumSerializer::writeBellAttachmentType($w, $this->attachmentType);
|
||||
$w->writeHorizontalFacing($this->facing);
|
||||
}
|
||||
|
||||
|
@ -29,8 +29,8 @@ namespace pocketmine\block;
|
||||
use pocketmine\block\tile\Spawnable;
|
||||
use pocketmine\block\tile\Tile;
|
||||
use pocketmine\block\utils\SupportType;
|
||||
use pocketmine\data\runtime\block\BlockDataReader;
|
||||
use pocketmine\data\runtime\block\BlockDataWriter;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\entity\Entity;
|
||||
use pocketmine\item\enchantment\VanillaEnchantments;
|
||||
use pocketmine\item\Item;
|
||||
@ -100,7 +100,7 @@ class Block{
|
||||
final public function decodeTypeData(int $data) : void{
|
||||
$typeBits = $this->getRequiredTypeDataBits();
|
||||
$givenBits = $typeBits;
|
||||
$reader = new BlockDataReader($givenBits, $data);
|
||||
$reader = new RuntimeDataReader($givenBits, $data);
|
||||
|
||||
$this->decodeType($reader);
|
||||
$readBits = $reader->getOffset();
|
||||
@ -113,7 +113,7 @@ class Block{
|
||||
$typeBits = $this->getRequiredTypeDataBits();
|
||||
$stateBits = $this->getRequiredStateDataBits();
|
||||
$givenBits = $typeBits + $stateBits;
|
||||
$reader = new BlockDataReader($givenBits, $data);
|
||||
$reader = new RuntimeDataReader($givenBits, $data);
|
||||
$this->decodeTypeData($reader->readInt($typeBits));
|
||||
|
||||
$this->decodeState($reader);
|
||||
@ -123,18 +123,18 @@ class Block{
|
||||
}
|
||||
}
|
||||
|
||||
protected function decodeType(BlockDataReader $r) : void{
|
||||
protected function decodeType(RuntimeDataReader $r) : void{
|
||||
//NOOP
|
||||
}
|
||||
|
||||
protected function decodeState(BlockDataReader $r) : void{
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
//NOOP
|
||||
}
|
||||
|
||||
final public function computeTypeData() : int{
|
||||
$typeBits = $this->getRequiredTypeDataBits();
|
||||
$requiredBits = $typeBits;
|
||||
$writer = new BlockDataWriter($requiredBits);
|
||||
$writer = new RuntimeDataWriter($requiredBits);
|
||||
|
||||
$this->encodeType($writer);
|
||||
$writtenBits = $writer->getOffset();
|
||||
@ -152,7 +152,7 @@ class Block{
|
||||
$typeBits = $this->getRequiredTypeDataBits();
|
||||
$stateBits = $this->getRequiredStateDataBits();
|
||||
$requiredBits = $typeBits + $stateBits;
|
||||
$writer = new BlockDataWriter($requiredBits);
|
||||
$writer = new RuntimeDataWriter($requiredBits);
|
||||
$writer->writeInt($typeBits, $this->computeTypeData());
|
||||
|
||||
$this->encodeState($writer);
|
||||
@ -164,11 +164,11 @@ class Block{
|
||||
return $writer->getValue();
|
||||
}
|
||||
|
||||
protected function encodeType(BlockDataWriter $w) : void{
|
||||
protected function encodeType(RuntimeDataWriter $w) : void{
|
||||
//NOOP
|
||||
}
|
||||
|
||||
protected function encodeState(BlockDataWriter $w) : void{
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
//NOOP
|
||||
}
|
||||
|
||||
|
@ -50,9 +50,9 @@ use pocketmine\block\tile\Note as TileNote;
|
||||
use pocketmine\block\tile\ShulkerBox as TileShulkerBox;
|
||||
use pocketmine\block\tile\Skull as TileSkull;
|
||||
use pocketmine\block\tile\Smoker as TileSmoker;
|
||||
use pocketmine\block\utils\InvalidBlockStateException;
|
||||
use pocketmine\block\utils\TreeType;
|
||||
use pocketmine\block\utils\WoodType;
|
||||
use pocketmine\data\runtime\InvalidSerializedRuntimeDataException;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\ToolTier;
|
||||
use pocketmine\utils\AssumptionFailedError;
|
||||
@ -829,9 +829,9 @@ class BlockFactory{
|
||||
$v->decodeStateData($stateData);
|
||||
if($v->computeStateData() !== $stateData){
|
||||
//if the fullID comes back different, this is a broken state that we can't rely on; map it to default
|
||||
throw new InvalidBlockStateException("Corrupted state");
|
||||
throw new InvalidSerializedRuntimeDataException("Corrupted state");
|
||||
}
|
||||
}catch(InvalidBlockStateException $e){ //invalid property combination, leave it
|
||||
}catch(InvalidSerializedRuntimeDataException $e){ //invalid property combination, leave it
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -26,10 +26,8 @@ namespace pocketmine\block;
|
||||
use pocketmine\block\tile\BrewingStand as TileBrewingStand;
|
||||
use pocketmine\block\utils\BrewingStandSlot;
|
||||
use pocketmine\block\utils\SupportType;
|
||||
use pocketmine\data\runtime\block\BlockDataReader;
|
||||
use pocketmine\data\runtime\block\BlockDataReaderHelper;
|
||||
use pocketmine\data\runtime\block\BlockDataWriter;
|
||||
use pocketmine\data\runtime\block\BlockDataWriterHelper;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\Axis;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
@ -48,12 +46,29 @@ class BrewingStand extends Transparent{
|
||||
|
||||
public function getRequiredStateDataBits() : int{ return 3; }
|
||||
|
||||
protected function decodeState(BlockDataReader $r) : void{
|
||||
$this->setSlots(BlockDataReaderHelper::readBrewingStandSlotKeySet($r));
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$result = [];
|
||||
foreach([
|
||||
BrewingStandSlot::EAST(),
|
||||
BrewingStandSlot::NORTHWEST(),
|
||||
BrewingStandSlot::SOUTHWEST(),
|
||||
] as $member){
|
||||
if($r->readBool()){
|
||||
$result[$member->id()] = $member;
|
||||
}
|
||||
}
|
||||
|
||||
$this->setSlots($result);
|
||||
}
|
||||
|
||||
protected function encodeState(BlockDataWriter $w) : void{
|
||||
BlockDataWriterHelper::writeBrewingStandSlotKeySet($w, $this->slots);
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
foreach([
|
||||
\pocketmine\block\utils\BrewingStandSlot::EAST(),
|
||||
\pocketmine\block\utils\BrewingStandSlot::NORTHWEST(),
|
||||
\pocketmine\block\utils\BrewingStandSlot::SOUTHWEST(),
|
||||
] as $member){
|
||||
$w->writeBool(isset($this->slots[$member->id()]));
|
||||
}
|
||||
}
|
||||
|
||||
protected function recalculateCollisionBoxes() : array{
|
||||
|
@ -24,8 +24,8 @@ declare(strict_types=1);
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\AnyFacingTrait;
|
||||
use pocketmine\data\runtime\block\BlockDataReader;
|
||||
use pocketmine\data\runtime\block\BlockDataWriter;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\Facing;
|
||||
use pocketmine\math\Vector3;
|
||||
@ -41,12 +41,12 @@ abstract class Button extends Flowable{
|
||||
|
||||
public function getRequiredStateDataBits() : int{ return 4; }
|
||||
|
||||
protected function decodeState(BlockDataReader $r) : void{
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->facing = $r->readFacing();
|
||||
$this->pressed = $r->readBool();
|
||||
}
|
||||
|
||||
protected function encodeState(BlockDataWriter $w) : void{
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeFacing($this->facing);
|
||||
$w->writeBool($this->pressed);
|
||||
}
|
||||
|
@ -24,8 +24,8 @@ declare(strict_types=1);
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\SupportType;
|
||||
use pocketmine\data\runtime\block\BlockDataReader;
|
||||
use pocketmine\data\runtime\block\BlockDataWriter;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\entity\Entity;
|
||||
use pocketmine\event\block\BlockGrowEvent;
|
||||
use pocketmine\event\entity\EntityDamageByBlockEvent;
|
||||
@ -44,11 +44,11 @@ class Cactus extends Transparent{
|
||||
|
||||
public function getRequiredStateDataBits() : int{ return 4; }
|
||||
|
||||
protected function decodeState(BlockDataReader $r) : void{
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->age = $r->readBoundedInt(4, 0, self::MAX_AGE);
|
||||
}
|
||||
|
||||
protected function encodeState(BlockDataWriter $w) : void{
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeInt(4, $this->age);
|
||||
}
|
||||
|
||||
|
@ -24,8 +24,8 @@ declare(strict_types=1);
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\SupportType;
|
||||
use pocketmine\data\runtime\block\BlockDataReader;
|
||||
use pocketmine\data\runtime\block\BlockDataWriter;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\entity\effect\EffectInstance;
|
||||
use pocketmine\entity\FoodSource;
|
||||
use pocketmine\entity\Living;
|
||||
@ -43,11 +43,11 @@ class Cake extends Transparent implements FoodSource{
|
||||
|
||||
public function getRequiredStateDataBits() : int{ return 3; }
|
||||
|
||||
protected function decodeState(BlockDataReader $r) : void{
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->bites = $r->readBoundedInt(3, 0, self::MAX_BITES);
|
||||
}
|
||||
|
||||
protected function encodeState(BlockDataWriter $w) : void{
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeInt(3, $this->bites);
|
||||
}
|
||||
|
||||
|
@ -26,8 +26,8 @@ namespace pocketmine\block;
|
||||
use pocketmine\block\utils\HorizontalFacingTrait;
|
||||
use pocketmine\block\utils\SupportType;
|
||||
use pocketmine\block\utils\WoodType;
|
||||
use pocketmine\data\runtime\block\BlockDataReader;
|
||||
use pocketmine\data\runtime\block\BlockDataWriter;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\event\block\BlockGrowEvent;
|
||||
use pocketmine\item\Fertilizer;
|
||||
use pocketmine\item\Item;
|
||||
@ -49,12 +49,12 @@ class CocoaBlock extends Transparent{
|
||||
|
||||
public function getRequiredStateDataBits() : int{ return 4; }
|
||||
|
||||
protected function decodeState(BlockDataReader $r) : void{
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->facing = $r->readHorizontalFacing();
|
||||
$this->age = $r->readBoundedInt(2, 0, self::MAX_AGE);
|
||||
}
|
||||
|
||||
protected function encodeState(BlockDataWriter $w) : void{
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeHorizontalFacing($this->facing);
|
||||
$w->writeInt(2, $this->age);
|
||||
}
|
||||
|
@ -23,8 +23,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\data\runtime\block\BlockDataReader;
|
||||
use pocketmine\data\runtime\block\BlockDataWriter;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\event\block\BlockGrowEvent;
|
||||
use pocketmine\item\Fertilizer;
|
||||
use pocketmine\item\Item;
|
||||
@ -41,11 +41,11 @@ abstract class Crops extends Flowable{
|
||||
|
||||
public function getRequiredStateDataBits() : int{ return 3; }
|
||||
|
||||
protected function decodeState(BlockDataReader $r) : void{
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->age = $r->readBoundedInt(3, 0, self::MAX_AGE);
|
||||
}
|
||||
|
||||
protected function encodeState(BlockDataWriter $w) : void{
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeInt(3, $this->age);
|
||||
}
|
||||
|
||||
|
@ -25,8 +25,8 @@ namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\AnalogRedstoneSignalEmitterTrait;
|
||||
use pocketmine\block\utils\SupportType;
|
||||
use pocketmine\data\runtime\block\BlockDataReader;
|
||||
use pocketmine\data\runtime\block\BlockDataWriter;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
use pocketmine\math\Facing;
|
||||
@ -44,12 +44,12 @@ class DaylightSensor extends Transparent{
|
||||
|
||||
public function getRequiredStateDataBits() : int{ return 5; }
|
||||
|
||||
protected function decodeState(BlockDataReader $r) : void{
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->signalStrength = $r->readBoundedInt(4, 0, 15);
|
||||
$this->inverted = $r->readBool();
|
||||
}
|
||||
|
||||
protected function encodeState(BlockDataWriter $w) : void{
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeInt(4, $this->signalStrength);
|
||||
$w->writeBool($this->inverted);
|
||||
}
|
||||
|
@ -23,20 +23,20 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\data\runtime\block\BlockDataReader;
|
||||
use pocketmine\data\runtime\block\BlockDataWriter;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
|
||||
class DetectorRail extends StraightOnlyRail{
|
||||
protected bool $activated = false;
|
||||
|
||||
public function getRequiredStateDataBits() : int{ return 4; }
|
||||
|
||||
protected function decodeState(BlockDataReader $r) : void{
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
parent::decodeState($r);
|
||||
$this->activated = $r->readBool();
|
||||
}
|
||||
|
||||
protected function encodeState(BlockDataWriter $w) : void{
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
parent::encodeState($w);
|
||||
$w->writeBool($this->activated);
|
||||
}
|
||||
|
@ -23,8 +23,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\data\runtime\block\BlockDataReader;
|
||||
use pocketmine\data\runtime\block\BlockDataWriter;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\item\Hoe;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\Facing;
|
||||
@ -37,11 +37,11 @@ class Dirt extends Opaque{
|
||||
|
||||
public function getRequiredTypeDataBits() : int{ return 1; }
|
||||
|
||||
protected function decodeType(BlockDataReader $r) : void{
|
||||
protected function decodeType(RuntimeDataReader $r) : void{
|
||||
$this->coarse = $r->readBool();
|
||||
}
|
||||
|
||||
protected function encodeType(BlockDataWriter $w) : void{
|
||||
protected function encodeType(RuntimeDataWriter $w) : void{
|
||||
$w->writeBool($this->coarse);
|
||||
}
|
||||
|
||||
|
@ -25,8 +25,8 @@ namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\HorizontalFacingTrait;
|
||||
use pocketmine\block\utils\SupportType;
|
||||
use pocketmine\data\runtime\block\BlockDataReader;
|
||||
use pocketmine\data\runtime\block\BlockDataWriter;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
use pocketmine\math\Facing;
|
||||
@ -44,14 +44,14 @@ class Door extends Transparent{
|
||||
|
||||
public function getRequiredStateDataBits() : int{ return 5; }
|
||||
|
||||
protected function decodeState(BlockDataReader $r) : void{
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->facing = $r->readHorizontalFacing();
|
||||
$this->top = $r->readBool();
|
||||
$this->hingeRight = $r->readBool();
|
||||
$this->open = $r->readBool();
|
||||
}
|
||||
|
||||
protected function encodeState(BlockDataWriter $w) : void{
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeHorizontalFacing($this->facing);
|
||||
$w->writeBool($this->top);
|
||||
$w->writeBool($this->hingeRight);
|
||||
|
@ -23,8 +23,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\data\runtime\block\BlockDataReader;
|
||||
use pocketmine\data\runtime\block\BlockDataWriter;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\Facing;
|
||||
use pocketmine\math\Vector3;
|
||||
@ -36,11 +36,11 @@ class DoublePlant extends Flowable{
|
||||
|
||||
public function getRequiredStateDataBits() : int{ return 1; }
|
||||
|
||||
protected function decodeState(BlockDataReader $r) : void{
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->top = $r->readBool();
|
||||
}
|
||||
|
||||
protected function encodeState(BlockDataWriter $w) : void{
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeBool($this->top);
|
||||
}
|
||||
|
||||
|
@ -25,8 +25,8 @@ namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\FacesOppositePlacingPlayerTrait;
|
||||
use pocketmine\block\utils\HorizontalFacingTrait;
|
||||
use pocketmine\data\runtime\block\BlockDataReader;
|
||||
use pocketmine\data\runtime\block\BlockDataWriter;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
use pocketmine\math\Facing;
|
||||
|
||||
@ -38,12 +38,12 @@ class EndPortalFrame extends Opaque{
|
||||
|
||||
public function getRequiredStateDataBits() : int{ return 3; }
|
||||
|
||||
protected function decodeState(BlockDataReader $r) : void{
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->facing = $r->readHorizontalFacing();
|
||||
$this->eye = $r->readBool();
|
||||
}
|
||||
|
||||
protected function encodeState(BlockDataWriter $w) : void{
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeHorizontalFacing($this->facing);
|
||||
$w->writeBool($this->eye);
|
||||
}
|
||||
|
@ -23,8 +23,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\data\runtime\block\BlockDataReader;
|
||||
use pocketmine\data\runtime\block\BlockDataWriter;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\entity\Entity;
|
||||
use pocketmine\entity\Living;
|
||||
use pocketmine\event\entity\EntityTrampleFarmlandEvent;
|
||||
@ -40,11 +40,11 @@ class Farmland extends Transparent{
|
||||
|
||||
public function getRequiredStateDataBits() : int{ return 3; }
|
||||
|
||||
protected function decodeState(BlockDataReader $r) : void{
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->wetness = $r->readBoundedInt(3, 0, self::MAX_WETNESS);
|
||||
}
|
||||
|
||||
protected function encodeState(BlockDataWriter $w) : void{
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeInt(3, $this->wetness);
|
||||
}
|
||||
|
||||
|
@ -26,8 +26,8 @@ namespace pocketmine\block;
|
||||
use pocketmine\block\utils\HorizontalFacingTrait;
|
||||
use pocketmine\block\utils\SupportType;
|
||||
use pocketmine\block\utils\WoodTypeTrait;
|
||||
use pocketmine\data\runtime\block\BlockDataReader;
|
||||
use pocketmine\data\runtime\block\BlockDataWriter;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
use pocketmine\math\Facing;
|
||||
@ -45,13 +45,13 @@ class FenceGate extends Transparent{
|
||||
|
||||
public function getRequiredStateDataBits() : int{ return 4; }
|
||||
|
||||
protected function decodeState(BlockDataReader $r) : void{
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->facing = $r->readHorizontalFacing();
|
||||
$this->open = $r->readBool();
|
||||
$this->inWall = $r->readBool();
|
||||
}
|
||||
|
||||
protected function encodeState(BlockDataWriter $w) : void{
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeHorizontalFacing($this->facing);
|
||||
$w->writeBool($this->open);
|
||||
$w->writeBool($this->inWall);
|
||||
|
@ -23,8 +23,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\data\runtime\block\BlockDataReader;
|
||||
use pocketmine\data\runtime\block\BlockDataWriter;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\event\block\BlockBurnEvent;
|
||||
use pocketmine\event\block\BlockSpreadEvent;
|
||||
use pocketmine\math\Facing;
|
||||
@ -42,11 +42,11 @@ class Fire extends BaseFire{
|
||||
|
||||
public function getRequiredStateDataBits() : int{ return 4; }
|
||||
|
||||
protected function decodeState(BlockDataReader $r) : void{
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->age = $r->readBoundedInt(4, 0, self::MAX_AGE);
|
||||
}
|
||||
|
||||
protected function encodeState(BlockDataWriter $w) : void{
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeInt(4, $this->age);
|
||||
}
|
||||
|
||||
|
@ -23,8 +23,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\data\runtime\block\BlockDataReader;
|
||||
use pocketmine\data\runtime\block\BlockDataWriter;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\VanillaItems;
|
||||
use pocketmine\math\Axis;
|
||||
@ -40,11 +40,11 @@ final class FloorCoralFan extends BaseCoral{
|
||||
|
||||
public function getRequiredStateDataBits() : int{ return parent::getRequiredStateDataBits() + 1; }
|
||||
|
||||
protected function decodeState(BlockDataReader $r) : void{
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->axis = $r->readHorizontalAxis();
|
||||
}
|
||||
|
||||
protected function encodeState(BlockDataWriter $w) : void{
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeHorizontalAxis($this->axis);
|
||||
}
|
||||
|
||||
|
@ -23,8 +23,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\data\runtime\block\BlockDataReader;
|
||||
use pocketmine\data\runtime\block\BlockDataWriter;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\event\block\BlockMeltEvent;
|
||||
use function mt_rand;
|
||||
|
||||
@ -35,11 +35,11 @@ class FrostedIce extends Ice{
|
||||
|
||||
public function getRequiredStateDataBits() : int{ return 2; }
|
||||
|
||||
protected function decodeState(BlockDataReader $r) : void{
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->age = $r->readBoundedInt(2, 0, self::MAX_AGE);
|
||||
}
|
||||
|
||||
protected function encodeState(BlockDataWriter $w) : void{
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeInt(2, $this->age);
|
||||
}
|
||||
|
||||
|
@ -26,8 +26,8 @@ namespace pocketmine\block;
|
||||
use pocketmine\block\tile\Furnace as TileFurnace;
|
||||
use pocketmine\block\utils\FacesOppositePlacingPlayerTrait;
|
||||
use pocketmine\block\utils\HorizontalFacingTrait;
|
||||
use pocketmine\data\runtime\block\BlockDataReader;
|
||||
use pocketmine\data\runtime\block\BlockDataWriter;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\player\Player;
|
||||
@ -41,12 +41,12 @@ class Furnace extends Opaque{
|
||||
|
||||
public function getRequiredStateDataBits() : int{ return 3; }
|
||||
|
||||
protected function decodeState(BlockDataReader $r) : void{
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->facing = $r->readHorizontalFacing();
|
||||
$this->lit = $r->readBool();
|
||||
}
|
||||
|
||||
protected function encodeState(BlockDataWriter $w) : void{
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeHorizontalFacing($this->facing);
|
||||
$w->writeBool($this->lit);
|
||||
}
|
||||
|
@ -24,11 +24,11 @@ declare(strict_types=1);
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\tile\Hopper as TileHopper;
|
||||
use pocketmine\block\utils\InvalidBlockStateException;
|
||||
use pocketmine\block\utils\PoweredByRedstoneTrait;
|
||||
use pocketmine\block\utils\SupportType;
|
||||
use pocketmine\data\runtime\block\BlockDataReader;
|
||||
use pocketmine\data\runtime\block\BlockDataWriter;
|
||||
use pocketmine\data\runtime\InvalidSerializedRuntimeDataException;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
use pocketmine\math\Facing;
|
||||
@ -43,16 +43,16 @@ class Hopper extends Transparent{
|
||||
|
||||
public function getRequiredStateDataBits() : int{ return 4; }
|
||||
|
||||
protected function decodeState(BlockDataReader $r) : void{
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$facing = $r->readFacing();
|
||||
if($facing === Facing::UP){
|
||||
throw new InvalidBlockStateException("Hopper may not face upward");
|
||||
throw new InvalidSerializedRuntimeDataException("Hopper may not face upward");
|
||||
}
|
||||
$this->facing = $facing;
|
||||
$this->powered = $r->readBool();
|
||||
}
|
||||
|
||||
protected function encodeState(BlockDataWriter $w) : void{
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeFacing($this->facing);
|
||||
$w->writeBool($this->powered);
|
||||
}
|
||||
|
@ -25,8 +25,8 @@ namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\tile\ItemFrame as TileItemFrame;
|
||||
use pocketmine\block\utils\AnyFacingTrait;
|
||||
use pocketmine\data\runtime\block\BlockDataReader;
|
||||
use pocketmine\data\runtime\block\BlockDataWriter;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\Facing;
|
||||
use pocketmine\math\Vector3;
|
||||
@ -49,12 +49,12 @@ class ItemFrame extends Flowable{
|
||||
|
||||
public function getRequiredStateDataBits() : int{ return 4; }
|
||||
|
||||
protected function decodeState(BlockDataReader $r) : void{
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->facing = $r->readFacing();
|
||||
$this->hasMap = $r->readBool();
|
||||
}
|
||||
|
||||
protected function encodeState(BlockDataWriter $w) : void{
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeFacing($this->facing);
|
||||
$w->writeBool($this->hasMap);
|
||||
}
|
||||
|
@ -24,8 +24,8 @@ declare(strict_types=1);
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\SupportType;
|
||||
use pocketmine\data\runtime\block\BlockDataReader;
|
||||
use pocketmine\data\runtime\block\BlockDataWriter;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\Axis;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
@ -39,11 +39,11 @@ class Lantern extends Transparent{
|
||||
|
||||
public function getRequiredStateDataBits() : int{ return 1; }
|
||||
|
||||
protected function decodeState(BlockDataReader $r) : void{
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->hanging = $r->readBool();
|
||||
}
|
||||
|
||||
protected function encodeState(BlockDataWriter $w) : void{
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeBool($this->hanging);
|
||||
}
|
||||
|
||||
|
@ -25,8 +25,8 @@ namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\SupportType;
|
||||
use pocketmine\block\utils\TreeType;
|
||||
use pocketmine\data\runtime\block\BlockDataReader;
|
||||
use pocketmine\data\runtime\block\BlockDataWriter;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\event\block\LeavesDecayEvent;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\VanillaItems;
|
||||
@ -50,12 +50,12 @@ class Leaves extends Transparent{
|
||||
|
||||
public function getRequiredStateDataBits() : int{ return 2; }
|
||||
|
||||
protected function decodeState(BlockDataReader $r) : void{
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->noDecay = $r->readBool();
|
||||
$this->checkDecay = $r->readBool();
|
||||
}
|
||||
|
||||
protected function encodeState(BlockDataWriter $w) : void{
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeBool($this->noDecay);
|
||||
$w->writeBool($this->checkDecay);
|
||||
}
|
||||
|
@ -27,8 +27,8 @@ use pocketmine\block\tile\Lectern as TileLectern;
|
||||
use pocketmine\block\utils\FacesOppositePlacingPlayerTrait;
|
||||
use pocketmine\block\utils\HorizontalFacingTrait;
|
||||
use pocketmine\block\utils\SupportType;
|
||||
use pocketmine\data\runtime\block\BlockDataReader;
|
||||
use pocketmine\data\runtime\block\BlockDataWriter;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\WritableBookBase;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
@ -49,12 +49,12 @@ class Lectern extends Transparent{
|
||||
|
||||
public function getRequiredStateDataBits() : int{ return 3; }
|
||||
|
||||
protected function decodeState(BlockDataReader $r) : void{
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->facing = $r->readHorizontalFacing();
|
||||
$this->producingSignal = $r->readBool();
|
||||
}
|
||||
|
||||
protected function encodeState(BlockDataWriter $w) : void{
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeHorizontalFacing($this->facing);
|
||||
$w->writeBool($this->producingSignal);
|
||||
}
|
||||
|
@ -24,10 +24,10 @@ declare(strict_types=1);
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\LeverFacing;
|
||||
use pocketmine\data\runtime\block\BlockDataReader;
|
||||
use pocketmine\data\runtime\block\BlockDataReaderHelper;
|
||||
use pocketmine\data\runtime\block\BlockDataWriter;
|
||||
use pocketmine\data\runtime\block\BlockDataWriterHelper;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\data\runtime\RuntimeEnumDeserializer;
|
||||
use pocketmine\data\runtime\RuntimeEnumSerializer;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\Axis;
|
||||
use pocketmine\math\Facing;
|
||||
@ -49,13 +49,13 @@ class Lever extends Flowable{
|
||||
|
||||
public function getRequiredStateDataBits() : int{ return 4; }
|
||||
|
||||
protected function decodeState(BlockDataReader $r) : void{
|
||||
$this->facing = BlockDataReaderHelper::readLeverFacing($r);
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->facing = RuntimeEnumDeserializer::readLeverFacing($r);
|
||||
$this->activated = $r->readBool();
|
||||
}
|
||||
|
||||
protected function encodeState(BlockDataWriter $w) : void{
|
||||
BlockDataWriterHelper::writeLeverFacing($w, $this->facing);
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
RuntimeEnumSerializer::writeLeverFacing($w, $this->facing);
|
||||
$w->writeBool($this->activated);
|
||||
}
|
||||
|
||||
|
@ -23,8 +23,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\data\runtime\block\BlockDataReader;
|
||||
use pocketmine\data\runtime\block\BlockDataWriter;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\player\Player;
|
||||
@ -37,11 +37,11 @@ final class Light extends Flowable{
|
||||
|
||||
public function getRequiredTypeDataBits() : int{ return 4; }
|
||||
|
||||
protected function decodeType(BlockDataReader $r) : void{
|
||||
protected function decodeType(RuntimeDataReader $r) : void{
|
||||
$this->level = $r->readBoundedInt(4, self::MIN_LIGHT_LEVEL, self::MAX_LIGHT_LEVEL);
|
||||
}
|
||||
|
||||
protected function encodeType(BlockDataWriter $w) : void{
|
||||
protected function encodeType(RuntimeDataWriter $w) : void{
|
||||
$w->writeInt(4, $this->level);
|
||||
}
|
||||
|
||||
|
@ -25,8 +25,8 @@ namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\MinimumCostFlowCalculator;
|
||||
use pocketmine\block\utils\SupportType;
|
||||
use pocketmine\data\runtime\block\BlockDataReader;
|
||||
use pocketmine\data\runtime\block\BlockDataWriter;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\entity\Entity;
|
||||
use pocketmine\event\block\BlockFormEvent;
|
||||
use pocketmine\event\block\BlockSpreadEvent;
|
||||
@ -51,13 +51,13 @@ abstract class Liquid extends Transparent{
|
||||
|
||||
public function getRequiredStateDataBits() : int{ return 5; }
|
||||
|
||||
protected function decodeState(BlockDataReader $r) : void{
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->decay = $r->readBoundedInt(3, 0, self::MAX_DECAY);
|
||||
$this->falling = $r->readBool();
|
||||
$this->still = $r->readBool();
|
||||
}
|
||||
|
||||
protected function encodeState(BlockDataWriter $w) : void{
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeInt(3, $this->decay);
|
||||
$w->writeBool($this->falling);
|
||||
$w->writeBool($this->still);
|
||||
|
@ -24,8 +24,8 @@ declare(strict_types=1);
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\SupportType;
|
||||
use pocketmine\data\runtime\block\BlockDataReader;
|
||||
use pocketmine\data\runtime\block\BlockDataWriter;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\entity\Entity;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\Axis;
|
||||
@ -37,11 +37,11 @@ class NetherPortal extends Transparent{
|
||||
|
||||
public function getRequiredStateDataBits() : int{ return 1; }
|
||||
|
||||
protected function decodeState(BlockDataReader $r) : void{
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->axis = $r->readHorizontalAxis();
|
||||
}
|
||||
|
||||
protected function encodeState(BlockDataWriter $w) : void{
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeHorizontalAxis($this->axis);
|
||||
}
|
||||
|
||||
|
@ -23,8 +23,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\data\runtime\block\BlockDataReader;
|
||||
use pocketmine\data\runtime\block\BlockDataWriter;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\event\block\BlockGrowEvent;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\Facing;
|
||||
@ -40,11 +40,11 @@ class NetherWartPlant extends Flowable{
|
||||
|
||||
public function getRequiredStateDataBits() : int{ return 2; }
|
||||
|
||||
protected function decodeState(BlockDataReader $r) : void{
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->age = $r->readBoundedInt(2, 0, self::MAX_AGE);
|
||||
}
|
||||
|
||||
protected function encodeState(BlockDataWriter $w) : void{
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeInt(2, $this->age);
|
||||
}
|
||||
|
||||
|
@ -23,11 +23,11 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\InvalidBlockStateException;
|
||||
use pocketmine\block\utils\RailConnectionInfo;
|
||||
use pocketmine\data\bedrock\block\BlockLegacyMetadata;
|
||||
use pocketmine\data\runtime\block\BlockDataReader;
|
||||
use pocketmine\data\runtime\block\BlockDataWriter;
|
||||
use pocketmine\data\runtime\InvalidSerializedRuntimeDataException;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\math\Facing;
|
||||
use function array_keys;
|
||||
use function implode;
|
||||
@ -38,15 +38,15 @@ class Rail extends BaseRail{
|
||||
|
||||
public function getRequiredStateDataBits() : int{ return 4; }
|
||||
|
||||
protected function decodeState(BlockDataReader $r) : void{
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$railShape = $r->readInt(4);
|
||||
if(!isset(RailConnectionInfo::CONNECTIONS[$railShape]) && !isset(RailConnectionInfo::CURVE_CONNECTIONS[$railShape])){
|
||||
throw new InvalidBlockStateException("Invalid rail shape $railShape");
|
||||
throw new InvalidSerializedRuntimeDataException("Invalid rail shape $railShape");
|
||||
}
|
||||
$this->railShape = $railShape;
|
||||
}
|
||||
|
||||
protected function encodeState(BlockDataWriter $w) : void{
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeInt(4, $this->railShape);
|
||||
}
|
||||
|
||||
|
@ -24,10 +24,10 @@ declare(strict_types=1);
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\MushroomBlockType;
|
||||
use pocketmine\data\runtime\block\BlockDataReader;
|
||||
use pocketmine\data\runtime\block\BlockDataReaderHelper;
|
||||
use pocketmine\data\runtime\block\BlockDataWriter;
|
||||
use pocketmine\data\runtime\block\BlockDataWriterHelper;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\data\runtime\RuntimeEnumDeserializer;
|
||||
use pocketmine\data\runtime\RuntimeEnumSerializer;
|
||||
use pocketmine\item\Item;
|
||||
use function mt_rand;
|
||||
|
||||
@ -41,12 +41,12 @@ class RedMushroomBlock extends Opaque{
|
||||
|
||||
public function getRequiredStateDataBits() : int{ return 4; }
|
||||
|
||||
protected function decodeState(BlockDataReader $r) : void{
|
||||
$this->mushroomBlockType = BlockDataReaderHelper::readMushroomBlockType($r);
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->mushroomBlockType = RuntimeEnumDeserializer::readMushroomBlockType($r);
|
||||
}
|
||||
|
||||
protected function encodeState(BlockDataWriter $w) : void{
|
||||
BlockDataWriterHelper::writeMushroomBlockType($w, $this->mushroomBlockType);
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
RuntimeEnumSerializer::writeMushroomBlockType($w, $this->mushroomBlockType);
|
||||
}
|
||||
|
||||
public function getMushroomBlockType() : MushroomBlockType{ return $this->mushroomBlockType; }
|
||||
|
@ -28,8 +28,8 @@ use pocketmine\block\utils\AnalogRedstoneSignalEmitterTrait;
|
||||
use pocketmine\block\utils\HorizontalFacingTrait;
|
||||
use pocketmine\block\utils\PoweredByRedstoneTrait;
|
||||
use pocketmine\block\utils\SupportType;
|
||||
use pocketmine\data\runtime\block\BlockDataReader;
|
||||
use pocketmine\data\runtime\block\BlockDataWriter;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
use pocketmine\math\Facing;
|
||||
@ -47,14 +47,14 @@ class RedstoneComparator extends Flowable{
|
||||
|
||||
public function getRequiredStateDataBits() : int{ return 4; }
|
||||
|
||||
protected function decodeState(BlockDataReader $r) : void{
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->facing = $r->readHorizontalFacing();
|
||||
$this->isSubtractMode = $r->readBool();
|
||||
$this->powered = $r->readBool();
|
||||
//TODO: this doesn't call the decoder from AnalogRedstoneSignalEmitter
|
||||
}
|
||||
|
||||
protected function encodeState(BlockDataWriter $w) : void{
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeHorizontalFacing($this->facing);
|
||||
$w->writeBool($this->isSubtractMode);
|
||||
$w->writeBool($this->powered);
|
||||
|
@ -24,19 +24,19 @@ declare(strict_types=1);
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\PoweredByRedstoneTrait;
|
||||
use pocketmine\data\runtime\block\BlockDataReader;
|
||||
use pocketmine\data\runtime\block\BlockDataWriter;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
|
||||
class RedstoneLamp extends Opaque{
|
||||
use PoweredByRedstoneTrait;
|
||||
|
||||
public function getRequiredStateDataBits() : int{ return 1; }
|
||||
|
||||
protected function decodeState(BlockDataReader $r) : void{
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->powered = $r->readBool();
|
||||
}
|
||||
|
||||
protected function encodeState(BlockDataWriter $w) : void{
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeBool($this->powered);
|
||||
}
|
||||
|
||||
|
@ -23,8 +23,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\data\runtime\block\BlockDataReader;
|
||||
use pocketmine\data\runtime\block\BlockDataWriter;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\VanillaItems;
|
||||
use pocketmine\math\Vector3;
|
||||
@ -36,11 +36,11 @@ class RedstoneOre extends Opaque{
|
||||
|
||||
public function getRequiredStateDataBits() : int{ return 1; }
|
||||
|
||||
protected function decodeState(BlockDataReader $r) : void{
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->lit = $r->readBool();
|
||||
}
|
||||
|
||||
protected function encodeState(BlockDataWriter $w) : void{
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeBool($this->lit);
|
||||
}
|
||||
|
||||
|
@ -26,8 +26,8 @@ namespace pocketmine\block;
|
||||
use pocketmine\block\utils\HorizontalFacingTrait;
|
||||
use pocketmine\block\utils\PoweredByRedstoneTrait;
|
||||
use pocketmine\block\utils\SupportType;
|
||||
use pocketmine\data\runtime\block\BlockDataReader;
|
||||
use pocketmine\data\runtime\block\BlockDataWriter;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
use pocketmine\math\Facing;
|
||||
@ -46,13 +46,13 @@ class RedstoneRepeater extends Flowable{
|
||||
|
||||
public function getRequiredStateDataBits() : int{ return 5; }
|
||||
|
||||
protected function decodeState(BlockDataReader $r) : void{
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->facing = $r->readHorizontalFacing();
|
||||
$this->delay = $r->readBoundedInt(2, self::MIN_DELAY - 1, self::MAX_DELAY - 1) + 1;
|
||||
$this->powered = $r->readBool();
|
||||
}
|
||||
|
||||
protected function encodeState(BlockDataWriter $w) : void{
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeHorizontalFacing($this->facing);
|
||||
$w->writeInt(2, $this->delay - 1);
|
||||
$w->writeBool($this->powered);
|
||||
|
@ -23,20 +23,20 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\data\runtime\block\BlockDataReader;
|
||||
use pocketmine\data\runtime\block\BlockDataWriter;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
|
||||
class RedstoneTorch extends Torch{
|
||||
protected bool $lit = true;
|
||||
|
||||
public function getRequiredStateDataBits() : int{ return parent::getRequiredStateDataBits() + 1; }
|
||||
|
||||
protected function decodeState(BlockDataReader $r) : void{
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
parent::decodeState($r);
|
||||
$this->lit = $r->readBool();
|
||||
}
|
||||
|
||||
protected function encodeState(BlockDataWriter $w) : void{
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
parent::encodeState($w);
|
||||
$w->writeBool($this->lit);
|
||||
}
|
||||
|
@ -24,8 +24,8 @@ declare(strict_types=1);
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\TreeType;
|
||||
use pocketmine\data\runtime\block\BlockDataReader;
|
||||
use pocketmine\data\runtime\block\BlockDataWriter;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\event\block\StructureGrowEvent;
|
||||
use pocketmine\item\Fertilizer;
|
||||
use pocketmine\item\Item;
|
||||
@ -49,11 +49,11 @@ class Sapling extends Flowable{
|
||||
|
||||
public function getRequiredStateDataBits() : int{ return 1; }
|
||||
|
||||
protected function decodeState(BlockDataReader $r) : void{
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->ready = $r->readBool();
|
||||
}
|
||||
|
||||
protected function encodeState(BlockDataWriter $w) : void{
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeBool($this->ready);
|
||||
}
|
||||
|
||||
|
@ -24,8 +24,8 @@ declare(strict_types=1);
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\SupportType;
|
||||
use pocketmine\data\runtime\block\BlockDataReader;
|
||||
use pocketmine\data\runtime\block\BlockDataWriter;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
use pocketmine\math\Vector3;
|
||||
@ -41,12 +41,12 @@ class SeaPickle extends Transparent{
|
||||
|
||||
public function getRequiredStateDataBits() : int{ return 3; }
|
||||
|
||||
protected function decodeState(BlockDataReader $r) : void{
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->count = $r->readBoundedInt(2, self::MIN_COUNT - 1, self::MAX_COUNT - 1) + 1;
|
||||
$this->underwater = $r->readBool();
|
||||
}
|
||||
|
||||
protected function encodeState(BlockDataWriter $w) : void{
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeInt(2, $this->count - 1);
|
||||
$w->writeBool($this->underwater);
|
||||
}
|
||||
|
@ -25,8 +25,8 @@ namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\tile\ShulkerBox as TileShulkerBox;
|
||||
use pocketmine\block\utils\AnyFacingTrait;
|
||||
use pocketmine\data\runtime\block\BlockDataReader;
|
||||
use pocketmine\data\runtime\block\BlockDataWriter;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\player\Player;
|
||||
@ -37,11 +37,11 @@ class ShulkerBox extends Opaque{
|
||||
|
||||
public function getRequiredStateDataBits() : int{ return 0; }
|
||||
|
||||
protected function decodeState(BlockDataReader $r) : void{
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
//NOOP - we don't read or write facing here, because the tile persists it
|
||||
}
|
||||
|
||||
protected function encodeState(BlockDataWriter $w) : void{
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
//NOOP - we don't read or write facing here, because the tile persists it
|
||||
}
|
||||
|
||||
|
@ -23,19 +23,19 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\data\runtime\block\BlockDataReader;
|
||||
use pocketmine\data\runtime\block\BlockDataWriter;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
|
||||
abstract class SimplePressurePlate extends PressurePlate{
|
||||
protected bool $pressed = false;
|
||||
|
||||
public function getRequiredStateDataBits() : int{ return 1; }
|
||||
|
||||
protected function decodeState(BlockDataReader $r) : void{
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->pressed = $r->readBool();
|
||||
}
|
||||
|
||||
protected function encodeState(BlockDataWriter $w) : void{
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeBool($this->pressed);
|
||||
}
|
||||
|
||||
|
@ -24,12 +24,12 @@ declare(strict_types=1);
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\tile\Skull as TileSkull;
|
||||
use pocketmine\block\utils\InvalidBlockStateException;
|
||||
use pocketmine\block\utils\SkullType;
|
||||
use pocketmine\data\runtime\block\BlockDataReader;
|
||||
use pocketmine\data\runtime\block\BlockDataReaderHelper;
|
||||
use pocketmine\data\runtime\block\BlockDataWriter;
|
||||
use pocketmine\data\runtime\block\BlockDataWriterHelper;
|
||||
use pocketmine\data\runtime\InvalidSerializedRuntimeDataException;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\data\runtime\RuntimeEnumDeserializer;
|
||||
use pocketmine\data\runtime\RuntimeEnumSerializer;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
use pocketmine\math\Facing;
|
||||
@ -55,25 +55,25 @@ class Skull extends Flowable{
|
||||
|
||||
public function getRequiredTypeDataBits() : int{ return 3; }
|
||||
|
||||
protected function decodeType(BlockDataReader $r) : void{
|
||||
$this->skullType = BlockDataReaderHelper::readSkullType($r);
|
||||
protected function decodeType(RuntimeDataReader $r) : void{
|
||||
$this->skullType = RuntimeEnumDeserializer::readSkullType($r);
|
||||
}
|
||||
|
||||
protected function encodeType(BlockDataWriter $w) : void{
|
||||
BlockDataWriterHelper::writeSkullType($w, $this->skullType);
|
||||
protected function encodeType(RuntimeDataWriter $w) : void{
|
||||
RuntimeEnumSerializer::writeSkullType($w, $this->skullType);
|
||||
}
|
||||
|
||||
public function getRequiredStateDataBits() : int{ return 3; }
|
||||
|
||||
protected function decodeState(BlockDataReader $r) : void{
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$facing = $r->readFacing();
|
||||
if($facing === Facing::DOWN){
|
||||
throw new InvalidBlockStateException("Skull may not face down");
|
||||
throw new InvalidSerializedRuntimeDataException("Skull may not face down");
|
||||
}
|
||||
$this->facing = $facing;
|
||||
}
|
||||
|
||||
protected function encodeState(BlockDataWriter $w) : void{
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeFacing($this->facing);
|
||||
}
|
||||
|
||||
|
@ -25,10 +25,10 @@ namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\SlabType;
|
||||
use pocketmine\block\utils\SupportType;
|
||||
use pocketmine\data\runtime\block\BlockDataReader;
|
||||
use pocketmine\data\runtime\block\BlockDataReaderHelper;
|
||||
use pocketmine\data\runtime\block\BlockDataWriter;
|
||||
use pocketmine\data\runtime\block\BlockDataWriterHelper;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\data\runtime\RuntimeEnumDeserializer;
|
||||
use pocketmine\data\runtime\RuntimeEnumSerializer;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
use pocketmine\math\Facing;
|
||||
@ -46,12 +46,12 @@ class Slab extends Transparent{
|
||||
|
||||
public function getRequiredStateDataBits() : int{ return 2; }
|
||||
|
||||
protected function decodeState(BlockDataReader $r) : void{
|
||||
$this->slabType = BlockDataReaderHelper::readSlabType($r);
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->slabType = RuntimeEnumDeserializer::readSlabType($r);
|
||||
}
|
||||
|
||||
protected function encodeState(BlockDataWriter $w) : void{
|
||||
BlockDataWriterHelper::writeSlabType($w, $this->slabType);
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
RuntimeEnumSerializer::writeSlabType($w, $this->slabType);
|
||||
}
|
||||
|
||||
public function isTransparent() : bool{
|
||||
|
@ -26,8 +26,8 @@ namespace pocketmine\block;
|
||||
use pocketmine\block\utils\Fallable;
|
||||
use pocketmine\block\utils\FallableTrait;
|
||||
use pocketmine\block\utils\SupportType;
|
||||
use pocketmine\data\runtime\block\BlockDataReader;
|
||||
use pocketmine\data\runtime\block\BlockDataWriter;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\event\block\BlockMeltEvent;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\VanillaItems;
|
||||
@ -49,11 +49,11 @@ class SnowLayer extends Flowable implements Fallable{
|
||||
|
||||
public function getRequiredStateDataBits() : int{ return 3; }
|
||||
|
||||
protected function decodeState(BlockDataReader $r) : void{
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->layers = $r->readBoundedInt(3, self::MIN_LAYERS - 1, self::MAX_LAYERS - 1) + 1;
|
||||
}
|
||||
|
||||
protected function encodeState(BlockDataWriter $w) : void{
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeInt(3, $this->layers - 1);
|
||||
}
|
||||
|
||||
|
@ -23,19 +23,19 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\data\runtime\block\BlockDataReader;
|
||||
use pocketmine\data\runtime\block\BlockDataWriter;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
|
||||
class Sponge extends Opaque{
|
||||
protected bool $wet = false;
|
||||
|
||||
public function getRequiredTypeDataBits() : int{ return 1; }
|
||||
|
||||
protected function decodeType(BlockDataReader $r) : void{
|
||||
protected function decodeType(RuntimeDataReader $r) : void{
|
||||
$this->wet = $r->readBool();
|
||||
}
|
||||
|
||||
protected function encodeType(BlockDataWriter $w) : void{
|
||||
protected function encodeType(RuntimeDataWriter $w) : void{
|
||||
$w->writeBool($this->wet);
|
||||
}
|
||||
|
||||
|
@ -26,8 +26,8 @@ namespace pocketmine\block;
|
||||
use pocketmine\block\utils\HorizontalFacingTrait;
|
||||
use pocketmine\block\utils\StairShape;
|
||||
use pocketmine\block\utils\SupportType;
|
||||
use pocketmine\data\runtime\block\BlockDataReader;
|
||||
use pocketmine\data\runtime\block\BlockDataWriter;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\Axis;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
@ -49,12 +49,12 @@ class Stair extends Transparent{
|
||||
|
||||
public function getRequiredStateDataBits() : int{ return 3; }
|
||||
|
||||
protected function decodeState(BlockDataReader $r) : void{
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->facing = $r->readHorizontalFacing();
|
||||
$this->upsideDown = $r->readBool();
|
||||
}
|
||||
|
||||
protected function encodeState(BlockDataWriter $w) : void{
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeHorizontalFacing($this->facing);
|
||||
$w->writeBool($this->upsideDown);
|
||||
}
|
||||
|
@ -23,11 +23,11 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\InvalidBlockStateException;
|
||||
use pocketmine\block\utils\RailConnectionInfo;
|
||||
use pocketmine\data\bedrock\block\BlockLegacyMetadata;
|
||||
use pocketmine\data\runtime\block\BlockDataReader;
|
||||
use pocketmine\data\runtime\block\BlockDataWriter;
|
||||
use pocketmine\data\runtime\InvalidSerializedRuntimeDataException;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use function array_keys;
|
||||
use function implode;
|
||||
|
||||
@ -40,15 +40,15 @@ class StraightOnlyRail extends BaseRail{
|
||||
|
||||
public function getRequiredStateDataBits() : int{ return 3; }
|
||||
|
||||
protected function decodeState(BlockDataReader $r) : void{
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$railShape = $r->readInt(3);
|
||||
if(!isset(RailConnectionInfo::CONNECTIONS[$railShape])){
|
||||
throw new InvalidBlockStateException("No rail shape matches meta $railShape");
|
||||
throw new InvalidSerializedRuntimeDataException("No rail shape matches meta $railShape");
|
||||
}
|
||||
$this->railShape = $railShape;
|
||||
}
|
||||
|
||||
protected function encodeState(BlockDataWriter $w) : void{
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeInt(3, $this->railShape);
|
||||
}
|
||||
|
||||
|
@ -23,8 +23,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\data\runtime\block\BlockDataReader;
|
||||
use pocketmine\data\runtime\block\BlockDataWriter;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\event\block\BlockGrowEvent;
|
||||
use pocketmine\item\Fertilizer;
|
||||
use pocketmine\item\Item;
|
||||
@ -40,11 +40,11 @@ class Sugarcane extends Flowable{
|
||||
|
||||
public function getRequiredStateDataBits() : int{ return 4; }
|
||||
|
||||
protected function decodeState(BlockDataReader $r) : void{
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->age = $r->readBoundedInt(4, 0, self::MAX_AGE);
|
||||
}
|
||||
|
||||
protected function encodeState(BlockDataWriter $w) : void{
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeInt(4, $this->age);
|
||||
}
|
||||
|
||||
|
@ -23,8 +23,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\data\runtime\block\BlockDataReader;
|
||||
use pocketmine\data\runtime\block\BlockDataWriter;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\entity\Entity;
|
||||
use pocketmine\entity\Living;
|
||||
use pocketmine\event\block\BlockGrowEvent;
|
||||
@ -48,11 +48,11 @@ class SweetBerryBush extends Flowable{
|
||||
|
||||
public function getRequiredStateDataBits() : int{ return 3; }
|
||||
|
||||
protected function decodeState(BlockDataReader $r) : void{
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->age = $r->readBoundedInt(3, self::STAGE_SAPLING, self::STAGE_MATURE);
|
||||
}
|
||||
|
||||
protected function encodeState(BlockDataWriter $w) : void{
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeInt(3, $this->age);
|
||||
}
|
||||
|
||||
|
@ -23,8 +23,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\data\runtime\block\BlockDataReader;
|
||||
use pocketmine\data\runtime\block\BlockDataWriter;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\entity\Entity;
|
||||
use pocketmine\entity\Location;
|
||||
use pocketmine\entity\object\PrimedTNT;
|
||||
@ -47,21 +47,21 @@ class TNT extends Opaque{
|
||||
|
||||
public function getRequiredTypeDataBits() : int{ return 1; }
|
||||
|
||||
protected function decodeType(BlockDataReader $r) : void{
|
||||
protected function decodeType(RuntimeDataReader $r) : void{
|
||||
$this->worksUnderwater = $r->readBool();
|
||||
}
|
||||
|
||||
protected function encodeType(BlockDataWriter $w) : void{
|
||||
protected function encodeType(RuntimeDataWriter $w) : void{
|
||||
$w->writeBool($this->worksUnderwater);
|
||||
}
|
||||
|
||||
public function getRequiredStateDataBits() : int{ return 1; }
|
||||
|
||||
protected function decodeState(BlockDataReader $r) : void{
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->unstable = $r->readBool();
|
||||
}
|
||||
|
||||
protected function encodeState(BlockDataWriter $w) : void{
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeBool($this->unstable);
|
||||
}
|
||||
|
||||
|
@ -23,10 +23,10 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\InvalidBlockStateException;
|
||||
use pocketmine\block\utils\SupportType;
|
||||
use pocketmine\data\runtime\block\BlockDataReader;
|
||||
use pocketmine\data\runtime\block\BlockDataWriter;
|
||||
use pocketmine\data\runtime\InvalidSerializedRuntimeDataException;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\Axis;
|
||||
use pocketmine\math\Facing;
|
||||
@ -40,15 +40,15 @@ class Torch extends Flowable{
|
||||
|
||||
public function getRequiredStateDataBits() : int{ return 3; }
|
||||
|
||||
protected function decodeState(BlockDataReader $r) : void{
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$facing = $r->readFacing();
|
||||
if($facing === Facing::DOWN){
|
||||
throw new InvalidBlockStateException("Torch cannot have a DOWN facing");
|
||||
throw new InvalidSerializedRuntimeDataException("Torch cannot have a DOWN facing");
|
||||
}
|
||||
$this->facing = $facing;
|
||||
}
|
||||
|
||||
protected function encodeState(BlockDataWriter $w) : void{
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeFacing($this->facing);
|
||||
}
|
||||
|
||||
|
@ -25,8 +25,8 @@ namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\HorizontalFacingTrait;
|
||||
use pocketmine\block\utils\SupportType;
|
||||
use pocketmine\data\runtime\block\BlockDataReader;
|
||||
use pocketmine\data\runtime\block\BlockDataWriter;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
use pocketmine\math\Facing;
|
||||
@ -43,13 +43,13 @@ class Trapdoor extends Transparent{
|
||||
|
||||
public function getRequiredStateDataBits() : int{ return 4; }
|
||||
|
||||
protected function decodeState(BlockDataReader $r) : void{
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->facing = $r->readHorizontalFacing();
|
||||
$this->top = $r->readBool();
|
||||
$this->open = $r->readBool();
|
||||
}
|
||||
|
||||
protected function encodeState(BlockDataWriter $w) : void{
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeHorizontalFacing($this->facing);
|
||||
$w->writeBool($this->top);
|
||||
$w->writeBool($this->open);
|
||||
|
@ -23,8 +23,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\data\runtime\block\BlockDataReader;
|
||||
use pocketmine\data\runtime\block\BlockDataWriter;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\VanillaItems;
|
||||
|
||||
@ -36,14 +36,14 @@ class Tripwire extends Flowable{
|
||||
|
||||
public function getRequiredStateDataBits() : int{ return 4; }
|
||||
|
||||
protected function decodeState(BlockDataReader $r) : void{
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->triggered = $r->readBool();
|
||||
$this->suspended = $r->readBool();
|
||||
$this->connected = $r->readBool();
|
||||
$this->disarmed = $r->readBool();
|
||||
}
|
||||
|
||||
protected function encodeState(BlockDataWriter $w) : void{
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeBool($this->triggered);
|
||||
$w->writeBool($this->suspended);
|
||||
$w->writeBool($this->connected);
|
||||
|
@ -24,8 +24,8 @@ declare(strict_types=1);
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\HorizontalFacingTrait;
|
||||
use pocketmine\data\runtime\block\BlockDataReader;
|
||||
use pocketmine\data\runtime\block\BlockDataWriter;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\Axis;
|
||||
use pocketmine\math\Facing;
|
||||
@ -41,13 +41,13 @@ class TripwireHook extends Flowable{
|
||||
|
||||
public function getRequiredStateDataBits() : int{ return 4; }
|
||||
|
||||
protected function decodeState(BlockDataReader $r) : void{
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->facing = $r->readHorizontalFacing();
|
||||
$this->connected = $r->readBool();
|
||||
$this->powered = $r->readBool();
|
||||
}
|
||||
|
||||
protected function encodeState(BlockDataWriter $w) : void{
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeHorizontalFacing($this->facing);
|
||||
$w->writeBool($this->connected);
|
||||
$w->writeBool($this->powered);
|
||||
|
@ -23,8 +23,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\data\runtime\block\BlockDataReader;
|
||||
use pocketmine\data\runtime\block\BlockDataWriter;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\item\Item;
|
||||
|
||||
class UnknownBlock extends Transparent{
|
||||
@ -36,13 +36,13 @@ class UnknownBlock extends Transparent{
|
||||
$this->stateData = $stateData;
|
||||
}
|
||||
|
||||
protected function decodeType(BlockDataReader $r) : void{
|
||||
protected function decodeType(RuntimeDataReader $r) : void{
|
||||
//use type instead of state, so we don't lose any information like colour
|
||||
//this might be an improperly registered plugin block
|
||||
$this->stateData = $r->readInt(Block::INTERNAL_STATE_DATA_BITS);
|
||||
}
|
||||
|
||||
protected function encodeType(BlockDataWriter $w) : void{
|
||||
protected function encodeType(RuntimeDataWriter $w) : void{
|
||||
$w->writeInt(Block::INTERNAL_STATE_DATA_BITS, $this->stateData);
|
||||
}
|
||||
|
||||
|
@ -23,8 +23,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\data\runtime\block\BlockDataReader;
|
||||
use pocketmine\data\runtime\block\BlockDataWriter;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\entity\Entity;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\Axis;
|
||||
@ -42,13 +42,13 @@ class Vine extends Flowable{
|
||||
|
||||
public function getRequiredStateDataBits() : int{ return 4; }
|
||||
|
||||
protected function decodeState(BlockDataReader $r) : void{
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
foreach(Facing::HORIZONTAL as $facing){
|
||||
$this->setFace($facing, $r->readBool());
|
||||
}
|
||||
}
|
||||
|
||||
protected function encodeState(BlockDataWriter $w) : void{
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
foreach(Facing::HORIZONTAL as $facing){
|
||||
$w->writeBool($this->hasFace($facing));
|
||||
}
|
||||
|
@ -25,8 +25,8 @@ namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\SupportType;
|
||||
use pocketmine\block\utils\WallConnectionType;
|
||||
use pocketmine\data\runtime\block\BlockDataReader;
|
||||
use pocketmine\data\runtime\block\BlockDataWriter;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\math\Axis;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
use pocketmine\math\Facing;
|
||||
@ -45,12 +45,12 @@ class Wall extends Transparent{
|
||||
|
||||
public function getRequiredStateDataBits() : int{ return 9; }
|
||||
|
||||
protected function decodeState(BlockDataReader $r) : void{
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->connections = $r->readWallConnections();
|
||||
$this->post = $r->readBool();
|
||||
}
|
||||
|
||||
protected function encodeState(BlockDataWriter $w) : void{
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeWallConnections($this->connections);
|
||||
$w->writeBool($this->post);
|
||||
}
|
||||
|
@ -24,8 +24,8 @@ declare(strict_types=1);
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\HorizontalFacingTrait;
|
||||
use pocketmine\data\runtime\block\BlockDataReader;
|
||||
use pocketmine\data\runtime\block\BlockDataWriter;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\VanillaItems;
|
||||
use pocketmine\math\Axis;
|
||||
@ -39,11 +39,11 @@ final class WallCoralFan extends BaseCoral{
|
||||
|
||||
public function getRequiredStateDataBits() : int{ return parent::getRequiredStateDataBits() + 2; }
|
||||
|
||||
protected function decodeState(BlockDataReader $r) : void{
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->facing = $r->readHorizontalFacing();
|
||||
}
|
||||
|
||||
protected function encodeState(BlockDataWriter $w) : void{
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeHorizontalFacing($this->facing);
|
||||
}
|
||||
|
||||
|
@ -25,8 +25,8 @@ namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\PillarRotationTrait;
|
||||
use pocketmine\block\utils\WoodTypeTrait;
|
||||
use pocketmine\data\runtime\block\BlockDataReader;
|
||||
use pocketmine\data\runtime\block\BlockDataWriter;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\item\Axe;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\Vector3;
|
||||
@ -40,11 +40,11 @@ class Wood extends Opaque{
|
||||
|
||||
public function getRequiredTypeDataBits() : int{ return 1; }
|
||||
|
||||
protected function decodeType(BlockDataReader $r) : void{
|
||||
protected function decodeType(RuntimeDataReader $r) : void{
|
||||
$this->stripped = $r->readBool();
|
||||
}
|
||||
|
||||
protected function encodeType(BlockDataWriter $w) : void{
|
||||
protected function encodeType(RuntimeDataWriter $w) : void{
|
||||
$w->writeBool($this->stripped);
|
||||
}
|
||||
|
||||
|
@ -23,19 +23,19 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block\utils;
|
||||
|
||||
use pocketmine\data\runtime\block\BlockDataReader;
|
||||
use pocketmine\data\runtime\block\BlockDataWriter;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
|
||||
trait AnalogRedstoneSignalEmitterTrait{
|
||||
protected int $signalStrength = 0;
|
||||
|
||||
public function getRequiredStateDataBits() : int{ return 4; }
|
||||
|
||||
protected function decodeState(BlockDataReader $r) : void{
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->signalStrength = $r->readBoundedInt(4, 0, 15);
|
||||
}
|
||||
|
||||
protected function encodeState(BlockDataWriter $w) : void{
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeInt(4, $this->signalStrength);
|
||||
}
|
||||
|
||||
|
@ -23,8 +23,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block\utils;
|
||||
|
||||
use pocketmine\data\runtime\block\BlockDataReader;
|
||||
use pocketmine\data\runtime\block\BlockDataWriter;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\math\Facing;
|
||||
|
||||
trait AnyFacingTrait{
|
||||
@ -32,11 +32,11 @@ trait AnyFacingTrait{
|
||||
|
||||
public function getRequiredStateDataBits() : int{ return 3; }
|
||||
|
||||
protected function decodeState(BlockDataReader $r) : void{
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->facing = $r->readFacing();
|
||||
}
|
||||
|
||||
protected function encodeState(BlockDataWriter $w) : void{
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeFacing($this->facing);
|
||||
}
|
||||
|
||||
|
@ -24,10 +24,10 @@ declare(strict_types=1);
|
||||
namespace pocketmine\block\utils;
|
||||
|
||||
use pocketmine\block\Block;
|
||||
use pocketmine\data\runtime\block\BlockDataReader;
|
||||
use pocketmine\data\runtime\block\BlockDataReaderHelper;
|
||||
use pocketmine\data\runtime\block\BlockDataWriter;
|
||||
use pocketmine\data\runtime\block\BlockDataWriterHelper;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\data\runtime\RuntimeEnumDeserializer;
|
||||
use pocketmine\data\runtime\RuntimeEnumSerializer;
|
||||
|
||||
trait ColoredTrait{
|
||||
/** @var DyeColor */
|
||||
@ -36,13 +36,13 @@ trait ColoredTrait{
|
||||
public function getRequiredTypeDataBits() : int{ return 4; }
|
||||
|
||||
/** @see Block::decodeType() */
|
||||
protected function decodeType(BlockDataReader $r) : void{
|
||||
$this->color = BlockDataReaderHelper::readDyeColor($r);
|
||||
protected function decodeType(RuntimeDataReader $r) : void{
|
||||
$this->color = RuntimeEnumDeserializer::readDyeColor($r);
|
||||
}
|
||||
|
||||
/** @see Block::encodeType() */
|
||||
protected function encodeType(BlockDataWriter $w) : void{
|
||||
BlockDataWriterHelper::writeDyeColor($w, $this->color);
|
||||
protected function encodeType(RuntimeDataWriter $w) : void{
|
||||
RuntimeEnumSerializer::writeDyeColor($w, $this->color);
|
||||
}
|
||||
|
||||
public function getColor() : DyeColor{ return $this->color; }
|
||||
|
@ -24,10 +24,10 @@ declare(strict_types=1);
|
||||
namespace pocketmine\block\utils;
|
||||
|
||||
use pocketmine\block\Block;
|
||||
use pocketmine\data\runtime\block\BlockDataReader;
|
||||
use pocketmine\data\runtime\block\BlockDataReaderHelper;
|
||||
use pocketmine\data\runtime\block\BlockDataWriter;
|
||||
use pocketmine\data\runtime\block\BlockDataWriterHelper;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\data\runtime\RuntimeEnumDeserializer;
|
||||
use pocketmine\data\runtime\RuntimeEnumSerializer;
|
||||
|
||||
trait CoralTypeTrait{
|
||||
protected CoralType $coralType;
|
||||
@ -36,14 +36,14 @@ trait CoralTypeTrait{
|
||||
public function getRequiredTypeDataBits() : int{ return 4; }
|
||||
|
||||
/** @see Block::decodeType() */
|
||||
protected function decodeType(BlockDataReader $r) : void{
|
||||
$this->coralType = BlockDataReaderHelper::readCoralType($r);
|
||||
protected function decodeType(RuntimeDataReader $r) : void{
|
||||
$this->coralType = RuntimeEnumDeserializer::readCoralType($r);
|
||||
$this->dead = $r->readBool();
|
||||
}
|
||||
|
||||
/** @see Block::encodeType() */
|
||||
protected function encodeType(BlockDataWriter $w) : void{
|
||||
BlockDataWriterHelper::writeCoralType($w, $this->coralType);
|
||||
protected function encodeType(RuntimeDataWriter $w) : void{
|
||||
RuntimeEnumSerializer::writeCoralType($w, $this->coralType);
|
||||
$w->writeBool($this->dead);
|
||||
}
|
||||
|
||||
|
@ -23,8 +23,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block\utils;
|
||||
|
||||
use pocketmine\data\runtime\block\BlockDataReader;
|
||||
use pocketmine\data\runtime\block\BlockDataWriter;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\math\Axis;
|
||||
use pocketmine\math\Facing;
|
||||
|
||||
@ -33,11 +33,11 @@ trait HorizontalFacingTrait{
|
||||
|
||||
public function getRequiredStateDataBits() : int{ return 2; }
|
||||
|
||||
protected function decodeState(BlockDataReader $r) : void{
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->facing = $r->readHorizontalFacing();
|
||||
}
|
||||
|
||||
protected function encodeState(BlockDataWriter $w) : void{
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeHorizontalFacing($this->facing);
|
||||
}
|
||||
|
||||
|
@ -24,8 +24,8 @@ declare(strict_types=1);
|
||||
namespace pocketmine\block\utils;
|
||||
|
||||
use pocketmine\block\Block;
|
||||
use pocketmine\data\runtime\block\BlockDataReader;
|
||||
use pocketmine\data\runtime\block\BlockDataWriter;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\Axis;
|
||||
use pocketmine\math\Facing;
|
||||
@ -38,11 +38,11 @@ trait PillarRotationTrait{
|
||||
|
||||
public function getRequiredStateDataBits() : int{ return 2; }
|
||||
|
||||
protected function decodeState(BlockDataReader $r) : void{
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->axis = $r->readAxis();
|
||||
}
|
||||
|
||||
protected function encodeState(BlockDataWriter $w) : void{
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeAxis($this->axis);
|
||||
}
|
||||
|
||||
|
@ -23,20 +23,20 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block\utils;
|
||||
|
||||
use pocketmine\data\runtime\block\BlockDataReader;
|
||||
use pocketmine\data\runtime\block\BlockDataWriter;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
|
||||
trait RailPoweredByRedstoneTrait{
|
||||
use PoweredByRedstoneTrait;
|
||||
|
||||
public function getRequiredStateDataBits() : int{ return parent::getRequiredStateDataBits() + 1; }
|
||||
|
||||
protected function decodeState(BlockDataReader $r) : void{
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
parent::decodeState($r);
|
||||
$this->powered = $r->readBool();
|
||||
}
|
||||
|
||||
protected function encodeState(BlockDataWriter $w) : void{
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
parent::encodeState($w);
|
||||
$w->writeBool($this->powered);
|
||||
}
|
||||
|
@ -23,8 +23,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block\utils;
|
||||
|
||||
use pocketmine\data\runtime\block\BlockDataReader;
|
||||
use pocketmine\data\runtime\block\BlockDataWriter;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use function floor;
|
||||
|
||||
trait SignLikeRotationTrait{
|
||||
@ -33,11 +33,11 @@ trait SignLikeRotationTrait{
|
||||
|
||||
public function getRequiredStateDataBits() : int{ return 4; }
|
||||
|
||||
protected function decodeState(BlockDataReader $r) : void{
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->rotation = $r->readBoundedInt(4, 0, 15);
|
||||
}
|
||||
|
||||
protected function encodeState(BlockDataWriter $w) : void{
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeInt(4, $this->rotation);
|
||||
}
|
||||
|
||||
|
@ -21,8 +21,8 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block\utils;
|
||||
namespace pocketmine\data\runtime;
|
||||
|
||||
class InvalidBlockStateException extends \UnexpectedValueException{
|
||||
final class InvalidSerializedRuntimeDataException extends \UnexpectedValueException{
|
||||
|
||||
}
|
@ -21,15 +21,14 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\data\runtime\block;
|
||||
namespace pocketmine\data\runtime;
|
||||
|
||||
use pocketmine\block\utils\InvalidBlockStateException;
|
||||
use pocketmine\block\utils\WallConnectionType;
|
||||
use pocketmine\math\Axis;
|
||||
use pocketmine\math\Facing;
|
||||
use pocketmine\utils\AssumptionFailedError;
|
||||
|
||||
final class BlockDataReader{
|
||||
final class RuntimeDataReader{
|
||||
|
||||
private int $offset = 0;
|
||||
|
||||
@ -52,7 +51,7 @@ final class BlockDataReader{
|
||||
public function readBoundedInt(int $bits, int $min, int $max) : int{
|
||||
$result = $this->readInt($bits);
|
||||
if($result < $min || $result > $max){
|
||||
throw new InvalidBlockStateException("Value is outside the range $min - $max");
|
||||
throw new InvalidSerializedRuntimeDataException("Value is outside the range $min - $max");
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
@ -79,7 +78,7 @@ final class BlockDataReader{
|
||||
3 => Facing::SOUTH,
|
||||
4 => Facing::WEST,
|
||||
5 => Facing::EAST,
|
||||
default => throw new InvalidBlockStateException("Invalid facing value")
|
||||
default => throw new InvalidSerializedRuntimeDataException("Invalid facing value")
|
||||
};
|
||||
}
|
||||
|
||||
@ -88,7 +87,7 @@ final class BlockDataReader{
|
||||
0 => Axis::X,
|
||||
1 => Axis::Z,
|
||||
2 => Axis::Y,
|
||||
default => throw new InvalidBlockStateException("Invalid axis value")
|
||||
default => throw new InvalidSerializedRuntimeDataException("Invalid axis value")
|
||||
};
|
||||
}
|
||||
|
@ -21,14 +21,14 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\data\runtime\block;
|
||||
namespace pocketmine\data\runtime;
|
||||
|
||||
use pocketmine\block\utils\WallConnectionType;
|
||||
use pocketmine\math\Axis;
|
||||
use pocketmine\math\Facing;
|
||||
use pocketmine\utils\AssumptionFailedError;
|
||||
|
||||
final class BlockDataWriter{
|
||||
final class RuntimeDataWriter{
|
||||
|
||||
private int $value = 0;
|
||||
private int $offset = 0;
|
108
src/data/runtime/RuntimeEnumDeserializer.php
Normal file
108
src/data/runtime/RuntimeEnumDeserializer.php
Normal file
@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
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
|
||||
*/
|
||||
final class RuntimeEnumDeserializer{
|
||||
|
||||
public static function readBellAttachmentType(RuntimeDataReader $r) : \pocketmine\block\utils\BellAttachmentType{
|
||||
return match($r->readInt(2)){
|
||||
0 => \pocketmine\block\utils\BellAttachmentType::CEILING(),
|
||||
1 => \pocketmine\block\utils\BellAttachmentType::FLOOR(),
|
||||
2 => \pocketmine\block\utils\BellAttachmentType::ONE_WALL(),
|
||||
3 => \pocketmine\block\utils\BellAttachmentType::TWO_WALLS(),
|
||||
default => throw new InvalidSerializedRuntimeDataException("Invalid serialized value for BellAttachmentType")
|
||||
};
|
||||
}
|
||||
|
||||
public static function readCoralType(RuntimeDataReader $r) : \pocketmine\block\utils\CoralType{
|
||||
return match($r->readInt(3)){
|
||||
0 => \pocketmine\block\utils\CoralType::BRAIN(),
|
||||
1 => \pocketmine\block\utils\CoralType::BUBBLE(),
|
||||
2 => \pocketmine\block\utils\CoralType::FIRE(),
|
||||
3 => \pocketmine\block\utils\CoralType::HORN(),
|
||||
4 => \pocketmine\block\utils\CoralType::TUBE(),
|
||||
default => throw new InvalidSerializedRuntimeDataException("Invalid serialized value for CoralType")
|
||||
};
|
||||
}
|
||||
|
||||
public static function readDyeColor(RuntimeDataReader $r) : \pocketmine\block\utils\DyeColor{
|
||||
return match($r->readInt(4)){
|
||||
0 => \pocketmine\block\utils\DyeColor::BLACK(),
|
||||
1 => \pocketmine\block\utils\DyeColor::BLUE(),
|
||||
2 => \pocketmine\block\utils\DyeColor::BROWN(),
|
||||
3 => \pocketmine\block\utils\DyeColor::CYAN(),
|
||||
4 => \pocketmine\block\utils\DyeColor::GRAY(),
|
||||
5 => \pocketmine\block\utils\DyeColor::GREEN(),
|
||||
6 => \pocketmine\block\utils\DyeColor::LIGHT_BLUE(),
|
||||
7 => \pocketmine\block\utils\DyeColor::LIGHT_GRAY(),
|
||||
8 => \pocketmine\block\utils\DyeColor::LIME(),
|
||||
9 => \pocketmine\block\utils\DyeColor::MAGENTA(),
|
||||
10 => \pocketmine\block\utils\DyeColor::ORANGE(),
|
||||
11 => \pocketmine\block\utils\DyeColor::PINK(),
|
||||
12 => \pocketmine\block\utils\DyeColor::PURPLE(),
|
||||
13 => \pocketmine\block\utils\DyeColor::RED(),
|
||||
14 => \pocketmine\block\utils\DyeColor::WHITE(),
|
||||
15 => \pocketmine\block\utils\DyeColor::YELLOW(),
|
||||
default => throw new InvalidSerializedRuntimeDataException("Invalid serialized value for DyeColor")
|
||||
};
|
||||
}
|
||||
|
||||
public static function readLeverFacing(RuntimeDataReader $r) : \pocketmine\block\utils\LeverFacing{
|
||||
return match($r->readInt(3)){
|
||||
0 => \pocketmine\block\utils\LeverFacing::DOWN_AXIS_X(),
|
||||
1 => \pocketmine\block\utils\LeverFacing::DOWN_AXIS_Z(),
|
||||
2 => \pocketmine\block\utils\LeverFacing::EAST(),
|
||||
3 => \pocketmine\block\utils\LeverFacing::NORTH(),
|
||||
4 => \pocketmine\block\utils\LeverFacing::SOUTH(),
|
||||
5 => \pocketmine\block\utils\LeverFacing::UP_AXIS_X(),
|
||||
6 => \pocketmine\block\utils\LeverFacing::UP_AXIS_Z(),
|
||||
7 => \pocketmine\block\utils\LeverFacing::WEST(),
|
||||
default => throw new InvalidSerializedRuntimeDataException("Invalid serialized value for LeverFacing")
|
||||
};
|
||||
}
|
||||
|
||||
public static function readMushroomBlockType(RuntimeDataReader $r) : \pocketmine\block\utils\MushroomBlockType{
|
||||
return match($r->readInt(4)){
|
||||
0 => \pocketmine\block\utils\MushroomBlockType::ALL_CAP(),
|
||||
1 => \pocketmine\block\utils\MushroomBlockType::CAP_EAST(),
|
||||
2 => \pocketmine\block\utils\MushroomBlockType::CAP_MIDDLE(),
|
||||
3 => \pocketmine\block\utils\MushroomBlockType::CAP_NORTH(),
|
||||
4 => \pocketmine\block\utils\MushroomBlockType::CAP_NORTHEAST(),
|
||||
5 => \pocketmine\block\utils\MushroomBlockType::CAP_NORTHWEST(),
|
||||
6 => \pocketmine\block\utils\MushroomBlockType::CAP_SOUTH(),
|
||||
7 => \pocketmine\block\utils\MushroomBlockType::CAP_SOUTHEAST(),
|
||||
8 => \pocketmine\block\utils\MushroomBlockType::CAP_SOUTHWEST(),
|
||||
9 => \pocketmine\block\utils\MushroomBlockType::CAP_WEST(),
|
||||
10 => \pocketmine\block\utils\MushroomBlockType::PORES(),
|
||||
default => throw new InvalidSerializedRuntimeDataException("Invalid serialized value for MushroomBlockType")
|
||||
};
|
||||
}
|
||||
|
||||
public static function readSkullType(RuntimeDataReader $r) : \pocketmine\block\utils\SkullType{
|
||||
return match($r->readInt(3)){
|
||||
0 => \pocketmine\block\utils\SkullType::CREEPER(),
|
||||
1 => \pocketmine\block\utils\SkullType::DRAGON(),
|
||||
2 => \pocketmine\block\utils\SkullType::PLAYER(),
|
||||
3 => \pocketmine\block\utils\SkullType::SKELETON(),
|
||||
4 => \pocketmine\block\utils\SkullType::WITHER_SKELETON(),
|
||||
5 => \pocketmine\block\utils\SkullType::ZOMBIE(),
|
||||
default => throw new InvalidSerializedRuntimeDataException("Invalid serialized value for SkullType")
|
||||
};
|
||||
}
|
||||
|
||||
public static function readSlabType(RuntimeDataReader $r) : \pocketmine\block\utils\SlabType{
|
||||
return match($r->readInt(2)){
|
||||
0 => \pocketmine\block\utils\SlabType::BOTTOM(),
|
||||
1 => \pocketmine\block\utils\SlabType::DOUBLE(),
|
||||
2 => \pocketmine\block\utils\SlabType::TOP(),
|
||||
default => throw new InvalidSerializedRuntimeDataException("Invalid serialized value for SlabType")
|
||||
};
|
||||
}
|
||||
|
||||
}
|
@ -1,41 +1,16 @@
|
||||
<?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\block;
|
||||
namespace pocketmine\data\runtime;
|
||||
|
||||
use pocketmine\block\utils\BellAttachmentType;
|
||||
use pocketmine\block\utils\CoralType;
|
||||
use pocketmine\block\utils\DyeColor;
|
||||
use pocketmine\block\utils\LeverFacing;
|
||||
use pocketmine\block\utils\MushroomBlockType;
|
||||
use pocketmine\block\utils\SkullType;
|
||||
use pocketmine\block\utils\SlabType;
|
||||
use pocketmine\block\utils\StairShape;
|
||||
use pocketmine\block\utils\TreeType;
|
||||
/**
|
||||
* This class is auto-generated. Do not edit it manually.
|
||||
* @see build/generate-runtime-enum-serializers.php
|
||||
*/
|
||||
final class RuntimeEnumSerializer{
|
||||
|
||||
final class BlockDataWriterHelper{
|
||||
|
||||
public static function writeBellAttachmentType(BlockDataWriter $w, BellAttachmentType $value) : void{
|
||||
public static function writeBellAttachmentType(RuntimeDataWriter $w, \pocketmine\block\utils\BellAttachmentType $value) : void{
|
||||
$w->writeInt(2, match($value){
|
||||
\pocketmine\block\utils\BellAttachmentType::CEILING() => 0,
|
||||
\pocketmine\block\utils\BellAttachmentType::FLOOR() => 1,
|
||||
@ -45,21 +20,7 @@ final class BlockDataWriterHelper{
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \pocketmine\block\utils\BrewingStandSlot[] $value
|
||||
* @phpstan-param array<int, \pocketmine\block\utils\BrewingStandSlot> $value
|
||||
*/
|
||||
public static function writeBrewingStandSlotKeySet(BlockDataWriter $w, array $value) : void{
|
||||
foreach([
|
||||
\pocketmine\block\utils\BrewingStandSlot::EAST(),
|
||||
\pocketmine\block\utils\BrewingStandSlot::NORTHWEST(),
|
||||
\pocketmine\block\utils\BrewingStandSlot::SOUTHWEST(),
|
||||
] as $member){
|
||||
$w->writeBool(isset($value[$member->id()]));
|
||||
}
|
||||
}
|
||||
|
||||
public static function writeCoralType(BlockDataWriter $w, CoralType $value) : void{
|
||||
public static function writeCoralType(RuntimeDataWriter $w, \pocketmine\block\utils\CoralType $value) : void{
|
||||
$w->writeInt(3, match($value){
|
||||
\pocketmine\block\utils\CoralType::BRAIN() => 0,
|
||||
\pocketmine\block\utils\CoralType::BUBBLE() => 1,
|
||||
@ -70,7 +31,7 @@ final class BlockDataWriterHelper{
|
||||
});
|
||||
}
|
||||
|
||||
public static function writeDyeColor(BlockDataWriter $w, DyeColor $value) : void{
|
||||
public static function writeDyeColor(RuntimeDataWriter $w, \pocketmine\block\utils\DyeColor $value) : void{
|
||||
$w->writeInt(4, match($value){
|
||||
\pocketmine\block\utils\DyeColor::BLACK() => 0,
|
||||
\pocketmine\block\utils\DyeColor::BLUE() => 1,
|
||||
@ -92,7 +53,7 @@ final class BlockDataWriterHelper{
|
||||
});
|
||||
}
|
||||
|
||||
public static function writeLeverFacing(BlockDataWriter $w, LeverFacing $value) : void{
|
||||
public static function writeLeverFacing(RuntimeDataWriter $w, \pocketmine\block\utils\LeverFacing $value) : void{
|
||||
$w->writeInt(3, match($value){
|
||||
\pocketmine\block\utils\LeverFacing::DOWN_AXIS_X() => 0,
|
||||
\pocketmine\block\utils\LeverFacing::DOWN_AXIS_Z() => 1,
|
||||
@ -106,7 +67,7 @@ final class BlockDataWriterHelper{
|
||||
});
|
||||
}
|
||||
|
||||
public static function writeMushroomBlockType(BlockDataWriter $w, MushroomBlockType $value) : void{
|
||||
public static function writeMushroomBlockType(RuntimeDataWriter $w, \pocketmine\block\utils\MushroomBlockType $value) : void{
|
||||
$w->writeInt(4, match($value){
|
||||
\pocketmine\block\utils\MushroomBlockType::ALL_CAP() => 0,
|
||||
\pocketmine\block\utils\MushroomBlockType::CAP_EAST() => 1,
|
||||
@ -123,7 +84,7 @@ final class BlockDataWriterHelper{
|
||||
});
|
||||
}
|
||||
|
||||
public static function writeSkullType(BlockDataWriter $w, SkullType $value) : void{
|
||||
public static function writeSkullType(RuntimeDataWriter $w, \pocketmine\block\utils\SkullType $value) : void{
|
||||
$w->writeInt(3, match($value){
|
||||
\pocketmine\block\utils\SkullType::CREEPER() => 0,
|
||||
\pocketmine\block\utils\SkullType::DRAGON() => 1,
|
||||
@ -135,7 +96,7 @@ final class BlockDataWriterHelper{
|
||||
});
|
||||
}
|
||||
|
||||
public static function writeSlabType(BlockDataWriter $w, SlabType $value) : void{
|
||||
public static function writeSlabType(RuntimeDataWriter $w, \pocketmine\block\utils\SlabType $value) : void{
|
||||
$w->writeInt(2, match($value){
|
||||
\pocketmine\block\utils\SlabType::BOTTOM() => 0,
|
||||
\pocketmine\block\utils\SlabType::DOUBLE() => 1,
|
||||
@ -144,27 +105,4 @@ final class BlockDataWriterHelper{
|
||||
});
|
||||
}
|
||||
|
||||
public static function writeStairShape(BlockDataWriter $w, StairShape $value) : void{
|
||||
$w->writeInt(3, match($value){
|
||||
\pocketmine\block\utils\StairShape::INNER_LEFT() => 0,
|
||||
\pocketmine\block\utils\StairShape::INNER_RIGHT() => 1,
|
||||
\pocketmine\block\utils\StairShape::OUTER_LEFT() => 2,
|
||||
\pocketmine\block\utils\StairShape::OUTER_RIGHT() => 3,
|
||||
\pocketmine\block\utils\StairShape::STRAIGHT() => 4,
|
||||
default => throw new \pocketmine\utils\AssumptionFailedError("All StairShape cases should be covered")
|
||||
});
|
||||
}
|
||||
|
||||
public static function writeTreeType(BlockDataWriter $w, TreeType $value) : void{
|
||||
$w->writeInt(3, match($value){
|
||||
\pocketmine\block\utils\TreeType::ACACIA() => 0,
|
||||
\pocketmine\block\utils\TreeType::BIRCH() => 1,
|
||||
\pocketmine\block\utils\TreeType::DARK_OAK() => 2,
|
||||
\pocketmine\block\utils\TreeType::JUNGLE() => 3,
|
||||
\pocketmine\block\utils\TreeType::OAK() => 4,
|
||||
\pocketmine\block\utils\TreeType::SPRUCE() => 5,
|
||||
default => throw new \pocketmine\utils\AssumptionFailedError("All TreeType cases should be covered")
|
||||
});
|
||||
}
|
||||
|
||||
}
|
@ -1,174 +0,0 @@
|
||||
<?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\block;
|
||||
|
||||
use pocketmine\block\utils\BellAttachmentType;
|
||||
use pocketmine\block\utils\CoralType;
|
||||
use pocketmine\block\utils\DyeColor;
|
||||
use pocketmine\block\utils\LeverFacing;
|
||||
use pocketmine\block\utils\MushroomBlockType;
|
||||
use pocketmine\block\utils\SkullType;
|
||||
use pocketmine\block\utils\SlabType;
|
||||
use pocketmine\block\utils\StairShape;
|
||||
use pocketmine\block\utils\TreeType;
|
||||
|
||||
final class BlockDataReaderHelper{
|
||||
|
||||
public static function readBellAttachmentType(BlockDataReader $r) : BellAttachmentType{
|
||||
return match($r->readInt(2)){
|
||||
0 => \pocketmine\block\utils\BellAttachmentType::CEILING(),
|
||||
1 => \pocketmine\block\utils\BellAttachmentType::FLOOR(),
|
||||
2 => \pocketmine\block\utils\BellAttachmentType::ONE_WALL(),
|
||||
3 => \pocketmine\block\utils\BellAttachmentType::TWO_WALLS(),
|
||||
default => throw new \pocketmine\block\utils\InvalidBlockStateException("Invalid serialized value for BellAttachmentType")
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \pocketmine\block\utils\BrewingStandSlot[]
|
||||
* @phpstan-return array<int, \pocketmine\block\utils\BrewingStandSlot>
|
||||
*/
|
||||
public static function readBrewingStandSlotKeySet(BlockDataReader $r) : array{
|
||||
$result = [];
|
||||
foreach([
|
||||
\pocketmine\block\utils\BrewingStandSlot::EAST(),
|
||||
\pocketmine\block\utils\BrewingStandSlot::NORTHWEST(),
|
||||
\pocketmine\block\utils\BrewingStandSlot::SOUTHWEST(),
|
||||
] as $member){
|
||||
if($r->readBool()){
|
||||
$result[$member->id()] = $member;
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function readCoralType(BlockDataReader $r) : CoralType{
|
||||
return match($r->readInt(3)){
|
||||
0 => \pocketmine\block\utils\CoralType::BRAIN(),
|
||||
1 => \pocketmine\block\utils\CoralType::BUBBLE(),
|
||||
2 => \pocketmine\block\utils\CoralType::FIRE(),
|
||||
3 => \pocketmine\block\utils\CoralType::HORN(),
|
||||
4 => \pocketmine\block\utils\CoralType::TUBE(),
|
||||
default => throw new \pocketmine\block\utils\InvalidBlockStateException("Invalid serialized value for CoralType")
|
||||
};
|
||||
}
|
||||
|
||||
public static function readDyeColor(BlockDataReader $r) : DyeColor{
|
||||
return match($r->readInt(4)){
|
||||
0 => \pocketmine\block\utils\DyeColor::BLACK(),
|
||||
1 => \pocketmine\block\utils\DyeColor::BLUE(),
|
||||
2 => \pocketmine\block\utils\DyeColor::BROWN(),
|
||||
3 => \pocketmine\block\utils\DyeColor::CYAN(),
|
||||
4 => \pocketmine\block\utils\DyeColor::GRAY(),
|
||||
5 => \pocketmine\block\utils\DyeColor::GREEN(),
|
||||
6 => \pocketmine\block\utils\DyeColor::LIGHT_BLUE(),
|
||||
7 => \pocketmine\block\utils\DyeColor::LIGHT_GRAY(),
|
||||
8 => \pocketmine\block\utils\DyeColor::LIME(),
|
||||
9 => \pocketmine\block\utils\DyeColor::MAGENTA(),
|
||||
10 => \pocketmine\block\utils\DyeColor::ORANGE(),
|
||||
11 => \pocketmine\block\utils\DyeColor::PINK(),
|
||||
12 => \pocketmine\block\utils\DyeColor::PURPLE(),
|
||||
13 => \pocketmine\block\utils\DyeColor::RED(),
|
||||
14 => \pocketmine\block\utils\DyeColor::WHITE(),
|
||||
15 => \pocketmine\block\utils\DyeColor::YELLOW(),
|
||||
default => throw new \pocketmine\block\utils\InvalidBlockStateException("Invalid serialized value for DyeColor")
|
||||
};
|
||||
}
|
||||
|
||||
public static function readLeverFacing(BlockDataReader $r) : LeverFacing{
|
||||
return match($r->readInt(3)){
|
||||
0 => \pocketmine\block\utils\LeverFacing::DOWN_AXIS_X(),
|
||||
1 => \pocketmine\block\utils\LeverFacing::DOWN_AXIS_Z(),
|
||||
2 => \pocketmine\block\utils\LeverFacing::EAST(),
|
||||
3 => \pocketmine\block\utils\LeverFacing::NORTH(),
|
||||
4 => \pocketmine\block\utils\LeverFacing::SOUTH(),
|
||||
5 => \pocketmine\block\utils\LeverFacing::UP_AXIS_X(),
|
||||
6 => \pocketmine\block\utils\LeverFacing::UP_AXIS_Z(),
|
||||
7 => \pocketmine\block\utils\LeverFacing::WEST(),
|
||||
default => throw new \pocketmine\block\utils\InvalidBlockStateException("Invalid serialized value for LeverFacing")
|
||||
};
|
||||
}
|
||||
|
||||
public static function readMushroomBlockType(BlockDataReader $r) : MushroomBlockType{
|
||||
return match($r->readInt(4)){
|
||||
0 => \pocketmine\block\utils\MushroomBlockType::ALL_CAP(),
|
||||
1 => \pocketmine\block\utils\MushroomBlockType::CAP_EAST(),
|
||||
2 => \pocketmine\block\utils\MushroomBlockType::CAP_MIDDLE(),
|
||||
3 => \pocketmine\block\utils\MushroomBlockType::CAP_NORTH(),
|
||||
4 => \pocketmine\block\utils\MushroomBlockType::CAP_NORTHEAST(),
|
||||
5 => \pocketmine\block\utils\MushroomBlockType::CAP_NORTHWEST(),
|
||||
6 => \pocketmine\block\utils\MushroomBlockType::CAP_SOUTH(),
|
||||
7 => \pocketmine\block\utils\MushroomBlockType::CAP_SOUTHEAST(),
|
||||
8 => \pocketmine\block\utils\MushroomBlockType::CAP_SOUTHWEST(),
|
||||
9 => \pocketmine\block\utils\MushroomBlockType::CAP_WEST(),
|
||||
10 => \pocketmine\block\utils\MushroomBlockType::PORES(),
|
||||
default => throw new \pocketmine\block\utils\InvalidBlockStateException("Invalid serialized value for MushroomBlockType")
|
||||
};
|
||||
}
|
||||
|
||||
public static function readSkullType(BlockDataReader $r) : SkullType{
|
||||
return match($r->readInt(3)){
|
||||
0 => \pocketmine\block\utils\SkullType::CREEPER(),
|
||||
1 => \pocketmine\block\utils\SkullType::DRAGON(),
|
||||
2 => \pocketmine\block\utils\SkullType::PLAYER(),
|
||||
3 => \pocketmine\block\utils\SkullType::SKELETON(),
|
||||
4 => \pocketmine\block\utils\SkullType::WITHER_SKELETON(),
|
||||
5 => \pocketmine\block\utils\SkullType::ZOMBIE(),
|
||||
default => throw new \pocketmine\block\utils\InvalidBlockStateException("Invalid serialized value for SkullType")
|
||||
};
|
||||
}
|
||||
|
||||
public static function readSlabType(BlockDataReader $r) : SlabType{
|
||||
return match($r->readInt(2)){
|
||||
0 => \pocketmine\block\utils\SlabType::BOTTOM(),
|
||||
1 => \pocketmine\block\utils\SlabType::DOUBLE(),
|
||||
2 => \pocketmine\block\utils\SlabType::TOP(),
|
||||
default => throw new \pocketmine\block\utils\InvalidBlockStateException("Invalid serialized value for SlabType")
|
||||
};
|
||||
}
|
||||
|
||||
public static function readStairShape(BlockDataReader $r) : StairShape{
|
||||
return match($r->readInt(3)){
|
||||
0 => \pocketmine\block\utils\StairShape::INNER_LEFT(),
|
||||
1 => \pocketmine\block\utils\StairShape::INNER_RIGHT(),
|
||||
2 => \pocketmine\block\utils\StairShape::OUTER_LEFT(),
|
||||
3 => \pocketmine\block\utils\StairShape::OUTER_RIGHT(),
|
||||
4 => \pocketmine\block\utils\StairShape::STRAIGHT(),
|
||||
default => throw new \pocketmine\block\utils\InvalidBlockStateException("Invalid serialized value for StairShape")
|
||||
};
|
||||
}
|
||||
|
||||
public static function readTreeType(BlockDataReader $r) : TreeType{
|
||||
return match($r->readInt(3)){
|
||||
0 => \pocketmine\block\utils\TreeType::ACACIA(),
|
||||
1 => \pocketmine\block\utils\TreeType::BIRCH(),
|
||||
2 => \pocketmine\block\utils\TreeType::DARK_OAK(),
|
||||
3 => \pocketmine\block\utils\TreeType::JUNGLE(),
|
||||
4 => \pocketmine\block\utils\TreeType::OAK(),
|
||||
5 => \pocketmine\block\utils\TreeType::SPRUCE(),
|
||||
default => throw new \pocketmine\block\utils\InvalidBlockStateException("Invalid serialized value for TreeType")
|
||||
};
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user