Merge branch 'master' into mcpe-1.2

This commit is contained in:
Dylan K. Taylor
2017-09-14 18:16:45 +01:00
12 changed files with 220 additions and 52 deletions

View File

@ -256,7 +256,7 @@ class ItemFactory{
*/
public static function registerItem(Item $item, bool $override = false){
$id = $item->getId();
if(!$override and self::$list[$id] !== null){
if(!$override and self::isRegistered($id)){
throw new \RuntimeException("Trying to overwrite an already registered item");
}
@ -350,4 +350,17 @@ class ItemFactory{
return $item;
}
}
/**
* Returns whether the specified item ID is already registered in the item factory.
*
* @param int $id
* @return bool
*/
public static function isRegistered(int $id) : bool{
if($id < 256){
return BlockFactory::isRegistered($id);
}
return self::$list[$id] !== null;
}
}