Compare commits
3 Commits
261684ea90
...
master
Author | SHA1 | Date | |
---|---|---|---|
bbe2d9f99c | |||
2f77c7b990 | |||
3540e5580e |
@@ -72,14 +72,6 @@ class GatherCropStates:
|
|||||||
|
|
||||||
def break_crop(self):
|
def break_crop(self):
|
||||||
self.g.game.break_block(self.crop)
|
self.g.game.break_block(self.crop)
|
||||||
self.wait_time = 0.5
|
|
||||||
self.state = self.wait
|
|
||||||
|
|
||||||
def wait(self):
|
|
||||||
# wait for the item
|
|
||||||
if self.wait_time > 0:
|
|
||||||
self.wait_time -= utils.TICK
|
|
||||||
else:
|
|
||||||
self.state = self.select_seed
|
self.state = self.select_seed
|
||||||
|
|
||||||
def select_seed(self):
|
def select_seed(self):
|
||||||
@@ -91,18 +83,17 @@ class GatherCropStates:
|
|||||||
blocks.MATURE_CARROT_ID: items.CARROT_ID,
|
blocks.MATURE_CARROT_ID: items.CARROT_ID,
|
||||||
blocks.MATURE_BEETROOT_ID: items.BEETROOT_SEEDS_ID,
|
blocks.MATURE_BEETROOT_ID: items.BEETROOT_SEEDS_ID,
|
||||||
}
|
}
|
||||||
|
self.target_seed = crop_seeds[self.type_id]
|
||||||
|
|
||||||
if self.g.game.select_item([crop_seeds[self.type_id]]):
|
if self.g.game.select_item([self.target_seed]):
|
||||||
self.state = self.wait_select
|
self.state = self.wait_select
|
||||||
self.wait_time = 0.5
|
|
||||||
else:
|
else:
|
||||||
print('Aborting planting, no crop')
|
print('Havent picked up seed yet')
|
||||||
self.state = self.cleanup
|
return
|
||||||
|
|
||||||
def wait_select(self):
|
def wait_select(self):
|
||||||
# wait a bit to select
|
if self.target_seed != self.g.holding:
|
||||||
if self.wait_time > 0:
|
return
|
||||||
self.wait_time -= utils.TICK
|
|
||||||
else:
|
else:
|
||||||
self.state = self.place_crop
|
self.state = self.place_crop
|
||||||
|
|
||||||
@@ -111,12 +102,11 @@ class GatherCropStates:
|
|||||||
self.g.game.place_block(p, BlockFace.TOP)
|
self.g.game.place_block(p, BlockFace.TOP)
|
||||||
print('Placed crop')
|
print('Placed crop')
|
||||||
self.state = self.wait_place
|
self.state = self.wait_place
|
||||||
self.wait_time = 0.5
|
|
||||||
|
|
||||||
def wait_place(self):
|
def wait_place(self):
|
||||||
# wait a bit for chunk data to update
|
w = self.g.world
|
||||||
if self.wait_time > 0:
|
if w.block_at(*self.crop) == blocks.AIR:
|
||||||
self.wait_time -= utils.TICK
|
return
|
||||||
else:
|
else:
|
||||||
self.state = self.cleanup
|
self.state = self.cleanup
|
||||||
|
|
||||||
@@ -134,8 +124,8 @@ class GatherCropStates:
|
|||||||
|
|
||||||
self.crop = None
|
self.crop = None
|
||||||
self.type_id = None
|
self.type_id = None
|
||||||
|
self.target_seed = None
|
||||||
self.bad_crops = []
|
self.bad_crops = []
|
||||||
self.wait_time = 0
|
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
self.state()
|
self.state()
|
||||||
|
@@ -312,6 +312,7 @@ class World:
|
|||||||
if utils.phyp(center, pos) > distance:
|
if utils.phyp(center, pos) > distance:
|
||||||
continue
|
continue
|
||||||
result.append(mob)
|
result.append(mob)
|
||||||
|
result.sort(key=lambda mob: utils.phyp(center, (mob.x, mob.y, mob.z)))
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def find_threats(self, center, distance):
|
def find_threats(self, center, distance):
|
||||||
@@ -324,6 +325,7 @@ class World:
|
|||||||
if not self.check_air_column(pos, distance):
|
if not self.check_air_column(pos, distance):
|
||||||
continue
|
continue
|
||||||
result.append(mob)
|
result.append(mob)
|
||||||
|
result.sort(key=lambda mob: utils.phyp(center, (mob.x, mob.y, mob.z)))
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def find_villagers(self, center, distance):
|
def find_villagers(self, center, distance):
|
||||||
@@ -336,6 +338,7 @@ class World:
|
|||||||
if utils.phyp(center, pos) > distance:
|
if utils.phyp(center, pos) > distance:
|
||||||
continue
|
continue
|
||||||
result.append(mob)
|
result.append(mob)
|
||||||
|
result.sort(key=lambda mob: utils.phyp(center, (mob.x, mob.y, mob.z)))
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def find_villager_openings(self, villager):
|
def find_villager_openings(self, villager):
|
||||||
|
Reference in New Issue
Block a user