Skip to content

Commit 3f05b90

Browse files
authored
Merge pull request #539 from nickcat325/master
Elytra Flight code refactor
2 parents 36b02e5 + 15077fe commit 3f05b90

File tree

2 files changed

+10
-22
lines changed

2 files changed

+10
-22
lines changed

src/main/kotlin/com/lambda/client/module/modules/misc/ElytraFix.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,6 @@ object ElytraFix : Module(
3535
&& entity.world.loadedEntityList
3636
.filterIsInstance<AccessorEntityFireworkRocket>()
3737
.any {
38-
it.boostedEntity.equals(entity)
38+
it.boostedEntity === entity
3939
}
4040
}

src/main/kotlin/com/lambda/client/module/modules/movement/ElytraFlight.kt

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,8 @@ object ElytraFlight : Module(
128128
private var boostingTick = 0
129129

130130
/* Vanilla mode state */
131-
private var lastY = 0.0
132-
private var shouldDescend = false
133-
private var lastHighY = 0.0
131+
private var firstY = 0.0
132+
private var secondY = 0.0
134133

135134
/* Event Listeners */
136135
init {
@@ -484,24 +483,13 @@ object ElytraFlight : Module(
484483
}
485484

486485
private fun SafeClientEvent.vanillaMode() {
487-
val playerY = player.posY
488-
val lastShouldDescend = shouldDescend
489-
val isBoosted = world.getLoadedEntityList().any { it is EntityFireworkRocket && it.boostedEntity == player }
490-
491-
shouldDescend = lastY > playerY && lastHighY - 60 < playerY
492-
493-
packetPitch = if (isBoosted) {
494-
-rocketPitch
495-
} else if (shouldDescend) {
496-
if (!lastShouldDescend) {
497-
lastHighY = playerY
498-
}
499-
downPitch
500-
} else {
501-
-upPitch
486+
secondY = player.posY
487+
packetPitch = when {
488+
world.loadedEntityList.any { it is EntityFireworkRocket && it.boostedEntity == player } -> -rocketPitch
489+
firstY - secondY > 0 -> downPitch
490+
else -> -upPitch
502491
}
503-
504-
lastY = playerY
492+
firstY = player.posY
505493
}
506494

507495
fun shouldSwing(): Boolean {
@@ -553,4 +541,4 @@ object ElytraFlight : Module(
553541
runSafe { reset(true) }
554542
}
555543
}
556-
}
544+
}

0 commit comments

Comments
 (0)