Skip to content

Commit

Permalink
final push be4 recode x2
Browse files Browse the repository at this point in the history
  • Loading branch information
Jelly298 committed Aug 7, 2022
1 parent cf14acd commit c715049
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,9 @@ private LinkedList<BlockNode> calculatePath(BlockPos startingPos, BlockPos endin
if (goalNode.blockPos.equals(currentNode.blockPos)) {
completedPathfind = true;
}
if(step > 3000)
if(step > 30000)
{
Logger.playerLog("Steps exceeded");
throw new Exception();
}
}
Expand All @@ -208,6 +209,7 @@ private void openNodeAndCalculateCost(Node searchNode, Node currentNode, BlockPo
if (allowedMiningBlocks != null && !allowedMiningBlocks.contains(BlockUtils.getBlock(searchNode.blockPos)) && !BlockUtils.getBlock(searchNode.blockPos).equals(Blocks.air))
return;
}
BlockRenderer.renderMap.put(searchNode.blockPos, Color.cyan);

searchNode.opened = true;
searchNode.lastNode = currentNode;
Expand Down Expand Up @@ -314,13 +316,13 @@ private void calculateCost(Node node, BlockPos endingBlock){
else
node.gValue = 1f;

node.gValue *= BlockUtils.isPassable(node.blockPos) ? 0.5f : 2f;
// node.gValue *= BlockUtils.isPassable(node.blockPos) ? 0.5f : 2f;
node.fValue = node.gValue + node.hValue;
}
private int calculatePathCost(List<BlockNode> nodes){
int cost = 0;
for(BlockNode node : nodes){
cost += (node.getBlockType() == BlockType.WALK) ? 1 : 2;
cost += (node.getBlockType() == BlockType.WALK) ? 2 : 1;
}
return cost;
}
Expand All @@ -330,6 +332,6 @@ BlockType getBlockType (BlockPos blockToSearch) {
}

double getHeuristic(BlockPos start, BlockPos goal){
return MathUtils.getDistanceBetweenTwoBlock(start, goal) * (BlockUtils.isPassable(goal) ? 0.5f : 2f);
return MathUtils.getDistanceBetweenTwoBlock(start, goal);
}
}

0 comments on commit c715049

Please sign in to comment.