Skip to content

Elytra Flight code refactor #539

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ object ElytraFix : Module(
&& entity.world.loadedEntityList
.filterIsInstance<AccessorEntityFireworkRocket>()
.any {
it.boostedEntity.equals(entity)
it.boostedEntity === entity
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,8 @@ object ElytraFlight : Module(
private var boostingTick = 0

/* Vanilla mode state */
private var lastY = 0.0
private var shouldDescend = false
private var lastHighY = 0.0
private var firstY = 0.0
private var secondY = 0.0

/* Event Listeners */
init {
Expand Down Expand Up @@ -484,24 +483,13 @@ object ElytraFlight : Module(
}

private fun SafeClientEvent.vanillaMode() {
val playerY = player.posY
val lastShouldDescend = shouldDescend
val isBoosted = world.getLoadedEntityList().any { it is EntityFireworkRocket && it.boostedEntity == player }

shouldDescend = lastY > playerY && lastHighY - 60 < playerY

packetPitch = if (isBoosted) {
-rocketPitch
} else if (shouldDescend) {
if (!lastShouldDescend) {
lastHighY = playerY
}
downPitch
} else {
-upPitch
secondY = player.posY
packetPitch = when {
world.loadedEntityList.any { it is EntityFireworkRocket && it.boostedEntity == player } -> -rocketPitch
firstY - secondY > 0 -> downPitch
else -> -upPitch
}

lastY = playerY
firstY = player.posY
}

fun shouldSwing(): Boolean {
Expand Down Expand Up @@ -553,4 +541,4 @@ object ElytraFlight : Module(
runSafe { reset(true) }
}
}
}
}