From 8e127e60a05b96c334525717c45b904c72ea795d Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Fri, 7 Jun 2013 19:18:35 +0200 Subject: [PATCH] Another fix --- src/Player.php | 8 +++----- src/material/Item.php | 6 ++++++ src/material/block/solid/Dirt.php | 2 +- src/material/block/solid/Grass.php | 2 +- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/Player.php b/src/Player.php index 27745470da..10e92e84b4 100644 --- a/src/Player.php +++ b/src/Player.php @@ -1348,11 +1348,9 @@ class Player{ default: $damage = 1;//$this->server->difficulty; } - $this->server->api->entity->harm($data["target"], $damage, $this->eid); - if($slot->isSword() !== false){ - $slot->meta++; - }elseif($slot->isTool() === true){ - $slot->meta += 2; + $target->harm($damage, $this->eid); + if($slot->isTool() === true){ + $slot->useOn($target); } } } diff --git a/src/material/Item.php b/src/material/Item.php index 5851866a68..a0ff0cc891 100644 --- a/src/material/Item.php +++ b/src/material/Item.php @@ -131,6 +131,12 @@ class Item{ } + public function useOn($object){ + if($this->isTool()){ + $this->meta++; + } + } + final public function isTool(){ return ($this->isPickaxe() !== false or $this->isAxe() !== false or $this->isShovel() !== false or $this->isSword() !== false or $this->isHoe() !== false); } diff --git a/src/material/block/solid/Dirt.php b/src/material/block/solid/Dirt.php index f74b34b264..a39bce9eb0 100644 --- a/src/material/block/solid/Dirt.php +++ b/src/material/block/solid/Dirt.php @@ -33,7 +33,7 @@ class DirtBlock extends SolidBlock{ public function onActivate(Item $item, Player $player){ if($item->isHoe()){ - $item->meta++; + $item->useOn($this); $this->level->setBlock($this, BlockAPI::get(FARMLAND, 0)); return true; } diff --git a/src/material/block/solid/Grass.php b/src/material/block/solid/Grass.php index c255b3c978..059fc2defc 100644 --- a/src/material/block/solid/Grass.php +++ b/src/material/block/solid/Grass.php @@ -41,7 +41,7 @@ class GrassBlock extends SolidBlock{ TallGrassObject::growGrass($this->level, $this, new Random()); return true; }elseif($item->isHoe()){ - $item->meta++; + $item->useOn($this); $this->level->setBlock($this, new FarmlandBlock()); return true; }