From a2a6286e1c51c8d5617120f1ab07400aa0f4edf4 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Wed, 17 Oct 2018 17:12:53 +0100 Subject: [PATCH] ItemFactory: clean up some unnecessary code this try/catch isn't needed because the list offset derivation function will deal with invalid IDs anyway. --- src/pocketmine/item/ItemFactory.php | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/src/pocketmine/item/ItemFactory.php b/src/pocketmine/item/ItemFactory.php index d5a291fa4..4493b88a7 100644 --- a/src/pocketmine/item/ItemFactory.php +++ b/src/pocketmine/item/ItemFactory.php @@ -346,25 +346,19 @@ class ItemFactory{ /** @var Item $item */ $item = null; if($meta !== -1){ - try{ - $sublist = self::$list[self::getListOffset($id)]; + $sublist = self::$list[self::getListOffset($id)]; - /** @var Item|null $listed */ - if($sublist !== null){ - if(isset($sublist[$meta])){ - $item = clone $sublist[$meta]; - }elseif(isset($sublist[0]) and $sublist[0] instanceof Durable){ - /** @var Durable $item */ - $item = clone $sublist[0]; - $item->setDamage($meta); - } - }elseif($id < 256){ //intentionally includes negatives, for extended block IDs - /* Blocks must have a damage value 0-15, but items can have damage value -1 to indicate that they are - * crafting ingredients with any-damage. */ - $item = new ItemBlock($id, $meta); + /** @var Item|null $listed */ + if($sublist !== null){ + if(isset($sublist[$meta])){ + $item = clone $sublist[$meta]; + }elseif(isset($sublist[0]) and $sublist[0] instanceof Durable){ + /** @var Durable $item */ + $item = clone $sublist[0]; + $item->setDamage($meta); } - }catch(\RuntimeException $e){ - throw new \InvalidArgumentException("Item ID $id is invalid or out of bounds"); + }elseif($id < 256){ //intentionally includes negatives, for extended block IDs + $item = new ItemBlock($id, $meta); } }