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:
Dylan K. Taylor
2025-04-20 19:48:28 +01:00
parent 028815490e
commit ad6f7dfedb
4 changed files with 35 additions and 0 deletions

View File

@ -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