@@ -31,46 +31,36 @@ object SafeWalk : Module(
31
31
32
32
var x = event.x
33
33
var z = event.z
34
- while (x != 0.0 && world.getCollisionBoxes(player, player.entityBoundingBox.offset(x, (- player.stepHeight).toDouble(), 0.0 )).isEmpty()) {
35
- if (x < 0.05 && x >= - 0.05 ) {
36
- x = 0.0
37
- } else if (x > 0.0 ) {
38
- x - = 0.05
39
- } else {
40
- x + = 0.05
41
- }
42
- }
43
- while (z != 0.0 && world.getCollisionBoxes(player, player.entityBoundingBox.offset(0.0 , (- player.stepHeight).toDouble(), z)).isEmpty()) {
44
- if (z < 0.05 && z >= - 0.05 ) {
45
- z = 0.0
46
- } else if (z > 0.0 ) {
47
- z - = 0.05
48
- } else {
49
- z + = 0.05
50
- }
34
+
35
+ var boundingBox = player.entityBoundingBox.offset(0.0 , (- player.stepHeight).toDouble(), 0.0 )
36
+
37
+ while (x != 0.0 && world.getCollisionBoxes(player, boundingBox.offset(x, 0.0 , 0.0 )).isEmpty()) {
38
+ x = updateCoordinate(x)
51
39
}
52
- while (x != 0.0 && z != 0.0 && world.getCollisionBoxes(player, player.entityBoundingBox.offset(x, (- player.stepHeight).toDouble(), z)).isEmpty()) {
53
- if (x < 0.05 && x >= - 0.05 ) {
54
- x = 0.0
55
- } else if (x > 0.0 ) {
56
- x - = 0.05
57
- } else {
58
- x + = 0.05
59
- }
60
- if (z < 0.05 && z >= - 0.05 ) {
61
- z = 0.0
62
- } else if (z > 0.0 ) {
63
- z - = 0.05
64
- } else {
65
- z + = 0.05
66
- }
40
+
41
+ boundingBox = boundingBox.offset(x, 0.0 , 0.0 )
42
+
43
+ while (z != 0.0 && world.getCollisionBoxes(player, boundingBox.offset(0.0 , 0.0 , z)).isEmpty()) {
44
+ z = updateCoordinate(z)
67
45
}
46
+
68
47
event.x = x
69
48
event.z = z
70
49
}
71
50
}
72
51
}
73
52
53
+ private fun updateCoordinate (coordinate : Double ): Double {
54
+ return if (coordinate < 0.05 && coordinate >= - 0.05 ) {
55
+ 0.0
56
+ } else if (coordinate > 0.0 ) {
57
+ coordinate - 0.05
58
+ } else {
59
+ coordinate + 0.05
60
+ }
61
+ }
62
+
63
+
74
64
private val isEdgeSafe: Boolean
75
65
get() = runSafeR {
76
66
val pos = player.flooredPosition.toVec3d(0.5 , 0.0 , 0.5 )
0 commit comments