durability is hopefully fixed

This commit is contained in:
GameHerobrine 2023-01-13 01:08:38 +03:00
parent 629a044053
commit 0c13e4ce1d
6 changed files with 93 additions and 13 deletions

View file

@ -247,20 +247,17 @@ class Item{
BOW => 385 //x3
];
if(($type = $this->getPickaxeLevel()) === false){
if(($type = $this->isAxe()) === false){
if(($type = $this->isSword()) === false){
if(($type = $this->isShovel()) === false){
if(($type = $this->isHoe()) === false){
$type = $this->id;
}
}
}
}
if(($type = $this->getLevel()) === false){
$type = $this->id;
}
return $levels[$type];
}
public function getLevel(){
return false;
}
//TODO remove?
public function getPickaxeLevel(){ //Returns false or level of the pickaxe
switch($this->id){
case WOODEN_PICKAXE:

View file

@ -6,6 +6,21 @@ abstract class ItemAxe extends ItemTool
return true;
}
public function getLevel(){
switch($this->id){
case WOODEN_AXE:
return 1;
case GOLDEN_AXE:
return 2;
case STONE_AXE:
return 3;
case IRON_AXE:
return 4;
case DIAMOND_AXE:
return 5;
default:
return false;
}
}
}

View file

@ -14,5 +14,22 @@ abstract class ItemHoe extends ItemTool
return parent::useOn($object, $force);
}
}
public function getLevel(){
switch($this->id){
case WOODEN_HOE:
return 1;
case GOLDEN_HOE:
return 2;
case STONE_HOE:
return 3;
case IRON_HOE:
return 4;
case DIAMOND_HOE:
return 5;
default:
return false;
}
}
}

View file

@ -5,9 +5,26 @@ abstract class ItemPickaxe extends ItemTool
public function isTool(){
return true;
}
public function isPickaxe(){
return true;
}
public function getLevel(){
switch($this->id){
case WOODEN_PICKAXE:
return 1;
case GOLDEN_PICKAXE:
return 2;
case STONE_PICKAXE:
return 3;
case IRON_PICKAXE:
return 4;
case DIAMOND_PICKAXE:
return 5;
default:
return false;
}
}
}

View file

@ -5,5 +5,22 @@ class ItemShovel extends ItemTool
public function isShovel(){
return true;
}
public function getLevel(){
switch($this->id){
case WOODEN_SHOVEL:
return 1;
case GOLDEN_SHOVEL:
return 2;
case STONE_SHOVEL:
return 3;
case IRON_SHOVEL:
return 4;
case DIAMOND_SHOVEL:
return 5;
default:
return false;
}
}
}

View file

@ -6,5 +6,22 @@ abstract class ItemSword extends ItemTool
public function isSword(){
return true;
}
public function getLevel(){
switch($this->id){
case WOODEN_SWORD:
return 1;
case GOLDEN_SWORD:
return 2;
case STONE_SWORD:
return 3;
case IRON_SWORD:
return 4;
case DIAMOND_SWORD:
return 5;
default:
return false;
}
}
}