Skip to content

Commit 1b75d99

Browse files
committed
Runtime optimizations
1 parent f3f3eaf commit 1b75d99

File tree

3 files changed

+8
-12
lines changed

3 files changed

+8
-12
lines changed

common/src/main/java/com/lambda/mixin/DebugHudMixin.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
public class DebugHudMixin {
1818
@Inject(method = "getRightText", at = @At(value = "TAIL"))
1919
private void onGetRightText(CallbackInfoReturnable<List<String>> cir) {
20-
2120
if (Lambda.getMc().crosshairTarget == null) return;
2221
HitResult hitResult = Lambda.getMc().crosshairTarget;
2322
List<String> list = cir.getReturnValue();

common/src/main/kotlin/com/lambda/event/EventFlow.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,13 @@ object EventFlow {
8686
return cancellable
8787
}
8888

89+
@JvmStatic
8990
fun <T> post(cancellable: T, process: T.() -> Unit) where T : Event, T : ICancellable {
9091
val event = post(cancellable)
9192
process(event)
9293
}
9394

95+
@JvmStatic
9496
fun <T> postChecked(cancellable: T, process: T.() -> Unit) where T : Event, T : ICancellable {
9597
val event = post(cancellable)
9698
if (!event.isCanceled()) process(event)

common/src/main/kotlin/com/lambda/manager/interaction/VisibilityChecker.kt

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ object VisibilityChecker {
88
operator fun DoubleArray.component6() = this[5]
99

1010
inline fun SafeContext.scanVisibleSurfaces(box: Box, resolution: Int, check: (Vec3d) -> Unit) {
11+
val shrunk = box.expand(-0.025)
1112
getVisibleSides(box).forEach { side ->
12-
val shrunk = box.expand(-0.025)
1313
val (minX, minY, minZ, maxX, maxY, maxZ) = shrunk.bounds(side)
1414
val stepX = (maxX - minX) / resolution
1515
val stepY = (maxY - minY) / resolution
1616
val stepZ = (maxZ - minZ) / resolution
1717
for (i in 0 .. resolution) {
18+
val x = if (stepX != 0.0) minX + stepX * i else minX
1819
for (j in 0 .. resolution) {
19-
val x = if (stepX != 0.0) minX + stepX * i else minX
2020
val y = if (stepY != 0.0) minY + stepY * j else minY
2121
val z = if (stepZ != 0.0) minZ + stepZ * ((if (stepX != 0.0) j else i)) else minZ
2222
check(Vec3d(x, y, z))
@@ -35,21 +35,16 @@ object VisibilityChecker {
3535
Direction.EAST -> doubleArrayOf(maxX, minY, minZ, maxX, maxY, maxZ)
3636
}
3737

38-
fun SafeContext.getVisibleSides(box: Box): List<Direction> {
38+
fun SafeContext.getVisibleSides(box: Box): Set<Direction> {
3939
val visibleSides = EnumSet.noneOf(Direction::class.java)
4040

4141
val eyePos = player.eyePos
4242
val center = box.center
4343

44-
val halfX = box.lengthX / 2
45-
val halfY = box.lengthY / 2
46-
val halfZ = box.lengthZ / 2
47-
4844
return visibleSides
49-
.checkAxis(eyePos.x - center.x, halfX, Direction.WEST, Direction.EAST)
50-
.checkAxis(eyePos.y - center.y, halfY, Direction.DOWN, Direction.UP)
51-
.checkAxis(eyePos.z - center.z, halfZ, Direction.NORTH, Direction.SOUTH)
52-
.map { it }
45+
.checkAxis(eyePos.x - center.x, box.lengthX / 2, Direction.WEST, Direction.EAST)
46+
.checkAxis(eyePos.y - center.y, box.lengthY / 2, Direction.DOWN, Direction.UP)
47+
.checkAxis(eyePos.z - center.z, box.lengthZ / 2, Direction.NORTH, Direction.SOUTH)
5348
}
5449

5550
private fun EnumSet<Direction>.checkAxis(

0 commit comments

Comments
 (0)