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

Commit

Permalink
finished wolfkiller dk if i broke revkiller in the process or not
Browse files Browse the repository at this point in the history
  • Loading branch information
OsamaBeingLagging committed Sep 7, 2023
1 parent 4b60c84 commit 2d967ac
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ class PathfindTest {
private var path = mutableListOf<BlockPos>()
@Main
private fun main() {
batphoneHandler.enable()
mobKiller.enable()
// batphoneHandler.enable(true)
// RenderUtil.markers.clear()
// RenderUtil.markers.addAll(AStarPathfinder(player.getStandingOnFloor(), swiftSlayer.removeLater!!).findPath(2000))
}

@SubCommand
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class AStarPathfinder(startPos: BlockPos, endPos: BlockPos) {
if(BlockUtil.isStairSlab(this.position)) cost -= 1f
}
BlockUtil.neighbourGenerator(this.position.up().up().up(), 1).forEach{
if(world.isBlockFullCube(it)) cost += 1f
if(world.isBlockFullCube(it)) cost += 1.5f
}
this.gCost = if (this.parent != null) sqrt(this.parent.position.distanceSq(this.position)).toFloat()
else 0f
Expand Down
45 changes: 34 additions & 11 deletions src/main/kotlin/dev/macrohq/swiftslayer/util/BlockUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,24 +34,47 @@ object BlockUtil {
}

fun blocksBetweenValid(startPos: BlockPos, endPos: BlockPos): Boolean{
val blocks = bresenham(startPos.toVec3().addVector(0.0,0.4,0.0), endPos.toVec3().addVector(0.0,0.4,0.0))
val blocks = bresenham(startPos.toVec3().addVector(0.0,0.4,0.0), endPos.toVec3().addVector(0.0,0.4,0.0)).toMutableList()
var blockFail = 0
var lastBlockY = blocks[0].y
var lastFullBlock = world.isBlockFullCube(blocks[0])
var isLastBlockSlab = isStairSlab(blocks[0])
var isLastBlockAir = world.isAirBlock(blocks[0])
blocks.remove(blocks[0])
blocks.forEach{
if(!AStarPathfinder.Node(it, null).isWalkable() && !world.isAirBlock(it)){
return false
}
if(world.isAirBlock(it)){
blockFail++
}
if(world.isBlockFullCube(it) && blockFail>0) return false
if(AStarPathfinder.Node(it, null).isWalkable()){
blockFail = 0
}
if(blockFail>5){
return false
}
// if(!(isLastBlockSlab && world.isBlockFullCube(it))) return false
if(isLastBlockAir && world.isBlockFullCube(it) && !isStairSlab(it)) return false
// if(!(isLastBlockAir && isStairSlab(it))) return false
if(lastFullBlock && world.isBlockFullCube(it) && it.y > lastBlockY) return false
if(world.isAirBlock(it)) blockFail++
else blockFail=0
if(blockFail>3) return false

lastBlockY = it.y
lastFullBlock = world.isBlockFullCube(it)
isLastBlockSlab = isStairSlab(it)
isLastBlockAir = world.isAirBlock(it)
}
return true
// blocks.forEach{
// if(!AStarPathfinder.Node(it, null).isWalkable() && !world.isAirBlock(it)){
// return false
// }
// if(world.isAirBlock(it)){
// blockFail++
// }
// if(world.isBlockFullCube(it) && blockFail>0) return false
// if(AStarPathfinder.Node(it, null).isWalkable()){
// blockFail = 0
// }
// if(blockFail>5){
// return false
// }
// }
// return true
}

fun bresenham(start: Vec3, end: Vec3): List<BlockPos> {
Expand Down
3 changes: 2 additions & 1 deletion src/main/kotlin/dev/macrohq/swiftslayer/util/EntityUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ object EntityUtil {
val angleChange = yawChange + pitchChange
val distance = sqrt(player.getDistanceToEntity(entity))
val cost = getRevCost(entity)
return (distance + angleChange + cost)
// return (distance + angleChange + cost)
return distance
}

fun getRevCost(entity: EntityLiving): Int{
Expand Down

0 comments on commit 2d967ac

Please sign in to comment.