Only try to sleep in one existing bed

This commit is contained in:
Tanner Collin 2021-04-17 20:59:06 +00:00
parent ef68956e63
commit daf152389a
1 changed files with 12 additions and 1 deletions

13
jobs.py
View File

@ -739,7 +739,13 @@ class SleepWithBedStates:
w = self.g.world
p = utils.pint(self.g.pos)
self.beds = w.find_blocks_indexed(p, blocks.BED_IDS)
result = w.find_blocks_indexed(p, blocks.BED_IDS)
self.beds = []
for bed in result:
if bed not in self.beds and bed not in self.bad_beds:
self.beds.append(bed)
print('Found:', self.beds)
self.state = self.choose_bed
@ -755,6 +761,7 @@ class SleepWithBedStates:
return
bed = self.beds[0]
print('Chose:', bed)
tmp = c.get_block_at(*bed)
c.set_block_at(*bed, blocks.AIR)
@ -771,6 +778,9 @@ class SleepWithBedStates:
return
else:
self.beds.pop(0)
self.bad_beds.append(bed)
print('Cant get to bed, blacklisting')
self.state = self.select_bed
def going_to_bed(self):
if utils.pint(self.g.pos) == self.opening:
@ -884,6 +894,7 @@ class SleepWithBedStates:
self.my_bed = False
self.beds = []
self.bad_beds = []
self.area = None
self.opening = None
self.bad_areas = []