Select most damaged tool

master
Tanner Collin 3 years ago
parent 743d002167
commit 4b97aaf739
  1. 2
      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:

Loading…
Cancel
Save