Fixed crash when getting an item from a block which came from an item which came from a block

had a stroke yet?
This commit is contained in:
Dylan K. Taylor 2023-06-02 16:16:54 +01:00
parent 007ef833d4
commit 9c6d4093ae
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
2 changed files with 11 additions and 1 deletions

View File

@ -93,7 +93,9 @@ class Block{
$this->describeBlockOnlyState($calculator);
$this->requiredBlockOnlyStateDataBits = $calculator->getBitsUsed();
$this->defaultState = clone $this;
$defaultState = clone $this;
$this->defaultState = $defaultState;
$defaultState->defaultState = $defaultState;
}
public function __clone(){

View File

@ -124,4 +124,12 @@ class BlockTest extends TestCase{
$block = $this->blockFactory->fromStateId(Block::EMPTY_STATE_ID);
self::assertInstanceOf(Air::class, $block);
}
public function testAsItemFromItem() : void{
$block = VanillaBlocks::FLOWER_POT();
$item = $block->asItem();
$defaultBlock = $item->getBlock();
$item2 = $defaultBlock->asItem();
self::assertTrue($item2->equalsExact($item));
}
}