From ef1116916420e760725d1ae5c7d73dbc086e7315 Mon Sep 17 00:00:00 2001 From: alex-s168 <63254202+alex-s168@users.noreply.github.com> Date: Wed, 22 May 2024 20:41:38 +0200 Subject: [PATCH] connectors don't crash the game anymore + bump version --- .../tournament/blockentity/SensorBlockEntity.kt | 5 ++++- .../valkyrienskies/tournament/util/math/Lerp.kt | 15 ++++++++------- gradle.properties | 2 +- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/common/src/main/kotlin/org/valkyrienskies/tournament/blockentity/SensorBlockEntity.kt b/common/src/main/kotlin/org/valkyrienskies/tournament/blockentity/SensorBlockEntity.kt index 2b808c1..61d206f 100644 --- a/common/src/main/kotlin/org/valkyrienskies/tournament/blockentity/SensorBlockEntity.kt +++ b/common/src/main/kotlin/org/valkyrienskies/tournament/blockentity/SensorBlockEntity.kt @@ -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() diff --git a/common/src/main/kotlin/org/valkyrienskies/tournament/util/math/Lerp.kt b/common/src/main/kotlin/org/valkyrienskies/tournament/util/math/Lerp.kt index 957f339..e9481ad 100644 --- a/common/src/main/kotlin/org/valkyrienskies/tournament/util/math/Lerp.kt +++ b/common/src/main/kotlin/org/valkyrienskies/tournament/util/math/Lerp.kt @@ -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) \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index bc40535..1eff73f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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