Manage needed items and item counts better
This commit is contained in:
@@ -848,7 +848,7 @@ class Game:
|
||||
if authed:
|
||||
|
||||
if command == 'print':
|
||||
data = data.replace('^', '.')
|
||||
data = data.replace('`', '.')
|
||||
reply = str(eval(data))
|
||||
|
||||
if command == 'exit':
|
||||
@@ -964,6 +964,28 @@ class Game:
|
||||
count += item.item_count
|
||||
return count
|
||||
|
||||
def count_inventory_slots(self):
|
||||
# count how many inventory slots are filled
|
||||
# excludes armour, crafting slots, off-hand
|
||||
count = 0
|
||||
for slot, item in self.g.inv.items():
|
||||
if item.present and slot >= 9 and slot <= 45:
|
||||
count += 1
|
||||
return count
|
||||
|
||||
def count_window_slots(self):
|
||||
# count how many window slots are filled
|
||||
# excludes player inventory
|
||||
w = self.g.window
|
||||
w_info = mcdata.WINDOWS[w.data.window_type]
|
||||
w_container_slots = w_info.container
|
||||
|
||||
count = 0
|
||||
for slot, item in w.contents.items():
|
||||
if item.present and slot in w_container_slots:
|
||||
count += 1
|
||||
return count
|
||||
|
||||
def get_window_slot(self, item_id):
|
||||
# get the first slot that matches item of a window
|
||||
window_items = list(self.g.window.contents.items())
|
||||
|
||||
Reference in New Issue
Block a user