From 77fa1608c10e1e39d0199e586c31fbf09b5b7e04 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Pueyo Date: Tue, 2 Apr 2013 16:33:15 +0200 Subject: [PATCH] Fixed #179 --- src/Player.php | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/Player.php b/src/Player.php index 2eeebbf7..0a39b544 100644 --- a/src/Player.php +++ b/src/Player.php @@ -852,24 +852,24 @@ class Player{ if(($target instanceof Entity) and $target->class === ENTITY_PLAYER and ($this->server->difficulty <= 0 or $target->gamemode === CREATIVE)){ break; }elseif($this->handle("player.interact", $data) !== false){ - // Swords do proper damage amiunt (by williamtdr) - $harmamount = $this->server->difficulty; - if($data["entity"]->hand == 268) { // wooden sword - $harmamount = $harmamount + 3; + switch($this->equipment->getID()){ + case WOODEN_SWORD: + case GOLD_SWORD: + $damage = 4; + break; + case STONE_SWORD: + $damage = 5; + break; + case IRON_SWORD: + $damage = 6; + break; + case DIAMOND_SWORD: + $damage = 7; + break; + default: + $damage = $this->server->difficulty; } - if($data["entity"]->hand == 283) { // gold sword - $harmamount = $harmamount + 3; - } - if($data["entity"]->hand == 272) { // stone sword - $harmamount = $harmamount + 4; - } - if($data["entity"]->hand == 267) { // iron sword - $harmamount = $harmamount + 5; - } - if($data["entity"]->hand == 276) { // diamond sword - $harmamount = $harmamount + 6; - } - $this->server->api->entity->harm($data["target"], $harmamount, $this->eid); + $this->server->api->entity->harm($data["target"], $damage, $this->eid); } } break;