From 5888dca3b59c1119b89d529448a474a56a518c94 Mon Sep 17 00:00:00 2001 From: cattyn Date: Mon, 15 Dec 2025 12:30:16 +0300 Subject: [PATCH 1/2] fix(PlayerTrap): account epsilon when calculating player hitbox size --- .../com/lambda/module/modules/combat/PlayerTrap.kt | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/com/lambda/module/modules/combat/PlayerTrap.kt b/src/main/kotlin/com/lambda/module/modules/combat/PlayerTrap.kt index de2f3f01c..1fe355991 100644 --- a/src/main/kotlin/com/lambda/module/modules/combat/PlayerTrap.kt +++ b/src/main/kotlin/com/lambda/module/modules/combat/PlayerTrap.kt @@ -39,6 +39,7 @@ import net.minecraft.client.network.OtherClientPlayerEntity import net.minecraft.entity.player.PlayerEntity import net.minecraft.item.BlockItem import net.minecraft.util.math.BlockPos +import net.minecraft.util.math.Box import kotlin.jvm.optionals.getOrNull object PlayerTrap : Module( @@ -88,8 +89,8 @@ object PlayerTrap : Module( } fun SafeContext.getTrapPositions(player: PlayerEntity): Set { - val min = player.boundingBox.minPos.flooredBlockPos.add(-1, -1, -1) - val max = player.boundingBox.maxPos.flooredBlockPos.add(1, 1, 1) + val min = player.boundingBox.withEpsilon().minPos.flooredBlockPos.add(-1, -1, -1) + val max = player.boundingBox.withEpsilon().maxPos.flooredBlockPos.add(1, 1, 1) return buildSet { (min.x + 1.. @@ -116,4 +117,11 @@ object PlayerTrap : Module( } } } + + /** + * @see net.minecraft.util.math.Box.EPSILON + */ + fun Box.withEpsilon(): Box { + return this.expand(-1e-7) + } } \ No newline at end of file From 03291fce51fca0d0d61e0fa9825c0471e3d7bbaf Mon Sep 17 00:00:00 2001 From: cattyn Date: Tue, 16 Dec 2025 01:08:22 +0300 Subject: [PATCH 2/2] refactor: move `shrinkByEpsilon` to box extensions --- .../com/lambda/module/modules/combat/PlayerTrap.kt | 13 +++---------- src/main/kotlin/com/lambda/util/extension/Box.kt | 2 ++ 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/main/kotlin/com/lambda/module/modules/combat/PlayerTrap.kt b/src/main/kotlin/com/lambda/module/modules/combat/PlayerTrap.kt index 1fe355991..09d200801 100644 --- a/src/main/kotlin/com/lambda/module/modules/combat/PlayerTrap.kt +++ b/src/main/kotlin/com/lambda/module/modules/combat/PlayerTrap.kt @@ -30,6 +30,7 @@ import com.lambda.task.RootTask.run import com.lambda.task.Task import com.lambda.task.tasks.BuildTask.Companion.build import com.lambda.util.BlockUtils.blockState +import com.lambda.util.extension.shrinkByEpsilon import com.lambda.util.item.ItemUtils.block import com.lambda.util.math.flooredBlockPos import com.lambda.util.player.SlotUtils.hotbarAndStorage @@ -39,7 +40,6 @@ import net.minecraft.client.network.OtherClientPlayerEntity import net.minecraft.entity.player.PlayerEntity import net.minecraft.item.BlockItem import net.minecraft.util.math.BlockPos -import net.minecraft.util.math.Box import kotlin.jvm.optionals.getOrNull object PlayerTrap : Module( @@ -89,8 +89,8 @@ object PlayerTrap : Module( } fun SafeContext.getTrapPositions(player: PlayerEntity): Set { - val min = player.boundingBox.withEpsilon().minPos.flooredBlockPos.add(-1, -1, -1) - val max = player.boundingBox.withEpsilon().maxPos.flooredBlockPos.add(1, 1, 1) + val min = player.boundingBox.shrinkByEpsilon().minPos.flooredBlockPos.add(-1, -1, -1) + val max = player.boundingBox.shrinkByEpsilon().maxPos.flooredBlockPos.add(1, 1, 1) return buildSet { (min.x + 1.. @@ -117,11 +117,4 @@ object PlayerTrap : Module( } } } - - /** - * @see net.minecraft.util.math.Box.EPSILON - */ - fun Box.withEpsilon(): Box { - return this.expand(-1e-7) - } } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/util/extension/Box.kt b/src/main/kotlin/com/lambda/util/extension/Box.kt index 84c617a53..13bf99aab 100644 --- a/src/main/kotlin/com/lambda/util/extension/Box.kt +++ b/src/main/kotlin/com/lambda/util/extension/Box.kt @@ -23,5 +23,7 @@ import net.minecraft.util.math.Vec3d val Box.min get() = Vec3d(minX, minY, minZ) val Box.max get() = Vec3d(maxX, maxY, maxZ) +fun Box.shrinkByEpsilon(): Box = expand(-1e-7) + operator fun Box.contains(boundingBox: Box) = this.intersects(boundingBox) operator fun DoubleArray.component6() = this[5]