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

@ -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(){