diff options
-rw-r--r-- | mc-resources.py | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/mc-resources.py b/mc-resources.py index dadd79d..f60f53f 100644 --- a/mc-resources.py +++ b/mc-resources.py @@ -333,22 +333,34 @@ while True: gathers = [] order = [] -while ts.is_active(): - ready_smelt = [] - ready_nonsmelt = [] - ready = ts.get_ready() +ready = [] + +while True: + ready += list(ts.get_ready()) + if len(ready) == 0: + break + ready_to_smelt = [] + leftover = [] for id in ready: recipe = chosen_recipes[id] if recipe is None: gathers.append(id) + ts.done(id) elif recipe[0] == 'smelt': - ready_smelt.append(id) + ready_to_smelt.append(id) + ts.done(id) else: - ready_nonsmelt.append(id) - ts.done(id) - ready_smelt.sort() - ready_nonsmelt.sort() - order += ready_smelt + ready_nonsmelt + leftover.append(id) + ready = leftover + if len(ready_to_smelt) == 0: + if len(ready) != 0: + ready.sort() + item = ready.pop(0) + order.append(item) + ts.done(item) + else: + ready_to_smelt.sort() + order += ready_to_smelt order.reverse() |