diff --git a/src/block/Block.php b/src/block/Block.php index fb43a214f..934a485d9 100644 --- a/src/block/Block.php +++ b/src/block/Block.php @@ -132,7 +132,7 @@ class Block{ * This ID can be used to later obtain a copy of this block using {@link RuntimeBlockStateRegistry::fromStateId()}. */ public function getStateId() : int{ - return ($this->getTypeId() << self::INTERNAL_STATE_DATA_BITS) | $this->computeStateData(); + return ($this->getTypeId() << self::INTERNAL_STATE_DATA_BITS) | $this->computeTypeAndStateData(); } /** @@ -214,7 +214,7 @@ class Block{ /** * @internal */ - final public function decodeStateData(int $data) : void{ + final public function decodeTypeAndStateData(int $data) : void{ $typeBits = $this->getRequiredTypeDataBits(); $stateBits = $this->getRequiredStateDataBits(); $reader = new RuntimeDataReader($typeBits + $stateBits, $data); @@ -246,7 +246,7 @@ class Block{ /** * @internal */ - final public function computeStateData() : int{ + final public function computeTypeAndStateData() : int{ $typeBits = $this->getRequiredTypeDataBits(); $stateBits = $this->getRequiredStateDataBits(); $writer = new RuntimeDataWriter($typeBits + $stateBits); @@ -720,7 +720,7 @@ class Block{ * @return string */ public function __toString(){ - return "Block[" . $this->getName() . "] (" . $this->getTypeId() . ":" . $this->computeStateData() . ")"; + return "Block[" . $this->getName() . "] (" . $this->getTypeId() . ":" . $this->computeTypeAndStateData() . ")"; } /** diff --git a/src/block/RuntimeBlockStateRegistry.php b/src/block/RuntimeBlockStateRegistry.php index ae6386e33..ed3761b72 100644 --- a/src/block/RuntimeBlockStateRegistry.php +++ b/src/block/RuntimeBlockStateRegistry.php @@ -97,10 +97,10 @@ class RuntimeBlockStateRegistry{ for($stateData = 0; $stateData < (1 << $bits); ++$stateData){ $v = clone $block; try{ - $v->decodeStateData($stateData); - if($v->computeStateData() !== $stateData){ + $v->decodeTypeAndStateData($stateData); + if($v->computeTypeAndStateData() !== $stateData){ //TODO: this should probably be a hard error - throw new \LogicException(get_class($block) . "::decodeStateData() accepts invalid state data (returned " . $v->computeStateData() . " for input $stateData)"); + throw new \LogicException(get_class($block) . "::decodeStateData() accepts invalid state data (returned " . $v->computeTypeAndStateData() . " for input $stateData)"); } }catch(InvalidSerializedRuntimeDataException){ //invalid property combination, leave it continue; diff --git a/tests/phpunit/block/BlockTest.php b/tests/phpunit/block/BlockTest.php index 3f6dbac95..8712212c5 100644 --- a/tests/phpunit/block/BlockTest.php +++ b/tests/phpunit/block/BlockTest.php @@ -126,7 +126,7 @@ class BlockTest extends TestCase{ $states = $this->blockFactory->getAllKnownStates(); foreach($states as $stateId => $state){ - self::assertArrayHasKey($stateId, $knownStates, "New block state $stateId (" . $state->getTypeId() . ":" . $state->computeStateData() . ", " . print_r($state, true) . ") - consistency check may need regenerating"); + self::assertArrayHasKey($stateId, $knownStates, "New block state $stateId (" . $state->getTypeId() . ":" . $state->computeTypeAndStateData() . ", " . print_r($state, true) . ") - consistency check may need regenerating"); self::assertSame($knownStates[$stateId], $state->getName()); } asort($knownStates, SORT_STRING);