mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-08 19:02:59 +00:00
World: verify saveability of blocks, entities and tiles at entry points
I want to do the same for items, but items are going to be a pain in the ass. For items there are multiple possible entry points and all of them will need to be checked: - dropped items - inventory contents - lecterns - item frames I don't see a good way to deal with all these. We can't check for registration in the constructor because we need to fully construct the item in order to register it. Blocks are also a potential issue in other areas, but setBlock() is definitely the biggest offender.
This commit is contained in:
@ -225,6 +225,10 @@ final class BlockObjectToStateSerializer implements BlockStateSerializer{
|
||||
return $this->cache[$stateId] ??= $this->serializeBlock(RuntimeBlockStateRegistry::getInstance()->fromStateId($stateId));
|
||||
}
|
||||
|
||||
public function isRegistered(Block $block) : bool{
|
||||
return isset($this->serializers[$block->getTypeId()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @phpstan-template TBlockType of Block
|
||||
* @phpstan-param TBlockType $block
|
||||
|
Reference in New Issue
Block a user