PssbleTrngle / FlightLib

Creative Commons Zero v1.0 Universal
0 stars 1 forks source link

Weird behaviour of elytra boost #7

Open vlad-iakovlev opened 3 months ago

vlad-iakovlev commented 3 months ago

What happened?

I just tried your jetpack mod for Create and it works awesome. However, I noticed that elytra boost is too weak for me. I tried setting elytraBoost value to 2 and noticed that it works like fireworks, with delay. But it's different delay. It can ignore UP button click and I have to hold the button so it can be registered and processed. And usually I overboost with this setting :)

Looks like it was caused by calculating deltaMovement every 15 ticks: https://github.com/PssbleTrngle/FlightLib/blob/96bb6bf3ce9aac5c62afd8e8a8e1096424d1cb0d/common/src/main/kotlin/com/possible_triangle/flightlib/logic/JetpackLogic.kt#L107

I suggest these possible solutions:

  1. Processing first button press and then wait for 15 ticks until next press could be processed. Looks like some class property elytraBoostDelay set to 15 when boost was processed and then updating it in onTick method. Not sure actually if it will work, I'm not familiar with creating Minecraft mods. It could be just some other weird behaviour.
  2. Adjusting formula, so boost can be processes on every tick. Should work just fine and will provide experience similar to just flying with jetpack.

Also, I think it's a good idea to limit maximum elytra speed after boost, similar to fireworks.

Mod Version

create-jetpack-fabric 4.2.0

Minecraft Version

None

Forge Version

Fabric 0.15.11 on Minecraft 1.20.1

Relevant log output

No response

vlad-iakovlev commented 3 months ago

Just tried suggestion 2. I replaced

if (entity.level().gameTime % 15 == 0L) {
    val look = entity.lookAngle
    val factor = { i: Double -> (i * 0.1 + (i * boost - i) * 0.5) }
    entity.deltaMovement = entity.deltaMovement.add(
        factor(look.x),
        factor(look.y),
        factor(look.z),
    )
}

with:

val look = entity.lookAngle
val factor = { i: Double -> (i * boost * 0.01) }
entity.deltaMovement = entity.deltaMovement.add(
    factor(look.x),
    factor(look.y),
    factor(look.z),
)

and it worked just fine. Should produce similar values for default boost 1.25.

I can create a PR if you don't mind