Skip to content

Commit 87aa4ac

Browse files
committed
ElytraAttitudeControl: Improve firework detection method
1 parent e3c4bb4 commit 87aa4ac

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/main/kotlin/com/lambda/module/modules/movement/ElytraAttitudeControl.kt

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,14 @@ import com.lambda.module.Module
2323
import com.lambda.module.modules.movement.BetterFirework.startFirework
2424
import com.lambda.module.tag.ModuleTag
2525
import com.lambda.threading.runSafe
26+
import com.lambda.util.Communication.info
2627
import com.lambda.util.NamedEnum
2728
import com.lambda.util.SpeedUnit
2829
import com.lambda.util.Timer
30+
import com.lambda.util.world.fastEntitySearch
2931
import net.minecraft.client.network.ClientPlayerEntity
30-
import net.minecraft.entity.EntityType
32+
import net.minecraft.entity.projectile.FireworkRocketEntity
33+
import net.minecraft.text.Text
3134
import net.minecraft.util.math.Vec3d
3235
import kotlin.time.Duration.Companion.seconds
3336

@@ -75,7 +78,7 @@ object ElytraAttitudeControl : Module(
7578
init {
7679
listen<TickEvent.Pre> {
7780
if (!player.isGliding) return@listen
78-
if (player.hasFirework && disableOnFirework) return@listen
81+
if (disableOnFirework && player.hasFirework) return@listen
7982

8083
val outputPitch = when (controlValue) {
8184
Mode.Speed -> {
@@ -121,11 +124,7 @@ object ElytraAttitudeControl : Module(
121124
}
122125

123126
val ClientPlayerEntity.hasFirework: Boolean
124-
get() = clientWorld.getEntitiesByType(
125-
EntityType.FIREWORK_ROCKET,
126-
boundingBox.expand(4.0),
127-
{ it.distanceTo(this) < 4.0 }
128-
).isNotEmpty()
127+
get() = runSafe { return fastEntitySearch<FireworkRocketEntity>(4.0) { it.shooter == this.player }.any() } ?: false
129128

130129
class PIController(val valueP: () -> Double, val valueD: () -> Double, val valueI: () -> Double, val constant: () -> Double) {
131130
var accumulator = 0.0 // Integral term accumulator

0 commit comments

Comments
 (0)