|
|
|
@ -773,6 +773,7 @@ class SleepWithBedStates: |
|
|
|
|
if navpath: |
|
|
|
|
self.g.path = navpath[:-1] |
|
|
|
|
self.opening = self.g.path[-1] |
|
|
|
|
self.g.look_at = self.opening |
|
|
|
|
self.area = bed |
|
|
|
|
self.state = self.going_to_bed |
|
|
|
|
return |
|
|
|
@ -785,7 +786,7 @@ class SleepWithBedStates: |
|
|
|
|
def going_to_bed(self): |
|
|
|
|
if utils.pint(self.g.pos) == self.opening: |
|
|
|
|
self.my_bed = False |
|
|
|
|
self.g.look_at = self.area |
|
|
|
|
self.g.look_at = utils.padd(self.area, path.BLOCK_BELOW) |
|
|
|
|
self.state = self.use_bed |
|
|
|
|
|
|
|
|
|
def select_bed(self): |
|
|
|
@ -823,6 +824,7 @@ class SleepWithBedStates: |
|
|
|
|
return |
|
|
|
|
|
|
|
|
|
self.g.path = navpath |
|
|
|
|
self.g.look_at = self.opening |
|
|
|
|
self.state = self.going_to_area |
|
|
|
|
|
|
|
|
|
def going_to_area(self): |
|
|
|
@ -912,9 +914,9 @@ class CacheItemsStates: |
|
|
|
|
self.skip_slots = [] |
|
|
|
|
self.skip_items = [] |
|
|
|
|
|
|
|
|
|
num_stacks = len([x for x in self.g.inv.values() if x.present]) |
|
|
|
|
num_stacks = self.g.game.count_inventory_slots() |
|
|
|
|
print('Inventory amount:', num_stacks) |
|
|
|
|
if num_stacks >= self.minimum: |
|
|
|
|
if num_stacks >= self.g.minimum_cache_slots: |
|
|
|
|
self.state = self.find_trapped_chests |
|
|
|
|
else: |
|
|
|
|
print('Aborting caching, not full') |
|
|
|
@ -1037,6 +1039,16 @@ class CacheItemsStates: |
|
|
|
|
|
|
|
|
|
w_info = mcdata.WINDOWS[w.data.window_type] |
|
|
|
|
w_inventory_slots = w_info.inventory |
|
|
|
|
w_container_slots = w_info.container |
|
|
|
|
|
|
|
|
|
used_slots = self.g.game.count_window_slots() |
|
|
|
|
print('used:', used_slots, 'total:', len(w_container_slots)) |
|
|
|
|
if used_slots >= len(w_container_slots): |
|
|
|
|
print('Container is too full, aborting') |
|
|
|
|
self.g.game.close_window() |
|
|
|
|
self.g.look_at = None |
|
|
|
|
self.state = self.cleanup |
|
|
|
|
return |
|
|
|
|
|
|
|
|
|
slot_list = [] |
|
|
|
|
|
|
|
|
@ -1049,7 +1061,7 @@ class CacheItemsStates: |
|
|
|
|
if not slot.present: |
|
|
|
|
continue |
|
|
|
|
|
|
|
|
|
if slot.item_id in self.needed_items: |
|
|
|
|
if slot.item_id in items.NEEDED_ITEMS: |
|
|
|
|
continue |
|
|
|
|
|
|
|
|
|
if slot_num in self.skip_slots: |
|
|
|
@ -1060,7 +1072,7 @@ class CacheItemsStates: |
|
|
|
|
slot_list.sort(key=lambda x: x[1].item_count, reverse=True) |
|
|
|
|
|
|
|
|
|
for slot_num, slot in slot_list: |
|
|
|
|
if slot.item_id in self.wanted_items and slot.item_id not in self.skip_items: |
|
|
|
|
if slot.item_id in items.WANTED_ITEMS and slot.item_id not in self.skip_items: |
|
|
|
|
print('skipping wanted item', slot) |
|
|
|
|
self.skip_slots.append(slot_num) |
|
|
|
|
self.skip_items.append(slot.item_id) |
|
|
|
@ -1094,14 +1106,8 @@ class CacheItemsStates: |
|
|
|
|
self.g = global_state |
|
|
|
|
self.state = self.idle |
|
|
|
|
|
|
|
|
|
self.minimum = 27 |
|
|
|
|
self.silent = False |
|
|
|
|
|
|
|
|
|
# keep all needed items |
|
|
|
|
self.needed_items = items.NEEDED_ITEMS |
|
|
|
|
# keep one stack of wanted items |
|
|
|
|
self.wanted_items = items.WANTED_ITEMS |
|
|
|
|
|
|
|
|
|
self.skip_slots = [] |
|
|
|
|
self.skip_items = [] |
|
|
|
|
|
|
|
|
@ -1121,8 +1127,16 @@ class GrabSuppliesStates: |
|
|
|
|
return None |
|
|
|
|
|
|
|
|
|
def init(self): |
|
|
|
|
print('Started grab supplies states') |
|
|
|
|
self.checked_barrels = [] |
|
|
|
|
|
|
|
|
|
used_slots = self.g.game.count_inventory_slots() |
|
|
|
|
print('used:', used_slots, 'total:', self.g.maximum_supply_slots) |
|
|
|
|
if used_slots >= self.g.maximum_supply_slots: |
|
|
|
|
print('Inventory is too full, aborting') |
|
|
|
|
self.state = self.cleanup |
|
|
|
|
return |
|
|
|
|
|
|
|
|
|
if self.supplies: |
|
|
|
|
self.state = self.check_supplies |
|
|
|
|
else: |
|
|
|
@ -1221,12 +1235,12 @@ class GrabSuppliesStates: |
|
|
|
|
def choose_items(self): |
|
|
|
|
print('Selecting next item') |
|
|
|
|
for items, limits in self.supplies.items(): |
|
|
|
|
minimum, maximum = limits |
|
|
|
|
minimum_items, maximum_stacks = limits |
|
|
|
|
print('Checking items:', items) |
|
|
|
|
num_items = self.g.game.count_items(items) |
|
|
|
|
print('Have:', num_items) |
|
|
|
|
|
|
|
|
|
if num_items >= minimum: |
|
|
|
|
if num_items >= minimum_items: |
|
|
|
|
print('Have enough, skipping') |
|
|
|
|
continue |
|
|
|
|
|
|
|
|
@ -1237,7 +1251,7 @@ class GrabSuppliesStates: |
|
|
|
|
print('Need some') |
|
|
|
|
self.checked_supplies.append(items) |
|
|
|
|
self.target_items = items |
|
|
|
|
self.maximum_items = maximum |
|
|
|
|
self.maximum_stacks = maximum_stacks |
|
|
|
|
self.count = 0 |
|
|
|
|
self.state = self.grab_items |
|
|
|
|
return |
|
|
|
@ -1257,6 +1271,14 @@ class GrabSuppliesStates: |
|
|
|
|
print('Got wrong window, aborting') |
|
|
|
|
self.state = self.cleanup |
|
|
|
|
return |
|
|
|
|
used_slots = self.g.game.count_inventory_slots() |
|
|
|
|
print('used:', used_slots, 'total:', self.g.maximum_supply_slots) |
|
|
|
|
if used_slots >= self.g.maximum_supply_slots: |
|
|
|
|
print('Inventory is too full, aborting') |
|
|
|
|
self.g.game.close_window() |
|
|
|
|
self.g.look_at = None |
|
|
|
|
self.state = self.cleanup |
|
|
|
|
return |
|
|
|
|
|
|
|
|
|
w_info = mcdata.WINDOWS[w.data.window_type] |
|
|
|
|
w_container_slots = w_info.container |
|
|
|
@ -1273,7 +1295,7 @@ class GrabSuppliesStates: |
|
|
|
|
if slot.item_id not in self.target_items: |
|
|
|
|
continue |
|
|
|
|
|
|
|
|
|
if self.maximum_items and self.count >= self.maximum_items: |
|
|
|
|
if self.maximum_stacks and self.count >= self.maximum_stacks: |
|
|
|
|
break |
|
|
|
|
self.count += 1 |
|
|
|
|
|
|
|
|
@ -1291,7 +1313,6 @@ class GrabSuppliesStates: |
|
|
|
|
print('Closing barrel') |
|
|
|
|
self.g.game.close_window() |
|
|
|
|
self.g.look_at = None |
|
|
|
|
self.barrels.pop(0) |
|
|
|
|
self.state = self.choose_barrel |
|
|
|
|
|
|
|
|
|
def cleanup(self): |
|
|
|
@ -1312,7 +1333,7 @@ class GrabSuppliesStates: |
|
|
|
|
self.barrel = None |
|
|
|
|
self.checked_supplies = [] |
|
|
|
|
self.target_items = None |
|
|
|
|
self.maximum_items = 0 |
|
|
|
|
self.maximum_stacks = 0 |
|
|
|
|
self.count = 0 |
|
|
|
|
self.area = None |
|
|
|
|
self.opening = None |
|
|
|
@ -2160,6 +2181,8 @@ class JobStates: |
|
|
|
|
self.grab_supplies_states.supplies = { |
|
|
|
|
tuple(items.SHOVEL_IDS): (1, 9), |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
items.set_needed(items.SHOVEL_IDS) |
|
|
|
|
return machines |
|
|
|
|
|
|
|
|
|
def cache_items(self): |
|
|
|
@ -2200,6 +2223,9 @@ class JobStates: |
|
|
|
|
self.grab_supplies_states.supplies = { |
|
|
|
|
tuple(items.AXE_IDS): (1, 9), |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
items.set_needed(items.AXE_IDS) |
|
|
|
|
items.set_wanted(items.SAPLING_IDS) |
|
|
|
|
return machines |
|
|
|
|
|
|
|
|
|
def farm_wart(self): |
|
|
|
@ -2211,6 +2237,8 @@ class JobStates: |
|
|
|
|
] |
|
|
|
|
self.sleep_with_bed_states.silent = True |
|
|
|
|
self.cache_items_states.silent = True |
|
|
|
|
|
|
|
|
|
items.set_wanted(set([items.NETHERWART_ID])) |
|
|
|
|
return machines |
|
|
|
|
|
|
|
|
|
def farm_crop(self): |
|
|
|
@ -2222,6 +2250,13 @@ class JobStates: |
|
|
|
|
] |
|
|
|
|
self.sleep_with_bed_states.silent = True |
|
|
|
|
self.cache_items_states.silent = True |
|
|
|
|
|
|
|
|
|
items.set_wanted(set([ |
|
|
|
|
items.CARROT_ID, |
|
|
|
|
items.POTATO_ID, |
|
|
|
|
items.WHEAT_SEEDS_ID, |
|
|
|
|
items.BEETROOT_SEEDS_ID, |
|
|
|
|
])) |
|
|
|
|
return machines |
|
|
|
|
|
|
|
|
|
def fill_blocks(self): |
|
|
|
@ -2266,7 +2301,17 @@ class JobStates: |
|
|
|
|
tuple([items.PUMPKIN_ID]): (64, 9), |
|
|
|
|
tuple([items.BERRIES_ID]): (64, 9), |
|
|
|
|
tuple([items.IRON_INGOT_ID]): (64, 9), |
|
|
|
|
tuple([items.WHEAT_ID]): (64, 9), |
|
|
|
|
tuple([items.POTATO_ID]): (64, 9), |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
items.set_needed(set([ |
|
|
|
|
items.PUMPKIN_ID, |
|
|
|
|
items.BERRIES_ID, |
|
|
|
|
items.IRON_INGOT_ID, |
|
|
|
|
items.WHEAT_ID, |
|
|
|
|
items.POTATO_ID, |
|
|
|
|
])) |
|
|
|
|
return machines |
|
|
|
|
|
|
|
|
|
def stop(self): |
|
|
|
|