Reorder check_descend pathfinding functions
This commit is contained in:
		@@ -15,6 +15,9 @@ for name, data in JSON_BLOCKS.items():
 | 
			
		||||
    for state in data['states']:
 | 
			
		||||
        BLOCKS[state['id']] = name.replace('minecraft:', '')
 | 
			
		||||
 | 
			
		||||
SINGLE_SNOW = 3921
 | 
			
		||||
SOUL_TORCH = 4008
 | 
			
		||||
 | 
			
		||||
AVOID = [
 | 
			
		||||
    'lava',
 | 
			
		||||
    'water',
 | 
			
		||||
@@ -184,8 +187,8 @@ NON_SOLID = [
 | 
			
		||||
    'void_air',
 | 
			
		||||
    'cave_air',
 | 
			
		||||
    'lantern',
 | 
			
		||||
    'soul_torch',
 | 
			
		||||
]
 | 
			
		||||
SINGLE_SNOW = 3919
 | 
			
		||||
 | 
			
		||||
LOGS = [
 | 
			
		||||
    'oak_log',
 | 
			
		||||
 
 | 
			
		||||
@@ -10,6 +10,8 @@ import utils
 | 
			
		||||
importlib.reload(utils)
 | 
			
		||||
import path
 | 
			
		||||
importlib.reload(path)
 | 
			
		||||
import blocks
 | 
			
		||||
importlib.reload(blocks)
 | 
			
		||||
 | 
			
		||||
def handle_join_game(packet, g):
 | 
			
		||||
    print('Connected.')
 | 
			
		||||
@@ -19,7 +21,7 @@ def handle_join_game(packet, g):
 | 
			
		||||
def handle_block_change(packet, g):
 | 
			
		||||
    l = g.local_state
 | 
			
		||||
 | 
			
		||||
    if packet.block_state_id == 3887:
 | 
			
		||||
    if packet.block_state_id == blocks.SOUL_TORCH:
 | 
			
		||||
        try:
 | 
			
		||||
            l.goal = LPoint3f(x=packet.location[0], y=packet.location[1], z=packet.location[2])
 | 
			
		||||
            print('new waypoint:', l.goal)
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										24
									
								
								path.py
									
									
									
									
									
								
							
							
						
						
									
										24
									
								
								path.py
									
									
									
									
									
								
							@@ -188,47 +188,47 @@ class Pathfinder(AStar):
 | 
			
		||||
        return True
 | 
			
		||||
 | 
			
		||||
    def check_ascend(self, node, offset):
 | 
			
		||||
        if not self.check_traverse(node, offset):
 | 
			
		||||
            return False
 | 
			
		||||
 | 
			
		||||
        dest = utils.padd(node, offset)
 | 
			
		||||
 | 
			
		||||
        if not self.bair(utils.padd(node, BLOCK_ABOVE2)):
 | 
			
		||||
            return False
 | 
			
		||||
 | 
			
		||||
        return True
 | 
			
		||||
 | 
			
		||||
    def check_descend(self, node, offset):
 | 
			
		||||
        if not self.check_traverse(node, offset):
 | 
			
		||||
            return False
 | 
			
		||||
 | 
			
		||||
        return True
 | 
			
		||||
 | 
			
		||||
    def check_descend(self, node, offset):
 | 
			
		||||
        dest = utils.padd(node, offset)
 | 
			
		||||
 | 
			
		||||
        if not self.bair(utils.padd(dest, BLOCK_ABOVE2)):
 | 
			
		||||
            return False
 | 
			
		||||
 | 
			
		||||
        if not self.check_traverse(node, offset):
 | 
			
		||||
            return False
 | 
			
		||||
 | 
			
		||||
        return True
 | 
			
		||||
 | 
			
		||||
    def check_descend2(self, node, offset):
 | 
			
		||||
        if not self.check_descend(node, offset):
 | 
			
		||||
            return False
 | 
			
		||||
 | 
			
		||||
        dest = utils.padd(node, offset)
 | 
			
		||||
 | 
			
		||||
        if not self.bair(utils.padd(dest, BLOCK_ABOVE3)):
 | 
			
		||||
            return False
 | 
			
		||||
 | 
			
		||||
        if not self.check_descend(node, offset):
 | 
			
		||||
            return False
 | 
			
		||||
 | 
			
		||||
        return True
 | 
			
		||||
 | 
			
		||||
    def check_descend3(self, node, offset):
 | 
			
		||||
        if not self.check_descend2(node, offset):
 | 
			
		||||
            return False
 | 
			
		||||
 | 
			
		||||
        dest = utils.padd(node, offset)
 | 
			
		||||
 | 
			
		||||
        if not self.bair(utils.padd(dest, BLOCK_ABOVE4)):
 | 
			
		||||
            return False
 | 
			
		||||
 | 
			
		||||
        if not self.check_descend2(node, offset):
 | 
			
		||||
            return False
 | 
			
		||||
 | 
			
		||||
        return True
 | 
			
		||||
 | 
			
		||||
    def check_parkour(self, node, offset):
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user