Implemented food and hunger

This commit is contained in:
PEMapModder
2016-02-10 22:49:48 +08:00
parent 1082e32fd7
commit 329a525ea1
47 changed files with 724 additions and 323 deletions

View File

@ -22,9 +22,16 @@
namespace pocketmine\item;
class Apple extends Item{
class Apple extends Food{
public function __construct($meta = 0, $count = 1){
parent::__construct(self::APPLE, 0, $count, "Apple");
}
public function getFoodRestore() : int{
return 4;
}
public function getSaturationRestore() : float{
return 2.4;
}
}

View File

@ -21,10 +21,17 @@
namespace pocketmine\item;
class BakedPotato extends Item{
class BakedPotato extends Food{
public function __construct($meta = 0, $count = 1){
parent::__construct(self::BAKED_POTATO, $meta, $count, "Baked Potato");
}
public function getFoodRestore() : int{
return 5;
}
public function getSaturationRestore() : float{
return 7.2;
}
}

View File

@ -21,10 +21,17 @@
namespace pocketmine\item;
class Beetroot extends Item{
class Beetroot extends Food{
public function __construct($meta = 0, $count = 1){
parent::__construct(self::BEETROOT, $meta, $count, "Beetroot");
}
public function getFoodRestore() : int{
return 1;
}
public function getSaturationRestore() : float{
return 1.2;
}
}

View File

@ -22,7 +22,7 @@
namespace pocketmine\item;
class BeetrootSoup extends Item{
class BeetrootSoup extends Food{
public function __construct($meta = 0, $count = 1){
parent::__construct(self::BEETROOT_SOUP, 0, $count, "Beetroot Soup");
}
@ -30,4 +30,16 @@ class BeetrootSoup extends Item{
public function getMaxStackSize(){
return 1;
}
public function getFoodRestore() : int{
return 6;
}
public function getSaturationRestore() : float{
return 7.2;
}
public function getResidue() : Item{
return Item::get(Item::BOWL);
}
}

View File

@ -21,8 +21,8 @@
namespace pocketmine\item;
class BlazePowder extends Item {
public function __construct($meta = 0, $count =1){
parent::__construct(self::BLAZE_POWDER, $meta, $count, "Blaze Powder");
}
class BlazePowder extends Item{
public function __construct($meta = 0, $count = 1){
parent::__construct(self::BLAZE_POWDER, $meta, $count, "Blaze Powder");
}
}

View File

@ -21,8 +21,8 @@
namespace pocketmine\item;
class Boat extends Item {
public function __construct($meta = 0, $count =1){
parent::__construct(self::BOAT, $meta, $count, "Boat");
}
class Boat extends Item{
public function __construct($meta = 0, $count = 1){
parent::__construct(self::BOAT, $meta, $count, "Boat");
}
}

View File

@ -2,11 +2,11 @@
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
@ -15,7 +15,7 @@
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*
*/

View File

@ -21,10 +21,17 @@
namespace pocketmine\item;
class Bread extends Item{
class Bread extends Food{
public function __construct($meta = 0, $count = 1){
parent::__construct(self::BREAD, $meta, $count, "Bread");
}
public function getFoodRestore() : int{
return 5;
}
public function getSaturationRestore() : float{
return 6;
}
}

View File

@ -21,8 +21,8 @@
namespace pocketmine\item;
class BrewingStand extends Item {
public function __construct($meta = 0, $count =1){
parent::__construct(self::BREWING_STAND, $meta, $count, "Brewing Stand");
}
class BrewingStand extends Item{
public function __construct($meta = 0, $count = 1){
parent::__construct(self::BREWING_STAND, $meta, $count, "Brewing Stand");
}
}

View File

@ -23,9 +23,17 @@ namespace pocketmine\item;
use pocketmine\block\Block;
class Carrot extends Item{
class Carrot extends Food{
public function __construct($meta = 0, $count = 1){
$this->block = Block::get(Item::CARROT_BLOCK);
parent::__construct(self::CARROT, 0, $count, "Carrot");
}
}
public function getFoodRestore() : int{
return 3;
}
public function getSaturationRestore() : float{
return 4.8;
}
}

View File

@ -2,11 +2,11 @@
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
@ -15,16 +15,23 @@
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*
*/
namespace pocketmine\item;
class CookedChicken extends Item{
class CookedChicken extends Food{
public function __construct($meta = 0, $count = 1){
parent::__construct(self::COOKED_CHICKEN, $meta, $count, "Cooked Chicken");
}
public function getFoodRestore() : int{
return 6;
}
public function getSaturationRestore() : float{
return 7.2;
}
}

View File

@ -2,11 +2,11 @@
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
@ -15,19 +15,22 @@
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*
*/
namespace pocketmine\item;
class CookedFish extends Item{
class CookedFish extends Fish{
public function __construct($meta = 0, $count = 1){
parent::__construct(self::COOKED_FISH, $meta, $count, "Cooked Fish");
if($this->meta === 1){
$this->name = "Cooked Salmon";
}
Food::__construct(self::COOKED_FISH, $meta, $count, $meta === self::FISH_SALMON ? "Cooked Salmon" : "Cooked Fish");
}
public function getFoodRestore() : int{
return $this->meta === self::FISH_SALMON ? 6 : 5;
}
public function getSaturationRestore() : int{
return $this->meta === self::FISH_SALMON ? 9.6 : 6;
}
}

View File

@ -2,11 +2,11 @@
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
@ -15,16 +15,23 @@
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*
*/
namespace pocketmine\item;
class CookedPorkchop extends Item{
class CookedPorkchop extends Food{
public function __construct($meta = 0, $count = 1){
parent::__construct(self::COOKED_PORKCHOP, $meta, $count, "Cooked Porkchop");
}
public function getFoodRestore() : int{
return 8;
}
public function getSaturationRestore() : float{
return 12.8;
}
}

View File

@ -21,8 +21,16 @@
namespace pocketmine\item;
class CookedRabbit extends Item {
public function __construct($meta = 0, $count =1){
parent::__construct(self::COOKED_RABBIT, $meta, $count, "Cooked Rabbit");
}
class CookedRabbit extends Food{
public function __construct($meta = 0, $count = 1){
parent::__construct(self::COOKED_RABBIT, $meta, $count, "Cooked Rabbit");
}
public function getFoodRestore() : int{
return 5;
}
public function getSaturationRestore() : float{
return 6;
}
}

View File

@ -2,11 +2,11 @@
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
@ -15,16 +15,23 @@
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*
*/
namespace pocketmine\item;
class Cookie extends Item{
class Cookie extends Food{
public function __construct($meta = 0, $count = 1){
parent::__construct(self::COOKIE, $meta, $count, "Cookie");
}
public function getFoodRestore() : int{
return 2;
}
public function getSaturationRestore() : float{
return 0.4;
}
}

View File

@ -21,8 +21,8 @@
namespace pocketmine\item;
class FermentedSpiderEye extends Item {
public function __construct($meta = 0, $count =1){
class FermentedSpiderEye extends Item{
public function __construct($meta = 0, $count = 1){
parent::__construct(self::FERMENTED_SPIDER_EYE, $meta, $count, "Fermented Spider Eye");
}
}
}

View File

@ -2,11 +2,11 @@
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
@ -15,23 +15,63 @@
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*
*/
namespace pocketmine\item;
use pocketmine\entity\Effect;
class Fish extends Food{
const FISH_FISH = 0;
const FISH_SALMON = 1;
const FISH_CLOWNFISH = 2;
const FISH_PUFFERFISH = 3;
class Fish extends Item{
public function __construct($meta = 0, $count = 1){
parent::__construct(self::RAW_FISH, $meta, $count, "Raw Fish");
if($this->meta === 1){
$this->name = "Raw Salmon";
}elseif($this->meta === 2){
$this->name = "Clownfish";
}elseif($this->meta === 3){
$this->name = "Pufferfish";
$name = "Raw Fish";
if($this->meta === self::FISH_SALMON){
$name = "Raw Salmon";
}elseif($this->meta === self::FISH_CLOWNFISH){
$name = "Clownfish";
}elseif($this->meta === self::FISH_PUFFERFISH){
$name = "Pufferfish";
}
parent::__construct(self::RAW_FISH, $meta, $count, $name);
}
}
public function getFoodRestore() : int{
if($this->meta === self::FISH_FISH){
return 2;
}elseif($this->meta === self::FISH_SALMON){
return 2;
}elseif($this->meta === self::FISH_CLOWNFISH){
return 1;
}elseif($this->meta === self::FISH_PUFFERFISH){
return 1.2;
}
return 0;
}
public function getSaturationRestore() : float{
if($this->meta === self::FISH_FISH){
return 0.4;
}elseif($this->meta === self::FISH_SALMON){
return 0.4;
}elseif($this->meta === self::FISH_CLOWNFISH){
return 0.2;
}elseif($this->meta === self::FISH_PUFFERFISH){
return 0.2;
}
return 0;
}
public function getAdditionEffects(){
return $this->meta === self::FISH_PUFFERFISH ? [
Effect::getEffect(Effect::HUNGER)->setDuration(300)->setAmplifier(2),
Effect::getEffect(Effect::NAUSEA)->setDuration(300)->setAmplifier(1),
Effect::getEffect(Effect::POISON)->setDuration(1200)->setAmplifier(3),
] : [];
}
}

View File

@ -21,8 +21,6 @@
namespace pocketmine\item;
use pocketmine\block\Block;
class FishingRod extends Item{
public function __construct($meta = 0, $count = 1){
parent::__construct(self::FISHING_ROD, 0, $count, "Fishing Rod");

View File

@ -0,0 +1,50 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
namespace pocketmine\item;
use pocketmine\entity\Effect;
use pocketmine\Player;
abstract class Food extends Item{
public abstract function getFoodRestore() : int;
public abstract function getSaturationRestore() : float;
public function getResidue() : Item{
if($this->getCount() === 1){
return Item::get(0);
}else{
$this->count--;
return $this;
}
}
/**
* @return Effect[]
*/
public function getAdditionEffects() : array{
return [];
}
public function onEat(Player $player){
}
}

View File

@ -21,8 +21,8 @@
namespace pocketmine\item;
class GlassBottle extends Item {
public function __construct($meta = 0, $count =1){
parent::__construct(self::GLASS_BOTTLE, $meta, $count, "Glass Bottle");
}
class GlassBottle extends Item{
public function __construct($meta = 0, $count = 1){
parent::__construct(self::GLASS_BOTTLE, $meta, $count, "Glass Bottle");
}
}

View File

@ -21,8 +21,8 @@
namespace pocketmine\item;
class GlisteringMelon extends Item {
public function __construct($meta = 0, $count =1){
parent::__construct(self::GLISTERING_MELON, $meta, $count, "Glistering Melon");
}
class GlisteringMelon extends Item{
public function __construct($meta = 0, $count = 1){
parent::__construct(self::GLISTERING_MELON, $meta, $count, "Glistering Melon");
}
}

View File

@ -2,11 +2,11 @@
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
@ -15,16 +15,37 @@
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*
*/
namespace pocketmine\item;
class GoldenApple extends Item{
use pocketmine\entity\Effect;
class GoldenApple extends Food{
public function __construct($meta = 0, $count = 1){
parent::__construct(self::GOLDEN_APPLE, $meta, $count, "Golden Apple");
parent::__construct(self::GOLDEN_APPLE, $meta, $count, ($meta === 1 ? "Enchanted " : "") . "Golden Apple");
}
public function getFoodRestore() : int{
return 4;
}
public function getSaturationRestore() : float{
return 9.6;
}
public function getAdditionEffects() : array{
return $this->meta === 1 ? [
Effect::getEffect(Effect::REGENERATION)->setDuration(600)->setAmplifier(4),
Effect::getEffect(Effect::ABSORPTION)->setDuration(2400),
Effect::getEffect(Effect::DAMAGE_RESISTANCE)->setDuration(6000),
Effect::getEffect(Effect::FIRE_RESISTANCE)->setDuration(6000),
] : [
Effect::getEffect(Effect::REGENERATION)->setDuration(100)->setAmplifier(1),
Effect::getEffect(Effect::ABSORPTION)->setDuration(2400)
];
}
}

View File

@ -21,8 +21,16 @@
namespace pocketmine\item;
class GoldenCarrot extends Item {
public function __construct($meta = 0, $count =1){
parent::__construct(self::GOLDEN_CARROT, $meta, $count, "Golden Carrot");
}
class GoldenCarrot extends Food{
public function __construct($meta = 0, $count = 1){
parent::__construct(self::GOLDEN_CARROT, $meta, $count, "Golden Carrot");
}
public function getFoodRestore() : int{
return 6;
}
public function getSaturationRestore() : float{
return 14.4;
}
}

View File

@ -25,23 +25,18 @@
namespace pocketmine\item;
use pocketmine\block\Block;
use pocketmine\block\Fence;
use pocketmine\block\Flower;
use pocketmine\entity\Entity;
use pocketmine\entity\Squid;
use pocketmine\entity\Villager;
use pocketmine\entity\Zombie;
use pocketmine\inventory\Fuel;
use pocketmine\item\enchantment\Enchantment;
use pocketmine\level\Level;
use pocketmine\nbt\NBT;
use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\tag\ListTag;
use pocketmine\nbt\tag\ShortTag;
use pocketmine\nbt\tag\StringTag;
use pocketmine\Player;
use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\NBT;
use pocketmine\utils\Config;
use pocketmine\Server;
use pocketmine\utils\Config;
class Item{
@ -301,7 +296,6 @@ class Item{
const STONECUTTER = 245;
const GLOWING_OBSIDIAN = 246;
//Normal Item IDs
const IRON_SHOVEL = 256;
const IRON_PICKAXE = 257;
@ -413,7 +407,6 @@ class Item{
const CAKE = 354;
const BED = 355;
const COOKIE = 357;
const SHEARS = 359;
@ -477,7 +470,6 @@ class Item{
const BEETROOT_SEED = 458;
const BEETROOT_SOUP = 459;
/** @var \SplFixedArray */
public static $list = null;
protected $block;
@ -643,7 +635,7 @@ class Item{
$creativeItems = new Config(Server::getInstance()->getFilePath() . "src/pocketmine/resources/creativeitems.json", Config::JSON, []);
foreach($creativeItems->getAll() as $item) {
foreach($creativeItems->getAll() as $item){
self::addCreativeItem(Item::get($item["ID"], $item["Damage"]));
}
}
@ -679,6 +671,7 @@ class Item{
/**
* @param $index
*
* @return Item
*/
public static function getCreativeItem(int $index){
@ -712,7 +705,8 @@ class Item{
/**
* @param string $str
* @param bool $multiple
* @param bool $multiple
*
* @return Item[]|Item
*/
public static function fromString(string $str, bool $multiple = false){
@ -772,7 +766,7 @@ class Item{
public function getCompoundTag(){
return $this->tags;
}
public function hasCompoundTag() : bool{
return $this->tags !== "" and $this->tags !== null;
}
@ -851,6 +845,7 @@ class Item{
/**
* @param $id
*
* @return Enchantment|null
*/
public function getEnchantment(int $id){
@ -1130,7 +1125,7 @@ class Item{
}
final public function __toString() : string{
return "Item " . $this->name . " (" . $this->id . ":" . ($this->meta === null ? "?" : $this->meta) . ")x" . $this->count . ($this->hasCompoundTag() ? " tags:0x".bin2hex($this->getCompoundTag()) : "");
return "Item " . $this->name . " (" . $this->id . ":" . ($this->meta === null ? "?" : $this->meta) . ")x" . $this->count . ($this->hasCompoundTag() ? " tags:0x" . bin2hex($this->getCompoundTag()) : "");
}
public function getDestroySpeed(Block $block, Player $player){

View File

@ -21,8 +21,8 @@
namespace pocketmine\item;
class MagmaCream extends Item {
public function __construct($meta = 0, $count =1){
parent::__construct(self::MAGMA_CREAM, $meta, $count, "Magma Cream");
}
class MagmaCream extends Item{
public function __construct($meta = 0, $count = 1){
parent::__construct(self::MAGMA_CREAM, $meta, $count, "Magma Cream");
}
}

View File

@ -2,11 +2,11 @@
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
@ -15,16 +15,23 @@
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*
*/
namespace pocketmine\item;
class Melon extends Item{
class Melon extends Food{
public function __construct($meta = 0, $count = 1){
parent::__construct(self::MELON, $meta, $count, "Melon");
}
public function getFoodRestore() : int{
return 2;
}
public function getSaturationRestore() : float{
return 1.2;
}
}

View File

@ -2,11 +2,11 @@
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
@ -15,14 +15,13 @@
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*
*/
namespace pocketmine\item;
class MushroomStew extends Item{
class MushroomStew extends Food{
public function __construct($meta = 0, $count = 1){
parent::__construct(self::MUSHROOM_STEW, 0, $count, "Mushroom Stew");
}
@ -30,4 +29,16 @@ class MushroomStew extends Item{
public function getMaxStackSize(){
return 1;
}
}
public function getFoodRestore() : int{
return 6;
}
public function getSaturationRestore() : float{
return 7.2;
}
public function getResidue() : Item{
return Item::get(Item::BOWL);
}
}

View File

@ -21,8 +21,8 @@
namespace pocketmine\item;
class NetherWart extends Item {
public function __construct($meta = 0, $count =1){
parent::__construct(self::NETHER_WART, $meta, $count, "Nether Wart");
}
class NetherWart extends Item{
public function __construct($meta = 0, $count = 1){
parent::__construct(self::NETHER_WART, $meta, $count, "Nether Wart");
}
}

View File

@ -23,9 +23,17 @@ namespace pocketmine\item;
use pocketmine\block\Block;
class Potato extends Item{
class Potato extends Food{
public function __construct($meta = 0, $count = 1){
$this->block = Block::get(Item::POTATO_BLOCK);
parent::__construct(self::POTATO, 0, $count, "Potato");
}
public function getFoodRestore() : int{
return 1;
}
public function getSaturationRestore() : float{
return 0.6;
}
}

View File

@ -21,8 +21,8 @@
namespace pocketmine\item;
class Potion extends Item {
public function __construct($meta = 0, $count =1){
parent::__construct(self::POTION, $meta, $count, "Potion");
}
class Potion extends Item{
public function __construct($meta = 0, $count = 1){
parent::__construct(self::POTION, $meta, $count, "Potion");
}
}

View File

@ -21,10 +21,17 @@
namespace pocketmine\item;
class PumpkinPie extends Item{
class PumpkinPie extends Food{
public function __construct($meta = 0, $count = 1){
parent::__construct(self::PUMPKIN_PIE, $meta, $count, "Pumpkin Pie");
}
public function getFoodRestore() : int{
return 8;
}
public function getSaturationRestore() : float{
return 4.8;
}
}

View File

@ -21,10 +21,17 @@
namespace pocketmine\item;
class RawBeef extends Item{
class RawBeef extends Food{
public function __construct($meta = 0, $count = 1){
parent::__construct(self::RAW_BEEF, $meta, $count, "Raw Beef");
}
public function getFoodRestore() : int{
return 3;
}
public function getSaturationRestore() : float{
return 1.8;
}
}

View File

@ -21,10 +21,25 @@
namespace pocketmine\item;
class RawChicken extends 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 getFoodRestore() : int{
return 2;
}
public function getSaturationRestore() : float{
return 1.2;
}
public function getAdditionEffects() : array{
if(mt_rand(0, 9) < 3){
return Effect::getEffect(Effect::HUNGER)->setDuration(600);
}
}
}

View File

@ -2,11 +2,12 @@
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* ____ _ _ __ __ _ __ __ ____
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
@ -15,7 +16,7 @@
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*
*/
@ -27,8 +28,8 @@ use pocketmine\level\format\FullChunk;
use pocketmine\level\Level;
use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\tag\DoubleTag;
use pocketmine\nbt\tag\ListTag;
use pocketmine\nbt\tag\FloatTag;
use pocketmine\nbt\tag\ListTag;
use pocketmine\nbt\tag\StringTag;
use pocketmine\Player;
@ -82,4 +83,4 @@ class SpawnEgg extends Item{
return false;
}
}
}

View File

@ -21,8 +21,22 @@
namespace pocketmine\item;
class SpiderEye extends Item {
public function __construct($meta = 0, $count =1){
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 getFoodRestore() : int{
return 2;
}
public function getSaturationRestore() : float{
return 3.2;
}
public function getAdditionEffects() : array{
return Effect::getEffect(Effect::POISON)->setDuration(80);
}
}

View File

@ -2,11 +2,11 @@
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
@ -15,16 +15,23 @@
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*
*/
namespace pocketmine\item;
class Steak extends Item{
class Steak extends Food{
public function __construct($meta = 0, $count = 1){
parent::__construct(self::STEAK, $meta, $count, "Steak");
}
public function getFoodRestore() : int{
return 8;
}
public function getSaturationRestore() : float{
return 12.8;
}
}

View File

@ -19,12 +19,10 @@
*
*/
namespace pocketmine\item;
use pocketmine\block\Block;
use pocketmine\entity\Entity;
use pocketmine\nbt\tag\ByteTag;
abstract class Tool extends Item{
const TIER_WOODEN = 1;

View File

@ -31,8 +31,8 @@ class EnchantmentEntry{
/**
* @param Enchantment[] $enchantments
* @param $cost
* @param $randomName
* @param number $cost
* @param string $randomName
*/
public function __construct(array $enchantments, $cost, $randomName){
$this->enchantments = $enchantments;

View File

@ -32,7 +32,7 @@ class EnchantmentList{
}
/**
* @param $slot
* @param $slot
* @param EnchantmentEntry $entry
*/
public function setSlot($slot, EnchantmentEntry $entry){