Added Tool for Items, new items

This commit is contained in:
Shoghi Cervantes 2014-04-02 04:26:53 +02:00
parent ee23b42e23
commit 9a5ffbe56c
29 changed files with 788 additions and 145 deletions

View 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/
*
*
*/
namespace pocketmine\item;
class Bow extends Tool{
public function __construct($meta = 0, $count = 1){
parent::__construct(self::BOW, 0, $count, "Bow");
}
}

View 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/
*
*
*/
namespace pocketmine\item;
class DiamondAxe extends Tool{
public function __construct($meta = 0, $count = 1){
parent::__construct(self::DIAMOND_AXE, 0, $count, "Diamond Axe");
}
}

View 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/
*
*
*/
namespace pocketmine\item;
class DiamondHoe extends Tool{
public function __construct($meta = 0, $count = 1){
parent::__construct(self::DIAMOND_HOE, 0, $count, "Diamond Hoe");
}
}

View 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/
*
*
*/
namespace pocketmine\item;
class DiamondPickaxe extends Tool{
public function __construct($meta = 0, $count = 1){
parent::__construct(self::DIAMOND_PICKAXE, 0, $count, "Diamond Pickaxe");
}
}

View 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/
*
*
*/
namespace pocketmine\item;
class DiamondShovel extends Tool{
public function __construct($meta = 0, $count = 1){
parent::__construct(self::DIAMOND_SHOVEL, 0, $count, "Diamond Shovel");
}
}

View 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/
*
*
*/
namespace pocketmine\item;
class DiamondSword extends Tool{
public function __construct($meta = 0, $count = 1){
parent::__construct(self::DIAMOND_SWORD, 0, $count, "Diamond Sword");
}
}

View File

