diff --git a/mosfet/jobs/gather_crop.py b/mosfet/jobs/gather_crop.py index f92cddd..883a178 100644 --- a/mosfet/jobs/gather_crop.py +++ b/mosfet/jobs/gather_crop.py @@ -72,13 +72,11 @@ class GatherCropStates: def break_crop(self): self.g.game.break_block(self.crop) - self.wait_time = 0.5 - self.state = self.wait + self.state = self.wait_for_item - def wait(self): - # wait for the item - if self.wait_time > 0: - self.wait_time -= utils.TICK + def wait_for_item(self): + if self.g.item_lock: + return else: self.state = self.select_seed @@ -91,18 +89,17 @@ class GatherCropStates: blocks.MATURE_CARROT_ID: items.CARROT_ID, blocks.MATURE_BEETROOT_ID: items.BEETROOT_SEEDS_ID, } + self.target_seed = crop_seeds[self.type_id] - if self.g.game.select_item([crop_seeds[self.type_id]]): + if self.g.game.select_item([self.target_seed]): self.state = self.wait_select - self.wait_time = 0.5 else: print('Aborting planting, no crop') self.state = self.cleanup def wait_select(self): - # wait a bit to select - if self.wait_time > 0: - self.wait_time -= utils.TICK + if self.target_seed != self.g.holding: + return else: self.state = self.place_crop @@ -111,12 +108,11 @@ class GatherCropStates: self.g.game.place_block(p, BlockFace.TOP) print('Placed crop') self.state = self.wait_place - self.wait_time = 0.5 def wait_place(self): - # wait a bit for chunk data to update - if self.wait_time > 0: - self.wait_time -= utils.TICK + w = self.g.world + if w.block_at(*self.crop) == blocks.AIR: + return else: self.state = self.cleanup @@ -134,8 +130,8 @@ class GatherCropStates: self.crop = None self.type_id = None + self.target_seed = None self.bad_crops = [] - self.wait_time = 0 def run(self): self.state()