Apply sign work zones before candidate routing
This commit is contained in:
@@ -92,10 +92,12 @@ class GatherCropStates:
|
||||
blocks.MATURE_BEETROOT_ID,
|
||||
]
|
||||
|
||||
candidates = w.find_blocks_indexed(p, mature_crops, 50)
|
||||
candidates = w.filter_work_positions(
|
||||
w.find_blocks_indexed(p, mature_crops, 50))
|
||||
crop_ids = (blocks.WHEAT_IDS | blocks.POTATO_IDS |
|
||||
blocks.CARROT_IDS | blocks.BEETROOT_IDS)
|
||||
crop_positions = w.find_blocks_indexed(p, crop_ids, 50)
|
||||
crop_positions = w.filter_work_positions(
|
||||
w.find_blocks_indexed(p, crop_ids, 50))
|
||||
crop_types = {
|
||||
position: blocks.BLOCKS.get(w.block_at(*position))
|
||||
for position in crop_positions
|
||||
|
||||
@@ -61,12 +61,13 @@ class GatherSandStates:
|
||||
head = utils.padd(p, path.BLOCK_ABOVE)
|
||||
|
||||
for sand in w.find_sand(self.slice, 2, p):
|
||||
if sand not in self.bad_sand:
|
||||
if (sand not in self.bad_sand and
|
||||
w.work_position_allowed(sand)):
|
||||
print('Found sand:', sand)
|
||||
break
|
||||
else: # for
|
||||
print('No good sands left, aborting.')
|
||||
self.state = self.cleanup
|
||||
print('No in-bounds sand left in this slice; trying another.')
|
||||
self.state = self.find_new_slice
|
||||
return
|
||||
|
||||
self.sand = sand
|
||||
|
||||
@@ -30,7 +30,8 @@ class GatherWartStates:
|
||||
|
||||
mature_wart = max(blocks.NETHERWART_IDS)
|
||||
for wart in w.find_blocks_3d(p, [mature_wart], 50, 20, True):
|
||||
if wart not in self.bad_warts:
|
||||
if (wart not in self.bad_warts and
|
||||
w.work_position_allowed(wart)):
|
||||
break
|
||||
else: # for
|
||||
print('No good warts left, aborting.')
|
||||
|
||||
@@ -30,10 +30,11 @@ class GatherWoodStates:
|
||||
w = self.g.world
|
||||
p = utils.pint(self.g.pos)
|
||||
|
||||
for tree in w.find_trees(p, 100):
|
||||
print('Found tree:', tree)
|
||||
trees = w.filter_work_positions(w.find_trees(p, 100))
|
||||
for tree in trees:
|
||||
if tree in self.bad_trees:
|
||||
continue
|
||||
print('Found tree:', tree)
|
||||
tree_type = blocks.BLOCKS[w.block_at(*tree)].replace('_log', '')
|
||||
if items.get_sapling_id(tree_type) is None:
|
||||
print('No plantable sapling for', tree_type, '- skipping')
|
||||
@@ -53,7 +54,10 @@ class GatherWoodStates:
|
||||
|
||||
def find_openings(self):
|
||||
w = self.g.world
|
||||
self.openings = w.find_tree_openings(self.tree)
|
||||
self.openings = [
|
||||
opening for opening in w.find_tree_openings(self.tree)
|
||||
if w.work_position_allowed(opening)
|
||||
]
|
||||
self.state = self.choose_opening
|
||||
|
||||
def choose_opening(self):
|
||||
|
||||
@@ -44,6 +44,8 @@ class GrabSaplingStates:
|
||||
|
||||
if s.entity_id in self.eid_blacklist:
|
||||
continue
|
||||
if not w.work_position_allowed(s_pos):
|
||||
continue
|
||||
|
||||
# skip if the sapling is floating
|
||||
if self.g.chunks.get_block_at(*check) in blocks.LEAF_IDS | {0}:
|
||||
|
||||
@@ -80,6 +80,8 @@ class PlantTreeStates:
|
||||
p = utils.pint(self.g.pos)
|
||||
|
||||
for opening in w.find_tree_openings(p)[::-1]:
|
||||
if not w.work_position_allowed(opening):
|
||||
continue
|
||||
print('trying sapling opening', opening)
|
||||
navpath = w.path_to_place(p, opening)
|
||||
if navpath:
|
||||
|
||||
Reference in New Issue
Block a user