Batch crop farming and stop on unreachable barrels
This commit is contained in:
@@ -17,6 +17,8 @@ from mosfet.info import mcdata
|
||||
from mosfet.info import mobs
|
||||
|
||||
class GatherCropStates:
|
||||
CROPS_PER_BATCH = 16
|
||||
|
||||
def idle(self):
|
||||
return None
|
||||
|
||||
@@ -216,7 +218,14 @@ class GatherCropStates:
|
||||
blocks.BLOCKS.get(current_state) == crop_name and
|
||||
current_state != self.type_id)
|
||||
if replanted:
|
||||
self.state = self.cleanup
|
||||
self.completed_crops += 1
|
||||
if self.completed_crops >= self.CROPS_PER_BATCH:
|
||||
print('Completed {} crop harvests; running maintenance'.format(
|
||||
self.completed_crops))
|
||||
self.completed_crops = 0
|
||||
self.state = self.cleanup
|
||||
else:
|
||||
self.state = self.find_new_crop
|
||||
elif time.time() > getattr(self, 'place_deadline', 0):
|
||||
print('Crop did not replant; blacklisting', self.crop)
|
||||
self.bad_crops.append(self.crop)
|
||||
@@ -242,6 +251,7 @@ class GatherCropStates:
|
||||
self.active_section_anchor = None
|
||||
self.retry_after = 0.0
|
||||
self.bad_crops = []
|
||||
self.completed_crops = 0
|
||||
|
||||
def run(self):
|
||||
self.state()
|
||||
|
||||
@@ -242,13 +242,9 @@ class GrabSuppliesStates:
|
||||
self.checked_supplies = []
|
||||
return
|
||||
else:
|
||||
print('No path, blacklisting barrel')
|
||||
time.sleep(0.1)
|
||||
print('Barrel is unreachable; ending supply task')
|
||||
self.bad_barrels.append(self.barrel)
|
||||
if len(self.bad_barrels) > 3:
|
||||
self.state = self.cleanup
|
||||
else:
|
||||
self.state = self.choose_barrel
|
||||
self.state = self.cleanup
|
||||
|
||||
def going_to_barrel(self):
|
||||
if utils.pint(self.g.pos) == self.opening:
|
||||
|
||||
Reference in New Issue
Block a user