mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-10-20 07:39:42 +00:00
Fixed tool metadata [partial]
This commit is contained in:
@@ -131,6 +131,10 @@ class Item{
|
||||
|
||||
}
|
||||
|
||||
final public function isTool(){
|
||||
return ($this->isPickaxe !== false or $this->isAxe !== false or $this->isShovel !== false or $this->isSword !== false or $this->isHoe !== false);
|
||||
}
|
||||
|
||||
final public function isPickaxe(){ //Returns false or level of the pickaxe
|
||||
switch($this->id){
|
||||
case IRON_PICKAXE:
|
||||
@@ -148,6 +152,40 @@ class Item{
|
||||
}
|
||||
}
|
||||
|
||||
final public function isAxe(){
|
||||
switch($this->id){
|
||||
case IRON_AXE:
|
||||
return 4;
|
||||
case WOODEN_AXE:
|
||||
return 1;
|
||||
case STONE_AXE:
|
||||
return 3;
|
||||
case DIAMOND_AXE:
|
||||
return 5;
|
||||
case GOLD_AXE:
|
||||
return 2;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
final public function isSword(){
|
||||
switch($this->id){
|
||||
case IRON_SWORD:
|
||||
return 4;
|
||||
case WOODEN_SWORD:
|
||||
return 1;
|
||||
case STONE_SWORD:
|
||||
return 3;
|
||||
case DIAMOND_SWORD:
|
||||
return 5;
|
||||
case GOLD_SWORD:
|
||||
return 2;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
final public function isShovel(){
|
||||
switch($this->id){
|
||||
case IRON_SHOVEL:
|
||||
|
@@ -33,6 +33,7 @@ class DirtBlock extends SolidBlock{
|
||||
|
||||
public function onActivate(Item $item, Player $player){
|
||||
if($item->isHoe()){
|
||||
$item->meta++;
|
||||
$this->level->setBlock($this, BlockAPI::get(FARMLAND, 0));
|
||||
return true;
|
||||
}
|
||||
|
@@ -41,6 +41,7 @@ class GrassBlock extends SolidBlock{
|
||||
TallGrassObject::growGrass($this->level, $this, new Random());
|
||||
return true;
|
||||
}elseif($item->isHoe()){
|
||||
$item->meta++;
|
||||
$this->level->setBlock($this, new FarmlandBlock());
|
||||
return true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user