Skip to content

Commit 5888dca

Browse files
committed
fix(PlayerTrap): account epsilon when calculating player hitbox size
1 parent 94a8f3c commit 5888dca

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/main/kotlin/com/lambda/module/modules/combat/PlayerTrap.kt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import net.minecraft.client.network.OtherClientPlayerEntity
3939
import net.minecraft.entity.player.PlayerEntity
4040
import net.minecraft.item.BlockItem
4141
import net.minecraft.util.math.BlockPos
42+
import net.minecraft.util.math.Box
4243
import kotlin.jvm.optionals.getOrNull
4344

4445
object PlayerTrap : Module(
@@ -88,8 +89,8 @@ object PlayerTrap : Module(
8889
}
8990

9091
fun SafeContext.getTrapPositions(player: PlayerEntity): Set<BlockPos> {
91-
val min = player.boundingBox.minPos.flooredBlockPos.add(-1, -1, -1)
92-
val max = player.boundingBox.maxPos.flooredBlockPos.add(1, 1, 1)
92+
val min = player.boundingBox.withEpsilon().minPos.flooredBlockPos.add(-1, -1, -1)
93+
val max = player.boundingBox.withEpsilon().maxPos.flooredBlockPos.add(1, 1, 1)
9394

9495
return buildSet {
9596
(min.x + 1..<max.x).forEach { x ->
@@ -116,4 +117,11 @@ object PlayerTrap : Module(
116117
}
117118
}
118119
}
120+
121+
/**
122+
* @see net.minecraft.util.math.Box.EPSILON
123+
*/
124+
fun Box.withEpsilon(): Box {
125+
return this.expand(-1e-7)
126+
}
119127
}

0 commit comments

Comments
 (0)