mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-21 13:04:40 +00:00
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:
parent
1fec16f167
commit
9e142655ea
@ -117,7 +117,10 @@ class Block extends Position implements BlockIds, Metadatable{
|
|||||||
* @param int $meta
|
* @param int $meta
|
||||||
*/
|
*/
|
||||||
final public function setDamage(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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -370,11 +370,14 @@ class BlockFactory{
|
|||||||
* @return Block
|
* @return Block
|
||||||
*/
|
*/
|
||||||
public static function get(int $id, int $meta = 0, Position $pos = null) : 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{
|
try{
|
||||||
$block = clone self::$fullList[($id << 4) | $meta];
|
$block = clone self::$fullList[($id << 4) | $meta];
|
||||||
}catch(\RuntimeException $e){
|
}catch(\RuntimeException $e){
|
||||||
//TODO: this probably should return null (out of bounds IDs may cause unexpected behaviour)
|
throw new \InvalidArgumentException("Block ID $id is out of bounds");
|
||||||
$block = new UnknownBlock($id, $meta);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if($pos !== null){
|
if($pos !== null){
|
||||||
|
@ -25,8 +25,8 @@ namespace pocketmine\item;
|
|||||||
|
|
||||||
|
|
||||||
class Apple extends Food{
|
class Apple extends Food{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
parent::__construct(self::APPLE, $meta, $count, "Apple");
|
parent::__construct(self::APPLE, $meta, "Apple");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFoodRestore() : int{
|
public function getFoodRestore() : int{
|
||||||
|
@ -24,8 +24,8 @@ declare(strict_types=1);
|
|||||||
namespace pocketmine\item;
|
namespace pocketmine\item;
|
||||||
|
|
||||||
class Arrow extends Item{
|
class Arrow extends Item{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
parent::__construct(self::ARROW, $meta, $count, "Arrow");
|
parent::__construct(self::ARROW, $meta, "Arrow");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -24,8 +24,8 @@ declare(strict_types=1);
|
|||||||
namespace pocketmine\item;
|
namespace pocketmine\item;
|
||||||
|
|
||||||
class BakedPotato extends Food{
|
class BakedPotato extends Food{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
parent::__construct(self::BAKED_POTATO, $meta, $count, "Baked Potato");
|
parent::__construct(self::BAKED_POTATO, $meta, "Baked Potato");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFoodRestore() : int{
|
public function getFoodRestore() : int{
|
||||||
|
@ -27,9 +27,9 @@ use pocketmine\block\Block;
|
|||||||
use pocketmine\block\BlockFactory;
|
use pocketmine\block\BlockFactory;
|
||||||
|
|
||||||
class Bed extends Item{
|
class Bed extends Item{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
$this->block = BlockFactory::get(Block::BED_BLOCK);
|
$this->block = BlockFactory::get(Block::BED_BLOCK);
|
||||||
parent::__construct(self::BED, $meta, $count, "Bed");
|
parent::__construct(self::BED, $meta, "Bed");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getMaxStackSize(){
|
public function getMaxStackSize(){
|
||||||
|
@ -24,8 +24,8 @@ declare(strict_types=1);
|
|||||||
namespace pocketmine\item;
|
namespace pocketmine\item;
|
||||||
|
|
||||||
class Beetroot extends Food{
|
class Beetroot extends Food{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
parent::__construct(self::BEETROOT, $meta, $count, "Beetroot");
|
parent::__construct(self::BEETROOT, $meta, "Beetroot");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFoodRestore() : int{
|
public function getFoodRestore() : int{
|
||||||
|
@ -27,8 +27,8 @@ use pocketmine\block\Block;
|
|||||||
use pocketmine\block\BlockFactory;
|
use pocketmine\block\BlockFactory;
|
||||||
|
|
||||||
class BeetrootSeeds extends Item{
|
class BeetrootSeeds extends Item{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
$this->block = BlockFactory::get(Block::BEETROOT_BLOCK);
|
$this->block = BlockFactory::get(Block::BEETROOT_BLOCK);
|
||||||
parent::__construct(self::BEETROOT_SEEDS, $meta, $count, "Beetroot Seeds");
|
parent::__construct(self::BEETROOT_SEEDS, $meta, "Beetroot Seeds");
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -25,8 +25,8 @@ namespace pocketmine\item;
|
|||||||
|
|
||||||
|
|
||||||
class BeetrootSoup extends Food{
|
class BeetrootSoup extends Food{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
parent::__construct(self::BEETROOT_SOUP, $meta, $count, "Beetroot Soup");
|
parent::__construct(self::BEETROOT_SOUP, $meta, "Beetroot Soup");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getMaxStackSize(){
|
public function getMaxStackSize(){
|
||||||
|
@ -24,8 +24,8 @@ declare(strict_types=1);
|
|||||||
namespace pocketmine\item;
|
namespace pocketmine\item;
|
||||||
|
|
||||||
class Boat extends Item{
|
class Boat extends Item{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
parent::__construct(self::BOAT, $meta, $count, "Boat");
|
parent::__construct(self::BOAT, $meta, "Boat");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFuelTime() : int{
|
public function getFuelTime() : int{
|
||||||
|
@ -24,8 +24,8 @@ declare(strict_types=1);
|
|||||||
namespace pocketmine\item;
|
namespace pocketmine\item;
|
||||||
|
|
||||||
class Book extends Item{
|
class Book extends Item{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
parent::__construct(self::BOOK, $meta, $count, "Book");
|
parent::__construct(self::BOOK, $meta, "Book");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -25,8 +25,8 @@ namespace pocketmine\item;
|
|||||||
|
|
||||||
|
|
||||||
class Bow extends Tool{
|
class Bow extends Tool{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
parent::__construct(self::BOW, $meta, $count, "Bow");
|
parent::__construct(self::BOW, $meta, "Bow");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFuelTime() : int{
|
public function getFuelTime() : int{
|
||||||
|
@ -25,8 +25,8 @@ namespace pocketmine\item;
|
|||||||
|
|
||||||
|
|
||||||
class Bowl extends Item{
|
class Bowl extends Item{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
parent::__construct(self::BOWL, $meta, $count, "Bowl");
|
parent::__construct(self::BOWL, $meta, "Bowl");
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: check fuel
|
//TODO: check fuel
|
||||||
|
@ -24,8 +24,8 @@ declare(strict_types=1);
|
|||||||
namespace pocketmine\item;
|
namespace pocketmine\item;
|
||||||
|
|
||||||
class Bread extends Food{
|
class Bread extends Food{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
parent::__construct(self::BREAD, $meta, $count, "Bread");
|
parent::__construct(self::BREAD, $meta, "Bread");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFoodRestore() : int{
|
public function getFoodRestore() : int{
|
||||||
|
@ -26,8 +26,8 @@ namespace pocketmine\item;
|
|||||||
use pocketmine\block\Block;
|
use pocketmine\block\Block;
|
||||||
|
|
||||||
class BrewingStand extends Item{
|
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);
|
$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");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,8 +33,8 @@ use pocketmine\math\Vector3;
|
|||||||
use pocketmine\Player;
|
use pocketmine\Player;
|
||||||
|
|
||||||
class Bucket extends Item{
|
class Bucket extends Item{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
parent::__construct(self::BUCKET, $meta, $count, "Bucket");
|
parent::__construct(self::BUCKET, $meta, "Bucket");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getMaxStackSize(){
|
public function getMaxStackSize(){
|
||||||
|
@ -27,9 +27,9 @@ use pocketmine\block\Block;
|
|||||||
use pocketmine\block\BlockFactory;
|
use pocketmine\block\BlockFactory;
|
||||||
|
|
||||||
class Cake extends Item{
|
class Cake extends Item{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
$this->block = BlockFactory::get(Block::CAKE_BLOCK);
|
$this->block = BlockFactory::get(Block::CAKE_BLOCK);
|
||||||
parent::__construct(self::CAKE, $meta, $count, "Cake");
|
parent::__construct(self::CAKE, $meta, "Cake");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getMaxStackSize(){
|
public function getMaxStackSize(){
|
||||||
|
@ -27,9 +27,9 @@ use pocketmine\block\Block;
|
|||||||
use pocketmine\block\BlockFactory;
|
use pocketmine\block\BlockFactory;
|
||||||
|
|
||||||
class Carrot extends Food{
|
class Carrot extends Food{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
$this->block = BlockFactory::get(Block::CARROT_BLOCK);
|
$this->block = BlockFactory::get(Block::CARROT_BLOCK);
|
||||||
parent::__construct(self::CARROT, $meta, $count, "Carrot");
|
parent::__construct(self::CARROT, $meta, "Carrot");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFoodRestore() : int{
|
public function getFoodRestore() : int{
|
||||||
|
@ -25,7 +25,7 @@ namespace pocketmine\item;
|
|||||||
|
|
||||||
|
|
||||||
class ChainBoots extends Armor{
|
class ChainBoots extends Armor{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
parent::__construct(self::CHAIN_BOOTS, $meta, $count, "Chainmail Boots");
|
parent::__construct(self::CHAIN_BOOTS, $meta, "Chainmail Boots");
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -25,7 +25,7 @@ namespace pocketmine\item;
|
|||||||
|
|
||||||
|
|
||||||
class ChainChestplate extends Armor{
|
class ChainChestplate extends Armor{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
parent::__construct(self::CHAIN_CHESTPLATE, $meta, $count, "Chain Chestplate");
|
parent::__construct(self::CHAIN_CHESTPLATE, $meta, "Chain Chestplate");
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -25,7 +25,7 @@ namespace pocketmine\item;
|
|||||||
|
|
||||||
|
|
||||||
class ChainHelmet extends Armor{
|
class ChainHelmet extends Armor{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
parent::__construct(self::CHAIN_HELMET, $meta, $count, "Chainmail Helmet");
|
parent::__construct(self::CHAIN_HELMET, $meta, "Chainmail Helmet");
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -25,7 +25,7 @@ namespace pocketmine\item;
|
|||||||
|
|
||||||
|
|
||||||
class ChainLeggings extends Armor{
|
class ChainLeggings extends Armor{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
parent::__construct(self::CHAIN_LEGGINGS, $meta, $count, "Chain Leggings");
|
parent::__construct(self::CHAIN_LEGGINGS, $meta, "Chain Leggings");
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -24,8 +24,8 @@ declare(strict_types=1);
|
|||||||
namespace pocketmine\item;
|
namespace pocketmine\item;
|
||||||
|
|
||||||
class Clock extends Item{
|
class Clock extends Item{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
parent::__construct(self::CLOCK, $meta, $count, "Clock");
|
parent::__construct(self::CLOCK, $meta, "Clock");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -25,8 +25,8 @@ namespace pocketmine\item;
|
|||||||
|
|
||||||
|
|
||||||
class Coal extends Item{
|
class Coal extends Item{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
parent::__construct(self::COAL, $meta, $count, "Coal");
|
parent::__construct(self::COAL, $meta, "Coal");
|
||||||
if($this->meta === 1){
|
if($this->meta === 1){
|
||||||
$this->name = "Charcoal";
|
$this->name = "Charcoal";
|
||||||
}
|
}
|
||||||
|
@ -24,8 +24,8 @@ declare(strict_types=1);
|
|||||||
namespace pocketmine\item;
|
namespace pocketmine\item;
|
||||||
|
|
||||||
class Compass extends Item{
|
class Compass extends Item{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
parent::__construct(self::COMPASS, $meta, $count, "Compass");
|
parent::__construct(self::COMPASS, $meta, "Compass");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -24,8 +24,8 @@ declare(strict_types=1);
|
|||||||
namespace pocketmine\item;
|
namespace pocketmine\item;
|
||||||
|
|
||||||
class CookedChicken extends Food{
|
class CookedChicken extends Food{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
parent::__construct(self::COOKED_CHICKEN, $meta, $count, "Cooked Chicken");
|
parent::__construct(self::COOKED_CHICKEN, $meta, "Cooked Chicken");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFoodRestore() : int{
|
public function getFoodRestore() : int{
|
||||||
|
@ -24,8 +24,8 @@ declare(strict_types=1);
|
|||||||
namespace pocketmine\item;
|
namespace pocketmine\item;
|
||||||
|
|
||||||
class CookedFish extends Fish{
|
class CookedFish extends Fish{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
Food::__construct(self::COOKED_FISH, $meta, $count, $meta === self::FISH_SALMON ? "Cooked Salmon" : "Cooked Fish");
|
Food::__construct(self::COOKED_FISH, $meta, $meta === self::FISH_SALMON ? "Cooked Salmon" : "Cooked Fish");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFoodRestore() : int{
|
public function getFoodRestore() : int{
|
||||||
|
@ -24,8 +24,8 @@ declare(strict_types=1);
|
|||||||
namespace pocketmine\item;
|
namespace pocketmine\item;
|
||||||
|
|
||||||
class CookedPorkchop extends Food{
|
class CookedPorkchop extends Food{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
parent::__construct(self::COOKED_PORKCHOP, $meta, $count, "Cooked Porkchop");
|
parent::__construct(self::COOKED_PORKCHOP, $meta, "Cooked Porkchop");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFoodRestore() : int{
|
public function getFoodRestore() : int{
|
||||||
|
@ -24,8 +24,8 @@ declare(strict_types=1);
|
|||||||
namespace pocketmine\item;
|
namespace pocketmine\item;
|
||||||
|
|
||||||
class CookedRabbit extends Food{
|
class CookedRabbit extends Food{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
parent::__construct(self::COOKED_RABBIT, $meta, $count, "Cooked Rabbit");
|
parent::__construct(self::COOKED_RABBIT, $meta, "Cooked Rabbit");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFoodRestore() : int{
|
public function getFoodRestore() : int{
|
||||||
|
@ -24,8 +24,8 @@ declare(strict_types=1);
|
|||||||
namespace pocketmine\item;
|
namespace pocketmine\item;
|
||||||
|
|
||||||
class Cookie extends Food{
|
class Cookie extends Food{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
parent::__construct(self::COOKIE, $meta, $count, "Cookie");
|
parent::__construct(self::COOKIE, $meta, "Cookie");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFoodRestore() : int{
|
public function getFoodRestore() : int{
|
||||||
|
@ -25,8 +25,8 @@ namespace pocketmine\item;
|
|||||||
|
|
||||||
|
|
||||||
class DiamondAxe extends Tool{
|
class DiamondAxe extends Tool{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
parent::__construct(self::DIAMOND_AXE, $meta, $count, "Diamond Axe");
|
parent::__construct(self::DIAMOND_AXE, $meta, "Diamond Axe");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isAxe(){
|
public function isAxe(){
|
||||||
|
@ -25,7 +25,7 @@ namespace pocketmine\item;
|
|||||||
|
|
||||||
|
|
||||||
class DiamondBoots extends Armor{
|
class DiamondBoots extends Armor{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
parent::__construct(self::DIAMOND_BOOTS, $meta, $count, "Diamond Boots");
|
parent::__construct(self::DIAMOND_BOOTS, $meta, "Diamond Boots");
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -25,7 +25,7 @@ namespace pocketmine\item;
|
|||||||
|
|
||||||
|
|
||||||
class DiamondChestplate extends Armor{
|
class DiamondChestplate extends Armor{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
parent::__construct(self::DIAMOND_CHESTPLATE, $meta, $count, "Diamond Chestplate");
|
parent::__construct(self::DIAMOND_CHESTPLATE, $meta, "Diamond Chestplate");
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -25,7 +25,7 @@ namespace pocketmine\item;
|
|||||||
|
|
||||||
|
|
||||||
class DiamondHelmet extends Armor{
|
class DiamondHelmet extends Armor{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
parent::__construct(self::DIAMOND_HELMET, $meta, $count, "Diamond Helmet");
|
parent::__construct(self::DIAMOND_HELMET, $meta, "Diamond Helmet");
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -25,8 +25,8 @@ namespace pocketmine\item;
|
|||||||
|
|
||||||
|
|
||||||
class DiamondHoe extends Tool{
|
class DiamondHoe extends Tool{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
parent::__construct(self::DIAMOND_HOE, $meta, $count, "Diamond Hoe");
|
parent::__construct(self::DIAMOND_HOE, $meta, "Diamond Hoe");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isHoe(){
|
public function isHoe(){
|
||||||
|
@ -25,7 +25,7 @@ namespace pocketmine\item;
|
|||||||
|
|
||||||
|
|
||||||
class DiamondLeggings extends Armor{
|
class DiamondLeggings extends Armor{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
parent::__construct(self::DIAMOND_LEGGINGS, $meta, $count, "Diamond Leggings");
|
parent::__construct(self::DIAMOND_LEGGINGS, $meta, "Diamond Leggings");
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -25,8 +25,8 @@ namespace pocketmine\item;
|
|||||||
|
|
||||||
|
|
||||||
class DiamondPickaxe extends Tool{
|
class DiamondPickaxe extends Tool{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
parent::__construct(self::DIAMOND_PICKAXE, $meta, $count, "Diamond Pickaxe");
|
parent::__construct(self::DIAMOND_PICKAXE, $meta, "Diamond Pickaxe");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isPickaxe(){
|
public function isPickaxe(){
|
||||||
|
@ -25,8 +25,8 @@ namespace pocketmine\item;
|
|||||||
|
|
||||||
|
|
||||||
class DiamondShovel extends Tool{
|
class DiamondShovel extends Tool{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
parent::__construct(self::DIAMOND_SHOVEL, $meta, $count, "Diamond Shovel");
|
parent::__construct(self::DIAMOND_SHOVEL, $meta, "Diamond Shovel");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isShovel(){
|
public function isShovel(){
|
||||||
|
@ -25,8 +25,8 @@ namespace pocketmine\item;
|
|||||||
|
|
||||||
|
|
||||||
class DiamondSword extends Tool{
|
class DiamondSword extends Tool{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
parent::__construct(self::DIAMOND_SWORD, $meta, $count, "Diamond Sword");
|
parent::__construct(self::DIAMOND_SWORD, $meta, "Diamond Sword");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isSword(){
|
public function isSword(){
|
||||||
|
@ -24,8 +24,8 @@ declare(strict_types=1);
|
|||||||
namespace pocketmine\item;
|
namespace pocketmine\item;
|
||||||
|
|
||||||
class Dye extends Item{
|
class Dye extends Item{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
parent::__construct(self::DYE, $meta, $count, "Dye");
|
parent::__construct(self::DYE, $meta, "Dye");
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: names
|
//TODO: names
|
||||||
|
@ -24,8 +24,8 @@ declare(strict_types=1);
|
|||||||
namespace pocketmine\item;
|
namespace pocketmine\item;
|
||||||
|
|
||||||
class Egg extends Item{
|
class Egg extends Item{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
parent::__construct(self::EGG, $meta, $count, "Egg");
|
parent::__construct(self::EGG, $meta, "Egg");
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO
|
//TODO
|
||||||
|
@ -31,7 +31,7 @@ class Fish extends Food{
|
|||||||
const FISH_CLOWNFISH = 2;
|
const FISH_CLOWNFISH = 2;
|
||||||
const FISH_PUFFERFISH = 3;
|
const FISH_PUFFERFISH = 3;
|
||||||
|
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
$name = "Raw Fish";
|
$name = "Raw Fish";
|
||||||
if($this->meta === self::FISH_SALMON){
|
if($this->meta === self::FISH_SALMON){
|
||||||
$name = "Raw Salmon";
|
$name = "Raw Salmon";
|
||||||
@ -40,7 +40,7 @@ class Fish extends Food{
|
|||||||
}elseif($this->meta === self::FISH_PUFFERFISH){
|
}elseif($this->meta === self::FISH_PUFFERFISH){
|
||||||
$name = "Pufferfish";
|
$name = "Pufferfish";
|
||||||
}
|
}
|
||||||
parent::__construct(self::RAW_FISH, $meta, $count, $name);
|
parent::__construct(self::RAW_FISH, $meta, $name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFoodRestore() : int{
|
public function getFoodRestore() : int{
|
||||||
|
@ -24,8 +24,8 @@ declare(strict_types=1);
|
|||||||
namespace pocketmine\item;
|
namespace pocketmine\item;
|
||||||
|
|
||||||
class FishingRod extends Item{
|
class FishingRod extends Item{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
parent::__construct(self::FISHING_ROD, $meta, $count, "Fishing Rod");
|
parent::__construct(self::FISHING_ROD, $meta, "Fishing Rod");
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO
|
//TODO
|
||||||
|
@ -31,8 +31,8 @@ use pocketmine\math\Vector3;
|
|||||||
use pocketmine\Player;
|
use pocketmine\Player;
|
||||||
|
|
||||||
class FlintSteel extends Tool{
|
class FlintSteel extends Tool{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
parent::__construct(self::FLINT_STEEL, $meta, $count, "Flint and Steel");
|
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{
|
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);
|
$level->setBlock($block, BlockFactory::get(Block::FIRE), true);
|
||||||
if(($player->gamemode & 0x01) === 0 and $this->useOn($block)){
|
if(($player->gamemode & 0x01) === 0 and $this->useOn($block)){
|
||||||
if($this->getDamage() >= $this->getMaxDurability()){
|
if($this->getDamage() >= $this->getMaxDurability()){
|
||||||
$player->getInventory()->setItemInHand(new Item(Item::AIR, 0, 0));
|
$player->getInventory()->setItemInHand(Item::get(Item::AIR, 0, 0));
|
||||||
}else{
|
}else{
|
||||||
$this->meta++;
|
$this->meta++;
|
||||||
$player->getInventory()->setItemInHand($this);
|
$player->getInventory()->setItemInHand($this);
|
||||||
|
@ -27,8 +27,8 @@ use pocketmine\block\Block;
|
|||||||
use pocketmine\block\BlockFactory;
|
use pocketmine\block\BlockFactory;
|
||||||
|
|
||||||
class FlowerPot extends Item{
|
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);
|
$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");
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -24,7 +24,7 @@ declare(strict_types=1);
|
|||||||
namespace pocketmine\item;
|
namespace pocketmine\item;
|
||||||
|
|
||||||
class GlassBottle extends Item{
|
class GlassBottle extends Item{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
parent::__construct(self::GLASS_BOTTLE, $meta, $count, "Glass Bottle");
|
parent::__construct(self::GLASS_BOTTLE, $meta, "Glass Bottle");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,8 +25,8 @@ namespace pocketmine\item;
|
|||||||
|
|
||||||
|
|
||||||
class GoldAxe extends Tool{
|
class GoldAxe extends Tool{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
parent::__construct(self::GOLD_AXE, $meta, $count, "Gold Axe");
|
parent::__construct(self::GOLD_AXE, $meta, "Gold Axe");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isAxe(){
|
public function isAxe(){
|
||||||
|
@ -25,7 +25,7 @@ namespace pocketmine\item;
|
|||||||
|
|
||||||
|
|
||||||
class GoldBoots extends Armor{
|
class GoldBoots extends Armor{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
parent::__construct(self::GOLD_BOOTS, $meta, $count, "Gold Boots");
|
parent::__construct(self::GOLD_BOOTS, $meta, "Gold Boots");
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -25,7 +25,7 @@ namespace pocketmine\item;
|
|||||||
|
|
||||||
|
|
||||||
class GoldChestplate extends Armor{
|
class GoldChestplate extends Armor{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
parent::__construct(self::GOLD_CHESTPLATE, $meta, $count, "Gold Chestplate");
|
parent::__construct(self::GOLD_CHESTPLATE, $meta, "Gold Chestplate");
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -25,7 +25,7 @@ namespace pocketmine\item;
|
|||||||
|
|
||||||
|
|
||||||
class GoldHelmet extends Armor{
|
class GoldHelmet extends Armor{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
parent::__construct(self::GOLD_HELMET, $meta, $count, "Gold Helmet");
|
parent::__construct(self::GOLD_HELMET, $meta, "Gold Helmet");
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -25,8 +25,8 @@ namespace pocketmine\item;
|
|||||||
|
|
||||||
|
|
||||||
class GoldHoe extends Tool{
|
class GoldHoe extends Tool{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
parent::__construct(self::GOLD_HOE, $meta, $count, "Gold Hoe");
|
parent::__construct(self::GOLD_HOE, $meta, "Gold Hoe");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isHoe(){
|
public function isHoe(){
|
||||||
|
@ -25,7 +25,7 @@ namespace pocketmine\item;
|
|||||||
|
|
||||||
|
|
||||||
class GoldLeggings extends Armor{
|
class GoldLeggings extends Armor{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
parent::__construct(self::GOLD_LEGGINGS, $meta, $count, "Gold Leggings");
|
parent::__construct(self::GOLD_LEGGINGS, $meta, "Gold Leggings");
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -25,8 +25,8 @@ namespace pocketmine\item;
|
|||||||
|
|
||||||
|
|
||||||
class GoldPickaxe extends Tool{
|
class GoldPickaxe extends Tool{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
parent::__construct(self::GOLD_PICKAXE, $meta, $count, "Gold Pickaxe");
|
parent::__construct(self::GOLD_PICKAXE, $meta, "Gold Pickaxe");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isPickaxe(){
|
public function isPickaxe(){
|
||||||
|
@ -25,8 +25,8 @@ namespace pocketmine\item;
|
|||||||
|
|
||||||
|
|
||||||
class GoldShovel extends Tool{
|
class GoldShovel extends Tool{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
parent::__construct(self::GOLD_SHOVEL, $meta, $count, "Gold Shovel");
|
parent::__construct(self::GOLD_SHOVEL, $meta, "Gold Shovel");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isShovel(){
|
public function isShovel(){
|
||||||
|
@ -25,8 +25,8 @@ namespace pocketmine\item;
|
|||||||
|
|
||||||
|
|
||||||
class GoldSword extends Tool{
|
class GoldSword extends Tool{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
parent::__construct(self::GOLD_SWORD, $meta, $count, "Gold Sword");
|
parent::__construct(self::GOLD_SWORD, $meta, "Gold Sword");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isSword(){
|
public function isSword(){
|
||||||
|
@ -29,8 +29,8 @@ use pocketmine\entity\Human;
|
|||||||
|
|
||||||
class GoldenApple extends Food{
|
class GoldenApple extends Food{
|
||||||
|
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
parent::__construct(self::GOLDEN_APPLE, $meta, $count, "Golden Apple");
|
parent::__construct(self::GOLDEN_APPLE, $meta, "Golden Apple");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function canBeConsumedBy(Entity $entity) : bool{
|
public function canBeConsumedBy(Entity $entity) : bool{
|
||||||
|
@ -27,8 +27,8 @@ use pocketmine\entity\Effect;
|
|||||||
|
|
||||||
class GoldenAppleEnchanted extends GoldenApple{
|
class GoldenAppleEnchanted extends GoldenApple{
|
||||||
|
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
Food::__construct(self::ENCHANTED_GOLDEN_APPLE, $meta, $count, "Enchanted Golden Apple"); //skip parent constructor
|
Food::__construct(self::ENCHANTED_GOLDEN_APPLE, $meta, "Enchanted Golden Apple"); //skip parent constructor
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getAdditionalEffects() : array{
|
public function getAdditionalEffects() : array{
|
||||||
|
@ -24,8 +24,8 @@ declare(strict_types=1);
|
|||||||
namespace pocketmine\item;
|
namespace pocketmine\item;
|
||||||
|
|
||||||
class GoldenCarrot extends Food{
|
class GoldenCarrot extends Food{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
parent::__construct(self::GOLDEN_CARROT, $meta, $count, "Golden Carrot");
|
parent::__construct(self::GOLDEN_CARROT, $meta, "Golden Carrot");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFoodRestore() : int{
|
public function getFoodRestore() : int{
|
||||||
|
@ -25,8 +25,8 @@ namespace pocketmine\item;
|
|||||||
|
|
||||||
|
|
||||||
class IronAxe extends Tool{
|
class IronAxe extends Tool{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
parent::__construct(self::IRON_AXE, $meta, $count, "Iron Axe");
|
parent::__construct(self::IRON_AXE, $meta, "Iron Axe");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isAxe(){
|
public function isAxe(){
|
||||||
|
@ -25,7 +25,7 @@ namespace pocketmine\item;
|
|||||||
|
|
||||||
|
|
||||||
class IronBoots extends Armor{
|
class IronBoots extends Armor{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
parent::__construct(self::IRON_BOOTS, $meta, $count, "Iron Boots");
|
parent::__construct(self::IRON_BOOTS, $meta, "Iron Boots");
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -25,7 +25,7 @@ namespace pocketmine\item;
|
|||||||
|
|
||||||
|
|
||||||
class IronChestplate extends Armor{
|
class IronChestplate extends Armor{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
parent::__construct(self::IRON_CHESTPLATE, $meta, $count, "Iron Chestplate");
|
parent::__construct(self::IRON_CHESTPLATE, $meta, "Iron Chestplate");
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -27,9 +27,9 @@ use pocketmine\block\Block;
|
|||||||
use pocketmine\block\BlockFactory;
|
use pocketmine\block\BlockFactory;
|
||||||
|
|
||||||
class IronDoor extends Item{
|
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);
|
$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(){
|
public function getMaxStackSize(){
|
||||||
|
@ -25,7 +25,7 @@ namespace pocketmine\item;
|
|||||||
|
|
||||||
|
|
||||||
class IronHelmet extends Armor{
|
class IronHelmet extends Armor{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
parent::__construct(self::IRON_HELMET, $meta, $count, "Iron Helmet");
|
parent::__construct(self::IRON_HELMET, $meta, "Iron Helmet");
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -25,8 +25,8 @@ namespace pocketmine\item;
|
|||||||
|
|
||||||
|
|
||||||
class IronHoe extends Tool{
|
class IronHoe extends Tool{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
parent::__construct(self::IRON_HOE, $meta, $count, "Iron Hoe");
|
parent::__construct(self::IRON_HOE, $meta, "Iron Hoe");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isHoe(){
|
public function isHoe(){
|
||||||
|
@ -25,7 +25,7 @@ namespace pocketmine\item;
|
|||||||
|
|
||||||
|
|
||||||
class IronLeggings extends Armor{
|
class IronLeggings extends Armor{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
parent::__construct(self::IRON_LEGGINGS, $meta, $count, "Iron Leggings");
|
parent::__construct(self::IRON_LEGGINGS, $meta, "Iron Leggings");
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -25,8 +25,8 @@ namespace pocketmine\item;
|
|||||||
|
|
||||||
|
|
||||||
class IronPickaxe extends Tool{
|
class IronPickaxe extends Tool{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
parent::__construct(self::IRON_PICKAXE, $meta, $count, "Iron Pickaxe");
|
parent::__construct(self::IRON_PICKAXE, $meta, "Iron Pickaxe");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isPickaxe(){
|
public function isPickaxe(){
|
||||||
|
@ -25,8 +25,8 @@ namespace pocketmine\item;
|
|||||||
|
|
||||||
|
|
||||||
class IronShovel extends Tool{
|
class IronShovel extends Tool{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
parent::__construct(self::IRON_SHOVEL, $meta, $count, "Iron Shovel");
|
parent::__construct(self::IRON_SHOVEL, $meta, "Iron Shovel");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isShovel(){
|
public function isShovel(){
|
||||||
|
@ -25,8 +25,8 @@ namespace pocketmine\item;
|
|||||||
|
|
||||||
|
|
||||||
class IronSword extends Tool{
|
class IronSword extends Tool{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
parent::__construct(self::IRON_SWORD, $meta, $count, "Iron Sword");
|
parent::__construct(self::IRON_SWORD, $meta, "Iron Sword");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isSword(){
|
public function isSword(){
|
||||||
|
@ -183,20 +183,24 @@ class Item implements ItemIds, \JsonSerializable{
|
|||||||
/** @var CompoundTag|null */
|
/** @var CompoundTag|null */
|
||||||
private $cachedNBT = null;
|
private $cachedNBT = null;
|
||||||
/** @var int */
|
/** @var int */
|
||||||
public $count;
|
public $count = 1;
|
||||||
/** @var string */
|
/** @var string */
|
||||||
protected $name;
|
protected $name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* 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 $id
|
||||||
* @param int $meta
|
* @param int $meta
|
||||||
* @param int $count
|
|
||||||
* @param string $name
|
* @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->id = $id & 0xffff;
|
||||||
$this->meta = $meta !== -1 ? $meta & 0xffff : -1;
|
$this->meta = $meta !== -1 ? $meta & 0xffff : -1;
|
||||||
$this->count = $count;
|
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
if(!isset($this->block) and $this->id <= 0xff and isset(BlockFactory::$list[$this->id])){
|
if(!isset($this->block) and $this->id <= 0xff and isset(BlockFactory::$list[$this->id])){
|
||||||
$this->block = BlockFactory::get($this->id, $this->meta);
|
$this->block = BlockFactory::get($this->id, $this->meta);
|
||||||
@ -631,9 +635,12 @@ class Item implements ItemIds, \JsonSerializable{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param int $count
|
* @param int $count
|
||||||
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function setCount(int $count){
|
public function setCount(int $count){
|
||||||
$this->count = $count;
|
$this->count = $count;
|
||||||
|
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -705,9 +712,12 @@ class Item implements ItemIds, \JsonSerializable{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param int $meta
|
* @param int $meta
|
||||||
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function setDamage(int $meta){
|
public function setDamage(int $meta){
|
||||||
$this->meta = $meta !== -1 ? $meta & 0xFFFF : -1;
|
$this->meta = $meta !== -1 ? $meta & 0xFFFF : -1;
|
||||||
|
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -29,13 +29,18 @@ use pocketmine\block\Block;
|
|||||||
* Class used for Items that can be Blocks
|
* Class used for Items that can be Blocks
|
||||||
*/
|
*/
|
||||||
class ItemBlock extends Item{
|
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;
|
$this->block = $block;
|
||||||
parent::__construct($block->getId(), $block->getDamage(), $count, $block->getName());
|
parent::__construct($block->getId(), $meta, $block->getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setDamage(int $meta){
|
public function setDamage(int $meta){
|
||||||
$this->meta = $meta !== -1 ? $meta & 0xf : -1;
|
$this->meta = $meta;
|
||||||
$this->block->setDamage($this->meta !== -1 ? $this->meta : 0);
|
$this->block->setDamage($this->meta !== -1 ? $this->meta : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,9 +46,9 @@ class ItemFactory{
|
|||||||
self::registerItem(new Bow());
|
self::registerItem(new Bow());
|
||||||
self::registerItem(new Arrow());
|
self::registerItem(new Arrow());
|
||||||
self::registerItem(new Coal());
|
self::registerItem(new Coal());
|
||||||
self::registerItem(new Item(Item::DIAMOND, 0, 1, "Diamond"));
|
self::registerItem(new Item(Item::DIAMOND, 0, "Diamond"));
|
||||||
self::registerItem(new Item(Item::IRON_INGOT, 0, 1, "Iron Ingot"));
|
self::registerItem(new Item(Item::IRON_INGOT, 0, "Iron Ingot"));
|
||||||
self::registerItem(new Item(Item::GOLD_INGOT, 0, 1, "Gold Ingot"));
|
self::registerItem(new Item(Item::GOLD_INGOT, 0, "Gold Ingot"));
|
||||||
self::registerItem(new IronSword());
|
self::registerItem(new IronSword());
|
||||||
self::registerItem(new WoodenSword());
|
self::registerItem(new WoodenSword());
|
||||||
self::registerItem(new WoodenShovel());
|
self::registerItem(new WoodenShovel());
|
||||||
@ -70,15 +70,15 @@ class ItemFactory{
|
|||||||
self::registerItem(new GoldPickaxe());
|
self::registerItem(new GoldPickaxe());
|
||||||
self::registerItem(new GoldAxe());
|
self::registerItem(new GoldAxe());
|
||||||
self::registerItem(new StringItem());
|
self::registerItem(new StringItem());
|
||||||
self::registerItem(new Item(Item::FEATHER, 0, 1, "Feather"));
|
self::registerItem(new Item(Item::FEATHER, 0, "Feather"));
|
||||||
self::registerItem(new Item(Item::GUNPOWDER, 0, 1, "Gunpowder"));
|
self::registerItem(new Item(Item::GUNPOWDER, 0, "Gunpowder"));
|
||||||
self::registerItem(new WoodenHoe());
|
self::registerItem(new WoodenHoe());
|
||||||
self::registerItem(new StoneHoe());
|
self::registerItem(new StoneHoe());
|
||||||
self::registerItem(new IronHoe());
|
self::registerItem(new IronHoe());
|
||||||
self::registerItem(new DiamondHoe());
|
self::registerItem(new DiamondHoe());
|
||||||
self::registerItem(new GoldHoe());
|
self::registerItem(new GoldHoe());
|
||||||
self::registerItem(new WheatSeeds());
|
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 Bread());
|
||||||
self::registerItem(new LeatherCap());
|
self::registerItem(new LeatherCap());
|
||||||
self::registerItem(new LeatherTunic());
|
self::registerItem(new LeatherTunic());
|
||||||
@ -100,7 +100,7 @@ class ItemFactory{
|
|||||||
self::registerItem(new GoldChestplate());
|
self::registerItem(new GoldChestplate());
|
||||||
self::registerItem(new GoldLeggings());
|
self::registerItem(new GoldLeggings());
|
||||||
self::registerItem(new GoldBoots());
|
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 RawPorkchop());
|
||||||
self::registerItem(new CookedPorkchop());
|
self::registerItem(new CookedPorkchop());
|
||||||
self::registerItem(new Painting());
|
self::registerItem(new Painting());
|
||||||
@ -115,26 +115,26 @@ class ItemFactory{
|
|||||||
self::registerItem(new Redstone());
|
self::registerItem(new Redstone());
|
||||||
self::registerItem(new Snowball());
|
self::registerItem(new Snowball());
|
||||||
self::registerItem(new Boat());
|
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::BRICK, 0, "Brick"));
|
||||||
self::registerItem(new Item(Item::CLAY_BALL, 0, 1, "Clay"));
|
self::registerItem(new Item(Item::CLAY_BALL, 0, "Clay"));
|
||||||
self::registerItem(new Sugarcane());
|
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 Book());
|
||||||
self::registerItem(new Item(Item::SLIME_BALL, 0, 1, "Slimeball"));
|
self::registerItem(new Item(Item::SLIME_BALL, 0, "Slimeball"));
|
||||||
//TODO: CHEST_MINECART
|
//TODO: CHEST_MINECART
|
||||||
|
|
||||||
self::registerItem(new Egg());
|
self::registerItem(new Egg());
|
||||||
self::registerItem(new Compass());
|
self::registerItem(new Compass());
|
||||||
self::registerItem(new FishingRod());
|
self::registerItem(new FishingRod());
|
||||||
self::registerItem(new Clock());
|
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 Fish());
|
||||||
self::registerItem(new CookedFish());
|
self::registerItem(new CookedFish());
|
||||||
self::registerItem(new Dye());
|
self::registerItem(new Dye());
|
||||||
self::registerItem(new Item(Item::BONE, 0, 1, "Bone"));
|
self::registerItem(new Item(Item::BONE, 0, "Bone"));
|
||||||
self::registerItem(new Item(Item::SUGAR, 0, 1, "Sugar"));
|
self::registerItem(new Item(Item::SUGAR, 0, "Sugar"));
|
||||||
self::registerItem(new Cake());
|
self::registerItem(new Cake());
|
||||||
self::registerItem(new Bed());
|
self::registerItem(new Bed());
|
||||||
//TODO: REPEATER
|
//TODO: REPEATER
|
||||||
@ -152,23 +152,23 @@ class ItemFactory{
|
|||||||
//TODO: ENDER_PEARL
|
//TODO: ENDER_PEARL
|
||||||
//TODO: BLAZE_ROD
|
//TODO: BLAZE_ROD
|
||||||
//TODO: GHAST_TEAR
|
//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 NetherWart());
|
||||||
self::registerItem(new Potion());
|
self::registerItem(new Potion());
|
||||||
self::registerItem(new GlassBottle());
|
self::registerItem(new GlassBottle());
|
||||||
self::registerItem(new SpiderEye());
|
self::registerItem(new SpiderEye());
|
||||||
self::registerItem(new Item(Item::FERMENTED_SPIDER_EYE, 0, 1, "Fermented Spider Eye"));
|
self::registerItem(new Item(Item::FERMENTED_SPIDER_EYE, 0, "Fermented Spider Eye"));
|
||||||
self::registerItem(new Item(Item::BLAZE_POWDER, 0, 1, "Blaze Powder"));
|
self::registerItem(new Item(Item::BLAZE_POWDER, 0, "Blaze Powder"));
|
||||||
self::registerItem(new Item(Item::MAGMA_CREAM, 0, 1, "Magma Cream"));
|
self::registerItem(new Item(Item::MAGMA_CREAM, 0, "Magma Cream"));
|
||||||
self::registerItem(new BrewingStand());
|
self::registerItem(new BrewingStand());
|
||||||
//TODO: CAULDRON
|
//TODO: CAULDRON
|
||||||
//TODO: ENDER_EYE
|
//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());
|
self::registerItem(new SpawnEgg());
|
||||||
//TODO: BOTTLE_O_ENCHANTING
|
//TODO: BOTTLE_O_ENCHANTING
|
||||||
//TODO: FIREBALL
|
//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 ItemFrame());
|
||||||
self::registerItem(new FlowerPot());
|
self::registerItem(new FlowerPot());
|
||||||
self::registerItem(new Carrot());
|
self::registerItem(new Carrot());
|
||||||
@ -179,16 +179,16 @@ class ItemFactory{
|
|||||||
self::registerItem(new GoldenCarrot());
|
self::registerItem(new GoldenCarrot());
|
||||||
self::registerItem(new Skull());
|
self::registerItem(new Skull());
|
||||||
//TODO: CARROTONASTICK
|
//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());
|
self::registerItem(new PumpkinPie());
|
||||||
|
|
||||||
//TODO: ENCHANTED_BOOK
|
//TODO: ENCHANTED_BOOK
|
||||||
//TODO: COMPARATOR
|
//TODO: COMPARATOR
|
||||||
self::registerItem(new Item(Item::NETHER_BRICK, 0, 1, "Nether Brick"));
|
self::registerItem(new Item(Item::NETHER_BRICK, 0, "Nether Brick"));
|
||||||
self::registerItem(new Item(Item::NETHER_QUARTZ, 0, 1, "Nether Quartz"));
|
self::registerItem(new Item(Item::NETHER_QUARTZ, 0, "Nether Quartz"));
|
||||||
//TODO: MINECART_WITH_TNT
|
//TODO: MINECART_WITH_TNT
|
||||||
//TODO: HOPPER_MINECART
|
//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: HOPPER
|
||||||
//TODO: RABBIT
|
//TODO: RABBIT
|
||||||
self::registerItem(new CookedRabbit());
|
self::registerItem(new CookedRabbit());
|
||||||
@ -201,7 +201,7 @@ class ItemFactory{
|
|||||||
//TODO: DIAMOND_HORSE_ARMOR
|
//TODO: DIAMOND_HORSE_ARMOR
|
||||||
//TODO: LEAD
|
//TODO: LEAD
|
||||||
//TODO: NAMETAG
|
//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: MUTTONRAW
|
||||||
//TODO: COOKED_MUTTON
|
//TODO: COOKED_MUTTON
|
||||||
|
|
||||||
@ -272,28 +272,36 @@ class ItemFactory{
|
|||||||
* @param CompoundTag|string $tags
|
* @param CompoundTag|string $tags
|
||||||
*
|
*
|
||||||
* @return Item
|
* @return Item
|
||||||
|
* @throws \TypeError
|
||||||
*/
|
*/
|
||||||
public static function get(int $id, int $meta = 0, int $count = 1, $tags = "") : Item{
|
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{
|
try{
|
||||||
if($id < 256){
|
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{
|
}else{
|
||||||
/** @var Item|null $item */
|
/** @var Item|null $listed */
|
||||||
$item = self::$list[$id];
|
$listed = self::$list[$id];
|
||||||
if($item === null){
|
if($listed !== null){
|
||||||
return (new Item($id, $meta, $count))->setCompoundTag($tags);
|
$item = clone $listed;
|
||||||
}else{
|
|
||||||
$item = clone $item;
|
|
||||||
$item->setDamage($meta);
|
|
||||||
$item->setCount($count);
|
|
||||||
$item->setCompoundTag($tags);
|
|
||||||
|
|
||||||
return $item;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}catch(\RuntimeException $e){
|
}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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -27,8 +27,8 @@ use pocketmine\block\Block;
|
|||||||
use pocketmine\block\BlockFactory;
|
use pocketmine\block\BlockFactory;
|
||||||
|
|
||||||
class ItemFrame extends Item{
|
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);
|
$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");
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -25,7 +25,7 @@ namespace pocketmine\item;
|
|||||||
|
|
||||||
|
|
||||||
class LeatherBoots extends Armor{
|
class LeatherBoots extends Armor{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
parent::__construct(self::LEATHER_BOOTS, $meta, $count, "Leather Boots");
|
parent::__construct(self::LEATHER_BOOTS, $meta, "Leather Boots");
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -25,7 +25,7 @@ namespace pocketmine\item;
|
|||||||
|
|
||||||
|
|
||||||
class LeatherCap extends Armor{
|
class LeatherCap extends Armor{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
parent::__construct(self::LEATHER_CAP, $meta, $count, "Leather Cap");
|
parent::__construct(self::LEATHER_CAP, $meta, "Leather Cap");
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -25,7 +25,7 @@ namespace pocketmine\item;
|
|||||||
|
|
||||||
|
|
||||||
class LeatherPants extends Armor{
|
class LeatherPants extends Armor{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
parent::__construct(self::LEATHER_PANTS, $meta, $count, "Leather Pants");
|
parent::__construct(self::LEATHER_PANTS, $meta, "Leather Pants");
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -25,7 +25,7 @@ namespace pocketmine\item;
|
|||||||
|
|
||||||
|
|
||||||
class LeatherTunic extends Armor{
|
class LeatherTunic extends Armor{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
parent::__construct(self::LEATHER_TUNIC, $meta, $count, "Leather Tunic");
|
parent::__construct(self::LEATHER_TUNIC, $meta, "Leather Tunic");
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -24,8 +24,8 @@ declare(strict_types=1);
|
|||||||
namespace pocketmine\item;
|
namespace pocketmine\item;
|
||||||
|
|
||||||
class Melon extends Food{
|
class Melon extends Food{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
parent::__construct(self::MELON, $meta, $count, "Melon");
|
parent::__construct(self::MELON, $meta, "Melon");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFoodRestore() : int{
|
public function getFoodRestore() : int{
|
||||||
|
@ -27,8 +27,8 @@ use pocketmine\block\Block;
|
|||||||
use pocketmine\block\BlockFactory;
|
use pocketmine\block\BlockFactory;
|
||||||
|
|
||||||
class MelonSeeds extends Item{
|
class MelonSeeds extends Item{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
$this->block = BlockFactory::get(Block::MELON_STEM);
|
$this->block = BlockFactory::get(Block::MELON_STEM);
|
||||||
parent::__construct(self::MELON_SEEDS, $meta, $count, "Melon Seeds");
|
parent::__construct(self::MELON_SEEDS, $meta, "Melon Seeds");
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -24,8 +24,8 @@ declare(strict_types=1);
|
|||||||
namespace pocketmine\item;
|
namespace pocketmine\item;
|
||||||
|
|
||||||
class Minecart extends Item{
|
class Minecart extends Item{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
parent::__construct(self::MINECART, $meta, $count, "Minecart");
|
parent::__construct(self::MINECART, $meta, "Minecart");
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO
|
//TODO
|
||||||
|
@ -24,8 +24,8 @@ declare(strict_types=1);
|
|||||||
namespace pocketmine\item;
|
namespace pocketmine\item;
|
||||||
|
|
||||||
class MushroomStew extends Food{
|
class MushroomStew extends Food{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
parent::__construct(self::MUSHROOM_STEW, $meta, $count, "Mushroom Stew");
|
parent::__construct(self::MUSHROOM_STEW, $meta, "Mushroom Stew");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getMaxStackSize(){
|
public function getMaxStackSize(){
|
||||||
|
@ -27,8 +27,8 @@ use pocketmine\block\Block;
|
|||||||
use pocketmine\block\BlockFactory;
|
use pocketmine\block\BlockFactory;
|
||||||
|
|
||||||
class NetherWart extends Item{
|
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);
|
$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");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,8 +29,8 @@ use pocketmine\math\Vector3;
|
|||||||
use pocketmine\Player;
|
use pocketmine\Player;
|
||||||
|
|
||||||
class Painting extends Item{
|
class Painting extends Item{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
parent::__construct(self::PAINTING, $meta, $count, "Painting");
|
parent::__construct(self::PAINTING, $meta, "Painting");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onActivate(Level $level, Player $player, Block $block, Block $target, int $face, Vector3 $facePos) : bool{
|
public function onActivate(Level $level, Player $player, Block $block, Block $target, int $face, Vector3 $facePos) : bool{
|
||||||
|
@ -27,9 +27,9 @@ use pocketmine\block\Block;
|
|||||||
use pocketmine\block\BlockFactory;
|
use pocketmine\block\BlockFactory;
|
||||||
|
|
||||||
class Potato extends Food{
|
class Potato extends Food{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
$this->block = BlockFactory::get(Block::POTATO_BLOCK);
|
$this->block = BlockFactory::get(Block::POTATO_BLOCK);
|
||||||
parent::__construct(self::POTATO, $meta, $count, "Potato");
|
parent::__construct(self::POTATO, $meta, "Potato");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFoodRestore() : int{
|
public function getFoodRestore() : int{
|
||||||
|
@ -26,8 +26,8 @@ namespace pocketmine\item;
|
|||||||
use pocketmine\entity\Entity;
|
use pocketmine\entity\Entity;
|
||||||
|
|
||||||
class Potion extends Item{
|
class Potion extends Item{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
parent::__construct(self::POTION, $meta, $count, "Potion");
|
parent::__construct(self::POTION, $meta, "Potion");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function canBeConsumed() : bool{
|
public function canBeConsumed() : bool{
|
||||||
|
@ -24,8 +24,8 @@ declare(strict_types=1);
|
|||||||
namespace pocketmine\item;
|
namespace pocketmine\item;
|
||||||
|
|
||||||
class PumpkinPie extends Food{
|
class PumpkinPie extends Food{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
parent::__construct(self::PUMPKIN_PIE, $meta, $count, "Pumpkin Pie");
|
parent::__construct(self::PUMPKIN_PIE, $meta, "Pumpkin Pie");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFoodRestore() : int{
|
public function getFoodRestore() : int{
|
||||||
|
@ -27,8 +27,8 @@ use pocketmine\block\Block;
|
|||||||
use pocketmine\block\BlockFactory;
|
use pocketmine\block\BlockFactory;
|
||||||
|
|
||||||
class PumpkinSeeds extends Item{
|
class PumpkinSeeds extends Item{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
$this->block = BlockFactory::get(Block::PUMPKIN_STEM);
|
$this->block = BlockFactory::get(Block::PUMPKIN_STEM);
|
||||||
parent::__construct(self::PUMPKIN_SEEDS, $meta, $count, "Pumpkin Seeds");
|
parent::__construct(self::PUMPKIN_SEEDS, $meta, "Pumpkin Seeds");
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -24,8 +24,8 @@ declare(strict_types=1);
|
|||||||
namespace pocketmine\item;
|
namespace pocketmine\item;
|
||||||
|
|
||||||
class RawBeef extends Food{
|
class RawBeef extends Food{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
parent::__construct(self::RAW_BEEF, $meta, $count, "Raw Beef");
|
parent::__construct(self::RAW_BEEF, $meta, "Raw Beef");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFoodRestore() : int{
|
public function getFoodRestore() : int{
|
||||||
|
@ -26,8 +26,8 @@ namespace pocketmine\item;
|
|||||||
use pocketmine\entity\Effect;
|
use pocketmine\entity\Effect;
|
||||||
|
|
||||||
class RawChicken extends Food{
|
class RawChicken extends Food{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
parent::__construct(self::RAW_CHICKEN, $meta, $count, "Raw Chicken");
|
parent::__construct(self::RAW_CHICKEN, $meta, "Raw Chicken");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFoodRestore() : int{
|
public function getFoodRestore() : int{
|
||||||
|
@ -24,8 +24,8 @@ declare(strict_types=1);
|
|||||||
namespace pocketmine\item;
|
namespace pocketmine\item;
|
||||||
|
|
||||||
class RawPorkchop extends Item{
|
class RawPorkchop extends Item{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
parent::__construct(self::RAW_PORKCHOP, $meta, $count, "Raw Porkchop");
|
parent::__construct(self::RAW_PORKCHOP, $meta, "Raw Porkchop");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -27,9 +27,9 @@ use pocketmine\block\Block;
|
|||||||
use pocketmine\block\BlockFactory;
|
use pocketmine\block\BlockFactory;
|
||||||
|
|
||||||
class Redstone extends Item{
|
class Redstone extends Item{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
$this->block = BlockFactory::get(Block::REDSTONE_WIRE);
|
$this->block = BlockFactory::get(Block::REDSTONE_WIRE);
|
||||||
parent::__construct(self::REDSTONE, $meta, $count, "Redstone");
|
parent::__construct(self::REDSTONE, $meta, "Redstone");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -25,8 +25,8 @@ namespace pocketmine\item;
|
|||||||
|
|
||||||
|
|
||||||
class Shears extends Tool{
|
class Shears extends Tool{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
parent::__construct(self::SHEARS, $meta, $count, "Shears");
|
parent::__construct(self::SHEARS, $meta, "Shears");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getMaxDurability(){
|
public function getMaxDurability(){
|
||||||
|
@ -27,9 +27,9 @@ use pocketmine\block\Block;
|
|||||||
use pocketmine\block\BlockFactory;
|
use pocketmine\block\BlockFactory;
|
||||||
|
|
||||||
class Sign extends Item{
|
class Sign extends Item{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
$this->block = BlockFactory::get(Block::SIGN_POST);
|
$this->block = BlockFactory::get(Block::SIGN_POST);
|
||||||
parent::__construct(self::SIGN, $meta, $count, "Sign");
|
parent::__construct(self::SIGN, $meta, "Sign");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getMaxStackSize(){
|
public function getMaxStackSize(){
|
||||||
|
@ -27,8 +27,8 @@ use pocketmine\block\Block;
|
|||||||
use pocketmine\block\BlockFactory;
|
use pocketmine\block\BlockFactory;
|
||||||
|
|
||||||
class Skull extends Item{
|
class Skull extends Item{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
$this->block = BlockFactory::get(Block::SKULL_BLOCK);
|
$this->block = BlockFactory::get(Block::SKULL_BLOCK);
|
||||||
parent::__construct(self::SKULL, $meta, $count, "Mob Head");
|
parent::__construct(self::SKULL, $meta, "Mob Head");
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -25,8 +25,8 @@ namespace pocketmine\item;
|
|||||||
|
|
||||||
|
|
||||||
class Snowball extends Item{
|
class Snowball extends Item{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
parent::__construct(self::SNOWBALL, $meta, $count, "Snowball");
|
parent::__construct(self::SNOWBALL, $meta, "Snowball");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getMaxStackSize(){
|
public function getMaxStackSize(){
|
||||||
|
@ -35,8 +35,8 @@ use pocketmine\nbt\tag\StringTag;
|
|||||||
use pocketmine\Player;
|
use pocketmine\Player;
|
||||||
|
|
||||||
class SpawnEgg extends Item{
|
class SpawnEgg extends Item{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
parent::__construct(self::SPAWN_EGG, $meta, $count, "Spawn Egg");
|
parent::__construct(self::SPAWN_EGG, $meta, "Spawn Egg");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onActivate(Level $level, Player $player, Block $block, Block $target, int $face, Vector3 $facePos) : bool{
|
public function onActivate(Level $level, Player $player, Block $block, Block $target, int $face, Vector3 $facePos) : bool{
|
||||||
|
@ -26,8 +26,8 @@ namespace pocketmine\item;
|
|||||||
use pocketmine\entity\Effect;
|
use pocketmine\entity\Effect;
|
||||||
|
|
||||||
class SpiderEye extends Food{
|
class SpiderEye extends Food{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
parent::__construct(self::SPIDER_EYE, $meta, $count, "Spider Eye");
|
parent::__construct(self::SPIDER_EYE, $meta, "Spider Eye");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFoodRestore() : int{
|
public function getFoodRestore() : int{
|
||||||
|
@ -24,8 +24,8 @@ declare(strict_types=1);
|
|||||||
namespace pocketmine\item;
|
namespace pocketmine\item;
|
||||||
|
|
||||||
class Steak extends Food{
|
class Steak extends Food{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
parent::__construct(self::STEAK, $meta, $count, "Steak");
|
parent::__construct(self::STEAK, $meta, "Steak");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFoodRestore() : int{
|
public function getFoodRestore() : int{
|
||||||
|
@ -25,8 +25,8 @@ namespace pocketmine\item;
|
|||||||
|
|
||||||
|
|
||||||
class Stick extends Item{
|
class Stick extends Item{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
parent::__construct(self::STICK, $meta, $count, "Stick");
|
parent::__construct(self::STICK, $meta, "Stick");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFuelTime() : int{
|
public function getFuelTime() : int{
|
||||||
|
@ -25,8 +25,8 @@ namespace pocketmine\item;
|
|||||||
|
|
||||||
|
|
||||||
class StoneAxe extends Tool{
|
class StoneAxe extends Tool{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
parent::__construct(self::STONE_AXE, $meta, $count, "Stone Axe");
|
parent::__construct(self::STONE_AXE, $meta, "Stone Axe");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -25,8 +25,8 @@ namespace pocketmine\item;
|
|||||||
|
|
||||||
|
|
||||||
class StoneHoe extends Tool{
|
class StoneHoe extends Tool{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct(int $meta = 0){
|
||||||
parent::__construct(self::STONE_HOE, $meta, $count, "Stone Hoe");
|
parent::__construct(self::STONE_HOE, $meta, "Stone Hoe");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isHoe(){
|
public function isHoe(){
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user