Skip to content

Commit

Permalink
connectors don't crash the game anymore + bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-s168 committed May 22, 2024
1 parent 4ea57fd commit ef11169
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,12 @@ class SensorBlockEntity(pos: BlockPos, state: BlockState):
true
)

val hit = clipResult
val hit = Helper3d.convertShipToWorldSpace(
level,
clipResult
.location
.toJOML()
)

return if (clipResult.type != HitResult.Type.MISS) {
ceil(lerp(15.0, 1.0, start.distance(hit) / TournamentConfig.SERVER.sensorDistance)).toInt()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package org.valkyrienskies.tournament.util.math

fun lerp(a: Double, b: Double, t: Double): Double =
a + (b - a) * t
import kotlin.math.max
import kotlin.math.min

fun clamp(v: Double, minv: Double, maxv: Double): Double =
if (minv > maxv) clamp(v, maxv, minv)
else min(max(v, minv), maxv)

fun lerp(a: Float, b: Float, t: Float): Float =
a + (b - a) * t
fun lerp(a: Double, b: Double, t: Double): Double =
clamp(a + (b - a) * t, a, b)

fun invLerp(a: Double, b: Double, v: Double): Double =
(v - a) / (b - a)

fun invLerp(a: Float, b: Float, v: Float): Float =
(v - a) / (b - a)
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx4096M
# Identity
mod_name=Tournament
mod_id=vs_tournament
Tournament_version=1.1.0_beta-5.1
Tournament_version=1.1.0_beta-5.2
enabled_platforms=fabric,forge
archives_base_name=tournament
maven_group=org.valkyrienskies
Expand Down

0 comments on commit ef11169

Please sign in to comment.