Skip to content

Commit 03291fc

Browse files
committed
refactor: move shrinkByEpsilon to box extensions
1 parent 5888dca commit 03291fc

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

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

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import com.lambda.task.RootTask.run
3030
import com.lambda.task.Task
3131
import com.lambda.task.tasks.BuildTask.Companion.build
3232
import com.lambda.util.BlockUtils.blockState
33+
import com.lambda.util.extension.shrinkByEpsilon
3334
import com.lambda.util.item.ItemUtils.block
3435
import com.lambda.util.math.flooredBlockPos
3536
import com.lambda.util.player.SlotUtils.hotbarAndStorage
@@ -39,7 +40,6 @@ import net.minecraft.client.network.OtherClientPlayerEntity
3940
import net.minecraft.entity.player.PlayerEntity
4041
import net.minecraft.item.BlockItem
4142
import net.minecraft.util.math.BlockPos
42-
import net.minecraft.util.math.Box
4343
import kotlin.jvm.optionals.getOrNull
4444

4545
object PlayerTrap : Module(
@@ -89,8 +89,8 @@ object PlayerTrap : Module(
8989
}
9090

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

9595
return buildSet {
9696
(min.x + 1..<max.x).forEach { x ->
@@ -117,11 +117,4 @@ object PlayerTrap : Module(
117117
}
118118
}
119119
}
120-
121-
/**
122-
* @see net.minecraft.util.math.Box.EPSILON
123-
*/
124-
fun Box.withEpsilon(): Box {
125-
return this.expand(-1e-7)
126-
}
127120
}

src/main/kotlin/com/lambda/util/extension/Box.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,7 @@ import net.minecraft.util.math.Vec3d
2323
val Box.min get() = Vec3d(minX, minY, minZ)
2424
val Box.max get() = Vec3d(maxX, maxY, maxZ)
2525

26+
fun Box.shrinkByEpsilon(): Box = expand(-1e-7)
27+
2628
operator fun Box.contains(boundingBox: Box) = this.intersects(boundingBox)
2729
operator fun DoubleArray.component6() = this[5]

0 commit comments

Comments
 (0)