Program the bot to crawl, fix wood farming bugs

This commit is contained in:
2021-03-12 06:04:04 +00:00
parent e642e426b9
commit 2fa3044acb
3 changed files with 57 additions and 33 deletions
+8 -10
View File
@@ -117,10 +117,8 @@ class MCWorld:
log_count += 1
for offset in path.CHECK_DIRECTIONS:
if self.block_at(*utils.padd(log, offset)) not in blocks.LEAF_IDS:
break
else: # for:
good_leaves = True
if self.block_at(*utils.padd(log, offset)) in blocks.LEAF_IDS:
good_leaves = True
# make sure it's a good tree
if not good_leaves or log_count < 3:
@@ -132,7 +130,7 @@ class MCWorld:
def find_tree_openings(self, tree):
# returns coords in a cardinal direction where we can stand by tree
maze_solver = path.Pathfinder(self.g.chunks)
maze_solver = path.Pathfinder(self.g)
result = []
# TODO: make sure only non-solid and leaves between
@@ -146,7 +144,7 @@ class MCWorld:
return result
def path_to_place(self, start, place):
maze_solver = path.Pathfinder(self.g.chunks)
maze_solver = path.Pathfinder(self.g)
try:
s = maze_solver.astar(start, place)
@@ -155,8 +153,8 @@ class MCWorld:
return None
def find_bed_areas(self, center, distance):
bed_clearance = 25 # 5x5 area
clear_distance = 3
bed_clearance = 9 # 5x5 area
clear_distance = 2
for a in self.find_blocks_3d(center, [0], distance, 50):
# check for air around the area
@@ -324,7 +322,7 @@ class MCWorld:
def find_villager_openings(self, villager):
# returns coords in a cardinal direction where we can stand by a villager
maze_solver = path.Pathfinder(self.g.chunks)
maze_solver = path.Pathfinder(self.g)
result = []
for distance in range(3):
@@ -398,7 +396,7 @@ class Game:
print('new waypoint:', self.g.goal)
start = time.time()
solution = path.Pathfinder(self.g.chunks).astar(utils.pint(self.g.pos), utils.pint(self.g.goal))
solution = path.Pathfinder(self.g).astar(utils.pint(self.g.pos), utils.pint(self.g.goal))
if solution:
solution = list(solution)
self.g.path = solution