|
|
|
@ -305,13 +305,13 @@ class GatherSandStates: |
|
|
|
|
print('Finding new slice...') |
|
|
|
|
w = self.g.world |
|
|
|
|
|
|
|
|
|
#o = utils.padd(self.origin, (0, 10, 0)) |
|
|
|
|
print('using origin', self.origin) |
|
|
|
|
self.skip, s = w.find_sand_slice(self.origin, 50) |
|
|
|
|
print('Found slice:', s, 'skip:', self.skip) |
|
|
|
|
s = w.find_sand_slice(self.origin, 50, self.bad_slices) |
|
|
|
|
print('Found slice:', s) |
|
|
|
|
|
|
|
|
|
if s: |
|
|
|
|
self.slice = s |
|
|
|
|
#self.bad_slices.append(s) |
|
|
|
|
self.state = self.find_new_sand |
|
|
|
|
else: |
|
|
|
|
print('No slices remaining.') |
|
|
|
@ -385,8 +385,8 @@ class GatherSandStates: |
|
|
|
|
self.state = self.idle |
|
|
|
|
|
|
|
|
|
self.origin = utils.pint(self.g.pos) |
|
|
|
|
self.skip = (0, 0) |
|
|
|
|
self.slice = None |
|
|
|
|
self.bad_slices = [] |
|
|
|
|
self.sand = None |
|
|
|
|
self.bad_sand = [] |
|
|
|
|
self.wait_time = 0 |
|
|
|
@ -422,11 +422,13 @@ class GrabSandStates: |
|
|
|
|
|
|
|
|
|
if utils.phyp(p, s_pos) > 6: |
|
|
|
|
continue |
|
|
|
|
if s.entity_id in self.eid_blacklist: |
|
|
|
|
continue |
|
|
|
|
# skip if the sand is floating |
|
|
|
|
if self.g.chunks.get_block_at(*check) in {0}: |
|
|
|
|
continue |
|
|
|
|
if s.entity_id in self.eid_blacklist: |
|
|
|
|
continue |
|
|
|
|
|
|
|
|
|
self.eid_blacklist.append(s.entity_id) |
|
|
|
|
|
|
|
|
|
navpath = w.path_to_place(p, s_pos) |
|
|
|
|
|
|
|
|
@ -434,16 +436,17 @@ class GrabSandStates: |
|
|
|
|
self.g.path = navpath |
|
|
|
|
self.state = self.going_to_sand |
|
|
|
|
self.sand = s_pos |
|
|
|
|
self.eid_blacklist.append(s.entity_id) |
|
|
|
|
print('Going to sand', self.sand) |
|
|
|
|
return |
|
|
|
|
else: |
|
|
|
|
print('Cant get to sand', self.sand) |
|
|
|
|
|
|
|
|
|
print('Cant get to any more sand, aborting') |
|
|
|
|
self.state = self.cleanup |
|
|
|
|
|
|
|
|
|
def going_to_sand(self): |
|
|
|
|
if utils.pint(self.g.pos) == self.sand: |
|
|
|
|
self.state = self.find_sand |
|
|
|
|
self.state = self.cleanup |
|
|
|
|
|
|
|
|
|
def cleanup(self): |
|
|
|
|
self.g.look_at = None |
|
|
|
@ -607,7 +610,7 @@ class CacheItemsStates: |
|
|
|
|
|
|
|
|
|
if not len(self.trapped_chests): |
|
|
|
|
print('No trapped chests') |
|
|
|
|
self.state = self.find_cache_spot |
|
|
|
|
self.state = self.select_chest |
|
|
|
|
return |
|
|
|
|
|
|
|
|
|
chest = self.trapped_chests[0] |
|
|
|
@ -634,6 +637,14 @@ class CacheItemsStates: |
|
|
|
|
self.state = self.open_chest |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def select_chest(self): |
|
|
|
|
if self.g.game.select_item(items.CHEST_ID): |
|
|
|
|
self.g.look_at = utils.padd(self.area, path.BLOCK_BELOW) |
|
|
|
|
self.state = self.find_cache_spot |
|
|
|
|
else: |
|
|
|
|
print('No chest, aborting') |
|
|
|
|
self.state = self.cleanup |
|
|
|
|
|
|
|
|
|
def find_cache_spot(self): |
|
|
|
|
print('Finding a chest spot...') |
|
|
|
|
w = self.g.world |
|
|
|
@ -667,15 +678,7 @@ class CacheItemsStates: |
|
|
|
|
def going_to_area(self): |
|
|
|
|
if utils.pint(self.g.pos) == self.opening: |
|
|
|
|
self.g.look_at = self.area |
|
|
|
|
self.state = self.select_chest |
|
|
|
|
|
|
|
|
|
def select_chest(self): |
|
|
|
|
if self.g.game.select_item(items.CHEST_ID): |
|
|
|
|
self.g.look_at = utils.padd(self.area, path.BLOCK_BELOW) |
|
|
|
|
self.state = self.place_chest |
|
|
|
|
else: |
|
|
|
|
print('No chest, aborting') |
|
|
|
|
self.state = self.cleanup |
|
|
|
|
|
|
|
|
|
def place_chest(self): |
|
|
|
|
self.g.game.place_block(self.area, BlockFace.TOP) |
|
|
|
|