mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-10-18 04:00:29 +00:00
Removed pocketmine subdirectory, map PSR-4 style
This commit is contained in:
36
src/item/Apple.php
Normal file
36
src/item/Apple.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
|
||||
class Apple extends Food{
|
||||
|
||||
public function getFoodRestore() : int{
|
||||
return 4;
|
||||
}
|
||||
|
||||
public function getSaturationRestore() : float{
|
||||
return 2.4;
|
||||
}
|
||||
}
|
156
src/item/Armor.php
Normal file
156
src/item/Armor.php
Normal file
@@ -0,0 +1,156 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
use pocketmine\block\Block;
|
||||
use pocketmine\event\entity\EntityDamageEvent;
|
||||
use pocketmine\inventory\ArmorInventory;
|
||||
use pocketmine\item\enchantment\Enchantment;
|
||||
use pocketmine\item\enchantment\ProtectionEnchantment;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
use pocketmine\nbt\tag\IntTag;
|
||||
use pocketmine\player\Player;
|
||||
use pocketmine\utils\Binary;
|
||||
use pocketmine\utils\Color;
|
||||
use function lcg_value;
|
||||
use function mt_rand;
|
||||
|
||||
abstract class Armor extends Durable{
|
||||
|
||||
public const TAG_CUSTOM_COLOR = "customColor"; //TAG_Int
|
||||
|
||||
/** @var ArmorTypeInfo */
|
||||
private $armorInfo;
|
||||
|
||||
/** @var Color|null */
|
||||
protected $customColor = null;
|
||||
|
||||
public function __construct(int $id, int $variant, string $name, ArmorTypeInfo $info){
|
||||
parent::__construct($id, $variant, $name);
|
||||
$this->armorInfo = $info;
|
||||
}
|
||||
|
||||
public function getMaxDurability() : int{
|
||||
return $this->armorInfo->getMaxDurability();
|
||||
}
|
||||
|
||||
public function getDefensePoints() : int{
|
||||
return $this->armorInfo->getDefensePoints();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ArmorInventory
|
||||
* @return int
|
||||
*/
|
||||
abstract public function getArmorSlot() : int;
|
||||
|
||||
public function getMaxStackSize() : int{
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the dyed colour of this armour piece. This generally only applies to leather armour.
|
||||
* @return Color|null
|
||||
*/
|
||||
public function getCustomColor() : ?Color{
|
||||
return $this->customColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the dyed colour of this armour piece. This generally only applies to leather armour.
|
||||
*
|
||||
* @param Color $color
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setCustomColor(Color $color) : self{
|
||||
$this->customColor = $color;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the total enchantment protection factor this armour piece offers from all applicable protection
|
||||
* enchantments on the item.
|
||||
*
|
||||
* @param EntityDamageEvent $event
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getEnchantmentProtectionFactor(EntityDamageEvent $event) : int{
|
||||
$epf = 0;
|
||||
|
||||
foreach($this->getEnchantments() as $enchantment){
|
||||
$type = $enchantment->getType();
|
||||
if($type instanceof ProtectionEnchantment and $type->isApplicable($event)){
|
||||
$epf += $type->getProtectionFactor($enchantment->getLevel());
|
||||
}
|
||||
}
|
||||
|
||||
return $epf;
|
||||
}
|
||||
|
||||
protected function getUnbreakingDamageReduction(int $amount) : int{
|
||||
if(($unbreakingLevel = $this->getEnchantmentLevel(Enchantment::UNBREAKING())) > 0){
|
||||
$negated = 0;
|
||||
|
||||
$chance = 1 / ($unbreakingLevel + 1);
|
||||
for($i = 0; $i < $amount; ++$i){
|
||||
if(mt_rand(1, 100) > 60 and lcg_value() > $chance){ //unbreaking only applies to armor 40% of the time at best
|
||||
$negated++;
|
||||
}
|
||||
}
|
||||
|
||||
return $negated;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function onActivate(Player $player, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector) : ItemUseResult{
|
||||
$existing = $player->getArmorInventory()->getItem($this->getArmorSlot());
|
||||
if(!$existing->isNull()){
|
||||
return ItemUseResult::FAIL();
|
||||
}
|
||||
$player->getArmorInventory()->setItem($this->getArmorSlot(), $this->pop());
|
||||
return ItemUseResult::SUCCESS();
|
||||
}
|
||||
|
||||
protected function deserializeCompoundTag(CompoundTag $tag) : void{
|
||||
parent::deserializeCompoundTag($tag);
|
||||
if($tag->hasTag(self::TAG_CUSTOM_COLOR, IntTag::class)){
|
||||
$this->customColor = Color::fromARGB(Binary::unsignInt($tag->getInt(self::TAG_CUSTOM_COLOR)));
|
||||
}else{
|
||||
$this->customColor = null;
|
||||
}
|
||||
}
|
||||
|
||||
protected function serializeCompoundTag(CompoundTag $tag) : void{
|
||||
parent::serializeCompoundTag($tag);
|
||||
$this->customColor !== null ?
|
||||
$tag->setInt(self::TAG_CUSTOM_COLOR, Binary::signInt($this->customColor->toARGB())) :
|
||||
$tag->removeTag(self::TAG_CUSTOM_COLOR);
|
||||
}
|
||||
}
|
51
src/item/ArmorTypeInfo.php
Normal file
51
src/item/ArmorTypeInfo.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
class ArmorTypeInfo{
|
||||
|
||||
/** @var int */
|
||||
private $defensePoints;
|
||||
/** @var int */
|
||||
private $maxDurability;
|
||||
|
||||
public function __construct(int $defensePoints, int $maxDurability){
|
||||
$this->defensePoints = $defensePoints;
|
||||
$this->maxDurability = $maxDurability;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getDefensePoints() : int{
|
||||
return $this->defensePoints;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getMaxDurability() : int{
|
||||
return $this->maxDurability;
|
||||
}
|
||||
}
|
28
src/item/Arrow.php
Normal file
28
src/item/Arrow.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
class Arrow extends Item{
|
||||
|
||||
}
|
54
src/item/Axe.php
Normal file
54
src/item/Axe.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
use pocketmine\block\Block;
|
||||
use pocketmine\block\BlockToolType;
|
||||
use pocketmine\entity\Entity;
|
||||
|
||||
class Axe extends TieredTool{
|
||||
|
||||
public function getBlockToolType() : int{
|
||||
return BlockToolType::AXE;
|
||||
}
|
||||
|
||||
public function getBlockToolHarvestLevel() : int{
|
||||
return $this->tier->getHarvestLevel();
|
||||
}
|
||||
|
||||
public function getAttackPoints() : int{
|
||||
return $this->tier->getBaseAttackPoints() - 1;
|
||||
}
|
||||
|
||||
public function onDestroyBlock(Block $block) : bool{
|
||||
if(!$block->getBreakInfo()->breaksInstantly()){
|
||||
return $this->applyDamage(1);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function onAttackEntity(Entity $victim) : bool{
|
||||
return $this->applyDamage(2);
|
||||
}
|
||||
}
|
35
src/item/BakedPotato.php
Normal file
35
src/item/BakedPotato.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
class BakedPotato extends Food{
|
||||
|
||||
public function getFoodRestore() : int{
|
||||
return 5;
|
||||
}
|
||||
|
||||
public function getSaturationRestore() : float{
|
||||
return 7.2;
|
||||
}
|
||||
}
|
128
src/item/Banner.php
Normal file
128
src/item/Banner.php
Normal file
@@ -0,0 +1,128 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
use Ds\Deque;
|
||||
use pocketmine\block\Block;
|
||||
use pocketmine\block\tile\Banner as TileBanner;
|
||||
use pocketmine\block\utils\BannerPattern;
|
||||
use pocketmine\block\utils\DyeColor;
|
||||
use pocketmine\block\VanillaBlocks;
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
use pocketmine\nbt\tag\ListTag;
|
||||
|
||||
class Banner extends Item{
|
||||
public const TAG_PATTERNS = TileBanner::TAG_PATTERNS;
|
||||
public const TAG_PATTERN_COLOR = TileBanner::TAG_PATTERN_COLOR;
|
||||
public const TAG_PATTERN_NAME = TileBanner::TAG_PATTERN_NAME;
|
||||
|
||||
/** @var DyeColor */
|
||||
private $color;
|
||||
|
||||
/** @var BannerPattern[]|Deque */
|
||||
private $patterns;
|
||||
|
||||
public function __construct(int $id, int $variant, string $name, DyeColor $color){
|
||||
parent::__construct($id, $variant, $name);
|
||||
$this->color = $color;
|
||||
|
||||
$this->patterns = new Deque();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DyeColor
|
||||
*/
|
||||
public function getColor() : DyeColor{
|
||||
return $this->color;
|
||||
}
|
||||
|
||||
public function getBlock() : Block{
|
||||
return VanillaBlocks::BANNER();
|
||||
}
|
||||
|
||||
public function getMaxStackSize() : int{
|
||||
return 16;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Deque|BannerPattern[]
|
||||
*/
|
||||
public function getPatterns() : Deque{
|
||||
return $this->patterns;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Deque|BannerPattern[] $patterns
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setPatterns(Deque $patterns) : self{
|
||||
$this->patterns = $patterns;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getFuelTime() : int{
|
||||
return 300;
|
||||
}
|
||||
|
||||
protected function deserializeCompoundTag(CompoundTag $tag) : void{
|
||||
parent::deserializeCompoundTag($tag);
|
||||
|
||||
$this->patterns = new Deque();
|
||||
|
||||
$patterns = $tag->getListTag(self::TAG_PATTERNS);
|
||||
if($patterns !== null){
|
||||
/** @var CompoundTag $t */
|
||||
foreach($patterns as $t){
|
||||
$this->patterns->push(new BannerPattern($t->getString(self::TAG_PATTERN_NAME), DyeColor::fromMagicNumber($t->getInt(self::TAG_PATTERN_COLOR), true)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function serializeCompoundTag(CompoundTag $tag) : void{
|
||||
parent::serializeCompoundTag($tag);
|
||||
|
||||
if(!$this->patterns->isEmpty()){
|
||||
$patterns = new ListTag();
|
||||
/** @var BannerPattern $pattern */
|
||||
foreach($this->patterns as $pattern){
|
||||
$patterns->push(CompoundTag::create()
|
||||
->setString(self::TAG_PATTERN_NAME, $pattern->getId())
|
||||
->setInt(self::TAG_PATTERN_COLOR, $pattern->getColor()->getInvertedMagicNumber())
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
$tag->setTag(self::TAG_PATTERNS, $patterns);
|
||||
}else{
|
||||
$tag->removeTag(self::TAG_PATTERNS);
|
||||
}
|
||||
}
|
||||
|
||||
public function __clone(){
|
||||
parent::__clone();
|
||||
//we don't need to duplicate the individual patterns because they are immutable
|
||||
$this->patterns = $this->patterns->copy();
|
||||
}
|
||||
}
|
54
src/item/Bed.php
Normal file
54
src/item/Bed.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
use pocketmine\block\Block;
|
||||
use pocketmine\block\utils\DyeColor;
|
||||
use pocketmine\block\VanillaBlocks;
|
||||
|
||||
class Bed extends Item{
|
||||
|
||||
/** @var DyeColor */
|
||||
private $color;
|
||||
|
||||
public function __construct(int $id, int $variant, string $name, DyeColor $color){
|
||||
parent::__construct($id, $variant, $name);
|
||||
$this->color = $color;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DyeColor
|
||||
*/
|
||||
public function getColor() : DyeColor{
|
||||
return $this->color;
|
||||
}
|
||||
|
||||
public function getBlock() : Block{
|
||||
return VanillaBlocks::BED();
|
||||
}
|
||||
|
||||
public function getMaxStackSize() : int{
|
||||
return 1;
|
||||
}
|
||||
}
|
35
src/item/Beetroot.php
Normal file
35
src/item/Beetroot.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
class Beetroot extends Food{
|
||||
|
||||
public function getFoodRestore() : int{
|
||||
return 1;
|
||||
}
|
||||
|
||||
public function getSaturationRestore() : float{
|
||||
return 1.2;
|
||||
}
|
||||
}
|
34
src/item/BeetrootSeeds.php
Normal file
34
src/item/BeetrootSeeds.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
use pocketmine\block\Block;
|
||||
use pocketmine\block\VanillaBlocks;
|
||||
|
||||
class BeetrootSeeds extends Item{
|
||||
|
||||
public function getBlock() : Block{
|
||||
return VanillaBlocks::BEETROOTS();
|
||||
}
|
||||
}
|
44
src/item/BeetrootSoup.php
Normal file
44
src/item/BeetrootSoup.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
|
||||
class BeetrootSoup extends Food{
|
||||
|
||||
public function getMaxStackSize() : int{
|
||||
return 1;
|
||||
}
|
||||
|
||||
public function getFoodRestore() : int{
|
||||
return 6;
|
||||
}
|
||||
|
||||
public function getSaturationRestore() : float{
|
||||
return 7.2;
|
||||
}
|
||||
|
||||
public function getResidue(){
|
||||
return VanillaItems::BOWL();
|
||||
}
|
||||
}
|
31
src/item/BlazeRod.php
Normal file
31
src/item/BlazeRod.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
class BlazeRod extends Item{
|
||||
|
||||
public function getFuelTime() : int{
|
||||
return 2400;
|
||||
}
|
||||
}
|
49
src/item/Boat.php
Normal file
49
src/item/Boat.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
use pocketmine\block\utils\TreeType;
|
||||
|
||||
class Boat extends Item{
|
||||
/** @var TreeType */
|
||||
private $woodType;
|
||||
|
||||
public function __construct(int $id, int $variant, string $name, TreeType $woodType){
|
||||
parent::__construct($id, $variant, $name);
|
||||
$this->woodType = $woodType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return TreeType
|
||||
*/
|
||||
public function getWoodType() : TreeType{
|
||||
return $this->woodType;
|
||||
}
|
||||
|
||||
public function getFuelTime() : int{
|
||||
return 1200; //400 in PC
|
||||
}
|
||||
|
||||
//TODO
|
||||
}
|
28
src/item/Book.php
Normal file
28
src/item/Book.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
class Book extends Item{
|
||||
|
||||
}
|
33
src/item/Boots.php
Normal file
33
src/item/Boots.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
use pocketmine\inventory\ArmorInventory;
|
||||
|
||||
class Boots extends Armor{
|
||||
|
||||
public function getArmorSlot() : int{
|
||||
return ArmorInventory::SLOT_FEET;
|
||||
}
|
||||
}
|
121
src/item/Bow.php
Normal file
121
src/item/Bow.php
Normal file
@@ -0,0 +1,121 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
use pocketmine\entity\EntityFactory;
|
||||
use pocketmine\entity\projectile\Arrow as ArrowEntity;
|
||||
use pocketmine\entity\projectile\Projectile;
|
||||
use pocketmine\event\entity\EntityShootBowEvent;
|
||||
use pocketmine\event\entity\ProjectileLaunchEvent;
|
||||
use pocketmine\item\enchantment\Enchantment;
|
||||
use pocketmine\player\Player;
|
||||
use pocketmine\world\sound\BowShootSound;
|
||||
use function intdiv;
|
||||
use function min;
|
||||
|
||||
class Bow extends Tool{
|
||||
|
||||
public function getFuelTime() : int{
|
||||
return 200;
|
||||
}
|
||||
|
||||
public function getMaxDurability() : int{
|
||||
return 385;
|
||||
}
|
||||
|
||||
public function onReleaseUsing(Player $player) : ItemUseResult{
|
||||
$arrow = VanillaItems::ARROW();
|
||||
if($player->hasFiniteResources() and !$player->getInventory()->contains($arrow)){
|
||||
return ItemUseResult::FAIL();
|
||||
}
|
||||
|
||||
$nbt = EntityFactory::createBaseNBT(
|
||||
$player->add(0, $player->getEyeHeight(), 0),
|
||||
$player->getDirectionVector(),
|
||||
($player->yaw > 180 ? 360 : 0) - $player->yaw,
|
||||
-$player->pitch
|
||||
);
|
||||
$nbt->setShort("Fire", $player->isOnFire() ? 45 * 60 : 0);
|
||||
|
||||
$diff = $player->getItemUseDuration();
|
||||
$p = $diff / 20;
|
||||
$baseForce = min((($p ** 2) + $p * 2) / 3, 1);
|
||||
|
||||
/** @var ArrowEntity $entity */
|
||||
$entity = EntityFactory::create(ArrowEntity::class, $player->getWorld(), $nbt, $player, $baseForce >= 1);
|
||||
|
||||
$infinity = $this->hasEnchantment(Enchantment::INFINITY());
|
||||
if($infinity){
|
||||
$entity->setPickupMode(ArrowEntity::PICKUP_CREATIVE);
|
||||
}
|
||||
if(($punchLevel = $this->getEnchantmentLevel(Enchantment::PUNCH())) > 0){
|
||||
$entity->setPunchKnockback($punchLevel);
|
||||
}
|
||||
if(($powerLevel = $this->getEnchantmentLevel(Enchantment::POWER())) > 0){
|
||||
$entity->setBaseDamage($entity->getBaseDamage() + (($powerLevel + 1) / 2));
|
||||
}
|
||||
if($this->hasEnchantment(Enchantment::FLAME())){
|
||||
$entity->setOnFire(intdiv($entity->getFireTicks(), 20) + 100);
|
||||
}
|
||||
$ev = new EntityShootBowEvent($player, $this, $entity, $baseForce * 3);
|
||||
|
||||
if($baseForce < 0.1 or $diff < 5){
|
||||
$ev->setCancelled();
|
||||
}
|
||||
|
||||
$ev->call();
|
||||
|
||||
$entity = $ev->getProjectile(); //This might have been changed by plugins
|
||||
|
||||
if($ev->isCancelled()){
|
||||
$entity->flagForDespawn();
|
||||
return ItemUseResult::FAIL();
|
||||
}
|
||||
|
||||
$entity->setMotion($entity->getMotion()->multiply($ev->getForce()));
|
||||
|
||||
if($entity instanceof Projectile){
|
||||
$projectileEv = new ProjectileLaunchEvent($entity);
|
||||
$projectileEv->call();
|
||||
if($projectileEv->isCancelled()){
|
||||
$ev->getProjectile()->flagForDespawn();
|
||||
return ItemUseResult::FAIL();
|
||||
}
|
||||
|
||||
$ev->getProjectile()->spawnToAll();
|
||||
$player->getWorld()->addSound($player, new BowShootSound());
|
||||
}else{
|
||||
$entity->spawnToAll();
|
||||
}
|
||||
|
||||
if($player->hasFiniteResources()){
|
||||
if(!$infinity){ //TODO: tipped arrows are still consumed when Infinity is applied
|
||||
$player->getInventory()->removeItem($arrow);
|
||||
}
|
||||
$this->applyDamage(1);
|
||||
}
|
||||
|
||||
return ItemUseResult::SUCCESS();
|
||||
}
|
||||
}
|
30
src/item/Bowl.php
Normal file
30
src/item/Bowl.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
|
||||
class Bowl extends Item{
|
||||
|
||||
//TODO: check fuel
|
||||
}
|
35
src/item/Bread.php
Normal file
35
src/item/Bread.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
class Bread extends Food{
|
||||
|
||||
public function getFoodRestore() : int{
|
||||
return 5;
|
||||
}
|
||||
|
||||
public function getSaturationRestore() : float{
|
||||
return 6;
|
||||
}
|
||||
}
|
69
src/item/Bucket.php
Normal file
69
src/item/Bucket.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
use pocketmine\block\Block;
|
||||
use pocketmine\block\Liquid;
|
||||
use pocketmine\block\VanillaBlocks;
|
||||
use pocketmine\event\player\PlayerBucketFillEvent;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\player\Player;
|
||||
|
||||
class Bucket extends Item{
|
||||
|
||||
public function getMaxStackSize() : int{
|
||||
return 16;
|
||||
}
|
||||
|
||||
public function onActivate(Player $player, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector) : ItemUseResult{
|
||||
//TODO: move this to generic placement logic
|
||||
if($blockClicked instanceof Liquid and $blockClicked->isSource()){
|
||||
$stack = clone $this;
|
||||
$stack->pop();
|
||||
|
||||
$resultItem = ItemFactory::get(ItemIds::BUCKET, $blockClicked->getFlowingForm()->getId());
|
||||
$ev = new PlayerBucketFillEvent($player, $blockReplace, $face, $this, $resultItem);
|
||||
$ev->call();
|
||||
if(!$ev->isCancelled()){
|
||||
$player->getWorld()->setBlock($blockClicked, VanillaBlocks::AIR());
|
||||
$player->getWorld()->addSound($blockClicked->add(0.5, 0.5, 0.5), $blockClicked->getBucketFillSound());
|
||||
if($player->hasFiniteResources()){
|
||||
if($stack->getCount() === 0){
|
||||
$player->getInventory()->setItemInHand($ev->getItem());
|
||||
}else{
|
||||
$player->getInventory()->setItemInHand($stack);
|
||||
$player->getInventory()->addItem($ev->getItem());
|
||||
}
|
||||
}else{
|
||||
$player->getInventory()->addItem($ev->getItem());
|
||||
}
|
||||
return ItemUseResult::SUCCESS();
|
||||
}
|
||||
|
||||
return ItemUseResult::FAIL();
|
||||
}
|
||||
|
||||
return ItemUseResult::NONE();
|
||||
}
|
||||
}
|
42
src/item/Carrot.php
Normal file
42
src/item/Carrot.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
use pocketmine\block\Block;
|
||||
use pocketmine\block\VanillaBlocks;
|
||||
|
||||
class Carrot extends Food{
|
||||
|
||||
public function getBlock() : Block{
|
||||
return VanillaBlocks::CARROTS();
|
||||
}
|
||||
|
||||
public function getFoodRestore() : int{
|
||||
return 3;
|
||||
}
|
||||
|
||||
public function getSaturationRestore() : float{
|
||||
return 4.8;
|
||||
}
|
||||
}
|
33
src/item/Chestplate.php
Normal file
33
src/item/Chestplate.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
use pocketmine\inventory\ArmorInventory;
|
||||
|
||||
class Chestplate extends Armor{
|
||||
|
||||
public function getArmorSlot() : int{
|
||||
return ArmorInventory::SLOT_CHEST;
|
||||
}
|
||||
}
|
90
src/item/ChorusFruit.php
Normal file
90
src/item/ChorusFruit.php
Normal file
@@ -0,0 +1,90 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
use pocketmine\block\Liquid;
|
||||
use pocketmine\entity\Living;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\world\sound\EndermanTeleportSound;
|
||||
use function assert;
|
||||
use function min;
|
||||
use function mt_rand;
|
||||
|
||||
class ChorusFruit extends Food{
|
||||
|
||||
public function getFoodRestore() : int{
|
||||
return 4;
|
||||
}
|
||||
|
||||
public function getSaturationRestore() : float{
|
||||
return 2.4;
|
||||
}
|
||||
|
||||
public function requiresHunger() : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function onConsume(Living $consumer) : void{
|
||||
$world = $consumer->getWorld();
|
||||
assert($world !== null);
|
||||
|
||||
$minX = $consumer->getFloorX() - 8;
|
||||
$minY = min($consumer->getFloorY(), $consumer->getWorld()->getWorldHeight()) - 8;
|
||||
$minZ = $consumer->getFloorZ() - 8;
|
||||
|
||||
$maxX = $minX + 16;
|
||||
$maxY = $minY + 16;
|
||||
$maxZ = $minZ + 16;
|
||||
|
||||
for($attempts = 0; $attempts < 16; ++$attempts){
|
||||
$x = mt_rand($minX, $maxX);
|
||||
$y = mt_rand($minY, $maxY);
|
||||
$z = mt_rand($minZ, $maxZ);
|
||||
|
||||
while($y >= 0 and !$world->getBlockAt($x, $y, $z)->isSolid()){
|
||||
$y--;
|
||||
}
|
||||
if($y < 0){
|
||||
continue;
|
||||
}
|
||||
|
||||
$blockUp = $world->getBlockAt($x, $y + 1, $z);
|
||||
$blockUp2 = $world->getBlockAt($x, $y + 2, $z);
|
||||
if($blockUp->isSolid() or $blockUp instanceof Liquid or $blockUp2->isSolid() or $blockUp2 instanceof Liquid){
|
||||
continue;
|
||||
}
|
||||
|
||||
//Sounds are broadcasted at both source and destination
|
||||
$world->addSound($consumer->asVector3(), new EndermanTeleportSound());
|
||||
$consumer->teleport($target = new Vector3($x + 0.5, $y + 1, $z + 0.5));
|
||||
$world->addSound($target, new EndermanTeleportSound());
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public function getCooldownTicks() : int{
|
||||
return 20;
|
||||
}
|
||||
}
|
28
src/item/Clock.php
Normal file
28
src/item/Clock.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
class Clock extends Item{
|
||||
|
||||
}
|
35
src/item/Clownfish.php
Normal file
35
src/item/Clownfish.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
class Clownfish extends Food{
|
||||
|
||||
public function getFoodRestore() : int{
|
||||
return 1;
|
||||
}
|
||||
|
||||
public function getSaturationRestore() : float{
|
||||
return 0.2;
|
||||
}
|
||||
}
|
32
src/item/Coal.php
Normal file
32
src/item/Coal.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
|
||||
class Coal extends Item{
|
||||
|
||||
public function getFuelTime() : int{
|
||||
return 1600;
|
||||
}
|
||||
}
|
34
src/item/CocoaBeans.php
Normal file
34
src/item/CocoaBeans.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
use pocketmine\block\Block;
|
||||
use pocketmine\block\VanillaBlocks;
|
||||
|
||||
class CocoaBeans extends Item{
|
||||
|
||||
public function getBlock() : Block{
|
||||
return VanillaBlocks::COCOA_POD();
|
||||
}
|
||||
}
|
28
src/item/Compass.php
Normal file
28
src/item/Compass.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
class Compass extends Item{
|
||||
|
||||
}
|
54
src/item/Consumable.php
Normal file
54
src/item/Consumable.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
use pocketmine\block\Block;
|
||||
use pocketmine\entity\effect\EffectInstance;
|
||||
use pocketmine\entity\Living;
|
||||
|
||||
/**
|
||||
* Interface implemented by objects that can be consumed by mobs.
|
||||
*/
|
||||
interface Consumable{
|
||||
|
||||
/**
|
||||
* Returns the leftover that this Consumable produces when it is consumed. For Items, this is usually air, but could
|
||||
* be an Item to add to a Player's inventory afterwards (such as a bowl).
|
||||
*
|
||||
* @return Item|Block|mixed
|
||||
*/
|
||||
public function getResidue();
|
||||
|
||||
/**
|
||||
* @return EffectInstance[]
|
||||
*/
|
||||
public function getAdditionalEffects() : array;
|
||||
|
||||
/**
|
||||
* Called when this Consumable is consumed by mob, after standard resulting effects have been applied.
|
||||
*
|
||||
* @param Living $consumer
|
||||
*/
|
||||
public function onConsume(Living $consumer) : void;
|
||||
}
|
35
src/item/CookedChicken.php
Normal file
35
src/item/CookedChicken.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
class CookedChicken extends Food{
|
||||
|
||||
public function getFoodRestore() : int{
|
||||
return 6;
|
||||
}
|
||||
|
||||
public function getSaturationRestore() : float{
|
||||
return 7.2;
|
||||
}
|
||||
}
|
35
src/item/CookedFish.php
Normal file
35
src/item/CookedFish.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
class CookedFish extends Food{
|
||||
|
||||
public function getFoodRestore() : int{
|
||||
return 5;
|
||||
}
|
||||
|
||||
public function getSaturationRestore() : float{
|
||||
return 6;
|
||||
}
|
||||
}
|
35
src/item/CookedMutton.php
Normal file
35
src/item/CookedMutton.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
class CookedMutton extends Food{
|
||||
|
||||
public function getFoodRestore() : int{
|
||||
return 6;
|
||||
}
|
||||
|
||||
public function getSaturationRestore() : float{
|
||||
return 9.6;
|
||||
}
|
||||
}
|
35
src/item/CookedPorkchop.php
Normal file
35
src/item/CookedPorkchop.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
class CookedPorkchop extends Food{
|
||||
|
||||
public function getFoodRestore() : int{
|
||||
return 8;
|
||||
}
|
||||
|
||||
public function getSaturationRestore() : float{
|
||||
return 12.8;
|
||||
}
|
||||
}
|
35
src/item/CookedRabbit.php
Normal file
35
src/item/CookedRabbit.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
class CookedRabbit extends Food{
|
||||
|
||||
public function getFoodRestore() : int{
|
||||
return 5;
|
||||
}
|
||||
|
||||
public function getSaturationRestore() : float{
|
||||
return 6;
|
||||
}
|
||||
}
|
35
src/item/CookedSalmon.php
Normal file
35
src/item/CookedSalmon.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
class CookedSalmon extends Food{
|
||||
|
||||
public function getFoodRestore() : int{
|
||||
return 6;
|
||||
}
|
||||
|
||||
public function getSaturationRestore() : float{
|
||||
return 9.6;
|
||||
}
|
||||
}
|
35
src/item/Cookie.php
Normal file
35
src/item/Cookie.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
class Cookie extends Food{
|
||||
|
||||
public function getFoodRestore() : int{
|
||||
return 2;
|
||||
}
|
||||
|
||||
public function getSaturationRestore() : float{
|
||||
return 0.4;
|
||||
}
|
||||
}
|
35
src/item/DriedKelp.php
Normal file
35
src/item/DriedKelp.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
class DriedKelp extends Food{
|
||||
|
||||
public function getFoodRestore() : int{
|
||||
return 1;
|
||||
}
|
||||
|
||||
public function getSaturationRestore() : float{
|
||||
return 0.6;
|
||||
}
|
||||
}
|
144
src/item/Durable.php
Normal file
144
src/item/Durable.php
Normal file
@@ -0,0 +1,144 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
use pocketmine\item\enchantment\Enchantment;
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
use function lcg_value;
|
||||
use function min;
|
||||
|
||||
abstract class Durable extends Item{
|
||||
|
||||
/** @var int */
|
||||
protected $damage = 0;
|
||||
/** @var bool */
|
||||
private $unbreakable = false;
|
||||
|
||||
public function getMeta() : int{
|
||||
return $this->damage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this item will take damage when used.
|
||||
* @return bool
|
||||
*/
|
||||
public function isUnbreakable() : bool{
|
||||
return $this->unbreakable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether the item will take damage when used.
|
||||
*
|
||||
* @param bool $value
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setUnbreakable(bool $value = true) : self{
|
||||
$this->unbreakable = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies damage to the item.
|
||||
*
|
||||
* @param int $amount
|
||||
*
|
||||
* @return bool if any damage was applied to the item
|
||||
*/
|
||||
public function applyDamage(int $amount) : bool{
|
||||
if($this->isUnbreakable() or $this->isBroken()){
|
||||
return false;
|
||||
}
|
||||
|
||||
$amount -= $this->getUnbreakingDamageReduction($amount);
|
||||
|
||||
$this->damage = min($this->damage + $amount, $this->getMaxDurability());
|
||||
if($this->isBroken()){
|
||||
$this->onBroken();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getDamage() : int{
|
||||
return $this->damage;
|
||||
}
|
||||
|
||||
public function setDamage(int $damage) : Item{
|
||||
if($damage < 0 or $damage > $this->getMaxDurability()){
|
||||
throw new \InvalidArgumentException("Damage must be in range 0 - " . $this->getMaxDurability());
|
||||
}
|
||||
$this->damage = $damage;
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function getUnbreakingDamageReduction(int $amount) : int{
|
||||
if(($unbreakingLevel = $this->getEnchantmentLevel(Enchantment::UNBREAKING())) > 0){
|
||||
$negated = 0;
|
||||
|
||||
$chance = 1 / ($unbreakingLevel + 1);
|
||||
for($i = 0; $i < $amount; ++$i){
|
||||
if(lcg_value() > $chance){
|
||||
$negated++;
|
||||
}
|
||||
}
|
||||
|
||||
return $negated;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the item's damage exceeds its maximum durability.
|
||||
*/
|
||||
protected function onBroken() : void{
|
||||
$this->pop();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the maximum amount of damage this item can take before it breaks.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
abstract public function getMaxDurability() : int;
|
||||
|
||||
/**
|
||||
* Returns whether the item is broken.
|
||||
* @return bool
|
||||
*/
|
||||
public function isBroken() : bool{
|
||||
return $this->damage >= $this->getMaxDurability();
|
||||
}
|
||||
|
||||
protected function deserializeCompoundTag(CompoundTag $tag) : void{
|
||||
parent::deserializeCompoundTag($tag);
|
||||
$this->unbreakable = $tag->getByte("Unbreakable", 0) !== 0;
|
||||
}
|
||||
|
||||
protected function serializeCompoundTag(CompoundTag $tag) : void{
|
||||
parent::serializeCompoundTag($tag);
|
||||
$this->unbreakable ? $tag->setByte("Unbreakable", 1) : $tag->removeTag("Unbreakable");
|
||||
}
|
||||
}
|
44
src/item/Dye.php
Normal file
44
src/item/Dye.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
use pocketmine\block\utils\DyeColor;
|
||||
|
||||
class Dye extends Item{
|
||||
|
||||
/** @var DyeColor */
|
||||
private $color;
|
||||
|
||||
public function __construct(int $id, int $variant, string $name, DyeColor $color){
|
||||
parent::__construct($id, $variant, $name);
|
||||
$this->color = $color;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DyeColor
|
||||
*/
|
||||
public function getColor() : DyeColor{
|
||||
return $this->color;
|
||||
}
|
||||
}
|
41
src/item/Egg.php
Normal file
41
src/item/Egg.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
use pocketmine\entity\projectile\Egg as EggEntity;
|
||||
|
||||
class Egg extends ProjectileItem{
|
||||
|
||||
public function getMaxStackSize() : int{
|
||||
return 16;
|
||||
}
|
||||
|
||||
public function getProjectileEntityClass() : string{
|
||||
return EggEntity::class;
|
||||
}
|
||||
|
||||
public function getThrowForce() : float{
|
||||
return 1.5;
|
||||
}
|
||||
}
|
45
src/item/EnderPearl.php
Normal file
45
src/item/EnderPearl.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
use pocketmine\entity\projectile\EnderPearl as EnderPearlEntity;
|
||||
|
||||
class EnderPearl extends ProjectileItem{
|
||||
|
||||
public function getMaxStackSize() : int{
|
||||
return 16;
|
||||
}
|
||||
|
||||
public function getProjectileEntityClass() : string{
|
||||
return EnderPearlEntity::class;
|
||||
}
|
||||
|
||||
public function getThrowForce() : float{
|
||||
return 1.5;
|
||||
}
|
||||
|
||||
public function getCooldownTicks() : int{
|
||||
return 20;
|
||||
}
|
||||
}
|
37
src/item/ExperienceBottle.php
Normal file
37
src/item/ExperienceBottle.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
use pocketmine\entity\projectile\ExperienceBottle as ExperienceBottleEntity;
|
||||
|
||||
class ExperienceBottle extends ProjectileItem{
|
||||
|
||||
public function getProjectileEntityClass() : string{
|
||||
return ExperienceBottleEntity::class;
|
||||
}
|
||||
|
||||
public function getThrowForce() : float{
|
||||
return 0.7;
|
||||
}
|
||||
}
|
28
src/item/Fertilizer.php
Normal file
28
src/item/Fertilizer.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
class Fertilizer extends Item{
|
||||
|
||||
}
|
29
src/item/FishingRod.php
Normal file
29
src/item/FishingRod.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
class FishingRod extends Item{
|
||||
|
||||
//TODO
|
||||
}
|
54
src/item/FlintSteel.php
Normal file
54
src/item/FlintSteel.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
use pocketmine\block\Block;
|
||||
use pocketmine\block\BlockLegacyIds;
|
||||
use pocketmine\block\VanillaBlocks;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\player\Player;
|
||||
use pocketmine\world\sound\FlintSteelSound;
|
||||
use function assert;
|
||||
|
||||
class FlintSteel extends Tool{
|
||||
|
||||
public function onActivate(Player $player, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector) : ItemUseResult{
|
||||
if($blockReplace->getId() === BlockLegacyIds::AIR){
|
||||
$world = $player->getWorld();
|
||||
assert($world !== null);
|
||||
$world->setBlock($blockReplace, VanillaBlocks::FIRE());
|
||||
$world->addSound($blockReplace->add(0.5, 0.5, 0.5), new FlintSteelSound());
|
||||
|
||||
$this->applyDamage(1);
|
||||
|
||||
return ItemUseResult::SUCCESS();
|
||||
}
|
||||
|
||||
return ItemUseResult::NONE();
|
||||
}
|
||||
|
||||
public function getMaxDurability() : int{
|
||||
return 65;
|
||||
}
|
||||
}
|
47
src/item/Food.php
Normal file
47
src/item/Food.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
use pocketmine\entity\Living;
|
||||
|
||||
abstract class Food extends Item implements FoodSource{
|
||||
public function requiresHunger() : bool{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Item
|
||||
*/
|
||||
public function getResidue(){
|
||||
return ItemFactory::air();
|
||||
}
|
||||
|
||||
public function getAdditionalEffects() : array{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function onConsume(Living $consumer) : void{
|
||||
|
||||
}
|
||||
}
|
40
src/item/FoodSource.php
Normal file
40
src/item/FoodSource.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
/**
|
||||
* Interface implemented by objects that can be consumed by players, giving them food and saturation.
|
||||
*/
|
||||
interface FoodSource extends Consumable{
|
||||
|
||||
public function getFoodRestore() : int;
|
||||
|
||||
public function getSaturationRestore() : float;
|
||||
|
||||
/**
|
||||
* Returns whether a Human eating this FoodSource must have a non-full hunger bar.
|
||||
* @return bool
|
||||
*/
|
||||
public function requiresHunger() : bool;
|
||||
}
|
28
src/item/GlassBottle.php
Normal file
28
src/item/GlassBottle.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
class GlassBottle extends Item{
|
||||
|
||||
}
|
49
src/item/GoldenApple.php
Normal file
49
src/item/GoldenApple.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
use pocketmine\entity\effect\EffectInstance;
|
||||
use pocketmine\entity\effect\VanillaEffects;
|
||||
|
||||
class GoldenApple extends Food{
|
||||
|
||||
public function requiresHunger() : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getFoodRestore() : int{
|
||||
return 4;
|
||||
}
|
||||
|
||||
public function getSaturationRestore() : float{
|
||||
return 9.6;
|
||||
}
|
||||
|
||||
public function getAdditionalEffects() : array{
|
||||
return [
|
||||
new EffectInstance(VanillaEffects::REGENERATION(), 100, 1),
|
||||
new EffectInstance(VanillaEffects::ABSORPTION(), 2400)
|
||||
];
|
||||
}
|
||||
}
|
39
src/item/GoldenAppleEnchanted.php
Normal file
39
src/item/GoldenAppleEnchanted.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
use pocketmine\entity\effect\EffectInstance;
|
||||
use pocketmine\entity\effect\VanillaEffects;
|
||||
|
||||
class GoldenAppleEnchanted extends GoldenApple{
|
||||
|
||||
public function getAdditionalEffects() : array{
|
||||
return [
|
||||
new EffectInstance(VanillaEffects::REGENERATION(), 600, 4),
|
||||
new EffectInstance(VanillaEffects::ABSORPTION(), 2400, 3),
|
||||
new EffectInstance(VanillaEffects::RESISTANCE(), 6000),
|
||||
new EffectInstance(VanillaEffects::FIRE_RESISTANCE(), 6000)
|
||||
];
|
||||
}
|
||||
}
|
35
src/item/GoldenCarrot.php
Normal file
35
src/item/GoldenCarrot.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
class GoldenCarrot extends Food{
|
||||
|
||||
public function getFoodRestore() : int{
|
||||
return 6;
|
||||
}
|
||||
|
||||
public function getSaturationRestore() : float{
|
||||
return 14.4;
|
||||
}
|
||||
}
|
33
src/item/Helmet.php
Normal file
33
src/item/Helmet.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
use pocketmine\inventory\ArmorInventory;
|
||||
|
||||
class Helmet extends Armor{
|
||||
|
||||
public function getArmorSlot() : int{
|
||||
return ArmorInventory::SLOT_HEAD;
|
||||
}
|
||||
}
|
33
src/item/Hoe.php
Normal file
33
src/item/Hoe.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
use pocketmine\entity\Entity;
|
||||
|
||||
class Hoe extends TieredTool{
|
||||
|
||||
public function onAttackEntity(Entity $victim) : bool{
|
||||
return $this->applyDamage(1);
|
||||
}
|
||||
}
|
772
src/item/Item.php
Normal file
772
src/item/Item.php
Normal file
@@ -0,0 +1,772 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* All the Item classes
|
||||
*/
|
||||
namespace pocketmine\item;
|
||||
|
||||
use Ds\Set;
|
||||
use pocketmine\block\Block;
|
||||
use pocketmine\block\BlockBreakInfo;
|
||||
use pocketmine\block\BlockToolType;
|
||||
use pocketmine\block\VanillaBlocks;
|
||||
use pocketmine\entity\Entity;
|
||||
use pocketmine\item\enchantment\Enchantment;
|
||||
use pocketmine\item\enchantment\EnchantmentInstance;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\nbt\LittleEndianNbtSerializer;
|
||||
use pocketmine\nbt\NBT;
|
||||
use pocketmine\nbt\NbtDataException;
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
use pocketmine\nbt\tag\ListTag;
|
||||
use pocketmine\nbt\tag\ShortTag;
|
||||
use pocketmine\nbt\tag\StringTag;
|
||||
use pocketmine\nbt\TreeRoot;
|
||||
use pocketmine\player\Player;
|
||||
use pocketmine\utils\Binary;
|
||||
use function base64_decode;
|
||||
use function base64_encode;
|
||||
use function get_class;
|
||||
use function gettype;
|
||||
use function hex2bin;
|
||||
use function is_string;
|
||||
|
||||
class Item implements \JsonSerializable{
|
||||
use ItemEnchantmentHandlingTrait;
|
||||
|
||||
public const TAG_ENCH = "ench";
|
||||
public const TAG_DISPLAY = "display";
|
||||
public const TAG_BLOCK_ENTITY_TAG = "BlockEntityTag";
|
||||
|
||||
public const TAG_DISPLAY_NAME = "Name";
|
||||
public const TAG_DISPLAY_LORE = "Lore";
|
||||
|
||||
/** @var int */
|
||||
protected $id;
|
||||
/** @var int */
|
||||
protected $meta;
|
||||
/** @var CompoundTag|null */
|
||||
private $nbt = null;
|
||||
/** @var int */
|
||||
protected $count = 1;
|
||||
/** @var string */
|
||||
protected $name;
|
||||
|
||||
//TODO: this stuff should be moved to itemstack properties, not mushed in with type properties
|
||||
|
||||
/** @var string */
|
||||
protected $customName = "";
|
||||
/** @var string[] */
|
||||
protected $lore = [];
|
||||
/**
|
||||
* TODO: this needs to die in a fire
|
||||
* @var CompoundTag|null
|
||||
*/
|
||||
protected $blockEntityTag = null;
|
||||
|
||||
/** @var Set|string[] */
|
||||
protected $canPlaceOn;
|
||||
/** @var Set|string[] */
|
||||
protected $canDestroy;
|
||||
|
||||
/**
|
||||
* 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 $variant
|
||||
* @param string $name
|
||||
*/
|
||||
public function __construct(int $id, int $variant = 0, string $name = "Unknown"){
|
||||
if($id < -0x8000 or $id > 0x7fff){ //signed short range
|
||||
throw new \InvalidArgumentException("ID must be in range " . -0x8000 . " - " . 0x7fff);
|
||||
}
|
||||
$this->id = $id;
|
||||
$this->meta = $variant !== -1 ? $variant & 0x7FFF : -1;
|
||||
$this->name = $name;
|
||||
|
||||
$this->canPlaceOn = new Set();
|
||||
$this->canDestroy = new Set();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function hasCustomBlockData() : bool{
|
||||
return $this->blockEntityTag !== null;
|
||||
}
|
||||
|
||||
public function clearCustomBlockData(){
|
||||
$this->blockEntityTag = null;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CompoundTag $compound
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setCustomBlockData(CompoundTag $compound) : Item{
|
||||
$this->blockEntityTag = clone $compound;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return CompoundTag|null
|
||||
*/
|
||||
public function getCustomBlockData() : ?CompoundTag{
|
||||
return $this->blockEntityTag;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function hasCustomName() : bool{
|
||||
return $this->customName !== "";
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCustomName() : string{
|
||||
return $this->customName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setCustomName(string $name) : Item{
|
||||
//TODO: encoding might need to be checked here
|
||||
$this->customName = $name;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function clearCustomName() : Item{
|
||||
$this->setCustomName("");
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function getLore() : array{
|
||||
return $this->lore;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string[] $lines
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setLore(array $lines) : Item{
|
||||
foreach($lines as $line){
|
||||
if(!is_string($line)){
|
||||
throw new \TypeError("Expected string[], but found " . gettype($line) . " in given array");
|
||||
}
|
||||
}
|
||||
$this->lore = $lines;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Set|string[]
|
||||
*/
|
||||
public function getCanPlaceOn() : Set{
|
||||
return $this->canPlaceOn;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Set|string[] $canPlaceOn
|
||||
*/
|
||||
public function setCanPlaceOn(Set $canPlaceOn) : void{
|
||||
$this->canPlaceOn = $canPlaceOn;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Set|string[]
|
||||
*/
|
||||
public function getCanDestroy() : Set{
|
||||
return $this->canDestroy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Set|string[] $canDestroy
|
||||
*/
|
||||
public function setCanDestroy(Set $canDestroy) : void{
|
||||
$this->canDestroy = $canDestroy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this Item has a non-empty NBT.
|
||||
* @return bool
|
||||
*/
|
||||
public function hasNamedTag() : bool{
|
||||
return $this->getNamedTag()->count() > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a tree of Tag objects representing the Item's NBT. If the item does not have any NBT, an empty CompoundTag
|
||||
* object is returned to allow the caller to manipulate and apply back to the item.
|
||||
*
|
||||
* @return CompoundTag
|
||||
*/
|
||||
public function getNamedTag() : CompoundTag{
|
||||
if($this->nbt === null){
|
||||
$this->nbt = new CompoundTag();
|
||||
}
|
||||
$this->serializeCompoundTag($this->nbt);
|
||||
return $this->nbt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Item's NBT from the supplied CompoundTag object.
|
||||
*
|
||||
* @param CompoundTag $tag
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setNamedTag(CompoundTag $tag) : Item{
|
||||
if($tag->getCount() === 0){
|
||||
return $this->clearNamedTag();
|
||||
}
|
||||
|
||||
$this->nbt = clone $tag;
|
||||
$this->deserializeCompoundTag($this->nbt);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the Item's NBT.
|
||||
* @return $this
|
||||
*/
|
||||
public function clearNamedTag() : Item{
|
||||
$this->nbt = new CompoundTag();
|
||||
$this->deserializeCompoundTag($this->nbt);
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function deserializeCompoundTag(CompoundTag $tag) : void{
|
||||
$this->customName = "";
|
||||
$this->lore = [];
|
||||
|
||||
$display = $tag->getCompoundTag(self::TAG_DISPLAY);
|
||||
if($display !== null){
|
||||
$this->customName = $display->getString(self::TAG_DISPLAY_NAME, $this->customName, true);
|
||||
$lore = $display->getListTag(self::TAG_DISPLAY_LORE);
|
||||
if($lore !== null and $lore->getTagType() === NBT::TAG_String){
|
||||
/** @var StringTag $t */
|
||||
foreach($lore as $t){
|
||||
$this->lore[] = $t->getValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->removeEnchantments();
|
||||
$enchantments = $tag->getListTag(self::TAG_ENCH);
|
||||
if($enchantments !== null and $enchantments->getTagType() === NBT::TAG_Compound){
|
||||
/** @var CompoundTag $enchantment */
|
||||
foreach($enchantments as $enchantment){
|
||||
$magicNumber = $enchantment->getShort("id", 0, true);
|
||||
$level = $enchantment->getShort("lvl", 0, true);
|
||||
if($magicNumber <= 0 or $level <= 0){
|
||||
continue;
|
||||
}
|
||||
$type = Enchantment::get($magicNumber);
|
||||
if($type !== null){
|
||||
$this->addEnchantment(new EnchantmentInstance($type, $level));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->blockEntityTag = $tag->getCompoundTag(self::TAG_BLOCK_ENTITY_TAG);
|
||||
|
||||
$this->canPlaceOn = new Set();
|
||||
$canPlaceOn = $tag->getListTag("CanPlaceOn");
|
||||
if($canPlaceOn !== null){
|
||||
/** @var StringTag $tag */
|
||||
foreach($canPlaceOn as $entry){
|
||||
$this->canPlaceOn->add($entry->getValue());
|
||||
}
|
||||
}
|
||||
$this->canDestroy = new Set();
|
||||
$canDestroy = $tag->getListTag("CanDestroy");
|
||||
if($canDestroy !== null){
|
||||
/** @var StringTag $entry */
|
||||
foreach($canDestroy as $entry){
|
||||
$this->canDestroy->add($entry->getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function serializeCompoundTag(CompoundTag $tag) : void{
|
||||
$display = $tag->getCompoundTag(self::TAG_DISPLAY) ?? new CompoundTag();
|
||||
|
||||
$this->hasCustomName() ?
|
||||
$display->setString(self::TAG_DISPLAY_NAME, $this->getCustomName()) :
|
||||
$display->removeTag(self::TAG_DISPLAY);
|
||||
|
||||
if(!empty($this->lore)){
|
||||
$loreTag = new ListTag();
|
||||
foreach($this->lore as $line){
|
||||
$loreTag->push(new StringTag($line));
|
||||
}
|
||||
$display->setTag(self::TAG_DISPLAY_LORE, $loreTag);
|
||||
}else{
|
||||
$display->removeTag(self::TAG_DISPLAY_LORE);
|
||||
}
|
||||
$display->count() > 0 ?
|
||||
$tag->setTag(self::TAG_DISPLAY, $display) :
|
||||
$tag->removeTag(self::TAG_DISPLAY);
|
||||
|
||||
if($this->hasEnchantments()){
|
||||
$ench = new ListTag();
|
||||
foreach($this->getEnchantments() as $enchantmentInstance){
|
||||
$ench->push(CompoundTag::create()
|
||||
->setShort("id", $enchantmentInstance->getType()->getId())
|
||||
->setShort("lvl", $enchantmentInstance->getLevel())
|
||||
);
|
||||
}
|
||||
$tag->setTag(self::TAG_ENCH, $ench);
|
||||
}else{
|
||||
$tag->removeTag(self::TAG_ENCH);
|
||||
}
|
||||
|
||||
$this->hasCustomBlockData() ?
|
||||
$tag->setTag(self::TAG_BLOCK_ENTITY_TAG, clone $this->getCustomBlockData()) :
|
||||
$tag->removeTag(self::TAG_BLOCK_ENTITY_TAG);
|
||||
|
||||
if(!$this->canPlaceOn->isEmpty()){
|
||||
$canPlaceOn = new ListTag();
|
||||
foreach($this->canPlaceOn as $item){
|
||||
$canPlaceOn->push(new StringTag($item));
|
||||
}
|
||||
$tag->setTag("CanPlaceOn", $canPlaceOn);
|
||||
}else{
|
||||
$tag->removeTag("CanPlaceOn");
|
||||
}
|
||||
if(!$this->canDestroy->isEmpty()){
|
||||
$canDestroy = new ListTag();
|
||||
foreach($this->canDestroy as $item){
|
||||
$canDestroy->push(new StringTag($item));
|
||||
}
|
||||
$tag->setTag("CanDestroy", $canDestroy);
|
||||
}else{
|
||||
$tag->removeTag("CanDestroy");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getCount() : int{
|
||||
return $this->count;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $count
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setCount(int $count) : Item{
|
||||
$this->count = $count;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pops an item from the stack and returns it, decreasing the stack count of this item stack by one.
|
||||
*
|
||||
* @param int $count
|
||||
*
|
||||
* @return Item
|
||||
* @throws \InvalidArgumentException if trying to pop more items than are on the stack
|
||||
*/
|
||||
public function pop(int $count = 1) : Item{
|
||||
if($count > $this->count){
|
||||
throw new \InvalidArgumentException("Cannot pop $count items from a stack of $this->count");
|
||||
}
|
||||
|
||||
$item = clone $this;
|
||||
$item->count = $count;
|
||||
|
||||
$this->count -= $count;
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
public function isNull() : bool{
|
||||
return $this->count <= 0 or $this->id === ItemIds::AIR;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the item, or the custom name if it is set.
|
||||
* @return string
|
||||
*/
|
||||
final public function getName() : string{
|
||||
return $this->hasCustomName() ? $this->getCustomName() : $this->getVanillaName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the vanilla name of the item, disregarding custom names.
|
||||
* @return string
|
||||
*/
|
||||
public function getVanillaName() : string{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
final public function canBePlaced() : bool{
|
||||
return $this->getBlock()->canBePlaced();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the block corresponding to this Item.
|
||||
* @return Block
|
||||
*/
|
||||
public function getBlock() : Block{
|
||||
return VanillaBlocks::AIR();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
final public function getId() : int{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getMeta() : int{
|
||||
return $this->meta;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this item can match any item with an equivalent ID with any meta value.
|
||||
* Used in crafting recipes which accept multiple variants of the same item, for example crafting tables recipes.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasAnyDamageValue() : bool{
|
||||
return $this->meta === -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the highest amount of this item which will fit into one inventory slot.
|
||||
* @return int
|
||||
*/
|
||||
public function getMaxStackSize() : int{
|
||||
return 64;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the time in ticks which the item will fuel a furnace for.
|
||||
* @return int
|
||||
*/
|
||||
public function getFuelTime() : int{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns how many points of damage this item will deal to an entity when used as a weapon.
|
||||
* @return int
|
||||
*/
|
||||
public function getAttackPoints() : int{
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns how many armor points can be gained by wearing this item.
|
||||
* @return int
|
||||
*/
|
||||
public function getDefensePoints() : int{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns what type of block-breaking tool this is. Blocks requiring the same tool type as the item will break
|
||||
* faster (except for blocks requiring no tool, which break at the same speed regardless of the tool used)
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getBlockToolType() : int{
|
||||
return BlockToolType::NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the harvesting power that this tool has. This affects what blocks it can mine when the tool type matches
|
||||
* the mined block.
|
||||
* This should return 1 for non-tiered tools, and the tool tier for tiered tools.
|
||||
*
|
||||
* @see BlockBreakInfo::getToolHarvestLevel()
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getBlockToolHarvestLevel() : int{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getMiningEfficiency(bool $isCorrectTool) : float{
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a player uses this item on a block.
|
||||
*
|
||||
* @param Player $player
|
||||
* @param Block $blockReplace
|
||||
* @param Block $blockClicked
|
||||
* @param int $face
|
||||
* @param Vector3 $clickVector
|
||||
*
|
||||
* @return ItemUseResult
|
||||
*/
|
||||
public function onActivate(Player $player, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector) : ItemUseResult{
|
||||
return ItemUseResult::NONE();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a player uses the item on air, for example throwing a projectile.
|
||||
* Returns whether the item was changed, for example count decrease or durability change.
|
||||
*
|
||||
* @param Player $player
|
||||
* @param Vector3 $directionVector
|
||||
*
|
||||
* @return ItemUseResult
|
||||
*/
|
||||
public function onClickAir(Player $player, Vector3 $directionVector) : ItemUseResult{
|
||||
return ItemUseResult::NONE();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a player is using this item and releases it. Used to handle bow shoot actions.
|
||||
* Returns whether the item was changed, for example count decrease or durability change.
|
||||
*
|
||||
* @param Player $player
|
||||
*
|
||||
* @return ItemUseResult
|
||||
*/
|
||||
public function onReleaseUsing(Player $player) : ItemUseResult{
|
||||
return ItemUseResult::NONE();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when this item is used to destroy a block. Usually used to update durability.
|
||||
*
|
||||
* @param Block $block
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function onDestroyBlock(Block $block) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when this item is used to attack an entity. Usually used to update durability.
|
||||
*
|
||||
* @param Entity $victim
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function onAttackEntity(Entity $victim) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of ticks a player must wait before activating this item again.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getCooldownTicks() : int{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares an Item to this Item and check if they match.
|
||||
*
|
||||
* @param Item $item
|
||||
* @param bool $checkDamage Whether to verify that the damage values match.
|
||||
* @param bool $checkCompound Whether to verify that the items' NBT match.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
final public function equals(Item $item, bool $checkDamage = true, bool $checkCompound = true) : bool{
|
||||
return $this->id === $item->getId() and
|
||||
(!$checkDamage or $this->getMeta() === $item->getMeta()) and
|
||||
(!$checkCompound or $this->getNamedTag()->equals($item->getNamedTag()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the specified item stack has the same ID, damage, NBT and count as this item stack.
|
||||
*
|
||||
* @param Item $other
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
final public function equalsExact(Item $other) : bool{
|
||||
return $this->equals($other, true, true) and $this->count === $other->count;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
final public function __toString() : string{
|
||||
return "Item " . $this->name . " (" . $this->id . ":" . ($this->hasAnyDamageValue() ? "?" : $this->getMeta()) . ")x" . $this->count . ($this->hasNamedTag() ? " tags:0x" . base64_encode((new LittleEndianNbtSerializer())->write(new TreeRoot($this->getNamedTag()))) : "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of item stack properties that can be serialized to json.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
final public function jsonSerialize() : array{
|
||||
$data = [
|
||||
"id" => $this->getId()
|
||||
];
|
||||
|
||||
if($this->getMeta() !== 0){
|
||||
$data["damage"] = $this->getMeta();
|
||||
}
|
||||
|
||||
if($this->getCount() !== 1){
|
||||
$data["count"] = $this->getCount();
|
||||
}
|
||||
|
||||
if($this->hasNamedTag()){
|
||||
$data["nbt_b64"] = base64_encode((new LittleEndianNbtSerializer())->write(new TreeRoot($this->getNamedTag())));
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an Item from properties created in an array by {@link Item#jsonSerialize}
|
||||
*
|
||||
* @param array $data
|
||||
*
|
||||
* @return Item
|
||||
* @throws NbtDataException
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
final public static function jsonDeserialize(array $data) : Item{
|
||||
$nbt = "";
|
||||
|
||||
//Backwards compatibility
|
||||
if(isset($data["nbt"])){
|
||||
$nbt = $data["nbt"];
|
||||
}elseif(isset($data["nbt_hex"])){
|
||||
$nbt = hex2bin($data["nbt_hex"]);
|
||||
}elseif(isset($data["nbt_b64"])){
|
||||
$nbt = base64_decode($data["nbt_b64"], true);
|
||||
}
|
||||
return ItemFactory::get(
|
||||
(int) $data["id"], (int) ($data["damage"] ?? 0), (int) ($data["count"] ?? 1), $nbt !== "" ? (new LittleEndianNbtSerializer())->read($nbt)->getTag() : null
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Serializes the item to an NBT CompoundTag
|
||||
*
|
||||
* @param int $slot optional, the inventory slot of the item
|
||||
*
|
||||
* @return CompoundTag
|
||||
*/
|
||||
public function nbtSerialize(int $slot = -1) : CompoundTag{
|
||||
$result = CompoundTag::create()
|
||||
->setShort("id", $this->id)
|
||||
->setByte("Count", Binary::signByte($this->count))
|
||||
->setShort("Damage", $this->getMeta());
|
||||
|
||||
if($this->hasNamedTag()){
|
||||
$result->setTag("tag", $this->getNamedTag());
|
||||
}
|
||||
|
||||
if($slot !== -1){
|
||||
$result->setByte("Slot", $slot);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deserializes an Item from an NBT CompoundTag
|
||||
*
|
||||
* @param CompoundTag $tag
|
||||
*
|
||||
* @return Item
|
||||
*/
|
||||
public static function nbtDeserialize(CompoundTag $tag) : Item{
|
||||
if(!$tag->hasTag("id") or !$tag->hasTag("Count")){
|
||||
return ItemFactory::get(0);
|
||||
}
|
||||
|
||||
$count = Binary::unsignByte($tag->getByte("Count"));
|
||||
$meta = $tag->getShort("Damage", 0);
|
||||
|
||||
$idTag = $tag->getTag("id");
|
||||
if($idTag instanceof ShortTag){
|
||||
$item = ItemFactory::get($idTag->getValue(), $meta, $count);
|
||||
}elseif($idTag instanceof StringTag){ //PC item save format
|
||||
try{
|
||||
$item = ItemFactory::fromString($idTag->getValue() . ":$meta");
|
||||
}catch(\InvalidArgumentException $e){
|
||||
//TODO: improve error handling
|
||||
return ItemFactory::air();
|
||||
}
|
||||
$item->setCount($count);
|
||||
}else{
|
||||
throw new \InvalidArgumentException("Item CompoundTag ID must be an instance of StringTag or ShortTag, " . get_class($idTag) . " given");
|
||||
}
|
||||
|
||||
$itemNBT = $tag->getCompoundTag("tag");
|
||||
if($itemNBT !== null){
|
||||
$item->setNamedTag(clone $itemNBT);
|
||||
}
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
public function __clone(){
|
||||
if($this->nbt !== null){
|
||||
$this->nbt = clone $this->nbt;
|
||||
}
|
||||
if($this->blockEntityTag !== null){
|
||||
$this->blockEntityTag = clone $this->blockEntityTag;
|
||||
}
|
||||
$this->canPlaceOn = $this->canPlaceOn->copy();
|
||||
$this->canDestroy = $this->canDestroy->copy();
|
||||
}
|
||||
}
|
61
src/item/ItemBlock.php
Normal file
61
src/item/ItemBlock.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
use pocketmine\block\Block;
|
||||
use pocketmine\block\BlockFactory;
|
||||
|
||||
/**
|
||||
* Class used for Items that can be Blocks
|
||||
*/
|
||||
class ItemBlock extends Item{
|
||||
/** @var int */
|
||||
protected $blockId;
|
||||
|
||||
/**
|
||||
* @param int $blockId
|
||||
* @param int $meta usually 0-15 (placed blocks may only have meta values 0-15)
|
||||
* @param int|null $itemId
|
||||
*/
|
||||
public function __construct(int $blockId, int $meta = 0, ?int $itemId = null){
|
||||
if($blockId < 0){ //extended blocks
|
||||
if($itemId === null){
|
||||
$itemId = $blockId;
|
||||
}
|
||||
$blockId = 255 - $blockId;
|
||||
}
|
||||
$this->blockId = $blockId;
|
||||
$this->meta = $meta;
|
||||
|
||||
parent::__construct($itemId ?? $blockId, $meta, $this->getBlock()->getName());
|
||||
}
|
||||
|
||||
public function getBlock() : Block{
|
||||
return BlockFactory::get($this->blockId, $this->meta === -1 ? 0 : $this->meta & 0xf);
|
||||
}
|
||||
|
||||
public function getFuelTime() : int{
|
||||
return $this->getBlock()->getFuelTime();
|
||||
}
|
||||
}
|
116
src/item/ItemEnchantmentHandlingTrait.php
Normal file
116
src/item/ItemEnchantmentHandlingTrait.php
Normal file
@@ -0,0 +1,116 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
|
||||
use pocketmine\item\enchantment\Enchantment;
|
||||
use pocketmine\item\enchantment\EnchantmentInstance;
|
||||
|
||||
/**
|
||||
* This trait encapsulates all enchantment handling needed for itemstacks.
|
||||
* The primary purpose of this trait is providing scope isolation for the methods it contains.
|
||||
*/
|
||||
trait ItemEnchantmentHandlingTrait{
|
||||
/** @var EnchantmentInstance[] */
|
||||
protected $enchantments = [];
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function hasEnchantments() : bool{
|
||||
return !empty($this->enchantments);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Enchantment $enchantment
|
||||
* @param int $level
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasEnchantment(Enchantment $enchantment, int $level = -1) : bool{
|
||||
$id = $enchantment->getId();
|
||||
return isset($this->enchantments[$id]) and ($level === -1 or $this->enchantments[$id]->getLevel() === $level);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Enchantment $enchantment
|
||||
*
|
||||
* @return EnchantmentInstance|null
|
||||
*/
|
||||
public function getEnchantment(Enchantment $enchantment) : ?EnchantmentInstance{
|
||||
return $this->enchantments[$enchantment->getId()] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Enchantment $enchantment
|
||||
* @param int $level
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function removeEnchantment(Enchantment $enchantment, int $level = -1) : self{
|
||||
$instance = $this->getEnchantment($enchantment);
|
||||
if($instance !== null and ($level === -1 or $instance->getLevel() === $level)){
|
||||
unset($this->enchantments[$enchantment->getId()]);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function removeEnchantments() : self{
|
||||
$this->enchantments = [];
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param EnchantmentInstance $enchantment
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function addEnchantment(EnchantmentInstance $enchantment) : self{
|
||||
$this->enchantments[$enchantment->getId()] = $enchantment;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return EnchantmentInstance[]
|
||||
*/
|
||||
public function getEnchantments() : array{
|
||||
return $this->enchantments;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the level of the enchantment on this item with the specified ID, or 0 if the item does not have the
|
||||
* enchantment.
|
||||
*
|
||||
* @param Enchantment $enchantment
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getEnchantmentLevel(Enchantment $enchantment) : int{
|
||||
return ($instance = $this->getEnchantment($enchantment)) !== null ? $instance->getLevel() : 0;
|
||||
}
|
||||
}
|
496
src/item/ItemFactory.php
Normal file
496
src/item/ItemFactory.php
Normal file
@@ -0,0 +1,496 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
use pocketmine\block\BlockFactory;
|
||||
use pocketmine\block\BlockLegacyIds;
|
||||
use pocketmine\block\utils\DyeColor;
|
||||
use pocketmine\block\utils\SkullType;
|
||||
use pocketmine\block\utils\TreeType;
|
||||
use pocketmine\block\VanillaBlocks;
|
||||
use pocketmine\entity\EntityFactory;
|
||||
use pocketmine\entity\Living;
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
use function constant;
|
||||
use function defined;
|
||||
use function explode;
|
||||
use function is_a;
|
||||
use function is_numeric;
|
||||
use function str_replace;
|
||||
use function strtoupper;
|
||||
use function trim;
|
||||
|
||||
/**
|
||||
* Manages Item instance creation and registration
|
||||
*/
|
||||
class ItemFactory{
|
||||
|
||||
/** @var Item[] */
|
||||
private static $list = [];
|
||||
|
||||
/** @var Item|null */
|
||||
private static $air = null;
|
||||
|
||||
public static function init() : void{
|
||||
self::$list = []; //in case of re-initializing
|
||||
|
||||
self::register(new Apple(ItemIds::APPLE, 0, "Apple"));
|
||||
self::register(new Arrow(ItemIds::ARROW, 0, "Arrow"));
|
||||
self::register(new Axe(ItemIds::DIAMOND_AXE, "Diamond Axe", ToolTier::DIAMOND()));
|
||||
self::register(new Axe(ItemIds::GOLDEN_AXE, "Golden Axe", ToolTier::GOLD()));
|
||||
self::register(new Axe(ItemIds::IRON_AXE, "Iron Axe", ToolTier::IRON()));
|
||||
self::register(new Axe(ItemIds::STONE_AXE, "Stone Axe", ToolTier::STONE()));
|
||||
self::register(new Axe(ItemIds::WOODEN_AXE, "Wooden Axe", ToolTier::WOOD()));
|
||||
self::register(new BakedPotato(ItemIds::BAKED_POTATO, 0, "Baked Potato"));
|
||||
self::register(new Beetroot(ItemIds::BEETROOT, 0, "Beetroot"));
|
||||
self::register(new BeetrootSeeds(ItemIds::BEETROOT_SEEDS, 0, "Beetroot Seeds"));
|
||||
self::register(new BeetrootSoup(ItemIds::BEETROOT_SOUP, 0, "Beetroot Soup"));
|
||||
self::register(new BlazeRod(ItemIds::BLAZE_ROD, 0, "Blaze Rod"));
|
||||
self::register(new Book(ItemIds::BOOK, 0, "Book"));
|
||||
self::register(new Boots(ItemIds::CHAIN_BOOTS, 0, "Chainmail Boots", new ArmorTypeInfo(1, 196)));
|
||||
self::register(new Boots(ItemIds::DIAMOND_BOOTS, 0, "Diamond Boots", new ArmorTypeInfo(3, 430)));
|
||||
self::register(new Boots(ItemIds::GOLDEN_BOOTS, 0, "Golden Boots", new ArmorTypeInfo(1, 92)));
|
||||
self::register(new Boots(ItemIds::IRON_BOOTS, 0, "Iron Boots", new ArmorTypeInfo(2, 196)));
|
||||
self::register(new Boots(ItemIds::LEATHER_BOOTS, 0, "Leather Boots", new ArmorTypeInfo(1, 66)));
|
||||
self::register(new Bow(ItemIds::BOW, 0, "Bow"));
|
||||
self::register(new Bowl(ItemIds::BOWL, 0, "Bowl"));
|
||||
self::register(new Bread(ItemIds::BREAD, 0, "Bread"));
|
||||
self::register(new Bucket(ItemIds::BUCKET, 0, "Bucket"));
|
||||
self::register(new Carrot(ItemIds::CARROT, 0, "Carrot"));
|
||||
self::register(new Chestplate(ItemIds::CHAIN_CHESTPLATE, 0, "Chainmail Chestplate", new ArmorTypeInfo(5, 241)));
|
||||
self::register(new Chestplate(ItemIds::DIAMOND_CHESTPLATE, 0, "Diamond Chestplate", new ArmorTypeInfo(8, 529)));
|
||||
self::register(new Chestplate(ItemIds::GOLDEN_CHESTPLATE, 0, "Golden Chestplate", new ArmorTypeInfo(5, 113)));
|
||||
self::register(new Chestplate(ItemIds::IRON_CHESTPLATE, 0, "Iron Chestplate", new ArmorTypeInfo(6, 241)));
|
||||
self::register(new Chestplate(ItemIds::LEATHER_CHESTPLATE, 0, "Leather Tunic", new ArmorTypeInfo(3, 81)));
|
||||
self::register(new ChorusFruit(ItemIds::CHORUS_FRUIT, 0, "Chorus Fruit"));
|
||||
self::register(new Clock(ItemIds::CLOCK, 0, "Clock"));
|
||||
self::register(new Clownfish(ItemIds::CLOWNFISH, 0, "Clownfish"));
|
||||
self::register(new Coal(ItemIds::COAL, 0, "Coal"));
|
||||
self::register(new Coal(ItemIds::COAL, 1, "Charcoal"));
|
||||
self::register(new CocoaBeans(ItemIds::DYE, 3, "Cocoa Beans"));
|
||||
self::register(new Compass(ItemIds::COMPASS, 0, "Compass"));
|
||||
self::register(new CookedChicken(ItemIds::COOKED_CHICKEN, 0, "Cooked Chicken"));
|
||||
self::register(new CookedFish(ItemIds::COOKED_FISH, 0, "Cooked Fish"));
|
||||
self::register(new CookedMutton(ItemIds::COOKED_MUTTON, 0, "Cooked Mutton"));
|
||||
self::register(new CookedPorkchop(ItemIds::COOKED_PORKCHOP, 0, "Cooked Porkchop"));
|
||||
self::register(new CookedRabbit(ItemIds::COOKED_RABBIT, 0, "Cooked Rabbit"));
|
||||
self::register(new CookedSalmon(ItemIds::COOKED_SALMON, 0, "Cooked Salmon"));
|
||||
self::register(new Cookie(ItemIds::COOKIE, 0, "Cookie"));
|
||||
self::register(new DriedKelp(ItemIds::DRIED_KELP, 0, "Dried Kelp"));
|
||||
self::register(new Egg(ItemIds::EGG, 0, "Egg"));
|
||||
self::register(new EnderPearl(ItemIds::ENDER_PEARL, 0, "Ender Pearl"));
|
||||
self::register(new ExperienceBottle(ItemIds::EXPERIENCE_BOTTLE, 0, "Bottle o' Enchanting"));
|
||||
self::register(new Fertilizer(ItemIds::DYE, 15, "Bone Meal"));
|
||||
self::register(new FishingRod(ItemIds::FISHING_ROD, 0, "Fishing Rod"));
|
||||
self::register(new FlintSteel(ItemIds::FLINT_STEEL, 0, "Flint and Steel"));
|
||||
self::register(new GlassBottle(ItemIds::GLASS_BOTTLE, 0, "Glass Bottle"));
|
||||
self::register(new GoldenApple(ItemIds::GOLDEN_APPLE, 0, "Golden Apple"));
|
||||
self::register(new GoldenAppleEnchanted(ItemIds::ENCHANTED_GOLDEN_APPLE, 0, "Enchanted Golden Apple"));
|
||||
self::register(new GoldenCarrot(ItemIds::GOLDEN_CARROT, 0, "Golden Carrot"));
|
||||
self::register(new Helmet(ItemIds::CHAIN_HELMET, 0, "Chainmail Helmet", new ArmorTypeInfo(2, 166)));
|
||||
self::register(new Helmet(ItemIds::DIAMOND_HELMET, 0, "Diamond Helmet", new ArmorTypeInfo(3, 364)));
|
||||
self::register(new Helmet(ItemIds::GOLDEN_HELMET, 0, "Golden Helmet", new ArmorTypeInfo(2, 78)));
|
||||
self::register(new Helmet(ItemIds::IRON_HELMET, 0, "Iron Helmet", new ArmorTypeInfo(2, 166)));
|
||||
self::register(new Helmet(ItemIds::LEATHER_HELMET, 0, "Leather Cap", new ArmorTypeInfo(1, 56)));
|
||||
self::register(new Hoe(ItemIds::DIAMOND_HOE, "Diamond Hoe", ToolTier::DIAMOND()));
|
||||
self::register(new Hoe(ItemIds::GOLDEN_HOE, "Golden Hoe", ToolTier::GOLD()));
|
||||
self::register(new Hoe(ItemIds::IRON_HOE, "Iron Hoe", ToolTier::IRON()));
|
||||
self::register(new Hoe(ItemIds::STONE_HOE, "Stone Hoe", ToolTier::STONE()));
|
||||
self::register(new Hoe(ItemIds::WOODEN_HOE, "Wooden Hoe", ToolTier::WOOD()));
|
||||
self::register(new Item(ItemIds::BLAZE_POWDER, 0, "Blaze Powder"));
|
||||
self::register(new Item(ItemIds::BLEACH, 0, "Bleach")); //EDU
|
||||
self::register(new Item(ItemIds::BONE, 0, "Bone"));
|
||||
self::register(new Item(ItemIds::BRICK, 0, "Brick"));
|
||||
self::register(new Item(ItemIds::CHORUS_FRUIT_POPPED, 0, "Popped Chorus Fruit"));
|
||||
self::register(new Item(ItemIds::CLAY_BALL, 0, "Clay"));
|
||||
self::register(new Item(ItemIds::COMPOUND, 0, "Salt"));
|
||||
self::register(new Item(ItemIds::COMPOUND, 1, "Sodium Oxide"));
|
||||
self::register(new Item(ItemIds::COMPOUND, 2, "Sodium Hydroxide"));
|
||||
self::register(new Item(ItemIds::COMPOUND, 3, "Magnesium Nitrate"));
|
||||
self::register(new Item(ItemIds::COMPOUND, 4, "Iron Sulphide"));
|
||||
self::register(new Item(ItemIds::COMPOUND, 5, "Lithium Hydride"));
|
||||
self::register(new Item(ItemIds::COMPOUND, 6, "Sodium Hydride"));
|
||||
self::register(new Item(ItemIds::COMPOUND, 7, "Calcium Bromide"));
|
||||
self::register(new Item(ItemIds::COMPOUND, 8, "Magnesium Oxide"));
|
||||
self::register(new Item(ItemIds::COMPOUND, 9, "Sodium Acetate"));
|
||||
self::register(new Item(ItemIds::COMPOUND, 10, "Luminol"));
|
||||
self::register(new Item(ItemIds::COMPOUND, 11, "Charcoal")); //??? maybe bug
|
||||
self::register(new Item(ItemIds::COMPOUND, 12, "Sugar")); //??? maybe bug
|
||||
self::register(new Item(ItemIds::COMPOUND, 13, "Aluminium Oxide"));
|
||||
self::register(new Item(ItemIds::COMPOUND, 14, "Boron Trioxide"));
|
||||
self::register(new Item(ItemIds::COMPOUND, 15, "Soap"));
|
||||
self::register(new Item(ItemIds::COMPOUND, 16, "Polyethylene"));
|
||||
self::register(new Item(ItemIds::COMPOUND, 17, "Rubbish"));
|
||||
self::register(new Item(ItemIds::COMPOUND, 18, "Magnesium Salts"));
|
||||
self::register(new Item(ItemIds::COMPOUND, 19, "Sulphate"));
|
||||
self::register(new Item(ItemIds::COMPOUND, 20, "Barium Sulphate"));
|
||||
self::register(new Item(ItemIds::COMPOUND, 21, "Potassium Chloride"));
|
||||
self::register(new Item(ItemIds::COMPOUND, 22, "Mercuric Chloride"));
|
||||
self::register(new Item(ItemIds::COMPOUND, 23, "Cerium Chloride"));
|
||||
self::register(new Item(ItemIds::COMPOUND, 24, "Tungsten Chloride"));
|
||||
self::register(new Item(ItemIds::COMPOUND, 25, "Calcium Chloride"));
|
||||
self::register(new Item(ItemIds::COMPOUND, 26, "Water")); //???
|
||||
self::register(new Item(ItemIds::COMPOUND, 27, "Glue"));
|
||||
self::register(new Item(ItemIds::COMPOUND, 28, "Hypochlorite"));
|
||||
self::register(new Item(ItemIds::COMPOUND, 29, "Crude Oil"));
|
||||
self::register(new Item(ItemIds::COMPOUND, 30, "Latex"));
|
||||
self::register(new Item(ItemIds::COMPOUND, 31, "Potassium Iodide"));
|
||||
self::register(new Item(ItemIds::COMPOUND, 32, "Sodium Fluoride"));
|
||||
self::register(new Item(ItemIds::COMPOUND, 33, "Benzene"));
|
||||
self::register(new Item(ItemIds::COMPOUND, 34, "Ink"));
|
||||
self::register(new Item(ItemIds::COMPOUND, 35, "Hydrogen Peroxide"));
|
||||
self::register(new Item(ItemIds::COMPOUND, 36, "Ammonia"));
|
||||
self::register(new Item(ItemIds::COMPOUND, 37, "Sodium Hypochlorite"));
|
||||
self::register(new Item(ItemIds::DIAMOND, 0, "Diamond"));
|
||||
self::register(new Item(ItemIds::DRAGON_BREATH, 0, "Dragon's Breath"));
|
||||
self::register(new Item(ItemIds::DYE, 0, "Ink Sac"));
|
||||
self::register(new Item(ItemIds::DYE, 4, "Lapis Lazuli"));
|
||||
self::register(new Item(ItemIds::EMERALD, 0, "Emerald"));
|
||||
self::register(new Item(ItemIds::FEATHER, 0, "Feather"));
|
||||
self::register(new Item(ItemIds::FERMENTED_SPIDER_EYE, 0, "Fermented Spider Eye"));
|
||||
self::register(new Item(ItemIds::FLINT, 0, "Flint"));
|
||||
self::register(new Item(ItemIds::GHAST_TEAR, 0, "Ghast Tear"));
|
||||
self::register(new Item(ItemIds::GLISTERING_MELON, 0, "Glistering Melon"));
|
||||
self::register(new Item(ItemIds::GLOWSTONE_DUST, 0, "Glowstone Dust"));
|
||||
self::register(new Item(ItemIds::GOLD_INGOT, 0, "Gold Ingot"));
|
||||
self::register(new Item(ItemIds::GOLD_NUGGET, 0, "Gold Nugget"));
|
||||
self::register(new Item(ItemIds::GUNPOWDER, 0, "Gunpowder"));
|
||||
self::register(new Item(ItemIds::HEART_OF_THE_SEA, 0, "Heart of the Sea"));
|
||||
self::register(new Item(ItemIds::IRON_INGOT, 0, "Iron Ingot"));
|
||||
self::register(new Item(ItemIds::IRON_NUGGET, 0, "Iron Nugget"));
|
||||
self::register(new Item(ItemIds::LEATHER, 0, "Leather"));
|
||||
self::register(new Item(ItemIds::MAGMA_CREAM, 0, "Magma Cream"));
|
||||
self::register(new Item(ItemIds::NAUTILUS_SHELL, 0, "Nautilus Shell"));
|
||||
self::register(new Item(ItemIds::NETHER_BRICK, 0, "Nether Brick"));
|
||||
self::register(new Item(ItemIds::NETHER_QUARTZ, 0, "Nether Quartz"));
|
||||
self::register(new Item(ItemIds::NETHER_STAR, 0, "Nether Star"));
|
||||
self::register(new Item(ItemIds::PAPER, 0, "Paper"));
|
||||
self::register(new Item(ItemIds::PRISMARINE_CRYSTALS, 0, "Prismarine Crystals"));
|
||||
self::register(new Item(ItemIds::PRISMARINE_SHARD, 0, "Prismarine Shard"));
|
||||
self::register(new Item(ItemIds::RABBIT_FOOT, 0, "Rabbit's Foot"));
|
||||
self::register(new Item(ItemIds::RABBIT_HIDE, 0, "Rabbit Hide"));
|
||||
self::register(new Item(ItemIds::SHULKER_SHELL, 0, "Shulker Shell"));
|
||||
self::register(new Item(ItemIds::SLIME_BALL, 0, "Slimeball"));
|
||||
self::register(new Item(ItemIds::SUGAR, 0, "Sugar"));
|
||||
self::register(new Item(ItemIds::TURTLE_SHELL_PIECE, 0, "Scute"));
|
||||
self::register(new Item(ItemIds::WHEAT, 0, "Wheat"));
|
||||
self::register(new ItemBlock(BlockLegacyIds::ACACIA_DOOR_BLOCK, 0, ItemIds::ACACIA_DOOR));
|
||||
self::register(new ItemBlock(BlockLegacyIds::BIRCH_DOOR_BLOCK, 0, ItemIds::BIRCH_DOOR));
|
||||
self::register(new ItemBlock(BlockLegacyIds::BREWING_STAND_BLOCK, 0, ItemIds::BREWING_STAND));
|
||||
self::register(new ItemBlock(BlockLegacyIds::CAKE_BLOCK, 0, ItemIds::CAKE));
|
||||
self::register(new ItemBlock(BlockLegacyIds::CAULDRON_BLOCK, 0, ItemIds::CAULDRON));
|
||||
self::register(new ItemBlock(BlockLegacyIds::COMPARATOR_BLOCK, 0, ItemIds::COMPARATOR));
|
||||
self::register(new ItemBlock(BlockLegacyIds::DARK_OAK_DOOR_BLOCK, 0, ItemIds::DARK_OAK_DOOR));
|
||||
self::register(new ItemBlock(BlockLegacyIds::FLOWER_POT_BLOCK, 0, ItemIds::FLOWER_POT));
|
||||
self::register(new ItemBlock(BlockLegacyIds::HOPPER_BLOCK, 0, ItemIds::HOPPER));
|
||||
self::register(new ItemBlock(BlockLegacyIds::IRON_DOOR_BLOCK, 0, ItemIds::IRON_DOOR));
|
||||
self::register(new ItemBlock(BlockLegacyIds::ITEM_FRAME_BLOCK, 0, ItemIds::ITEM_FRAME));
|
||||
self::register(new ItemBlock(BlockLegacyIds::JUNGLE_DOOR_BLOCK, 0, ItemIds::JUNGLE_DOOR));
|
||||
self::register(new ItemBlock(BlockLegacyIds::NETHER_WART_PLANT, 0, ItemIds::NETHER_WART));
|
||||
self::register(new ItemBlock(BlockLegacyIds::OAK_DOOR_BLOCK, 0, ItemIds::OAK_DOOR));
|
||||
self::register(new ItemBlock(BlockLegacyIds::REPEATER_BLOCK, 0, ItemIds::REPEATER));
|
||||
self::register(new ItemBlock(BlockLegacyIds::SPRUCE_DOOR_BLOCK, 0, ItemIds::SPRUCE_DOOR));
|
||||
self::register(new ItemBlock(BlockLegacyIds::SUGARCANE_BLOCK, 0, ItemIds::SUGARCANE));
|
||||
self::register(new Leggings(ItemIds::CHAIN_LEGGINGS, 0, "Chainmail Leggings", new ArmorTypeInfo(4, 226)));
|
||||
self::register(new Leggings(ItemIds::DIAMOND_LEGGINGS, 0, "Diamond Leggings", new ArmorTypeInfo(6, 496)));
|
||||
self::register(new Leggings(ItemIds::GOLDEN_LEGGINGS, 0, "Golden Leggings", new ArmorTypeInfo(3, 106)));
|
||||
self::register(new Leggings(ItemIds::IRON_LEGGINGS, 0, "Iron Leggings", new ArmorTypeInfo(5, 226)));
|
||||
self::register(new Leggings(ItemIds::LEATHER_LEGGINGS, 0, "Leather Pants", new ArmorTypeInfo(2, 76)));
|
||||
//TODO: fix metadata for buckets with still liquid in them
|
||||
//the meta values are intentionally hardcoded because block IDs will change in the future
|
||||
self::register(new LiquidBucket(ItemIds::BUCKET, 8, "Water Bucket", VanillaBlocks::WATER()));
|
||||
self::register(new LiquidBucket(ItemIds::BUCKET, 10, "Lava Bucket", VanillaBlocks::LAVA()));
|
||||
self::register(new Melon(ItemIds::MELON, 0, "Melon"));
|
||||
self::register(new MelonSeeds(ItemIds::MELON_SEEDS, 0, "Melon Seeds"));
|
||||
self::register(new MilkBucket(ItemIds::BUCKET, 1, "Milk Bucket"));
|
||||
self::register(new Minecart(ItemIds::MINECART, 0, "Minecart"));
|
||||
self::register(new MushroomStew(ItemIds::MUSHROOM_STEW, 0, "Mushroom Stew"));
|
||||
self::register(new PaintingItem(ItemIds::PAINTING, 0, "Painting"));
|
||||
self::register(new Pickaxe(ItemIds::DIAMOND_PICKAXE, "Diamond Pickaxe", ToolTier::DIAMOND()));
|
||||
self::register(new Pickaxe(ItemIds::GOLDEN_PICKAXE, "Golden Pickaxe", ToolTier::GOLD()));
|
||||
self::register(new Pickaxe(ItemIds::IRON_PICKAXE, "Iron Pickaxe", ToolTier::IRON()));
|
||||
self::register(new Pickaxe(ItemIds::STONE_PICKAXE, "Stone Pickaxe", ToolTier::STONE()));
|
||||
self::register(new Pickaxe(ItemIds::WOODEN_PICKAXE, "Wooden Pickaxe", ToolTier::WOOD()));
|
||||
self::register(new PoisonousPotato(ItemIds::POISONOUS_POTATO, 0, "Poisonous Potato"));
|
||||
self::register(new Potato(ItemIds::POTATO, 0, "Potato"));
|
||||
self::register(new Pufferfish(ItemIds::PUFFERFISH, 0, "Pufferfish"));
|
||||
self::register(new PumpkinPie(ItemIds::PUMPKIN_PIE, 0, "Pumpkin Pie"));
|
||||
self::register(new PumpkinSeeds(ItemIds::PUMPKIN_SEEDS, 0, "Pumpkin Seeds"));
|
||||
self::register(new RabbitStew(ItemIds::RABBIT_STEW, 0, "Rabbit Stew"));
|
||||
self::register(new RawBeef(ItemIds::RAW_BEEF, 0, "Raw Beef"));
|
||||
self::register(new RawChicken(ItemIds::RAW_CHICKEN, 0, "Raw Chicken"));
|
||||
self::register(new RawFish(ItemIds::RAW_FISH, 0, "Raw Fish"));
|
||||
self::register(new RawMutton(ItemIds::RAW_MUTTON, 0, "Raw Mutton"));
|
||||
self::register(new RawPorkchop(ItemIds::RAW_PORKCHOP, 0, "Raw Porkchop"));
|
||||
self::register(new RawRabbit(ItemIds::RAW_RABBIT, 0, "Raw Rabbit"));
|
||||
self::register(new RawSalmon(ItemIds::RAW_SALMON, 0, "Raw Salmon"));
|
||||
self::register(new Redstone(ItemIds::REDSTONE, 0, "Redstone"));
|
||||
self::register(new RottenFlesh(ItemIds::ROTTEN_FLESH, 0, "Rotten Flesh"));
|
||||
self::register(new Shears(ItemIds::SHEARS, 0, "Shears"));
|
||||
self::register(new Shovel(ItemIds::DIAMOND_SHOVEL, "Diamond Shovel", ToolTier::DIAMOND()));
|
||||
self::register(new Shovel(ItemIds::GOLDEN_SHOVEL, "Golden Shovel", ToolTier::GOLD()));
|
||||
self::register(new Shovel(ItemIds::IRON_SHOVEL, "Iron Shovel", ToolTier::IRON()));
|
||||
self::register(new Shovel(ItemIds::STONE_SHOVEL, "Stone Shovel", ToolTier::STONE()));
|
||||
self::register(new Shovel(ItemIds::WOODEN_SHOVEL, "Wooden Shovel", ToolTier::WOOD()));
|
||||
self::register(new Sign(BlockLegacyIds::STANDING_SIGN, 0, ItemIds::SIGN));
|
||||
self::register(new Sign(BlockLegacyIds::SPRUCE_STANDING_SIGN, 0, ItemIds::SPRUCE_SIGN));
|
||||
self::register(new Sign(BlockLegacyIds::BIRCH_STANDING_SIGN, 0, ItemIds::BIRCH_SIGN));
|
||||
self::register(new Sign(BlockLegacyIds::JUNGLE_STANDING_SIGN, 0, ItemIds::JUNGLE_SIGN));
|
||||
self::register(new Sign(BlockLegacyIds::ACACIA_STANDING_SIGN, 0, ItemIds::ACACIA_SIGN));
|
||||
self::register(new Sign(BlockLegacyIds::DARKOAK_STANDING_SIGN, 0, ItemIds::DARKOAK_SIGN));
|
||||
self::register(new Snowball(ItemIds::SNOWBALL, 0, "Snowball"));
|
||||
self::register(new SpiderEye(ItemIds::SPIDER_EYE, 0, "Spider Eye"));
|
||||
self::register(new Steak(ItemIds::STEAK, 0, "Steak"));
|
||||
self::register(new Stick(ItemIds::STICK, 0, "Stick"));
|
||||
self::register(new StringItem(ItemIds::STRING, 0, "String"));
|
||||
self::register(new Sword(ItemIds::DIAMOND_SWORD, "Diamond Sword", ToolTier::DIAMOND()));
|
||||
self::register(new Sword(ItemIds::GOLDEN_SWORD, "Golden Sword", ToolTier::GOLD()));
|
||||
self::register(new Sword(ItemIds::IRON_SWORD, "Iron Sword", ToolTier::IRON()));
|
||||
self::register(new Sword(ItemIds::STONE_SWORD, "Stone Sword", ToolTier::STONE()));
|
||||
self::register(new Sword(ItemIds::WOODEN_SWORD, "Wooden Sword", ToolTier::WOOD()));
|
||||
self::register(new Totem(ItemIds::TOTEM, 0, "Totem of Undying"));
|
||||
self::register(new WheatSeeds(ItemIds::WHEAT_SEEDS, 0, "Wheat Seeds"));
|
||||
self::register(new WritableBook(ItemIds::WRITABLE_BOOK, 0, "Book & Quill"));
|
||||
self::register(new WrittenBook(ItemIds::WRITTEN_BOOK, 0, "Written Book"));
|
||||
|
||||
foreach(SkullType::getAll() as $skullType){
|
||||
self::register(new Skull(ItemIds::SKULL, $skullType->getMagicNumber(), $skullType->getDisplayName(), $skullType));
|
||||
}
|
||||
|
||||
/** @var int[]|\SplObjectStorage $dyeMap */
|
||||
$dyeMap = new \SplObjectStorage();
|
||||
$dyeMap[DyeColor::BLACK()] = 16;
|
||||
$dyeMap[DyeColor::BROWN()] = 17;
|
||||
$dyeMap[DyeColor::BLUE()] = 18;
|
||||
$dyeMap[DyeColor::WHITE()] = 19;
|
||||
foreach(DyeColor::getAll() as $color){
|
||||
//TODO: use colour object directly
|
||||
//TODO: add interface to dye-colour objects
|
||||
self::register(new Dye(ItemIds::DYE, $dyeMap[$color] ?? $color->getInvertedMagicNumber(), $color->getDisplayName() . " Dye", $color));
|
||||
self::register(new Bed(ItemIds::BED, $color->getMagicNumber(), $color->getDisplayName() . " Bed", $color));
|
||||
self::register(new Banner(ItemIds::BANNER, $color->getInvertedMagicNumber(), $color->getDisplayName() . " Banner", $color));
|
||||
}
|
||||
|
||||
foreach(Potion::ALL as $type){
|
||||
self::register(new Potion(ItemIds::POTION, $type, "Potion"));
|
||||
self::register(new SplashPotion(ItemIds::SPLASH_POTION, $type, "Splash Potion"));
|
||||
}
|
||||
|
||||
foreach(EntityFactory::getKnownTypes() as $className){
|
||||
/** @var Living|string $className */
|
||||
if(is_a($className, Living::class, true) and $className::NETWORK_ID !== -1){
|
||||
self::register(new SpawnEgg(ItemIds::SPAWN_EGG, $className::NETWORK_ID, "Spawn Egg", $className));
|
||||
}
|
||||
}
|
||||
|
||||
foreach(TreeType::getAll() as $type){
|
||||
self::register(new Boat(ItemIds::BOAT, $type->getMagicNumber(), $type->getDisplayName() . " Boat", $type));
|
||||
}
|
||||
|
||||
//region --- auto-generated TODOs ---
|
||||
//TODO: minecraft:armor_stand
|
||||
//TODO: minecraft:balloon
|
||||
//TODO: minecraft:banner_pattern
|
||||
//TODO: minecraft:campfire
|
||||
//TODO: minecraft:carrotOnAStick
|
||||
//TODO: minecraft:chest_minecart
|
||||
//TODO: minecraft:command_block_minecart
|
||||
//TODO: minecraft:crossbow
|
||||
//TODO: minecraft:elytra
|
||||
//TODO: minecraft:emptyMap
|
||||
//TODO: minecraft:enchanted_book
|
||||
//TODO: minecraft:end_crystal
|
||||
//TODO: minecraft:ender_eye
|
||||
//TODO: minecraft:fireball
|
||||
//TODO: minecraft:fireworks
|
||||
//TODO: minecraft:fireworksCharge
|
||||
//TODO: minecraft:glow_stick
|
||||
//TODO: minecraft:hopper_minecart
|
||||
//TODO: minecraft:horsearmordiamond
|
||||
//TODO: minecraft:horsearmorgold
|
||||
//TODO: minecraft:horsearmoriron
|
||||
//TODO: minecraft:horsearmorleather
|
||||
//TODO: minecraft:ice_bomb
|
||||
//TODO: minecraft:kelp
|
||||
//TODO: minecraft:lead
|
||||
//TODO: minecraft:lingering_potion
|
||||
//TODO: minecraft:map
|
||||
//TODO: minecraft:medicine
|
||||
//TODO: minecraft:name_tag
|
||||
//TODO: minecraft:phantom_membrane
|
||||
//TODO: minecraft:rapid_fertilizer
|
||||
//TODO: minecraft:record_11
|
||||
//TODO: minecraft:record_13
|
||||
//TODO: minecraft:record_blocks
|
||||
//TODO: minecraft:record_cat
|
||||
//TODO: minecraft:record_chirp
|
||||
//TODO: minecraft:record_far
|
||||
//TODO: minecraft:record_mall
|
||||
//TODO: minecraft:record_mellohi
|
||||
//TODO: minecraft:record_stal
|
||||
//TODO: minecraft:record_strad
|
||||
//TODO: minecraft:record_wait
|
||||
//TODO: minecraft:record_ward
|
||||
//TODO: minecraft:saddle
|
||||
//TODO: minecraft:shield
|
||||
//TODO: minecraft:sparkler
|
||||
//TODO: minecraft:spawn_egg
|
||||
//TODO: minecraft:sweet_berries
|
||||
//TODO: minecraft:tnt_minecart
|
||||
//TODO: minecraft:trident
|
||||
//TODO: minecraft:turtle_helmet
|
||||
//endregion
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers an item type into the index. Plugins may use this method to register new item types or override existing
|
||||
* ones.
|
||||
*
|
||||
* NOTE: If you are registering a new item type, you will need to add it to the creative inventory yourself - it
|
||||
* will not automatically appear there.
|
||||
*
|
||||
* @param Item $item
|
||||
* @param bool $override
|
||||
*
|
||||
* @throws \RuntimeException if something attempted to override an already-registered item without specifying the
|
||||
* $override parameter.
|
||||
*/
|
||||
public static function register(Item $item, bool $override = false) : void{
|
||||
$id = $item->getId();
|
||||
$variant = $item->getMeta();
|
||||
|
||||
if(!$override and self::isRegistered($id, $variant)){
|
||||
throw new \RuntimeException("Trying to overwrite an already registered item");
|
||||
}
|
||||
|
||||
self::$list[self::getListOffset($id, $variant)] = clone $item;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an instance of the Item with the specified id, meta, count and NBT.
|
||||
*
|
||||
* @param int $id
|
||||
* @param int $meta
|
||||
* @param int $count
|
||||
* @param CompoundTag|null $tags
|
||||
*
|
||||
* @return Item
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public static function get(int $id, int $meta = 0, int $count = 1, ?CompoundTag $tags = null) : Item{
|
||||
/** @var Item $item */
|
||||
$item = null;
|
||||
if($meta !== -1){
|
||||
if(isset(self::$list[$offset = self::getListOffset($id, $meta)])){
|
||||
$item = clone self::$list[$offset];
|
||||
}elseif(isset(self::$list[$zero = self::getListOffset($id, 0)]) and self::$list[$zero] instanceof Durable){
|
||||
/** @var Durable $item */
|
||||
$item = clone self::$list[$zero];
|
||||
$item->setDamage($meta);
|
||||
}elseif($id < 256){ //intentionally includes negatives, for extended block IDs
|
||||
$item = new ItemBlock($id, $meta);
|
||||
}
|
||||
}
|
||||
|
||||
if($item === null){
|
||||
//negative damage values will fallthru to here, to avoid crazy shit with crafting wildcard hacks
|
||||
$item = new Item($id, $meta);
|
||||
}
|
||||
|
||||
$item->setCount($count);
|
||||
if($tags !== null){
|
||||
$item->setNamedTag($tags);
|
||||
}
|
||||
return $item;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to parse the specified string into Item types.
|
||||
*
|
||||
* Example accepted formats:
|
||||
* - `diamond_pickaxe:5`
|
||||
* - `minecraft:string`
|
||||
* - `351:4 (lapis lazuli ID:meta)`
|
||||
*
|
||||
* @param string $str
|
||||
*
|
||||
* @return Item
|
||||
*
|
||||
* @throws \InvalidArgumentException if the given string cannot be parsed as an item identifier
|
||||
*/
|
||||
public static function fromString(string $str) : Item{
|
||||
$b = explode(":", str_replace([" ", "minecraft:"], ["_", ""], trim($str)));
|
||||
if(!isset($b[1])){
|
||||
$meta = 0;
|
||||
}elseif(is_numeric($b[1])){
|
||||
$meta = (int) $b[1];
|
||||
}else{
|
||||
throw new \InvalidArgumentException("Unable to parse \"" . $b[1] . "\" from \"" . $str . "\" as a valid meta value");
|
||||
}
|
||||
|
||||
if(is_numeric($b[0])){
|
||||
$item = self::get((int) $b[0], $meta);
|
||||
}elseif(defined(ItemIds::class . "::" . strtoupper($b[0]))){
|
||||
$item = self::get(constant(ItemIds::class . "::" . strtoupper($b[0])), $meta);
|
||||
}else{
|
||||
throw new \InvalidArgumentException("Unable to resolve \"" . $str . "\" to a valid item");
|
||||
}
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
public static function air() : Item{
|
||||
return self::$air ?? (self::$air = self::get(ItemIds::AIR, 0, 0));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the specified item ID is already registered in the item factory.
|
||||
*
|
||||
* @param int $id
|
||||
* @param int $variant
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function isRegistered(int $id, int $variant = 0) : bool{
|
||||
if($id < 256){
|
||||
return BlockFactory::isRegistered($id);
|
||||
}
|
||||
|
||||
return isset(self::$list[self::getListOffset($id, $variant)]);
|
||||
}
|
||||
|
||||
private static function getListOffset(int $id, int $variant) : int{
|
||||
if($id < -0x8000 or $id > 0x7fff){
|
||||
throw new \InvalidArgumentException("ID must be in range " . -0x8000 . " - " . 0x7fff);
|
||||
}
|
||||
return (($id & 0xffff) << 16) | ($variant & 0xffff);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Item[]
|
||||
*/
|
||||
public static function getAllRegistered() : array{
|
||||
return self::$list;
|
||||
}
|
||||
}
|
732
src/item/ItemIds.php
Normal file
732
src/item/ItemIds.php
Normal file
@@ -0,0 +1,732 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
interface ItemIds{
|
||||
|
||||
public const LIT_BLAST_FURNACE = -214;
|
||||
public const COMPOSTER = -213;
|
||||
public const WOOD = -212;
|
||||
public const JIGSAW = -211;
|
||||
public const LAVA_CAULDRON = -210;
|
||||
public const CAMPFIRE = -209;
|
||||
public const LANTERN = -208;
|
||||
public const SWEET_BERRY_BUSH = -207;
|
||||
public const BELL = -206;
|
||||
|
||||
public const LOOM = -204;
|
||||
public const BARREL = -203;
|
||||
public const SMITHING_TABLE = -202;
|
||||
public const FLETCHING_TABLE = -201;
|
||||
public const CARTOGRAPHY_TABLE = -200;
|
||||
public const LIT_SMOKER = -199;
|
||||
public const SMOKER = -198;
|
||||
public const STONECUTTER_BLOCK = -197;
|
||||
public const BLAST_FURNACE = -196;
|
||||
public const GRINDSTONE = -195;
|
||||
public const LECTERN = -194;
|
||||
public const DARKOAK_WALL_SIGN = -193;
|
||||
public const DARKOAK_STANDING_SIGN = -192;
|
||||
public const ACACIA_WALL_SIGN = -191;
|
||||
public const ACACIA_STANDING_SIGN = -190;
|
||||
public const JUNGLE_WALL_SIGN = -189;
|
||||
public const JUNGLE_STANDING_SIGN = -188;
|
||||
public const BIRCH_WALL_SIGN = -187;
|
||||
public const BIRCH_STANDING_SIGN = -186;
|
||||
public const SMOOTH_QUARTZ_STAIRS = -185;
|
||||
public const RED_NETHER_BRICK_STAIRS = -184;
|
||||
public const SMOOTH_STONE = -183;
|
||||
public const SPRUCE_WALL_SIGN = -182;
|
||||
public const SPRUCE_STANDING_SIGN = -181;
|
||||
public const NORMAL_STONE_STAIRS = -180;
|
||||
public const MOSSY_COBBLESTONE_STAIRS = -179;
|
||||
public const END_BRICK_STAIRS = -178;
|
||||
public const SMOOTH_SANDSTONE_STAIRS = -177;
|
||||
public const SMOOTH_RED_SANDSTONE_STAIRS = -176;
|
||||
public const MOSSY_STONE_BRICK_STAIRS = -175;
|
||||
public const POLISHED_ANDESITE_STAIRS = -174;
|
||||
public const POLISHED_DIORITE_STAIRS = -173;
|
||||
public const POLISHED_GRANITE_STAIRS = -172;
|
||||
public const ANDESITE_STAIRS = -171;
|
||||
public const DIORITE_STAIRS = -170;
|
||||
public const GRANITE_STAIRS = -169;
|
||||
public const DOUBLE_STONE_SLAB4 = -168;
|
||||
public const DOUBLE_STONE_SLAB3 = -167;
|
||||
public const STONE_SLAB4 = -166;
|
||||
public const SCAFFOLDING = -165;
|
||||
public const BAMBOO_SAPLING = -164;
|
||||
public const BAMBOO = -163;
|
||||
public const STONE_SLAB3 = -162;
|
||||
public const BARRIER = -161;
|
||||
public const BUBBLE_COLUMN = -160;
|
||||
public const TURTLE_EGG = -159;
|
||||
|
||||
public const CONDUIT = -157;
|
||||
public const SEA_PICKLE = -156;
|
||||
public const CARVED_PUMPKIN = -155;
|
||||
public const SPRUCE_PRESSURE_PLATE = -154;
|
||||
public const JUNGLE_PRESSURE_PLATE = -153;
|
||||
public const DARK_OAK_PRESSURE_PLATE = -152;
|
||||
public const BIRCH_PRESSURE_PLATE = -151;
|
||||
public const ACACIA_PRESSURE_PLATE = -150;
|
||||
public const SPRUCE_TRAPDOOR = -149;
|
||||
public const JUNGLE_TRAPDOOR = -148;
|
||||
public const DARK_OAK_TRAPDOOR = -147;
|
||||
public const BIRCH_TRAPDOOR = -146;
|
||||
public const ACACIA_TRAPDOOR = -145;
|
||||
public const SPRUCE_BUTTON = -144;
|
||||
public const JUNGLE_BUTTON = -143;
|
||||
public const DARK_OAK_BUTTON = -142;
|
||||
public const BIRCH_BUTTON = -141;
|
||||
public const ACACIA_BUTTON = -140;
|
||||
public const DRIED_KELP_BLOCK = -139;
|
||||
public const KELP_BLOCK = -138;
|
||||
public const CORAL_FAN_HANG3 = -137;
|
||||
public const CORAL_FAN_HANG2 = -136;
|
||||
public const CORAL_FAN_HANG = -135;
|
||||
public const CORAL_FAN_DEAD = -134;
|
||||
public const CORAL_FAN = -133;
|
||||
public const CORAL_BLOCK = -132;
|
||||
public const CORAL = -131;
|
||||
public const SEAGRASS = -130;
|
||||
public const ELEMENT_118 = -129;
|
||||
public const ELEMENT_117 = -128;
|
||||
public const ELEMENT_116 = -127;
|
||||
public const ELEMENT_115 = -126;
|
||||
public const ELEMENT_114 = -125;
|
||||
public const ELEMENT_113 = -124;
|
||||
public const ELEMENT_112 = -123;
|
||||
public const ELEMENT_111 = -122;
|
||||
public const ELEMENT_110 = -121;
|
||||
public const ELEMENT_109 = -120;
|
||||
public const ELEMENT_108 = -119;
|
||||
public const ELEMENT_107 = -118;
|
||||
public const ELEMENT_106 = -117;
|
||||
public const ELEMENT_105 = -116;
|
||||
public const ELEMENT_104 = -115;
|
||||
public const ELEMENT_103 = -114;
|
||||
public const ELEMENT_102 = -113;
|
||||
public const ELEMENT_101 = -112;
|
||||
public const ELEMENT_100 = -111;
|
||||
public const ELEMENT_99 = -110;
|
||||
public const ELEMENT_98 = -109;
|
||||
public const ELEMENT_97 = -108;
|
||||
public const ELEMENT_96 = -107;
|
||||
public const ELEMENT_95 = -106;
|
||||
public const ELEMENT_94 = -105;
|
||||
public const ELEMENT_93 = -104;
|
||||
public const ELEMENT_92 = -103;
|
||||
public const ELEMENT_91 = -102;
|
||||
public const ELEMENT_90 = -101;
|
||||
public const ELEMENT_89 = -100;
|
||||
public const ELEMENT_88 = -99;
|
||||
public const ELEMENT_87 = -98;
|
||||
public const ELEMENT_86 = -97;
|
||||
public const ELEMENT_85 = -96;
|
||||
public const ELEMENT_84 = -95;
|
||||
public const ELEMENT_83 = -94;
|
||||
public const ELEMENT_82 = -93;
|
||||
public const ELEMENT_81 = -92;
|
||||
public const ELEMENT_80 = -91;
|
||||
public const ELEMENT_79 = -90;
|
||||
public const ELEMENT_78 = -89;
|
||||
public const ELEMENT_77 = -88;
|
||||
public const ELEMENT_76 = -87;
|
||||
public const ELEMENT_75 = -86;
|
||||
public const ELEMENT_74 = -85;
|
||||
public const ELEMENT_73 = -84;
|
||||
public const ELEMENT_72 = -83;
|
||||
public const ELEMENT_71 = -82;
|
||||
public const ELEMENT_70 = -81;
|
||||
public const ELEMENT_69 = -80;
|
||||
public const ELEMENT_68 = -79;
|
||||
public const ELEMENT_67 = -78;
|
||||
public const ELEMENT_66 = -77;
|
||||
public const ELEMENT_65 = -76;
|
||||
public const ELEMENT_64 = -75;
|
||||
public const ELEMENT_63 = -74;
|
||||
public const ELEMENT_62 = -73;
|
||||
public const ELEMENT_61 = -72;
|
||||
public const ELEMENT_60 = -71;
|
||||
public const ELEMENT_59 = -70;
|
||||
public const ELEMENT_58 = -69;
|
||||
public const ELEMENT_57 = -68;
|
||||
public const ELEMENT_56 = -67;
|
||||
public const ELEMENT_55 = -66;
|
||||
public const ELEMENT_54 = -65;
|
||||
public const ELEMENT_53 = -64;
|
||||
public const ELEMENT_52 = -63;
|
||||
public const ELEMENT_51 = -62;
|
||||
public const ELEMENT_50 = -61;
|
||||
public const ELEMENT_49 = -60;
|
||||
public const ELEMENT_48 = -59;
|
||||
public const ELEMENT_47 = -58;
|
||||
public const ELEMENT_46 = -57;
|
||||
public const ELEMENT_45 = -56;
|
||||
public const ELEMENT_44 = -55;
|
||||
public const ELEMENT_43 = -54;
|
||||
public const ELEMENT_42 = -53;
|
||||
public const ELEMENT_41 = -52;
|
||||
public const ELEMENT_40 = -51;
|
||||
public const ELEMENT_39 = -50;
|
||||
public const ELEMENT_38 = -49;
|
||||
public const ELEMENT_37 = -48;
|
||||
public const ELEMENT_36 = -47;
|
||||
public const ELEMENT_35 = -46;
|
||||
public const ELEMENT_34 = -45;
|
||||
public const ELEMENT_33 = -44;
|
||||
public const ELEMENT_32 = -43;
|
||||
public const ELEMENT_31 = -42;
|
||||
public const ELEMENT_30 = -41;
|
||||
public const ELEMENT_29 = -40;
|
||||
public const ELEMENT_28 = -39;
|
||||
public const ELEMENT_27 = -38;
|
||||
public const ELEMENT_26 = -37;
|
||||
public const ELEMENT_25 = -36;
|
||||
public const ELEMENT_24 = -35;
|
||||
public const ELEMENT_23 = -34;
|
||||
public const ELEMENT_22 = -33;
|
||||
public const ELEMENT_21 = -32;
|
||||
public const ELEMENT_20 = -31;
|
||||
public const ELEMENT_19 = -30;
|
||||
public const ELEMENT_18 = -29;
|
||||
public const ELEMENT_17 = -28;
|
||||
public const ELEMENT_16 = -27;
|
||||
public const ELEMENT_15 = -26;
|
||||
public const ELEMENT_14 = -25;
|
||||
public const ELEMENT_13 = -24;
|
||||
public const ELEMENT_12 = -23;
|
||||
public const ELEMENT_11 = -22;
|
||||
public const ELEMENT_10 = -21;
|
||||
public const ELEMENT_9 = -20;
|
||||
public const ELEMENT_8 = -19;
|
||||
public const ELEMENT_7 = -18;
|
||||
public const ELEMENT_6 = -17;
|
||||
public const ELEMENT_5 = -16;
|
||||
public const ELEMENT_4 = -15;
|
||||
public const ELEMENT_3 = -14;
|
||||
public const ELEMENT_2 = -13;
|
||||
public const ELEMENT_1 = -12;
|
||||
public const BLUE_ICE = -11;
|
||||
public const STRIPPED_OAK_LOG = -10;
|
||||
public const STRIPPED_DARK_OAK_LOG = -9;
|
||||
public const STRIPPED_ACACIA_LOG = -8;
|
||||
public const STRIPPED_JUNGLE_LOG = -7;
|
||||
public const STRIPPED_BIRCH_LOG = -6;
|
||||
public const STRIPPED_SPRUCE_LOG = -5;
|
||||
public const PRISMARINE_BRICKS_STAIRS = -4;
|
||||
public const DARK_PRISMARINE_STAIRS = -3;
|
||||
public const PRISMARINE_STAIRS = -2;
|
||||
|
||||
public const AIR = 0;
|
||||
public const STONE = 1;
|
||||
public const GRASS = 2;
|
||||
public const DIRT = 3;
|
||||
public const COBBLESTONE = 4;
|
||||
public const PLANKS = 5, WOODEN_PLANKS = 5;
|
||||
public const SAPLING = 6;
|
||||
public const BEDROCK = 7;
|
||||
public const FLOWING_WATER = 8;
|
||||
public const STILL_WATER = 9, WATER = 9;
|
||||
public const FLOWING_LAVA = 10;
|
||||
public const LAVA = 11, STILL_LAVA = 11;
|
||||
public const SAND = 12;
|
||||
public const GRAVEL = 13;
|
||||
public const GOLD_ORE = 14;
|
||||
public const IRON_ORE = 15;
|
||||
public const COAL_ORE = 16;
|
||||
public const LOG = 17;
|
||||
public const LEAVES = 18;
|
||||
public const SPONGE = 19;
|
||||
public const GLASS = 20;
|
||||
public const LAPIS_ORE = 21;
|
||||
public const LAPIS_BLOCK = 22;
|
||||
public const DISPENSER = 23;
|
||||
public const SANDSTONE = 24;
|
||||
public const NOTEBLOCK = 25, NOTE_BLOCK = 25;
|
||||
public const BED_BLOCK = 26;
|
||||
public const GOLDEN_RAIL = 27, POWERED_RAIL = 27;
|
||||
public const DETECTOR_RAIL = 28;
|
||||
public const STICKY_PISTON = 29;
|
||||
public const COBWEB = 30, WEB = 30;
|
||||
public const TALLGRASS = 31, TALL_GRASS = 31;
|
||||
public const DEADBUSH = 32, DEAD_BUSH = 32;
|
||||
public const PISTON = 33;
|
||||
public const PISTONARMCOLLISION = 34, PISTON_ARM_COLLISION = 34;
|
||||
public const WOOL = 35;
|
||||
public const ELEMENT_0 = 36;
|
||||
public const DANDELION = 37, YELLOW_FLOWER = 37;
|
||||
public const POPPY = 38, RED_FLOWER = 38;
|
||||
public const BROWN_MUSHROOM = 39;
|
||||
public const RED_MUSHROOM = 40;
|
||||
public const GOLD_BLOCK = 41;
|
||||
public const IRON_BLOCK = 42;
|
||||
public const DOUBLE_STONE_SLAB = 43;
|
||||
public const STONE_SLAB = 44;
|
||||
public const BRICK_BLOCK = 45;
|
||||
public const TNT = 46;
|
||||
public const BOOKSHELF = 47;
|
||||
public const MOSSY_COBBLESTONE = 48, MOSS_STONE = 48;
|
||||
public const OBSIDIAN = 49;
|
||||
public const TORCH = 50;
|
||||
public const FIRE = 51;
|
||||
public const MOB_SPAWNER = 52, MONSTER_SPAWNER = 52;
|
||||
public const OAK_STAIRS = 53, WOODEN_STAIRS = 53;
|
||||
public const CHEST = 54;
|
||||
public const REDSTONE_WIRE = 55;
|
||||
public const DIAMOND_ORE = 56;
|
||||
public const DIAMOND_BLOCK = 57;
|
||||
public const CRAFTING_TABLE = 58, WORKBENCH = 58;
|
||||
public const WHEAT_BLOCK = 59;
|
||||
public const FARMLAND = 60;
|
||||
public const FURNACE = 61;
|
||||
public const BURNING_FURNACE = 62, LIT_FURNACE = 62;
|
||||
public const SIGN_POST = 63, STANDING_SIGN = 63;
|
||||
public const OAK_DOOR_BLOCK = 64, WOODEN_DOOR_BLOCK = 64;
|
||||
public const LADDER = 65;
|
||||
public const RAIL = 66;
|
||||
public const COBBLESTONE_STAIRS = 67, STONE_STAIRS = 67;
|
||||
public const WALL_SIGN = 68;
|
||||
public const LEVER = 69;
|
||||
public const STONE_PRESSURE_PLATE = 70;
|
||||
public const IRON_DOOR_BLOCK = 71;
|
||||
public const WOODEN_PRESSURE_PLATE = 72;
|
||||
public const REDSTONE_ORE = 73;
|
||||
public const GLOWING_REDSTONE_ORE = 74, LIT_REDSTONE_ORE = 74;
|
||||
public const UNLIT_REDSTONE_TORCH = 75;
|
||||
public const LIT_REDSTONE_TORCH = 76, REDSTONE_TORCH = 76;
|
||||
public const STONE_BUTTON = 77;
|
||||
public const SNOW_LAYER = 78;
|
||||
public const ICE = 79;
|
||||
public const SNOW = 80, SNOW_BLOCK = 80;
|
||||
public const CACTUS = 81;
|
||||
public const CLAY_BLOCK = 82;
|
||||
public const REEDS_BLOCK = 83, SUGARCANE_BLOCK = 83;
|
||||
public const JUKEBOX = 84;
|
||||
public const FENCE = 85;
|
||||
public const PUMPKIN = 86;
|
||||
public const NETHERRACK = 87;
|
||||
public const SOUL_SAND = 88;
|
||||
public const GLOWSTONE = 89;
|
||||
public const PORTAL = 90;
|
||||
public const JACK_O_LANTERN = 91, LIT_PUMPKIN = 91;
|
||||
public const CAKE_BLOCK = 92;
|
||||
public const REPEATER_BLOCK = 93, UNPOWERED_REPEATER = 93;
|
||||
public const POWERED_REPEATER = 94;
|
||||
public const INVISIBLEBEDROCK = 95, INVISIBLE_BEDROCK = 95;
|
||||
public const TRAPDOOR = 96, WOODEN_TRAPDOOR = 96;
|
||||
public const MONSTER_EGG = 97;
|
||||
public const STONEBRICK = 98, STONE_BRICK = 98, STONE_BRICKS = 98;
|
||||
public const BROWN_MUSHROOM_BLOCK = 99;
|
||||
public const RED_MUSHROOM_BLOCK = 100;
|
||||
public const IRON_BARS = 101;
|
||||
public const GLASS_PANE = 102;
|
||||
public const MELON_BLOCK = 103;
|
||||
public const PUMPKIN_STEM = 104;
|
||||
public const MELON_STEM = 105;
|
||||
public const VINE = 106, VINES = 106;
|
||||
public const FENCE_GATE = 107, OAK_FENCE_GATE = 107;
|
||||
public const BRICK_STAIRS = 108;
|
||||
public const STONE_BRICK_STAIRS = 109;
|
||||
public const MYCELIUM = 110;
|
||||
public const LILY_PAD = 111, WATERLILY = 111, WATER_LILY = 111;
|
||||
public const NETHER_BRICK_BLOCK = 112;
|
||||
public const NETHER_BRICK_FENCE = 113;
|
||||
public const NETHER_BRICK_STAIRS = 114;
|
||||
public const NETHER_WART_PLANT = 115;
|
||||
public const ENCHANTING_TABLE = 116, ENCHANTMENT_TABLE = 116;
|
||||
public const BREWING_STAND_BLOCK = 117;
|
||||
public const CAULDRON_BLOCK = 118;
|
||||
public const END_PORTAL = 119;
|
||||
public const END_PORTAL_FRAME = 120;
|
||||
public const END_STONE = 121;
|
||||
public const DRAGON_EGG = 122;
|
||||
public const REDSTONE_LAMP = 123;
|
||||
public const LIT_REDSTONE_LAMP = 124;
|
||||
public const DROPPER = 125;
|
||||
public const ACTIVATOR_RAIL = 126;
|
||||
public const COCOA = 127, COCOA_BLOCK = 127;
|
||||
public const SANDSTONE_STAIRS = 128;
|
||||
public const EMERALD_ORE = 129;
|
||||
public const ENDER_CHEST = 130;
|
||||
public const TRIPWIRE_HOOK = 131;
|
||||
public const TRIPWIRE = 132, TRIP_WIRE = 132;
|
||||
public const EMERALD_BLOCK = 133;
|
||||
public const SPRUCE_STAIRS = 134;
|
||||
public const BIRCH_STAIRS = 135;
|
||||
public const JUNGLE_STAIRS = 136;
|
||||
public const COMMAND_BLOCK = 137;
|
||||
public const BEACON = 138;
|
||||
public const COBBLESTONE_WALL = 139, STONE_WALL = 139;
|
||||
public const FLOWER_POT_BLOCK = 140;
|
||||
public const CARROTS = 141, CARROT_BLOCK = 141;
|
||||
public const POTATOES = 142, POTATO_BLOCK = 142;
|
||||
public const WOODEN_BUTTON = 143;
|
||||
public const MOB_HEAD_BLOCK = 144, SKULL_BLOCK = 144;
|
||||
public const ANVIL = 145;
|
||||
public const TRAPPED_CHEST = 146;
|
||||
public const LIGHT_WEIGHTED_PRESSURE_PLATE = 147;
|
||||
public const HEAVY_WEIGHTED_PRESSURE_PLATE = 148;
|
||||
public const COMPARATOR_BLOCK = 149, UNPOWERED_COMPARATOR = 149;
|
||||
public const POWERED_COMPARATOR = 150;
|
||||
public const DAYLIGHT_DETECTOR = 151, DAYLIGHT_SENSOR = 151;
|
||||
public const REDSTONE_BLOCK = 152;
|
||||
public const NETHER_QUARTZ_ORE = 153, QUARTZ_ORE = 153;
|
||||
public const HOPPER_BLOCK = 154;
|
||||
public const QUARTZ_BLOCK = 155;
|
||||
public const QUARTZ_STAIRS = 156;
|
||||
public const DOUBLE_WOODEN_SLAB = 157;
|
||||
public const WOODEN_SLAB = 158;
|
||||
public const STAINED_CLAY = 159, STAINED_HARDENED_CLAY = 159, TERRACOTTA = 159;
|
||||
public const STAINED_GLASS_PANE = 160;
|
||||
public const LEAVES2 = 161;
|
||||
public const LOG2 = 162;
|
||||
public const ACACIA_STAIRS = 163;
|
||||
public const DARK_OAK_STAIRS = 164;
|
||||
public const SLIME = 165, SLIME_BLOCK = 165;
|
||||
public const GLOW_STICK = 166;
|
||||
public const IRON_TRAPDOOR = 167;
|
||||
public const PRISMARINE = 168;
|
||||
public const SEALANTERN = 169, SEA_LANTERN = 169;
|
||||
public const HAY_BALE = 170, HAY_BLOCK = 170;
|
||||
public const CARPET = 171;
|
||||
public const HARDENED_CLAY = 172;
|
||||
public const COAL_BLOCK = 173;
|
||||
public const PACKED_ICE = 174;
|
||||
public const DOUBLE_PLANT = 175;
|
||||
public const STANDING_BANNER = 176;
|
||||
public const WALL_BANNER = 177;
|
||||
public const DAYLIGHT_DETECTOR_INVERTED = 178, DAYLIGHT_SENSOR_INVERTED = 178;
|
||||
public const RED_SANDSTONE = 179;
|
||||
public const RED_SANDSTONE_STAIRS = 180;
|
||||
public const DOUBLE_STONE_SLAB2 = 181;
|
||||
public const STONE_SLAB2 = 182;
|
||||
public const SPRUCE_FENCE_GATE = 183;
|
||||
public const BIRCH_FENCE_GATE = 184;
|
||||
public const JUNGLE_FENCE_GATE = 185;
|
||||
public const DARK_OAK_FENCE_GATE = 186;
|
||||
public const ACACIA_FENCE_GATE = 187;
|
||||
public const REPEATING_COMMAND_BLOCK = 188;
|
||||
public const CHAIN_COMMAND_BLOCK = 189;
|
||||
public const HARD_GLASS_PANE = 190;
|
||||
public const HARD_STAINED_GLASS_PANE = 191;
|
||||
public const CHEMICAL_HEAT = 192;
|
||||
public const SPRUCE_DOOR_BLOCK = 193;
|
||||
public const BIRCH_DOOR_BLOCK = 194;
|
||||
public const JUNGLE_DOOR_BLOCK = 195;
|
||||
public const ACACIA_DOOR_BLOCK = 196;
|
||||
public const DARK_OAK_DOOR_BLOCK = 197;
|
||||
public const GRASS_PATH = 198;
|
||||
public const FRAME_BLOCK = 199, ITEM_FRAME_BLOCK = 199;
|
||||
public const CHORUS_FLOWER = 200;
|
||||
public const PURPUR_BLOCK = 201;
|
||||
public const COLORED_TORCH_RG = 202;
|
||||
public const PURPUR_STAIRS = 203;
|
||||
public const COLORED_TORCH_BP = 204;
|
||||
public const UNDYED_SHULKER_BOX = 205;
|
||||
public const END_BRICKS = 206;
|
||||
public const FROSTED_ICE = 207;
|
||||
public const END_ROD = 208;
|
||||
public const END_GATEWAY = 209;
|
||||
|
||||
public const MAGMA = 213;
|
||||
public const NETHER_WART_BLOCK = 214;
|
||||
public const RED_NETHER_BRICK = 215;
|
||||
public const BONE_BLOCK = 216;
|
||||
|
||||
public const SHULKER_BOX = 218;
|
||||
public const PURPLE_GLAZED_TERRACOTTA = 219;
|
||||
public const WHITE_GLAZED_TERRACOTTA = 220;
|
||||
public const ORANGE_GLAZED_TERRACOTTA = 221;
|
||||
public const MAGENTA_GLAZED_TERRACOTTA = 222;
|
||||
public const LIGHT_BLUE_GLAZED_TERRACOTTA = 223;
|
||||
public const YELLOW_GLAZED_TERRACOTTA = 224;
|
||||
public const LIME_GLAZED_TERRACOTTA = 225;
|
||||
public const PINK_GLAZED_TERRACOTTA = 226;
|
||||
public const GRAY_GLAZED_TERRACOTTA = 227;
|
||||
public const SILVER_GLAZED_TERRACOTTA = 228;
|
||||
public const CYAN_GLAZED_TERRACOTTA = 229;
|
||||
|
||||
public const BLUE_GLAZED_TERRACOTTA = 231;
|
||||
public const BROWN_GLAZED_TERRACOTTA = 232;
|
||||
public const GREEN_GLAZED_TERRACOTTA = 233;
|
||||
public const RED_GLAZED_TERRACOTTA = 234;
|
||||
public const BLACK_GLAZED_TERRACOTTA = 235;
|
||||
public const CONCRETE = 236;
|
||||
public const CONCRETEPOWDER = 237, CONCRETE_POWDER = 237;
|
||||
public const CHEMISTRY_TABLE = 238;
|
||||
public const UNDERWATER_TORCH = 239;
|
||||
public const CHORUS_PLANT = 240;
|
||||
public const STAINED_GLASS = 241;
|
||||
|
||||
public const PODZOL = 243;
|
||||
public const BEETROOT_BLOCK = 244;
|
||||
public const STONECUTTER = 245;
|
||||
public const GLOWINGOBSIDIAN = 246, GLOWING_OBSIDIAN = 246;
|
||||
public const NETHERREACTOR = 247, NETHER_REACTOR = 247;
|
||||
public const INFO_UPDATE = 248;
|
||||
public const INFO_UPDATE2 = 249;
|
||||
public const MOVINGBLOCK = 250, MOVING_BLOCK = 250;
|
||||
public const OBSERVER = 251;
|
||||
public const STRUCTURE_BLOCK = 252;
|
||||
public const HARD_GLASS = 253;
|
||||
public const HARD_STAINED_GLASS = 254;
|
||||
public const RESERVED6 = 255;
|
||||
public const IRON_SHOVEL = 256;
|
||||
public const IRON_PICKAXE = 257;
|
||||
public const IRON_AXE = 258;
|
||||
public const FLINT_AND_STEEL = 259, FLINT_STEEL = 259;
|
||||
public const APPLE = 260;
|
||||
public const BOW = 261;
|
||||
public const ARROW = 262;
|
||||
public const COAL = 263;
|
||||
public const DIAMOND = 264;
|
||||
public const IRON_INGOT = 265;
|
||||
public const GOLD_INGOT = 266;
|
||||
public const IRON_SWORD = 267;
|
||||
public const WOODEN_SWORD = 268;
|
||||
public const WOODEN_SHOVEL = 269;
|
||||
public const WOODEN_PICKAXE = 270;
|
||||
public const WOODEN_AXE = 271;
|
||||
public const STONE_SWORD = 272;
|
||||
public const STONE_SHOVEL = 273;
|
||||
public const STONE_PICKAXE = 274;
|
||||
public const STONE_AXE = 275;
|
||||
public const DIAMOND_SWORD = 276;
|
||||
public const DIAMOND_SHOVEL = 277;
|
||||
public const DIAMOND_PICKAXE = 278;
|
||||
public const DIAMOND_AXE = 279;
|
||||
public const STICK = 280;
|
||||
public const BOWL = 281;
|
||||
public const MUSHROOM_STEW = 282;
|
||||
public const GOLDEN_SWORD = 283, GOLD_SWORD = 283;
|
||||
public const GOLDEN_SHOVEL = 284, GOLD_SHOVEL = 284;
|
||||
public const GOLDEN_PICKAXE = 285, GOLD_PICKAXE = 285;
|
||||
public const GOLDEN_AXE = 286, GOLD_AXE = 286;
|
||||
public const STRING = 287;
|
||||
public const FEATHER = 288;
|
||||
public const GUNPOWDER = 289;
|
||||
public const WOODEN_HOE = 290;
|
||||
public const STONE_HOE = 291;
|
||||
public const IRON_HOE = 292;
|
||||
public const DIAMOND_HOE = 293;
|
||||
public const GOLDEN_HOE = 294, GOLD_HOE = 294;
|
||||
public const SEEDS = 295, WHEAT_SEEDS = 295;
|
||||
public const WHEAT = 296;
|
||||
public const BREAD = 297;
|
||||
public const LEATHER_CAP = 298, LEATHER_HELMET = 298;
|
||||
public const LEATHER_CHESTPLATE = 299, LEATHER_TUNIC = 299;
|
||||
public const LEATHER_LEGGINGS = 300, LEATHER_PANTS = 300;
|
||||
public const LEATHER_BOOTS = 301;
|
||||
public const CHAINMAIL_HELMET = 302, CHAIN_HELMET = 302;
|
||||
public const CHAINMAIL_CHESTPLATE = 303, CHAIN_CHESTPLATE = 303;
|
||||
public const CHAINMAIL_LEGGINGS = 304, CHAIN_LEGGINGS = 304;
|
||||
public const CHAINMAIL_BOOTS = 305, CHAIN_BOOTS = 305;
|
||||
public const IRON_HELMET = 306;
|
||||
public const IRON_CHESTPLATE = 307;
|
||||
public const IRON_LEGGINGS = 308;
|
||||
public const IRON_BOOTS = 309;
|
||||
public const DIAMOND_HELMET = 310;
|
||||
public const DIAMOND_CHESTPLATE = 311;
|
||||
public const DIAMOND_LEGGINGS = 312;
|
||||
public const DIAMOND_BOOTS = 313;
|
||||
public const GOLDEN_HELMET = 314, GOLD_HELMET = 314;
|
||||
public const GOLDEN_CHESTPLATE = 315, GOLD_CHESTPLATE = 315;
|
||||
public const GOLDEN_LEGGINGS = 316, GOLD_LEGGINGS = 316;
|
||||
public const GOLDEN_BOOTS = 317, GOLD_BOOTS = 317;
|
||||
public const FLINT = 318;
|
||||
public const PORKCHOP = 319, RAW_PORKCHOP = 319;
|
||||
public const COOKED_PORKCHOP = 320;
|
||||
public const PAINTING = 321;
|
||||
public const GOLDEN_APPLE = 322;
|
||||
public const SIGN = 323;
|
||||
public const OAK_DOOR = 324, WOODEN_DOOR = 324;
|
||||
public const BUCKET = 325;
|
||||
|
||||
public const MINECART = 328;
|
||||
public const SADDLE = 329;
|
||||
public const IRON_DOOR = 330;
|
||||
public const REDSTONE = 331, REDSTONE_DUST = 331;
|
||||
public const SNOWBALL = 332;
|
||||
public const BOAT = 333;
|
||||
public const LEATHER = 334;
|
||||
public const KELP = 335;
|
||||
public const BRICK = 336;
|
||||
public const CLAY = 337, CLAY_BALL = 337;
|
||||
public const REEDS = 338, SUGARCANE = 338;
|
||||
public const PAPER = 339;
|
||||
public const BOOK = 340;
|
||||
public const SLIMEBALL = 341, SLIME_BALL = 341;
|
||||
public const CHEST_MINECART = 342, MINECART_WITH_CHEST = 342;
|
||||
|
||||
public const EGG = 344;
|
||||
public const COMPASS = 345;
|
||||
public const FISHING_ROD = 346;
|
||||
public const CLOCK = 347;
|
||||
public const GLOWSTONE_DUST = 348;
|
||||
public const FISH = 349, RAW_FISH = 349;
|
||||
public const COOKED_FISH = 350;
|
||||
public const DYE = 351;
|
||||
public const BONE = 352;
|
||||
public const SUGAR = 353;
|
||||
public const CAKE = 354;
|
||||
public const BED = 355;
|
||||
public const REPEATER = 356;
|
||||
public const COOKIE = 357;
|
||||
public const FILLED_MAP = 358;
|
||||
public const SHEARS = 359;
|
||||
public const MELON = 360, MELON_SLICE = 360;
|
||||
public const PUMPKIN_SEEDS = 361;
|
||||
public const MELON_SEEDS = 362;
|
||||
public const BEEF = 363, RAW_BEEF = 363;
|
||||
public const COOKED_BEEF = 364, STEAK = 364;
|
||||
public const CHICKEN = 365, RAW_CHICKEN = 365;
|
||||
public const COOKED_CHICKEN = 366;
|
||||
public const ROTTEN_FLESH = 367;
|
||||
public const ENDER_PEARL = 368;
|
||||
public const BLAZE_ROD = 369;
|
||||
public const GHAST_TEAR = 370;
|
||||
public const GOLDEN_NUGGET = 371, GOLD_NUGGET = 371;
|
||||
public const NETHER_WART = 372;
|
||||
public const POTION = 373;
|
||||
public const GLASS_BOTTLE = 374;
|
||||
public const SPIDER_EYE = 375;
|
||||
public const FERMENTED_SPIDER_EYE = 376;
|
||||
public const BLAZE_POWDER = 377;
|
||||
public const MAGMA_CREAM = 378;
|
||||
public const BREWING_STAND = 379;
|
||||
public const CAULDRON = 380;
|
||||
public const ENDER_EYE = 381;
|
||||
public const GLISTERING_MELON = 382, SPECKLED_MELON = 382;
|
||||
public const SPAWN_EGG = 383;
|
||||
public const BOTTLE_O_ENCHANTING = 384, EXPERIENCE_BOTTLE = 384;
|
||||
public const FIREBALL = 385, FIRE_CHARGE = 385;
|
||||
public const WRITABLE_BOOK = 386;
|
||||
public const WRITTEN_BOOK = 387;
|
||||
public const EMERALD = 388;
|
||||
public const FRAME = 389, ITEM_FRAME = 389;
|
||||
public const FLOWER_POT = 390;
|
||||
public const CARROT = 391;
|
||||
public const POTATO = 392;
|
||||
public const BAKED_POTATO = 393;
|
||||
public const POISONOUS_POTATO = 394;
|
||||
public const EMPTYMAP = 395, EMPTY_MAP = 395, MAP = 395;
|
||||
public const GOLDEN_CARROT = 396;
|
||||
public const MOB_HEAD = 397, SKULL = 397;
|
||||
public const CARROTONASTICK = 398, CARROT_ON_A_STICK = 398;
|
||||
public const NETHERSTAR = 399, NETHER_STAR = 399;
|
||||
public const PUMPKIN_PIE = 400;
|
||||
public const FIREWORKS = 401;
|
||||
public const FIREWORKSCHARGE = 402, FIREWORKS_CHARGE = 402;
|
||||
public const ENCHANTED_BOOK = 403;
|
||||
public const COMPARATOR = 404;
|
||||
public const NETHERBRICK = 405, NETHER_BRICK = 405;
|
||||
public const NETHER_QUARTZ = 406, QUARTZ = 406;
|
||||
public const MINECART_WITH_TNT = 407, TNT_MINECART = 407;
|
||||
public const HOPPER_MINECART = 408, MINECART_WITH_HOPPER = 408;
|
||||
public const PRISMARINE_SHARD = 409;
|
||||
public const HOPPER = 410;
|
||||
public const RABBIT = 411, RAW_RABBIT = 411;
|
||||
public const COOKED_RABBIT = 412;
|
||||
public const RABBIT_STEW = 413;
|
||||
public const RABBIT_FOOT = 414;
|
||||
public const RABBIT_HIDE = 415;
|
||||
public const HORSEARMORLEATHER = 416, HORSE_ARMOR_LEATHER = 416, LEATHER_HORSE_ARMOR = 416;
|
||||
public const HORSEARMORIRON = 417, HORSE_ARMOR_IRON = 417, IRON_HORSE_ARMOR = 417;
|
||||
public const GOLDEN_HORSE_ARMOR = 418, GOLD_HORSE_ARMOR = 418, HORSEARMORGOLD = 418, HORSE_ARMOR_GOLD = 418;
|
||||
public const DIAMOND_HORSE_ARMOR = 419, HORSEARMORDIAMOND = 419, HORSE_ARMOR_DIAMOND = 419;
|
||||
public const LEAD = 420;
|
||||
public const NAMETAG = 421, NAME_TAG = 421;
|
||||
public const PRISMARINE_CRYSTALS = 422;
|
||||
public const MUTTON = 423, MUTTONRAW = 423, MUTTON_RAW = 423, RAW_MUTTON = 423;
|
||||
public const COOKED_MUTTON = 424, MUTTONCOOKED = 424, MUTTON_COOKED = 424;
|
||||
public const ARMOR_STAND = 425;
|
||||
public const END_CRYSTAL = 426;
|
||||
public const SPRUCE_DOOR = 427;
|
||||
public const BIRCH_DOOR = 428;
|
||||
public const JUNGLE_DOOR = 429;
|
||||
public const ACACIA_DOOR = 430;
|
||||
public const DARK_OAK_DOOR = 431;
|
||||
public const CHORUS_FRUIT = 432;
|
||||
public const CHORUS_FRUIT_POPPED = 433;
|
||||
public const BANNER_PATTERN = 434;
|
||||
|
||||
public const DRAGON_BREATH = 437;
|
||||
public const SPLASH_POTION = 438;
|
||||
|
||||
public const LINGERING_POTION = 441;
|
||||
public const SPARKLER = 442;
|
||||
public const COMMAND_BLOCK_MINECART = 443, MINECART_WITH_COMMAND_BLOCK = 443;
|
||||
public const ELYTRA = 444;
|
||||
public const SHULKER_SHELL = 445;
|
||||
public const BANNER = 446;
|
||||
public const MEDICINE = 447;
|
||||
public const BALLOON = 448;
|
||||
public const RAPID_FERTILIZER = 449;
|
||||
public const TOTEM = 450;
|
||||
public const BLEACH = 451;
|
||||
public const IRON_NUGGET = 452;
|
||||
public const ICE_BOMB = 453;
|
||||
|
||||
public const TRIDENT = 455;
|
||||
|
||||
public const BEETROOT = 457;
|
||||
public const BEETROOT_SEEDS = 458;
|
||||
public const BEETROOT_SOUP = 459;
|
||||
public const RAW_SALMON = 460, SALMON = 460;
|
||||
public const CLOWNFISH = 461;
|
||||
public const PUFFERFISH = 462;
|
||||
public const COOKED_SALMON = 463;
|
||||
public const DRIED_KELP = 464;
|
||||
public const NAUTILUS_SHELL = 465;
|
||||
public const APPLEENCHANTED = 466, APPLE_ENCHANTED = 466, ENCHANTED_GOLDEN_APPLE = 466;
|
||||
public const HEART_OF_THE_SEA = 467;
|
||||
public const TURTLE_SHELL_PIECE = 468;
|
||||
public const TURTLE_HELMET = 469;
|
||||
public const PHANTOM_MEMBRANE = 470;
|
||||
public const CROSSBOW = 471;
|
||||
public const SPRUCE_SIGN = 472;
|
||||
public const BIRCH_SIGN = 473;
|
||||
public const JUNGLE_SIGN = 474;
|
||||
public const ACACIA_SIGN = 475;
|
||||
public const DARKOAK_SIGN = 476;
|
||||
public const SWEET_BERRIES = 477;
|
||||
|
||||
public const COMPOUND = 499;
|
||||
public const RECORD_13 = 500;
|
||||
public const RECORD_CAT = 501;
|
||||
public const RECORD_BLOCKS = 502;
|
||||
public const RECORD_CHIRP = 503;
|
||||
public const RECORD_FAR = 504;
|
||||
public const RECORD_MALL = 505;
|
||||
public const RECORD_MELLOHI = 506;
|
||||
public const RECORD_STAL = 507;
|
||||
public const RECORD_STRAD = 508;
|
||||
public const RECORD_WARD = 509;
|
||||
public const RECORD_11 = 510;
|
||||
public const RECORD_WAIT = 511;
|
||||
|
||||
public const SHIELD = 513;
|
||||
|
||||
}
|
47
src/item/ItemUseResult.php
Normal file
47
src/item/ItemUseResult.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
use pocketmine\utils\EnumTrait;
|
||||
|
||||
/**
|
||||
* This doc-block is generated automatically, do not modify it manually.
|
||||
* This must be regenerated whenever enum members are added, removed or changed.
|
||||
* @see EnumTrait::_generateMethodAnnotations()
|
||||
*
|
||||
* @method static self NONE()
|
||||
* @method static self FAIL()
|
||||
* @method static self SUCCESS()
|
||||
*/
|
||||
final class ItemUseResult{
|
||||
use EnumTrait;
|
||||
|
||||
protected static function setup() : iterable{
|
||||
return [
|
||||
new self("none"),
|
||||
new self("fail"),
|
||||
new self("success")
|
||||
];
|
||||
}
|
||||
}
|
33
src/item/Leggings.php
Normal file
33
src/item/Leggings.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
use pocketmine\inventory\ArmorInventory;
|
||||
|
||||
class Leggings extends Armor{
|
||||
|
||||
public function getArmorSlot() : int{
|
||||
return ArmorInventory::SLOT_LEGS;
|
||||
}
|
||||
}
|
77
src/item/LiquidBucket.php
Normal file
77
src/item/LiquidBucket.php
Normal file
@@ -0,0 +1,77 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
use pocketmine\block\Block;
|
||||
use pocketmine\block\Lava;
|
||||
use pocketmine\block\Liquid;
|
||||
use pocketmine\event\player\PlayerBucketEmptyEvent;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\player\Player;
|
||||
|
||||
class LiquidBucket extends Item{
|
||||
|
||||
/** @var Liquid */
|
||||
private $liquid;
|
||||
|
||||
public function __construct(int $id, int $meta, string $name, Liquid $liquid){
|
||||
parent::__construct($id, $meta, $name);
|
||||
$this->liquid = $liquid;
|
||||
}
|
||||
|
||||
public function getMaxStackSize() : int{
|
||||
return 1;
|
||||
}
|
||||
|
||||
public function getFuelTime() : int{
|
||||
if($this->liquid instanceof Lava){
|
||||
return 20000;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function onActivate(Player $player, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector) : ItemUseResult{
|
||||
if(!$blockReplace->canBeReplaced()){
|
||||
return ItemUseResult::NONE();
|
||||
}
|
||||
|
||||
//TODO: move this to generic placement logic
|
||||
$resultBlock = clone $this->liquid;
|
||||
|
||||
$ev = new PlayerBucketEmptyEvent($player, $blockReplace, $face, $this, VanillaItems::BUCKET());
|
||||
$ev->call();
|
||||
if(!$ev->isCancelled()){
|
||||
$player->getWorld()->setBlock($blockReplace, $resultBlock->getFlowingForm());
|
||||
$player->getWorld()->addSound($blockReplace->add(0.5, 0.5, 0.5), $resultBlock->getBucketEmptySound());
|
||||
|
||||
if($player->hasFiniteResources()){
|
||||
$player->getInventory()->setItemInHand($ev->getItem());
|
||||
}
|
||||
return ItemUseResult::SUCCESS();
|
||||
}
|
||||
|
||||
return ItemUseResult::FAIL();
|
||||
}
|
||||
}
|
35
src/item/Melon.php
Normal file
35
src/item/Melon.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
class Melon extends Food{
|
||||
|
||||
public function getFoodRestore() : int{
|
||||
return 2;
|
||||
}
|
||||
|
||||
public function getSaturationRestore() : float{
|
||||
return 1.2;
|
||||
}
|
||||
}
|
34
src/item/MelonSeeds.php
Normal file
34
src/item/MelonSeeds.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
use pocketmine\block\Block;
|
||||
use pocketmine\block\VanillaBlocks;
|
||||
|
||||
class MelonSeeds extends Item{
|
||||
|
||||
public function getBlock() : Block{
|
||||
return VanillaBlocks::MELON_STEM();
|
||||
}
|
||||
}
|
45
src/item/MilkBucket.php
Normal file
45
src/item/MilkBucket.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
use pocketmine\entity\Living;
|
||||
|
||||
class MilkBucket extends Item implements Consumable{
|
||||
|
||||
public function getMaxStackSize() : int{
|
||||
return 1;
|
||||
}
|
||||
|
||||
public function getResidue(){
|
||||
return VanillaItems::BUCKET();
|
||||
}
|
||||
|
||||
public function getAdditionalEffects() : array{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function onConsume(Living $consumer) : void{
|
||||
$consumer->getEffects()->clear();
|
||||
}
|
||||
}
|
29
src/item/Minecart.php
Normal file
29
src/item/Minecart.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
class Minecart extends Item{
|
||||
|
||||
//TODO
|
||||
}
|
43
src/item/MushroomStew.php
Normal file
43
src/item/MushroomStew.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
class MushroomStew extends Food{
|
||||
|
||||
public function getMaxStackSize() : int{
|
||||
return 1;
|
||||
}
|
||||
|
||||
public function getFoodRestore() : int{
|
||||
return 6;
|
||||
}
|
||||
|
||||
public function getSaturationRestore() : float{
|
||||
return 7.2;
|
||||
}
|
||||
|
||||
public function getResidue(){
|
||||
return VanillaItems::BOWL();
|
||||
}
|
||||
}
|
101
src/item/PaintingItem.php
Normal file
101
src/item/PaintingItem.php
Normal file
@@ -0,0 +1,101 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
use pocketmine\block\Block;
|
||||
use pocketmine\entity\EntityFactory;
|
||||
use pocketmine\entity\object\Painting;
|
||||
use pocketmine\entity\object\PaintingMotive;
|
||||
use pocketmine\math\Facing;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\player\Player;
|
||||
use pocketmine\world\sound\PaintingPlaceSound;
|
||||
use function array_rand;
|
||||
|
||||
class PaintingItem extends Item{
|
||||
|
||||
public function onActivate(Player $player, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector) : ItemUseResult{
|
||||
if(Facing::axis($face) === Facing::AXIS_Y){
|
||||
return ItemUseResult::NONE();
|
||||
}
|
||||
|
||||
$motives = [];
|
||||
|
||||
$totalDimension = 0;
|
||||
foreach(PaintingMotive::getAll() as $motive){
|
||||
$currentTotalDimension = $motive->getHeight() + $motive->getWidth();
|
||||
if($currentTotalDimension < $totalDimension){
|
||||
continue;
|
||||
}
|
||||
|
||||
if(Painting::canFit($player->getWorld(), $blockReplace, $face, true, $motive)){
|
||||
if($currentTotalDimension > $totalDimension){
|
||||
$totalDimension = $currentTotalDimension;
|
||||
/*
|
||||
* This drops all motive possibilities smaller than this
|
||||
* We use the total of height + width to allow equal chance of horizontal/vertical paintings
|
||||
* when there is an L-shape of space available.
|
||||
*/
|
||||
$motives = [];
|
||||
}
|
||||
|
||||
$motives[] = $motive;
|
||||
}
|
||||
}
|
||||
|
||||
if(empty($motives)){ //No space available
|
||||
return ItemUseResult::NONE();
|
||||
}
|
||||
|
||||
/** @var PaintingMotive $motive */
|
||||
$motive = $motives[array_rand($motives)];
|
||||
|
||||
static $directions = [
|
||||
Facing::SOUTH => 0,
|
||||
Facing::WEST => 1,
|
||||
Facing::NORTH => 2,
|
||||
Facing::EAST => 3
|
||||
];
|
||||
|
||||
$direction = $directions[$face] ?? -1;
|
||||
if($direction === -1){
|
||||
return ItemUseResult::NONE();
|
||||
}
|
||||
|
||||
$nbt = EntityFactory::createBaseNBT($blockReplace, null, $direction * 90, 0);
|
||||
$nbt->setByte("Direction", $direction);
|
||||
$nbt->setString("Motive", $motive->getName());
|
||||
$nbt->setInt("TileX", $blockClicked->getFloorX());
|
||||
$nbt->setInt("TileY", $blockClicked->getFloorY());
|
||||
$nbt->setInt("TileZ", $blockClicked->getFloorZ());
|
||||
|
||||
/** @var Painting $entity */
|
||||
$entity = EntityFactory::create(Painting::class, $blockReplace->getWorld(), $nbt);
|
||||
$this->pop();
|
||||
$entity->spawnToAll();
|
||||
|
||||
$player->getWorld()->addSound($blockReplace->add(0.5, 0.5, 0.5), new PaintingPlaceSound());
|
||||
return ItemUseResult::SUCCESS();
|
||||
}
|
||||
}
|
54
src/item/Pickaxe.php
Normal file
54
src/item/Pickaxe.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
use pocketmine\block\Block;
|
||||
use pocketmine\block\BlockToolType;
|
||||
use pocketmine\entity\Entity;
|
||||
|
||||
class Pickaxe extends TieredTool{
|
||||
|
||||
public function getBlockToolType() : int{
|
||||
return BlockToolType::PICKAXE;
|
||||
}
|
||||
|
||||
public function getBlockToolHarvestLevel() : int{
|
||||
return $this->tier->getHarvestLevel();
|
||||
}
|
||||
|
||||
public function getAttackPoints() : int{
|
||||
return $this->tier->getBaseAttackPoints() - 2;
|
||||
}
|
||||
|
||||
public function onDestroyBlock(Block $block) : bool{
|
||||
if(!$block->getBreakInfo()->breaksInstantly()){
|
||||
return $this->applyDamage(1);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function onAttackEntity(Entity $victim) : bool{
|
||||
return $this->applyDamage(2);
|
||||
}
|
||||
}
|
48
src/item/PoisonousPotato.php
Normal file
48
src/item/PoisonousPotato.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
use pocketmine\entity\effect\EffectInstance;
|
||||
use pocketmine\entity\effect\VanillaEffects;
|
||||
use function mt_rand;
|
||||
|
||||
class PoisonousPotato extends Food{
|
||||
|
||||
public function getFoodRestore() : int{
|
||||
return 2;
|
||||
}
|
||||
|
||||
public function getSaturationRestore() : float{
|
||||
return 1.2;
|
||||
}
|
||||
|
||||
public function getAdditionalEffects() : array{
|
||||
if(mt_rand(0, 100) > 40){
|
||||
return [
|
||||
new EffectInstance(VanillaEffects::POISON(), 100)
|
||||
];
|
||||
}
|
||||
return [];
|
||||
}
|
||||
}
|
42
src/item/Potato.php
Normal file
42
src/item/Potato.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
use pocketmine\block\Block;
|
||||
use pocketmine\block\VanillaBlocks;
|
||||
|
||||
class Potato extends Food{
|
||||
|
||||
public function getBlock() : Block{
|
||||
return VanillaBlocks::POTATOES();
|
||||
}
|
||||
|
||||
public function getFoodRestore() : int{
|
||||
return 1;
|
||||
}
|
||||
|
||||
public function getSaturationRestore() : float{
|
||||
return 0.6;
|
||||
}
|
||||
}
|
274
src/item/Potion.php
Normal file
274
src/item/Potion.php
Normal file
@@ -0,0 +1,274 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
use pocketmine\entity\effect\EffectInstance;
|
||||
use pocketmine\entity\effect\VanillaEffects;
|
||||
use pocketmine\entity\Living;
|
||||
|
||||
class Potion extends Item implements Consumable{
|
||||
|
||||
public const WATER = 0;
|
||||
public const MUNDANE = 1;
|
||||
public const LONG_MUNDANE = 2;
|
||||
public const THICK = 3;
|
||||
public const AWKWARD = 4;
|
||||
public const NIGHT_VISION = 5;
|
||||
public const LONG_NIGHT_VISION = 6;
|
||||
public const INVISIBILITY = 7;
|
||||
public const LONG_INVISIBILITY = 8;
|
||||
public const LEAPING = 9;
|
||||
public const LONG_LEAPING = 10;
|
||||
public const STRONG_LEAPING = 11;
|
||||
public const FIRE_RESISTANCE = 12;
|
||||
public const LONG_FIRE_RESISTANCE = 13;
|
||||
public const SWIFTNESS = 14;
|
||||
public const LONG_SWIFTNESS = 15;
|
||||
public const STRONG_SWIFTNESS = 16;
|
||||
public const SLOWNESS = 17;
|
||||
public const LONG_SLOWNESS = 18;
|
||||
public const WATER_BREATHING = 19;
|
||||
public const LONG_WATER_BREATHING = 20;
|
||||
public const HEALING = 21;
|
||||
public const STRONG_HEALING = 22;
|
||||
public const HARMING = 23;
|
||||
public const STRONG_HARMING = 24;
|
||||
public const POISON = 25;
|
||||
public const LONG_POISON = 26;
|
||||
public const STRONG_POISON = 27;
|
||||
public const REGENERATION = 28;
|
||||
public const LONG_REGENERATION = 29;
|
||||
public const STRONG_REGENERATION = 30;
|
||||
public const STRENGTH = 31;
|
||||
public const LONG_STRENGTH = 32;
|
||||
public const STRONG_STRENGTH = 33;
|
||||
public const WEAKNESS = 34;
|
||||
public const LONG_WEAKNESS = 35;
|
||||
public const WITHER = 36;
|
||||
|
||||
public const ALL = [
|
||||
self::WATER,
|
||||
self::MUNDANE,
|
||||
self::LONG_MUNDANE,
|
||||
self::THICK,
|
||||
self::AWKWARD,
|
||||
self::NIGHT_VISION,
|
||||
self::LONG_NIGHT_VISION,
|
||||
self::INVISIBILITY,
|
||||
self::LONG_INVISIBILITY,
|
||||
self::LEAPING,
|
||||
self::LONG_LEAPING,
|
||||
self::STRONG_LEAPING,
|
||||
self::FIRE_RESISTANCE,
|
||||
self::LONG_FIRE_RESISTANCE,
|
||||
self::SWIFTNESS,
|
||||
self::LONG_SWIFTNESS,
|
||||
self::STRONG_SWIFTNESS,
|
||||
self::SLOWNESS,
|
||||
self::LONG_SLOWNESS,
|
||||
self::WATER_BREATHING,
|
||||
self::LONG_WATER_BREATHING,
|
||||
self::HEALING,
|
||||
self::STRONG_HEALING,
|
||||
self::HARMING,
|
||||
self::STRONG_HARMING,
|
||||
self::POISON,
|
||||
self::LONG_POISON,
|
||||
self::STRONG_POISON,
|
||||
self::REGENERATION,
|
||||
self::LONG_REGENERATION,
|
||||
self::STRONG_REGENERATION,
|
||||
self::STRENGTH,
|
||||
self::LONG_STRENGTH,
|
||||
self::STRONG_STRENGTH,
|
||||
self::WEAKNESS,
|
||||
self::LONG_WEAKNESS,
|
||||
self::WITHER
|
||||
];
|
||||
|
||||
/**
|
||||
* Returns a list of effects applied by potions with the specified ID.
|
||||
*
|
||||
* @param int $id
|
||||
*
|
||||
* @return EffectInstance[]
|
||||
*/
|
||||
public static function getPotionEffectsById(int $id) : array{
|
||||
switch($id){
|
||||
case self::WATER:
|
||||
case self::MUNDANE:
|
||||
case self::LONG_MUNDANE:
|
||||
case self::THICK:
|
||||
case self::AWKWARD:
|
||||
return [];
|
||||
case self::NIGHT_VISION:
|
||||
return [
|
||||
new EffectInstance(VanillaEffects::NIGHT_VISION(), 3600)
|
||||
];
|
||||
case self::LONG_NIGHT_VISION:
|
||||
return [
|
||||
new EffectInstance(VanillaEffects::NIGHT_VISION(), 9600)
|
||||
];
|
||||
case self::INVISIBILITY:
|
||||
return [
|
||||
new EffectInstance(VanillaEffects::INVISIBILITY(), 3600)
|
||||
];
|
||||
case self::LONG_INVISIBILITY:
|
||||
return [
|
||||
new EffectInstance(VanillaEffects::INVISIBILITY(), 9600)
|
||||
];
|
||||
case self::LEAPING:
|
||||
return [
|
||||
new EffectInstance(VanillaEffects::JUMP_BOOST(), 3600)
|
||||
];
|
||||
case self::LONG_LEAPING:
|
||||
return [
|
||||
new EffectInstance(VanillaEffects::JUMP_BOOST(), 9600)
|
||||
];
|
||||
case self::STRONG_LEAPING:
|
||||
return [
|
||||
new EffectInstance(VanillaEffects::JUMP_BOOST(), 1800, 1)
|
||||
];
|
||||
case self::FIRE_RESISTANCE:
|
||||
return [
|
||||
new EffectInstance(VanillaEffects::FIRE_RESISTANCE(), 3600)
|
||||
];
|
||||
case self::LONG_FIRE_RESISTANCE:
|
||||
return [
|
||||
new EffectInstance(VanillaEffects::FIRE_RESISTANCE(), 9600)
|
||||
];
|
||||
case self::SWIFTNESS:
|
||||
return [
|
||||
new EffectInstance(VanillaEffects::SPEED(), 3600)
|
||||
];
|
||||
case self::LONG_SWIFTNESS:
|
||||
return [
|
||||
new EffectInstance(VanillaEffects::SPEED(), 9600)
|
||||
];
|
||||
case self::STRONG_SWIFTNESS:
|
||||
return [
|
||||
new EffectInstance(VanillaEffects::SPEED(), 1800, 1)
|
||||
];
|
||||
case self::SLOWNESS:
|
||||
return [
|
||||
new EffectInstance(VanillaEffects::SLOWNESS(), 1800)
|
||||
];
|
||||
case self::LONG_SLOWNESS:
|
||||
return [
|
||||
new EffectInstance(VanillaEffects::SLOWNESS(), 4800)
|
||||
];
|
||||
case self::WATER_BREATHING:
|
||||
return [
|
||||
new EffectInstance(VanillaEffects::WATER_BREATHING(), 3600)
|
||||
];
|
||||
case self::LONG_WATER_BREATHING:
|
||||
return [
|
||||
new EffectInstance(VanillaEffects::WATER_BREATHING(), 9600)
|
||||
];
|
||||
case self::HEALING:
|
||||
return [
|
||||
new EffectInstance(VanillaEffects::INSTANT_HEALTH())
|
||||
];
|
||||
case self::STRONG_HEALING:
|
||||
return [
|
||||
new EffectInstance(VanillaEffects::INSTANT_HEALTH(), null, 1)
|
||||
];
|
||||
case self::HARMING:
|
||||
return [
|
||||
new EffectInstance(VanillaEffects::INSTANT_DAMAGE())
|
||||
];
|
||||
case self::STRONG_HARMING:
|
||||
return [
|
||||
new EffectInstance(VanillaEffects::INSTANT_DAMAGE(), null, 1)
|
||||
];
|
||||
case self::POISON:
|
||||
return [
|
||||
new EffectInstance(VanillaEffects::POISON(), 900)
|
||||
];
|
||||
case self::LONG_POISON:
|
||||
return [
|
||||
new EffectInstance(VanillaEffects::POISON(), 2400)
|
||||
];
|
||||
case self::STRONG_POISON:
|
||||
return [
|
||||
new EffectInstance(VanillaEffects::POISON(), 440, 1)
|
||||
];
|
||||
case self::REGENERATION:
|
||||
return [
|
||||
new EffectInstance(VanillaEffects::REGENERATION(), 900)
|
||||
];
|
||||
case self::LONG_REGENERATION:
|
||||
return [
|
||||
new EffectInstance(VanillaEffects::REGENERATION(), 2400)
|
||||
];
|
||||
case self::STRONG_REGENERATION:
|
||||
return [
|
||||
new EffectInstance(VanillaEffects::REGENERATION(), 440, 1)
|
||||
];
|
||||
case self::STRENGTH:
|
||||
return [
|
||||
new EffectInstance(VanillaEffects::STRENGTH(), 3600)
|
||||
];
|
||||
case self::LONG_STRENGTH:
|
||||
return [
|
||||
new EffectInstance(VanillaEffects::STRENGTH(), 9600)
|
||||
];
|
||||
case self::STRONG_STRENGTH:
|
||||
return [
|
||||
new EffectInstance(VanillaEffects::STRENGTH(), 1800, 1)
|
||||
];
|
||||
case self::WEAKNESS:
|
||||
return [
|
||||
new EffectInstance(VanillaEffects::WEAKNESS(), 1800)
|
||||
];
|
||||
case self::LONG_WEAKNESS:
|
||||
return [
|
||||
new EffectInstance(VanillaEffects::WEAKNESS(), 4800)
|
||||
];
|
||||
case self::WITHER:
|
||||
return [
|
||||
new EffectInstance(VanillaEffects::WITHER(), 800, 1)
|
||||
];
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
public function getMaxStackSize() : int{
|
||||
return 1;
|
||||
}
|
||||
|
||||
public function onConsume(Living $consumer) : void{
|
||||
|
||||
}
|
||||
|
||||
public function getAdditionalEffects() : array{
|
||||
//TODO: check CustomPotionEffects NBT
|
||||
return self::getPotionEffectsById($this->meta);
|
||||
}
|
||||
|
||||
public function getResidue(){
|
||||
return VanillaItems::GLASS_BOTTLE();
|
||||
}
|
||||
}
|
81
src/item/ProjectileItem.php
Normal file
81
src/item/ProjectileItem.php
Normal file
@@ -0,0 +1,81 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
use pocketmine\entity\EntityFactory;
|
||||
use pocketmine\entity\projectile\Throwable;
|
||||
use pocketmine\event\entity\ProjectileLaunchEvent;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
use pocketmine\player\Player;
|
||||
use pocketmine\utils\Utils;
|
||||
use pocketmine\world\sound\ThrowSound;
|
||||
|
||||
abstract class ProjectileItem extends Item{
|
||||
|
||||
/**
|
||||
* Returns the entity type that this projectile creates. This should return a ::class extending Throwable.
|
||||
*
|
||||
* @return string class extends Throwable
|
||||
*/
|
||||
abstract public function getProjectileEntityClass() : string;
|
||||
|
||||
abstract public function getThrowForce() : float;
|
||||
|
||||
/**
|
||||
* Helper function to apply extra NBT tags to pass to the created projectile.
|
||||
*
|
||||
* @param CompoundTag $tag
|
||||
*/
|
||||
protected function addExtraTags(CompoundTag $tag) : void{
|
||||
|
||||
}
|
||||
|
||||
public function onClickAir(Player $player, Vector3 $directionVector) : ItemUseResult{
|
||||
$nbt = EntityFactory::createBaseNBT($player->add(0, $player->getEyeHeight(), 0), $directionVector, $player->yaw, $player->pitch);
|
||||
$this->addExtraTags($nbt);
|
||||
|
||||
$class = $this->getProjectileEntityClass();
|
||||
Utils::testValidInstance($class, Throwable::class);
|
||||
|
||||
/** @var Throwable $projectile */
|
||||
$projectile = EntityFactory::create($class, $player->getWorld(), $nbt, $player);
|
||||
$projectile->setMotion($projectile->getMotion()->multiply($this->getThrowForce()));
|
||||
|
||||
$projectileEv = new ProjectileLaunchEvent($projectile);
|
||||
$projectileEv->call();
|
||||
if($projectileEv->isCancelled()){
|
||||
$projectile->flagForDespawn();
|
||||
return ItemUseResult::FAIL();
|
||||
}
|
||||
|
||||
$projectile->spawnToAll();
|
||||
|
||||
$player->getWorld()->addSound($player, new ThrowSound());
|
||||
|
||||
$this->pop();
|
||||
|
||||
return ItemUseResult::SUCCESS();
|
||||
}
|
||||
}
|
46
src/item/Pufferfish.php
Normal file
46
src/item/Pufferfish.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
use pocketmine\entity\effect\EffectInstance;
|
||||
use pocketmine\entity\effect\VanillaEffects;
|
||||
|
||||
class Pufferfish extends Food{
|
||||
|
||||
public function getFoodRestore() : int{
|
||||
return 1;
|
||||
}
|
||||
|
||||
public function getSaturationRestore() : float{
|
||||
return 0.2;
|
||||
}
|
||||
|
||||
public function getAdditionalEffects() : array{
|
||||
return [
|
||||
new EffectInstance(VanillaEffects::HUNGER(), 300, 2),
|
||||
new EffectInstance(VanillaEffects::POISON(), 1200, 3),
|
||||
new EffectInstance(VanillaEffects::NAUSEA(), 300, 1)
|
||||
];
|
||||
}
|
||||
}
|
35
src/item/PumpkinPie.php
Normal file
35
src/item/PumpkinPie.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
class PumpkinPie extends Food{
|
||||
|
||||
public function getFoodRestore() : int{
|
||||
return 8;
|
||||
}
|
||||
|
||||
public function getSaturationRestore() : float{
|
||||
return 4.8;
|
||||
}
|
||||
}
|
34
src/item/PumpkinSeeds.php
Normal file
34
src/item/PumpkinSeeds.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
use pocketmine\block\Block;
|
||||
use pocketmine\block\VanillaBlocks;
|
||||
|
||||
class PumpkinSeeds extends Item{
|
||||
|
||||
public function getBlock() : Block{
|
||||
return VanillaBlocks::PUMPKIN_STEM();
|
||||
}
|
||||
}
|
43
src/item/RabbitStew.php
Normal file
43
src/item/RabbitStew.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
class RabbitStew extends Food{
|
||||
|
||||
public function getMaxStackSize() : int{
|
||||
return 1;
|
||||
}
|
||||
|
||||
public function getFoodRestore() : int{
|
||||
return 10;
|
||||
}
|
||||
|
||||
public function getSaturationRestore() : float{
|
||||
return 12;
|
||||
}
|
||||
|
||||
public function getResidue(){
|
||||
return VanillaItems::BOWL();
|
||||
}
|
||||
}
|
35
src/item/RawBeef.php
Normal file
35
src/item/RawBeef.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
class RawBeef extends Food{
|
||||
|
||||
public function getFoodRestore() : int{
|
||||
return 3;
|
||||
}
|
||||
|
||||
public function getSaturationRestore() : float{
|
||||
return 1.8;
|
||||
}
|
||||
}
|
43
src/item/RawChicken.php
Normal file
43
src/item/RawChicken.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
use pocketmine\entity\effect\EffectInstance;
|
||||
use pocketmine\entity\effect\VanillaEffects;
|
||||
use function mt_rand;
|
||||
|
||||
class RawChicken extends Food{
|
||||
|
||||
public function getFoodRestore() : int{
|
||||
return 2;
|
||||
}
|
||||
|
||||
public function getSaturationRestore() : float{
|
||||
return 1.2;
|
||||
}
|
||||
|
||||
public function getAdditionalEffects() : array{
|
||||
return mt_rand(0, 9) < 3 ? [new EffectInstance(VanillaEffects::HUNGER(), 600)] : [];
|
||||
}
|
||||
}
|
35
src/item/RawFish.php
Normal file
35
src/item/RawFish.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
class RawFish extends Food{
|
||||
|
||||
public function getFoodRestore() : int{
|
||||
return 2;
|
||||
}
|
||||
|
||||
public function getSaturationRestore() : float{
|
||||
return 0.4;
|
||||
}
|
||||
}
|
35
src/item/RawMutton.php
Normal file
35
src/item/RawMutton.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
class RawMutton extends Food{
|
||||
|
||||
public function getFoodRestore() : int{
|
||||
return 2;
|
||||
}
|
||||
|
||||
public function getSaturationRestore() : float{
|
||||
return 1.2;
|
||||
}
|
||||
}
|
35
src/item/RawPorkchop.php
Normal file
35
src/item/RawPorkchop.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
class RawPorkchop extends Food{
|
||||
|
||||
public function getFoodRestore() : int{
|
||||
return 3;
|
||||
}
|
||||
|
||||
public function getSaturationRestore() : float{
|
||||
return 0.6;
|
||||
}
|
||||
}
|
35
src/item/RawRabbit.php
Normal file
35
src/item/RawRabbit.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
class RawRabbit extends Food{
|
||||
|
||||
public function getFoodRestore() : int{
|
||||
return 3;
|
||||
}
|
||||
|
||||
public function getSaturationRestore() : float{
|
||||
return 1.8;
|
||||
}
|
||||
}
|
35
src/item/RawSalmon.php
Normal file
35
src/item/RawSalmon.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
class RawSalmon extends Food{
|
||||
|
||||
public function getFoodRestore() : int{
|
||||
return 2;
|
||||
}
|
||||
|
||||
public function getSaturationRestore() : float{
|
||||
return 0.2;
|
||||
}
|
||||
}
|
34
src/item/Redstone.php
Normal file
34
src/item/Redstone.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
use pocketmine\block\Block;
|
||||
use pocketmine\block\VanillaBlocks;
|
||||
|
||||
class Redstone extends Item{
|
||||
|
||||
public function getBlock() : Block{
|
||||
return VanillaBlocks::REDSTONE_WIRE();
|
||||
}
|
||||
}
|
49
src/item/RottenFlesh.php
Normal file
49
src/item/RottenFlesh.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
use pocketmine\entity\effect\EffectInstance;
|
||||
use pocketmine\entity\effect\VanillaEffects;
|
||||
use function lcg_value;
|
||||
|
||||
class RottenFlesh extends Food{
|
||||
|
||||
public function getFoodRestore() : int{
|
||||
return 4;
|
||||
}
|
||||
|
||||
public function getSaturationRestore() : float{
|
||||
return 0.8;
|
||||
}
|
||||
|
||||
public function getAdditionalEffects() : array{
|
||||
if(lcg_value() <= 0.8){
|
||||
return [
|
||||
new EffectInstance(VanillaEffects::HUNGER(), 600)
|
||||
];
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
50
src/item/Shears.php
Normal file
50
src/item/Shears.php
Normal 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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
use pocketmine\block\Block;
|
||||
use pocketmine\block\BlockToolType;
|
||||
|
||||
class Shears extends Tool{
|
||||
|
||||
public function getMaxDurability() : int{
|
||||
return 239;
|
||||
}
|
||||
|
||||
public function getBlockToolType() : int{
|
||||
return BlockToolType::SHEARS;
|
||||
}
|
||||
|
||||
public function getBlockToolHarvestLevel() : int{
|
||||
return 1;
|
||||
}
|
||||
|
||||
protected function getBaseMiningEfficiency() : float{
|
||||
return 15;
|
||||
}
|
||||
|
||||
public function onDestroyBlock(Block $block) : bool{
|
||||
return $this->applyDamage(1);
|
||||
}
|
||||
}
|
54
src/item/Shovel.php
Normal file
54
src/item/Shovel.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
use pocketmine\block\Block;
|
||||
use pocketmine\block\BlockToolType;
|
||||
use pocketmine\entity\Entity;
|
||||
|
||||
class Shovel extends TieredTool{
|
||||
|
||||
public function getBlockToolType() : int{
|
||||
return BlockToolType::SHOVEL;
|
||||
}
|
||||
|
||||
public function getBlockToolHarvestLevel() : int{
|
||||
return $this->tier->getHarvestLevel();
|
||||
}
|
||||
|
||||
public function getAttackPoints() : int{
|
||||
return $this->tier->getBaseAttackPoints() - 3;
|
||||
}
|
||||
|
||||
public function onDestroyBlock(Block $block) : bool{
|
||||
if(!$block->getBreakInfo()->breaksInstantly()){
|
||||
return $this->applyDamage(1);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function onAttackEntity(Entity $victim) : bool{
|
||||
return $this->applyDamage(2);
|
||||
}
|
||||
}
|
31
src/item/Sign.php
Normal file
31
src/item/Sign.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
class Sign extends ItemBlock{
|
||||
|
||||
public function getMaxStackSize() : int{
|
||||
return 16;
|
||||
}
|
||||
}
|
47
src/item/Skull.php
Normal file
47
src/item/Skull.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
use pocketmine\block\Block;
|
||||
use pocketmine\block\utils\SkullType;
|
||||
use pocketmine\block\VanillaBlocks;
|
||||
|
||||
class Skull extends Item{
|
||||
|
||||
/** @var SkullType */
|
||||
private $skullType;
|
||||
|
||||
public function __construct(int $id, int $variant, string $name, SkullType $skullType){
|
||||
parent::__construct($id, $variant, $name);
|
||||
$this->skullType = $skullType;
|
||||
}
|
||||
|
||||
public function getBlock() : Block{
|
||||
return VanillaBlocks::MOB_HEAD();
|
||||
}
|
||||
|
||||
public function getSkullType() : SkullType{
|
||||
return $this->skullType;
|
||||
}
|
||||
}
|
41
src/item/Snowball.php
Normal file
41
src/item/Snowball.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
use pocketmine\entity\projectile\Snowball as SnowballEntity;
|
||||
|
||||
class Snowball extends ProjectileItem{
|
||||
|
||||
public function getMaxStackSize() : int{
|
||||
return 16;
|
||||
}
|
||||
|
||||
public function getProjectileEntityClass() : string{
|
||||
return SnowballEntity::class;
|
||||
}
|
||||
|
||||
public function getThrowForce() : float{
|
||||
return 1.5;
|
||||
}
|
||||
}
|
67
src/item/SpawnEgg.php
Normal file
67
src/item/SpawnEgg.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
use pocketmine\block\Block;
|
||||
use pocketmine\entity\Entity;
|
||||
use pocketmine\entity\EntityFactory;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\player\Player;
|
||||
use pocketmine\utils\Utils;
|
||||
use function lcg_value;
|
||||
|
||||
class SpawnEgg extends Item{
|
||||
|
||||
/** @var string */
|
||||
private $entityClass;
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @param int $variant
|
||||
* @param string $name
|
||||
*
|
||||
* @param string $entityClass instanceof Entity
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function __construct(int $id, int $variant, string $name, string $entityClass){
|
||||
parent::__construct($id, $variant, $name);
|
||||
Utils::testValidInstance($entityClass, Entity::class);
|
||||
$this->entityClass = $entityClass;
|
||||
}
|
||||
|
||||
public function onActivate(Player $player, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector) : ItemUseResult{
|
||||
$nbt = EntityFactory::createBaseNBT($blockReplace->add(0.5, 0, 0.5), null, lcg_value() * 360, 0);
|
||||
|
||||
if($this->hasCustomName()){
|
||||
$nbt->setString("CustomName", $this->getCustomName());
|
||||
}
|
||||
|
||||
$entity = EntityFactory::create($this->entityClass, $player->getWorld(), $nbt);
|
||||
$this->pop();
|
||||
$entity->spawnToAll();
|
||||
//TODO: what if the entity was marked for deletion?
|
||||
return ItemUseResult::SUCCESS();
|
||||
}
|
||||
}
|
42
src/item/SpiderEye.php
Normal file
42
src/item/SpiderEye.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
use pocketmine\entity\effect\EffectInstance;
|
||||
use pocketmine\entity\effect\VanillaEffects;
|
||||
|
||||
class SpiderEye extends Food{
|
||||
|
||||
public function getFoodRestore() : int{
|
||||
return 2;
|
||||
}
|
||||
|
||||
public function getSaturationRestore() : float{
|
||||
return 3.2;
|
||||
}
|
||||
|
||||
public function getAdditionalEffects() : array{
|
||||
return [new EffectInstance(VanillaEffects::POISON(), 80)];
|
||||
}
|
||||
}
|
46
src/item/SplashPotion.php
Normal file
46
src/item/SplashPotion.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
use pocketmine\entity\projectile\SplashPotion as SplashPotionEntity;
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
|
||||
class SplashPotion extends ProjectileItem{
|
||||
|
||||
public function getMaxStackSize() : int{
|
||||
return 1;
|
||||
}
|
||||
|
||||
public function getProjectileEntityClass() : string{
|
||||
return SplashPotionEntity::class;
|
||||
}
|
||||
|
||||
public function getThrowForce() : float{
|
||||
return 0.5;
|
||||
}
|
||||
|
||||
protected function addExtraTags(CompoundTag $tag) : void{
|
||||
$tag->setShort("PotionId", $this->meta);
|
||||
}
|
||||
}
|
35
src/item/Steak.php
Normal file
35
src/item/Steak.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
class Steak extends Food{
|
||||
|
||||
public function getFoodRestore() : int{
|
||||
return 8;
|
||||
}
|
||||
|
||||
public function getSaturationRestore() : float{
|
||||
return 12.8;
|
||||
}
|
||||
}
|
32
src/item/Stick.php
Normal file
32
src/item/Stick.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
|
||||
class Stick extends Item{
|
||||
|
||||
public function getFuelTime() : int{
|
||||
return 100;
|
||||
}
|
||||
}
|
34
src/item/StringItem.php
Normal file
34
src/item/StringItem.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
use pocketmine\block\Block;
|
||||
use pocketmine\block\VanillaBlocks;
|
||||
|
||||
class StringItem extends Item{
|
||||
|
||||
public function getBlock() : Block{
|
||||
return VanillaBlocks::TRIPWIRE();
|
||||
}
|
||||
}
|
62
src/item/Sword.php
Normal file
62
src/item/Sword.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
use pocketmine\block\Block;
|
||||
use pocketmine\block\BlockToolType;
|
||||
use pocketmine\entity\Entity;
|
||||
|
||||
class Sword extends TieredTool{
|
||||
|
||||
public function getBlockToolType() : int{
|
||||
return BlockToolType::SWORD;
|
||||
}
|
||||
|
||||
public function getAttackPoints() : int{
|
||||
return $this->tier->getBaseAttackPoints();
|
||||
}
|
||||
|
||||
public function getBlockToolHarvestLevel() : int{
|
||||
return 1;
|
||||
}
|
||||
|
||||
public function getMiningEfficiency(bool $isCorrectTool) : float{
|
||||
return parent::getMiningEfficiency($isCorrectTool) * 1.5; //swords break any block 1.5x faster than hand
|
||||
}
|
||||
|
||||
protected function getBaseMiningEfficiency() : float{
|
||||
return 10;
|
||||
}
|
||||
|
||||
public function onDestroyBlock(Block $block) : bool{
|
||||
if(!$block->getBreakInfo()->breaksInstantly()){
|
||||
return $this->applyDamage(2);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function onAttackEntity(Entity $victim) : bool{
|
||||
return $this->applyDamage(1);
|
||||
}
|
||||
}
|
55
src/item/TieredTool.php
Normal file
55
src/item/TieredTool.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
abstract class TieredTool extends Tool{
|
||||
|
||||
/** @var ToolTier */
|
||||
protected $tier;
|
||||
|
||||
public function __construct(int $id, string $name, ToolTier $tier){
|
||||
parent::__construct($id, 0, $name);
|
||||
$this->tier = $tier;
|
||||
}
|
||||
|
||||
public function getMaxDurability() : int{
|
||||
return $this->tier->getMaxDurability();
|
||||
}
|
||||
|
||||
public function getTier() : ToolTier{
|
||||
return $this->tier;
|
||||
}
|
||||
|
||||
protected function getBaseMiningEfficiency() : float{
|
||||
return $this->tier->getBaseEfficiency();
|
||||
}
|
||||
|
||||
public function getFuelTime() : int{
|
||||
if($this->tier->equals(ToolTier::WOOD())){
|
||||
return 200;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
49
src/item/Tool.php
Normal file
49
src/item/Tool.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
use pocketmine\item\enchantment\Enchantment;
|
||||
|
||||
abstract class Tool extends Durable{
|
||||
|
||||
public function getMaxStackSize() : int{
|
||||
return 1;
|
||||
}
|
||||
|
||||
public function getMiningEfficiency(bool $isCorrectTool) : float{
|
||||
$efficiency = 1;
|
||||
if($isCorrectTool){
|
||||
$efficiency = $this->getBaseMiningEfficiency();
|
||||
if(($enchantmentLevel = $this->getEnchantmentLevel(Enchantment::EFFICIENCY())) > 0){
|
||||
$efficiency += ($enchantmentLevel ** 2 + 1);
|
||||
}
|
||||
}
|
||||
|
||||
return $efficiency;
|
||||
}
|
||||
|
||||
protected function getBaseMiningEfficiency() : float{
|
||||
return 1;
|
||||
}
|
||||
}
|
99
src/item/ToolTier.php
Normal file
99
src/item/ToolTier.php
Normal file
@@ -0,0 +1,99 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
|
||||
use pocketmine\utils\EnumTrait;
|
||||
|
||||
/**
|
||||
* This doc-block is generated automatically, do not modify it manually.
|
||||
* This must be regenerated whenever registry members are added, removed or changed.
|
||||
* @see RegistryTrait::_generateMethodAnnotations()
|
||||
*
|
||||
* @method static self WOOD()
|
||||
* @method static self GOLD()
|
||||
* @method static self STONE()
|
||||
* @method static self IRON()
|
||||
* @method static self DIAMOND()
|
||||
*/
|
||||
final class ToolTier{
|
||||
use EnumTrait {
|
||||
__construct as Enum___construct;
|
||||
}
|
||||
|
||||
protected static function setup() : iterable{
|
||||
return [
|
||||
new self("wood", 1, 60, 5, 2),
|
||||
new self("gold", 2, 33, 5, 12),
|
||||
new self("stone", 3, 132, 6, 4),
|
||||
new self("iron", 4, 251, 7, 6),
|
||||
new self("diamond", 5, 1562, 8, 8)
|
||||
];
|
||||
}
|
||||
|
||||
/** @var int */
|
||||
private $harvestLevel;
|
||||
/** @var int */
|
||||
private $maxDurability;
|
||||
/** @var int */
|
||||
private $baseAttackPoints;
|
||||
/** @var int */
|
||||
private $baseEfficiency;
|
||||
|
||||
private function __construct(string $name, int $harvestLevel, int $maxDurability, int $baseAttackPoints, int $baseEfficiency){
|
||||
$this->Enum___construct($name);
|
||||
$this->harvestLevel = $harvestLevel;
|
||||
$this->maxDurability = $maxDurability;
|
||||
$this->baseAttackPoints = $baseAttackPoints;
|
||||
$this->baseEfficiency = $baseEfficiency;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getHarvestLevel() : int{
|
||||
return $this->harvestLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getMaxDurability() : int{
|
||||
return $this->maxDurability;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getBaseAttackPoints() : int{
|
||||
return $this->baseAttackPoints;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getBaseEfficiency() : int{
|
||||
return $this->baseEfficiency;
|
||||
}
|
||||
}
|
31
src/item/Totem.php
Normal file
31
src/item/Totem.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
class Totem extends Item{
|
||||
|
||||
public function getMaxStackSize() : int{
|
||||
return 1;
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user