Redefine what trees are

master
Tanner Collin 3 years ago
parent 93c1ab7c0a
commit c49ce127b9
  1. 32
      game.py

@ -97,30 +97,35 @@ class MCWorld:
# crawl to the bottom log
while self.block_at(*utils.padd(log, path.BLOCK_BELOW)) in blocks.LOG_IDS:
log = utils.padd(log, path.BLOCK_BELOW)
base = log
if base in found_trees:
continue
# make sure we are on the ground
if self.block_at(*utils.padd(log, path.BLOCK_BELOW)) in blocks.NON_SOLID_IDS:
if self.block_at(*utils.padd(base, path.BLOCK_BELOW)) in blocks.NON_SOLID_IDS:
continue
# crawl to the top log to count
# crawl to the top log to count and check leaves
log_count = 1
good_leaves = False
while self.block_at(*utils.padd(log, path.BLOCK_ABOVE)) in blocks.LOG_IDS:
log = utils.padd(log, path.BLOCK_ABOVE)
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
# make sure it's a good tree
if self.block_at(*utils.padd(log, path.BLOCK_ABOVE)) not in blocks.LEAF_IDS or log_count < 3:
if not good_leaves or log_count < 3:
continue
# crawl back to the bottom log
while self.block_at(*utils.padd(log, path.BLOCK_BELOW)) in blocks.LOG_IDS:
log = utils.padd(log, path.BLOCK_BELOW)
if log in found_trees:
continue
found_trees.append(log)
found_trees.append(base)
yield log
yield base
def find_tree_openings(self, tree):
# returns coords in a cardinal direction where we can stand by tree
@ -577,6 +582,11 @@ class Game:
else:
reply = '/afk'
if command == 'tree':
pos = utils.pint(self.g.pos)
tree = next(self.g.world.find_trees(pos, 50))
reply = str(tree)[1:-1]
################# Specific commands ##########################
if for_me:

Loading…
Cancel
Save