Skip to content
This repository has been archived by the owner on Jul 20, 2024. It is now read-only.

Commit

Permalink
Pathfinder
Browse files Browse the repository at this point in the history
  • Loading branch information
OsamaBeingLagging committed Sep 17, 2023
1 parent ebe9593 commit 6e5bef6
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package dev.macrohq.swiftslayer.pathfinding

import dev.macrohq.swiftslayer.util.AngleUtil
import dev.macrohq.swiftslayer.util.BlockUtil
import dev.macrohq.swiftslayer.util.RenderUtil
import dev.macrohq.swiftslayer.util.world
import net.minecraft.init.Blocks
import net.minecraft.util.BlockPos
Expand Down Expand Up @@ -45,6 +46,9 @@ class AStarPathfinder(startPos: BlockPos, endPos: BlockPos) {
path.add(0, currentNode.position)
currentNode = currentNode.parent
}
RenderUtil.markers.clear()
RenderUtil.lines.clear()
RenderUtil.markers.addAll(path)

val smooth = mutableListOf<BlockPos>()
if (path.isNotEmpty()) {
Expand Down Expand Up @@ -108,7 +112,7 @@ class AStarPathfinder(startPos: BlockPos, endPos: BlockPos) {

fun getNeighbours(): List<Node> {
val neighbours = mutableListOf<Node>()
BlockUtil.neighbourGenerator(this.position, -1, 1, -4, 3, -1, 1).forEach {
BlockUtil.neighbourGenerator(this.position, -1, 1, -2, 2, -1, 1).forEach {
val newNode = Node(it, this)
if (newNode.isWalkable()) neighbours.add(newNode)
}
Expand Down

0 comments on commit 6e5bef6

Please sign in to comment.