Add function for faking blocks while pathing
This commit is contained in:
		@@ -54,11 +54,7 @@ class CacheItemsStates:
 | 
			
		||||
 | 
			
		||||
        chest = self.trapped_chests[0]
 | 
			
		||||
 | 
			
		||||
        tmp = c.get_block_at(*chest)
 | 
			
		||||
        c.set_block_at(*chest, blocks.AIR)
 | 
			
		||||
        navpath = w.path_to_place(p, chest)
 | 
			
		||||
        c.set_block_at(*chest, tmp)
 | 
			
		||||
 | 
			
		||||
        navpath = w.path_to_place_faked(p, chest)
 | 
			
		||||
        print('navpath:', navpath)
 | 
			
		||||
 | 
			
		||||
        if navpath:
 | 
			
		||||
 
 | 
			
		||||
@@ -81,10 +81,8 @@ class GatherSandStates:
 | 
			
		||||
        p = utils.pint(self.g.pos)
 | 
			
		||||
        c = self.g.chunks
 | 
			
		||||
 | 
			
		||||
        tmp = c.get_block_at(*self.sand)
 | 
			
		||||
        c.set_block_at(*self.sand, blocks.AIR)
 | 
			
		||||
        navpath = w.path_to_place(p, self.sand)
 | 
			
		||||
        c.set_block_at(*self.sand, tmp)
 | 
			
		||||
        navpath = w.path_to_place_faked(p, self.sand)
 | 
			
		||||
        print('navpath:', navpath)
 | 
			
		||||
 | 
			
		||||
        if navpath:
 | 
			
		||||
            self.g.path = navpath[:-1]
 | 
			
		||||
 
 | 
			
		||||
@@ -61,7 +61,7 @@ class GrabSuppliesStates:
 | 
			
		||||
        w = self.g.world
 | 
			
		||||
        p = utils.pint(self.g.pos)
 | 
			
		||||
 | 
			
		||||
        self.barrels = w.find_blocks_indexed(p, blocks.BARREL_IDS)
 | 
			
		||||
        self.barrels = w.find_blocks_indexed(p, blocks.BARREL_IDS, 80)
 | 
			
		||||
        print('Found:', self.barrels)
 | 
			
		||||
        self.state = self.choose_barrel
 | 
			
		||||
 | 
			
		||||
@@ -73,6 +73,7 @@ class GrabSuppliesStates:
 | 
			
		||||
            if barrel in self.bad_barrels:
 | 
			
		||||
                continue
 | 
			
		||||
 | 
			
		||||
            print('Chose:', barrel)
 | 
			
		||||
            self.barrel = barrel
 | 
			
		||||
            self.state = self.path_to_barrel
 | 
			
		||||
            return
 | 
			
		||||
@@ -86,26 +87,20 @@ class GrabSuppliesStates:
 | 
			
		||||
        p = utils.pint(self.g.pos)
 | 
			
		||||
        c = self.g.chunks
 | 
			
		||||
 | 
			
		||||
        barrel = self.barrel
 | 
			
		||||
 | 
			
		||||
        tmp = c.get_block_at(*barrel)
 | 
			
		||||
        c.set_block_at(*barrel, blocks.AIR)
 | 
			
		||||
        navpath = w.path_to_place(p, barrel)
 | 
			
		||||
        c.set_block_at(*barrel, tmp)
 | 
			
		||||
 | 
			
		||||
        navpath = w.path_to_place_faked(p, self.barrel)
 | 
			
		||||
        print('navpath:', navpath)
 | 
			
		||||
 | 
			
		||||
        if navpath:
 | 
			
		||||
            self.g.path = navpath[:-1]
 | 
			
		||||
            self.opening = self.g.path[-1]
 | 
			
		||||
            self.checked_barrels.append(barrel)
 | 
			
		||||
            self.area = barrel
 | 
			
		||||
            self.checked_barrels.append(self.barrel)
 | 
			
		||||
            self.area = self.barrel
 | 
			
		||||
            self.state = self.going_to_barrel
 | 
			
		||||
            self.checked_supplies = []
 | 
			
		||||
            return
 | 
			
		||||
        else:
 | 
			
		||||
            print('No path, blacklisting barrel')
 | 
			
		||||
            self.bad_barrels.append(barrel)
 | 
			
		||||
            self.bad_barrels.append(self.barrel)
 | 
			
		||||
            self.state = self.choose_barrel
 | 
			
		||||
 | 
			
		||||
    def going_to_barrel(self):
 | 
			
		||||
 
 | 
			
		||||
@@ -67,11 +67,7 @@ class SleepWithBedStates:
 | 
			
		||||
        bed = self.beds[0]
 | 
			
		||||
        print('Chose:', bed)
 | 
			
		||||
 | 
			
		||||
        tmp = c.get_block_at(*bed)
 | 
			
		||||
        c.set_block_at(*bed, blocks.AIR)
 | 
			
		||||
        navpath = w.path_to_place(p, bed)
 | 
			
		||||
        c.set_block_at(*bed, tmp)
 | 
			
		||||
 | 
			
		||||
        navpath = w.path_to_place_faked(p, bed)
 | 
			
		||||
        print('navpath:', navpath)
 | 
			
		||||
 | 
			
		||||
        if navpath:
 | 
			
		||||
@@ -171,12 +167,12 @@ class SleepWithBedStates:
 | 
			
		||||
            print(threats)
 | 
			
		||||
            self.g.game.leave_bed()
 | 
			
		||||
            self.state = self.cleanup
 | 
			
		||||
        elif self.g.correction_count:
 | 
			
		||||
            print('Forcefully woke up')
 | 
			
		||||
            self.state = self.collect_bed
 | 
			
		||||
        elif self.g.time < 100:
 | 
			
		||||
            print('Woke up time')
 | 
			
		||||
            self.state = self.break_bed
 | 
			
		||||
        elif self.g.correction_count:
 | 
			
		||||
            print('Woke up by movement')
 | 
			
		||||
            self.state = self.break_bed
 | 
			
		||||
 | 
			
		||||
    def break_bed(self):
 | 
			
		||||
        if self.my_bed:
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user