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