import time import importlib from panda3d.core import LPoint3f import utils importlib.reload(utils) import path importlib.reload(path) def handle_join_game(packet, g): print('Connected.') print(packet) g.info = packet def handle_block_change(packet, g): l = g.local_state print('block change:') print(packet) if packet.block_state_id == 3887: try: l.goal = LPoint3f(x=packet.location[0], y=packet.location[1], z=packet.location[2]) print('new waypoint:', l.goal) start = time.time() solution = path.Pathfinder(g.chunks).astar(utils.pint(g.pos), utils.pint(l.goal)) if solution: solution = list(solution) l.path = solution #l.jobstate.state = l.jobstate.stop print(len(solution)) print(solution) print(round(time.time() - start, 3), 'seconds') else: print('No path found') #say(connection, 'No path found') #l.y_v = 10.0 #l.y_a = -36.0 except BaseException as e: import traceback print(traceback.format_exc()) def handle_position_and_look(packet, g): print('pos and look:') print(packet) p = LPoint3f(x=packet.x, y=packet.y, z=packet.z) g.pos = p