Fix jobstate bugs
This commit is contained in:
@@ -2,6 +2,7 @@ import re
|
||||
import time
|
||||
import importlib
|
||||
from math import hypot
|
||||
from itertools import count
|
||||
|
||||
from panda3d.core import LPoint3f
|
||||
|
||||
@@ -40,7 +41,7 @@ class MCWorld:
|
||||
def find_trees(self, center, distance):
|
||||
logs = []
|
||||
for i in range(5):
|
||||
check = utils.padd(center, alternate(i, 3))
|
||||
check = utils.padd(center, utils.alternate(i, 3))
|
||||
logs.extend(self.find_blocks(check, distance, blocks.LOG_IDS, 50))
|
||||
|
||||
trees = []
|
||||
@@ -66,26 +67,26 @@ class MCWorld:
|
||||
log = utils.padd(log, path.BLOCK_BELOW)
|
||||
trees.append(log)
|
||||
|
||||
trees.sort(key=lambda x: phyp(center, x))
|
||||
trees.sort(key=lambda x: utils.phyp(center, x))
|
||||
return trees
|
||||
|
||||
def find_tree_openings(self, tree):
|
||||
# returns coords in a cardinal direction where we can stand by tree
|
||||
maze_solver = MazeSolver(self.g.chunks)
|
||||
maze_solver = path.Pathfinder(self.g.chunks)
|
||||
result = []
|
||||
|
||||
# TODO: make sure only non-solid and leaves between
|
||||
# make sure traversable too
|
||||
|
||||
for distance in range(5):
|
||||
for direction in CHECK_DIRECTIONS:
|
||||
offset = pmul(direction, distance+1)
|
||||
for direction in path.CHECK_DIRECTIONS:
|
||||
offset = utils.pmul(direction, distance+1)
|
||||
if maze_solver.check_traverse(tree, offset):
|
||||
result.append(utils.padd(tree, offset))
|
||||
return result
|
||||
|
||||
def path_to_place(self, start, place):
|
||||
maze_solver = MazeSolver(self.g.chunks)
|
||||
maze_solver = path.Pathfinder(self.g.chunks)
|
||||
|
||||
try:
|
||||
s = maze_solver.astar(start, place)
|
||||
@@ -115,11 +116,11 @@ class MCWorld:
|
||||
|
||||
areas.append(a)
|
||||
|
||||
areas.sort(key=lambda x: phyp(center, x))
|
||||
areas.sort(key=lambda x: utils.phyp(center, x))
|
||||
return areas
|
||||
|
||||
def sand_adjacent_safe(self, sand):
|
||||
for direction in CHECK_DIRECTIONS:
|
||||
for direction in path.CHECK_DIRECTIONS:
|
||||
if self.block_at(*utils.padd(sand, direction)) in blocks.AVOID_IDS:
|
||||
return False
|
||||
return True
|
||||
@@ -155,7 +156,7 @@ class MCWorld:
|
||||
# returns coords in a cardinal direction where we can stand by bed
|
||||
result = []
|
||||
|
||||
for direction in CHECK_DIRECTIONS:
|
||||
for direction in path.CHECK_DIRECTIONS:
|
||||
result.append(utils.padd(area, direction))
|
||||
return result
|
||||
|
||||
@@ -188,7 +189,7 @@ class Game:
|
||||
print('new waypoint:', self.g.goal)
|
||||
|
||||
start = time.time()
|
||||
solution = path.Pathfinder(self.g.chunks).astar(utils.pint(self.g.pos), utils.pint(g.goal))
|
||||
solution = path.Pathfinder(self.g.chunks).astar(utils.pint(self.g.pos), utils.pint(self.g.goal))
|
||||
if solution:
|
||||
solution = list(solution)
|
||||
self.g.path = solution
|
||||
@@ -261,6 +262,11 @@ class Game:
|
||||
self.break_block((616, 78, 496))
|
||||
reply = 'ok'
|
||||
|
||||
if command == 'gather' and data:
|
||||
if data == 'wood':
|
||||
self.g.job.state = self.g.job.lumberjack
|
||||
reply = 'ok'
|
||||
|
||||
if reply:
|
||||
print(reply)
|
||||
self.g.chat.send(reply)
|
||||
@@ -291,6 +297,7 @@ class Game:
|
||||
packet.location = self.g.breaking
|
||||
packet.face = 1
|
||||
self.g.connection.write_packet(packet)
|
||||
self.g.chunks.set_block_at(*self.g.breaking, 0)
|
||||
self.g.breaking = None
|
||||
|
||||
|
||||
@@ -298,7 +305,8 @@ class Game:
|
||||
print(packet)
|
||||
|
||||
def handle_break_ack(self, packet):
|
||||
print(packet)
|
||||
#print(packet)
|
||||
return
|
||||
|
||||
def animate(self):
|
||||
packet = serverbound.play.AnimationPacket()
|
||||
|
||||
Reference in New Issue
Block a user