Port over job sleeping

This commit is contained in:
2020-09-16 20:11:42 -06:00
parent 58458a561f
commit f2e0b162f9
4 changed files with 85 additions and 19 deletions
+13 -14
View File
@@ -13,6 +13,8 @@ import path
importlib.reload(path)
import blocks
importlib.reload(blocks)
import items
importlib.reload(items)
class LumberjackStates:
@@ -310,22 +312,22 @@ class SleepWithBedStates:
if item.item_id in items.BED_IDS:
print('Found bed in slot', slot)
self.g.look_at = utils.padd(self.area, path.BLOCK_BELOW)
choose_slot(self.connection, slot)
self.g.game.choose_slot(slot)
self.state = self.place_bed
break
else: # for
say(self.connection, 'I need a bed')
self.g.chat.send('I need a bed')
self.state = self.cleanup
def place_bed(self):
place_block(self.connection, self.area, BlockFace.TOP)
self.g.game.place_block(self.area, BlockFace.TOP)
self.state = self.use_bed
def use_bed(self):
if self.g.time >= 12542:
print('Sleeping')
place_block(self.connection, self.area, BlockFace.TOP)
say(self.connection, 'zzz')
self.g.game.place_block(self.area, BlockFace.TOP)
self.g.chat.send('zzz')
self.state = self.sleep_bed
def sleep_bed(self):
@@ -399,10 +401,9 @@ class JobStates:
s.state = s.init
# check time, etc
if self.survive:
self.prev_state = self.gather_sand
self.state = self.sleep_with_bed
return
self.prev_state = self.gather_sand
self.state = self.sleep_with_bed
return
s.run()
@@ -414,10 +415,9 @@ class JobStates:
s.state = s.init
# check time, etc
if self.survive:
self.prev_state = self.lumberjack
self.state = self.sleep_with_bed
return
self.prev_state = self.lumberjack
self.state = self.sleep_with_bed
return
s.run()
@@ -435,7 +435,6 @@ class JobStates:
self.lumberjack_states = LumberjackStates(self.g)
self.gather_sand_states = GatherSandStates(self.g)
self.sleep_with_bed_states = SleepWithBedStates(self.g)
self.survive = False
def tick(self):
self.state()