Clean up confusing mess around block and item overriding

right now, I don't see an obvious reason to do this. If it turns out I was wrong later on, we can add functionality back, but we can't remove functionality after release.
This commit is contained in:
Dylan K. Taylor
2023-05-17 15:21:49 +01:00
parent c9bb4335a1
commit 9621836e36
5 changed files with 11 additions and 25 deletions

View File

@ -81,22 +81,16 @@ class RuntimeBlockStateRegistry{
}
/**
* Maps a block type to its corresponding type ID. This is necessary for the block to be recognized when loading
* from disk, and also when being read at runtime.
* Maps a block type's state permutations to its corresponding state IDs. This is necessary for the block to be
* recognized when fetching it by its state ID from chunks at runtime.
*
* NOTE: If you are registering a new block type, you will need to add it to the creative inventory yourself - it
* will not automatically appear there.
*
* @param bool $override Whether to override existing registrations
*
* @throws \InvalidArgumentException if something attempted to override an already-registered block without specifying the
* $override parameter.
* @throws \InvalidArgumentException if the desired block type ID is already registered
*/
public function register(Block $block, bool $override = false) : void{
public function register(Block $block) : void{
$typeId = $block->getTypeId();
if(!$override && isset($this->typeIndex[$typeId])){
throw new \InvalidArgumentException("Block ID $typeId is already used by another block, and override was not requested");
if(isset($this->typeIndex[$typeId])){
throw new \InvalidArgumentException("Block ID $typeId is already used by another block");
}
$this->typeIndex[$typeId] = clone $block;