A giant hack to cut down code needed for runtime block serialization by 50%

this also avoids repeated information and inconsistencies.
This commit is contained in:
Dylan K. Taylor
2022-07-18 18:25:41 +01:00
parent cf34f88a67
commit 6d4279671e
90 changed files with 380 additions and 717 deletions

View File

@ -24,7 +24,6 @@ declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\block\utils\SupportType;
use pocketmine\data\runtime\InvalidSerializedRuntimeDataException;
use pocketmine\data\runtime\RuntimeDataReader;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\item\Item;
@ -40,16 +39,8 @@ class Torch extends Flowable{
public function getRequiredStateDataBits() : int{ return 3; }
protected function decodeState(RuntimeDataReader $r) : void{
$facing = $r->readFacing();
if($facing === Facing::DOWN){
throw new InvalidSerializedRuntimeDataException("Torch cannot have a DOWN facing");
}
$this->facing = $facing;
}
protected function encodeState(RuntimeDataWriter $w) : void{
$w->writeFacing($this->facing);
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{
$w->facingExcept($this->facing, Facing::DOWN);
}
public function getFacing() : int{ return $this->facing; }