Save items properly on several places, added NBT::getItemHelper() and NBT::putItemHelper()

This commit is contained in:
Shoghi Cervantes
2015-08-06 21:44:00 +02:00
parent 554bfb4855
commit 02cb9d69a9
10 changed files with 84 additions and 65 deletions

View File

@ -24,6 +24,7 @@ namespace pocketmine\item;
use pocketmine\block\Block;
use pocketmine\entity\Entity;
use pocketmine\nbt\tag\Byte;
abstract class Tool extends Item{
const TIER_WOODEN = 1;
@ -55,6 +56,10 @@ abstract class Tool extends Item{
* @return bool
*/
public function useOn($object){
if($this->isUnbreakable()){
return true;
}
if($this->isHoe()){
if(($object instanceof Block) and ($object->getId() === self::GRASS or $object->getId() === self::DIRT)){
$this->meta++;
@ -101,6 +106,11 @@ abstract class Tool extends Item{
return $levels[$type];
}
public function isUnbreakable(){
$tag = $this->getNamedTagEntry("Unbreakable");
return $tag instanceof Byte and $tag->getValue() > 0;
}
public function isPickaxe(){
return false;
}