Fixed mis-uses of Item->isTool()

this has been wrongly used to indicate a durable item, but not just tools are durable items.
This commit is contained in:
Dylan K. Taylor 2018-05-01 20:05:02 +01:00
parent 5368120f13
commit 0247dff909
2 changed files with 3 additions and 2 deletions

View File

@ -76,6 +76,7 @@ use pocketmine\inventory\transaction\CraftingTransaction;
use pocketmine\inventory\transaction\InventoryTransaction; use pocketmine\inventory\transaction\InventoryTransaction;
use pocketmine\inventory\transaction\TransactionValidationException; use pocketmine\inventory\transaction\TransactionValidationException;
use pocketmine\item\Consumable; use pocketmine\item\Consumable;
use pocketmine\item\Durable;
use pocketmine\item\Item; use pocketmine\item\Item;
use pocketmine\item\WritableBook; use pocketmine\item\WritableBook;
use pocketmine\item\WrittenBook; use pocketmine\item\WrittenBook;
@ -2511,7 +2512,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
$target->attack($ev); $target->attack($ev);
if($ev->isCancelled()){ if($ev->isCancelled()){
if($heldItem->isTool() and $this->isSurvival()){ if($heldItem instanceof Durable and $this->isSurvival()){
$this->inventory->sendContents($this); $this->inventory->sendContents($this);
} }
return true; return true;

View File

@ -164,7 +164,7 @@ class Item implements ItemIds, \JsonSerializable{
public static function getCreativeItemIndex(Item $item) : int{ public static function getCreativeItemIndex(Item $item) : int{
foreach(Item::$creative as $i => $d){ foreach(Item::$creative as $i => $d){
if($item->equals($d, !$item->isTool())){ if($item->equals($d, !($item instanceof Durable))){
return $i; return $i;
} }
} }