mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-07 18:32:55 +00:00
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:
@ -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;
|
||||
|
Reference in New Issue
Block a user