diff --git a/bot.py b/bot.py index 0ee4698..482d160 100644 --- a/bot.py +++ b/bot.py @@ -101,6 +101,10 @@ def tick(global_state): target.x += 0.5 target.z += 0.5 + if g.afk_timeout > 0: + target = None + g.afk_timeout -= utils.TICK + if target: d = p - target @@ -205,7 +209,7 @@ def init(global_state): g.job = jobs.JobStates(g) g.chopped_tree = False - g.queue_afk = False + g.afk_timeout = 0 g.filling = False diff --git a/game.py b/game.py index 29663a2..137104e 100644 --- a/game.py +++ b/game.py @@ -578,12 +578,8 @@ class Game: if command == 'zzz': if not self.g.afk and self.g.dimension == 'overworld': - if self.g.path: - travel_time = int(len(self.g.path) * 0.4) + 2 - reply = 'gimme ' + str(travel_time) + ' secs, moving' - self.g.queue_afk = True - else: - reply = '/afk' + reply = '/afk' + self.g.afk_timeout = 5.0 if command == 'tree': pos = utils.pint(self.g.pos) @@ -1101,8 +1097,3 @@ class Game: if not self.g.path: self.g.correction_count = 0 - - if self.g.queue_afk: - self.g.chat.send('/afk') - self.g.queue_afk = False - diff --git a/items.py b/items.py index 786896f..bda11d0 100644 --- a/items.py +++ b/items.py @@ -82,5 +82,5 @@ POTATO_ID = get_id('potato') WHEAT_SEEDS_ID = get_id('wheat_seeds') BEETROOT_SEEDS_ID = get_id('beetroot_seeds') -NEEDED_ITEMS = BED_IDS | set([CHEST_ID]) +NEEDED_ITEMS = BED_IDS | SHOVEL_IDS | AXE_IDS | set([CHEST_ID]) WANTED_ITEMS = SAPLING_IDS | set([NETHERWART_ID, CARROT_ID, POTATO_ID, WHEAT_SEEDS_ID, BEETROOT_SEEDS_ID]) diff --git a/jobs.py b/jobs.py index 3d450ca..ee27866 100644 --- a/jobs.py +++ b/jobs.py @@ -364,6 +364,10 @@ class GatherWoodStates: def init(self): self.g.chopped_tree = False + self.state = self.select_axe + + def select_axe(self): + self.g.game.select_item(items.AXE_IDS) self.state = self.find_new_tree def find_new_tree(self): @@ -647,7 +651,7 @@ class GrabSandStates: w = self.g.world p = utils.pint(self.g.pos) - sand = w.find_objects(items.SAND_ID) + sand = w.find_objects([items.SAND_ID]) if not sand: print('No sand objects found, aborting') @@ -771,7 +775,7 @@ class SleepWithBedStates: self.state = self.use_bed def use_bed(self): - if self.g.time >= 12542: + if self.g.time > 12550: print('Sleeping') self.g.game.place_block(self.area, BlockFace.TOP) if not self.silent: @@ -798,7 +802,7 @@ class SleepWithBedStates: def collect_bed(self): if not self.g.breaking: self.g.path = [utils.padd(self.area, utils.spiral(n)) for n in range(9)] - self.wait_time = 4 + self.wait_time = 2 self.state = self.wait def wait(self): @@ -1101,7 +1105,7 @@ class GrabSuppliesStates: self.state = self.going_to_barrel return else: - self.barrel.pop(0) + self.barrels.pop(0) def going_to_barrel(self): if utils.pint(self.g.pos) == self.opening: @@ -1140,7 +1144,7 @@ class GrabSuppliesStates: if slot.item_id not in self.target_items: continue - if self.count >= self.maximum_items: + if self.maximum_items and self.count >= self.maximum_items: break self.count += 1 @@ -1743,6 +1747,7 @@ class JobStates: def farm_sand(self): machines = [ + self.grab_supplies_states, self.check_threats_states, self.gather_sand_states, self.grab_sand_states, @@ -1751,6 +1756,9 @@ class JobStates: ] self.sleep_with_bed_states.silent = True self.cache_items_states.silent = True + self.grab_supplies_states.supplies = { + tuple(items.SHOVEL_IDS): 9 + } return machines def cache_items(self):