1
0
mirror of https://github.com/kami-blue/client synced 2025-01-18 13:00:47 +00:00

Better remote pos

This commit is contained in:
Christian 2021-04-24 00:05:54 +02:00
parent 2f3249fb5e
commit 864ab4a1b7
No known key found for this signature in database
GPG Key ID: 3A2E5C58D546EFD8

View File

@ -1842,20 +1842,20 @@ internal object HighwayTools : Module(
}
private fun SafeClientEvent.getRemotePos(): BlockPos? {
val eyePos = player.getPositionEyes(1f)
val origin = currentBlockPos.up().toVec3dCenter()
return VectorUtils.getBlockPosInSphere(eyePos, maxReach).asSequence()
return VectorUtils.getBlockPosInSphere(origin, maxReach).asSequence()
.filter { pos ->
!isInsideBlueprintBuild(pos) &&
pos != currentBlockPos &&
world.isPlaceable(pos) &&
!world.getBlockState(pos.down()).isReplaceable &&
world.isAirBlock(pos.up()) &&
world.rayTraceBlocks(eyePos, pos.toVec3dCenter())?.let { it.typeOfHit == RayTraceResult.Type.MISS } ?: true
world.rayTraceBlocks(origin, pos.toVec3dCenter())?.let { it.typeOfHit == RayTraceResult.Type.MISS } ?: true
}
.sortedWith(
compareBy<BlockPos> {
it.distanceSqToCenter(eyePos.x, eyePos.y, eyePos.z).ceilToInt()
it.distanceSqToCenter(origin.x, origin.y, origin.z).ceilToInt()
}.thenBy {
it.y
}