Removed redundant count parameter from item constructors, added some documentation and tightened safety checks

the count parameter is useless since Item ctor should now only be used for constructing item _types_, not actual items. All item creations for inventories etc, should go through the ItemFactory.
This commit is contained in:
Dylan K. Taylor
2017-08-25 19:06:23 +01:00
parent 1fec16f167
commit 9e142655ea
113 changed files with 295 additions and 270 deletions

View File

@ -370,11 +370,14 @@ class BlockFactory{
* @return Block
*/
public static function get(int $id, int $meta = 0, Position $pos = null) : Block{
if($meta < 0 or $meta > 0xf){
throw new \InvalidArgumentException("Block meta value $meta is out of bounds");
}
try{
$block = clone self::$fullList[($id << 4) | $meta];
}catch(\RuntimeException $e){
//TODO: this probably should return null (out of bounds IDs may cause unexpected behaviour)
$block = new UnknownBlock($id, $meta);
throw new \InvalidArgumentException("Block ID $id is out of bounds");
}
if($pos !== null){