@ -27,11 +27,10 @@ use pocketmine\block\Solid;
use pocketmine\level\Level;
use pocketmine\Player;
class FlintSteel extends Item{
class FlintSteel extends Tool{
public function __construct($meta = 0, $count = 1){
parent::__construct(self::FLINT_STEEL, $meta, $count, "Flint and Steel");
$this->isActivable = true;
$this->maxStackSize = 1;
}
public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){

View 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/
*
*
*/
namespace pocketmine\item;
class GoldAxe extends Tool{
public function __construct($meta = 0, $count = 1){
parent::__construct(self::GOLD_AXE, 0, $count, "Gold Axe");
}
}

View 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/
*
*
*/
namespace pocketmine\item;
class GoldHoe extends Tool{
public function __construct($meta = 0, $count = 1){
parent::__construct(self::GOLD_HOE, 0, $count, "Gold Hoe");
}
}

View 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/
*
*
*/
namespace pocketmine\item;
class GoldPickaxe extends Tool{
public function __construct($meta = 0, $count = 1){
parent::__construct(self::GOLD_PICKAXE, 0, $count, "Gold Pickaxe");
}
}

View 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/
*
*
*/
namespace pocketmine\item;
class GoldShovel extends Tool{
public function __construct($meta = 0, $count = 1){
parent::__construct(self::GOLD_SHOVEL, 0, $count, "Gold Shovel");
}
}

View 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/
*
*
*/
namespace pocketmine\item;
class GoldSword extends Tool{
public function __construct($meta = 0, $count = 1){
parent::__construct(self::GOLD_SWORD, 0, $count, "Gold Sword");
}
}

View File

@ -22,7 +22,7 @@
namespace pocketmine\item;
class IronAxe extends Item{
class IronAxe extends Tool{
public function __construct($meta = 0, $count = 1){
parent::__construct(self::IRON_AXE, 0, $count, "Iron Axe");
}

View File

@ -22,7 +22,7 @@
namespace pocketmine\item;
class IronHoe extends Item{
class IronHoe extends Tool{
public function __construct($meta = 0, $count = 1){
parent::__construct(self::IRON_HOE, 0, $count, "Iron Hoe");
}

View File

@ -22,7 +22,7 @@
namespace pocketmine\item;
class IronPickaxe extends Item{
class IronPickaxe extends Tool{
public function __construct($meta = 0, $count = 1){
parent::__construct(self::IRON_PICKAXE, 0, $count, "Iron Pickaxe");
}

View File

@ -22,7 +22,7 @@
namespace pocketmine\item;
class IronShovel extends Item{
class IronShovel extends Tool{
public function __construct($meta = 0, $count = 1){
parent::__construct(self::IRON_SHOVEL, 0, $count, "Iron Shovel");
}

View File

@ -210,23 +210,23 @@ class Item{
//Normal Item IDs
const IRON_SHOVEL = 256; //Implemented
const IRON_PICKAXE = 257; //Implemented
const IRON_AXE = 258; //Implemented
const FLINT_STEEL = 259;
const FLINT_AND_STEEL = 259;
const APPLE = 260; //Implemented
const IRON_SHOVEL = 256;//
const IRON_PICKAXE = 257;//
const IRON_AXE = 258;//
const FLINT_STEEL = 259;//
const FLINT_AND_STEEL = 259;//
const APPLE = 260;//
const BOW = 261;
const ARROW = 262;
const COAL = 263; //Implemented
const DIAMOND = 264; //Implemented
const IRON_INGOT = 265; //Implemented
const GOLD_INGOT = 266; //Implemented
const COAL = 263;//
const DIAMOND = 264;//
const IRON_INGOT = 265;//
const GOLD_INGOT = 266;//
const IRON_SWORD = 267;
const WOODEN_SWORD = 268; //Implemented
const WOODEN_SHOVEL = 269; //Implemented
const WOODEN_PICKAXE = 270; //Implemented
const WOODEN_AXE = 271; //Implemented
const WOODEN_SWORD = 268;//
const WOODEN_SHOVEL = 269;//
const WOODEN_PICKAXE = 270;//
const WOODEN_AXE = 271;//
const STONE_SWORD = 272;
const STONE_SHOVEL = 273;
const STONE_PICKAXE = 274;
@ -235,9 +235,9 @@ class Item{
const DIAMOND_SHOVEL = 277;
const DIAMOND_PICKAXE = 278;
const DIAMOND_AXE = 279;
const STICK = 280; //Implemented
const STICK = 280;//
const STICKS = 280;
const BOWL = 281; //Implemented
const BOWL = 281;//
const MUSHROOM_STEW = 282;
const GOLD_SWORD = 283;
const GOLD_SHOVEL = 284;
@ -248,11 +248,11 @@ class Item{
const GOLDEN_PICKAXE = 285;
const GOLDEN_AXE = 286;
const STRING = 287;
const FEATHER = 288; //Implemented
const FEATHER = 288;//
const GUNPOWDER = 289;
const WOODEN_HOE = 290;
const STONE_HOE = 291;
const IRON_HOE = 292; //Implemented
const IRON_HOE = 292;//
const DIAMOND_HOE = 293;
const GOLD_HOE = 294;
const GOLDEN_HOE = 294;
@ -358,6 +358,7 @@ class Item{
const BEETROOT_SOUP = 459;
/** @var Item[] */
public static $list = array();
protected $block;
protected $id;
@ -401,11 +402,29 @@ class Item{
self::IRON_PICKAXE => new IronPickaxe(),
self::IRON_AXE => new IronAxe(),
self::IRON_HOE => new IronHoe(),
self::DIAMOND_SWORD => new DiamondSword(),
self::DIAMOND_SHOVEL => new DiamondShovel(),
self::DIAMOND_PICKAXE => new DiamondPickaxe(),
self::DIAMOND_AXE => new DiamondAxe(),
self::DIAMOND_HOE => new DiamondHoe(),
self::GOLD_SWORD => new GoldSword(),
self::GOLD_SHOVEL => new GoldShovel(),
self::GOLD_PICKAXE => new GoldPickaxe(),
self::GOLD_AXE => new GoldAxe(),
self::GOLD_HOE => new GoldHoe(),
self::STONE_SWORD => new StoneSword(),
self::STONE_SHOVEL => new StoneShovel(),
self::STONE_PICKAXE => new StonePickaxe(),
self::STONE_AXE => new StoneAxe(),
self::STONE_HOE => new StoneHoe(),
self::WOODEN_SWORD => new WoodenSword(),
self::WOODEN_SHOVEL => new WoodenShovel(),
self::WOODEN_PICKAXE => new WoodenPickaxe(),
self::WOODEN_AXE => new WoodenAxe(),
self::WOODEN_HOE => new WoodenHoe(),
self::FLINT_STEEL => new FlintSteel(),
self::SHEARS => new Shears(),
self::BOW => new Bow(),
);
foreach(Block::$list as $id => $class){
self::$list[$id] = new ItemBlock($class);
@ -538,142 +557,51 @@ class Item{
}
public function useOn($object, $force = false){
if($this->isTool() or $force === true){
if(($object instanceof Entity) and !$this->isSword()){
$this->meta += 2;
}else{
$this->meta++;
}
return true;
}elseif($this->isHoe()){
if(($object instanceof Block) and ($object->getID() === self::GRASS or $object->getID() === self::DIRT)){
$this->meta++;
}
}
/**
* @param Entity|Block $object
*
* @return bool
*/
public function useOn($object){
return false;
}
final public function isTool(){
return ($this->id === self::FLINT_STEEL or $this->id === self::SHEARS or $this->isPickaxe() !== false or $this->isAxe() !== false or $this->isShovel() !== false or $this->isSword() !== false);
/**
* @return bool
*/
public function isTool(){
return false;
}
final public function getMaxDurability(){
if(!$this->isTool() and $this->isHoe() === false and $this->id !== self::BOW){
return false;
}
$levels = array(
2 => 33,
1 => 60,
3 => 132,
4 => 251,
5 => 1562,
self::FLINT_STEEL => 65,
self::SHEARS => 239,
self::BOW => 385,
);
if(($type = $this->isPickaxe()) === false){
if(($type = $this->isAxe()) === false){
if(($type = $this->isSword()) === false){
if(($type = $this->isShovel()) === false){
if(($type = $this->isHoe()) === false){
$type = $this->id;
}
}
}
}
}
return $levels[$type];
/**
* @return int|bool
*/
public function getMaxDurability(){
return false;
}
final public function isPickaxe(){ //Returns false or level of the pickaxe
switch($this->id){
case self::IRON_PICKAXE:
return 4;
case self::WOODEN_PICKAXE:
return 1;
case self::STONE_PICKAXE:
return 3;
case self::DIAMOND_PICKAXE:
return 5;
case self::GOLD_PICKAXE:
return 2;
default:
return false;
}
public function isPickaxe(){
return false;
}
final public function isAxe(){
switch($this->id){
case self::IRON_AXE:
return 4;
case self::WOODEN_AXE:
return 1;
case self::STONE_AXE:
return 3;
case self::DIAMOND_AXE:
return 5;
case self::GOLD_AXE:
return 2;
default:
return false;
}
public function isAxe(){
return false;
}
final public function isSword(){
switch($this->id){
case self::IRON_SWORD:
return 4;
case self::WOODEN_SWORD:
return 1;
case self::STONE_SWORD:
return 3;
case self::DIAMOND_SWORD:
return 5;
case self::GOLD_SWORD:
return 2;
default:
return false;
}
public function isSword(){
return false;
}
final public function isShovel(){
switch($this->id){
case self::IRON_SHOVEL:
return 4;
case self::WOODEN_SHOVEL:
return 1;
case self::STONE_SHOVEL:
return 3;
case self::DIAMOND_SHOVEL:
return 5;
case self::GOLD_SHOVEL:
return 2;
default:
return false;
}
public function isShovel(){
return false;
}
public function isHoe(){
switch($this->id){
case self::IRON_HOE:
case self::WOODEN_HOE:
case self::STONE_HOE:
case self::DIAMOND_HOE:
case self::GOLD_HOE:
return true;
default:
return false;
}
return false;
}
public function isShears(){
return ($this->id === self::SHEARS);
return false;
}
final public function __toString(){

View 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/
*
*
*/
namespace pocketmine\item;
class Shears extends Tool{
public function __construct($meta = 0, $count = 1){
parent::__construct(self::SHEARS, $meta, $count, "Shears");
}
}

View 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/
*
*
*/
namespace pocketmine\item;
class StoneAxe extends Tool{
public function __construct($meta = 0, $count = 1){
parent::__construct(self::STONE_AXE, 0, $count, "Stone Axe");
}
}

View 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/
*
*
*/
namespace pocketmine\item;
class StoneHoe extends Tool{
public function __construct($meta = 0, $count = 1){
parent::__construct(self::STONE_HOE, 0, $count, "Stone Hoe");
}
}

View 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/
*
*
*/
namespace pocketmine\item;
class StonePickaxe extends Tool{
public function __construct($meta = 0, $count = 1){
parent::__construct(self::STONE_PICKAXE, 0, $count, "Stone Pickaxe");
}
}

View 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/
*
*
*/
namespace pocketmine\item;
class StoneShovel extends Tool{
public function __construct($meta = 0, $count = 1){
parent::__construct(self::STONE_SHOVEL, 0, $count, "Stone Shovel");
}
}

View 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/
*
*
*/
namespace pocketmine\item;
class StoneSword extends Tool{
public function __construct($meta = 0, $count = 1){
parent::__construct(self::STONE_SWORD, 0, $count, "Stone Sword");
}
}

View File

@ -0,0 +1,177 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
namespace pocketmine\item;
use pocketmine\entity\Entity;
abstract class Tool extends Item{
public function __construct($id, $meta = 0, $count = 1, $name = "Unknown"){
parent::__construct($id, $meta, $count, $name);
$this->maxStackSize = 1;
}
/**
* TODO: Move this to each item
*
* @param Entity|Block $object
*
* @return bool
*/
public function useOn($object){
if($this->isHoe()){
if(($object instanceof Block) and ($object->getID() === self::GRASS or $object->getID() === self::DIRT)){
$this->meta++;
}
}elseif(($object instanceof Entity) and !$this->isSword()){
$this->meta += 2;
}else{
$this->meta++;
}
return true;
}
/**
* TODO: Move this to each item
*
* @return int|bool
*/
public function getMaxDurability(){
$levels = array(
2 => 33,
1 => 60,
3 => 132,
4 => 251,
5 => 1562,
self::FLINT_STEEL => 65,
self::SHEARS => 239,
self::BOW => 385,
);
if(($type = $this->isPickaxe()) === false){
if(($type = $this->isAxe()) === false){
if(($type = $this->isSword()) === false){
if(($type = $this->isShovel()) === false){
if(($type = $this->isHoe()) === false){
$type = $this->id;
}
}
}
}
}
return $levels[$type];
}
public function isPickaxe(){
switch($this->id){
case self::IRON_PICKAXE:
return 4;
case self::WOODEN_PICKAXE:
return 1;
case self::STONE_PICKAXE:
return 3;
case self::DIAMOND_PICKAXE:
return 5;
case self::GOLD_PICKAXE:
return 2;
default:
return false;
}
}
final public function isAxe(){
switch($this->id){
case self::IRON_AXE:
return 4;
case self::WOODEN_AXE:
return 1;
case self::STONE_AXE:
return 3;
case self::DIAMOND_AXE:
return 5;
case self::GOLD_AXE:
return 2;
default:
return false;
}
}
final public function isSword(){
switch($this->id){
case self::IRON_SWORD:
return 4;
case self::WOODEN_SWORD:
return 1;
case self::STONE_SWORD:
return 3;
case self::DIAMOND_SWORD:
return 5;
case self::GOLD_SWORD:
return 2;
default:
return false;
}
}
final public function isShovel(){
switch($this->id){
case self::IRON_SHOVEL:
return 4;
case self::WOODEN_SHOVEL:
return 1;
case self::STONE_SHOVEL:
return 3;
case self::DIAMOND_SHOVEL:
return 5;
case self::GOLD_SHOVEL:
return 2;
default:
return false;
}
}
public function isHoe(){
switch($this->id){
case self::IRON_HOE:
case self::WOODEN_HOE:
case self::STONE_HOE:
case self::DIAMOND_HOE:
case self::GOLD_HOE:
return true;
default:
return false;
}
}
public function isShears(){
return ($this->id === self::SHEARS);
}
public function isTool(){
return false;
return ($this->id === self::FLINT_STEEL or $this->id === self::SHEARS or $this->id === self::BOW or $this->isPickaxe() !== false or $this->isAxe() !== false or $this->isShovel() !== false or $this->isSword() !== false);
}
}

View File

@ -22,7 +22,7 @@
namespace pocketmine\item;
class WoodenAxe extends Item{
class WoodenAxe extends Tool{
public function __construct($meta = 0, $count = 1){
parent::__construct(self::WOODEN_AXE, 0, $count, "Wooden Axe");
}

View 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/
*
*
*/
namespace pocketmine\item;
class WoodenHoe extends Tool{
public function __construct($meta = 0, $count = 1){
parent::__construct(self::WOODEN_HOE, 0, $count, "Wooden Hoe");
}
}

View File

@ -22,7 +22,7 @@
namespace pocketmine\item;
class WoodenPickaxe extends Item{
class WoodenPickaxe extends Tool{
public function __construct($meta = 0, $count = 1){
parent::__construct(self::WOODEN_PICKAXE, 0, $count, "Wooden Pickaxe");
}

View File

@ -22,7 +22,7 @@
namespace pocketmine\item;
class WoodenShovel extends Item{
class WoodenShovel extends Tool{
public function __construct($meta = 0, $count = 1){
parent::__construct(self::WOODEN_SHOVEL, 0, $count, "Wooden Shovel");
}

View File

@ -22,7 +22,7 @@
namespace pocketmine\item;
class WoodenSword extends Item{
class WoodenSword extends Tool{
public function __construct($meta = 0, $count = 1){
parent::__construct(self::WOODEN_SWORD, 0, $count, "Wooden Sword");
}