From 4b97aaf7391e0900d08cc2e6553bfd5707f517a9 Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Mon, 22 Feb 2021 21:31:36 +0000 Subject: [PATCH] Select most damaged tool --- game.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/game.py b/game.py index 14844ed..f1775ba 100644 --- a/game.py +++ b/game.py @@ -893,7 +893,9 @@ class Game: def select_item(self, items): # select the first match from items of inv # uses smallest stack of that match + # and optionally the most damaged item inv_items = list(self.g.inv.items()) + inv_items.sort(key=lambda x: (x[1].nbt or {}).get('Damage', 0), reverse=True) inv_items.sort(key=lambda x: x[1].item_count or 0) for slot, item in inv_items: if item.item_id in items: