Redefine what trees are
This commit is contained in:
parent
93c1ab7c0a
commit
c49ce127b9
34
game.py
34
game.py
|
@ -97,30 +97,35 @@ class MCWorld:
|
||||||
# crawl to the bottom log
|
# crawl to the bottom log
|
||||||
while self.block_at(*utils.padd(log, path.BLOCK_BELOW)) in blocks.LOG_IDS:
|
while self.block_at(*utils.padd(log, path.BLOCK_BELOW)) in blocks.LOG_IDS:
|
||||||
log = utils.padd(log, path.BLOCK_BELOW)
|
log = utils.padd(log, path.BLOCK_BELOW)
|
||||||
|
base = log
|
||||||
|
|
||||||
# make sure we are on the ground
|
if base in found_trees:
|
||||||
if self.block_at(*utils.padd(log, path.BLOCK_BELOW)) in blocks.NON_SOLID_IDS:
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# crawl to the top log to count
|
# make sure we are on the ground
|
||||||
|
if self.block_at(*utils.padd(base, path.BLOCK_BELOW)) in blocks.NON_SOLID_IDS:
|
||||||
|
continue
|
||||||
|
|
||||||
|
# crawl to the top log to count and check leaves
|
||||||
log_count = 1
|
log_count = 1
|
||||||
|
good_leaves = False
|
||||||
while self.block_at(*utils.padd(log, path.BLOCK_ABOVE)) in blocks.LOG_IDS:
|
while self.block_at(*utils.padd(log, path.BLOCK_ABOVE)) in blocks.LOG_IDS:
|
||||||
log = utils.padd(log, path.BLOCK_ABOVE)
|
log = utils.padd(log, path.BLOCK_ABOVE)
|
||||||
log_count += 1
|
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
|
# 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
|
continue
|
||||||
|
|
||||||
# crawl back to the bottom log
|
found_trees.append(base)
|
||||||
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:
|
yield base
|
||||||
continue
|
|
||||||
found_trees.append(log)
|
|
||||||
|
|
||||||
yield log
|
|
||||||
|
|
||||||
def find_tree_openings(self, tree):
|
def find_tree_openings(self, tree):
|
||||||
# returns coords in a cardinal direction where we can stand by tree
|
# returns coords in a cardinal direction where we can stand by tree
|
||||||
|
@ -577,6 +582,11 @@ class Game:
|
||||||
else:
|
else:
|
||||||
reply = '/afk'
|
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 ##########################
|
################# Specific commands ##########################
|
||||||
if for_me:
|
if for_me:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user