From 9e142655eadbdfed28edd77bfe7513fa0c179b7c Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Fri, 25 Aug 2017 19:06:23 +0100 Subject: [PATCH] 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. --- src/pocketmine/block/Block.php | 5 +- src/pocketmine/block/BlockFactory.php | 7 +- src/pocketmine/item/Apple.php | 4 +- src/pocketmine/item/Arrow.php | 4 +- src/pocketmine/item/BakedPotato.php | 4 +- src/pocketmine/item/Bed.php | 4 +- src/pocketmine/item/Beetroot.php | 4 +- src/pocketmine/item/BeetrootSeeds.php | 4 +- src/pocketmine/item/BeetrootSoup.php | 4 +- src/pocketmine/item/Boat.php | 4 +- src/pocketmine/item/Book.php | 4 +- src/pocketmine/item/Bow.php | 4 +- src/pocketmine/item/Bowl.php | 4 +- src/pocketmine/item/Bread.php | 4 +- src/pocketmine/item/BrewingStand.php | 4 +- src/pocketmine/item/Bucket.php | 4 +- src/pocketmine/item/Cake.php | 4 +- src/pocketmine/item/Carrot.php | 4 +- src/pocketmine/item/ChainBoots.php | 4 +- src/pocketmine/item/ChainChestplate.php | 4 +- src/pocketmine/item/ChainHelmet.php | 4 +- src/pocketmine/item/ChainLeggings.php | 4 +- src/pocketmine/item/Clock.php | 4 +- src/pocketmine/item/Coal.php | 4 +- src/pocketmine/item/Compass.php | 4 +- src/pocketmine/item/CookedChicken.php | 4 +- src/pocketmine/item/CookedFish.php | 4 +- src/pocketmine/item/CookedPorkchop.php | 4 +- src/pocketmine/item/CookedRabbit.php | 4 +- src/pocketmine/item/Cookie.php | 4 +- src/pocketmine/item/DiamondAxe.php | 4 +- src/pocketmine/item/DiamondBoots.php | 4 +- src/pocketmine/item/DiamondChestplate.php | 4 +- src/pocketmine/item/DiamondHelmet.php | 4 +- src/pocketmine/item/DiamondHoe.php | 4 +- src/pocketmine/item/DiamondLeggings.php | 4 +- src/pocketmine/item/DiamondPickaxe.php | 4 +- src/pocketmine/item/DiamondShovel.php | 4 +- src/pocketmine/item/DiamondSword.php | 4 +- src/pocketmine/item/Dye.php | 4 +- src/pocketmine/item/Egg.php | 4 +- src/pocketmine/item/Fish.php | 4 +- src/pocketmine/item/FishingRod.php | 4 +- src/pocketmine/item/FlintSteel.php | 6 +- src/pocketmine/item/FlowerPot.php | 4 +- src/pocketmine/item/GlassBottle.php | 4 +- src/pocketmine/item/GoldAxe.php | 4 +- src/pocketmine/item/GoldBoots.php | 4 +- src/pocketmine/item/GoldChestplate.php | 4 +- src/pocketmine/item/GoldHelmet.php | 4 +- src/pocketmine/item/GoldHoe.php | 4 +- src/pocketmine/item/GoldLeggings.php | 4 +- src/pocketmine/item/GoldPickaxe.php | 4 +- src/pocketmine/item/GoldShovel.php | 4 +- src/pocketmine/item/GoldSword.php | 4 +- src/pocketmine/item/GoldenApple.php | 4 +- src/pocketmine/item/GoldenAppleEnchanted.php | 4 +- src/pocketmine/item/GoldenCarrot.php | 4 +- src/pocketmine/item/IronAxe.php | 4 +- src/pocketmine/item/IronBoots.php | 4 +- src/pocketmine/item/IronChestplate.php | 4 +- src/pocketmine/item/IronDoor.php | 4 +- src/pocketmine/item/IronHelmet.php | 4 +- src/pocketmine/item/IronHoe.php | 4 +- src/pocketmine/item/IronLeggings.php | 4 +- src/pocketmine/item/IronPickaxe.php | 4 +- src/pocketmine/item/IronShovel.php | 4 +- src/pocketmine/item/IronSword.php | 4 +- src/pocketmine/item/Item.php | 22 +++-- src/pocketmine/item/ItemBlock.php | 11 ++- src/pocketmine/item/ItemFactory.php | 86 +++++++++++--------- src/pocketmine/item/ItemFrame.php | 4 +- src/pocketmine/item/LeatherBoots.php | 4 +- src/pocketmine/item/LeatherCap.php | 4 +- src/pocketmine/item/LeatherPants.php | 4 +- src/pocketmine/item/LeatherTunic.php | 4 +- src/pocketmine/item/Melon.php | 4 +- src/pocketmine/item/MelonSeeds.php | 4 +- src/pocketmine/item/Minecart.php | 4 +- src/pocketmine/item/MushroomStew.php | 4 +- src/pocketmine/item/NetherWart.php | 4 +- src/pocketmine/item/Painting.php | 4 +- src/pocketmine/item/Potato.php | 4 +- src/pocketmine/item/Potion.php | 4 +- src/pocketmine/item/PumpkinPie.php | 4 +- src/pocketmine/item/PumpkinSeeds.php | 4 +- src/pocketmine/item/RawBeef.php | 4 +- src/pocketmine/item/RawChicken.php | 4 +- src/pocketmine/item/RawPorkchop.php | 4 +- src/pocketmine/item/Redstone.php | 4 +- src/pocketmine/item/Shears.php | 4 +- src/pocketmine/item/Sign.php | 4 +- src/pocketmine/item/Skull.php | 4 +- src/pocketmine/item/Snowball.php | 4 +- src/pocketmine/item/SpawnEgg.php | 4 +- src/pocketmine/item/SpiderEye.php | 4 +- src/pocketmine/item/Steak.php | 4 +- src/pocketmine/item/Stick.php | 4 +- src/pocketmine/item/StoneAxe.php | 4 +- src/pocketmine/item/StoneHoe.php | 4 +- src/pocketmine/item/StonePickaxe.php | 4 +- src/pocketmine/item/StoneShovel.php | 4 +- src/pocketmine/item/StoneSword.php | 4 +- src/pocketmine/item/StringItem.php | 4 +- src/pocketmine/item/Sugarcane.php | 4 +- src/pocketmine/item/Tool.php | 4 - src/pocketmine/item/WheatSeeds.php | 4 +- src/pocketmine/item/WoodenAxe.php | 4 +- src/pocketmine/item/WoodenDoor.php | 4 +- src/pocketmine/item/WoodenHoe.php | 4 +- src/pocketmine/item/WoodenPickaxe.php | 4 +- src/pocketmine/item/WoodenShovel.php | 4 +- src/pocketmine/item/WoodenSword.php | 4 +- 113 files changed, 295 insertions(+), 270 deletions(-) diff --git a/src/pocketmine/block/Block.php b/src/pocketmine/block/Block.php index 396343f9a..727352c39 100644 --- a/src/pocketmine/block/Block.php +++ b/src/pocketmine/block/Block.php @@ -117,7 +117,10 @@ class Block extends Position implements BlockIds, Metadatable{ * @param int $meta */ final public function setDamage(int $meta){ - $this->meta = $meta & 0x0f; + if($meta < 0 or $meta > 0xf){ + throw new \InvalidArgumentException("Block damage values must be 0-15, not $meta"); + } + $this->meta = $meta; } /** diff --git a/src/pocketmine/block/BlockFactory.php b/src/pocketmine/block/BlockFactory.php index 0bd81d4bb..6f41575d6 100644 --- a/src/pocketmine/block/BlockFactory.php +++ b/src/pocketmine/block/BlockFactory.php @@ -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){ diff --git a/src/pocketmine/item/Apple.php b/src/pocketmine/item/Apple.php index 5b2a2947d..1184d60cd 100644 --- a/src/pocketmine/item/Apple.php +++ b/src/pocketmine/item/Apple.php @@ -25,8 +25,8 @@ namespace pocketmine\item; class Apple extends Food{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::APPLE, $meta, $count, "Apple"); + public function __construct(int $meta = 0){ + parent::__construct(self::APPLE, $meta, "Apple"); } public function getFoodRestore() : int{ diff --git a/src/pocketmine/item/Arrow.php b/src/pocketmine/item/Arrow.php index ab5300ac3..e86076fc7 100644 --- a/src/pocketmine/item/Arrow.php +++ b/src/pocketmine/item/Arrow.php @@ -24,8 +24,8 @@ declare(strict_types=1); namespace pocketmine\item; class Arrow extends Item{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::ARROW, $meta, $count, "Arrow"); + public function __construct(int $meta = 0){ + parent::__construct(self::ARROW, $meta, "Arrow"); } } diff --git a/src/pocketmine/item/BakedPotato.php b/src/pocketmine/item/BakedPotato.php index a3bf3b31a..932b0ce0d 100644 --- a/src/pocketmine/item/BakedPotato.php +++ b/src/pocketmine/item/BakedPotato.php @@ -24,8 +24,8 @@ declare(strict_types=1); namespace pocketmine\item; class BakedPotato extends Food{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::BAKED_POTATO, $meta, $count, "Baked Potato"); + public function __construct(int $meta = 0){ + parent::__construct(self::BAKED_POTATO, $meta, "Baked Potato"); } public function getFoodRestore() : int{ diff --git a/src/pocketmine/item/Bed.php b/src/pocketmine/item/Bed.php index e9e6d5505..fece690a3 100644 --- a/src/pocketmine/item/Bed.php +++ b/src/pocketmine/item/Bed.php @@ -27,9 +27,9 @@ use pocketmine\block\Block; use pocketmine\block\BlockFactory; class Bed extends Item{ - public function __construct($meta = 0, $count = 1){ + public function __construct(int $meta = 0){ $this->block = BlockFactory::get(Block::BED_BLOCK); - parent::__construct(self::BED, $meta, $count, "Bed"); + parent::__construct(self::BED, $meta, "Bed"); } public function getMaxStackSize(){ diff --git a/src/pocketmine/item/Beetroot.php b/src/pocketmine/item/Beetroot.php index f84157717..3e36291ca 100644 --- a/src/pocketmine/item/Beetroot.php +++ b/src/pocketmine/item/Beetroot.php @@ -24,8 +24,8 @@ declare(strict_types=1); namespace pocketmine\item; class Beetroot extends Food{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::BEETROOT, $meta, $count, "Beetroot"); + public function __construct(int $meta = 0){ + parent::__construct(self::BEETROOT, $meta, "Beetroot"); } public function getFoodRestore() : int{ diff --git a/src/pocketmine/item/BeetrootSeeds.php b/src/pocketmine/item/BeetrootSeeds.php index a0bd39c14..5be598aa2 100644 --- a/src/pocketmine/item/BeetrootSeeds.php +++ b/src/pocketmine/item/BeetrootSeeds.php @@ -27,8 +27,8 @@ use pocketmine\block\Block; use pocketmine\block\BlockFactory; class BeetrootSeeds extends Item{ - public function __construct($meta = 0, $count = 1){ + public function __construct(int $meta = 0){ $this->block = BlockFactory::get(Block::BEETROOT_BLOCK); - parent::__construct(self::BEETROOT_SEEDS, $meta, $count, "Beetroot Seeds"); + parent::__construct(self::BEETROOT_SEEDS, $meta, "Beetroot Seeds"); } } \ No newline at end of file diff --git a/src/pocketmine/item/BeetrootSoup.php b/src/pocketmine/item/BeetrootSoup.php index 0b0f62856..011846038 100644 --- a/src/pocketmine/item/BeetrootSoup.php +++ b/src/pocketmine/item/BeetrootSoup.php @@ -25,8 +25,8 @@ namespace pocketmine\item; class BeetrootSoup extends Food{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::BEETROOT_SOUP, $meta, $count, "Beetroot Soup"); + public function __construct(int $meta = 0){ + parent::__construct(self::BEETROOT_SOUP, $meta, "Beetroot Soup"); } public function getMaxStackSize(){ diff --git a/src/pocketmine/item/Boat.php b/src/pocketmine/item/Boat.php index d25a960e7..35c05d997 100644 --- a/src/pocketmine/item/Boat.php +++ b/src/pocketmine/item/Boat.php @@ -24,8 +24,8 @@ declare(strict_types=1); namespace pocketmine\item; class Boat extends Item{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::BOAT, $meta, $count, "Boat"); + public function __construct(int $meta = 0){ + parent::__construct(self::BOAT, $meta, "Boat"); } public function getFuelTime() : int{ diff --git a/src/pocketmine/item/Book.php b/src/pocketmine/item/Book.php index ba60042fa..4cc3bfd47 100644 --- a/src/pocketmine/item/Book.php +++ b/src/pocketmine/item/Book.php @@ -24,8 +24,8 @@ declare(strict_types=1); namespace pocketmine\item; class Book extends Item{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::BOOK, $meta, $count, "Book"); + public function __construct(int $meta = 0){ + parent::__construct(self::BOOK, $meta, "Book"); } } diff --git a/src/pocketmine/item/Bow.php b/src/pocketmine/item/Bow.php index ab45bc4d5..7fe68608c 100644 --- a/src/pocketmine/item/Bow.php +++ b/src/pocketmine/item/Bow.php @@ -25,8 +25,8 @@ namespace pocketmine\item; class Bow extends Tool{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::BOW, $meta, $count, "Bow"); + public function __construct(int $meta = 0){ + parent::__construct(self::BOW, $meta, "Bow"); } public function getFuelTime() : int{ diff --git a/src/pocketmine/item/Bowl.php b/src/pocketmine/item/Bowl.php index 5d1593038..6d8405f0c 100644 --- a/src/pocketmine/item/Bowl.php +++ b/src/pocketmine/item/Bowl.php @@ -25,8 +25,8 @@ namespace pocketmine\item; class Bowl extends Item{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::BOWL, $meta, $count, "Bowl"); + public function __construct(int $meta = 0){ + parent::__construct(self::BOWL, $meta, "Bowl"); } //TODO: check fuel diff --git a/src/pocketmine/item/Bread.php b/src/pocketmine/item/Bread.php index a4d74bcd6..6673a470b 100644 --- a/src/pocketmine/item/Bread.php +++ b/src/pocketmine/item/Bread.php @@ -24,8 +24,8 @@ declare(strict_types=1); namespace pocketmine\item; class Bread extends Food{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::BREAD, $meta, $count, "Bread"); + public function __construct(int $meta = 0){ + parent::__construct(self::BREAD, $meta, "Bread"); } public function getFoodRestore() : int{ diff --git a/src/pocketmine/item/BrewingStand.php b/src/pocketmine/item/BrewingStand.php index 7b1da0b8a..9597d4ba0 100644 --- a/src/pocketmine/item/BrewingStand.php +++ b/src/pocketmine/item/BrewingStand.php @@ -26,8 +26,8 @@ namespace pocketmine\item; use pocketmine\block\Block; class BrewingStand extends Item{ - public function __construct($meta = 0, $count = 1){ + public function __construct(int $meta = 0){ $this->block = Block::get(Block::BREWING_STAND_BLOCK); - parent::__construct(self::BREWING_STAND, $meta, $count, "Brewing Stand"); + parent::__construct(self::BREWING_STAND, $meta, "Brewing Stand"); } } diff --git a/src/pocketmine/item/Bucket.php b/src/pocketmine/item/Bucket.php index 087541323..86c470453 100644 --- a/src/pocketmine/item/Bucket.php +++ b/src/pocketmine/item/Bucket.php @@ -33,8 +33,8 @@ use pocketmine\math\Vector3; use pocketmine\Player; class Bucket extends Item{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::BUCKET, $meta, $count, "Bucket"); + public function __construct(int $meta = 0){ + parent::__construct(self::BUCKET, $meta, "Bucket"); } public function getMaxStackSize(){ diff --git a/src/pocketmine/item/Cake.php b/src/pocketmine/item/Cake.php index ef1aa14c0..4ac6544c1 100644 --- a/src/pocketmine/item/Cake.php +++ b/src/pocketmine/item/Cake.php @@ -27,9 +27,9 @@ use pocketmine\block\Block; use pocketmine\block\BlockFactory; class Cake extends Item{ - public function __construct($meta = 0, $count = 1){ + public function __construct(int $meta = 0){ $this->block = BlockFactory::get(Block::CAKE_BLOCK); - parent::__construct(self::CAKE, $meta, $count, "Cake"); + parent::__construct(self::CAKE, $meta, "Cake"); } public function getMaxStackSize(){ diff --git a/src/pocketmine/item/Carrot.php b/src/pocketmine/item/Carrot.php index ee6ba7b40..d39588d26 100644 --- a/src/pocketmine/item/Carrot.php +++ b/src/pocketmine/item/Carrot.php @@ -27,9 +27,9 @@ use pocketmine\block\Block; use pocketmine\block\BlockFactory; class Carrot extends Food{ - public function __construct($meta = 0, $count = 1){ + public function __construct(int $meta = 0){ $this->block = BlockFactory::get(Block::CARROT_BLOCK); - parent::__construct(self::CARROT, $meta, $count, "Carrot"); + parent::__construct(self::CARROT, $meta, "Carrot"); } public function getFoodRestore() : int{ diff --git a/src/pocketmine/item/ChainBoots.php b/src/pocketmine/item/ChainBoots.php index 9786690b6..8caf1be6d 100644 --- a/src/pocketmine/item/ChainBoots.php +++ b/src/pocketmine/item/ChainBoots.php @@ -25,7 +25,7 @@ namespace pocketmine\item; class ChainBoots extends Armor{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::CHAIN_BOOTS, $meta, $count, "Chainmail Boots"); + public function __construct(int $meta = 0){ + parent::__construct(self::CHAIN_BOOTS, $meta, "Chainmail Boots"); } } \ No newline at end of file diff --git a/src/pocketmine/item/ChainChestplate.php b/src/pocketmine/item/ChainChestplate.php index e573e6a24..2a78b3d89 100644 --- a/src/pocketmine/item/ChainChestplate.php +++ b/src/pocketmine/item/ChainChestplate.php @@ -25,7 +25,7 @@ namespace pocketmine\item; class ChainChestplate extends Armor{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::CHAIN_CHESTPLATE, $meta, $count, "Chain Chestplate"); + public function __construct(int $meta = 0){ + parent::__construct(self::CHAIN_CHESTPLATE, $meta, "Chain Chestplate"); } } \ No newline at end of file diff --git a/src/pocketmine/item/ChainHelmet.php b/src/pocketmine/item/ChainHelmet.php index b6a31f8e9..e81aca216 100644 --- a/src/pocketmine/item/ChainHelmet.php +++ b/src/pocketmine/item/ChainHelmet.php @@ -25,7 +25,7 @@ namespace pocketmine\item; class ChainHelmet extends Armor{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::CHAIN_HELMET, $meta, $count, "Chainmail Helmet"); + public function __construct(int $meta = 0){ + parent::__construct(self::CHAIN_HELMET, $meta, "Chainmail Helmet"); } } \ No newline at end of file diff --git a/src/pocketmine/item/ChainLeggings.php b/src/pocketmine/item/ChainLeggings.php index 90a60bc79..32215ef55 100644 --- a/src/pocketmine/item/ChainLeggings.php +++ b/src/pocketmine/item/ChainLeggings.php @@ -25,7 +25,7 @@ namespace pocketmine\item; class ChainLeggings extends Armor{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::CHAIN_LEGGINGS, $meta, $count, "Chain Leggings"); + public function __construct(int $meta = 0){ + parent::__construct(self::CHAIN_LEGGINGS, $meta, "Chain Leggings"); } } \ No newline at end of file diff --git a/src/pocketmine/item/Clock.php b/src/pocketmine/item/Clock.php index 993d18815..fa48afb68 100644 --- a/src/pocketmine/item/Clock.php +++ b/src/pocketmine/item/Clock.php @@ -24,8 +24,8 @@ declare(strict_types=1); namespace pocketmine\item; class Clock extends Item{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::CLOCK, $meta, $count, "Clock"); + public function __construct(int $meta = 0){ + parent::__construct(self::CLOCK, $meta, "Clock"); } } diff --git a/src/pocketmine/item/Coal.php b/src/pocketmine/item/Coal.php index 1dd48ab47..da21c589a 100644 --- a/src/pocketmine/item/Coal.php +++ b/src/pocketmine/item/Coal.php @@ -25,8 +25,8 @@ namespace pocketmine\item; class Coal extends Item{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::COAL, $meta, $count, "Coal"); + public function __construct(int $meta = 0){ + parent::__construct(self::COAL, $meta, "Coal"); if($this->meta === 1){ $this->name = "Charcoal"; } diff --git a/src/pocketmine/item/Compass.php b/src/pocketmine/item/Compass.php index ace5fdcec..98e95ad2a 100644 --- a/src/pocketmine/item/Compass.php +++ b/src/pocketmine/item/Compass.php @@ -24,8 +24,8 @@ declare(strict_types=1); namespace pocketmine\item; class Compass extends Item{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::COMPASS, $meta, $count, "Compass"); + public function __construct(int $meta = 0){ + parent::__construct(self::COMPASS, $meta, "Compass"); } } diff --git a/src/pocketmine/item/CookedChicken.php b/src/pocketmine/item/CookedChicken.php index 55369f19c..153183d37 100644 --- a/src/pocketmine/item/CookedChicken.php +++ b/src/pocketmine/item/CookedChicken.php @@ -24,8 +24,8 @@ declare(strict_types=1); namespace pocketmine\item; class CookedChicken extends Food{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::COOKED_CHICKEN, $meta, $count, "Cooked Chicken"); + public function __construct(int $meta = 0){ + parent::__construct(self::COOKED_CHICKEN, $meta, "Cooked Chicken"); } public function getFoodRestore() : int{ diff --git a/src/pocketmine/item/CookedFish.php b/src/pocketmine/item/CookedFish.php index 168a61c62..27e77e64b 100644 --- a/src/pocketmine/item/CookedFish.php +++ b/src/pocketmine/item/CookedFish.php @@ -24,8 +24,8 @@ declare(strict_types=1); namespace pocketmine\item; class CookedFish extends Fish{ - public function __construct($meta = 0, $count = 1){ - Food::__construct(self::COOKED_FISH, $meta, $count, $meta === self::FISH_SALMON ? "Cooked Salmon" : "Cooked Fish"); + public function __construct(int $meta = 0){ + Food::__construct(self::COOKED_FISH, $meta, $meta === self::FISH_SALMON ? "Cooked Salmon" : "Cooked Fish"); } public function getFoodRestore() : int{ diff --git a/src/pocketmine/item/CookedPorkchop.php b/src/pocketmine/item/CookedPorkchop.php index 9b13ebb3d..7d6d8e387 100644 --- a/src/pocketmine/item/CookedPorkchop.php +++ b/src/pocketmine/item/CookedPorkchop.php @@ -24,8 +24,8 @@ declare(strict_types=1); namespace pocketmine\item; class CookedPorkchop extends Food{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::COOKED_PORKCHOP, $meta, $count, "Cooked Porkchop"); + public function __construct(int $meta = 0){ + parent::__construct(self::COOKED_PORKCHOP, $meta, "Cooked Porkchop"); } public function getFoodRestore() : int{ diff --git a/src/pocketmine/item/CookedRabbit.php b/src/pocketmine/item/CookedRabbit.php index 51bca14fa..c94543fc3 100644 --- a/src/pocketmine/item/CookedRabbit.php +++ b/src/pocketmine/item/CookedRabbit.php @@ -24,8 +24,8 @@ declare(strict_types=1); namespace pocketmine\item; class CookedRabbit extends Food{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::COOKED_RABBIT, $meta, $count, "Cooked Rabbit"); + public function __construct(int $meta = 0){ + parent::__construct(self::COOKED_RABBIT, $meta, "Cooked Rabbit"); } public function getFoodRestore() : int{ diff --git a/src/pocketmine/item/Cookie.php b/src/pocketmine/item/Cookie.php index 488816c2e..ad1a1f5a3 100644 --- a/src/pocketmine/item/Cookie.php +++ b/src/pocketmine/item/Cookie.php @@ -24,8 +24,8 @@ declare(strict_types=1); namespace pocketmine\item; class Cookie extends Food{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::COOKIE, $meta, $count, "Cookie"); + public function __construct(int $meta = 0){ + parent::__construct(self::COOKIE, $meta, "Cookie"); } public function getFoodRestore() : int{ diff --git a/src/pocketmine/item/DiamondAxe.php b/src/pocketmine/item/DiamondAxe.php index 0352a48c9..1a8d8a5fb 100644 --- a/src/pocketmine/item/DiamondAxe.php +++ b/src/pocketmine/item/DiamondAxe.php @@ -25,8 +25,8 @@ namespace pocketmine\item; class DiamondAxe extends Tool{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::DIAMOND_AXE, $meta, $count, "Diamond Axe"); + public function __construct(int $meta = 0){ + parent::__construct(self::DIAMOND_AXE, $meta, "Diamond Axe"); } public function isAxe(){ diff --git a/src/pocketmine/item/DiamondBoots.php b/src/pocketmine/item/DiamondBoots.php index 7666826b0..89d233435 100644 --- a/src/pocketmine/item/DiamondBoots.php +++ b/src/pocketmine/item/DiamondBoots.php @@ -25,7 +25,7 @@ namespace pocketmine\item; class DiamondBoots extends Armor{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::DIAMOND_BOOTS, $meta, $count, "Diamond Boots"); + public function __construct(int $meta = 0){ + parent::__construct(self::DIAMOND_BOOTS, $meta, "Diamond Boots"); } } \ No newline at end of file diff --git a/src/pocketmine/item/DiamondChestplate.php b/src/pocketmine/item/DiamondChestplate.php index 2aaf9d2ea..dd77d3b92 100644 --- a/src/pocketmine/item/DiamondChestplate.php +++ b/src/pocketmine/item/DiamondChestplate.php @@ -25,7 +25,7 @@ namespace pocketmine\item; class DiamondChestplate extends Armor{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::DIAMOND_CHESTPLATE, $meta, $count, "Diamond Chestplate"); + public function __construct(int $meta = 0){ + parent::__construct(self::DIAMOND_CHESTPLATE, $meta, "Diamond Chestplate"); } } \ No newline at end of file diff --git a/src/pocketmine/item/DiamondHelmet.php b/src/pocketmine/item/DiamondHelmet.php index bb70f7a8f..513bf437e 100644 --- a/src/pocketmine/item/DiamondHelmet.php +++ b/src/pocketmine/item/DiamondHelmet.php @@ -25,7 +25,7 @@ namespace pocketmine\item; class DiamondHelmet extends Armor{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::DIAMOND_HELMET, $meta, $count, "Diamond Helmet"); + public function __construct(int $meta = 0){ + parent::__construct(self::DIAMOND_HELMET, $meta, "Diamond Helmet"); } } \ No newline at end of file diff --git a/src/pocketmine/item/DiamondHoe.php b/src/pocketmine/item/DiamondHoe.php index 5b99f4047..f9414496c 100644 --- a/src/pocketmine/item/DiamondHoe.php +++ b/src/pocketmine/item/DiamondHoe.php @@ -25,8 +25,8 @@ namespace pocketmine\item; class DiamondHoe extends Tool{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::DIAMOND_HOE, $meta, $count, "Diamond Hoe"); + public function __construct(int $meta = 0){ + parent::__construct(self::DIAMOND_HOE, $meta, "Diamond Hoe"); } public function isHoe(){ diff --git a/src/pocketmine/item/DiamondLeggings.php b/src/pocketmine/item/DiamondLeggings.php index 997475abf..ccadf2327 100644 --- a/src/pocketmine/item/DiamondLeggings.php +++ b/src/pocketmine/item/DiamondLeggings.php @@ -25,7 +25,7 @@ namespace pocketmine\item; class DiamondLeggings extends Armor{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::DIAMOND_LEGGINGS, $meta, $count, "Diamond Leggings"); + public function __construct(int $meta = 0){ + parent::__construct(self::DIAMOND_LEGGINGS, $meta, "Diamond Leggings"); } } \ No newline at end of file diff --git a/src/pocketmine/item/DiamondPickaxe.php b/src/pocketmine/item/DiamondPickaxe.php index c9414a508..4a00821bb 100644 --- a/src/pocketmine/item/DiamondPickaxe.php +++ b/src/pocketmine/item/DiamondPickaxe.php @@ -25,8 +25,8 @@ namespace pocketmine\item; class DiamondPickaxe extends Tool{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::DIAMOND_PICKAXE, $meta, $count, "Diamond Pickaxe"); + public function __construct(int $meta = 0){ + parent::__construct(self::DIAMOND_PICKAXE, $meta, "Diamond Pickaxe"); } public function isPickaxe(){ diff --git a/src/pocketmine/item/DiamondShovel.php b/src/pocketmine/item/DiamondShovel.php index 7edefb0aa..d13187066 100644 --- a/src/pocketmine/item/DiamondShovel.php +++ b/src/pocketmine/item/DiamondShovel.php @@ -25,8 +25,8 @@ namespace pocketmine\item; class DiamondShovel extends Tool{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::DIAMOND_SHOVEL, $meta, $count, "Diamond Shovel"); + public function __construct(int $meta = 0){ + parent::__construct(self::DIAMOND_SHOVEL, $meta, "Diamond Shovel"); } public function isShovel(){ diff --git a/src/pocketmine/item/DiamondSword.php b/src/pocketmine/item/DiamondSword.php index 2ad11527f..5b192a9ee 100644 --- a/src/pocketmine/item/DiamondSword.php +++ b/src/pocketmine/item/DiamondSword.php @@ -25,8 +25,8 @@ namespace pocketmine\item; class DiamondSword extends Tool{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::DIAMOND_SWORD, $meta, $count, "Diamond Sword"); + public function __construct(int $meta = 0){ + parent::__construct(self::DIAMOND_SWORD, $meta, "Diamond Sword"); } public function isSword(){ diff --git a/src/pocketmine/item/Dye.php b/src/pocketmine/item/Dye.php index 895016cd9..54a9e137a 100644 --- a/src/pocketmine/item/Dye.php +++ b/src/pocketmine/item/Dye.php @@ -24,8 +24,8 @@ declare(strict_types=1); namespace pocketmine\item; class Dye extends Item{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::DYE, $meta, $count, "Dye"); + public function __construct(int $meta = 0){ + parent::__construct(self::DYE, $meta, "Dye"); } //TODO: names diff --git a/src/pocketmine/item/Egg.php b/src/pocketmine/item/Egg.php index 697112caf..b13868f06 100644 --- a/src/pocketmine/item/Egg.php +++ b/src/pocketmine/item/Egg.php @@ -24,8 +24,8 @@ declare(strict_types=1); namespace pocketmine\item; class Egg extends Item{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::EGG, $meta, $count, "Egg"); + public function __construct(int $meta = 0){ + parent::__construct(self::EGG, $meta, "Egg"); } //TODO diff --git a/src/pocketmine/item/Fish.php b/src/pocketmine/item/Fish.php index 80f5c9fee..cbc41526c 100644 --- a/src/pocketmine/item/Fish.php +++ b/src/pocketmine/item/Fish.php @@ -31,7 +31,7 @@ class Fish extends Food{ const FISH_CLOWNFISH = 2; const FISH_PUFFERFISH = 3; - public function __construct($meta = 0, $count = 1){ + public function __construct(int $meta = 0){ $name = "Raw Fish"; if($this->meta === self::FISH_SALMON){ $name = "Raw Salmon"; @@ -40,7 +40,7 @@ class Fish extends Food{ }elseif($this->meta === self::FISH_PUFFERFISH){ $name = "Pufferfish"; } - parent::__construct(self::RAW_FISH, $meta, $count, $name); + parent::__construct(self::RAW_FISH, $meta, $name); } public function getFoodRestore() : int{ diff --git a/src/pocketmine/item/FishingRod.php b/src/pocketmine/item/FishingRod.php index 8e1fb19d2..43ec05f43 100644 --- a/src/pocketmine/item/FishingRod.php +++ b/src/pocketmine/item/FishingRod.php @@ -24,8 +24,8 @@ declare(strict_types=1); namespace pocketmine\item; class FishingRod extends Item{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::FISHING_ROD, $meta, $count, "Fishing Rod"); + public function __construct(int $meta = 0){ + parent::__construct(self::FISHING_ROD, $meta, "Fishing Rod"); } //TODO diff --git a/src/pocketmine/item/FlintSteel.php b/src/pocketmine/item/FlintSteel.php index b123351a6..6c13b93ea 100644 --- a/src/pocketmine/item/FlintSteel.php +++ b/src/pocketmine/item/FlintSteel.php @@ -31,8 +31,8 @@ use pocketmine\math\Vector3; use pocketmine\Player; class FlintSteel extends Tool{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::FLINT_STEEL, $meta, $count, "Flint and Steel"); + public function __construct(int $meta = 0){ + parent::__construct(self::FLINT_STEEL, $meta, "Flint and Steel"); } public function onActivate(Level $level, Player $player, Block $block, Block $target, int $face, Vector3 $facePos) : bool{ @@ -40,7 +40,7 @@ class FlintSteel extends Tool{ $level->setBlock($block, BlockFactory::get(Block::FIRE), true); if(($player->gamemode & 0x01) === 0 and $this->useOn($block)){ if($this->getDamage() >= $this->getMaxDurability()){ - $player->getInventory()->setItemInHand(new Item(Item::AIR, 0, 0)); + $player->getInventory()->setItemInHand(Item::get(Item::AIR, 0, 0)); }else{ $this->meta++; $player->getInventory()->setItemInHand($this); diff --git a/src/pocketmine/item/FlowerPot.php b/src/pocketmine/item/FlowerPot.php index 9c880bbd3..b0ab35fd4 100644 --- a/src/pocketmine/item/FlowerPot.php +++ b/src/pocketmine/item/FlowerPot.php @@ -27,8 +27,8 @@ use pocketmine\block\Block; use pocketmine\block\BlockFactory; class FlowerPot extends Item{ - public function __construct($meta = 0, $count = 1){ + public function __construct(int $meta = 0){ $this->block = BlockFactory::get(Block::FLOWER_POT_BLOCK); - parent::__construct(self::FLOWER_POT, $meta, $count, "Flower Pot"); + parent::__construct(self::FLOWER_POT, $meta, "Flower Pot"); } } \ No newline at end of file diff --git a/src/pocketmine/item/GlassBottle.php b/src/pocketmine/item/GlassBottle.php index cfddc4d9f..682eecacf 100644 --- a/src/pocketmine/item/GlassBottle.php +++ b/src/pocketmine/item/GlassBottle.php @@ -24,7 +24,7 @@ declare(strict_types=1); namespace pocketmine\item; class GlassBottle extends Item{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::GLASS_BOTTLE, $meta, $count, "Glass Bottle"); + public function __construct(int $meta = 0){ + parent::__construct(self::GLASS_BOTTLE, $meta, "Glass Bottle"); } } diff --git a/src/pocketmine/item/GoldAxe.php b/src/pocketmine/item/GoldAxe.php index d97436520..208254e1c 100644 --- a/src/pocketmine/item/GoldAxe.php +++ b/src/pocketmine/item/GoldAxe.php @@ -25,8 +25,8 @@ namespace pocketmine\item; class GoldAxe extends Tool{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::GOLD_AXE, $meta, $count, "Gold Axe"); + public function __construct(int $meta = 0){ + parent::__construct(self::GOLD_AXE, $meta, "Gold Axe"); } public function isAxe(){ diff --git a/src/pocketmine/item/GoldBoots.php b/src/pocketmine/item/GoldBoots.php index 39af40fea..eab079f2d 100644 --- a/src/pocketmine/item/GoldBoots.php +++ b/src/pocketmine/item/GoldBoots.php @@ -25,7 +25,7 @@ namespace pocketmine\item; class GoldBoots extends Armor{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::GOLD_BOOTS, $meta, $count, "Gold Boots"); + public function __construct(int $meta = 0){ + parent::__construct(self::GOLD_BOOTS, $meta, "Gold Boots"); } } \ No newline at end of file diff --git a/src/pocketmine/item/GoldChestplate.php b/src/pocketmine/item/GoldChestplate.php index 2704c9544..e0dd71839 100644 --- a/src/pocketmine/item/GoldChestplate.php +++ b/src/pocketmine/item/GoldChestplate.php @@ -25,7 +25,7 @@ namespace pocketmine\item; class GoldChestplate extends Armor{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::GOLD_CHESTPLATE, $meta, $count, "Gold Chestplate"); + public function __construct(int $meta = 0){ + parent::__construct(self::GOLD_CHESTPLATE, $meta, "Gold Chestplate"); } } \ No newline at end of file diff --git a/src/pocketmine/item/GoldHelmet.php b/src/pocketmine/item/GoldHelmet.php index 1cbb38562..e8e6e3905 100644 --- a/src/pocketmine/item/GoldHelmet.php +++ b/src/pocketmine/item/GoldHelmet.php @@ -25,7 +25,7 @@ namespace pocketmine\item; class GoldHelmet extends Armor{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::GOLD_HELMET, $meta, $count, "Gold Helmet"); + public function __construct(int $meta = 0){ + parent::__construct(self::GOLD_HELMET, $meta, "Gold Helmet"); } } \ No newline at end of file diff --git a/src/pocketmine/item/GoldHoe.php b/src/pocketmine/item/GoldHoe.php index 57e16daf1..f0b66bd63 100644 --- a/src/pocketmine/item/GoldHoe.php +++ b/src/pocketmine/item/GoldHoe.php @@ -25,8 +25,8 @@ namespace pocketmine\item; class GoldHoe extends Tool{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::GOLD_HOE, $meta, $count, "Gold Hoe"); + public function __construct(int $meta = 0){ + parent::__construct(self::GOLD_HOE, $meta, "Gold Hoe"); } public function isHoe(){ diff --git a/src/pocketmine/item/GoldLeggings.php b/src/pocketmine/item/GoldLeggings.php index fbc4e4db6..cd61231fd 100644 --- a/src/pocketmine/item/GoldLeggings.php +++ b/src/pocketmine/item/GoldLeggings.php @@ -25,7 +25,7 @@ namespace pocketmine\item; class GoldLeggings extends Armor{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::GOLD_LEGGINGS, $meta, $count, "Gold Leggings"); + public function __construct(int $meta = 0){ + parent::__construct(self::GOLD_LEGGINGS, $meta, "Gold Leggings"); } } \ No newline at end of file diff --git a/src/pocketmine/item/GoldPickaxe.php b/src/pocketmine/item/GoldPickaxe.php index 0c9953ca7..042ac2bb5 100644 --- a/src/pocketmine/item/GoldPickaxe.php +++ b/src/pocketmine/item/GoldPickaxe.php @@ -25,8 +25,8 @@ namespace pocketmine\item; class GoldPickaxe extends Tool{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::GOLD_PICKAXE, $meta, $count, "Gold Pickaxe"); + public function __construct(int $meta = 0){ + parent::__construct(self::GOLD_PICKAXE, $meta, "Gold Pickaxe"); } public function isPickaxe(){ diff --git a/src/pocketmine/item/GoldShovel.php b/src/pocketmine/item/GoldShovel.php index 0428c33c3..041b0cc90 100644 --- a/src/pocketmine/item/GoldShovel.php +++ b/src/pocketmine/item/GoldShovel.php @@ -25,8 +25,8 @@ namespace pocketmine\item; class GoldShovel extends Tool{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::GOLD_SHOVEL, $meta, $count, "Gold Shovel"); + public function __construct(int $meta = 0){ + parent::__construct(self::GOLD_SHOVEL, $meta, "Gold Shovel"); } public function isShovel(){ diff --git a/src/pocketmine/item/GoldSword.php b/src/pocketmine/item/GoldSword.php index 089edc0b7..289f05888 100644 --- a/src/pocketmine/item/GoldSword.php +++ b/src/pocketmine/item/GoldSword.php @@ -25,8 +25,8 @@ namespace pocketmine\item; class GoldSword extends Tool{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::GOLD_SWORD, $meta, $count, "Gold Sword"); + public function __construct(int $meta = 0){ + parent::__construct(self::GOLD_SWORD, $meta, "Gold Sword"); } public function isSword(){ diff --git a/src/pocketmine/item/GoldenApple.php b/src/pocketmine/item/GoldenApple.php index 4fe9abc23..4c080d39b 100644 --- a/src/pocketmine/item/GoldenApple.php +++ b/src/pocketmine/item/GoldenApple.php @@ -29,8 +29,8 @@ use pocketmine\entity\Human; class GoldenApple extends Food{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::GOLDEN_APPLE, $meta, $count, "Golden Apple"); + public function __construct(int $meta = 0){ + parent::__construct(self::GOLDEN_APPLE, $meta, "Golden Apple"); } public function canBeConsumedBy(Entity $entity) : bool{ diff --git a/src/pocketmine/item/GoldenAppleEnchanted.php b/src/pocketmine/item/GoldenAppleEnchanted.php index b1569d395..4b3c7cb44 100644 --- a/src/pocketmine/item/GoldenAppleEnchanted.php +++ b/src/pocketmine/item/GoldenAppleEnchanted.php @@ -27,8 +27,8 @@ use pocketmine\entity\Effect; class GoldenAppleEnchanted extends GoldenApple{ - public function __construct($meta = 0, $count = 1){ - Food::__construct(self::ENCHANTED_GOLDEN_APPLE, $meta, $count, "Enchanted Golden Apple"); //skip parent constructor + public function __construct(int $meta = 0){ + Food::__construct(self::ENCHANTED_GOLDEN_APPLE, $meta, "Enchanted Golden Apple"); //skip parent constructor } public function getAdditionalEffects() : array{ diff --git a/src/pocketmine/item/GoldenCarrot.php b/src/pocketmine/item/GoldenCarrot.php index 80fcab749..78b99ab74 100644 --- a/src/pocketmine/item/GoldenCarrot.php +++ b/src/pocketmine/item/GoldenCarrot.php @@ -24,8 +24,8 @@ declare(strict_types=1); namespace pocketmine\item; class GoldenCarrot extends Food{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::GOLDEN_CARROT, $meta, $count, "Golden Carrot"); + public function __construct(int $meta = 0){ + parent::__construct(self::GOLDEN_CARROT, $meta, "Golden Carrot"); } public function getFoodRestore() : int{ diff --git a/src/pocketmine/item/IronAxe.php b/src/pocketmine/item/IronAxe.php index 0179e2ab7..9fc681ccd 100644 --- a/src/pocketmine/item/IronAxe.php +++ b/src/pocketmine/item/IronAxe.php @@ -25,8 +25,8 @@ namespace pocketmine\item; class IronAxe extends Tool{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::IRON_AXE, $meta, $count, "Iron Axe"); + public function __construct(int $meta = 0){ + parent::__construct(self::IRON_AXE, $meta, "Iron Axe"); } public function isAxe(){ diff --git a/src/pocketmine/item/IronBoots.php b/src/pocketmine/item/IronBoots.php index fa5ea3dff..8fbc7af84 100644 --- a/src/pocketmine/item/IronBoots.php +++ b/src/pocketmine/item/IronBoots.php @@ -25,7 +25,7 @@ namespace pocketmine\item; class IronBoots extends Armor{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::IRON_BOOTS, $meta, $count, "Iron Boots"); + public function __construct(int $meta = 0){ + parent::__construct(self::IRON_BOOTS, $meta, "Iron Boots"); } } \ No newline at end of file diff --git a/src/pocketmine/item/IronChestplate.php b/src/pocketmine/item/IronChestplate.php index ed82c87eb..7b69204b9 100644 --- a/src/pocketmine/item/IronChestplate.php +++ b/src/pocketmine/item/IronChestplate.php @@ -25,7 +25,7 @@ namespace pocketmine\item; class IronChestplate extends Armor{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::IRON_CHESTPLATE, $meta, $count, "Iron Chestplate"); + public function __construct(int $meta = 0){ + parent::__construct(self::IRON_CHESTPLATE, $meta, "Iron Chestplate"); } } \ No newline at end of file diff --git a/src/pocketmine/item/IronDoor.php b/src/pocketmine/item/IronDoor.php index 40dae003a..8fbce996b 100644 --- a/src/pocketmine/item/IronDoor.php +++ b/src/pocketmine/item/IronDoor.php @@ -27,9 +27,9 @@ use pocketmine\block\Block; use pocketmine\block\BlockFactory; class IronDoor extends Item{ - public function __construct($meta = 0, $count = 1){ + public function __construct(int $meta = 0){ $this->block = BlockFactory::get(Block::IRON_DOOR_BLOCK); - parent::__construct(self::IRON_DOOR, $meta, $count, "Iron Door"); + parent::__construct(self::IRON_DOOR, $meta, "Iron Door"); } public function getMaxStackSize(){ diff --git a/src/pocketmine/item/IronHelmet.php b/src/pocketmine/item/IronHelmet.php index e2d3cb594..2a7a7b8f6 100644 --- a/src/pocketmine/item/IronHelmet.php +++ b/src/pocketmine/item/IronHelmet.php @@ -25,7 +25,7 @@ namespace pocketmine\item; class IronHelmet extends Armor{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::IRON_HELMET, $meta, $count, "Iron Helmet"); + public function __construct(int $meta = 0){ + parent::__construct(self::IRON_HELMET, $meta, "Iron Helmet"); } } \ No newline at end of file diff --git a/src/pocketmine/item/IronHoe.php b/src/pocketmine/item/IronHoe.php index 8872a34ea..02205d607 100644 --- a/src/pocketmine/item/IronHoe.php +++ b/src/pocketmine/item/IronHoe.php @@ -25,8 +25,8 @@ namespace pocketmine\item; class IronHoe extends Tool{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::IRON_HOE, $meta, $count, "Iron Hoe"); + public function __construct(int $meta = 0){ + parent::__construct(self::IRON_HOE, $meta, "Iron Hoe"); } public function isHoe(){ diff --git a/src/pocketmine/item/IronLeggings.php b/src/pocketmine/item/IronLeggings.php index 5cbd3ee57..f0a135b4b 100644 --- a/src/pocketmine/item/IronLeggings.php +++ b/src/pocketmine/item/IronLeggings.php @@ -25,7 +25,7 @@ namespace pocketmine\item; class IronLeggings extends Armor{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::IRON_LEGGINGS, $meta, $count, "Iron Leggings"); + public function __construct(int $meta = 0){ + parent::__construct(self::IRON_LEGGINGS, $meta, "Iron Leggings"); } } \ No newline at end of file diff --git a/src/pocketmine/item/IronPickaxe.php b/src/pocketmine/item/IronPickaxe.php index a5add10b3..28a43bc90 100644 --- a/src/pocketmine/item/IronPickaxe.php +++ b/src/pocketmine/item/IronPickaxe.php @@ -25,8 +25,8 @@ namespace pocketmine\item; class IronPickaxe extends Tool{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::IRON_PICKAXE, $meta, $count, "Iron Pickaxe"); + public function __construct(int $meta = 0){ + parent::__construct(self::IRON_PICKAXE, $meta, "Iron Pickaxe"); } public function isPickaxe(){ diff --git a/src/pocketmine/item/IronShovel.php b/src/pocketmine/item/IronShovel.php index 2177c8e76..129e970ad 100644 --- a/src/pocketmine/item/IronShovel.php +++ b/src/pocketmine/item/IronShovel.php @@ -25,8 +25,8 @@ namespace pocketmine\item; class IronShovel extends Tool{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::IRON_SHOVEL, $meta, $count, "Iron Shovel"); + public function __construct(int $meta = 0){ + parent::__construct(self::IRON_SHOVEL, $meta, "Iron Shovel"); } public function isShovel(){ diff --git a/src/pocketmine/item/IronSword.php b/src/pocketmine/item/IronSword.php index b1b5db811..84d4cb1d9 100644 --- a/src/pocketmine/item/IronSword.php +++ b/src/pocketmine/item/IronSword.php @@ -25,8 +25,8 @@ namespace pocketmine\item; class IronSword extends Tool{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::IRON_SWORD, $meta, $count, "Iron Sword"); + public function __construct(int $meta = 0){ + parent::__construct(self::IRON_SWORD, $meta, "Iron Sword"); } public function isSword(){ diff --git a/src/pocketmine/item/Item.php b/src/pocketmine/item/Item.php index 8adc74152..4e2e91343 100644 --- a/src/pocketmine/item/Item.php +++ b/src/pocketmine/item/Item.php @@ -183,20 +183,24 @@ class Item implements ItemIds, \JsonSerializable{ /** @var CompoundTag|null */ private $cachedNBT = null; /** @var int */ - public $count; + public $count = 1; /** @var string */ protected $name; /** - * @param int $id - * @param int $meta - * @param int $count + * Constructs a new Item type. This constructor should ONLY be used when constructing a new item TYPE to register + * into the index. + * + * NOTE: This should NOT BE USED for creating items to set into an inventory. Use {@link ItemFactory#get} for that + * purpose. + * + * @param int $id + * @param int $meta * @param string $name */ - public function __construct(int $id, int $meta = 0, int $count = 1, string $name = "Unknown"){ + public function __construct(int $id, int $meta = 0, string $name = "Unknown"){ $this->id = $id & 0xffff; $this->meta = $meta !== -1 ? $meta & 0xffff : -1; - $this->count = $count; $this->name = $name; if(!isset($this->block) and $this->id <= 0xff and isset(BlockFactory::$list[$this->id])){ $this->block = BlockFactory::get($this->id, $this->meta); @@ -631,9 +635,12 @@ class Item implements ItemIds, \JsonSerializable{ /** * @param int $count + * @return $this */ public function setCount(int $count){ $this->count = $count; + + return $this; } /** @@ -705,9 +712,12 @@ class Item implements ItemIds, \JsonSerializable{ /** * @param int $meta + * @return $this */ public function setDamage(int $meta){ $this->meta = $meta !== -1 ? $meta & 0xFFFF : -1; + + return $this; } /** diff --git a/src/pocketmine/item/ItemBlock.php b/src/pocketmine/item/ItemBlock.php index c7ea32080..5bb173a77 100644 --- a/src/pocketmine/item/ItemBlock.php +++ b/src/pocketmine/item/ItemBlock.php @@ -29,13 +29,18 @@ use pocketmine\block\Block; * Class used for Items that can be Blocks */ class ItemBlock extends Item{ - public function __construct(Block $block, $meta = 0, int $count = 1){ + + /** + * @param Block $block + * @param int $meta Used in crafting recipes for any-damage ingredients (blocks must have meta values 0-15) + */ + public function __construct(Block $block, int $meta = 0){ $this->block = $block; - parent::__construct($block->getId(), $block->getDamage(), $count, $block->getName()); + parent::__construct($block->getId(), $meta, $block->getName()); } public function setDamage(int $meta){ - $this->meta = $meta !== -1 ? $meta & 0xf : -1; + $this->meta = $meta; $this->block->setDamage($this->meta !== -1 ? $this->meta : 0); } diff --git a/src/pocketmine/item/ItemFactory.php b/src/pocketmine/item/ItemFactory.php index 89d06c41c..c6ca3a8bd 100644 --- a/src/pocketmine/item/ItemFactory.php +++ b/src/pocketmine/item/ItemFactory.php @@ -46,9 +46,9 @@ class ItemFactory{ self::registerItem(new Bow()); self::registerItem(new Arrow()); self::registerItem(new Coal()); - self::registerItem(new Item(Item::DIAMOND, 0, 1, "Diamond")); - self::registerItem(new Item(Item::IRON_INGOT, 0, 1, "Iron Ingot")); - self::registerItem(new Item(Item::GOLD_INGOT, 0, 1, "Gold Ingot")); + self::registerItem(new Item(Item::DIAMOND, 0, "Diamond")); + self::registerItem(new Item(Item::IRON_INGOT, 0, "Iron Ingot")); + self::registerItem(new Item(Item::GOLD_INGOT, 0, "Gold Ingot")); self::registerItem(new IronSword()); self::registerItem(new WoodenSword()); self::registerItem(new WoodenShovel()); @@ -70,15 +70,15 @@ class ItemFactory{ self::registerItem(new GoldPickaxe()); self::registerItem(new GoldAxe()); self::registerItem(new StringItem()); - self::registerItem(new Item(Item::FEATHER, 0, 1, "Feather")); - self::registerItem(new Item(Item::GUNPOWDER, 0, 1, "Gunpowder")); + self::registerItem(new Item(Item::FEATHER, 0, "Feather")); + self::registerItem(new Item(Item::GUNPOWDER, 0, "Gunpowder")); self::registerItem(new WoodenHoe()); self::registerItem(new StoneHoe()); self::registerItem(new IronHoe()); self::registerItem(new DiamondHoe()); self::registerItem(new GoldHoe()); self::registerItem(new WheatSeeds()); - self::registerItem(new Item(Item::WHEAT, 0, 1, "Wheat")); + self::registerItem(new Item(Item::WHEAT, 0, "Wheat")); self::registerItem(new Bread()); self::registerItem(new LeatherCap()); self::registerItem(new LeatherTunic()); @@ -100,7 +100,7 @@ class ItemFactory{ self::registerItem(new GoldChestplate()); self::registerItem(new GoldLeggings()); self::registerItem(new GoldBoots()); - self::registerItem(new Item(Item::FLINT, 0, 1, "Flint")); + self::registerItem(new Item(Item::FLINT, 0, "Flint")); self::registerItem(new RawPorkchop()); self::registerItem(new CookedPorkchop()); self::registerItem(new Painting()); @@ -115,26 +115,26 @@ class ItemFactory{ self::registerItem(new Redstone()); self::registerItem(new Snowball()); self::registerItem(new Boat()); - self::registerItem(new Item(Item::LEATHER, 0, 1, "Leather")); + self::registerItem(new Item(Item::LEATHER, 0, "Leather")); - self::registerItem(new Item(Item::BRICK, 0, 1, "Brick")); - self::registerItem(new Item(Item::CLAY_BALL, 0, 1, "Clay")); + self::registerItem(new Item(Item::BRICK, 0, "Brick")); + self::registerItem(new Item(Item::CLAY_BALL, 0, "Clay")); self::registerItem(new Sugarcane()); - self::registerItem(new Item(Item::PAPER, 0, 1, "Paper")); + self::registerItem(new Item(Item::PAPER, 0, "Paper")); self::registerItem(new Book()); - self::registerItem(new Item(Item::SLIME_BALL, 0, 1, "Slimeball")); + self::registerItem(new Item(Item::SLIME_BALL, 0, "Slimeball")); //TODO: CHEST_MINECART self::registerItem(new Egg()); self::registerItem(new Compass()); self::registerItem(new FishingRod()); self::registerItem(new Clock()); - self::registerItem(new Item(Item::GLOWSTONE_DUST, 0, 1, "Glowstone Dust")); + self::registerItem(new Item(Item::GLOWSTONE_DUST, 0, "Glowstone Dust")); self::registerItem(new Fish()); self::registerItem(new CookedFish()); self::registerItem(new Dye()); - self::registerItem(new Item(Item::BONE, 0, 1, "Bone")); - self::registerItem(new Item(Item::SUGAR, 0, 1, "Sugar")); + self::registerItem(new Item(Item::BONE, 0, "Bone")); + self::registerItem(new Item(Item::SUGAR, 0, "Sugar")); self::registerItem(new Cake()); self::registerItem(new Bed()); //TODO: REPEATER @@ -152,23 +152,23 @@ class ItemFactory{ //TODO: ENDER_PEARL //TODO: BLAZE_ROD //TODO: GHAST_TEAR - self::registerItem(new Item(Item::GOLD_NUGGET, 0, 1, "Gold Nugget")); + self::registerItem(new Item(Item::GOLD_NUGGET, 0, "Gold Nugget")); self::registerItem(new NetherWart()); self::registerItem(new Potion()); self::registerItem(new GlassBottle()); self::registerItem(new SpiderEye()); - self::registerItem(new Item(Item::FERMENTED_SPIDER_EYE, 0, 1, "Fermented Spider Eye")); - self::registerItem(new Item(Item::BLAZE_POWDER, 0, 1, "Blaze Powder")); - self::registerItem(new Item(Item::MAGMA_CREAM, 0, 1, "Magma Cream")); + self::registerItem(new Item(Item::FERMENTED_SPIDER_EYE, 0, "Fermented Spider Eye")); + self::registerItem(new Item(Item::BLAZE_POWDER, 0, "Blaze Powder")); + self::registerItem(new Item(Item::MAGMA_CREAM, 0, "Magma Cream")); self::registerItem(new BrewingStand()); //TODO: CAULDRON //TODO: ENDER_EYE - self::registerItem(new Item(Item::GLISTERING_MELON, 0, 1, "Glistering Melon")); + self::registerItem(new Item(Item::GLISTERING_MELON, 0, "Glistering Melon")); self::registerItem(new SpawnEgg()); //TODO: BOTTLE_O_ENCHANTING //TODO: FIREBALL - self::registerItem(new Item(Item::EMERALD, 0, 1, "Emerald")); + self::registerItem(new Item(Item::EMERALD, 0, "Emerald")); self::registerItem(new ItemFrame()); self::registerItem(new FlowerPot()); self::registerItem(new Carrot()); @@ -179,16 +179,16 @@ class ItemFactory{ self::registerItem(new GoldenCarrot()); self::registerItem(new Skull()); //TODO: CARROTONASTICK - self::registerItem(new Item(Item::NETHER_STAR, 0, 1, "Nether Star")); + self::registerItem(new Item(Item::NETHER_STAR, 0, "Nether Star")); self::registerItem(new PumpkinPie()); //TODO: ENCHANTED_BOOK //TODO: COMPARATOR - self::registerItem(new Item(Item::NETHER_BRICK, 0, 1, "Nether Brick")); - self::registerItem(new Item(Item::NETHER_QUARTZ, 0, 1, "Nether Quartz")); + self::registerItem(new Item(Item::NETHER_BRICK, 0, "Nether Brick")); + self::registerItem(new Item(Item::NETHER_QUARTZ, 0, "Nether Quartz")); //TODO: MINECART_WITH_TNT //TODO: HOPPER_MINECART - self::registerItem(new Item(Item::PRISMARINE_SHARD, 0, 1, "Prismarine Shard")); + self::registerItem(new Item(Item::PRISMARINE_SHARD, 0, "Prismarine Shard")); //TODO: HOPPER //TODO: RABBIT self::registerItem(new CookedRabbit()); @@ -201,7 +201,7 @@ class ItemFactory{ //TODO: DIAMOND_HORSE_ARMOR //TODO: LEAD //TODO: NAMETAG - self::registerItem(new Item(Item::PRISMARINE_CRYSTALS, 0, 1, "Prismarine Crystals")); + self::registerItem(new Item(Item::PRISMARINE_CRYSTALS, 0, "Prismarine Crystals")); //TODO: MUTTONRAW //TODO: COOKED_MUTTON @@ -272,28 +272,36 @@ class ItemFactory{ * @param CompoundTag|string $tags * * @return Item + * @throws \TypeError */ public static function get(int $id, int $meta = 0, int $count = 1, $tags = "") : Item{ + if(!is_string($tags) and !($tags instanceof CompoundTag)){ + throw new \TypeError("`tags` argument must be a string or CompoundTag instance, " . (is_object($tags) ? "instance of " . get_class($tags) : gettype($tags)) . " given"); + } + + $item = null; try{ if($id < 256){ - return (new ItemBlock(BlockFactory::get($id, $meta), $meta, $count))->setCompoundTag($tags); + /* 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(BlockFactory::get($id, $meta !== -1 ? $meta : 0), $meta); }else{ - /** @var Item|null $item */ - $item = self::$list[$id]; - if($item === null){ - return (new Item($id, $meta, $count))->setCompoundTag($tags); - }else{ - $item = clone $item; - $item->setDamage($meta); - $item->setCount($count); - $item->setCompoundTag($tags); - - return $item; + /** @var Item|null $listed */ + $listed = self::$list[$id]; + if($listed !== null){ + $item = clone $listed; } } }catch(\RuntimeException $e){ - return (new Item($id, $meta, $count))->setCompoundTag($tags); + throw new \InvalidArgumentException("Item ID $id is invalid or out of bounds"); } + + $item = ($item ?? new Item($id, $meta)); + + $item->setDamage($meta); + $item->setCount($count); + $item->setCompoundTag($tags); + return $item; } /** diff --git a/src/pocketmine/item/ItemFrame.php b/src/pocketmine/item/ItemFrame.php index 59491f78d..9ee88ace0 100644 --- a/src/pocketmine/item/ItemFrame.php +++ b/src/pocketmine/item/ItemFrame.php @@ -27,8 +27,8 @@ use pocketmine\block\Block; use pocketmine\block\BlockFactory; class ItemFrame extends Item{ - public function __construct($meta = 0, $count = 1){ + public function __construct(int $meta = 0){ $this->block = BlockFactory::get(Block::ITEM_FRAME_BLOCK); - parent::__construct(self::ITEM_FRAME, $meta, $count, "Item Frame"); + parent::__construct(self::ITEM_FRAME, $meta, "Item Frame"); } } \ No newline at end of file diff --git a/src/pocketmine/item/LeatherBoots.php b/src/pocketmine/item/LeatherBoots.php index 0f1f10274..1008d491a 100644 --- a/src/pocketmine/item/LeatherBoots.php +++ b/src/pocketmine/item/LeatherBoots.php @@ -25,7 +25,7 @@ namespace pocketmine\item; class LeatherBoots extends Armor{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::LEATHER_BOOTS, $meta, $count, "Leather Boots"); + public function __construct(int $meta = 0){ + parent::__construct(self::LEATHER_BOOTS, $meta, "Leather Boots"); } } \ No newline at end of file diff --git a/src/pocketmine/item/LeatherCap.php b/src/pocketmine/item/LeatherCap.php index 32753ba6b..30ce1dde1 100644 --- a/src/pocketmine/item/LeatherCap.php +++ b/src/pocketmine/item/LeatherCap.php @@ -25,7 +25,7 @@ namespace pocketmine\item; class LeatherCap extends Armor{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::LEATHER_CAP, $meta, $count, "Leather Cap"); + public function __construct(int $meta = 0){ + parent::__construct(self::LEATHER_CAP, $meta, "Leather Cap"); } } \ No newline at end of file diff --git a/src/pocketmine/item/LeatherPants.php b/src/pocketmine/item/LeatherPants.php index ec38c9e26..6d181811c 100644 --- a/src/pocketmine/item/LeatherPants.php +++ b/src/pocketmine/item/LeatherPants.php @@ -25,7 +25,7 @@ namespace pocketmine\item; class LeatherPants extends Armor{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::LEATHER_PANTS, $meta, $count, "Leather Pants"); + public function __construct(int $meta = 0){ + parent::__construct(self::LEATHER_PANTS, $meta, "Leather Pants"); } } \ No newline at end of file diff --git a/src/pocketmine/item/LeatherTunic.php b/src/pocketmine/item/LeatherTunic.php index 72c3f461d..d5fe6f56a 100644 --- a/src/pocketmine/item/LeatherTunic.php +++ b/src/pocketmine/item/LeatherTunic.php @@ -25,7 +25,7 @@ namespace pocketmine\item; class LeatherTunic extends Armor{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::LEATHER_TUNIC, $meta, $count, "Leather Tunic"); + public function __construct(int $meta = 0){ + parent::__construct(self::LEATHER_TUNIC, $meta, "Leather Tunic"); } } \ No newline at end of file diff --git a/src/pocketmine/item/Melon.php b/src/pocketmine/item/Melon.php index faadabc29..855b2abb6 100644 --- a/src/pocketmine/item/Melon.php +++ b/src/pocketmine/item/Melon.php @@ -24,8 +24,8 @@ declare(strict_types=1); namespace pocketmine\item; class Melon extends Food{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::MELON, $meta, $count, "Melon"); + public function __construct(int $meta = 0){ + parent::__construct(self::MELON, $meta, "Melon"); } public function getFoodRestore() : int{ diff --git a/src/pocketmine/item/MelonSeeds.php b/src/pocketmine/item/MelonSeeds.php index d3c4f611e..986d66ba8 100644 --- a/src/pocketmine/item/MelonSeeds.php +++ b/src/pocketmine/item/MelonSeeds.php @@ -27,8 +27,8 @@ use pocketmine\block\Block; use pocketmine\block\BlockFactory; class MelonSeeds extends Item{ - public function __construct($meta = 0, $count = 1){ + public function __construct(int $meta = 0){ $this->block = BlockFactory::get(Block::MELON_STEM); - parent::__construct(self::MELON_SEEDS, $meta, $count, "Melon Seeds"); + parent::__construct(self::MELON_SEEDS, $meta, "Melon Seeds"); } } \ No newline at end of file diff --git a/src/pocketmine/item/Minecart.php b/src/pocketmine/item/Minecart.php index 90a5875fe..9454c57ee 100644 --- a/src/pocketmine/item/Minecart.php +++ b/src/pocketmine/item/Minecart.php @@ -24,8 +24,8 @@ declare(strict_types=1); namespace pocketmine\item; class Minecart extends Item{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::MINECART, $meta, $count, "Minecart"); + public function __construct(int $meta = 0){ + parent::__construct(self::MINECART, $meta, "Minecart"); } //TODO diff --git a/src/pocketmine/item/MushroomStew.php b/src/pocketmine/item/MushroomStew.php index 51929c5ec..8a2db5d08 100644 --- a/src/pocketmine/item/MushroomStew.php +++ b/src/pocketmine/item/MushroomStew.php @@ -24,8 +24,8 @@ declare(strict_types=1); namespace pocketmine\item; class MushroomStew extends Food{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::MUSHROOM_STEW, $meta, $count, "Mushroom Stew"); + public function __construct(int $meta = 0){ + parent::__construct(self::MUSHROOM_STEW, $meta, "Mushroom Stew"); } public function getMaxStackSize(){ diff --git a/src/pocketmine/item/NetherWart.php b/src/pocketmine/item/NetherWart.php index 9aa7fe4a0..b02cda3ba 100644 --- a/src/pocketmine/item/NetherWart.php +++ b/src/pocketmine/item/NetherWart.php @@ -27,8 +27,8 @@ use pocketmine\block\Block; use pocketmine\block\BlockFactory; class NetherWart extends Item{ - public function __construct($meta = 0, $count = 1){ + public function __construct(int $meta = 0){ $this->block = BlockFactory::get(Block::NETHER_WART_PLANT); - parent::__construct(self::NETHER_WART, $meta, $count, "Nether Wart"); + parent::__construct(self::NETHER_WART, $meta, "Nether Wart"); } } diff --git a/src/pocketmine/item/Painting.php b/src/pocketmine/item/Painting.php index badfaf701..c521675d6 100644 --- a/src/pocketmine/item/Painting.php +++ b/src/pocketmine/item/Painting.php @@ -29,8 +29,8 @@ use pocketmine\math\Vector3; use pocketmine\Player; class Painting extends Item{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::PAINTING, $meta, $count, "Painting"); + public function __construct(int $meta = 0){ + parent::__construct(self::PAINTING, $meta, "Painting"); } public function onActivate(Level $level, Player $player, Block $block, Block $target, int $face, Vector3 $facePos) : bool{ diff --git a/src/pocketmine/item/Potato.php b/src/pocketmine/item/Potato.php index e4d8f1855..879e5dff2 100644 --- a/src/pocketmine/item/Potato.php +++ b/src/pocketmine/item/Potato.php @@ -27,9 +27,9 @@ use pocketmine\block\Block; use pocketmine\block\BlockFactory; class Potato extends Food{ - public function __construct($meta = 0, $count = 1){ + public function __construct(int $meta = 0){ $this->block = BlockFactory::get(Block::POTATO_BLOCK); - parent::__construct(self::POTATO, $meta, $count, "Potato"); + parent::__construct(self::POTATO, $meta, "Potato"); } public function getFoodRestore() : int{ diff --git a/src/pocketmine/item/Potion.php b/src/pocketmine/item/Potion.php index a8d6f62e3..af52c249a 100644 --- a/src/pocketmine/item/Potion.php +++ b/src/pocketmine/item/Potion.php @@ -26,8 +26,8 @@ namespace pocketmine\item; use pocketmine\entity\Entity; class Potion extends Item{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::POTION, $meta, $count, "Potion"); + public function __construct(int $meta = 0){ + parent::__construct(self::POTION, $meta, "Potion"); } public function canBeConsumed() : bool{ diff --git a/src/pocketmine/item/PumpkinPie.php b/src/pocketmine/item/PumpkinPie.php index 9f96e8fc3..325fd3d52 100644 --- a/src/pocketmine/item/PumpkinPie.php +++ b/src/pocketmine/item/PumpkinPie.php @@ -24,8 +24,8 @@ declare(strict_types=1); namespace pocketmine\item; class PumpkinPie extends Food{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::PUMPKIN_PIE, $meta, $count, "Pumpkin Pie"); + public function __construct(int $meta = 0){ + parent::__construct(self::PUMPKIN_PIE, $meta, "Pumpkin Pie"); } public function getFoodRestore() : int{ diff --git a/src/pocketmine/item/PumpkinSeeds.php b/src/pocketmine/item/PumpkinSeeds.php index 43535d638..260043ebc 100644 --- a/src/pocketmine/item/PumpkinSeeds.php +++ b/src/pocketmine/item/PumpkinSeeds.php @@ -27,8 +27,8 @@ use pocketmine\block\Block; use pocketmine\block\BlockFactory; class PumpkinSeeds extends Item{ - public function __construct($meta = 0, $count = 1){ + public function __construct(int $meta = 0){ $this->block = BlockFactory::get(Block::PUMPKIN_STEM); - parent::__construct(self::PUMPKIN_SEEDS, $meta, $count, "Pumpkin Seeds"); + parent::__construct(self::PUMPKIN_SEEDS, $meta, "Pumpkin Seeds"); } } \ No newline at end of file diff --git a/src/pocketmine/item/RawBeef.php b/src/pocketmine/item/RawBeef.php index bce963e60..88a46265b 100644 --- a/src/pocketmine/item/RawBeef.php +++ b/src/pocketmine/item/RawBeef.php @@ -24,8 +24,8 @@ declare(strict_types=1); namespace pocketmine\item; class RawBeef extends Food{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::RAW_BEEF, $meta, $count, "Raw Beef"); + public function __construct(int $meta = 0){ + parent::__construct(self::RAW_BEEF, $meta, "Raw Beef"); } public function getFoodRestore() : int{ diff --git a/src/pocketmine/item/RawChicken.php b/src/pocketmine/item/RawChicken.php index a6f211d3b..fadcbde29 100644 --- a/src/pocketmine/item/RawChicken.php +++ b/src/pocketmine/item/RawChicken.php @@ -26,8 +26,8 @@ namespace pocketmine\item; use pocketmine\entity\Effect; class RawChicken extends Food{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::RAW_CHICKEN, $meta, $count, "Raw Chicken"); + public function __construct(int $meta = 0){ + parent::__construct(self::RAW_CHICKEN, $meta, "Raw Chicken"); } public function getFoodRestore() : int{ diff --git a/src/pocketmine/item/RawPorkchop.php b/src/pocketmine/item/RawPorkchop.php index 4c9f58e86..d5e56725d 100644 --- a/src/pocketmine/item/RawPorkchop.php +++ b/src/pocketmine/item/RawPorkchop.php @@ -24,8 +24,8 @@ declare(strict_types=1); namespace pocketmine\item; class RawPorkchop extends Item{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::RAW_PORKCHOP, $meta, $count, "Raw Porkchop"); + public function __construct(int $meta = 0){ + parent::__construct(self::RAW_PORKCHOP, $meta, "Raw Porkchop"); } } diff --git a/src/pocketmine/item/Redstone.php b/src/pocketmine/item/Redstone.php index ece0ca3b1..9f1784f2e 100644 --- a/src/pocketmine/item/Redstone.php +++ b/src/pocketmine/item/Redstone.php @@ -27,9 +27,9 @@ use pocketmine\block\Block; use pocketmine\block\BlockFactory; class Redstone extends Item{ - public function __construct($meta = 0, $count = 1){ + public function __construct(int $meta = 0){ $this->block = BlockFactory::get(Block::REDSTONE_WIRE); - parent::__construct(self::REDSTONE, $meta, $count, "Redstone"); + parent::__construct(self::REDSTONE, $meta, "Redstone"); } } diff --git a/src/pocketmine/item/Shears.php b/src/pocketmine/item/Shears.php index aa053644a..36d377185 100644 --- a/src/pocketmine/item/Shears.php +++ b/src/pocketmine/item/Shears.php @@ -25,8 +25,8 @@ namespace pocketmine\item; class Shears extends Tool{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::SHEARS, $meta, $count, "Shears"); + public function __construct(int $meta = 0){ + parent::__construct(self::SHEARS, $meta, "Shears"); } public function getMaxDurability(){ diff --git a/src/pocketmine/item/Sign.php b/src/pocketmine/item/Sign.php index 42e97f844..834be4e9a 100644 --- a/src/pocketmine/item/Sign.php +++ b/src/pocketmine/item/Sign.php @@ -27,9 +27,9 @@ use pocketmine\block\Block; use pocketmine\block\BlockFactory; class Sign extends Item{ - public function __construct($meta = 0, $count = 1){ + public function __construct(int $meta = 0){ $this->block = BlockFactory::get(Block::SIGN_POST); - parent::__construct(self::SIGN, $meta, $count, "Sign"); + parent::__construct(self::SIGN, $meta, "Sign"); } public function getMaxStackSize(){ diff --git a/src/pocketmine/item/Skull.php b/src/pocketmine/item/Skull.php index b5608f181..403418797 100644 --- a/src/pocketmine/item/Skull.php +++ b/src/pocketmine/item/Skull.php @@ -27,8 +27,8 @@ use pocketmine\block\Block; use pocketmine\block\BlockFactory; class Skull extends Item{ - public function __construct($meta = 0, $count = 1){ + public function __construct(int $meta = 0){ $this->block = BlockFactory::get(Block::SKULL_BLOCK); - parent::__construct(self::SKULL, $meta, $count, "Mob Head"); + parent::__construct(self::SKULL, $meta, "Mob Head"); } } \ No newline at end of file diff --git a/src/pocketmine/item/Snowball.php b/src/pocketmine/item/Snowball.php index bc3702f01..4a378d947 100644 --- a/src/pocketmine/item/Snowball.php +++ b/src/pocketmine/item/Snowball.php @@ -25,8 +25,8 @@ namespace pocketmine\item; class Snowball extends Item{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::SNOWBALL, $meta, $count, "Snowball"); + public function __construct(int $meta = 0){ + parent::__construct(self::SNOWBALL, $meta, "Snowball"); } public function getMaxStackSize(){ diff --git a/src/pocketmine/item/SpawnEgg.php b/src/pocketmine/item/SpawnEgg.php index 99c2d1692..ebeafe90b 100644 --- a/src/pocketmine/item/SpawnEgg.php +++ b/src/pocketmine/item/SpawnEgg.php @@ -35,8 +35,8 @@ use pocketmine\nbt\tag\StringTag; use pocketmine\Player; class SpawnEgg extends Item{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::SPAWN_EGG, $meta, $count, "Spawn Egg"); + public function __construct(int $meta = 0){ + parent::__construct(self::SPAWN_EGG, $meta, "Spawn Egg"); } public function onActivate(Level $level, Player $player, Block $block, Block $target, int $face, Vector3 $facePos) : bool{ diff --git a/src/pocketmine/item/SpiderEye.php b/src/pocketmine/item/SpiderEye.php index f669b5239..33655bbc9 100644 --- a/src/pocketmine/item/SpiderEye.php +++ b/src/pocketmine/item/SpiderEye.php @@ -26,8 +26,8 @@ namespace pocketmine\item; use pocketmine\entity\Effect; class SpiderEye extends Food{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::SPIDER_EYE, $meta, $count, "Spider Eye"); + public function __construct(int $meta = 0){ + parent::__construct(self::SPIDER_EYE, $meta, "Spider Eye"); } public function getFoodRestore() : int{ diff --git a/src/pocketmine/item/Steak.php b/src/pocketmine/item/Steak.php index f93d37350..f1d5b0c33 100644 --- a/src/pocketmine/item/Steak.php +++ b/src/pocketmine/item/Steak.php @@ -24,8 +24,8 @@ declare(strict_types=1); namespace pocketmine\item; class Steak extends Food{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::STEAK, $meta, $count, "Steak"); + public function __construct(int $meta = 0){ + parent::__construct(self::STEAK, $meta, "Steak"); } public function getFoodRestore() : int{ diff --git a/src/pocketmine/item/Stick.php b/src/pocketmine/item/Stick.php index fd02c6023..a3ff64e95 100644 --- a/src/pocketmine/item/Stick.php +++ b/src/pocketmine/item/Stick.php @@ -25,8 +25,8 @@ namespace pocketmine\item; class Stick extends Item{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::STICK, $meta, $count, "Stick"); + public function __construct(int $meta = 0){ + parent::__construct(self::STICK, $meta, "Stick"); } public function getFuelTime() : int{ diff --git a/src/pocketmine/item/StoneAxe.php b/src/pocketmine/item/StoneAxe.php index 592b6211f..a4f67cacc 100644 --- a/src/pocketmine/item/StoneAxe.php +++ b/src/pocketmine/item/StoneAxe.php @@ -25,8 +25,8 @@ namespace pocketmine\item; class StoneAxe extends Tool{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::STONE_AXE, $meta, $count, "Stone Axe"); + public function __construct(int $meta = 0){ + parent::__construct(self::STONE_AXE, $meta, "Stone Axe"); } diff --git a/src/pocketmine/item/StoneHoe.php b/src/pocketmine/item/StoneHoe.php index 6849e40f5..1185f64b9 100644 --- a/src/pocketmine/item/StoneHoe.php +++ b/src/pocketmine/item/StoneHoe.php @@ -25,8 +25,8 @@ namespace pocketmine\item; class StoneHoe extends Tool{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::STONE_HOE, $meta, $count, "Stone Hoe"); + public function __construct(int $meta = 0){ + parent::__construct(self::STONE_HOE, $meta, "Stone Hoe"); } public function isHoe(){ diff --git a/src/pocketmine/item/StonePickaxe.php b/src/pocketmine/item/StonePickaxe.php index fc8d9a1b3..dfb296dab 100644 --- a/src/pocketmine/item/StonePickaxe.php +++ b/src/pocketmine/item/StonePickaxe.php @@ -25,8 +25,8 @@ namespace pocketmine\item; class StonePickaxe extends Tool{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::STONE_PICKAXE, $meta, $count, "Stone Pickaxe"); + public function __construct(int $meta = 0){ + parent::__construct(self::STONE_PICKAXE, $meta, "Stone Pickaxe"); } public function isPickaxe(){ diff --git a/src/pocketmine/item/StoneShovel.php b/src/pocketmine/item/StoneShovel.php index 85eebd1a2..8378ae424 100644 --- a/src/pocketmine/item/StoneShovel.php +++ b/src/pocketmine/item/StoneShovel.php @@ -25,8 +25,8 @@ namespace pocketmine\item; class StoneShovel extends Tool{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::STONE_SHOVEL, $meta, $count, "Stone Shovel"); + public function __construct(int $meta = 0){ + parent::__construct(self::STONE_SHOVEL, $meta, "Stone Shovel"); } public function isShovel(){ diff --git a/src/pocketmine/item/StoneSword.php b/src/pocketmine/item/StoneSword.php index aa3b368a9..614755107 100644 --- a/src/pocketmine/item/StoneSword.php +++ b/src/pocketmine/item/StoneSword.php @@ -25,8 +25,8 @@ namespace pocketmine\item; class StoneSword extends Tool{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::STONE_SWORD, $meta, $count, "Stone Sword"); + public function __construct(int $meta = 0){ + parent::__construct(self::STONE_SWORD, $meta, "Stone Sword"); } public function isSword(){ diff --git a/src/pocketmine/item/StringItem.php b/src/pocketmine/item/StringItem.php index 8e2a688a7..aac043008 100644 --- a/src/pocketmine/item/StringItem.php +++ b/src/pocketmine/item/StringItem.php @@ -27,9 +27,9 @@ use pocketmine\block\Block; use pocketmine\block\BlockFactory; class StringItem extends Item{ - public function __construct($meta = 0, $count = 1){ + public function __construct(int $meta = 0){ $this->block = BlockFactory::get(Block::TRIPWIRE); - parent::__construct(self::STRING, $meta, $count, "String"); + parent::__construct(self::STRING, $meta, "String"); } } diff --git a/src/pocketmine/item/Sugarcane.php b/src/pocketmine/item/Sugarcane.php index 07ec3e2af..d499c9cfa 100644 --- a/src/pocketmine/item/Sugarcane.php +++ b/src/pocketmine/item/Sugarcane.php @@ -27,8 +27,8 @@ use pocketmine\block\Block; use pocketmine\block\BlockFactory; class Sugarcane extends Item{ - public function __construct($meta = 0, $count = 1){ + public function __construct(int $meta = 0){ $this->block = BlockFactory::get(Block::SUGARCANE_BLOCK); - parent::__construct(self::SUGARCANE, $meta, $count, "Sugar Cane"); + parent::__construct(self::SUGARCANE, $meta, "Sugar Cane"); } } \ No newline at end of file diff --git a/src/pocketmine/item/Tool.php b/src/pocketmine/item/Tool.php index 6ba6ab55a..b2b612f30 100644 --- a/src/pocketmine/item/Tool.php +++ b/src/pocketmine/item/Tool.php @@ -40,10 +40,6 @@ abstract class Tool extends Item{ const TYPE_AXE = 4; const TYPE_SHEARS = 5; - public function __construct($id, $meta = 0, $count = 1, $name = "Unknown"){ - parent::__construct($id, $meta, $count, $name); - } - public function getMaxStackSize(){ return 1; } diff --git a/src/pocketmine/item/WheatSeeds.php b/src/pocketmine/item/WheatSeeds.php index 92a738c33..ad98c930e 100644 --- a/src/pocketmine/item/WheatSeeds.php +++ b/src/pocketmine/item/WheatSeeds.php @@ -27,8 +27,8 @@ use pocketmine\block\Block; use pocketmine\block\BlockFactory; class WheatSeeds extends Item{ - public function __construct($meta = 0, $count = 1){ + public function __construct(int $meta = 0){ $this->block = BlockFactory::get(Block::WHEAT_BLOCK); - parent::__construct(self::WHEAT_SEEDS, $meta, $count, "Wheat Seeds"); + parent::__construct(self::WHEAT_SEEDS, $meta, "Wheat Seeds"); } } \ No newline at end of file diff --git a/src/pocketmine/item/WoodenAxe.php b/src/pocketmine/item/WoodenAxe.php index 5def14b7d..64ff55cd5 100644 --- a/src/pocketmine/item/WoodenAxe.php +++ b/src/pocketmine/item/WoodenAxe.php @@ -25,8 +25,8 @@ namespace pocketmine\item; class WoodenAxe extends Tool{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::WOODEN_AXE, $meta, $count, "Wooden Axe"); + public function __construct(int $meta = 0){ + parent::__construct(self::WOODEN_AXE, $meta, "Wooden Axe"); } public function isAxe(){ diff --git a/src/pocketmine/item/WoodenDoor.php b/src/pocketmine/item/WoodenDoor.php index d233cc1a3..3ea688ad3 100644 --- a/src/pocketmine/item/WoodenDoor.php +++ b/src/pocketmine/item/WoodenDoor.php @@ -27,9 +27,9 @@ use pocketmine\block\Block; use pocketmine\block\BlockFactory; class WoodenDoor extends Item{ - public function __construct($meta = 0, $count = 1){ + public function __construct(int $meta = 0){ $this->block = BlockFactory::get(Block::WOODEN_DOOR_BLOCK); - parent::__construct(self::WOODEN_DOOR, $meta, $count, "Wooden Door"); + parent::__construct(self::WOODEN_DOOR, $meta, "Wooden Door"); } public function getMaxStackSize(){ diff --git a/src/pocketmine/item/WoodenHoe.php b/src/pocketmine/item/WoodenHoe.php index b9926cc0e..ab2faa729 100644 --- a/src/pocketmine/item/WoodenHoe.php +++ b/src/pocketmine/item/WoodenHoe.php @@ -25,8 +25,8 @@ namespace pocketmine\item; class WoodenHoe extends Tool{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::WOODEN_HOE, $meta, $count, "Wooden Hoe"); + public function __construct(int $meta = 0){ + parent::__construct(self::WOODEN_HOE, $meta, "Wooden Hoe"); } public function isHoe(){ diff --git a/src/pocketmine/item/WoodenPickaxe.php b/src/pocketmine/item/WoodenPickaxe.php index 66d28b537..d08aabaf4 100644 --- a/src/pocketmine/item/WoodenPickaxe.php +++ b/src/pocketmine/item/WoodenPickaxe.php @@ -25,8 +25,8 @@ namespace pocketmine\item; class WoodenPickaxe extends Tool{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::WOODEN_PICKAXE, $meta, $count, "Wooden Pickaxe"); + public function __construct(int $meta = 0){ + parent::__construct(self::WOODEN_PICKAXE, $meta, "Wooden Pickaxe"); } public function isPickaxe(){ diff --git a/src/pocketmine/item/WoodenShovel.php b/src/pocketmine/item/WoodenShovel.php index e12907a47..760541627 100644 --- a/src/pocketmine/item/WoodenShovel.php +++ b/src/pocketmine/item/WoodenShovel.php @@ -25,8 +25,8 @@ namespace pocketmine\item; class WoodenShovel extends Tool{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::WOODEN_SHOVEL, $meta, $count, "Wooden Shovel"); + public function __construct(int $meta = 0){ + parent::__construct(self::WOODEN_SHOVEL, $meta, "Wooden Shovel"); } public function isShovel(){ diff --git a/src/pocketmine/item/WoodenSword.php b/src/pocketmine/item/WoodenSword.php index 5a1d52643..034a2ff9b 100644 --- a/src/pocketmine/item/WoodenSword.php +++ b/src/pocketmine/item/WoodenSword.php @@ -25,8 +25,8 @@ namespace pocketmine\item; class WoodenSword extends Tool{ - public function __construct($meta = 0, $count = 1){ - parent::__construct(self::WOODEN_SWORD, $meta, $count, "Wooden Sword"); + public function __construct(int $meta = 0){ + parent::__construct(self::WOODEN_SWORD, $meta, "Wooden Sword"); } public function isSword(){