|
|
|
@ -55,10 +55,10 @@ class LumberjackStates: |
|
|
|
|
self.state = self.cleanup |
|
|
|
|
return |
|
|
|
|
|
|
|
|
|
path = w.path_to_place(p, self.openings[0]) |
|
|
|
|
navpath = w.path_to_place(p, self.openings[0]) |
|
|
|
|
|
|
|
|
|
if path: |
|
|
|
|
self.g.path = path |
|
|
|
|
if navpath: |
|
|
|
|
self.g.path = navpath |
|
|
|
|
self.state = self.going_to_tree |
|
|
|
|
else: |
|
|
|
|
self.openings.pop(0) |
|
|
|
@ -71,10 +71,10 @@ class LumberjackStates: |
|
|
|
|
def clear_leaves(self): |
|
|
|
|
if not self.g.breaking: |
|
|
|
|
p = utils.pint(self.g.pos) |
|
|
|
|
diff = psub(self.tree, p) |
|
|
|
|
diff = utils.psub(self.tree, p) |
|
|
|
|
|
|
|
|
|
for x in diffrange(diff[0]): |
|
|
|
|
for z in diffrange(diff[2]): |
|
|
|
|
for x in utils.diffrange(diff[0]): |
|
|
|
|
for z in utils.diffrange(diff[2]): |
|
|
|
|
for y in range(2): |
|
|
|
|
check = utils.padd(p, (x, y, z)) |
|
|
|
|
if check == self.tree: |
|
|
|
@ -100,10 +100,10 @@ class LumberjackStates: |
|
|
|
|
else: |
|
|
|
|
w = self.g.world |
|
|
|
|
p = utils.pint(self.g.pos) |
|
|
|
|
path = w.path_to_place(p, self.tree) |
|
|
|
|
navpath = w.path_to_place(p, self.tree) |
|
|
|
|
|
|
|
|
|
if path: |
|
|
|
|
self.g.path = path |
|
|
|
|
if navpath: |
|
|
|
|
self.g.path = navpath |
|
|
|
|
self.state = self.going_to_trunk_base |
|
|
|
|
else: |
|
|
|
|
self.openings.pop(0) |
|
|
|
@ -134,7 +134,7 @@ class LumberjackStates: |
|
|
|
|
def wait(self): |
|
|
|
|
# wait for the last log to fall |
|
|
|
|
if self.wait_time > 0: |
|
|
|
|
self.wait_time -= TICK |
|
|
|
|
self.wait_time -= utils.TICK |
|
|
|
|
else: |
|
|
|
|
self.state = self.cleanup |
|
|
|
|
|
|
|
|
@ -149,7 +149,6 @@ class LumberjackStates: |
|
|
|
|
|
|
|
|
|
def __init__(self, global_state): |
|
|
|
|
self.g = global_state |
|
|
|
|
self.l = self.g.local_state |
|
|
|
|
self.state = self.idle |
|
|
|
|
|
|
|
|
|
self.tree = None |
|
|
|
@ -193,11 +192,11 @@ class GatherSandStates: |
|
|
|
|
p = utils.pint(self.g.pos) |
|
|
|
|
|
|
|
|
|
w.chunks.set_block_at(*self.sand, 0) |
|
|
|
|
path = w.path_to_place(p, self.sand) |
|
|
|
|
navpath = w.path_to_place(p, self.sand) |
|
|
|
|
w.chunks.set_block_at(*self.sand, 66) |
|
|
|
|
|
|
|
|
|
if path: |
|
|
|
|
self.g.path = path[:-1] |
|
|
|
|
if navpath: |
|
|
|
|
self.g.path = navpath[:-1] |
|
|
|
|
self.state = self.going_to_sand |
|
|
|
|
else: |
|
|
|
|
self.bad_sand.append(self.sand) |
|
|
|
@ -219,10 +218,10 @@ class GatherSandStates: |
|
|
|
|
def get_sand(self): |
|
|
|
|
w = self.g.world |
|
|
|
|
p = utils.pint(self.g.pos) |
|
|
|
|
path = w.path_to_place(p, self.sand) |
|
|
|
|
navpath = w.path_to_place(p, self.sand) |
|
|
|
|
|
|
|
|
|
if path: |
|
|
|
|
self.g.path = path |
|
|
|
|
if navpath: |
|
|
|
|
self.g.path = navpath |
|
|
|
|
self.state = self.going_to_item |
|
|
|
|
else: |
|
|
|
|
self.bad_sand.append(self.sand) |
|
|
|
@ -244,7 +243,6 @@ class GatherSandStates: |
|
|
|
|
|
|
|
|
|
def __init__(self, global_state): |
|
|
|
|
self.g = global_state |
|
|
|
|
self.l = self.g.local_state |
|
|
|
|
self.state = self.idle |
|
|
|
|
|
|
|
|
|
self.origin = utils.pint(self.g.pos) |
|
|
|
@ -289,16 +287,16 @@ class SleepWithBedStates: |
|
|
|
|
openings = w.find_bed_openings(self.area) |
|
|
|
|
|
|
|
|
|
for o in openings: |
|
|
|
|
path = w.path_to_place(p, o) |
|
|
|
|
navpath = w.path_to_place(p, o) |
|
|
|
|
self.opening = o |
|
|
|
|
if path: break |
|
|
|
|
if navpath: break |
|
|
|
|
else: # for |
|
|
|
|
print('Unable to get to bed area', self.area) |
|
|
|
|
self.bad_areas.append(self.area) |
|
|
|
|
self.state = self.cleanup |
|
|
|
|
return |
|
|
|
|
|
|
|
|
|
self.g.path = path |
|
|
|
|
self.g.path = navpath |
|
|
|
|
self.state = self.going_to_area |
|
|
|
|
self.last_area = self.area |
|
|
|
|
|
|
|
|
@ -348,7 +346,7 @@ class SleepWithBedStates: |
|
|
|
|
def wait(self): |
|
|
|
|
# wait to pick up bed |
|
|
|
|
if self.wait_time > 0: |
|
|
|
|
self.wait_time -= TICK |
|
|
|
|
self.wait_time -= utils.TICK |
|
|
|
|
else: |
|
|
|
|
self.state = self.cleanup |
|
|
|
|
|
|
|
|
@ -362,7 +360,6 @@ class SleepWithBedStates: |
|
|
|
|
|
|
|
|
|
def __init__(self, global_state): |
|
|
|
|
self.g = global_state |
|
|
|
|
self.l = self.g.local_state |
|
|
|
|
self.state = self.idle |
|
|
|
|
|
|
|
|
|
self.area = None |
|
|
|
@ -432,7 +429,6 @@ class JobStates: |
|
|
|
|
|
|
|
|
|
def __init__(self, global_state): |
|
|
|
|
self.g = global_state |
|
|
|
|
self.l = self.g.local_state |
|
|
|
|
|
|
|
|
|
self.state = self.idle |
|
|
|
|
self.prev_state = None |
|
|
|
@ -441,5 +437,5 @@ class JobStates: |
|
|
|
|
self.sleep_with_bed_states = SleepWithBedStates(self.g) |
|
|
|
|
self.survive = False |
|
|
|
|
|
|
|
|
|
def run(self): |
|
|
|
|
def tick(self): |
|
|
|
|
self.state() |
|
|
|
|